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