9 #include "../BPy_Convert.h"
10 #include "../Interface1D/BPy_Stroke.h"
24 "Class hierarchy: :class:`Iterator` > :class:`StrokeVertexIterator`\n"
26 "Class defining an iterator designed to iterate over the\n"
27 ":class:`StrokeVertex` of a :class:`Stroke`. An instance of a\n"
28 "StrokeVertexIterator can be obtained from a Stroke by calling\n"
29 "iter(), stroke_vertices_begin() or stroke_vertices_begin(). It is iterating\n"
30 "over the same vertices as an :class:`Interface0DIterator`. The difference\n"
31 "resides in the object access: an Interface0DIterator only allows\n"
32 "access to an Interface0D while one might need to access the\n"
33 "specialized StrokeVertex type. In this case, one should use a\n"
34 "StrokeVertexIterator. To call functions of the UnaryFuntion0D type,\n"
35 "a StrokeVertexIterator can be converted to an Interface0DIterator by\n"
36 "by calling Interface0DIterator(it).\n"
38 ".. method:: __init__()\n"
39 " __init__(brother)\n"
41 " Creates a :class:`StrokeVertexIterator` using either the\n"
42 " default constructor or the copy constructor.\n"
44 " :arg brother: A StrokeVertexIterator object.\n"
45 " :type brother: :class:`StrokeVertexIterator`");
51 static const char *kwlist_1[] = {
"brother",
nullptr};
52 static const char *kwlist_2[] = {
"stroke",
nullptr};
53 PyObject *brother =
nullptr, *stroke =
nullptr;
55 if (PyArg_ParseTupleAndKeywords(
63 else if ((
void)PyErr_Clear(),
64 PyArg_ParseTupleAndKeywords(
65 args, kwds,
"|O!", (
char **)kwlist_2, &
Stroke_Type, &stroke)) {
71 ((
BPy_Stroke *)stroke)->s->strokeVerticesBegin());
73 self->reversed =
false;
74 self->at_start =
true;
77 PyErr_SetString(PyExc_TypeError,
"argument 1 must be StrokeVertexIterator or Stroke");
80 self->py_it.it =
self->sv_it;
87 self->at_start =
true;
88 return (PyObject *)
self;
100 if (
self->sv_it->isBegin()) {
101 PyErr_SetNone(PyExc_StopIteration);
104 self->sv_it->decrement();
108 if (
self->sv_it->isEnd()) {
109 PyErr_SetNone(PyExc_StopIteration);
114 if (
self->at_start) {
115 self->at_start =
false;
119 else if (
self->sv_it->atLast()) {
120 PyErr_SetNone(PyExc_StopIteration);
124 self->sv_it->increment();
134 ".. method:: incremented()\n"
136 " Returns a copy of an incremented StrokeVertexIterator.\n"
138 " :return: A StrokeVertexIterator pointing the next StrokeVertex.\n"
139 " :rtype: :class:`StrokeVertexIterator`");
143 if (
self->sv_it->isEnd()) {
144 PyErr_SetString(PyExc_RuntimeError,
"cannot increment any more");
153 ".. method:: decremented()\n"
155 " Returns a copy of a decremented StrokeVertexIterator.\n"
157 " :return: A StrokeVertexIterator pointing the previous StrokeVertex.\n"
158 " :rtype: :class:`StrokeVertexIterator`");
162 if (
self->sv_it->isBegin()) {
163 PyErr_SetString(PyExc_RuntimeError,
"cannot decrement any more");
172 ".. method:: reversed()\n"
174 " Returns a StrokeVertexIterator that traverses stroke vertices in the\n"
177 " :return: A StrokeVertexIterator traversing stroke vertices backward.\n"
178 " :rtype: :class:`StrokeVertexIterator`");
189 StrokeVertexIterator_incremented_doc},
193 StrokeVertexIterator_decremented_doc},
197 StrokeVertexIterator_reversed_doc},
198 {
nullptr,
nullptr, 0,
nullptr},
204 "The StrokeVertex object currently pointed to by this iterator.\n"
206 ":type: :class:`StrokeVertex`");
211 if (
self->sv_it->isEnd()) {
212 PyErr_SetString(PyExc_RuntimeError,
"iteration has stopped");
223 "The curvilinear abscissa of the current point.\n"
229 return PyFloat_FromDouble(
self->sv_it->t());
233 "The point parameter at the current point in the stroke (0 <= u <= 1).\n"
239 return PyFloat_FromDouble(
self->sv_it->u());
243 "True if the iterator points to the last valid element.\n"
244 "For its counterpart (pointing to the first valid element), use it.is_begin.\n"
257 StrokeVertexIterator_object_doc,
262 StrokeVertexIterator_t_doc,
267 StrokeVertexIterator_u_doc,
272 StrokeVertexIterator_at_last_doc,
274 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
280 PyVarObject_HEAD_INIT(
nullptr, 0)
"StrokeVertexIterator",
298 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
299 StrokeVertexIterator_doc,
PyObject * PyBool_from_bool(bool b)
PyObject * BPy_StrokeVertex_from_StrokeVertex(StrokeVertex &sv)
PyObject * BPy_StrokeVertexIterator_from_StrokeVertexIterator(StrokeInternal::StrokeVertexIterator &sv_it, bool reversed)
PyTypeObject Iterator_Type
static int StrokeVertexIterator_init(BPy_StrokeVertexIterator *self, PyObject *args, PyObject *kwds)
static PyObject * StrokeVertexIterator_at_last_get(BPy_StrokeVertexIterator *self)
static PyObject * StrokeVertexIterator_reversed(BPy_StrokeVertexIterator *self)
static PyObject * StrokeVertexIterator_iternext(BPy_StrokeVertexIterator *self)
static PyObject * StrokeVertexIterator_t_get(BPy_StrokeVertexIterator *self, void *UNUSED(closure))
static PyObject * StrokeVertexIterator_decremented(BPy_StrokeVertexIterator *self)
PyTypeObject StrokeVertexIterator_Type
static PyObject * StrokeVertexIterator_object_get(BPy_StrokeVertexIterator *self, void *UNUSED(closure))
static PyGetSetDef BPy_StrokeVertexIterator_getseters[]
static PyMethodDef BPy_StrokeVertexIterator_methods[]
static PyObject * StrokeVertexIterator_incremented(BPy_StrokeVertexIterator *self)
static PyObject * StrokeVertexIterator_iter(BPy_StrokeVertexIterator *self)
static PyObject * StrokeVertexIterator_u_get(BPy_StrokeVertexIterator *self, void *UNUSED(closure))
PyDoc_STRVAR(StrokeVertexIterator_doc, "Class hierarchy: :class:`Iterator` > :class:`StrokeVertexIterator`\n" "\n" "Class defining an iterator designed to iterate over the\n" ":class:`StrokeVertex` of a :class:`Stroke`. An instance of a\n" "StrokeVertexIterator can be obtained from a Stroke by calling\n" "iter(), stroke_vertices_begin() or stroke_vertices_begin(). It is iterating\n" "over the same vertices as an :class:`Interface0DIterator`. The difference\n" "resides in the object access: an Interface0DIterator only allows\n" "access to an Interface0D while one might need to access the\n" "specialized StrokeVertex type. In this case, one should use a\n" "StrokeVertexIterator. To call functions of the UnaryFuntion0D type,\n" "a StrokeVertexIterator can be converted to an Interface0DIterator by\n" "by calling Interface0DIterator(it).\n" "\n" ".. method:: __init__()\n" " __init__(brother)\n" "\n" " Creates a :class:`StrokeVertexIterator` using either the\n" " default constructor or the copy constructor.\n" "\n" " :arg brother: A StrokeVertexIterator object.\n" " :type brother: :class:`StrokeVertexIterator`")
static void copy(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node)