Blender V5.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
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__(*args)\n"
30 "\n"
31 " Accepted call signatures:\n"
32 "\n"
33 " - ``__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 " :param iBrother: An orientedViewEdgeIterator object.\n"
40 " :type iBrother: :class:`orientedViewEdgeIterator`\n");
42 PyObject *args,
43 PyObject *kwds)
44{
45 static const char *kwlist[] = {"brother", nullptr};
46 PyObject *brother = nullptr;
47
48 if (!PyArg_ParseTupleAndKeywords(args,
49 kwds,
50 "|" /* Optional arguments. */
51 "O!" /* `brother` */
52 ":__init__",
53 (char **)kwlist,
55 &brother))
56 {
57 return -1;
58 }
59 if (!brother) {
61 self->at_start = true;
62 self->reversed = false;
63 }
64 else {
66 *(((BPy_orientedViewEdgeIterator *)brother)->ove_it));
67 self->at_start = ((BPy_orientedViewEdgeIterator *)brother)->at_start;
68 self->reversed = ((BPy_orientedViewEdgeIterator *)brother)->reversed;
69 }
70 self->py_it.it = self->ove_it;
71 return 0;
72}
73
75{
76 Py_INCREF(self);
77 self->at_start = true;
78 return (PyObject *)self;
79}
80
82{
83 if (self->reversed) {
84 if (self->ove_it->isBegin()) {
85 PyErr_SetNone(PyExc_StopIteration);
86 return nullptr;
87 }
88 self->ove_it->decrement();
89 }
90 else {
91 if (self->ove_it->isEnd()) {
92 PyErr_SetNone(PyExc_StopIteration);
93 return nullptr;
94 }
95 if (self->at_start) {
96 self->at_start = false;
97 }
98 else {
99 self->ove_it->increment();
100 if (self->ove_it->isEnd()) {
101 PyErr_SetNone(PyExc_StopIteration);
102 return nullptr;
103 }
104 }
105 }
106 ViewVertex::directedViewEdge *dve = self->ove_it->operator->();
108}
109
110/*----------------------orientedViewEdgeIterator get/setters ----------------------------*/
111
113 /* Wrap. */
114 orientedViewEdgeIterator_object_doc,
115 "The oriented ViewEdge (i.e., a tuple of the pointed ViewEdge and a boolean\n"
116 "value) currently pointed to by this iterator. If the boolean value is true,\n"
117 "the ViewEdge is incoming.\n"
118 "\n"
119 ":type: tuple[:class:`ViewEdge`, bool]\n");
121 void * /*closure*/)
122{
123 if (self->ove_it->isEnd()) {
124 PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
125 return nullptr;
126 }
127 return BPy_directedViewEdge_from_directedViewEdge(self->ove_it->operator*());
128}
129
131 {"object",
133 (setter) nullptr,
134 orientedViewEdgeIterator_object_doc,
135 nullptr},
136 {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
137};
138
139/*-----------------------BPy_orientedViewEdgeIterator type definition ---------------------------*/
140
142 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
143 /*tp_name*/ "orientedViewEdgeIterator",
144 /*tp_basicsize*/ sizeof(BPy_orientedViewEdgeIterator),
145 /*tp_itemsize*/ 0,
146 /*tp_dealloc*/ nullptr,
147 /*tp_vectorcall_offset*/ 0,
148 /*tp_getattr*/ nullptr,
149 /*tp_setattr*/ nullptr,
150 /*tp_as_async*/ nullptr,
151 /*tp_repr*/ nullptr,
152 /*tp_as_number*/ nullptr,
153 /*tp_as_sequence*/ nullptr,
154 /*tp_as_mapping*/ nullptr,
155 /*tp_hash*/ nullptr,
156 /*tp_call*/ nullptr,
157 /*tp_str*/ nullptr,
158 /*tp_getattro*/ nullptr,
159 /*tp_setattro*/ nullptr,
160 /*tp_as_buffer*/ nullptr,
161 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
162 /*tp_doc*/ orientedViewEdgeIterator_doc,
163 /*tp_traverse*/ nullptr,
164 /*tp_clear*/ nullptr,
165 /*tp_richcompare*/ nullptr,
166 /*tp_weaklistoffset*/ 0,
167 /*tp_iter*/ (getiterfunc)orientedViewEdgeIterator_iter,
168 /*tp_iternext*/ (iternextfunc)orientedViewEdgeIterator_iternext,
169 /*tp_methods*/ nullptr,
170 /*tp_members*/ nullptr,
172 /*tp_base*/ &Iterator_Type,
173 /*tp_dict*/ nullptr,
174 /*tp_descr_get*/ nullptr,
175 /*tp_descr_set*/ nullptr,
176 /*tp_dictoffset*/ 0,
177 /*tp_init*/ (initproc)orientedViewEdgeIterator_init,
178 /*tp_alloc*/ nullptr,
179 /*tp_new*/ nullptr,
180};
181
PyObject * BPy_directedViewEdge_from_directedViewEdge(ViewVertex::directedViewEdge &dve)
PyDoc_STRVAR(FalseBP1D___doc__, "Class hierarchy: :class:`freestyle.types.BinaryPredicate1D` > :class:`FalseBP1D`\n" "\n" ".. method:: __call__(inter1, inter2)\n" "\n" " Always returns false.\n" "\n" " :param inter1: The first Interface1D object.\n" " :type inter1: :class:`freestyle.types.Interface1D`\n" " :param inter2: The second Interface1D object.\n" " :type inter2: :class:`freestyle.types.Interface1D`\n" " :return: False.\n" " :rtype: bool\n")
PyTypeObject Iterator_Type
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[]
virtual int decrement()
Definition Iterator.h:35
pair< ViewEdge *, bool > directedViewEdge
Definition ViewMap.h:263
inherits from class Rep
Definition AppCanvas.cpp:20
PyObject_HEAD Freestyle::Iterator * it
Freestyle::ViewVertexInternal::orientedViewEdgeIterator * ove_it