Files
test/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

291 lines
9.2 KiB
C
Raw Normal View History

/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
2008-04-30 15:41:54 +00:00
#pragma once
2008-04-30 15:41:54 +00:00
/** \file
* \ingroup freestyle
* \brief Functions taking 1D input
*/
2008-04-30 15:41:54 +00:00
#include "AdvancedFunctions0D.h"
2008-04-30 15:41:54 +00:00
#include "../view_map/Functions1D.h"
2008-04-30 15:41:54 +00:00
//
// Functions definitions
//
///////////////////////////////////////////////////////////
Attempt to fix a potential name conflict between Freestyle and the compositor. A crash in the Freestyle renderer was reported by Ton on IRC with a stack trace below. Note that #2 is in Freestyle, whereas #1 is in the compositor. The problem was observed in a debug build on OS X 10.7 (gcc 4.2, openmp disabled, no llvm). ---------------------------------------------------------------------- Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: 13 at address: 0x0000000000000000 [Switching to process 72386 thread 0xf303] 0x0000000100c129f3 in NodeBase::~NodeBase (this=0x10e501c80) at COM_NodeBase.cpp:43 43 delete (this->m_outputsockets.back()); Current language: auto; currently c++ (gdb) where #0 0x0000000100c129f3 in NodeBase::~NodeBase (this=0x10e501c80) at COM_NodeBase.cpp:43 #1 0x0000000100c29066 in Node::~Node (this=0x10e501c80) at COM_Node.h:49 #2 0x000000010089c273 in NodeShape::~NodeShape (this=0x10e501c80) at NodeShape.cpp:43 #3 0x000000010089910b in NodeGroup::destroy (this=0x10e501da0) at NodeGroup.cpp:61 #4 0x00000001008990cd in NodeGroup::destroy (this=0x10e5014b0) at NodeGroup.cpp:59 #5 0x00000001008990cd in NodeGroup::destroy (this=0x114e18da0) at NodeGroup.cpp:59 #6 0x00000001007e6602 in Controller::ClearRootNode (this=0x114e19640) at Controller.cpp:329 #7 0x00000001007ea52e in Controller::LoadMesh (this=0x114e19640, re=0x10aba4638, srl=0x1140f5258) at Controller.cpp:302 #8 0x00000001008030ad in prepare (re=0x10aba4638, srl=0x1140f5258) at FRS_freestyle.cpp:302 #9 0x000000010080457a in FRS_do_stroke_rendering (re=0x10aba4638, srl=0x1140f5258) at FRS_freestyle.cpp:600 #10 0x00000001006aeb9d in add_freestyle (re=0x10aba4638) at pipeline.c:1584 #11 0x00000001006aceb7 in do_render_3d (re=0x10aba4638) at pipeline.c:1094 #12 0x00000001006ae061 in do_render_fields_blur_3d (re=0x10aba4638) at pipeline.c:1367 #13 0x00000001006afa16 in do_render_composite_fields_blur_3d (re=0x10aba4638) at pipeline.c:1815 #14 0x00000001006b04e4 in do_render_all_options (re=0x10aba4638) at pipeline.c:2021 ---------------------------------------------------------------------- Apparently a name conflict between the two Blender modules is taking place. The present commit hence intends to address it by putting all the Freestyle C++ classes in the namespace 'Freestyle'. This revision will also prevent potential name conflicts with other Blender modules in the future. Special thanks to Lukas Toenne for the help with C++ namespace.
2013-04-09 00:46:49 +00:00
namespace Freestyle {
2008-04-30 15:41:54 +00:00
namespace Functions1D {
// DensityF1D
/*! Returns the density evaluated for an Interface1D.
* The density is evaluated for a set of points along the Interface1D (using the DensityF0D
* functor) with a user-defined sampling and then integrated into a single value using a
* user-defined integration method.
*/
class DensityF1D : public UnaryFunction1D<double> {
private:
float _sampling;
public:
/*! Builds the functor.
* \param sigma:
* Thesigma used in DensityF0D and determining the window size used in each density query.
* \param iType:
* The integration method used to compute a single value from a set of values.
* \param sampling:
* The resolution used to sample the chain: the corresponding 0D function is evaluated at each
* sample point and the result is obtained by combining the resulting values into a single one,
* following the method specified by iType.
*/
DensityF1D(double sigma = 2, IntegrationType iType = MEAN, float sampling = 2.0f)
: UnaryFunction1D<double>(iType), _fun(sigma)
{
_sampling = sampling;
}
/*! Destructor */
virtual ~DensityF1D()
{
}
/*! Returns the string "DensityF1D"*/
string getName() const
{
return "DensityF1D";
}
/*! the () operator.*/
int operator()(Interface1D &inter)
{
result = integrate(
_fun, inter.pointsBegin(_sampling), inter.pointsEnd(_sampling), _integration);
return 0;
}
private:
Functions0D::DensityF0D _fun;
};
// LocalAverageDepthF1D
/*! Returns the average depth evaluated for an Interface1D.
* The average depth is evaluated for a set of points along the Interface1D (using the
* LocalAverageDepthF0D functor) with a user-defined sampling and then integrated into a single
* value using a user-defined integration method.
*/
class LocalAverageDepthF1D : public UnaryFunction1D<double> {
public:
/*! Builds the functor.
* \param sigma:
* The sigma used in DensityF0D and determining the window size used in each density query.
* \param iType:
* The integration method used to compute a single value from a set of values.
*/
LocalAverageDepthF1D(real sigma, IntegrationType iType = MEAN)
: UnaryFunction1D<double>(iType), _fun(sigma)
{
}
/*! Returns the string "LocalAverageDepthF1D" */
string getName() const
{
return "LocalAverageDepthF1D";
}
/*! the () operator. */
int operator()(Interface1D &inter)
{
result = integrate(_fun, inter.verticesBegin(), inter.verticesEnd(), _integration);
return 0;
}
private:
Functions0D::LocalAverageDepthF0D _fun;
};
// GetCompleteViewMapDensity
/*! Returns the density evaluated for an Interface1D in the complete viewmap image.
* The density is evaluated for a set of points along the Interface1D (using the
* ReadCompleteViewMapPixelF0D functor) and then integrated into a single value using a
* user-defined integration method.
*/
class GetCompleteViewMapDensityF1D : public UnaryFunction1D<double> {
public:
/*! Builds the functor.
* \param level:
2018-06-17 17:05:14 +02:00
* The level of the pyramid from which
* the pixel must be read.
* \param iType:
* The integration method used to compute
* a single value from a set of values.
* \param sampling:
* The resolution used to sample the chain: the corresponding 0D function
* is evaluated at each sample point and the result is obtained by
* combining the resulting values into a single one, following the
* method specified by iType.
*/
GetCompleteViewMapDensityF1D(unsigned level, IntegrationType iType = MEAN, float sampling = 2.0f)
: UnaryFunction1D<double>(iType), _fun(level)
{
_sampling = sampling;
}
/*! Returns the string "GetCompleteViewMapDensityF1D" */
string getName() const
{
return "GetCompleteViewMapDensityF1D";
}
/*! the () operator. */
int operator()(Interface1D &inter);
private:
Functions0D::ReadCompleteViewMapPixelF0D _fun;
float _sampling;
};
// GetDirectionalViewMapDensity
/*! Returns the density evaluated for an Interface1D in of the steerable viewmaps image.
2015-07-06 14:18:03 +10:00
* The direction telling which Directional map to choose is explicitly specified by the user.
* The density is evaluated for a set of points along the Interface1D
* (using the ReadSteerableViewMapPixelF0D functor)
* and then integrated into a single value using a user-defined integration method.
*/
class GetDirectionalViewMapDensityF1D : public UnaryFunction1D<double> {
public:
/*! Builds the functor.
* \param iOrientation:
* The number of the directional map we must work with.
* \param level:
* The level of the pyramid from which the pixel must be read.
* \param iType:
* The integration method used to compute a single value from a set of values.
* \param sampling:
* The resolution used to sample the chain: the corresponding 0D function is evaluated at
* each sample point and the result is obtained by combining the resulting values into a
* single one, following the method specified by iType.
*/
GetDirectionalViewMapDensityF1D(unsigned iOrientation,
unsigned level,
IntegrationType iType = MEAN,
float sampling = 2.0f)
: UnaryFunction1D<double>(iType), _fun(iOrientation, level)
{
_sampling = sampling;
}
/*! Returns the string "GetDirectionalViewMapDensityF1D" */
string getName() const
{
return "GetDirectionalViewMapDensityF1D";
}
/*! the () operator. */
int operator()(Interface1D &inter);
private:
Functions0D::ReadSteerableViewMapPixelF0D _fun;
float _sampling;
};
// GetSteerableViewMapDensityF1D
/*! Returns the density of the viewmap for a given Interface1D. The density of each FEdge is
2019-08-04 12:51:44 +10:00
* evaluated in the proper steerable ViewMap depending on its orientation.
*/
class GetSteerableViewMapDensityF1D : public UnaryFunction1D<double> {
private:
int _level;
float _sampling;
public:
/*! Builds the functor from the level of the pyramid from which the pixel must be read.
* \param level:
* The level of the pyramid from which the pixel must be read.
* \param iType:
* The integration method used to compute a single value from a set of values.
* \param sampling:
* The resolution used to sample the chain: the corresponding 0D function is evaluated at each
* sample point and the result is obtained by combining the resulting values into a single one,
* following the method specified by iType.
*/
GetSteerableViewMapDensityF1D(int level, IntegrationType iType = MEAN, float sampling = 2.0f)
: UnaryFunction1D<double>(iType)
{
_level = level;
_sampling = sampling;
}
/*! Destructor */
virtual ~GetSteerableViewMapDensityF1D()
{
}
/*! Returns the string "GetSteerableViewMapDensityF1D" */
string getName() const
{
return "GetSteerableViewMapDensityF1D";
}
/*! the () operator. */
int operator()(Interface1D &inter);
};
// GetViewMapGradientNormF1D
/*! Returns the density of the viewmap for a given Interface1D. The density of each FEdge is
2019-08-11 22:41:04 +10:00
* evaluated in the proper steerable ViewMap depending on its orientation.
*/
class GetViewMapGradientNormF1D : public UnaryFunction1D<double> {
private:
int _level;
float _sampling;
Functions0D::GetViewMapGradientNormF0D _func;
public:
/*! Builds the functor from the level of the pyramid from which the pixel must be read.
* \param level:
* The level of the pyramid from which the pixel must be read.
* \param iType:
* The integration method used to compute a single value from a set of values.
* \param sampling:
* The resolution used to sample the chain: the corresponding 0D function is evaluated at each
* sample point and the result is obtained by combining the resulting values into a single
* one, following the method specified by iType.
*/
GetViewMapGradientNormF1D(int level, IntegrationType iType = MEAN, float sampling = 2.0f)
: UnaryFunction1D<double>(iType), _func(level)
{
_level = level;
_sampling = sampling;
}
/*! Returns the string "GetSteerableViewMapDensityF1D" */
string getName() const
{
return "GetViewMapGradientNormF1D";
}
/*! the () operator. */
int operator()(Interface1D &inter);
};
2008-04-30 15:41:54 +00:00
} // end of namespace Functions1D
Attempt to fix a potential name conflict between Freestyle and the compositor. A crash in the Freestyle renderer was reported by Ton on IRC with a stack trace below. Note that #2 is in Freestyle, whereas #1 is in the compositor. The problem was observed in a debug build on OS X 10.7 (gcc 4.2, openmp disabled, no llvm). ---------------------------------------------------------------------- Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: 13 at address: 0x0000000000000000 [Switching to process 72386 thread 0xf303] 0x0000000100c129f3 in NodeBase::~NodeBase (this=0x10e501c80) at COM_NodeBase.cpp:43 43 delete (this->m_outputsockets.back()); Current language: auto; currently c++ (gdb) where #0 0x0000000100c129f3 in NodeBase::~NodeBase (this=0x10e501c80) at COM_NodeBase.cpp:43 #1 0x0000000100c29066 in Node::~Node (this=0x10e501c80) at COM_Node.h:49 #2 0x000000010089c273 in NodeShape::~NodeShape (this=0x10e501c80) at NodeShape.cpp:43 #3 0x000000010089910b in NodeGroup::destroy (this=0x10e501da0) at NodeGroup.cpp:61 #4 0x00000001008990cd in NodeGroup::destroy (this=0x10e5014b0) at NodeGroup.cpp:59 #5 0x00000001008990cd in NodeGroup::destroy (this=0x114e18da0) at NodeGroup.cpp:59 #6 0x00000001007e6602 in Controller::ClearRootNode (this=0x114e19640) at Controller.cpp:329 #7 0x00000001007ea52e in Controller::LoadMesh (this=0x114e19640, re=0x10aba4638, srl=0x1140f5258) at Controller.cpp:302 #8 0x00000001008030ad in prepare (re=0x10aba4638, srl=0x1140f5258) at FRS_freestyle.cpp:302 #9 0x000000010080457a in FRS_do_stroke_rendering (re=0x10aba4638, srl=0x1140f5258) at FRS_freestyle.cpp:600 #10 0x00000001006aeb9d in add_freestyle (re=0x10aba4638) at pipeline.c:1584 #11 0x00000001006aceb7 in do_render_3d (re=0x10aba4638) at pipeline.c:1094 #12 0x00000001006ae061 in do_render_fields_blur_3d (re=0x10aba4638) at pipeline.c:1367 #13 0x00000001006afa16 in do_render_composite_fields_blur_3d (re=0x10aba4638) at pipeline.c:1815 #14 0x00000001006b04e4 in do_render_all_options (re=0x10aba4638) at pipeline.c:2021 ---------------------------------------------------------------------- Apparently a name conflict between the two Blender modules is taking place. The present commit hence intends to address it by putting all the Freestyle C++ classes in the namespace 'Freestyle'. This revision will also prevent potential name conflicts with other Blender modules in the future. Special thanks to Lukas Toenne for the help with C++ namespace.
2013-04-09 00:46:49 +00:00
} /* namespace Freestyle */