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.\n");
55 Py_TYPE(
self)->tp_free((PyObject *)
self);
61 ".. staticmethod:: select(pred)\n"
63 " Selects the ViewEdges of the ViewMap verifying a specified\n"
66 " :arg pred: The predicate expressing this condition.\n"
67 " :type pred: :class:`UnaryPredicate1D`\n");
70 static const char *kwlist[] = {
"pred",
nullptr};
71 PyObject *obj =
nullptr;
73 if (!PyArg_ParseTupleAndKeywords(
79 PyErr_SetString(PyExc_TypeError,
80 "Operators.select(): 1st argument: invalid UnaryPredicate1D object");
84 if (!PyErr_Occurred()) {
85 PyErr_SetString(PyExc_RuntimeError,
"Operators.select() failed");
95 ".. staticmethod:: chain(it, pred, modifier)\n"
98 " Builds a set of chains from the current set of ViewEdges. Each\n"
99 " ViewEdge of the current list starts a new chain. The chaining\n"
100 " operator then iterates over the ViewEdges of the ViewMap using the\n"
101 " user specified iterator. This operator only iterates using the\n"
102 " increment operator and is therefore unidirectional.\n"
104 " :arg it: The iterator on the ViewEdges of the ViewMap. It contains\n"
105 " the chaining rule.\n"
106 " :type it: :class:`ViewEdgeIterator`\n"
107 " :arg pred: The predicate on the ViewEdge that expresses the\n"
108 " stopping condition.\n"
109 " :type pred: :class:`UnaryPredicate1D`\n"
110 " :arg modifier: A function that takes a ViewEdge as argument and\n"
111 " that is used to modify the processed ViewEdge state (the\n"
112 " timestamp incrementation is a typical illustration of such a modifier).\n"
113 " If this argument is not given, the time stamp is automatically managed.\n"
114 " :type modifier: :class:`UnaryFunction1DVoid`\n");
117 static const char *kwlist[] = {
"it",
"pred",
"modifier",
nullptr};
118 PyObject *obj1 =
nullptr, *obj2 =
nullptr, *obj3 =
nullptr;
120 if (!PyArg_ParseTupleAndKeywords(args,
134 PyErr_SetString(PyExc_TypeError,
135 "Operators.chain(): 1st argument: invalid ChainingIterator object");
139 PyErr_SetString(PyExc_TypeError,
140 "Operators.chain(): 2nd argument: invalid UnaryPredicate1D object");
147 if (!PyErr_Occurred()) {
148 PyErr_SetString(PyExc_RuntimeError,
"Operators.chain() failed");
155 PyErr_SetString(PyExc_TypeError,
156 "Operators.chain(): 3rd argument: invalid UnaryFunction1DVoid object");
163 if (!PyErr_Occurred()) {
164 PyErr_SetString(PyExc_RuntimeError,
"Operators.chain() failed");
174 Operators_bidirectional_chain_doc,
175 ".. staticmethod:: bidirectional_chain(it, pred)\n"
176 " bidirectional_chain(it)\n"
178 " Builds a set of chains from the current set of ViewEdges. Each\n"
179 " ViewEdge of the current list potentially starts a new chain. The\n"
180 " chaining operator then iterates over the ViewEdges of the ViewMap\n"
181 " using the user specified iterator. This operator iterates both using\n"
182 " the increment and decrement operators and is therefore bidirectional.\n"
183 " This operator works with a ChainingIterator which contains the\n"
184 " chaining rules. It is this last one which can be told to chain only\n"
185 " edges that belong to the selection or not to process twice a ViewEdge\n"
186 " during the chaining. Each time a ViewEdge is added to a chain, its\n"
187 " chaining time stamp is incremented. This allows you to keep track of\n"
188 " the number of chains to which a ViewEdge belongs to.\n"
190 " :arg it: The ChainingIterator on the ViewEdges of the ViewMap. It\n"
191 " contains the chaining rule.\n"
192 " :type it: :class:`ChainingIterator`\n"
193 " :arg pred: The predicate on the ViewEdge that expresses the stopping condition.\n"
194 " This parameter is optional, you make not want to pass a stopping criterion\n"
195 " when the stopping criterion is already contained in the iterator definition.\n"
196 " :type pred: :class:`UnaryPredicate1D`\n");
201 static const char *kwlist[] = {
"it",
"pred",
nullptr};
202 PyObject *obj1 =
nullptr, *obj2 =
nullptr;
204 if (!PyArg_ParseTupleAndKeywords(args,
218 "Operators.bidirectional_chain(): 1st argument: invalid ChainingIterator object");
223 if (!PyErr_Occurred()) {
224 PyErr_SetString(PyExc_RuntimeError,
"Operators.bidirectional_chain() failed");
233 "Operators.bidirectional_chain(): 2nd argument: invalid UnaryPredicate1D object");
239 if (!PyErr_Occurred()) {
240 PyErr_SetString(PyExc_RuntimeError,
"Operators.bidirectional_chain() failed");
250 Operators_sequential_split_doc,
251 ".. staticmethod:: sequential_split(starting_pred, stopping_pred, sampling=0.0)\n"
252 " sequential_split(pred, sampling=0.0)\n"
254 " Splits each chain of the current set of chains in a sequential way.\n"
255 " The points of each chain are processed (with a specified sampling)\n"
256 " sequentially. The first point of the initial chain is the\n"
257 " first point of one of the resulting chains. The splitting ends when\n"
258 " no more chain can start.\n"
262 " By specifying a starting and stopping predicate allows\n"
263 " the chains to overlap rather than chains partitioning.\n"
265 " :arg starting_pred: The predicate on a point that expresses the\n"
266 " starting condition. Each time this condition is verified, a new chain begins\n"
267 " :type starting_pred: :class:`UnaryPredicate0D`\n"
268 " :arg stopping_pred: The predicate on a point that expresses the\n"
269 " stopping condition. The chain ends as soon as this predicate is verified.\n"
270 " :type stopping_pred: :class:`UnaryPredicate0D`\n"
271 " :arg pred: The predicate on a point that expresses the splitting condition.\n"
272 " Each time the condition is verified, the chain is split into two chains.\n"
273 " The resulting set of chains is a partition of the initial chain\n"
274 " :type pred: :class:`UnaryPredicate0D`\n"
275 " :arg sampling: The resolution used to sample the chain for the\n"
276 " predicates evaluation. (The chain is not actually resampled;\n"
277 " a virtual point only progresses along the curve using this\n"
279 " :type sampling: float\n");
284 static const char *kwlist_1[] = {
"starting_pred",
"stopping_pred",
"sampling",
nullptr};
285 static const char *kwlist_2[] = {
"pred",
"sampling",
nullptr};
286 PyObject *obj1 =
nullptr, *obj2 =
nullptr;
289 if (PyArg_ParseTupleAndKeywords(args,
302 "Operators.sequential_split(): 1st argument: invalid UnaryPredicate0D object");
308 "Operators.sequential_split(): 2nd argument: invalid UnaryPredicate0D object");
315 if (!PyErr_Occurred()) {
316 PyErr_SetString(PyExc_RuntimeError,
"Operators.sequential_split() failed");
321 else if ((
void)PyErr_Clear(),
323 PyArg_ParseTupleAndKeywords(
329 "Operators.sequential_split(): 1st argument: invalid UnaryPredicate0D object");
333 if (!PyErr_Occurred()) {
334 PyErr_SetString(PyExc_RuntimeError,
"Operators.sequential_split() failed");
340 PyErr_SetString(PyExc_TypeError,
"invalid argument(s)");
348 Operators_recursive_split_doc,
349 ".. staticmethod:: recursive_split(func, pred_1d, sampling=0.0)\n"
350 " recursive_split(func, pred_0d, pred_1d, sampling=0.0)\n"
352 " Splits the current set of chains in a recursive way. We process the\n"
353 " points of each chain (with a specified sampling) to find the point\n"
354 " minimizing a specified function. The chain is split in two at this\n"
355 " point and the two new chains are processed in the same way. The\n"
356 " recursivity level is controlled through a predicate 1D that expresses\n"
357 " a stopping condition on the chain that is about to be processed.\n"
359 " The user can also specify a 0D predicate to make a first selection on the points\n"
360 " that can potentially be split. A point that doesn't verify the 0D\n"
361 " predicate won't be candidate in realizing the min.\n"
363 " :arg func: The Unary Function evaluated at each point of the chain.\n"
364 " The splitting point is the point minimizing this function.\n"
365 " :type func: :class:`UnaryFunction0DDouble`\n"
366 " :arg pred_0d: The Unary Predicate 0D used to select the candidate\n"
367 " points where the split can occur. For example, it is very likely\n"
368 " that would rather have your chain splitting around its middle\n"
369 " point than around one of its extremities. A 0D predicate working\n"
370 " on the curvilinear abscissa allows to add this kind of constraints.\n"
371 " :type pred_0d: :class:`UnaryPredicate0D`\n"
372 " :arg pred_1d: The Unary Predicate expressing the recursivity stopping\n"
373 " condition. This predicate is evaluated for each curve before it\n"
374 " actually gets split. If pred_1d(chain) is true, the curve won't be\n"
376 " :type pred_1d: :class:`UnaryPredicate1D`\n"
377 " :arg sampling: The resolution used to sample the chain for the\n"
378 " predicates evaluation. (The chain is not actually resampled; a\n"
379 " virtual point only progresses along the curve using this\n"
381 " :type sampling: float\n");
386 static const char *kwlist_1[] = {
"func",
"pred_1d",
"sampling",
nullptr};
387 static const char *kwlist_2[] = {
"func",
"pred_0d",
"pred_1d",
"sampling",
nullptr};
388 PyObject *obj1 =
nullptr, *obj2 =
nullptr, *obj3 =
nullptr;
391 if (PyArg_ParseTupleAndKeywords(args,
404 "Operators.recursive_split(): 1st argument: invalid UnaryFunction0DDouble object");
410 "Operators.recursive_split(): 2nd argument: invalid UnaryPredicate1D object");
417 if (!PyErr_Occurred()) {
418 PyErr_SetString(PyExc_RuntimeError,
"Operators.recursive_split() failed");
423 else if ((
void)PyErr_Clear(),
425 PyArg_ParseTupleAndKeywords(args,
440 "Operators.recursive_split(): 1st argument: invalid UnaryFunction0DDouble object");
446 "Operators.recursive_split(): 2nd argument: invalid UnaryPredicate0D object");
452 "Operators.recursive_split(): 3rd argument: invalid UnaryPredicate1D object");
460 if (!PyErr_Occurred()) {
461 PyErr_SetString(PyExc_RuntimeError,
"Operators.recursive_split() failed");
467 PyErr_SetString(PyExc_TypeError,
"invalid argument(s)");
476 ".. staticmethod:: sort(pred)\n"
478 " Sorts the current set of chains (or viewedges) according to the\n"
479 " comparison predicate given as argument.\n"
481 " :arg pred: The binary predicate used for the comparison.\n"
482 " :type pred: :class:`BinaryPredicate1D`\n");
485 static const char *kwlist[] = {
"pred",
nullptr};
486 PyObject *obj =
nullptr;
488 if (!PyArg_ParseTupleAndKeywords(
494 PyErr_SetString(PyExc_TypeError,
495 "Operators.sort(): 1st argument: invalid BinaryPredicate1D object");
499 if (!PyErr_Occurred()) {
500 PyErr_SetString(PyExc_RuntimeError,
"Operators.sort() failed");
509 Operators_create_doc,
510 ".. staticmethod:: create(pred, shaders)\n"
512 " Creates and shades the strokes from the current set of chains. A\n"
513 " predicate can be specified to make a selection pass on the chains.\n"
515 " :arg pred: The predicate that a chain must verify in order to be\n"
516 " transform as a stroke.\n"
517 " :type pred: :class:`UnaryPredicate1D`\n"
518 " :arg shaders: The list of shaders used to shade the strokes.\n"
519 " :type shaders: list[:class:`StrokeShader`]\n");
522 static const char *kwlist[] = {
"pred",
"shaders",
nullptr};
523 PyObject *obj1 =
nullptr, *obj2 =
nullptr;
525 if (!PyArg_ParseTupleAndKeywords(
531 PyErr_SetString(PyExc_TypeError,
532 "Operators.create(): 1st argument: invalid UnaryPredicate1D object");
536 shaders.reserve(PyList_Size(obj2));
537 for (
int i = 0;
i < PyList_Size(obj2);
i++) {
538 PyObject *py_ss = PyList_GET_ITEM(obj2,
i);
540 PyErr_SetString(PyExc_TypeError,
541 "Operators.create(): 2nd argument must be a list of StrokeShader objects");
547 ss <<
"Operators.create(): item " << (
i + 1)
548 <<
" of the shaders list is invalid likely due to missing call of "
549 "StrokeShader.__init__()";
550 PyErr_SetString(PyExc_TypeError, ss.str().c_str());
553 shaders.push_back(shader);
556 if (!PyErr_Occurred()) {
557 PyErr_SetString(PyExc_RuntimeError,
"Operators.create() failed");
567 ".. staticmethod:: reset(delete_strokes=True)\n"
569 " Resets the line stylization process to the initial state. The results of\n"
570 " stroke creation are accumulated if **delete_strokes** is set to False.\n"
572 " :arg delete_strokes: Delete the strokes that are currently stored.\n"
573 " :type delete_strokes: bool\n");
576 static const char *kwlist[] = {
"delete_strokes",
nullptr};
577 PyObject *obj1 =
nullptr;
578 if (PyArg_ParseTupleAndKeywords(args, kwds,
"|O!", (
char **)kwlist, &PyBool_Type, &obj1)) {
583 PyErr_SetString(PyExc_RuntimeError,
"Operators.reset() failed");
591 Operators_get_viewedge_from_index_doc,
592 ".. staticmethod:: get_viewedge_from_index(i)\n"
594 " Returns the ViewEdge at the index in the current set of ViewEdges.\n"
596 " :arg i: index (0 <= i < Operators.get_view_edges_size()).\n"
598 " :return: The ViewEdge object.\n"
599 " :rtype: :class:`ViewEdge`\n");
604 static const char *kwlist[] = {
"i",
nullptr};
607 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"I", (
char **)kwlist, &
i)) {
611 PyErr_SetString(PyExc_IndexError,
"index out of range");
619 Operators_get_chain_from_index_doc,
620 ".. staticmethod:: get_chain_from_index(i)\n"
622 " Returns the Chain at the index in the current set of Chains.\n"
624 " :arg i: index (0 <= i < Operators.get_chains_size()).\n"
626 " :return: The Chain object.\n"
627 " :rtype: :class:`Chain`\n");
632 static const char *kwlist[] = {
"i",
nullptr};
635 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"I", (
char **)kwlist, &
i)) {
639 PyErr_SetString(PyExc_IndexError,
"index out of range");
647 Operators_get_stroke_from_index_doc,
648 ".. staticmethod:: get_stroke_from_index(i)\n"
650 " Returns the Stroke at the index in the current set of Strokes.\n"
652 " :arg i: index (0 <= i < Operators.get_strokes_size()).\n"
654 " :return: The Stroke object.\n"
655 " :rtype: :class:`Stroke`\n");
660 static const char *kwlist[] = {
"i",
nullptr};
663 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"I", (
char **)kwlist, &
i)) {
667 PyErr_SetString(PyExc_IndexError,
"index out of range");
675 Operators_get_view_edges_size_doc,
676 ".. staticmethod:: get_view_edges_size()\n"
678 " Returns the number of ViewEdges.\n"
680 " :return: The number of ViewEdges.\n"
689 Operators_get_chains_size_doc,
690 ".. staticmethod:: get_chains_size()\n"
692 " Returns the number of Chains.\n"
694 " :return: The number of Chains.\n"
703 Operators_get_strokes_size_doc,
704 ".. staticmethod:: get_strokes_size()\n"
706 " Returns the number of Strokes.\n"
708 " :return: The number of Strokes.\n"
719# pragma clang diagnostic push
720# pragma clang diagnostic ignored "-Wcast-function-type"
722# pragma GCC diagnostic push
723# pragma GCC diagnostic ignored "-Wcast-function-type"
730 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
731 Operators_select_doc},
734 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
735 Operators_chain_doc},
736 {
"bidirectional_chain",
738 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
739 Operators_bidirectional_chain_doc},
742 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
743 Operators_sequential_split_doc},
746 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
747 Operators_recursive_split_doc},
750 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
754 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
755 Operators_create_doc},
758 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
759 Operators_reset_doc},
760 {
"get_viewedge_from_index",
762 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
763 Operators_get_viewedge_from_index_doc},
764 {
"get_chain_from_index",
766 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
767 Operators_get_chain_from_index_doc},
768 {
"get_stroke_from_index",
770 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
771 Operators_get_stroke_from_index_doc},
772 {
"get_view_edges_size",
774 METH_NOARGS | METH_STATIC,
775 Operators_get_view_edges_size_doc},
778 METH_NOARGS | METH_STATIC,
779 Operators_get_chains_size_doc},
782 METH_NOARGS | METH_STATIC,
783 Operators_get_strokes_size_doc},
784 {
nullptr,
nullptr, 0,
nullptr},
789# pragma clang diagnostic pop
791# pragma GCC diagnostic pop
798 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)
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)
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.\n")
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