23 #include "../BPy_Convert.h"
24 #include "../Interface1D/BPy_Stroke.h"
38 "Class hierarchy: :class:`Iterator` > :class:`StrokeVertexIterator`\n"
40 "Class defining an iterator designed to iterate over the\n"
41 ":class:`StrokeVertex` of a :class:`Stroke`. An instance of a\n"
42 "StrokeVertexIterator can be obtained from a Stroke by calling\n"
43 "iter(), stroke_vertices_begin() or stroke_vertices_begin(). It is iterating\n"
44 "over the same vertices as an :class:`Interface0DIterator`. The difference\n"
45 "resides in the object access: an Interface0DIterator only allows\n"
46 "access to an Interface0D while one might need to access the\n"
47 "specialized StrokeVertex type. In this case, one should use a\n"
48 "StrokeVertexIterator. To call functions of the UnaryFuntion0D type,\n"
49 "a StrokeVertexIterator can be converted to an Interface0DIterator by\n"
50 "by calling Interface0DIterator(it).\n"
52 ".. method:: __init__()\n"
53 " __init__(brother)\n"
55 " Creates a :class:`StrokeVertexIterator` using either the\n"
56 " default constructor or the copy constructor.\n"
58 " :arg brother: A StrokeVertexIterator object.\n"
59 " :type brother: :class:`StrokeVertexIterator`");
65 static const char *kwlist_1[] = {
"brother",
nullptr};
66 static const char *kwlist_2[] = {
"stroke",
nullptr};
67 PyObject *brother =
nullptr, *stroke =
nullptr;
69 if (PyArg_ParseTupleAndKeywords(
77 else if ((
void)PyErr_Clear(),
78 PyArg_ParseTupleAndKeywords(
79 args, kwds,
"|O!", (
char **)kwlist_2, &
Stroke_Type, &stroke)) {
85 ((
BPy_Stroke *)stroke)->s->strokeVerticesBegin());
87 self->reversed =
false;
88 self->at_start =
true;
91 PyErr_SetString(PyExc_TypeError,
"argument 1 must be StrokeVertexIterator or Stroke");
94 self->py_it.it =
self->sv_it;
101 self->at_start =
true;
102 return (PyObject *)
self;
113 if (
self->reversed) {
114 if (
self->sv_it->isBegin()) {
115 PyErr_SetNone(PyExc_StopIteration);
118 self->sv_it->decrement();
122 if (
self->sv_it->isEnd()) {
123 PyErr_SetNone(PyExc_StopIteration);
128 if (
self->at_start) {
129 self->at_start =
false;
133 else if (
self->sv_it->atLast()) {
134 PyErr_SetNone(PyExc_StopIteration);
138 self->sv_it->increment();
148 ".. method:: incremented()\n"
150 " Returns a copy of an incremented StrokeVertexIterator.\n"
152 " :return: A StrokeVertexIterator pointing the next StrokeVertex.\n"
153 " :rtype: :class:`StrokeVertexIterator`");
157 if (
self->sv_it->isEnd()) {
158 PyErr_SetString(PyExc_RuntimeError,
"cannot increment any more");
167 ".. method:: decremented()\n"
169 " Returns a copy of a decremented StrokeVertexIterator.\n"
171 " :return: A StrokeVertexIterator pointing the previous StrokeVertex.\n"
172 " :rtype: :class:`StrokeVertexIterator`");
176 if (
self->sv_it->isBegin()) {
177 PyErr_SetString(PyExc_RuntimeError,
"cannot decrement any more");
186 ".. method:: reversed()\n"
188 " Returns a StrokeVertexIterator that traverses stroke vertices in the\n"
191 " :return: A StrokeVertexIterator traversing stroke vertices backward.\n"
192 " :rtype: :class:`StrokeVertexIterator`");
203 StrokeVertexIterator_incremented_doc},
207 StrokeVertexIterator_decremented_doc},
211 StrokeVertexIterator_reversed_doc},
212 {
nullptr,
nullptr, 0,
nullptr},
218 "The StrokeVertex object currently pointed to by this iterator.\n"
220 ":type: :class:`StrokeVertex`");
225 if (
self->sv_it->isEnd()) {
226 PyErr_SetString(PyExc_RuntimeError,
"iteration has stopped");
237 "The curvilinear abscissa of the current point.\n"
243 return PyFloat_FromDouble(
self->sv_it->t());
247 "The point parameter at the current point in the stroke (0 <= u <= 1).\n"
253 return PyFloat_FromDouble(
self->sv_it->u());
257 "True if the iterator points to the last valid element.\n"
258 "For its counterpart (pointing to the first valid element), use it.is_begin.\n"
271 StrokeVertexIterator_object_doc,
276 StrokeVertexIterator_t_doc,
281 StrokeVertexIterator_u_doc,
286 StrokeVertexIterator_at_last_doc,
288 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
294 PyVarObject_HEAD_INIT(
nullptr, 0)
"StrokeVertexIterator",
312 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
313 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)