Blender V4.3
Freestyle::Operators Class Reference

#include <Operators.h>

Public Types

typedef vector< Interface1D * > I1DContainer
 
typedef vector< Stroke * > StrokesContainer
 

Static Public Member Functions

static int select (UnaryPredicate1D &pred)
 
static int chain (ViewEdgeInternal::ViewEdgeIterator &it, UnaryPredicate1D &pred, UnaryFunction1D_void &modifier)
 
static int chain (ViewEdgeInternal::ViewEdgeIterator &it, UnaryPredicate1D &pred)
 
static int bidirectionalChain (ChainingIterator &it, UnaryPredicate1D &pred)
 
static int bidirectionalChain (ChainingIterator &it)
 
static int sequentialSplit (UnaryPredicate0D &startingPred, UnaryPredicate0D &stoppingPred, float sampling=0.0f)
 
static int sequentialSplit (UnaryPredicate0D &pred, float sampling=0.0f)
 
static int recursiveSplit (UnaryFunction0D< double > &func, UnaryPredicate1D &pred, float sampling=0)
 
static int recursiveSplit (UnaryFunction0D< double > &func, UnaryPredicate0D &pred0d, UnaryPredicate1D &pred, float sampling=0.0f)
 
static int sort (BinaryPredicate1D &pred)
 
static int create (UnaryPredicate1D &pred, vector< StrokeShader * > shaders)
 
static ViewEdgegetViewEdgeFromIndex (uint i)
 
static ChaingetChainFromIndex (uint i)
 
static StrokegetStrokeFromIndex (uint i)
 
static uint getViewEdgesSize ()
 
static uint getChainsSize ()
 
static uint getStrokesSize ()
 
static StrokesContainergetStrokesSet ()
 
static void reset (bool removeStrokes=true)
 

Detailed Description

Class defining the operators used in a style module. There are 4 classes of operators: Selection, Chaining, Splitting and Creating. All these operators are user controlled in the scripting language through Functors, Predicates and Shaders that are taken as arguments.

Definition at line 37 of file Operators.h.

Member Typedef Documentation

◆ I1DContainer

Definition at line 40 of file Operators.h.

◆ StrokesContainer

Definition at line 41 of file Operators.h.

Member Function Documentation

◆ bidirectionalChain() [1/2]

int Freestyle::Operators::bidirectionalChain ( ChainingIterator & it)
static

The only difference with the above bidirectional chaining algorithm is that we don't need to pass a stopping criterion. This might be desirable when the stopping criterion is already contained in the iterator definition. Builds a set of chains from the current set of ViewEdges. Each ViewEdge of the current list potentially starts a new chain. The chaining operator then iterates over the ViewEdges of the ViewMap using the user specified iterator. This operator iterates both using the increment and decrement operators and is therefore bidirectional. This operator works with a ChainingIterator which contains the chaining rules. It is this last one which can be told to chain only edges that belong to the selection or not to process twice a ViewEdge during the chaining. Each time a ViewEdge is added to a chain, its chaining time stamp is incremented. This allows you to keep track of the number of chains to which a ViewEdge belongs to.

Parameters
itThe ChainingIterator on the ViewEdges of the ViewMap. It contains the chaining rule.

Definition at line 427 of file Operators.cpp.

References error(), Freestyle::TimeStamp::instance(), Freestyle::Chain::push_viewedge_back(), Freestyle::Chain::push_viewedge_front(), and Freestyle::UnaryPredicate1D::result.

◆ bidirectionalChain() [2/2]

int Freestyle::Operators::bidirectionalChain ( ChainingIterator & it,
UnaryPredicate1D & pred )
static

Builds a set of chains from the current set of ViewEdges. Each ViewEdge of the current list potentially starts a new chain. The chaining operator then iterates over the ViewEdges of the ViewMap using the user specified iterator. This operator iterates both using the increment and decrement operators and is therefore bidirectional. This operator works with a ChainingIterator which contains the chaining rules. It is this last one which can be told to chain only edges that belong to the selection or not to process twice a ViewEdge during the chaining. Each time a ViewEdge is added to a chain, its chaining time stamp is incremented. This allows you to keep track of the number of chains to which a ViewEdge belongs to.

Parameters
itThe ChainingIterator on the ViewEdges of the ViewMap. It contains the chaining rule.
predThe predicate on the ViewEdge that expresses the stopping condition.

Definition at line 323 of file Operators.cpp.

References error(), Freestyle::TimeStamp::instance(), Freestyle::Chain::push_viewedge_back(), Freestyle::Chain::push_viewedge_front(), and Freestyle::UnaryPredicate1D::result.

Referenced by Operators_bidirectional_chain().

◆ chain() [1/2]

