Blender V4.5
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`");
37
39 PyObject *args,
40 PyObject *kwds)
41{
42 static const char *kwlist[] = {"brother", nullptr};
43 PyObject *brother = nullptr;
44
45 if (!PyArg_ParseTupleAndKeywords(
46 args, kwds, "|O!", (char **)kwlist, &orientedViewEdgeIterator_Type, &brother))
47 {
48 return -1;
49 }
50 if (!brother) {
52 self->at_start = true;
53 self->reversed = false;
54 }
55 else {
57 *(((BPy_orientedViewEdgeIterator *)brother)->ove_it));
58 self->at_start = ((BPy_orientedViewEdgeIterator *)brother)->at_start;
59 self->reversed = ((BPy_orientedViewEdgeIterator *)brother)->reversed;
60 }
61 self->py_it.it = self->ove_it;
62 return 0;
63}
64
66{
67 Py_INCREF(self);
68 self->at_start = true;
69 return (PyObject *)self;
70}
71
73{
74 if (self->reversed) {
75 if (self->ove_it->isBegin()) {
76 PyErr_SetNone(PyExc_StopIteration);
77 return nullptr;
78 }
79 self->ove_it->decrement();
80 }
81 else {
82 if (self->ove_it->isEnd()) {
83 PyErr_SetNone(PyExc_StopIteration);
84 return nullptr;
85 }
86 if (self->at_start) {
87 self->at_start = false;
88 }
89 else {
90 self->ove_it->increment();
91 if (self->ove_it->isEnd()) {
92 PyErr_SetNone(PyExc_StopIteration);
93 return nullptr;
94 }
95 }
96 }
97 ViewVertex::directedViewEdge *dve = self->ove_it->operator->();
99}
100
101/*----------------------orientedViewEdgeIterator get/setters ----------------------------*/
102
104 /* Wrap. */
105 orientedViewEdgeIterator_object_doc,
106 "The oriented ViewEdge (i.e., a tuple of the pointed ViewEdge and a boolean\n"
107 "value) currently pointed to by this iterator. If the boolean value is true,\n"
108 "the ViewEdge is incoming.\n"
109 "\n"
110 ":type: (:class:`ViewEdge`, bool)");
111
113 void * /*closure*/)
114{
115 if (self->ove_it->isEnd()) {
116 PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
117 return nullptr;
118 }
119 return BPy_directedViewEdge_from_directedViewEdge(self->ove_it->operator*());
120}
121
123 {"object",
125 (setter) nullptr,
126 orientedViewEdgeIterator_object_doc,
127 nullptr},
128 {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
129};
130
131/*-----------------------BPy_orientedViewEdgeIterator type definition ---------------------------*/
132
134 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
135 /*tp_name*/ "orientedViewEdgeIterator",
136 /*tp_basicsize*/ sizeof(BPy_orientedViewEdgeIterator),
137 /*tp_itemsize*/ 0,
138 /*tp_dealloc*/ nullptr,
139 /*tp_vectorcall_offset*/ 0,
140 /*tp_getattr*/ nullptr,
141 /*tp_setattr*/ nullptr,
142 /*tp_as_async*/ nullptr,
143 /*tp_repr*/ nullptr,
144 /*tp_as_number*/ nullptr,
145 /*tp_as_sequence*/ nullptr,
146 /*tp_as_mapping*/ nullptr,
147 /*tp_hash*/ nullptr,
148 /*tp_call*/ nullptr,
149 /*tp_str*/ nullptr,
150 /*tp_getattro*/ nullptr,
151 /*tp_setattro*/ nullptr,
152 /*tp_as_buffer*/ nullptr,
153 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
154 /*tp_doc*/ orientedViewEdgeIterator_doc,
155 /*tp_traverse*/ nullptr,
156 /*tp_clear*/ nullptr,
157 /*tp_richcompare*/ nullptr,
158 /*tp_weaklistoffset*/ 0,
159 /*tp_iter*/ (getiterfunc)orientedViewEdgeIterator_iter,
160 /*tp_iternext*/ (iternextfunc)orientedViewEdgeIterator_iternext,
161 /*tp_methods*/ nullptr,
162 /*tp_members*/ nullptr,
164 /*tp_base*/ &Iterator_Type,
165 /*tp_dict*/ nullptr,
166 /*tp_descr_get*/ nullptr,
167 /*tp_descr_set*/ nullptr,
168 /*tp_dictoffset*/ 0,
169 /*tp_init*/ (initproc)orientedViewEdgeIterator_init,
170 /*tp_alloc*/ nullptr,
171 /*tp_new*/ nullptr,
172};
173
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:263
inherits from class Rep
Definition AppCanvas.cpp:20