53 "Class defining the operators used in a style module. There are five\n"
54 "types of operators: Selection, chaining, splitting, sorting and\n"
55 "creation. All these operators are user controlled through functors,\n"
56 "predicates and shaders that are taken as arguments.");
60 Py_TYPE(
self)->tp_free((PyObject *)
self);
66 ".. staticmethod:: select(pred)\n"
68 " Selects the ViewEdges of the ViewMap verifying a specified\n"
71 " :arg pred: The predicate expressing this condition.\n"
72 " :type pred: :class:`UnaryPredicate1D`");
76 static const char *kwlist[] = {
"pred",
nullptr};
77 PyObject *obj =
nullptr;
79 if (!PyArg_ParseTupleAndKeywords(
85 PyErr_SetString(PyExc_TypeError,
86 "Operators.select(): 1st argument: invalid UnaryPredicate1D object");
90 if (!PyErr_Occurred()) {
91 PyErr_SetString(PyExc_RuntimeError,
"Operators.select() failed");
101 ".. staticmethod:: chain(it, pred, modifier)\n"
104 " Builds a set of chains from the current set of ViewEdges. Each\n"
105 " ViewEdge of the current list starts a new chain. The chaining\n"
106 " operator then iterates over the ViewEdges of the ViewMap using the\n"
107 " user specified iterator. This operator only iterates using the\n"
108 " increment operator and is therefore unidirectional.\n"
110 " :arg it: The iterator on the ViewEdges of the ViewMap. It contains\n"
111 " the chaining rule.\n"
112 " :type it: :class:`ViewEdgeIterator`\n"
113 " :arg pred: The predicate on the ViewEdge that expresses the\n"
114 " stopping condition.\n"
115 " :type pred: :class:`UnaryPredicate1D`\n"
116 " :arg modifier: A function that takes a ViewEdge as argument and\n"
117 " that is used to modify the processed ViewEdge state (the\n"
118 " timestamp incrementation is a typical illustration of such a modifier).\n"
119 " If this argument is not given, the time stamp is automatically managed.\n"
120 " :type modifier: :class:`UnaryFunction1DVoid`\n");
124 static const char *kwlist[] = {
"it",
"pred",
"modifier",
nullptr};
125 PyObject *obj1 =
nullptr, *obj2 =
nullptr, *obj3 =
nullptr;
127 if (!PyArg_ParseTupleAndKeywords(args,
141 PyErr_SetString(PyExc_TypeError,
142 "Operators.chain(): 1st argument: invalid ChainingIterator object");
146 PyErr_SetString(PyExc_TypeError,
147 "Operators.chain(): 2nd argument: invalid UnaryPredicate1D object");
154 if (!PyErr_Occurred()) {
155 PyErr_SetString(PyExc_RuntimeError,
"Operators.chain() failed");
162 PyErr_SetString(PyExc_TypeError,
163 "Operators.chain(): 3rd argument: invalid UnaryFunction1DVoid object");
170 if (!PyErr_Occurred()) {
171 PyErr_SetString(PyExc_RuntimeError,
"Operators.chain() failed");
181 Operators_bidirectional_chain_doc,
182 ".. staticmethod:: bidirectional_chain(it, pred)\n"
183 " bidirectional_chain(it)\n"
185 " Builds a set of chains from the current set of ViewEdges. Each\n"
186 " ViewEdge of the current list potentially starts a new chain. The\n"
187 " chaining operator then iterates over the ViewEdges of the ViewMap\n"
188 " using the user specified iterator. This operator iterates both using\n"
189 " the increment and decrement operators and is therefore bidirectional.\n"
190 " This operator works with a ChainingIterator which contains the\n"
191 " chaining rules. It is this last one which can be told to chain only\n"
192 " edges that belong to the selection or not to process twice a ViewEdge\n"
193 " during the chaining. Each time a ViewEdge is added to a chain, its\n"
194 " chaining time stamp is incremented. This allows you to keep track of\n"
195 " the number of chains to which a ViewEdge belongs to.\n"
197 " :arg it: The ChainingIterator on the ViewEdges of the ViewMap. It\n"
198 " contains the chaining rule.\n"
199 " :type it: :class:`ChainingIterator`\n"
200 " :arg pred: The predicate on the ViewEdge that expresses the stopping condition.\n"
201 " This parameter is optional, you make not want to pass a stopping criterion\n"
202 " when the stopping criterion is already contained in the iterator definition.\n"
203 " :type pred: :class:`UnaryPredicate1D`\n");
209 static const char *kwlist[] = {
"it",
"pred",
nullptr};
210 PyObject *obj1 =
nullptr, *obj2 =
nullptr;
212 if (!PyArg_ParseTupleAndKeywords(args,
226 "Operators.bidirectional_chain(): 1st argument: invalid ChainingIterator object");
231 if (!PyErr_Occurred()) {
232 PyErr_SetString(PyExc_RuntimeError,
"Operators.bidirectional_chain() failed");
241 "Operators.bidirectional_chain(): 2nd argument: invalid UnaryPredicate1D object");
247 if (!PyErr_Occurred()) {
248 PyErr_SetString(PyExc_RuntimeError,
"Operators.bidirectional_chain() failed");
258 Operators_sequential_split_doc,
259 ".. staticmethod:: sequential_split(starting_pred, stopping_pred, sampling=0.0)\n"
260 " sequential_split(pred, sampling=0.0)\n"
262 " Splits each chain of the current set of chains in a sequential way.\n"
263 " The points of each chain are processed (with a specified sampling)\n"
264 " sequentially. The first point of the initial chain is the\n"
265 " first point of one of the resulting chains. The splitting ends when\n"
266 " no more chain can start.\n"
270 " By specifying a starting and stopping predicate allows\n"
271 " the chains to overlap rather than chains partitioning.\n"
273 " :arg starting_pred: The predicate on a point that expresses the\n"
274 " starting condition. Each time this condition is verified, a new chain begins\n"
275 " :type starting_pred: :class:`UnaryPredicate0D`\n"
276 " :arg stopping_pred: The predicate on a point that expresses the\n"
277 " stopping condition. The chain ends as soon as this predicate is verified.\n"
278 " :type stopping_pred: :class:`UnaryPredicate0D`\n"
279 " :arg pred: The predicate on a point that expresses the splitting condition.\n"
280 " Each time the condition is verified, the chain is split into two chains.\n"
281 " The resulting set of chains is a partition of the initial chain\n"
282 " :type pred: :class:`UnaryPredicate0D`\n"
283 " :arg sampling: The resolution used to sample the chain for the\n"
284 " predicates evaluation. (The chain is not actually resampled;\n"
285 " a virtual point only progresses along the curve using this\n"
287 " :type sampling: float\n");
293 static const char *kwlist_1[] = {
"starting_pred",
"stopping_pred",
"sampling",
nullptr};
294 static const char *kwlist_2[] = {
"pred",
"sampling",
nullptr};
295 PyObject *obj1 =
nullptr, *obj2 =
nullptr;
298 if (PyArg_ParseTupleAndKeywords(args,
311 "Operators.sequential_split(): 1st argument: invalid UnaryPredicate0D object");
317 "Operators.sequential_split(): 2nd argument: invalid UnaryPredicate0D object");
324 if (!PyErr_Occurred()) {
325 PyErr_SetString(PyExc_RuntimeError,
"Operators.sequential_split() failed");
330 else if ((
void)PyErr_Clear(),
332 PyArg_ParseTupleAndKeywords(
338 "Operators.sequential_split(): 1st argument: invalid UnaryPredicate0D object");
342 if (!PyErr_Occurred()) {
343 PyErr_SetString(PyExc_RuntimeError,
"Operators.sequential_split() failed");
349 PyErr_SetString(PyExc_TypeError,
"invalid argument(s)");
357 Operators_recursive_split_doc,
358 ".. staticmethod:: recursive_split(func, pred_1d, sampling=0.0)\n"
359 " recursive_split(func, pred_0d, pred_1d, sampling=0.0)\n"
361 " Splits the current set of chains in a recursive way. We process the\n"
362 " points of each chain (with a specified sampling) to find the point\n"
363 " minimizing a specified function. The chain is split in two at this\n"
364 " point and the two new chains are processed in the same way. The\n"
365 " recursivity level is controlled through a predicate 1D that expresses\n"
366 " a stopping condition on the chain that is about to be processed.\n"
368 " The user can also specify a 0D predicate to make a first selection on the points\n"
369 " that can potentially be split. A point that doesn't verify the 0D\n"
370 " predicate won't be candidate in realizing the min.\n"
372 " :arg func: The Unary Function evaluated at each point of the chain.\n"
373 " The splitting point is the point minimizing this function.\n"
374 " :type func: :class:`UnaryFunction0DDouble`\n"
375 " :arg pred_0d: The Unary Predicate 0D used to select the candidate\n"
376 " points where the split can occur. For example, it is very likely\n"
377 " that would rather have your chain splitting around its middle\n"
378 " point than around one of its extremities. A 0D predicate working\n"
379 " on the curvilinear abscissa allows to add this kind of constraints.\n"
380 " :type pred_0d: :class:`UnaryPredicate0D`\n"
381 " :arg pred_1d: The Unary Predicate expressing the recursivity stopping\n"
382 " condition. This predicate is evaluated for each curve before it\n"
383 " actually gets split. If pred_1d(chain) is true, the curve won't be\n"
385 " :type pred_1d: :class:`UnaryPredicate1D`\n"
386 " :arg sampling: The resolution used to sample the chain for the\n"
387 " predicates evaluation. (The chain is not actually resampled; a\n"
388 " virtual point only progresses along the curve using this\n"
390 " :type sampling: float\n");
396 static const char *kwlist_1[] = {
"func",
"pred_1d",
"sampling",
nullptr};
397 static const char *kwlist_2[] = {
"func",
"pred_0d",
"pred_1d",
"sampling",
nullptr};
398 PyObject *obj1 =
nullptr, *obj2 =
nullptr, *obj3 =
nullptr;
401 if (PyArg_ParseTupleAndKeywords(args,
414 "Operators.recursive_split(): 1st argument: invalid UnaryFunction0DDouble object");
420 "Operators.recursive_split(): 2nd argument: invalid UnaryPredicate1D object");
427 if (!PyErr_Occurred()) {
428 PyErr_SetString(PyExc_RuntimeError,
"Operators.recursive_split() failed");
433 else if ((
void)PyErr_Clear(),
435 PyArg_ParseTupleAndKeywords(args,
450 "Operators.recursive_split(): 1st argument: invalid UnaryFunction0DDouble object");
456 "Operators.recursive_split(): 2nd argument: invalid UnaryPredicate0D object");
462 "Operators.recursive_split(): 3rd argument: invalid UnaryPredicate1D object");
470 if (!PyErr_Occurred()) {
471 PyErr_SetString(PyExc_RuntimeError,
"Operators.recursive_split() failed");
477 PyErr_SetString(PyExc_TypeError,
"invalid argument(s)");
486 ".. staticmethod:: sort(pred)\n"
488 " Sorts the current set of chains (or viewedges) according to the\n"
489 " comparison predicate given as argument.\n"
491 " :arg pred: The binary predicate used for the comparison.\n"
492 " :type pred: :class:`BinaryPredicate1D`");
496 static const char *kwlist[] = {
"pred",
nullptr};
497 PyObject *obj =
nullptr;
499 if (!PyArg_ParseTupleAndKeywords(
505 PyErr_SetString(PyExc_TypeError,
506 "Operators.sort(): 1st argument: invalid BinaryPredicate1D object");
510 if (!PyErr_Occurred()) {
511 PyErr_SetString(PyExc_RuntimeError,
"Operators.sort() failed");
520 Operators_create_doc,
521 ".. staticmethod:: create(pred, shaders)\n"
523 " Creates and shades the strokes from the current set of chains. A\n"
524 " predicate can be specified to make a selection pass on the chains.\n"
526 " :arg pred: The predicate that a chain must verify in order to be\n"
527 " transform as a stroke.\n"
528 " :type pred: :class:`UnaryPredicate1D`\n"
529 " :arg shaders: The list of shaders used to shade the strokes.\n"
530 " :type shaders: list[:class:`StrokeShader`]");
534 static const char *kwlist[] = {
"pred",
"shaders",
nullptr};
535 PyObject *obj1 =
nullptr, *obj2 =
nullptr;
537 if (!PyArg_ParseTupleAndKeywords(
543 PyErr_SetString(PyExc_TypeError,
544 "Operators.create(): 1st argument: invalid UnaryPredicate1D object");
548 shaders.reserve(PyList_Size(obj2));
549 for (
int i = 0; i < PyList_Size(obj2); i++) {
550 PyObject *py_ss = PyList_GET_ITEM(obj2, i);
552 PyErr_SetString(PyExc_TypeError,
553 "Operators.create(): 2nd argument must be a list of StrokeShader objects");
559 ss <<
"Operators.create(): item " << (i + 1)
560 <<
" of the shaders list is invalid likely due to missing call of "
561 "StrokeShader.__init__()";
562 PyErr_SetString(PyExc_TypeError, ss.str().c_str());
565 shaders.push_back(shader);
568 if (!PyErr_Occurred()) {
569 PyErr_SetString(PyExc_RuntimeError,
"Operators.create() failed");
579 ".. staticmethod:: reset(delete_strokes=True)\n"
581 " Resets the line stylization process to the initial state. The results of\n"
582 " stroke creation are accumulated if **delete_strokes** is set to False.\n"
584 " :arg delete_strokes: Delete the strokes that are currently stored.\n"
585 " :type delete_strokes: bool\n");
589 static const char *kwlist[] = {
"delete_strokes",
nullptr};
590 PyObject *obj1 =
nullptr;
591 if (PyArg_ParseTupleAndKeywords(args, kwds,
"|O!", (
char **)kwlist, &PyBool_Type, &obj1)) {
596 PyErr_SetString(PyExc_RuntimeError,
"Operators.reset() failed");
604 Operators_get_viewedge_from_index_doc,
605 ".. staticmethod:: get_viewedge_from_index(i)\n"
607 " Returns the ViewEdge at the index in the current set of ViewEdges.\n"
609 " :arg i: index (0 <= i < Operators.get_view_edges_size()).\n"
611 " :return: The ViewEdge object.\n"
612 " :rtype: :class:`ViewEdge`");
618 static const char *kwlist[] = {
"i",
nullptr};
621 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"I", (
char **)kwlist, &i)) {
625 PyErr_SetString(PyExc_IndexError,
"index out of range");
633 Operators_get_chain_from_index_doc,
634 ".. staticmethod:: get_chain_from_index(i)\n"
636 " Returns the Chain at the index in the current set of Chains.\n"
638 " :arg i: index (0 <= i < Operators.get_chains_size()).\n"
640 " :return: The Chain object.\n"
641 " :rtype: :class:`Chain`");
647 static const char *kwlist[] = {
"i",
nullptr};
650 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"I", (
char **)kwlist, &i)) {
654 PyErr_SetString(PyExc_IndexError,
"index out of range");
662 Operators_get_stroke_from_index_doc,
663 ".. staticmethod:: get_stroke_from_index(i)\n"
665 " Returns the Stroke at the index in the current set of Strokes.\n"
667 " :arg i: index (0 <= i < Operators.get_strokes_size()).\n"
669 " :return: The Stroke object.\n"
670 " :rtype: :class:`Stroke`");
676 static const char *kwlist[] = {
"i",
nullptr};
679 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"I", (
char **)kwlist, &i)) {
683 PyErr_SetString(PyExc_IndexError,
"index out of range");
691 Operators_get_view_edges_size_doc,
692 ".. staticmethod:: get_view_edges_size()\n"
694 " Returns the number of ViewEdges.\n"
696 " :return: The number of ViewEdges.\n"
706 Operators_get_chains_size_doc,
707 ".. staticmethod:: get_chains_size()\n"
709 " Returns the number of Chains.\n"
711 " :return: The number of Chains.\n"
721 Operators_get_strokes_size_doc,
722 ".. staticmethod:: get_strokes_size()\n"
724 " Returns the number of Strokes.\n"
726 " :return: The number of Strokes.\n"
738 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
739 Operators_select_doc},
742 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
743 Operators_chain_doc},
744 {
"bidirectional_chain",
746 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
747 Operators_bidirectional_chain_doc},
750 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
751 Operators_sequential_split_doc},
754 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
755 Operators_recursive_split_doc},
758 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
762 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
763 Operators_create_doc},
766 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
767 Operators_reset_doc},
768 {
"get_viewedge_from_index",
770 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
771 Operators_get_viewedge_from_index_doc},
772 {
"get_chain_from_index",
774 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
775 Operators_get_chain_from_index_doc},
776 {
"get_stroke_from_index",
778 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
779 Operators_get_stroke_from_index_doc},
780 {
"get_view_edges_size",
782 METH_NOARGS | METH_STATIC,
783 Operators_get_view_edges_size_doc},
786 METH_NOARGS | METH_STATIC,
787 Operators_get_chains_size_doc},
790 METH_NOARGS | METH_STATIC,
791 Operators_get_strokes_size_doc},
792 {
nullptr,
nullptr, 0,
nullptr},
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)
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