Blender V4.3
BPy_orientedViewEdgeIterator.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2004-2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#include "../BPy_Convert.h"
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17using namespace Freestyle;
18
20
21//------------------------INSTANCE METHODS ----------------------------------
22
24 /* Wrap. */
25 orientedViewEdgeIterator_doc,
26 "Class hierarchy: :class:`Iterator` > :class:`orientedViewEdgeIterator`\n"
27 "\n"
28 "Class representing an iterator over oriented ViewEdges around a\n"
29 ":class:`ViewVertex`. This iterator allows a CCW iteration (in the image\n"
30 "plane). An instance of an orientedViewEdgeIterator can only be\n"
31 "obtained from a ViewVertex by calling edges_begin() or edges_end().\n"
32 "\n"
33 ".. method:: __init__()\n"
34 " __init__(iBrother)\n"
35 "\n"
36 " Creates an :class:`orientedViewEdgeIterator` using either the\n"
37 " default constructor or the copy constructor.\n"
38 "\n"
39 " :arg iBrother: An orientedViewEdgeIterator object.\n"
40 " :type iBrother: :class:`orientedViewEdgeIterator`");
41
43 PyObject *args,
44 PyObject *kwds)
45{
46 static const char *kwlist[] = {"brother", nullptr};
47 PyObject *brother = nullptr;
48
49 if (!PyArg_ParseTupleAndKeywords(
50 args, kwds, "|O!", (char **)kwlist, &orientedViewEdgeIterator_Type, &brother))
51 {
52 return -1;
53 }
54 if (!brother) {
56 self->at_start = true;
57 self->reversed = false;
58 }
59 else {
61 *(((BPy_orientedViewEdgeIterator *)brother)->ove_it));
62 self->at_start = ((BPy_orientedViewEdgeIterator *)brother)->at_start;
63 self->reversed = ((BPy_orientedViewEdgeIterator *)brother)->reversed;
64 }
65 self->py_it.it = self->ove_it;
66 return 0;
67}
68
70{
71 Py_INCREF(self);
72 self->at_start = true;
73 return (PyObject *)self;
74}
75
77{
78 if (self->reversed) {
79 if (self->ove_it->isBegin()) {
80 PyErr_SetNone(PyExc_StopIteration);
81 return nullptr;
82 }
83 self->ove_it->decrement();
84 }
85 else {
86 if (self->ove_it->isEnd()) {
87 PyErr_SetNone(PyExc_StopIteration);
88 return nullptr;
89 }
90 if (self->at_start) {
91 self->at_start = false;
92 }
93 else {
94 self->ove_it->increment();
95 if (self->ove_it->isEnd()) {
96 PyErr_SetNone(PyExc_StopIteration);
97 return nullptr;
98 }
99 }
100 }
101 ViewVertex::directedViewEdge *dve = self->ove_it->operator->();
103}
104
105/*----------------------orientedViewEdgeIterator get/setters ----------------------------*/
106
108 /* Wrap. */
109 orientedViewEdgeIterator_object_doc,
110 "The oriented ViewEdge (i.e., a tuple of the pointed ViewEdge and a boolean\n"
111 "value) currently pointed to by this iterator. If the boolean value is true,\n"
112 "the ViewEdge is incoming.\n"
113 "\n"
114 ":type: (:class:`ViewEdge`, bool)");
115
117 void * /*closure*/)
118{
119 if (self->ove_it->isEnd()) {
120 PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
121 return nullptr;
122 }
123 return BPy_directedViewEdge_from_directedViewEdge(self->ove_it->operator*());
124}
125
127 {"object",
129 (setter) nullptr,
130 orientedViewEdgeIterator_object_doc,
131 nullptr},
132 {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
133};
134
135/*-----------------------BPy_orientedViewEdgeIterator type definition ---------------------------*/
136
138 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
139 /*tp_name*/ "orientedViewEdgeIterator",
140 /*tp_basicsize*/ sizeof(BPy_orientedViewEdgeIterator),
141 /*tp_itemsize*/ 0,
142 /*tp_dealloc*/ nullptr,
143 /*tp_vectorcall_offset*/ 0,
144 /*tp_getattr*/ nullptr,
145 /*tp_setattr*/ nullptr,
146 /*tp_as_async*/ nullptr,
147 /*tp_repr*/ nullptr,
148 /*tp_as_number*/ nullptr,
149 /*tp_as_sequence*/ nullptr,
150 /*tp_as_mapping*/ nullptr,
151 /*tp_hash*/ nullptr,
152 /*tp_call*/ nullptr,
153 /*tp_str*/ nullptr,
154 /*tp_getattro*/ nullptr,
155 /*tp_setattro*/ nullptr,
156 /*tp_as_buffer*/ nullptr,
157 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
158 /*tp_doc*/ orientedViewEdgeIterator_doc,
159 /*tp_traverse*/ nullptr,
160 /*tp_clear*/ nullptr,
161 /*tp_richcompare*/ nullptr,
162 /*tp_weaklistoffset*/ 0,
163 /*tp_iter*/ (getiterfunc)orientedViewEdgeIterator_iter,
164 /*tp_iternext*/ (iternextfunc)orientedViewEdgeIterator_iternext,
165 /*tp_methods*/ nullptr,
166 /*tp_members*/ nullptr,
168 /*tp_base*/ &Iterator_Type,
169 /*tp_dict*/ nullptr,
170 /*tp_descr_get*/ nullptr,
171 /*tp_descr_set*/ nullptr,
172 /*tp_dictoffset*/ 0,
173 /*tp_init*/ (initproc)orientedViewEdgeIterator_init,
174 /*tp_alloc*/ nullptr,
175 /*tp_new*/ nullptr,
176};
177
179
180#ifdef __cplusplus
181}
182#endif
PyObject * BPy_directedViewEdge_from_directedViewEdge(ViewVertex::directedViewEdge &dve)
PyTypeObject Iterator_Type
static PyObject * orientedViewEdgeIterator_object_get(BPy_orientedViewEdgeIterator *self, void *)
static int orientedViewEdgeIterator_init(BPy_orientedViewEdgeIterator *self, PyObject *args, PyObject *kwds)
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_iter(BPy_orientedViewEdgeIterator *self)
static PyObject * orientedViewEdgeIterator_iternext(BPy_orientedViewEdgeIterator *self)
PyTypeObject orientedViewEdgeIterator_Type
static PyGetSetDef BPy_orientedViewEdgeIterator_getseters[]
PyObject * self
pair< ViewEdge *, bool > directedViewEdge
Definition ViewMap.h:267
inherits from class Rep
Definition AppCanvas.cpp:20