int Freestyle::Operators::chain ( ViewEdgeInternal::ViewEdgeIterator & it,
UnaryPredicate1D & pred )
static

Builds a set of chains from the current set of ViewEdges. Each ViewEdge of the current list starts a new chain. The chaining operator then iterates over the ViewEdges of the ViewMap using the user specified iterator. This operator only iterates using the increment operator and is therefore unidirectional. This chaining operator is different from the previous one because it doesn't take any modifier as argument. Indeed, the time stamp (insuring that a ViewEdge is processed one time) is automatically managed in this case.

Parameters
itThe iterator on the ViewEdges of the ViewMap. It contains the chaining rule.
predThe predicate on the ViewEdge that expresses the stopping condition.

Definition at line 139 of file Operators.cpp.

References error(), Freestyle::TimeStamp::instance(), Freestyle::Chain::push_viewedge_back(), and Freestyle::UnaryPredicate1D::result.

◆ chain() [2/2]

int Freestyle::Operators::chain ( ViewEdgeInternal::ViewEdgeIterator & it,
UnaryPredicate1D & pred,
UnaryFunction1D_void & modifier )
static

Builds a set of chains from the current set of ViewEdges. Each ViewEdge of the current list starts a new chain. The chaining operator then iterates over the ViewEdges of the ViewMap using the user specified iterator. This operator only iterates using the increment operator and is therefore unidirectional.

Parameters
itThe iterator on the ViewEdges of the ViewMap. It contains the chaining rule.
predThe predicate on the ViewEdge that expresses the stopping condition.
modifierA function that takes a ViewEdge as argument and that is used to modify the processed ViewEdge state (the timestamp incrementation is a typical illustration of such a modifier)

Definition at line 72 of file Operators.cpp.

References error(), Freestyle::Chain::push_viewedge_back(), and Freestyle::UnaryPredicate1D::result.

Referenced by Operators_chain().

◆ create()

int Freestyle::Operators::create ( UnaryPredicate1D & pred,
vector< StrokeShader * > shaders )
static

Creates and shades the strokes from the current set of chains. A predicate can be specified to make a selection pass on the chains.

Parameters
predThe predicate that a chain must verify in order to be transform as a stroke
shadersThe list of shaders used to shade the strokes

Definition at line 1271 of file Operators.cpp.

References Freestyle::applyShading(), Freestyle::createStroke(), error(), and Freestyle::UnaryPredicate1D::result.

Referenced by Operators_create().

◆ getChainFromIndex()

static Chain * Freestyle::Operators::getChainFromIndex ( uint i)
inlinestatic

Definition at line 227 of file Operators.h.

Referenced by Operators_get_chain_from_index().

◆ getChainsSize()

static uint Freestyle::Operators::getChainsSize ( )
inlinestatic

Definition at line 242 of file Operators.h.

Referenced by Operators_get_chain_from_index(), and Operators_get_chains_size().

◆ getStrokeFromIndex()

static Stroke * Freestyle::Operators::getStrokeFromIndex ( uint i)
inlinestatic

Definition at line 232 of file Operators.h.

Referenced by Operators_get_stroke_from_index().

◆ getStrokesSet()

static StrokesContainer * Freestyle::Operators::getStrokesSet ( )
inlinestatic

Definition at line 257 of file Operators.h.

Referenced by Freestyle::StyleModule::execute().

◆ getStrokesSize()

static uint Freestyle::Operators::getStrokesSize ( )
inlinestatic

Definition at line 247 of file Operators.h.

Referenced by Operators_get_stroke_from_index(), and Operators_get_strokes_size().

◆ getViewEdgeFromIndex()

static ViewEdge * Freestyle::Operators::getViewEdgeFromIndex ( uint i)
inlinestatic

Definition at line 222 of file Operators.h.

Referenced by Operators_get_viewedge_from_index().

◆ getViewEdgesSize()

static uint Freestyle::Operators::getViewEdgesSize ( )
inlinestatic

◆ recursiveSplit() [1/2]

int Freestyle::Operators::recursiveSplit ( UnaryFunction0D< double > & func,
UnaryPredicate0D & pred0d,
UnaryPredicate1D & pred,
float sampling = 0.0f )
static

Splits the current set of chains in a recursive way. We process the points of each chain (with a specified sampling) to find the point minimizing a specified function. The chain is split in two at this point and the two new chains are processed in the same way. The user can specify a 0D predicate to make a first selection on the points that can potentially be split. A point that doesn't verify the 0D predicate won't be candidate in realizing the min. The recursivity level is controlled through a predicate 1D that expresses a stopping condition on the chain that is about to be processed.

