48 "Class defining the operators used in a style module. There are five\n"
49 "types of operators: Selection, chaining, splitting, sorting and\n"
50 "creation. All these operators are user controlled through functors,\n"
51 "predicates and shaders that are taken as arguments.");
55 Py_TYPE(
self)->tp_free((PyObject *)
self);
59 ".. staticmethod:: select(pred)\n"
61 " Selects the ViewEdges of the ViewMap verifying a specified\n"
64 " :arg pred: The predicate expressing this condition.\n"
65 " :type pred: :class:`UnaryPredicate1D`");
69 static const char *kwlist[] = {
"pred",
nullptr};
70 PyObject *obj =
nullptr;
72 if (!PyArg_ParseTupleAndKeywords(
77 PyErr_SetString(PyExc_TypeError,
78 "Operators.select(): 1st argument: invalid UnaryPredicate1D object");
82 if (!PyErr_Occurred()) {
83 PyErr_SetString(PyExc_RuntimeError,
"Operators.select() failed");
91 ".. staticmethod:: chain(it, pred, modifier)\n"
94 " Builds a set of chains from the current set of ViewEdges. Each\n"
95 " ViewEdge of the current list starts a new chain. The chaining\n"
96 " operator then iterates over the ViewEdges of the ViewMap using the\n"
97 " user specified iterator. This operator only iterates using the\n"
98 " increment operator and is therefore unidirectional.\n"
100 " :arg it: The iterator on the ViewEdges of the ViewMap. It contains\n"
101 " the chaining rule.\n"
102 " :type it: :class:`ViewEdgeIterator`\n"
103 " :arg pred: The predicate on the ViewEdge that expresses the\n"
104 " stopping condition.\n"
105 " :type pred: :class:`UnaryPredicate1D`\n"
106 " :arg modifier: A function that takes a ViewEdge as argument and\n"
107 " that is used to modify the processed ViewEdge state (the\n"
108 " timestamp incrementation is a typical illustration of such a modifier).\n"
109 " If this argument is not given, the time stamp is automatically managed.\n"
110 " :type modifier: :class:`UnaryFunction1DVoid`\n");
114 static const char *kwlist[] = {
"it",
"pred",
"modifier",
nullptr};
115 PyObject *obj1 =
nullptr, *obj2 =
nullptr, *obj3 =
nullptr;
117 if (!PyArg_ParseTupleAndKeywords(args,
130 PyErr_SetString(PyExc_TypeError,
131 "Operators.chain(): 1st argument: invalid ChainingIterator object");
135 PyErr_SetString(PyExc_TypeError,
136 "Operators.chain(): 2nd argument: invalid UnaryPredicate1D object");
142 if (!PyErr_Occurred()) {
143 PyErr_SetString(PyExc_RuntimeError,
"Operators.chain() failed");
150 PyErr_SetString(PyExc_TypeError,
151 "Operators.chain(): 3rd argument: invalid UnaryFunction1DVoid object");
157 if (!PyErr_Occurred()) {
158 PyErr_SetString(PyExc_RuntimeError,
"Operators.chain() failed");
167 ".. staticmethod:: bidirectional_chain(it, pred)\n"
168 " bidirectional_chain(it)\n"
170 " Builds a set of chains from the current set of ViewEdges. Each\n"
171 " ViewEdge of the current list potentially starts a new chain. The\n"
172 " chaining operator then iterates over the ViewEdges of the ViewMap\n"
173 " using the user specified iterator. This operator iterates both using\n"
174 " the increment and decrement operators and is therefore bidirectional.\n"
175 " This operator works with a ChainingIterator which contains the\n"
176 " chaining rules. It is this last one which can be told to chain only\n"
177 " edges that belong to the selection or not to process twice a ViewEdge\n"
178 " during the chaining. Each time a ViewEdge is added to a chain, its\n"
179 " chaining time stamp is incremented. This allows you to keep track of\n"
180 " the number of chains to which a ViewEdge belongs to.\n"
182 " :arg it: The ChainingIterator on the ViewEdges of the ViewMap. It\n"
183 " contains the chaining rule.\n"
184 " :type it: :class:`ChainingIterator`\n"
185 " :arg pred: The predicate on the ViewEdge that expresses the stopping condition.\n"
186 " This parameter is optional, you make not want to pass a stopping criterion\n"
187 " when the stopping criterion is already contained in the iterator definition.\n"
188 " :type pred: :class:`UnaryPredicate1D`\n");
194 static const char *kwlist[] = {
"it",
"pred",
nullptr};
195 PyObject *obj1 =
nullptr, *obj2 =
nullptr;
197 if (!PyArg_ParseTupleAndKeywords(args,
210 "Operators.bidirectional_chain(): 1st argument: invalid ChainingIterator object");
215 if (!PyErr_Occurred()) {
216 PyErr_SetString(PyExc_RuntimeError,
"Operators.bidirectional_chain() failed");
225 "Operators.bidirectional_chain(): 2nd argument: invalid UnaryPredicate1D object");
230 if (!PyErr_Occurred()) {
231 PyErr_SetString(PyExc_RuntimeError,
"Operators.bidirectional_chain() failed");
240 ".. staticmethod:: sequential_split(starting_pred, stopping_pred, sampling=0.0)\n"
241 " sequential_split(pred, sampling=0.0)\n"
243 " Splits each chain of the current set of chains in a sequential way.\n"
244 " The points of each chain are processed (with a specified sampling)\n"
245 " sequentially. The first point of the initial chain is the\n"
246 " first point of one of the resulting chains. The splitting ends when\n"
247 " no more chain can start.\n"
251 " By specifying a starting and stopping predicate allows\n"
252 " the chains to overlap rather than chains partitioning.\n"
254 " :arg starting_pred: The predicate on a point that expresses the\n"
255 " starting condition. Each time this condition is verified, a new chain begins\n"
256 " :type starting_pred: :class:`UnaryPredicate0D`\n"
257 " :arg stopping_pred: The predicate on a point that expresses the\n"
258 " stopping condition. The chain ends as soon as this predicate is verified.\n"
259 " :type stopping_pred: :class:`UnaryPredicate0D`\n"
260 " :arg pred: The predicate on a point that expresses the splitting condition.\n"
261 " Each time the condition is verified, the chain is split into two chains.\n"
262 " The resulting set of chains is a partition of the initial chain\n"
263 " :type pred: :class:`UnaryPredicate0D`\n"
264 " :arg sampling: The resolution used to sample the chain for the\n"
265 " predicates evaluation. (The chain is not actually resampled;\n"
266 " a virtual point only progresses along the curve using this\n"
268 " :type sampling: float\n");
274 static const char *kwlist_1[] = {
"starting_pred",
"stopping_pred",
"sampling",
nullptr};
275 static const char *kwlist_2[] = {
"pred",
"sampling",
nullptr};
276 PyObject *obj1 =
nullptr, *obj2 =
nullptr;
279 if (PyArg_ParseTupleAndKeywords(args,
291 "Operators.sequential_split(): 1st argument: invalid UnaryPredicate0D object");
297 "Operators.sequential_split(): 2nd argument: invalid UnaryPredicate0D object");
303 if (!PyErr_Occurred()) {
304 PyErr_SetString(PyExc_RuntimeError,
"Operators.sequential_split() failed");
309 else if ((
void)PyErr_Clear(),
311 PyArg_ParseTupleAndKeywords(
316 "Operators.sequential_split(): 1st argument: invalid UnaryPredicate0D object");
320 if (!PyErr_Occurred()) {
321 PyErr_SetString(PyExc_RuntimeError,
"Operators.sequential_split() failed");
327 PyErr_SetString(PyExc_TypeError,
"invalid argument(s)");
334 Operators_recursive_split_doc,
335 ".. staticmethod:: recursive_split(func, pred_1d, sampling=0.0)\n"
336 " recursive_split(func, pred_0d, pred_1d, sampling=0.0)\n"
338 " Splits the current set of chains in a recursive way. We process the\n"
339 " points of each chain (with a specified sampling) to find the point\n"
340 " minimizing a specified function. The chain is split in two at this\n"
341 " point and the two new chains are processed in the same way. The\n"
342 " recursivity level is controlled through a predicate 1D that expresses\n"
343 " a stopping condition on the chain that is about to be processed.\n"
345 " The user can also specify a 0D predicate to make a first selection on the points\n"
346 " that can potentially be split. A point that doesn't verify the 0D\n"
347 " predicate won't be candidate in realizing the min.\n"
349 " :arg func: The Unary Function evaluated at each point of the chain.\n"
350 " The splitting point is the point minimizing this function.\n"
351 " :type func: :class:`UnaryFunction0DDouble`\n"
352 " :arg pred_0d: The Unary Predicate 0D used to select the candidate\n"
353 " points where the split can occur. For example, it is very likely\n"
354 " that would rather have your chain splitting around its middle\n"
355 " point than around one of its extremities. A 0D predicate working\n"
356 " on the curvilinear abscissa allows to add this kind of constraints.\n"
357 " :type pred_0d: :class:`UnaryPredicate0D`\n"
358 " :arg pred_1d: The Unary Predicate expressing the recursivity stopping\n"
359 " condition. This predicate is evaluated for each curve before it\n"
360 " actually gets split. If pred_1d(chain) is true, the curve won't be\n"
362 " :type pred_1d: :class:`UnaryPredicate1D`\n"
363 " :arg sampling: The resolution used to sample the chain for the\n"
364 " predicates evaluation. (The chain is not actually resampled; a\n"
365 " virtual point only progresses along the curve using this\n"
367 " :type sampling: float\n");
373 static const char *kwlist_1[] = {
"func",
"pred_1d",
"sampling",
nullptr};
374 static const char *kwlist_2[] = {
"func",
"pred_0d",
"pred_1d",
"sampling",
nullptr};
375 PyObject *obj1 =
nullptr, *obj2 =
nullptr, *obj3 =
nullptr;
378 if (PyArg_ParseTupleAndKeywords(args,
390 "Operators.recursive_split(): 1st argument: invalid UnaryFunction0DDouble object");
396 "Operators.recursive_split(): 2nd argument: invalid UnaryPredicate1D object");
402 if (!PyErr_Occurred()) {
403 PyErr_SetString(PyExc_RuntimeError,
"Operators.recursive_split() failed");
408 else if ((
void)PyErr_Clear(),
410 PyArg_ParseTupleAndKeywords(args,
424 "Operators.recursive_split(): 1st argument: invalid UnaryFunction0DDouble object");
430 "Operators.recursive_split(): 2nd argument: invalid UnaryPredicate0D object");
436 "Operators.recursive_split(): 3rd argument: invalid UnaryPredicate1D object");
443 if (!PyErr_Occurred()) {
444 PyErr_SetString(PyExc_RuntimeError,
"Operators.recursive_split() failed");
450 PyErr_SetString(PyExc_TypeError,
"invalid argument(s)");
457 ".. staticmethod:: sort(pred)\n"
459 " Sorts the current set of chains (or viewedges) according to the\n"
460 " comparison predicate given as argument.\n"
462 " :arg pred: The binary predicate used for the comparison.\n"
463 " :type pred: :class:`BinaryPredicate1D`");
467 static const char *kwlist[] = {
"pred",
nullptr};
468 PyObject *obj =
nullptr;
470 if (!PyArg_ParseTupleAndKeywords(
475 PyErr_SetString(PyExc_TypeError,
476 "Operators.sort(): 1st argument: invalid BinaryPredicate1D object");
480 if (!PyErr_Occurred()) {
481 PyErr_SetString(PyExc_RuntimeError,
"Operators.sort() failed");
489 ".. staticmethod:: create(pred, shaders)\n"
491 " Creates and shades the strokes from the current set of chains. A\n"
492 " predicate can be specified to make a selection pass on the chains.\n"
494 " :arg pred: The predicate that a chain must verify in order to be\n"
495 " transform as a stroke.\n"
496 " :type pred: :class:`UnaryPredicate1D`\n"
497 " :arg shaders: The list of shaders used to shade the strokes.\n"
498 " :type shaders: list of :class:`StrokeShader` objects");
502 static const char *kwlist[] = {
"pred",
"shaders",
nullptr};
503 PyObject *obj1 =
nullptr, *obj2 =
nullptr;
505 if (!PyArg_ParseTupleAndKeywords(args,
516 PyErr_SetString(PyExc_TypeError,
517 "Operators.create(): 1st argument: invalid UnaryPredicate1D object");
520 vector<StrokeShader *>
shaders;
521 shaders.reserve(PyList_Size(obj2));
522 for (
int i = 0; i < PyList_Size(obj2); i++) {
523 PyObject *py_ss = PyList_GET_ITEM(obj2, i);
525 PyErr_SetString(PyExc_TypeError,
526 "Operators.create(): 2nd argument must be a list of StrokeShader objects");
532 ss <<
"Operators.create(): item " << (i + 1)
533 <<
" of the shaders list is invalid likely due to missing call of "
534 "StrokeShader.__init__()";
535 PyErr_SetString(PyExc_TypeError, ss.str().c_str());
541 if (!PyErr_Occurred()) {
542 PyErr_SetString(PyExc_RuntimeError,
"Operators.create() failed");
550 ".. staticmethod:: reset(delete_strokes=True)\n"
552 " Resets the line stylization process to the initial state. The results of\n"
553 " stroke creation are accumulated if **delete_strokes** is set to False.\n"
555 " :arg delete_strokes: Delete the strokes that are currently stored.\n"
556 " :type delete_strokes: bool\n");
560 static const char *kwlist[] = {
"delete_strokes",
nullptr};
561 PyObject *obj1 =
nullptr;
562 if (PyArg_ParseTupleAndKeywords(args, kwds,
"|O!", (
char **)kwlist, &PyBool_Type, &obj1)) {
567 PyErr_SetString(PyExc_RuntimeError,
"Operators.reset() failed");
574 ".. staticmethod:: get_viewedge_from_index(i)\n"
576 " Returns the ViewEdge at the index in the current set of ViewEdges.\n"
578 " :arg i: index (0 <= i < Operators.get_view_edges_size()).\n"
580 " :return: The ViewEdge object.\n"
581 " :rtype: :class:`ViewEdge`");
587 static const char *kwlist[] = {
"i",
nullptr};
590 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"I", (
char **)kwlist, &i)) {
594 PyErr_SetString(PyExc_IndexError,
"index out of range");
601 ".. staticmethod:: get_chain_from_index(i)\n"
603 " Returns the Chain at the index in the current set of Chains.\n"
605 " :arg i: index (0 <= i < Operators.get_chains_size()).\n"
607 " :return: The Chain object.\n"
608 " :rtype: :class:`Chain`");
614 static const char *kwlist[] = {
"i",
nullptr};
617 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"I", (
char **)kwlist, &i)) {
621 PyErr_SetString(PyExc_IndexError,
"index out of range");
628 ".. staticmethod:: get_stroke_from_index(i)\n"
630 " Returns the Stroke at the index in the current set of Strokes.\n"
632 " :arg i: index (0 <= i < Operators.get_strokes_size()).\n"
634 " :return: The Stroke object.\n"
635 " :rtype: :class:`Stroke`");
641 static const char *kwlist[] = {
"i",
nullptr};
644 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"I", (
char **)kwlist, &i)) {
648 PyErr_SetString(PyExc_IndexError,
"index out of range");
655 ".. staticmethod:: get_view_edges_size()\n"
657 " Returns the number of ViewEdges.\n"
659 " :return: The number of ViewEdges.\n"
668 ".. staticmethod:: get_chains_size()\n"
670 " Returns the number of Chains.\n"
672 " :return: The number of Chains.\n"
681 ".. staticmethod:: get_strokes_size()\n"
683 " Returns the number of Strokes.\n"
685 " :return: The number of Strokes.\n"
697 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
698 Operators_select_doc},
701 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
702 Operators_chain_doc},
703 {
"bidirectional_chain",
705 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
706 Operators_bidirectional_chain_doc},
709 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
710 Operators_sequential_split_doc},
713 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
714 Operators_recursive_split_doc},
717 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
721 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
722 Operators_create_doc},
725 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
726 Operators_reset_doc},
727 {
"get_viewedge_from_index",
729 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
730 Operators_get_viewedge_from_index_doc},
731 {
"get_chain_from_index",
733 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
734 Operators_get_chain_from_index_doc},
735 {
"get_stroke_from_index",
737 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
738 Operators_get_stroke_from_index_doc},
739 {
"get_view_edges_size",
741 METH_NOARGS | METH_STATIC,
742 Operators_get_view_edges_size_doc},
745 METH_NOARGS | METH_STATIC,
746 Operators_get_chains_size_doc},
749 METH_NOARGS | METH_STATIC,
750 Operators_get_strokes_size_doc},
751 {
nullptr,
nullptr, 0,
nullptr},
757 PyVarObject_HEAD_INIT(
nullptr, 0)
"Operators",
PyTypeObject BinaryPredicate1D_Type
PyTypeObject ChainingIterator_Type
PyObject * BPy_Chain_from_Chain(Chain &c)
bool bool_from_PyBool(PyObject *b)
PyObject * BPy_Stroke_from_Stroke(Stroke &s)
PyObject * BPy_ViewEdge_from_ViewEdge(ViewEdge &ve)
static PyObject * Operators_get_viewedge_from_index(BPy_Operators *, PyObject *args, PyObject *kwds)
static PyObject * Operators_get_view_edges_size(BPy_Operators *)
static PyMethodDef BPy_Operators_methods[]
int Operators_Init(PyObject *module)
static PyObject * Operators_create(BPy_Operators *, PyObject *args, PyObject *kwds)
static PyObject * Operators_sort(BPy_Operators *, PyObject *args, PyObject *kwds)
static PyObject * Operators_get_chain_from_index(BPy_Operators *, PyObject *args, PyObject *kwds)
PyDoc_STRVAR(Operators_doc, "Class defining the operators used in a style module. There are five\n" "types of operators: Selection, chaining, splitting, sorting and\n" "creation. All these operators are user controlled through functors,\n" "predicates and shaders that are taken as arguments.")
static PyObject * Operators_get_stroke_from_index(BPy_Operators *, PyObject *args, PyObject *kwds)
static PyObject * Operators_get_strokes_size(BPy_Operators *)
static PyObject * Operators_get_chains_size(BPy_Operators *)
static PyObject * Operators_select(BPy_Operators *, PyObject *args, PyObject *kwds)
static PyObject * Operators_reset(BPy_Operators *, PyObject *args, PyObject *kwds)
static PyObject * Operators_recursive_split(BPy_Operators *, PyObject *args, PyObject *kwds)
static PyObject * Operators_chain(BPy_Operators *, PyObject *args, PyObject *kwds)
static PyObject * Operators_bidirectional_chain(BPy_Operators *, PyObject *args, PyObject *kwds)
static void Operators_dealloc(BPy_Operators *self)
PyTypeObject Operators_Type
static PyObject * Operators_sequential_split(BPy_Operators *, PyObject *args, PyObject *kwds)
#define BPy_StrokeShader_Check(v)
PyTypeObject UnaryFunction0DDouble_Type
PyTypeObject UnaryFunction1DVoid_Type
PyTypeObject UnaryPredicate0D_Type
PyTypeObject UnaryPredicate1D_Type
static int sort(BinaryPredicate1D &pred)
static int select(UnaryPredicate1D &pred)
static int chain(ViewEdgeInternal::ViewEdgeIterator &it, UnaryPredicate1D &pred, UnaryFunction1D_void &modifier)
static void reset(bool removeStrokes=true)
static ViewEdge * getViewEdgeFromIndex(unsigned i)
static int sequentialSplit(UnaryPredicate0D &startingPred, UnaryPredicate0D &stoppingPred, float sampling=0.0f)
static int recursiveSplit(UnaryFunction0D< double > &func, UnaryPredicate1D &pred, float sampling=0)
static unsigned getViewEdgesSize()
static int bidirectionalChain(ChainingIterator &it, UnaryPredicate1D &pred)
static Stroke * getStrokeFromIndex(unsigned i)
static Chain * getChainFromIndex(unsigned i)
static int create(UnaryPredicate1D &pred, vector< StrokeShader * > shaders)
static unsigned getStrokesSize()
static unsigned getChainsSize()
static struct PyModuleDef module