49 "Class defining the operators used in a style module. There are five\n"
50 "types of operators: Selection, chaining, splitting, sorting and\n"
51 "creation. All these operators are user controlled through functors,\n"
52 "predicates and shaders that are taken as arguments.");
56 Py_TYPE(
self)->tp_free((PyObject *)
self);
62 ".. staticmethod:: select(pred)\n"
64 " Selects the ViewEdges of the ViewMap verifying a specified\n"
67 " :arg pred: The predicate expressing this condition.\n"
68 " :type pred: :class:`UnaryPredicate1D`");
72 static const char *kwlist[] = {
"pred",
nullptr};
73 PyObject *obj =
nullptr;
75 if (!PyArg_ParseTupleAndKeywords(
81 PyErr_SetString(PyExc_TypeError,
82 "Operators.select(): 1st argument: invalid UnaryPredicate1D object");
86 if (!PyErr_Occurred()) {
87 PyErr_SetString(PyExc_RuntimeError,
"Operators.select() failed");
97 ".. staticmethod:: chain(it, pred, modifier)\n"
100 " Builds a set of chains from the current set of ViewEdges. Each\n"
101 " ViewEdge of the current list starts a new chain. The chaining\n"
102 " operator then iterates over the ViewEdges of the ViewMap using the\n"
103 " user specified iterator. This operator only iterates using the\n"
104 " increment operator and is therefore unidirectional.\n"
106 " :arg it: The iterator on the ViewEdges of the ViewMap. It contains\n"
107 " the chaining rule.\n"
108 " :type it: :class:`ViewEdgeIterator`\n"
109 " :arg pred: The predicate on the ViewEdge that expresses the\n"
110 " stopping condition.\n"
111 " :type pred: :class:`UnaryPredicate1D`\n"
112 " :arg modifier: A function that takes a ViewEdge as argument and\n"
113 " that is used to modify the processed ViewEdge state (the\n"
114 " timestamp incrementation is a typical illustration of such a modifier).\n"
115 " If this argument is not given, the time stamp is automatically managed.\n"
116 " :type modifier: :class:`UnaryFunction1DVoid`\n");
120 static const char *kwlist[] = {
"it",
"pred",
"modifier",
nullptr};
121 PyObject *obj1 =
nullptr, *obj2 =
nullptr, *obj3 =
nullptr;
123 if (!PyArg_ParseTupleAndKeywords(args,
137 PyErr_SetString(PyExc_TypeError,
138 "Operators.chain(): 1st argument: invalid ChainingIterator object");
142 PyErr_SetString(PyExc_TypeError,
143 "Operators.chain(): 2nd argument: invalid UnaryPredicate1D object");
150 if (!PyErr_Occurred()) {
151 PyErr_SetString(PyExc_RuntimeError,
"Operators.chain() failed");
158 PyErr_SetString(PyExc_TypeError,
159 "Operators.chain(): 3rd argument: invalid UnaryFunction1DVoid object");
166 if (!PyErr_Occurred()) {
167 PyErr_SetString(PyExc_RuntimeError,
"Operators.chain() failed");
177 Operators_bidirectional_chain_doc,
178 ".. staticmethod:: bidirectional_chain(it, pred)\n"
179 " bidirectional_chain(it)\n"
181 " Builds a set of chains from the current set of ViewEdges. Each\n"
182 " ViewEdge of the current list potentially starts a new chain. The\n"
183 " chaining operator then iterates over the ViewEdges of the ViewMap\n"
184 " using the user specified iterator. This operator iterates both using\n"
185 " the increment and decrement operators and is therefore bidirectional.\n"
186 " This operator works with a ChainingIterator which contains the\n"
187 " chaining rules. It is this last one which can be told to chain only\n"
188 " edges that belong to the selection or not to process twice a ViewEdge\n"
189 " during the chaining. Each time a ViewEdge is added to a chain, its\n"
190 " chaining time stamp is incremented. This allows you to keep track of\n"
191 " the number of chains to which a ViewEdge belongs to.\n"
193 " :arg it: The ChainingIterator on the ViewEdges of the ViewMap. It\n"
194 " contains the chaining rule.\n"
195 " :type it: :class:`ChainingIterator`\n"
196 " :arg pred: The predicate on the ViewEdge that expresses the stopping condition.\n"
197 " This parameter is optional, you make not want to pass a stopping criterion\n"
198 " when the stopping criterion is already contained in the iterator definition.\n"
199 " :type pred: :class:`UnaryPredicate1D`\n");
205 static const char *kwlist[] = {
"it",
"pred",
nullptr};
206 PyObject *obj1 =
nullptr, *obj2 =
nullptr;
208 if (!PyArg_ParseTupleAndKeywords(args,
222 "Operators.bidirectional_chain(): 1st argument: invalid ChainingIterator object");
227 if (!PyErr_Occurred()) {
228 PyErr_SetString(PyExc_RuntimeError,
"Operators.bidirectional_chain() failed");
237 "Operators.bidirectional_chain(): 2nd argument: invalid UnaryPredicate1D object");
243 if (!PyErr_Occurred()) {
244 PyErr_SetString(PyExc_RuntimeError,
"Operators.bidirectional_chain() failed");
254 Operators_sequential_split_doc,
255 ".. staticmethod:: sequential_split(starting_pred, stopping_pred, sampling=0.0)\n"
256 " sequential_split(pred, sampling=0.0)\n"
258 " Splits each chain of the current set of chains in a sequential way.\n"
259 " The points of each chain are processed (with a specified sampling)\n"
260 " sequentially. The first point of the initial chain is the\n"
261 " first point of one of the resulting chains. The splitting ends when\n"
262 " no more chain can start.\n"
266 " By specifying a starting and stopping predicate allows\n"
267 " the chains to overlap rather than chains partitioning.\n"
269 " :arg starting_pred: The predicate on a point that expresses the\n"
270 " starting condition. Each time this condition is verified, a new chain begins\n"
271 " :type starting_pred: :class:`UnaryPredicate0D`\n"
272 " :arg stopping_pred: The predicate on a point that expresses the\n"
273 " stopping condition. The chain ends as soon as this predicate is verified.\n"
274 " :type stopping_pred: :class:`UnaryPredicate0D`\n"
275 " :arg pred: The predicate on a point that expresses the splitting condition.\n"
276 " Each time the condition is verified, the chain is split into two chains.\n"
277 " The resulting set of chains is a partition of the initial chain\n"
278 " :type pred: :class:`UnaryPredicate0D`\n"
279 " :arg sampling: The resolution used to sample the chain for the\n"
280 " predicates evaluation. (The chain is not actually resampled;\n"
281 " a virtual point only progresses along the curve using this\n"
283 " :type sampling: float\n");
289 static const char *kwlist_1[] = {
"starting_pred",
"stopping_pred",
"sampling",
nullptr};
290 static const char *kwlist_2[] = {
"pred",
"sampling",
nullptr};
291 PyObject *obj1 =
nullptr, *obj2 =
nullptr;
294 if (PyArg_ParseTupleAndKeywords(args,
307 "Operators.sequential_split(): 1st argument: invalid UnaryPredicate0D object");
313 "Operators.sequential_split(): 2nd argument: invalid UnaryPredicate0D object");
320 if (!PyErr_Occurred()) {
321 PyErr_SetString(PyExc_RuntimeError,
"Operators.sequential_split() failed");
326 else if ((
void)PyErr_Clear(),
328 PyArg_ParseTupleAndKeywords(
334 "Operators.sequential_split(): 1st argument: invalid UnaryPredicate0D object");
338 if (!PyErr_Occurred()) {
339 PyErr_SetString(PyExc_RuntimeError,
"Operators.sequential_split() failed");
345 PyErr_SetString(PyExc_TypeError,
"invalid argument(s)");
353 Operators_recursive_split_doc,
354 ".. staticmethod:: recursive_split(func, pred_1d, sampling=0.0)\n"
355 " recursive_split(func, pred_0d, pred_1d, sampling=0.0)\n"
357 " Splits the current set of chains in a recursive way. We process the\n"
358 " points of each chain (with a specified sampling) to find the point\n"
359 " minimizing a specified function. The chain is split in two at this\n"
360 " point and the two new chains are processed in the same way. The\n"
361 " recursivity level is controlled through a predicate 1D that expresses\n"
362 " a stopping condition on the chain that is about to be processed.\n"
364 " The user can also specify a 0D predicate to make a first selection on the points\n"
365 " that can potentially be split. A point that doesn't verify the 0D\n"
366 " predicate won't be candidate in realizing the min.\n"
368 " :arg func: The Unary Function evaluated at each point of the chain.\n"
369 " The splitting point is the point minimizing this function.\n"
370 " :type func: :class:`UnaryFunction0DDouble`\n"
371 " :arg pred_0d: The Unary Predicate 0D used to select the candidate\n"
372 " points where the split can occur. For example, it is very likely\n"
373 " that would rather have your chain splitting around its middle\n"
374 " point than around one of its extremities. A 0D predicate working\n"
375 " on the curvilinear abscissa allows to add this kind of constraints.\n"
376 " :type pred_0d: :class:`UnaryPredicate0D`\n"
377 " :arg pred_1d: The Unary Predicate expressing the recursivity stopping\n"
378 " condition. This predicate is evaluated for each curve before it\n"
379 " actually gets split. If pred_1d(chain) is true, the curve won't be\n"
381 " :type pred_1d: :class:`UnaryPredicate1D`\n"
382 " :arg sampling: The resolution used to sample the chain for the\n"
383 " predicates evaluation. (The chain is not actually resampled; a\n"
384 " virtual point only progresses along the curve using this\n"
386 " :type sampling: float\n");
392 static const char *kwlist_1[] = {
"func",
"pred_1d",
"sampling",
nullptr};
393 static const char *kwlist_2[] = {
"func",
"pred_0d",
"pred_1d",
"sampling",
nullptr};
394 PyObject *obj1 =
nullptr, *obj2 =
nullptr, *obj3 =
nullptr;
397 if (PyArg_ParseTupleAndKeywords(args,
410 "Operators.recursive_split(): 1st argument: invalid UnaryFunction0DDouble object");
416 "Operators.recursive_split(): 2nd argument: invalid UnaryPredicate1D object");
423 if (!PyErr_Occurred()) {
424 PyErr_SetString(PyExc_RuntimeError,
"Operators.recursive_split() failed");
429 else if ((
void)PyErr_Clear(),
431 PyArg_ParseTupleAndKeywords(args,
446 "Operators.recursive_split(): 1st argument: invalid UnaryFunction0DDouble object");
452 "Operators.recursive_split(): 2nd argument: invalid UnaryPredicate0D object");
458 "Operators.recursive_split(): 3rd argument: invalid UnaryPredicate1D object");
466 if (!PyErr_Occurred()) {
467 PyErr_SetString(PyExc_RuntimeError,
"Operators.recursive_split() failed");
473 PyErr_SetString(PyExc_TypeError,
"invalid argument(s)");
482 ".. staticmethod:: sort(pred)\n"
484 " Sorts the current set of chains (or viewedges) according to the\n"
485 " comparison predicate given as argument.\n"
487 " :arg pred: The binary predicate used for the comparison.\n"
488 " :type pred: :class:`BinaryPredicate1D`");
492 static const char *kwlist[] = {
"pred",
nullptr};
493 PyObject *obj =
nullptr;
495 if (!PyArg_ParseTupleAndKeywords(
501 PyErr_SetString(PyExc_TypeError,
502 "Operators.sort(): 1st argument: invalid BinaryPredicate1D object");
506 if (!PyErr_Occurred()) {
507 PyErr_SetString(PyExc_RuntimeError,
"Operators.sort() failed");
516 Operators_create_doc,
517 ".. staticmethod:: create(pred, shaders)\n"
519 " Creates and shades the strokes from the current set of chains. A\n"
520 " predicate can be specified to make a selection pass on the chains.\n"
522 " :arg pred: The predicate that a chain must verify in order to be\n"
523 " transform as a stroke.\n"
524 " :type pred: :class:`UnaryPredicate1D`\n"
525 " :arg shaders: The list of shaders used to shade the strokes.\n"
526 " :type shaders: list[:class:`StrokeShader`]");
530 static const char *kwlist[] = {
"pred",
"shaders",
nullptr};
531 PyObject *obj1 =
nullptr, *obj2 =
nullptr;
533 if (!PyArg_ParseTupleAndKeywords(
539 PyErr_SetString(PyExc_TypeError,
540 "Operators.create(): 1st argument: invalid UnaryPredicate1D object");
544 shaders.reserve(PyList_Size(obj2));
545 for (
int i = 0;
i < PyList_Size(obj2);
i++) {
546 PyObject *py_ss = PyList_GET_ITEM(obj2,
i);
548 PyErr_SetString(PyExc_TypeError,
549 "Operators.create(): 2nd argument must be a list of StrokeShader objects");
555 ss <<
"Operators.create(): item " << (
i + 1)
556 <<
" of the shaders list is invalid likely due to missing call of "
557 "StrokeShader.__init__()";
558 PyErr_SetString(PyExc_TypeError, ss.str().c_str());
561 shaders.push_back(shader);
564 if (!PyErr_Occurred()) {
565 PyErr_SetString(PyExc_RuntimeError,
"Operators.create() failed");
575 ".. staticmethod:: reset(delete_strokes=True)\n"
577 " Resets the line stylization process to the initial state. The results of\n"
578 " stroke creation are accumulated if **delete_strokes** is set to False.\n"
580 " :arg delete_strokes: Delete the strokes that are currently stored.\n"
581 " :type delete_strokes: bool\n");
585 static const char *kwlist[] = {
"delete_strokes",
nullptr};
586 PyObject *obj1 =
nullptr;
587 if (PyArg_ParseTupleAndKeywords(args, kwds,
"|O!", (
char **)kwlist, &PyBool_Type, &obj1)) {
592 PyErr_SetString(PyExc_RuntimeError,
"Operators.reset() failed");
600 Operators_get_viewedge_from_index_doc,
601 ".. staticmethod:: get_viewedge_from_index(i)\n"
603 " Returns the ViewEdge at the index in the current set of ViewEdges.\n"
605 " :arg i: index (0 <= i < Operators.get_view_edges_size()).\n"
607 " :return: The ViewEdge object.\n"
608 " :rtype: :class:`ViewEdge`");
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");
629 Operators_get_chain_from_index_doc,
630 ".. staticmethod:: get_chain_from_index(i)\n"
632 " Returns the Chain at the index in the current set of Chains.\n"
634 " :arg i: index (0 <= i < Operators.get_chains_size()).\n"
636 " :return: The Chain object.\n"
637 " :rtype: :class:`Chain`");
643 static const char *kwlist[] = {
"i",
nullptr};
646 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"I", (
char **)kwlist, &
i)) {
650 PyErr_SetString(PyExc_IndexError,
"index out of range");
658 Operators_get_stroke_from_index_doc,
659 ".. staticmethod:: get_stroke_from_index(i)\n"
661 " Returns the Stroke at the index in the current set of Strokes.\n"
663 " :arg i: index (0 <= i < Operators.get_strokes_size()).\n"
665 " :return: The Stroke object.\n"
666 " :rtype: :class:`Stroke`");
672 static const char *kwlist[] = {
"i",
nullptr};
675 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"I", (
char **)kwlist, &
i)) {
679 PyErr_SetString(PyExc_IndexError,
"index out of range");
687 Operators_get_view_edges_size_doc,
688 ".. staticmethod:: get_view_edges_size()\n"
690 " Returns the number of ViewEdges.\n"
692 " :return: The number of ViewEdges.\n"
702 Operators_get_chains_size_doc,
703 ".. staticmethod:: get_chains_size()\n"
705 " Returns the number of Chains.\n"
707 " :return: The number of Chains.\n"
717 Operators_get_strokes_size_doc,
718 ".. staticmethod:: get_strokes_size()\n"
720 " Returns the number of Strokes.\n"
722 " :return: The number of Strokes.\n"
734# pragma clang diagnostic push
735# pragma clang diagnostic ignored "-Wcast-function-type"
737# pragma GCC diagnostic push
738# pragma GCC diagnostic ignored "-Wcast-function-type"
745 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
746 Operators_select_doc},
749 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
750 Operators_chain_doc},
751 {
"bidirectional_chain",
753 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
754 Operators_bidirectional_chain_doc},
757 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
758 Operators_sequential_split_doc},
761 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
762 Operators_recursive_split_doc},
765 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
769 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
770 Operators_create_doc},
773 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
774 Operators_reset_doc},
775 {
"get_viewedge_from_index",
777 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
778 Operators_get_viewedge_from_index_doc},
779 {
"get_chain_from_index",
781 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
782 Operators_get_chain_from_index_doc},
783 {
"get_stroke_from_index",
785 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
786 Operators_get_stroke_from_index_doc},
787 {
"get_view_edges_size",
789 METH_NOARGS | METH_STATIC,
790 Operators_get_view_edges_size_doc},
793 METH_NOARGS | METH_STATIC,
794 Operators_get_chains_size_doc},
797 METH_NOARGS | METH_STATIC,
798 Operators_get_strokes_size_doc},
799 {
nullptr,
nullptr, 0,
nullptr},
804# pragma clang diagnostic pop
806# pragma GCC diagnostic pop
813 PyVarObject_HEAD_INIT(
nullptr, 0)
PyTypeObject BinaryPredicate1D_Type
PyTypeObject ChainingIterator_Type
bool bool_from_PyBool(PyObject *b)
PyObject * BPy_Chain_from_Chain(Chain &c)
PyObject * BPy_Stroke_from_Stroke(Stroke &s)
PyObject * BPy_ViewEdge_from_ViewEdge(ViewEdge &ve)
static PyObject * Operators_select(BPy_Operators *, PyObject *args, PyObject *kwds)
static PyMethodDef BPy_Operators_methods[]
static PyObject * Operators_reset(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_recursive_split(BPy_Operators *, PyObject *args, PyObject *kwds)
int Operators_Init(PyObject *module)
static PyObject * Operators_get_chain_from_index(BPy_Operators *, PyObject *args, PyObject *kwds)
static PyObject * Operators_get_stroke_from_index(BPy_Operators *, PyObject *args, PyObject *kwds)
static PyObject * Operators_sort(BPy_Operators *, PyObject *args, PyObject *kwds)
static PyObject * Operators_sequential_split(BPy_Operators *, PyObject *args, PyObject *kwds)
static PyObject * Operators_get_view_edges_size(BPy_Operators *)
static PyObject * Operators_get_strokes_size(BPy_Operators *)
static PyObject * Operators_get_viewedge_from_index(BPy_Operators *, PyObject *args, PyObject *kwds)
static void Operators_dealloc(BPy_Operators *self)
static PyObject * Operators_get_chains_size(BPy_Operators *)
PyTypeObject Operators_Type
static PyObject * Operators_create(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)
#define BPy_StrokeShader_Check(v)
PyTypeObject UnaryFunction0DDouble_Type
PyTypeObject UnaryFunction1DVoid_Type
PyTypeObject UnaryPredicate0D_Type
PyTypeObject UnaryPredicate1D_Type
static int sort(BinaryPredicate1D &pred)
static ViewEdge * getViewEdgeFromIndex(uint i)
static int select(UnaryPredicate1D &pred)
static int chain(ViewEdgeInternal::ViewEdgeIterator &it, UnaryPredicate1D &pred, UnaryFunction1D_void &modifier)
static void reset(bool removeStrokes=true)
static uint getChainsSize()
static uint getViewEdgesSize()
static uint getStrokesSize()
static int sequentialSplit(UnaryPredicate0D &startingPred, UnaryPredicate0D &stoppingPred, float sampling=0.0f)
static int recursiveSplit(UnaryFunction0D< double > &func, UnaryPredicate1D &pred, float sampling=0)
static int bidirectionalChain(ChainingIterator &it, UnaryPredicate1D &pred)
static Stroke * getStrokeFromIndex(uint i)
static int create(UnaryPredicate1D &pred, vector< StrokeShader * > shaders)
static Chain * getChainFromIndex(uint i)
static struct PyModuleDef module