Parameters
funcThe Unary Function evaluated at each point of the chain. The splitting point is the point minimizing this function
pred0dThe Unary Predicate 0D used to select the candidate points where the split can occur. For example, it is very likely that would rather have your chain splitting around its middle point than around one of its extremities. A 0D predicate working on the curvilinear abscissa allows to add this kind of constraints.
predThe Unary Predicate ex pressing the recursivity stopping condition. This predicate is evaluated for each curve before it actually gets split. If pred(chain) is true, the curve won't be split anymore.
samplingThe resolution used to sample the chain for the predicates evaluation. (The chain is not actually resampled, a virtual point only progresses along the curve using this resolution)

Definition at line 985 of file Operators.cpp.

References Freestyle::__recursiveSplit(), Freestyle::M_EPSILON, and Freestyle::UnaryPredicate1D::result.

◆ recursiveSplit() [2/2]

int Freestyle::Operators::recursiveSplit ( UnaryFunction0D< double > & func,
UnaryPredicate1D & pred,
float sampling = 0 )
static

Splits the current set of chains in a recursive way. We process the points of each chain (with a specified sampling) to find the point minimizing a specified function. The chain is split in two at this point and the two new chains are processed in the same way. The recursivity level is controlled through a predicate 1D that expresses a stopping condition on the chain that is about to be processed.

Parameters
funcThe Unary Function evaluated at each point of the chain. The splitting point is the point minimizing this function
predThe Unary Predicate ex pressing the recursivity stopping condition. This predicate is evaluated for each curve before it actually gets split. If pred(chain) is true, the curve won't be split anymore.
samplingThe resolution used to sample the chain for the predicates evaluation. (The chain is not actually resampled, a virtual point only progresses along the curve using this resolution)

Definition at line 801 of file Operators.cpp.

References Freestyle::__recursiveSplit(), Freestyle::M_EPSILON, and Freestyle::UnaryPredicate1D::result.

Referenced by Operators_recursive_split().

◆ reset()

void Freestyle::Operators::reset ( bool removeStrokes = true)
static

◆ select()

int Freestyle::Operators::select ( UnaryPredicate1D & pred)
static

Selects the ViewEdges of the ViewMap verifying a specified condition.

Parameters
predThe predicate expressing this condition

Definition at line 30 of file Operators.cpp.

References Freestyle::UnaryPredicate1D::result.

Referenced by Operators_select().

◆ sequentialSplit() [1/2]

int Freestyle::Operators::sequentialSplit ( UnaryPredicate0D & pred,
float sampling = 0.0f )
static

Splits each chain of the current set of chains in a sequential way. The points of each chain are processed (with a specified sampling) sequentially and each time a user specified condition is verified, the chain is split into two chains. The resulting set of chains is a partition of the initial chain

Parameters
predThe predicate on a point that expresses the splitting condition
samplingThe resolution used to sample the chain for the predicate evaluation. (The chain is not actually resampled, a virtual point only progresses along the curve using this resolution)

Definition at line 508 of file Operators.cpp.

References error(), Freestyle::Id::getSecond(), Freestyle::M_EPSILON, Freestyle::Curve::nSegments(), point, Freestyle::Curve::push_vertex_back(), Freestyle::UnaryPredicate0D::result, and Freestyle::Id::setSecond().

◆ sequentialSplit() [2/2]

int Freestyle::Operators::sequentialSplit ( UnaryPredicate0D & startingPred,
UnaryPredicate0D & stoppingPred,
float sampling = 0.0f )
static

Splits each chain of the current set of chains in a sequential way. The points of each chain are processed (with a specified sampling) sequentially. Each time a user specified starting condition is verified, a new chain begins and ends as soon as a user-defined stopping predicate is verified. This allows chains overlapping rather than chains partitioning. The first point of the initial chain is the first point of one of the resulting chains. The splitting ends when no more chain can start.

Parameters
startingPredThe predicate on a point that expresses the starting condition
stoppingPredThe predicate on a point that expresses the stopping condition
samplingThe resolution used to sample the chain for the predicates evaluation. (The chain is not actually resampled, a virtual point only progresses along the curve using this resolution)

Definition at line 590 of file Operators.cpp.

References ELEM, error(), Freestyle::Id::getSecond(), Freestyle::M_EPSILON, Freestyle::Curve::nSegments(), point, Freestyle::Curve::push_vertex_back(), Freestyle::UnaryPredicate0D::result, and Freestyle::Id::setSecond().

Referenced by Operators_sequential_split().

◆ sort()

int Freestyle::Operators::sort ( BinaryPredicate1D & pred)
static

Sorts the current set of chains (or view-edges) according to the comparison predicate given as argument.

Parameters
predThe binary predicate used for the comparison

Definition at line 1066 of file Operators.cpp.

References e.

Referenced by Operators_sort().


The documentation for this class was generated from the following files: