Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2010-04-18 03:47:47 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2010-04-18 03:47:47 +0400
commitd7e08f2d33207fdf76b1b597ef0de9dec26e3987 (patch)
treeb310235b1d441e160c50bbfb7eceadb090694339 /source/blender/freestyle/intern/python/Iterator
parent11fc330f7ecfcb60bac3e29a83016ec7dfb85182 (diff)
Major documentation updates. The original Freestyle API reference
(http://freestyle.sourceforge.net/doc/html/index.html) has been incorporated into the Blender/Freestyle Python API implementation in the form of Sphinx-based embedded docstrings. Some C++-specific descriptions of classes and functions were revised so that they are suitable for Python programmers. Missing docstrings were filled, and sparse descriptions were extended. By means of the new documentation system for Blender, an up-to-date Freestyle Python API reference will be part of the Blender 2.5 documentation.
Diffstat (limited to 'source/blender/freestyle/intern/python/Iterator')
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp158
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp155
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp113
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp203
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp161
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp143
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp173
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp184
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp231
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp127
10 files changed, 1047 insertions, 601 deletions
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
index dcc56b406e1..a4fe0164f78 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
@@ -9,66 +9,35 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-/*--------------- Python API function prototypes for AdjacencyIterator instance -----------*/
-static int AdjacencyIterator___init__(BPy_AdjacencyIterator *self, PyObject *args);
-static PyObject * AdjacencyIterator_iternext(BPy_AdjacencyIterator *self);
-
-static PyObject * AdjacencyIterator_isIncoming(BPy_AdjacencyIterator *self);
-static PyObject * AdjacencyIterator_getObject(BPy_AdjacencyIterator *self);
-
-/*----------------------AdjacencyIterator instance definitions ----------------------------*/
-static PyMethodDef BPy_AdjacencyIterator_methods[] = {
- {"isIncoming", ( PyCFunction ) AdjacencyIterator_isIncoming, METH_NOARGS, "() Returns true if the current ViewEdge is is coming towards the iteration vertex. False otherwise."},
- {"getObject", ( PyCFunction ) AdjacencyIterator_getObject, METH_NOARGS, "() Get object referenced by the iterator"},
- {NULL, NULL, 0, NULL}
-};
-
-/*-----------------------BPy_AdjacencyIterator type definition ------------------------------*/
-
-PyTypeObject AdjacencyIterator_Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "AdjacencyIterator", /* tp_name */
- sizeof(BPy_AdjacencyIterator), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- "AdjacencyIterator objects", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- PyObject_SelfIter, /* tp_iter */
- (iternextfunc)AdjacencyIterator_iternext, /* tp_iternext */
- BPy_AdjacencyIterator_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &Iterator_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)AdjacencyIterator___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
-};
-
//------------------------INSTANCE METHODS ----------------------------------
-int AdjacencyIterator___init__(BPy_AdjacencyIterator *self, PyObject *args )
+static char AdjacencyIterator___doc__[] =
+"Class for representing adjacency iterators used in the chaining\n"
+"process. An AdjacencyIterator is created in the increment() and\n"
+"decrement() methods of a :class:`ChainingIterator` and passed to the\n"
+"traverse() method of the ChainingIterator.\n"
+"\n"
+".. method:: __init__(iVertex, iRestrictToSelection=True, iRestrictToUnvisited=True)\n"
+"\n"
+" Builds a AdjacencyIterator object.\n"
+"\n"
+" :arg iVertex: The vertex which is the next crossing.\n"
+" :type iVertex: :class:`ViewVertex`\n"
+" :arg iRestrictToSelection: Indicates whether to force the chaining\n"
+" to stay within the set of selected ViewEdges or not.\n"
+" :type iRestrictToSelection: bool\n"
+" :arg iRestrictToUnvisited: Indicates whether a ViewEdge that has\n"
+" already been chained must be ignored ot not.\n"
+" :type iRestrictToUnvisited: bool\n"
+"\n"
+".. method:: __init__(it)\n"
+"\n"
+" Copy constructor.\n"
+"\n"
+" :arg it: An AdjacencyIterator object.\n"
+" :type it: :class:`AdjacencyIterator`\n";
+
+static int AdjacencyIterator___init__(BPy_AdjacencyIterator *self, PyObject *args )
{
PyObject *obj1 = 0, *obj2 = 0 , *obj3 = 0;
@@ -98,7 +67,7 @@ int AdjacencyIterator___init__(BPy_AdjacencyIterator *self, PyObject *args )
}
-PyObject * AdjacencyIterator_iternext(BPy_AdjacencyIterator *self) {
+static PyObject * AdjacencyIterator_iternext(BPy_AdjacencyIterator *self) {
if (self->a_it->isEnd()) {
PyErr_SetNone(PyExc_StopIteration);
return NULL;
@@ -108,11 +77,29 @@ PyObject * AdjacencyIterator_iternext(BPy_AdjacencyIterator *self) {
return BPy_ViewEdge_from_ViewEdge( *ve );
}
-PyObject * AdjacencyIterator_isIncoming(BPy_AdjacencyIterator *self) {
+static char AdjacencyIterator_isIncoming___doc__[] =
+".. method:: isIncoming()\n"
+"\n"
+" Returns true if the current ViewEdge is coming towards the\n"
+" iteration vertex. False otherwise.\n"
+"\n"
+" :return: True if the current ViewEdge is coming towards the\n"
+" iteration vertex\n"
+" :rtype: bool\n";
+
+static PyObject * AdjacencyIterator_isIncoming(BPy_AdjacencyIterator *self) {
return PyBool_from_bool(self->a_it->isIncoming());
}
-PyObject * AdjacencyIterator_getObject(BPy_AdjacencyIterator *self) {
+static char AdjacencyIterator_getObject___doc__[] =
+".. method:: getObject()\n"
+"\n"
+" Returns the pointed ViewEdge.\n"
+"\n"
+" :return: The pointed ViewEdge.\n"
+" :rtype: ViewEdge* operator\n";
+
+static PyObject * AdjacencyIterator_getObject(BPy_AdjacencyIterator *self) {
ViewEdge *ve = self->a_it->operator*();
if( ve )
@@ -121,6 +108,55 @@ PyObject * AdjacencyIterator_getObject(BPy_AdjacencyIterator *self) {
Py_RETURN_NONE;
}
+/*----------------------AdjacencyIterator instance definitions ----------------------------*/
+static PyMethodDef BPy_AdjacencyIterator_methods[] = {
+ {"isIncoming", ( PyCFunction ) AdjacencyIterator_isIncoming, METH_NOARGS, AdjacencyIterator_isIncoming___doc__},
+ {"getObject", ( PyCFunction ) AdjacencyIterator_getObject, METH_NOARGS, AdjacencyIterator_getObject___doc__},
+ {NULL, NULL, 0, NULL}
+};
+
+/*-----------------------BPy_AdjacencyIterator type definition ------------------------------*/
+
+PyTypeObject AdjacencyIterator_Type = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "AdjacencyIterator", /* tp_name */
+ sizeof(BPy_AdjacencyIterator), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ 0, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ AdjacencyIterator___doc__, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ PyObject_SelfIter, /* tp_iter */
+ (iternextfunc)AdjacencyIterator_iternext, /* tp_iternext */
+ BPy_AdjacencyIterator_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ &Iterator_Type, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)AdjacencyIterator___init__, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
index f6750dc23d3..624d983da4d 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
@@ -11,56 +11,70 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-/*--------------- Python API function prototypes for ChainPredicateIterator instance -----------*/
-static int ChainPredicateIterator___init__(BPy_ChainPredicateIterator *self, PyObject *args);
-static void ChainPredicateIterator___dealloc__(BPy_ChainPredicateIterator *self);
-
-/*-----------------------BPy_ChainPredicateIterator type definition ------------------------------*/
-
-PyTypeObject ChainPredicateIterator_Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "ChainPredicateIterator", /* tp_name */
- sizeof(BPy_ChainPredicateIterator), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)ChainPredicateIterator___dealloc__, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- "ChainPredicateIterator objects", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &ChainingIterator_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ChainPredicateIterator___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
-};
-
//------------------------INSTANCE METHODS ----------------------------------
-int ChainPredicateIterator___init__(BPy_ChainPredicateIterator *self, PyObject *args )
+static char ChainPredicateIterator___doc__[] =
+"A \"generic\" user-controlled ViewEdge iterator. This iterator is in\n"
+"particular built from a unary predicate and a binary predicate.\n"
+"First, the unary predicate is evaluated for all potential next\n"
+"ViewEdges in order to only keep the ones respecting a certain\n"
+"constraint. Then, the binary predicate is evaluated on the current\n"
+"ViewEdge together with each ViewEdge of the previous selection. The\n"
+"first ViewEdge respecting both the unary predicate and the binary\n"
+"predicate is kept as the next one. If none of the potential next\n"
+"ViewEdge respects these two predicates, None is returned.\n"
+"\n"
+".. method:: __init__(iRestrictToSelection=True, iRestrictToUnvisited=True, begin=None, orientation=True)\n"
+"\n"
+" Builds a ChainPredicateIterator from a starting ViewEdge and its\n"
+" orientation.\n"
+"\n"
+" :arg iRestrictToSelection: Indicates whether to force the chaining\n"
+" to stay within the set of selected ViewEdges or not.\n"
+" :type iRestrictToSelection: bool\n"
+" :arg iRestrictToUnvisited: Indicates whether a ViewEdge that has\n"
+" already been chained must be ignored ot not.\n"
+" :type iRestrictToUnvisited: bool\n"
+" :arg begin: The ViewEdge from where to start the iteration.\n"
+" :type begin: :class:`ViewEdge` or None\n"
+" :arg orientation: If true, we'll look for the next ViewEdge among\n"
+" the ViewEdges that surround the ending ViewVertex of begin. If\n"
+" false, we'll search over the ViewEdges surrounding the ending\n"
+" ViewVertex of begin. \n"
+" :type orientation: bool\n"
+"\n"
+".. method:: __init__(upred, bpred, iRestrictToSelection=True, iRestrictToUnvisited=True, begin=None, orientation=True)\n"
+"\n"
+" Builds a ChainPredicateIterator from a unary predicate, a binary\n"
+" predicate, a starting ViewEdge and its orientation.\n"
+"\n"
+" :arg upred: The unary predicate that the next ViewEdge must satisfy.\n"
+" :type upred: :class:`UnaryPredicate1D`\n"
+" :arg bpred: The binary predicate that the next ViewEdge must\n"
+" satisfy together with the actual pointed ViewEdge.\n"
+" :type bpred: :class:`BinaryPredicate1D`\n"
+" :arg iRestrictToSelection: Indicates whether to force the chaining\n"
+" to stay within the set of selected ViewEdges or not.\n"
+" :type iRestrictToSelection: bool\n"
+" :arg iRestrictToUnvisited: Indicates whether a ViewEdge that has\n"
+" already been chained must be ignored ot not.\n"
+" :type iRestrictToUnvisited: bool\n"
+" :arg begin: The ViewEdge from where to start the iteration.\n"
+" :type begin: :class:`ViewEdge`\n"
+" :arg orientation: If true, we'll look for the next ViewEdge among\n"
+" the ViewEdges that surround the ending ViewVertex of begin. If\n"
+" false, we'll search over the ViewEdges surrounding the ending\n"
+" ViewVertex of begin.\n"
+" :type orientation: bool\n"
+"\n"
+".. method:: __init__(brother)\n"
+"\n"
+" Copy constructor.\n"
+"\n"
+" :arg brother: A ChainPredicateIterator object.\n"
+" :type brother: :class:`ChainPredicateIterator`\n";
+
+static int ChainPredicateIterator___init__(BPy_ChainPredicateIterator *self, PyObject *args )
{
PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0, *obj4 = 0, *obj5 = 0, *obj6 = 0;
@@ -132,13 +146,56 @@ int ChainPredicateIterator___init__(BPy_ChainPredicateIterator *self, PyObject *
}
-void ChainPredicateIterator___dealloc__(BPy_ChainPredicateIterator *self)
+static void ChainPredicateIterator___dealloc__(BPy_ChainPredicateIterator *self)
{
Py_XDECREF( self->upred );
Py_XDECREF( self->bpred );
ChainingIterator_Type.tp_dealloc((PyObject *)self);
}
+/*-----------------------BPy_ChainPredicateIterator type definition ------------------------------*/
+
+PyTypeObject ChainPredicateIterator_Type = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "ChainPredicateIterator", /* tp_name */
+ sizeof(BPy_ChainPredicateIterator), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)ChainPredicateIterator___dealloc__, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ChainPredicateIterator___doc__, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ &ChainingIterator_Type, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ChainPredicateIterator___init__, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+};
+
///////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp
index 3c7f3cd7836..00e62ad30d4 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp
@@ -9,8 +9,75 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-/*--------------- Python API function prototypes for ChainSilhouetteIterator instance -----------*/
-static int ChainSilhouetteIterator___init__(BPy_ChainSilhouetteIterator *self, PyObject *args);
+//------------------------INSTANCE METHODS ----------------------------------
+
+// ChainSilhouetteIterator (bool iRestrictToSelection=true, ViewEdge *begin=NULL, bool orientation=true)
+// ChainSilhouetteIterator (const ChainSilhouetteIterator &brother)
+
+static char ChainSilhouetteIterator___doc__[] =
+"A ViewEdge Iterator used to follow ViewEdges the most naturally. For\n"
+"example, it will follow visible ViewEdges of same nature. As soon, as\n"
+"the nature or the visibility changes, the iteration stops (by setting\n"
+"the pointed ViewEdge to 0). In the case of an iteration over a set of\n"
+"ViewEdge that are both Silhouette and Crease, there will be a\n"
+"precedence of the silhouette over the crease criterion.\n"
+"\n"
+".. method:: __init__(iRestrictToSelection=True, begin=None, orientation=True)\n"
+"\n"
+" Builds a ChainSilhouetteIterator from the first ViewEdge used for\n"
+" iteration and its orientation.\n"
+"\n"
+" :arg iRestrictToSelection: Indicates whether to force the chaining\n"
+" to stay within the set of selected ViewEdges or not.\n"
+" :type iRestrictToSelection: bool\n"
+" :arg begin: The ViewEdge from where to start the iteration.\n"
+" :type begin: :class:`ViewEdge`\n"
+" :arg orientation: If true, we'll look for the next ViewEdge among\n"
+" the ViewEdges that surround the ending ViewVertex of begin. If\n"
+" false, we'll search over the ViewEdges surrounding the ending\n"
+" ViewVertex of begin.\n"
+" :type orientation: bool\n"
+"\n"
+".. method:: __init__(brother)\n"
+"\n"
+" Copy constructor.\n"
+"\n"
+" :arg brother: A ChainSilhouetteIterator object.\n"
+" :type brother: :class:`ChainSilhouetteIterator`\n";
+
+static int ChainSilhouetteIterator___init__(BPy_ChainSilhouetteIterator *self, PyObject *args )
+{
+ PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0;
+
+ if (!( PyArg_ParseTuple(args, "|OOO", &obj1, &obj2, &obj3) ))
+ return -1;
+
+ if( obj1 && BPy_ChainSilhouetteIterator_Check(obj1) ) {
+ self->cs_it = new ChainSilhouetteIterator(*( ((BPy_ChainSilhouetteIterator *) obj1)->cs_it ));
+
+ } else {
+ bool restrictToSelection = ( obj1 ) ? bool_from_PyBool(obj1) : true;
+ ViewEdge *begin;
+ if ( !obj2 || obj2 == Py_None )
+ begin = NULL;
+ else if ( BPy_ViewEdge_Check(obj2) )
+ begin = ((BPy_ViewEdge *) obj2)->ve;
+ else {
+ PyErr_SetString(PyExc_TypeError, "2nd argument must be either a ViewEdge object or None");
+ return -1;
+ }
+ bool orientation = ( obj3 ) ? bool_from_PyBool(obj3) : true;
+
+ self->cs_it = new ChainSilhouetteIterator( restrictToSelection, begin, orientation);
+ }
+
+ self->py_c_it.c_it = self->cs_it;
+ self->py_c_it.py_ve_it.ve_it = self->cs_it;
+ self->py_c_it.py_ve_it.py_it.it = self->cs_it;
+
+ return 0;
+
+}
/*-----------------------BPy_ChainSilhouetteIterator type definition ------------------------------*/
@@ -35,7 +102,7 @@ PyTypeObject ChainSilhouetteIterator_Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- "ChainSilhouetteIterator objects", /* tp_doc */
+ ChainSilhouetteIterator___doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
@@ -55,46 +122,6 @@ PyTypeObject ChainSilhouetteIterator_Type = {
0, /* tp_new */
};
-//------------------------INSTANCE METHODS ----------------------------------
-
-// ChainSilhouetteIterator (bool iRestrictToSelection=true, ViewEdge *begin=NULL, bool orientation=true)
-// ChainSilhouetteIterator (const ChainSilhouetteIterator &brother)
-
-int ChainSilhouetteIterator___init__(BPy_ChainSilhouetteIterator *self, PyObject *args )
-{
- PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0;
-
- if (!( PyArg_ParseTuple(args, "|OOO", &obj1, &obj2, &obj3) ))
- return -1;
-
- if( obj1 && BPy_ChainSilhouetteIterator_Check(obj1) ) {
- self->cs_it = new ChainSilhouetteIterator(*( ((BPy_ChainSilhouetteIterator *) obj1)->cs_it ));
-
- } else {
- bool restrictToSelection = ( obj1 ) ? bool_from_PyBool(obj1) : true;
- ViewEdge *begin;
- if ( !obj2 || obj2 == Py_None )
- begin = NULL;
- else if ( BPy_ViewEdge_Check(obj2) )
- begin = ((BPy_ViewEdge *) obj2)->ve;
- else {
- PyErr_SetString(PyExc_TypeError, "2nd argument must be either a ViewEdge object or None");
- return -1;
- }
- bool orientation = ( obj3 ) ? bool_from_PyBool(obj3) : true;
-
- self->cs_it = new ChainSilhouetteIterator( restrictToSelection, begin, orientation);
- }
-
- self->py_c_it.c_it = self->cs_it;
- self->py_c_it.py_ve_it.ve_it = self->cs_it;
- self->py_c_it.py_ve_it.py_it.it = self->cs_it;
-
- return 0;
-
-}
-
-
///////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
index 52c5b080c52..9d3b1e5c0be 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
@@ -11,71 +11,43 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-/*--------------- Python API function prototypes for ChainingIterator instance -----------*/
-static int ChainingIterator___init__(BPy_ChainingIterator *self, PyObject *args);
-static PyObject * ChainingIterator_init( BPy_ChainingIterator *self );
-static PyObject * ChainingIterator_traverse( BPy_ChainingIterator *self, PyObject *args );
-static PyObject * ChainingIterator_getVertex( BPy_ChainingIterator *self );
-static PyObject * ChainingIterator_isIncrementing( BPy_ChainingIterator *self );
-
-static PyObject * ChainingIterator_getObject( BPy_ChainingIterator *self);
-
-/*----------------------ChainingIterator instance definitions ----------------------------*/
-static PyMethodDef BPy_ChainingIterator_methods[] = {
- {"init", ( PyCFunction ) ChainingIterator_init, METH_NOARGS, "() Inits the iterator context. This method is called each time a new chain is started. It can be used to reset some history information that you might want to keep."},
- {"traverse", ( PyCFunction ) ChainingIterator_traverse, METH_VARARGS, "(AdjacencyIterator ai) This method iterates over the potential next ViewEdges and returns the one that will be followed next. Returns the next ViewEdge to follow or 0 when the end of the chain is reached. "},
- {"getVertex", ( PyCFunction ) ChainingIterator_getVertex, METH_NOARGS, "() Returns the vertex which is the next crossing "},
- {"isIncrementing", ( PyCFunction ) ChainingIterator_isIncrementing, METH_NOARGS, "() Returns true if the current iteration is an incrementation."},
- {"getObject", ( PyCFunction ) ChainingIterator_getObject, METH_NOARGS, "() Get object referenced by the iterator"},
- {NULL, NULL, 0, NULL}
-};
-
-/*-----------------------BPy_ChainingIterator type definition ------------------------------*/
-
-PyTypeObject ChainingIterator_Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "ChainingIterator", /* tp_name */
- sizeof(BPy_ChainingIterator), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- "ChainingIterator objects", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- BPy_ChainingIterator_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &ViewEdgeIterator_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ChainingIterator___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
-};
-
//------------------------INSTANCE METHODS ----------------------------------
-int ChainingIterator___init__(BPy_ChainingIterator *self, PyObject *args )
+static char ChainingIterator___doc__[] =
+"Base class for chaining iterators. This class is designed to be\n"
+"overloaded in order to describe chaining rules. It makes the\n"
+"description of chaining rules easier. The two main methods that need\n"
+"to overloaded are traverse() and init(). traverse() tells which\n"
+":class:`ViewEdge` to follow, among the adjacent ones. If you specify\n"
+"restriction rules (such as \"Chain only ViewEdges of the selection\"),\n"
+"they will be included in the adjacency iterator (i.e, the adjacent\n"
+"iterator will only stop on \"valid\" edges).\n"
+"\n"
+".. method:: __init__(iRestrictToSelection=True, iRestrictToUnvisited=True, begin=None, orientation=True)\n"
+"\n"
+" Builds a Chaining Iterator from the first ViewEdge used for\n"
+" iteration and its orientation.\n"
+"\n"
+" :arg iRestrictToSelection: Indicates whether to force the chaining\n"
+" to stay within the set of selected ViewEdges or not.\n"
+" :type iRestrictToSelection: bool\n"
+" :arg iRestrictToUnvisited: Indicates whether a ViewEdge that has\n"
+" already been chained must be ignored ot not.\n"
+" :type iRestrictToUnvisited: bool\n"
+" :arg begin: The ViewEdge from which to start the chain.\n"
+" :type begin: :class:`ViewEdge` or None\n"
+" :arg orientation: The direction to follow to explore the graph. If\n"
+" true, the direction indicated by the first ViewEdge is used.\n"
+" :type orientation: bool\n"
+"\n"
+".. method:: __init__(brother)\n"
+"\n"
+" Copy constructor.\n"
+"\n"
+" :arg brother: \n"
+" :type brother: ChainingIterator\n";
+
+static int ChainingIterator___init__(BPy_ChainingIterator *self, PyObject *args )
{
PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0, *obj4 = 0;
@@ -110,7 +82,14 @@ int ChainingIterator___init__(BPy_ChainingIterator *self, PyObject *args )
return 0;
}
-PyObject *ChainingIterator_init( BPy_ChainingIterator *self ) {
+static char ChainingIterator_init___doc__[] =
+".. method:: init()\n"
+"\n"
+" Initializes the iterator context. This method is called each\n"
+" time a new chain is started. It can be used to reset some\n"
+" history information that you might want to keep.\n";
+
+static PyObject *ChainingIterator_init( BPy_ChainingIterator *self ) {
if( typeid(*(self->c_it)) == typeid(ChainingIterator) ) {
PyErr_SetString(PyExc_TypeError, "init() method not properly overridden");
return NULL;
@@ -120,7 +99,21 @@ PyObject *ChainingIterator_init( BPy_ChainingIterator *self ) {
Py_RETURN_NONE;
}
-PyObject *ChainingIterator_traverse( BPy_ChainingIterator *self, PyObject *args ) {
+static char ChainingIterator_traverse___doc__[] =
+".. method:: traverse(it)\n"
+"\n"
+" This method iterates over the potential next ViewEdges and returns\n"
+" the one that will be followed next. Returns the next ViewEdge to\n"
+" follow or None when the end of the chain is reached.\n"
+"\n"
+" :arg it: The iterator over the ViewEdges adjacent to the end vertex\n"
+" of the current ViewEdge. The adjacency iterator reflects the\n"
+" restriction rules by only iterating over the valid ViewEdges.\n"
+" :type it: :class:`AdjacencyIterator`\n"
+" :return: Returns the next ViewEdge to follow, or None if chaining ends.\n"
+" :rtype: :class:`ViewEdge` or None\n";
+
+static PyObject *ChainingIterator_traverse( BPy_ChainingIterator *self, PyObject *args ) {
PyObject *py_a_it;
if(!( PyArg_ParseTuple(args, "O!", &AdjacencyIterator_Type, &py_a_it) ))
@@ -136,8 +129,15 @@ PyObject *ChainingIterator_traverse( BPy_ChainingIterator *self, PyObject *args
Py_RETURN_NONE;
}
+static char ChainingIterator_getVertex___doc__[] =
+".. method:: getVertex()\n"
+"\n"
+" Returns the vertex which is the next crossing.\n"
+"\n"
+" :return: The vertex which is the next crossing.\n"
+" :rtype: :class:`ViewVertex`\n";
-PyObject *ChainingIterator_getVertex( BPy_ChainingIterator *self ) {
+static PyObject *ChainingIterator_getVertex( BPy_ChainingIterator *self ) {
ViewVertex *v = self->c_it->getVertex();
if( v )
return Any_BPy_ViewVertex_from_ViewVertex( *v );
@@ -145,11 +145,27 @@ PyObject *ChainingIterator_getVertex( BPy_ChainingIterator *self ) {
Py_RETURN_NONE;
}
-PyObject *ChainingIterator_isIncrementing( BPy_ChainingIterator *self ) {
+static char ChainingIterator_isIncrementing___doc__[] =
+".. method:: isIncrementing()\n"
+"\n"
+" Returns true if the current iteration is an incrementation.\n"
+"\n"
+" :return: True if the current iteration is an incrementation.\n"
+" :rtype: bool\n";
+
+static PyObject *ChainingIterator_isIncrementing( BPy_ChainingIterator *self ) {
return PyBool_from_bool( self->c_it->isIncrementing() );
}
-PyObject * ChainingIterator_getObject( BPy_ChainingIterator *self) {
+static char ChainingIterator_getObject___doc__[] =
+".. method:: getObject()\n"
+"\n"
+" Returns the pointed ViewEdge.\n"
+"\n"
+" :return: The pointed ViewEdge.\n"
+" :rtype: :class:`ViewEdge`\n";
+
+static PyObject * ChainingIterator_getObject( BPy_ChainingIterator *self) {
ViewEdge *ve = self->c_it->operator*();
if( ve )
@@ -158,7 +174,58 @@ PyObject * ChainingIterator_getObject( BPy_ChainingIterator *self) {
Py_RETURN_NONE;
}
+/*----------------------ChainingIterator instance definitions ----------------------------*/
+static PyMethodDef BPy_ChainingIterator_methods[] = {
+ {"init", ( PyCFunction ) ChainingIterator_init, METH_NOARGS, ChainingIterator_init___doc__},
+ {"traverse", ( PyCFunction ) ChainingIterator_traverse, METH_VARARGS, ChainingIterator_traverse___doc__},
+ {"getVertex", ( PyCFunction ) ChainingIterator_getVertex, METH_NOARGS, ChainingIterator_getVertex___doc__},
+ {"isIncrementing", ( PyCFunction ) ChainingIterator_isIncrementing, METH_NOARGS, ChainingIterator_isIncrementing___doc__},
+ {"getObject", ( PyCFunction ) ChainingIterator_getObject, METH_NOARGS, ChainingIterator_getObject___doc__},
+ {NULL, NULL, 0, NULL}
+};
+
+/*-----------------------BPy_ChainingIterator type definition ------------------------------*/
+PyTypeObject ChainingIterator_Type = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "ChainingIterator", /* tp_name */
+ sizeof(BPy_ChainingIterator), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ 0, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ChainingIterator___doc__, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ BPy_ChainingIterator_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ &ViewEdgeIterator_Type, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ChainingIterator___init__, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
index 0086a99a442..9af842b7612 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
@@ -9,20 +9,113 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-/*--------------- Python API function prototypes for CurvePointIterator instance -----------*/
-static int CurvePointIterator___init__(BPy_CurvePointIterator *self, PyObject *args);
-static PyObject * CurvePointIterator_t( BPy_CurvePointIterator *self );
-static PyObject * CurvePointIterator_u( BPy_CurvePointIterator *self );
-static PyObject * CurvePointIterator_castToInterface0DIterator( BPy_CurvePointIterator *self );
+//------------------------INSTANCE METHODS ----------------------------------
+
+static char CurvePointIterator___doc__[] =
+"Class representing an iterator on a curve. Allows an iterating\n"
+"outside initial vertices. A CurvePoint is instanciated and returned\n"
+"by getObject().\n"
+"\n"
+".. method:: __init__(step=0.0)\n"
+"\n"
+" Builds a CurvePointIterator object.\n"
+"\n"
+" :arg step: A resampling resolution with which the curve is resampled.\n"
+" If zero, no resampling is done (i.e., the iterator iterates over\n"
+" initial vertices).\n"
+" :type step: float\n"
+"\n"
+".. method:: __init__(brother)\n"
+"\n"
+" Copy constructor.\n"
+"\n"
+" :arg brother: A CurvePointIterator object.\n"
+" :type brother: :class:`CurvePointIterator`\n";
+
+static int CurvePointIterator___init__(BPy_CurvePointIterator *self, PyObject *args )
+{
+ PyObject *obj = 0;
+
+ if (! PyArg_ParseTuple(args, "|O", &obj) )
+ return -1;
+
+ if( !obj ){
+ self->cp_it = new CurveInternal::CurvePointIterator();
+
+ } else if( BPy_CurvePointIterator_Check(obj) ) {
+ self->cp_it = new CurveInternal::CurvePointIterator(*( ((BPy_CurvePointIterator *) obj)->cp_it ));
+
+ } else if( PyFloat_Check(obj) ) {
+ self->cp_it = new CurveInternal::CurvePointIterator( PyFloat_AsDouble(obj) );
+
+ } else {
+ PyErr_SetString(PyExc_TypeError, "invalid argument");
+ return -1;
+ }
-static PyObject * CurvePointIterator_getObject(BPy_CurvePointIterator *self);
+ self->py_it.it = self->cp_it;
+
+ return 0;
+}
+
+static char CurvePointIterator_t___doc__[] =
+".. method:: t()\n"
+"\n"
+" Returns the curvilinear abscissa.\n"
+"\n"
+" :return: The curvilinear abscissa.\n"
+" :rtype: float\n";
+
+PyObject * CurvePointIterator_t( BPy_CurvePointIterator *self ) {
+ return PyFloat_FromDouble( self->cp_it->t() );
+}
+
+static char CurvePointIterator_u___doc__[] =
+".. method:: u()\n"
+"\n"
+" Returns the point parameter in the curve (0<=u<=1).\n"
+"\n"
+" :return: The point parameter.\n"
+" :rtype: float\n";
+
+static PyObject * CurvePointIterator_u( BPy_CurvePointIterator *self ) {
+ return PyFloat_FromDouble( self->cp_it->u() );
+}
+
+static char CurvePointIterator_castToInterface0DIterator___doc__[] =
+".. method:: castToInterface0DIterator()\n"
+"\n"
+" Returns an Interface0DIterator converted from this\n"
+" CurvePointIterator. Useful for any call to a function of the\n"
+" UnaryFunction0D type.\n"
+"\n"
+" :return: An Interface0DIterator object converted from the\n"
+" iterator.\n"
+" :rtype: :class:`Interface0DIterator`\n";
+
+static PyObject * CurvePointIterator_castToInterface0DIterator( BPy_CurvePointIterator *self ) {
+ Interface0DIterator it( self->cp_it->castToInterface0DIterator() );
+ return BPy_Interface0DIterator_from_Interface0DIterator( it, 0 );
+}
+
+static char CurvePointIterator_getObject___doc__[] =
+".. method:: getObject()\n"
+"\n"
+" Returns a CurvePoint pointed by the iterator.\n"
+"\n"
+" :return: \n"
+" :rtype: :class:`CurvePoint`\n";
+
+static PyObject * CurvePointIterator_getObject(BPy_CurvePointIterator *self) {
+ return BPy_CurvePoint_from_CurvePoint( self->cp_it->operator*() );
+}
/*----------------------CurvePointIterator instance definitions ----------------------------*/
static PyMethodDef BPy_CurvePointIterator_methods[] = {
- {"t", ( PyCFunction ) CurvePointIterator_t, METH_NOARGS, "() Returns the curvilinear abscissa."},
- {"u", ( PyCFunction ) CurvePointIterator_u, METH_NOARGS, "() Returns the point parameter in the curve 0<=u<=1."},
- {"castToInterface0DIterator", ( PyCFunction ) CurvePointIterator_castToInterface0DIterator, METH_NOARGS, "() Casts this CurvePointIterator into an Interface0DIterator. Useful for any call to a function of the type UnaryFunction0D."},
- {"getObject", ( PyCFunction ) CurvePointIterator_getObject, METH_NOARGS, "() Get object referenced by the iterator"},
+ {"t", ( PyCFunction ) CurvePointIterator_t, METH_NOARGS, CurvePointIterator_t___doc__},
+ {"u", ( PyCFunction ) CurvePointIterator_u, METH_NOARGS, CurvePointIterator_u___doc__},
+ {"castToInterface0DIterator", ( PyCFunction ) CurvePointIterator_castToInterface0DIterator, METH_NOARGS, CurvePointIterator_castToInterface0DIterator___doc__},
+ {"getObject", ( PyCFunction ) CurvePointIterator_getObject, METH_NOARGS, CurvePointIterator_getObject___doc__},
{NULL, NULL, 0, NULL}
};
@@ -49,7 +142,7 @@ PyTypeObject CurvePointIterator_Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- "CurvePointIterator objects", /* tp_doc */
+ CurvePointIterator___doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
@@ -69,52 +162,6 @@ PyTypeObject CurvePointIterator_Type = {
0, /* tp_new */
};
-//------------------------INSTANCE METHODS ----------------------------------
-
-int CurvePointIterator___init__(BPy_CurvePointIterator *self, PyObject *args )
-{
- PyObject *obj = 0;
-
- if (! PyArg_ParseTuple(args, "|O", &obj) )
- return -1;
-
- if( !obj ){
- self->cp_it = new CurveInternal::CurvePointIterator();
-
- } else if( BPy_CurvePointIterator_Check(obj) ) {
- self->cp_it = new CurveInternal::CurvePointIterator(*( ((BPy_CurvePointIterator *) obj)->cp_it ));
-
- } else if( PyFloat_Check(obj) ) {
- self->cp_it = new CurveInternal::CurvePointIterator( PyFloat_AsDouble(obj) );
-
- } else {
- PyErr_SetString(PyExc_TypeError, "invalid argument");
- return -1;
- }
-
- self->py_it.it = self->cp_it;
-
- return 0;
-}
-
-PyObject * CurvePointIterator_t( BPy_CurvePointIterator *self ) {
- return PyFloat_FromDouble( self->cp_it->t() );
-}
-
-PyObject * CurvePointIterator_u( BPy_CurvePointIterator *self ) {
- return PyFloat_FromDouble( self->cp_it->u() );
-}
-
-PyObject * CurvePointIterator_castToInterface0DIterator( BPy_CurvePointIterator *self ) {
- Interface0DIterator it( self->cp_it->castToInterface0DIterator() );
- return BPy_Interface0DIterator_from_Interface0DIterator( it, 0 );
-}
-
-PyObject * CurvePointIterator_getObject(BPy_CurvePointIterator *self) {
- return BPy_CurvePoint_from_CurvePoint( self->cp_it->operator*() );
-}
-
-
///////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
index 3fbea715e8d..7276f7cd46b 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
@@ -8,20 +8,94 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-/*--------------- Python API function prototypes for Interface0DIterator instance -----------*/
-static int Interface0DIterator___init__(BPy_Interface0DIterator *self, PyObject *args);
-static PyObject * Interface0DIterator_iternext( BPy_Interface0DIterator *self );
+//------------------------INSTANCE METHODS ----------------------------------
+
+static char Interface0DIterator___doc__[] =
+"Class defining an iterator over Interface0D elements. An instance of\n"
+"this iterator is always obtained from a 1D element.\n"
+"\n"
+".. method:: __init__(it)\n"
+"\n"
+" Copy constructor.\n"
+"\n"
+" :arg it: An Interface0DIterator object.\n"
+" :type it: :class:`Interface0DIterator`\n";
+
+static int Interface0DIterator___init__(BPy_Interface0DIterator *self, PyObject *args )
+{
+ PyObject *obj = 0;
+
+ if (!( PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj) ))
+ return -1;
+
+ self->if0D_it = new Interface0DIterator(*( ((BPy_Interface0DIterator *) obj)->if0D_it ));
+ self->py_it.it = self->if0D_it;
+ self->reversed = 0;
+
+ return 0;
+}
+
+static PyObject * Interface0DIterator_iternext( BPy_Interface0DIterator *self ) {
+ Interface0D *if0D;
+ if (self->reversed) {
+ if (self->if0D_it->isBegin()) {
+ PyErr_SetNone(PyExc_StopIteration);
+ return NULL;
+ }
+ self->if0D_it->decrement();
+ if0D = self->if0D_it->operator->();
+ } else {
+ if (self->if0D_it->isEnd()) {
+ PyErr_SetNone(PyExc_StopIteration);
+ return NULL;
+ }
+ if0D = self->if0D_it->operator->();
+ self->if0D_it->increment();
+ }
+ return Any_BPy_Interface0D_from_Interface0D( *if0D );
+}
-static PyObject * Interface0DIterator_t( BPy_Interface0DIterator *self );
-static PyObject * Interface0DIterator_u( BPy_Interface0DIterator *self );
+static char Interface0DIterator_t___doc__[] =
+".. method:: t()\n"
+"\n"
+" Returns the curvilinear abscissa.\n"
+"\n"
+" :return: The curvilinear abscissa.\n"
+" :rtype: float\n";
-static PyObject * Interface0DIterator_getObject(BPy_Interface0DIterator *self);
+static PyObject * Interface0DIterator_t( BPy_Interface0DIterator *self ) {
+ return PyFloat_FromDouble( self->if0D_it->t() );
+}
+
+static char Interface0DIterator_u___doc__[] =
+".. method:: u()\n"
+"\n"
+" Returns the point parameter in the curve 0<=u<=1.\n"
+"\n"
+" :return: The point parameter.\n"
+" :rtype: float\n";
+
+static PyObject * Interface0DIterator_u( BPy_Interface0DIterator *self ) {
+ return PyFloat_FromDouble( self->if0D_it->u() );
+}
+
+static char Interface0DIterator_getObject___doc__[] =
+".. method:: getObject()\n"
+"\n"
+" Returns the pointed Interface0D.\n"
+"\n"
+" :return: The pointed Interface0D.\n"
+" :rtype: :class:`Interface0D`\n";
+
+static PyObject * Interface0DIterator_getObject(BPy_Interface0DIterator *self) {
+ return Any_BPy_Interface0D_from_Interface0D( self->if0D_it->operator*() );
+}
/*----------------------Interface0DIterator instance definitions ----------------------------*/
static PyMethodDef BPy_Interface0DIterator_methods[] = {
- {"t", ( PyCFunction ) Interface0DIterator_t, METH_NOARGS, "() Returns the curvilinear abscissa."},
- {"u", ( PyCFunction ) Interface0DIterator_u, METH_NOARGS, "() Returns the point parameter in the curve 0<=u<=1."},
- {"getObject", ( PyCFunction ) Interface0DIterator_getObject, METH_NOARGS, "() Get object referenced by the iterator"},
+ {"t", ( PyCFunction ) Interface0DIterator_t, METH_NOARGS, Interface0DIterator_t___doc__},
+ {"u", ( PyCFunction ) Interface0DIterator_u, METH_NOARGS, Interface0DIterator_u___doc__},
+ {"getObject", ( PyCFunction ) Interface0DIterator_getObject, METH_NOARGS, Interface0DIterator_getObject___doc__},
{NULL, NULL, 0, NULL}
};
@@ -48,7 +122,7 @@ PyTypeObject Interface0DIterator_Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- "Interface0DIterator objects", /* tp_doc */
+ Interface0DIterator___doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
@@ -68,55 +142,6 @@ PyTypeObject Interface0DIterator_Type = {
0, /* tp_new */
};
-//------------------------INSTANCE METHODS ----------------------------------
-
-int Interface0DIterator___init__(BPy_Interface0DIterator *self, PyObject *args )
-{
- PyObject *obj = 0;
-
- if (!( PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj) ))
- return -1;
-
- self->if0D_it = new Interface0DIterator(*( ((BPy_Interface0DIterator *) obj)->if0D_it ));
- self->py_it.it = self->if0D_it;
- self->reversed = 0;
-
- return 0;
-}
-
-PyObject * Interface0DIterator_iternext( BPy_Interface0DIterator *self ) {
- Interface0D *if0D;
- if (self->reversed) {
- if (self->if0D_it->isBegin()) {
- PyErr_SetNone(PyExc_StopIteration);
- return NULL;
- }
- self->if0D_it->decrement();
- if0D = self->if0D_it->operator->();
- } else {
- if (self->if0D_it->isEnd()) {
- PyErr_SetNone(PyExc_StopIteration);
- return NULL;
- }
- if0D = self->if0D_it->operator->();
- self->if0D_it->increment();
- }
- return Any_BPy_Interface0D_from_Interface0D( *if0D );
-}
-
-PyObject * Interface0DIterator_t( BPy_Interface0DIterator *self ) {
- return PyFloat_FromDouble( self->if0D_it->t() );
-}
-
-PyObject * Interface0DIterator_u( BPy_Interface0DIterator *self ) {
- return PyFloat_FromDouble( self->if0D_it->u() );
-}
-
-PyObject * Interface0DIterator_getObject(BPy_Interface0DIterator *self) {
- return Any_BPy_Interface0D_from_Interface0D( self->if0D_it->operator*() );
-}
-
-
///////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
index 5e5d45c61fd..06329ce2e30 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
@@ -10,68 +10,41 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-/*--------------- Python API function prototypes for SVertexIterator instance -----------*/
-static int SVertexIterator___init__(BPy_SVertexIterator *self, PyObject *args);
-
-static PyObject * SVertexIterator_t( BPy_SVertexIterator *self );
-static PyObject * SVertexIterator_u( BPy_SVertexIterator *self );
-
-static PyObject * SVertexIterator_getObject( BPy_SVertexIterator *self);
-
-/*----------------------SVertexIterator instance definitions ----------------------------*/
-static PyMethodDef BPy_SVertexIterator_methods[] = {
- {"t", ( PyCFunction ) SVertexIterator_t, METH_NOARGS, "() Returns the curvilinear abscissa."},
- {"u", ( PyCFunction ) SVertexIterator_u, METH_NOARGS, "() Returns the point parameter in the curve 0<=u<=1."},
- {"getObject", ( PyCFunction ) SVertexIterator_getObject, METH_NOARGS, "() Get object referenced by the iterator"},
- {NULL, NULL, 0, NULL}
-};
-
-/*-----------------------BPy_SVertexIterator type definition ------------------------------*/
-
-PyTypeObject SVertexIterator_Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "SVertexIterator", /* tp_name */
- sizeof(BPy_SVertexIterator), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- "SVertexIterator objects", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- BPy_SVertexIterator_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &Iterator_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)SVertexIterator___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
-};
-
//------------------------INSTANCE METHODS ----------------------------------
-int SVertexIterator___init__(BPy_SVertexIterator *self, PyObject *args )
+static char SVertexIterator___doc__[] =
+"Class representing an iterator over :class:`SVertex` of a\n"
+":class:`ViewEdge`. An instance of an SVertexIterator can be obtained\n"
+"from a ViewEdge by calling verticesBegin() or verticesEnd().\n"
+"\n"
+".. method:: __init__()\n"
+"\n"
+" Default constructor.\n"
+"\n"
+".. method:: __init__(it)\n"
+"\n"
+" Copy constructor.\n"
+"\n"
+" :arg it: An SVertexIterator object.\n"
+" :type it: :class:`SVertexIterator`\n"
+"\n"
+".. method:: __init__(v, begin, prev, next, t)\n"
+"\n"
+" Builds an SVertexIterator that starts iteration from an SVertex\n"
+" object v.\n"
+"\n"
+" :arg v: The SVertex from which the iterator starts iteration.\n"
+" :type v: :class:`SVertex`\n"
+" :arg begin: The first vertex of a view edge.\n"
+" :type begin: :class:`SVertex`\n"
+" :arg prev: The previous FEdge coming to v.\n"
+" :type prev: :class:`FEdge`\n"
+" :arg next: The next FEdge going out from v.\n"
+" :type next: :class:`FEdge`\n"
+" :arg t: The curvilinear abscissa at v.\n"
+" :type t: float\n";
+
+static int SVertexIterator___init__(BPy_SVertexIterator *self, PyObject *args )
{
PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0, *obj4 = 0;
float f = 0;
@@ -107,15 +80,39 @@ int SVertexIterator___init__(BPy_SVertexIterator *self, PyObject *args )
return 0;
}
-PyObject * SVertexIterator_t( BPy_SVertexIterator *self ) {
+static char SVertexIterator_t___doc__[] =
+".. method:: t()\n"
+"\n"
+" Returns the curvilinear abscissa.\n"
+"\n"
+" :return: The curvilinear abscissa.\n"
+" :rtype: float\n";
+
+static PyObject * SVertexIterator_t( BPy_SVertexIterator *self ) {
return PyFloat_FromDouble( self->sv_it->t() );
}
-PyObject * SVertexIterator_u( BPy_SVertexIterator *self ) {
+static char SVertexIterator_u___doc__[] =
+".. method:: u()\n"
+"\n"
+" Returns the point parameter (0<=u<=1).\n"
+"\n"
+" :return: The point parameter.\n"
+" :rtype: float\n";
+
+static PyObject * SVertexIterator_u( BPy_SVertexIterator *self ) {
return PyFloat_FromDouble( self->sv_it->u() );
}
-PyObject * SVertexIterator_getObject( BPy_SVertexIterator *self) {
+static char SVertexIterator_getObject___doc__[] =
+".. method:: getObject()\n"
+"\n"
+" Returns the pointed SVertex.\n"
+"\n"
+" :return: the pointed SVertex.\n"
+" :rtype: :class:`SVertex`\n";
+
+static PyObject * SVertexIterator_getObject( BPy_SVertexIterator *self) {
SVertex *sv = self->sv_it->operator->();
if( sv )
@@ -124,6 +121,56 @@ PyObject * SVertexIterator_getObject( BPy_SVertexIterator *self) {
Py_RETURN_NONE;
}
+/*----------------------SVertexIterator instance definitions ----------------------------*/
+static PyMethodDef BPy_SVertexIterator_methods[] = {
+ {"t", ( PyCFunction ) SVertexIterator_t, METH_NOARGS, SVertexIterator_t___doc__},
+ {"u", ( PyCFunction ) SVertexIterator_u, METH_NOARGS, SVertexIterator_u___doc__},
+ {"getObject", ( PyCFunction ) SVertexIterator_getObject, METH_NOARGS, SVertexIterator_getObject___doc__},
+ {NULL, NULL, 0, NULL}
+};
+
+/*-----------------------BPy_SVertexIterator type definition ------------------------------*/
+
+PyTypeObject SVertexIterator_Type = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "SVertexIterator", /* tp_name */
+ sizeof(BPy_SVertexIterator), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ 0, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ SVertexIterator___doc__, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ BPy_SVertexIterator_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ &Iterator_Type, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)SVertexIterator___init__, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
index fbfe9a66861..607109ce3ad 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
@@ -9,71 +9,34 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-/*--------------- Python API function prototypes for StrokeVertexIterator instance -----------*/
-static int StrokeVertexIterator___init__(BPy_StrokeVertexIterator *self, PyObject *args);
-static PyObject * StrokeVertexIterator_iternext( BPy_StrokeVertexIterator *self );
-static PyObject * StrokeVertexIterator_t( BPy_StrokeVertexIterator *self );
-static PyObject * StrokeVertexIterator_u( BPy_StrokeVertexIterator *self );
-static PyObject * StrokeVertexIterator_castToInterface0DIterator( BPy_StrokeVertexIterator *self );
-
-static PyObject * StrokeVertexIterator_getObject( BPy_StrokeVertexIterator *self);
-
-
-/*----------------------StrokeVertexIterator instance definitions ----------------------------*/
-static PyMethodDef BPy_StrokeVertexIterator_methods[] = {
- {"t", ( PyCFunction ) StrokeVertexIterator_t, METH_NOARGS, "() Returns the curvilinear abscissa."},
- {"u", ( PyCFunction ) StrokeVertexIterator_u, METH_NOARGS, "() Returns the point parameter in the curve 0<=u<=1."},
- {"castToInterface0DIterator", ( PyCFunction ) StrokeVertexIterator_castToInterface0DIterator, METH_NOARGS, "() Casts this StrokeVertexIterator into an Interface0DIterator. Useful for any call to a function of the type UnaryFunction0D."},
- {"getObject", ( PyCFunction ) StrokeVertexIterator_getObject, METH_NOARGS, "() Get object referenced by the iterator"},
- {NULL, NULL, 0, NULL}
-};
-
-/*-----------------------BPy_StrokeVertexIterator type definition ------------------------------*/
-
-PyTypeObject StrokeVertexIterator_Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "StrokeVertexIterator", /* tp_name */
- sizeof(BPy_StrokeVertexIterator), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- "StrokeVertexIterator objects", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- PyObject_SelfIter, /* tp_iter */
- (iternextfunc)StrokeVertexIterator_iternext, /* tp_iternext */
- BPy_StrokeVertexIterator_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &Iterator_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)StrokeVertexIterator___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
-};
-
//------------------------INSTANCE METHODS ----------------------------------
-int StrokeVertexIterator___init__(BPy_StrokeVertexIterator *self, PyObject *args )
+static char StrokeVertexIterator___doc__[] =
+
+"Class defining an iterator designed to iterate over the\n"
+":class:`StrokeVertex` of a :class:`Stroke`. An instance of a\n"
+"StrokeVertexIterator can only be obtained from a Stroke by calling\n"
+"strokeVerticesBegin() or strokeVerticesEnd(). It is iterating over\n"
+"the same vertices as an :class:`Interface0DIterator`. The difference\n"
+"resides in the object access. Indeed, an Interface0DIterator allows\n"
+"only an access to an Interface0D whereas we could need to access the\n"
+"specialized StrokeVertex type. In this case, one should use a\n"
+"StrokeVertexIterator. The castToInterface0DIterator() method is\n"
+"useful to get an Interface0DIterator from a StrokeVertexIterator in\n"
+"order to call any functions of the UnaryFunction0D type.\n"
+"\n"
+".. method:: __init__()\n"
+"\n"
+" Default constructor.\n"
+"\n"
+".. method:: __init__(it)\n"
+"\n"
+" Copy constructor.\n"
+"\n"
+" :arg it: A StrokeVertexIterator object.\n"
+" :type it: :class:`StrokeVertexIterator`\n";
+
+static int StrokeVertexIterator___init__(BPy_StrokeVertexIterator *self, PyObject *args )
{
PyObject *obj = 0;
@@ -97,7 +60,7 @@ int StrokeVertexIterator___init__(BPy_StrokeVertexIterator *self, PyObject *args
return 0;
}
-PyObject * StrokeVertexIterator_iternext( BPy_StrokeVertexIterator *self ) {
+static PyObject * StrokeVertexIterator_iternext( BPy_StrokeVertexIterator *self ) {
StrokeVertex *sv;
if (self->reversed) {
if (self->sv_it->isBegin()) {
@@ -117,20 +80,54 @@ PyObject * StrokeVertexIterator_iternext( BPy_StrokeVertexIterator *self ) {
return BPy_StrokeVertex_from_StrokeVertex( *sv );
}
-PyObject * StrokeVertexIterator_t( BPy_StrokeVertexIterator *self ) {
+static char StrokeVertexIterator_t___doc__[] =
+".. method:: t()\n"
+"\n"
+" Returns the curvilinear abscissa of the current point.\n"
+"\n"
+" :return: The curvilinear abscissa of the current point.\n"
+" :rtype: float\n";
+
+static PyObject * StrokeVertexIterator_t( BPy_StrokeVertexIterator *self ) {
return PyFloat_FromDouble( self->sv_it->t() );
}
-PyObject * StrokeVertexIterator_u( BPy_StrokeVertexIterator *self ) {
+static char StrokeVertexIterator_u___doc__[] =
+".. method:: u()\n"
+"\n"
+" Returns the point parameter in the stroke (0<=u<=1).\n"
+"\n"
+" :return: The point parameter in the stroke\n"
+" :rtype: float\n";
+
+static PyObject * StrokeVertexIterator_u( BPy_StrokeVertexIterator *self ) {
return PyFloat_FromDouble( self->sv_it->u() );
}
-PyObject * StrokeVertexIterator_castToInterface0DIterator( BPy_StrokeVertexIterator *self ) {
+static char StrokeVertexIterator_castToInterface0DIterator___doc__[] =
+".. method:: castToInterface0DIterator()\n"
+"\n"
+" Returns an Interface0DIterator converted from this\n"
+" StrokeVertexIterator. Useful for any call to a function of the\n"
+" UnaryFunction0D type.\n"
+"\n"
+" :return: An Interface0DIterator converted from the StrokeVertexIterator.\n"
+" :rtype: :class:`Interface0DIterator`\n";
+
+static PyObject * StrokeVertexIterator_castToInterface0DIterator( BPy_StrokeVertexIterator *self ) {
Interface0DIterator it( self->sv_it->castToInterface0DIterator() );
return BPy_Interface0DIterator_from_Interface0DIterator( it, 0 );
}
-PyObject * StrokeVertexIterator_getObject( BPy_StrokeVertexIterator *self) {
+static char StrokeVertexIterator_getObject___doc__[] =
+".. method:: getObject()\n"
+"\n"
+" Returns the pointed StrokeVertex.\n"
+"\n"
+" :return: The pointed StrokeVertex.\n"
+" :rtype: :class:`StrokeVertex`\n";
+
+static PyObject * StrokeVertexIterator_getObject( BPy_StrokeVertexIterator *self) {
StrokeVertex *sv = self->sv_it->operator->();
if( sv )
return BPy_StrokeVertex_from_StrokeVertex( *sv );
@@ -138,6 +135,57 @@ PyObject * StrokeVertexIterator_getObject( BPy_StrokeVertexIterator *self) {
Py_RETURN_NONE;
}
+/*----------------------StrokeVertexIterator instance definitions ----------------------------*/
+static PyMethodDef BPy_StrokeVertexIterator_methods[] = {
+ {"t", ( PyCFunction ) StrokeVertexIterator_t, METH_NOARGS, StrokeVertexIterator_t___doc__},
+ {"u", ( PyCFunction ) StrokeVertexIterator_u, METH_NOARGS, StrokeVertexIterator_u___doc__},
+ {"castToInterface0DIterator", ( PyCFunction ) StrokeVertexIterator_castToInterface0DIterator, METH_NOARGS, StrokeVertexIterator_castToInterface0DIterator___doc__},
+ {"getObject", ( PyCFunction ) StrokeVertexIterator_getObject, METH_NOARGS, StrokeVertexIterator_getObject___doc__},
+ {NULL, NULL, 0, NULL}
+};
+
+/*-----------------------BPy_StrokeVertexIterator type definition ------------------------------*/
+
+PyTypeObject StrokeVertexIterator_Type = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "StrokeVertexIterator", /* tp_name */
+ sizeof(BPy_StrokeVertexIterator), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ 0, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ StrokeVertexIterator___doc__, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ PyObject_SelfIter, /* tp_iter */
+ (iternextfunc)StrokeVertexIterator_iternext, /* tp_iternext */
+ BPy_StrokeVertexIterator_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ &Iterator_Type, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)StrokeVertexIterator___init__, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp
index 29c7b6e9413..856cebb308c 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp
@@ -10,79 +10,35 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-/*--------------- Python API function prototypes for ViewEdgeIterator instance -----------*/
-static int ViewEdgeIterator___init__(BPy_ViewEdgeIterator *self, PyObject *args);
-
-static PyObject * ViewEdgeIterator_getCurrentEdge( BPy_ViewEdgeIterator *self );
-static PyObject * ViewEdgeIterator_setCurrentEdge( BPy_ViewEdgeIterator *self, PyObject *args );
-static PyObject * ViewEdgeIterator_getBegin( BPy_ViewEdgeIterator *self );
-static PyObject * ViewEdgeIterator_setBegin( BPy_ViewEdgeIterator *self, PyObject *args );
-static PyObject * ViewEdgeIterator_getOrientation( BPy_ViewEdgeIterator *self );
-static PyObject * ViewEdgeIterator_setOrientation( BPy_ViewEdgeIterator *self, PyObject *args );
-static PyObject * ViewEdgeIterator_changeOrientation( BPy_ViewEdgeIterator *self );
-
-static PyObject * ViewEdgeIterator_getObject(BPy_ViewEdgeIterator *self);
-
-
-/*----------------------ViewEdgeIterator instance definitions ----------------------------*/
-static PyMethodDef BPy_ViewEdgeIterator_methods[] = {
- {"getCurrentEdge", ( PyCFunction ) ViewEdgeIterator_getCurrentEdge, METH_NOARGS, "() Returns the current pointed ViewEdge."},
- {"setCurrentEdge", ( PyCFunction ) ViewEdgeIterator_setCurrentEdge, METH_VARARGS, "(ViewEdge ve) Sets the current pointed ViewEdge. "},
- {"getBegin", ( PyCFunction ) ViewEdgeIterator_getBegin, METH_NOARGS, "() Returns the first ViewEdge used for the iteration."},
- {"setBegin", ( PyCFunction ) ViewEdgeIterator_setBegin, METH_VARARGS, "(ViewEdge ve) Sets the first ViewEdge used for the iteration."},
- {"getOrientation", ( PyCFunction ) ViewEdgeIterator_getOrientation, METH_NOARGS, "() Gets the orientation of the pointed ViewEdge in the iteration. "},
- {"setOrientation", ( PyCFunction ) ViewEdgeIterator_setOrientation, METH_VARARGS, "(bool b) Sets the orientation of the pointed ViewEdge in the iteration. "},
- {"changeOrientation", ( PyCFunction ) ViewEdgeIterator_changeOrientation, METH_NOARGS, "() Changes the current orientation."},
- {"getObject", ( PyCFunction ) ViewEdgeIterator_getObject, METH_NOARGS, "() Get object referenced by the iterator"},
- {NULL, NULL, 0, NULL}
-};
-
-/*-----------------------BPy_ViewEdgeIterator type definition ------------------------------*/
-
-PyTypeObject ViewEdgeIterator_Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "ViewEdgeIterator", /* tp_name */
- sizeof(BPy_ViewEdgeIterator), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- "ViewEdgeIterator objects", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- BPy_ViewEdgeIterator_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &Iterator_Type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ViewEdgeIterator___init__, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
-};
-
//------------------------INSTANCE METHODS ----------------------------------
-int ViewEdgeIterator___init__(BPy_ViewEdgeIterator *self, PyObject *args )
+static char ViewEdgeIterator___doc__[] =
+"Base class for iterators over ViewEdges of the :class:`ViewMap` Graph.\n"
+"Basically the increment() operator of this class should be able to\n"
+"take the decision of \"where\" (on which ViewEdge) to go when pointing\n"
+"on a given ViewEdge.\n"
+"\n"
+".. method:: __init__(begin=None, orientation=True)\n"
+"\n"
+" Builds a ViewEdgeIterator from a starting ViewEdge and its\n"
+" orientation.\n"
+"\n"
+" :arg begin: The ViewEdge from where to start the iteration.\n"
+" :type begin: :class:`ViewEdge`\n"
+" :arg orientation: If true, we'll look for the next ViewEdge among\n"
+" the ViewEdges that surround the ending ViewVertex of begin. If\n"
+" false, we'll search over the ViewEdges surrounding the ending\n"
+" ViewVertex of begin.\n"
+" :type orientation: bool\n"
+"\n"
+".. method:: __init__(it)\n"
+"\n"
+" Copy constructor.\n"
+"\n"
+" :arg it: A ViewEdgeIterator object.\n"
+" :type it: :class:`ViewEdgeIterator`\n";
+
+static int ViewEdgeIterator___init__(BPy_ViewEdgeIterator *self, PyObject *args )
{
PyObject *obj1 = 0, *obj2 = 0;
@@ -113,8 +69,15 @@ int ViewEdgeIterator___init__(BPy_ViewEdgeIterator *self, PyObject *args )
return 0;
}
+static char ViewEdgeIterator_getCurrentEdge___doc__[] =
+".. method:: getCurrentEdge()\n"
+"\n"
+" Returns the current pointed ViewEdge.\n"
+"\n"
+" :return: The current pointed ViewEdge.\n"
+" :rtype: :class:`ViewEdge`\n";
-PyObject *ViewEdgeIterator_getCurrentEdge( BPy_ViewEdgeIterator *self ) {
+static PyObject *ViewEdgeIterator_getCurrentEdge( BPy_ViewEdgeIterator *self ) {
ViewEdge *ve = self->ve_it->getCurrentEdge();
if( ve )
return BPy_ViewEdge_from_ViewEdge( *ve );
@@ -122,7 +85,15 @@ PyObject *ViewEdgeIterator_getCurrentEdge( BPy_ViewEdgeIterator *self ) {
Py_RETURN_NONE;
}
-PyObject *ViewEdgeIterator_setCurrentEdge( BPy_ViewEdgeIterator *self, PyObject *args ) {
+static char ViewEdgeIterator_setCurrentEdge___doc__[] =
+".. method:: setCurrentEdge(edge)\n"
+"\n"
+" Sets the current pointed ViewEdge.\n"
+"\n"
+" :arg edge: The current pointed ViewEdge.\n"
+" :type edge: :class:`ViewEdge`\n";
+
+static PyObject *ViewEdgeIterator_setCurrentEdge( BPy_ViewEdgeIterator *self, PyObject *args ) {
PyObject *py_ve;
if(!( PyArg_ParseTuple(args, "O!", &ViewEdge_Type, &py_ve) ))
@@ -133,8 +104,15 @@ PyObject *ViewEdgeIterator_setCurrentEdge( BPy_ViewEdgeIterator *self, PyObject
Py_RETURN_NONE;
}
+static char ViewEdgeIterator_getBegin___doc__[] =
+".. method:: getBegin()\n"
+"\n"
+" Returns the first ViewEdge used for the iteration.\n"
+"\n"
+" :return: The first ViewEdge used for the iteration.\n"
+" :rtype: :class:`ViewEdge`\n";
-PyObject *ViewEdgeIterator_getBegin( BPy_ViewEdgeIterator *self ) {
+static PyObject *ViewEdgeIterator_getBegin( BPy_ViewEdgeIterator *self ) {
ViewEdge *ve = self->ve_it->getBegin();
if( ve )
return BPy_ViewEdge_from_ViewEdge( *ve );
@@ -142,7 +120,15 @@ PyObject *ViewEdgeIterator_getBegin( BPy_ViewEdgeIterator *self ) {
Py_RETURN_NONE;
}
-PyObject *ViewEdgeIterator_setBegin( BPy_ViewEdgeIterator *self, PyObject *args ) {
+static char ViewEdgeIterator_setBegin___doc__[] =
+".. method:: setBegin(begin)\n"
+"\n"
+" Sets the first ViewEdge used for the iteration.\n"
+"\n"
+" :arg begin: The first ViewEdge used for the iteration.\n"
+" :type begin: :class:`ViewEdge`\n";
+
+static PyObject *ViewEdgeIterator_setBegin( BPy_ViewEdgeIterator *self, PyObject *args ) {
PyObject *py_ve;
if(!( PyArg_ParseTuple(args, "O!", &ViewEdge_Type, &py_ve) ))
@@ -153,11 +139,30 @@ PyObject *ViewEdgeIterator_setBegin( BPy_ViewEdgeIterator *self, PyObject *args
Py_RETURN_NONE;
}
-PyObject *ViewEdgeIterator_getOrientation( BPy_ViewEdgeIterator *self ) {
+static char ViewEdgeIterator_getOrientation___doc__[] =
+".. method:: getOrientation()\n"
+"\n"
+" Returns the orientation of the pointed ViewEdge in the iteration.\n"
+"\n"
+" :return: The orientation of the pointed ViewEdge in the iteration.\n"
+" :rtype: bool\n";
+
+static PyObject *ViewEdgeIterator_getOrientation( BPy_ViewEdgeIterator *self ) {
return PyBool_from_bool( self->ve_it->getOrientation() );
}
-PyObject *ViewEdgeIterator_setOrientation( BPy_ViewEdgeIterator *self, PyObject *args ) {
+static char ViewEdgeIterator_setOrientation___doc__[] =
+".. method:: setOrientation(orientation)\n"
+"\n"
+" Sets the orientation of the pointed ViewEdge in the iteration.\n"
+"\n"
+" :arg orientation: If true, we'll look for the next ViewEdge among\n"
+" the ViewEdges that surround the ending ViewVertex of begin. If\n"
+" false, we'll search over the ViewEdges surrounding the ending\n"
+" ViewVertex of begin.\n"
+" :type orientation: bool\n";
+
+static PyObject *ViewEdgeIterator_setOrientation( BPy_ViewEdgeIterator *self, PyObject *args ) {
PyObject *py_b;
if(!( PyArg_ParseTuple(args, "O", &py_b) ))
@@ -168,13 +173,26 @@ PyObject *ViewEdgeIterator_setOrientation( BPy_ViewEdgeIterator *self, PyObject
Py_RETURN_NONE;
}
-PyObject *ViewEdgeIterator_changeOrientation( BPy_ViewEdgeIterator *self ) {
+static char ViewEdgeIterator_changeOrientation___doc__[] =
+".. method:: changeOrientation()\n"
+"\n"
+" Changes the current orientation.\n";
+
+static PyObject *ViewEdgeIterator_changeOrientation( BPy_ViewEdgeIterator *self ) {
self->ve_it->changeOrientation();
Py_RETURN_NONE;
}
-PyObject * ViewEdgeIterator_getObject( BPy_ViewEdgeIterator *self) {
+static char ViewEdgeIterator_getObject___doc__[] =
+".. method:: getObject()\n"
+"\n"
+" Returns the pointed ViewEdge.\n"
+"\n"
+" :return: The pointed ViewEdge.\n"
+" :rtype: :class:`ViewEdge`\n";
+
+static PyObject * ViewEdgeIterator_getObject( BPy_ViewEdgeIterator *self) {
ViewEdge *ve = self->ve_it->operator*();
if( ve )
@@ -183,6 +201,61 @@ PyObject * ViewEdgeIterator_getObject( BPy_ViewEdgeIterator *self) {
Py_RETURN_NONE;
}
+/*----------------------ViewEdgeIterator instance definitions ----------------------------*/
+static PyMethodDef BPy_ViewEdgeIterator_methods[] = {
+ {"getCurrentEdge", ( PyCFunction ) ViewEdgeIterator_getCurrentEdge, METH_NOARGS, ViewEdgeIterator_getCurrentEdge___doc__},
+ {"setCurrentEdge", ( PyCFunction ) ViewEdgeIterator_setCurrentEdge, METH_VARARGS, ViewEdgeIterator_setCurrentEdge___doc__},
+ {"getBegin", ( PyCFunction ) ViewEdgeIterator_getBegin, METH_NOARGS, ViewEdgeIterator_getBegin___doc__},
+ {"setBegin", ( PyCFunction ) ViewEdgeIterator_setBegin, METH_VARARGS, ViewEdgeIterator_setBegin___doc__},
+ {"getOrientation", ( PyCFunction ) ViewEdgeIterator_getOrientation, METH_NOARGS, ViewEdgeIterator_getOrientation___doc__},
+ {"setOrientation", ( PyCFunction ) ViewEdgeIterator_setOrientation, METH_VARARGS, ViewEdgeIterator_setOrientation___doc__},
+ {"changeOrientation", ( PyCFunction ) ViewEdgeIterator_changeOrientation, METH_NOARGS, ViewEdgeIterator_changeOrientation___doc__},
+ {"getObject", ( PyCFunction ) ViewEdgeIterator_getObject, METH_NOARGS, ViewEdgeIterator_getObject___doc__},
+ {NULL, NULL, 0, NULL}
+};
+
+/*-----------------------BPy_ViewEdgeIterator type definition ------------------------------*/
+
+PyTypeObject ViewEdgeIterator_Type = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "ViewEdgeIterator", /* tp_name */
+ sizeof(BPy_ViewEdgeIterator), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ 0, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ ViewEdgeIterator___doc__, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ BPy_ViewEdgeIterator_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ &Iterator_Type, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ViewEdgeIterator___init__, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+};
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
index 27f71d4cfc0..c080426daa8 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
@@ -8,16 +8,83 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-/*--------------- Python API function prototypes for orientedViewEdgeIterator instance -----------*/
-static int orientedViewEdgeIterator___init__(BPy_orientedViewEdgeIterator *self, PyObject *args);
-static PyObject * orientedViewEdgeIterator_iternext(BPy_orientedViewEdgeIterator *self);
+//------------------------INSTANCE METHODS ----------------------------------
+
+static char orientedViewEdgeIterator___doc__[] =
+"Class representing an iterator over oriented ViewEdges around a\n"
+":class:`ViewVertex`. This iterator allows a CCW iteration (in the image\n"
+"plane). An instance of an orientedViewEdgeIterator can only be\n"
+"obtained from a ViewVertex by calling edgesBegin() or edgesEnd().\n"
+"\n"
+".. method:: __init__()\n"
+"\n"
+" Default constructor.\n"
+"\n"
+".. method:: __init__(iBrother)\n"
+"\n"
+" Copy constructor.\n"
+"\n"
+" :arg iBrother: An orientedViewEdgeIterator object.\n"
+" :type iBrother: :class:`orientedViewEdgeIterator`\n";
+
+static int orientedViewEdgeIterator___init__(BPy_orientedViewEdgeIterator *self, PyObject *args )
+{
+ PyObject *obj = 0;
+
+ if (!( PyArg_ParseTuple(args, "|O", &obj) ))
+ return -1;
+
+ if( !obj )
+ self->ove_it = new ViewVertexInternal::orientedViewEdgeIterator();
+ else if( BPy_orientedViewEdgeIterator_Check(obj) )
+ self->ove_it = new ViewVertexInternal::orientedViewEdgeIterator(*( ((BPy_orientedViewEdgeIterator *) obj)->ove_it ));
+ else {
+ PyErr_SetString(PyExc_TypeError, "invalid argument");
+ return -1;
+ }
+
+ self->py_it.it = self->ove_it;
+ self->reversed = 0;
+
+ return 0;
+}
-static PyObject * orientedViewEdgeIterator_getObject(BPy_orientedViewEdgeIterator *self);
+static PyObject * orientedViewEdgeIterator_iternext( BPy_orientedViewEdgeIterator *self ) {
+ ViewVertex::directedViewEdge *dve;
+ if (self->reversed) {
+ if (self->ove_it->isBegin()) {
+ PyErr_SetNone(PyExc_StopIteration);
+ return NULL;
+ }
+ self->ove_it->decrement();
+ dve = self->ove_it->operator->();
+ } else {
+ if (self->ove_it->isEnd()) {
+ PyErr_SetNone(PyExc_StopIteration);
+ return NULL;
+ }
+ dve = self->ove_it->operator->();
+ self->ove_it->increment();
+ }
+ return BPy_directedViewEdge_from_directedViewEdge( *dve );
+}
+static char orientedViewEdgeIterator_getObject___doc__[] =
+".. method:: getObject()\n"
+"\n"
+" Returns the pointed oriented ViewEdge.\n"
+"\n"
+" :return: A tuple of the pointed ViewEdge and a boolean value. If\n"
+" the boolean value is true, the ViewEdge is incoming.\n"
+" :rtype: (:class:`directedViewEdge`, bool)\n";
+
+static PyObject * orientedViewEdgeIterator_getObject( BPy_orientedViewEdgeIterator *self) {
+ return BPy_directedViewEdge_from_directedViewEdge( self->ove_it->operator*() );
+}
/*----------------------orientedViewEdgeIterator instance definitions ----------------------------*/
static PyMethodDef BPy_orientedViewEdgeIterator_methods[] = {
- {"getObject", ( PyCFunction ) orientedViewEdgeIterator_getObject, METH_NOARGS, "() Get object referenced by the iterator"},
+ {"getObject", ( PyCFunction ) orientedViewEdgeIterator_getObject, METH_NOARGS, orientedViewEdgeIterator_getObject___doc__},
{NULL, NULL, 0, NULL}
};
@@ -44,7 +111,7 @@ PyTypeObject orientedViewEdgeIterator_Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- "orientedViewEdgeIterator objects", /* tp_doc */
+ orientedViewEdgeIterator___doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
@@ -64,54 +131,6 @@ PyTypeObject orientedViewEdgeIterator_Type = {
0, /* tp_new */
};
-//------------------------INSTANCE METHODS ----------------------------------
-
-int orientedViewEdgeIterator___init__(BPy_orientedViewEdgeIterator *self, PyObject *args )
-{
- PyObject *obj = 0;
-
- if (!( PyArg_ParseTuple(args, "|O", &obj) ))
- return -1;
-
- if( !obj )
- self->ove_it = new ViewVertexInternal::orientedViewEdgeIterator();
- else if( BPy_orientedViewEdgeIterator_Check(obj) )
- self->ove_it = new ViewVertexInternal::orientedViewEdgeIterator(*( ((BPy_orientedViewEdgeIterator *) obj)->ove_it ));
- else {
- PyErr_SetString(PyExc_TypeError, "invalid argument");
- return -1;
- }
-
- self->py_it.it = self->ove_it;
- self->reversed = 0;
-
- return 0;
-}
-
-PyObject * orientedViewEdgeIterator_iternext( BPy_orientedViewEdgeIterator *self ) {
- ViewVertex::directedViewEdge *dve;
- if (self->reversed) {
- if (self->ove_it->isBegin()) {
- PyErr_SetNone(PyExc_StopIteration);
- return NULL;
- }
- self->ove_it->decrement();
- dve = self->ove_it->operator->();
- } else {
- if (self->ove_it->isEnd()) {
- PyErr_SetNone(PyExc_StopIteration);
- return NULL;
- }
- dve = self->ove_it->operator->();
- self->ove_it->increment();
- }
- return BPy_directedViewEdge_from_directedViewEdge( *dve );
-}
-
-PyObject * orientedViewEdgeIterator_getObject( BPy_orientedViewEdgeIterator *self) {
- return BPy_directedViewEdge_from_directedViewEdge( self->ove_it->operator*() );
-}
-
///////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus