Blender  V2.93
BPy_orientedViewEdgeIterator.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
22 
23 #include "../BPy_Convert.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 using namespace Freestyle;
30 
32 
33 //------------------------INSTANCE METHODS ----------------------------------
34 
35 PyDoc_STRVAR(orientedViewEdgeIterator_doc,
36  "Class hierarchy: :class:`Iterator` > :class:`orientedViewEdgeIterator`\n"
37  "\n"
38  "Class representing an iterator over oriented ViewEdges around a\n"
39  ":class:`ViewVertex`. This iterator allows a CCW iteration (in the image\n"
40  "plane). An instance of an orientedViewEdgeIterator can only be\n"
41  "obtained from a ViewVertex by calling edges_begin() or edges_end().\n"
42  "\n"
43  ".. method:: __init__()\n"
44  " __init__(iBrother)\n"
45  "\n"
46  " Creates an :class:`orientedViewEdgeIterator` using either the\n"
47  " default constructor or the copy constructor.\n"
48  "\n"
49  " :arg iBrother: An orientedViewEdgeIterator object.\n"
50  " :type iBrother: :class:`orientedViewEdgeIterator`");
51 
53  PyObject *args,
54  PyObject *kwds)
55 {
56  static const char *kwlist[] = {"brother", nullptr};
57  PyObject *brother = nullptr;
58 
59  if (!PyArg_ParseTupleAndKeywords(
60  args, kwds, "|O!", (char **)kwlist, &orientedViewEdgeIterator_Type, &brother)) {
61  return -1;
62  }
63  if (!brother) {
65  self->at_start = true;
66  self->reversed = false;
67  }
68  else {
70  *(((BPy_orientedViewEdgeIterator *)brother)->ove_it));
71  self->at_start = ((BPy_orientedViewEdgeIterator *)brother)->at_start;
72  self->reversed = ((BPy_orientedViewEdgeIterator *)brother)->reversed;
73  }
74  self->py_it.it = self->ove_it;
75  return 0;
76 }
77 
79 {
80  Py_INCREF(self);
81  self->at_start = true;
82  return (PyObject *)self;
83 }
84 
86 {
87  if (self->reversed) {
88  if (self->ove_it->isBegin()) {
89  PyErr_SetNone(PyExc_StopIteration);
90  return nullptr;
91  }
92  self->ove_it->decrement();
93  }
94  else {
95  if (self->ove_it->isEnd()) {
96  PyErr_SetNone(PyExc_StopIteration);
97  return nullptr;
98  }
99  if (self->at_start) {
100  self->at_start = false;
101  }
102  else {
103  self->ove_it->increment();
104  if (self->ove_it->isEnd()) {
105  PyErr_SetNone(PyExc_StopIteration);
106  return nullptr;
107  }
108  }
109  }
110  ViewVertex::directedViewEdge *dve = self->ove_it->operator->();
112 }
113 
114 /*----------------------orientedViewEdgeIterator get/setters ----------------------------*/
115 
116 PyDoc_STRVAR(orientedViewEdgeIterator_object_doc,
117  "The oriented ViewEdge (i.e., a tuple of the pointed ViewEdge and a boolean\n"
118  "value) currently pointed to by this iterator. If the boolean value is true,\n"
119  "the ViewEdge is incoming.\n"
120  "\n"
121  ":type: (:class:`ViewEdge`, bool)");
122 
124  void *UNUSED(closure))
125 {
126  if (self->ove_it->isEnd()) {
127  PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
128  return nullptr;
129  }
130  return BPy_directedViewEdge_from_directedViewEdge(self->ove_it->operator*());
131 }
132 
134  {"object",
136  (setter) nullptr,
137  orientedViewEdgeIterator_object_doc,
138  nullptr},
139  {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
140 };
141 
142 /*-----------------------BPy_orientedViewEdgeIterator type definition ---------------------------*/
143 
145  PyVarObject_HEAD_INIT(nullptr, 0) "orientedViewEdgeIterator", /* tp_name */
146  sizeof(BPy_orientedViewEdgeIterator), /* tp_basicsize */
147  0, /* tp_itemsize */
148  nullptr, /* tp_dealloc */
149  0, /* tp_vectorcall_offset */
150  nullptr, /* tp_getattr */
151  nullptr, /* tp_setattr */
152  nullptr, /* tp_reserved */
153  nullptr, /* tp_repr */
154  nullptr, /* tp_as_number */
155  nullptr, /* tp_as_sequence */
156  nullptr, /* tp_as_mapping */
157  nullptr, /* tp_hash */
158  nullptr, /* tp_call */
159  nullptr, /* tp_str */
160  nullptr, /* tp_getattro */
161  nullptr, /* tp_setattro */
162  nullptr, /* tp_as_buffer */
163  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
164  orientedViewEdgeIterator_doc, /* tp_doc */
165  nullptr, /* tp_traverse */
166  nullptr, /* tp_clear */
167  nullptr, /* tp_richcompare */
168  0, /* tp_weaklistoffset */
169  (getiterfunc)orientedViewEdgeIterator_iter, /* tp_iter */
170  (iternextfunc)orientedViewEdgeIterator_iternext, /* tp_iternext */
171  nullptr, /* tp_methods */
172  nullptr, /* tp_members */
174  &Iterator_Type, /* tp_base */
175  nullptr, /* tp_dict */
176  nullptr, /* tp_descr_get */
177  nullptr, /* tp_descr_set */
178  0, /* tp_dictoffset */
179  (initproc)orientedViewEdgeIterator_init, /* tp_init */
180  nullptr, /* tp_alloc */
181  nullptr, /* tp_new */
182 };
183 
185 
186 #ifdef __cplusplus
187 }
188 #endif
#define UNUSED(x)
PyObject * BPy_directedViewEdge_from_directedViewEdge(ViewVertex::directedViewEdge &dve)
PyTypeObject Iterator_Type
static int orientedViewEdgeIterator_init(BPy_orientedViewEdgeIterator *self, PyObject *args, PyObject *kwds)
static PyObject * orientedViewEdgeIterator_iternext(BPy_orientedViewEdgeIterator *self)
PyDoc_STRVAR(orientedViewEdgeIterator_doc, "Class hierarchy: :class:`Iterator` > :class:`orientedViewEdgeIterator`\n" "\n" "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 edges_begin() or edges_end().\n" "\n" ".. method:: __init__()\n" " __init__(iBrother)\n" "\n" " Creates an :class:`orientedViewEdgeIterator` using either the\n" " default constructor or the copy constructor.\n" "\n" " :arg iBrother: An orientedViewEdgeIterator object.\n" " :type iBrother: :class:`orientedViewEdgeIterator`")
static PyObject * orientedViewEdgeIterator_object_get(BPy_orientedViewEdgeIterator *self, void *UNUSED(closure))
static PyObject * orientedViewEdgeIterator_iter(BPy_orientedViewEdgeIterator *self)
PyTypeObject orientedViewEdgeIterator_Type
static PyGetSetDef BPy_orientedViewEdgeIterator_getseters[]
PyObject * self
Definition: bpy_driver.c:185
pair< ViewEdge *, bool > directedViewEdge
Definition: ViewMap.h:280
inherits from class Rep
Definition: AppCanvas.cpp:32