Blender V4.3
BPy_SVertexIterator.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"
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19using namespace Freestyle;
20
22
23//------------------------INSTANCE METHODS ----------------------------------
24
26 /* Wrap. */
27 SVertexIterator_doc,
28 "Class hierarchy: :class:`Iterator` > :class:`SVertexIterator`\n"
29 "\n"
30 "Class representing an iterator over :class:`SVertex` of a\n"
31 ":class:`ViewEdge`. An instance of an SVertexIterator can be obtained\n"
32 "from a ViewEdge by calling verticesBegin() or verticesEnd().\n"
33 "\n"
34 ".. method:: __init__()\n"
35 " __init__(brother)\n"
36 " __init__(vertex, begin, previous_edge, next_edge, t)"
37 "\n"
38 " Build an SVertexIterator using either the default constructor, copy constructor,\n"
39 " or the overloaded constructor that starts iteration from an SVertex object vertex.\n"
40 "\n"
41 " :arg brother: An SVertexIterator object.\n"
42 " :type brother: :class:`SVertexIterator`\n"
43 " :arg vertex: The SVertex from which the iterator starts iteration.\n"
44 " :type vertex: :class:`SVertex`\n"
45 " :arg begin: The first SVertex of a ViewEdge.\n"
46 " :type begin: :class:`SVertex`\n"
47 " :arg previous_edge: The previous FEdge coming to vertex.\n"
48 " :type previous_edge: :class:`FEdge`\n"
49 " :arg next_edge: The next FEdge going out from vertex.\n"
50 " :type next_edge: :class:`FEdge`\n"
51 " :arg t: The curvilinear abscissa at vertex.\n"
52 " :type t: float");
53
54static int SVertexIterator_init(BPy_SVertexIterator *self, PyObject *args, PyObject *kwds)
55{
56 static const char *kwlist_1[] = {"brother", nullptr};
57 static const char *kwlist_2[] = {"vertex", "begin", "previous_edge", "next_edge", "t", nullptr};
58 PyObject *obj1 = nullptr, *obj2 = nullptr, *obj3 = nullptr, *obj4 = nullptr;
59 float t;
60
61 if (PyArg_ParseTupleAndKeywords(
62 args, kwds, "|O!", (char **)kwlist_1, &SVertexIterator_Type, &obj1))
63 {
64 if (!obj1) {
66 }
67 else {
68 self->sv_it = new ViewEdgeInternal::SVertexIterator(*(((BPy_SVertexIterator *)obj1)->sv_it));
69 }
70 }
71 else if ((void)PyErr_Clear(),
72 PyArg_ParseTupleAndKeywords(args,
73 kwds,
74 "O!O!O!O!f",
75 (char **)kwlist_2,
77 &obj1,
79 &obj2,
81 &obj3,
83 &obj4,
84 &t))
85 {
86 self->sv_it = new ViewEdgeInternal::SVertexIterator(((BPy_SVertex *)obj1)->sv,
87 ((BPy_SVertex *)obj2)->sv,
88 ((BPy_FEdge *)obj3)->fe,
89 ((BPy_FEdge *)obj4)->fe,
90 t);
91 }
92 else {
93 PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
94 return -1;
95 }
96 self->py_it.it = self->sv_it;
97 return 0;
98}
99
100/*----------------------SVertexIterator get/setters ----------------------------*/
101
103 /* Wrap. */
104 SVertexIterator_object_doc,
105 "The SVertex object currently pointed by this iterator.\n"
106 "\n"
107 ":type: :class:`SVertex`");
108
109static PyObject *SVertexIterator_object_get(BPy_SVertexIterator *self, void * /*closure*/)
110{
111 if (self->sv_it->isEnd()) {
112 PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
113 return nullptr;
114 }
115 SVertex *sv = self->sv_it->operator->();
116 if (sv) {
117 return BPy_SVertex_from_SVertex(*sv);
118 }
119 Py_RETURN_NONE;
120}
121
123 /* Wrap. */
124 SVertexIterator_t_doc,
125 "The curvilinear abscissa of the current point.\n"
126 "\n"
127 ":type: float");
128
129static PyObject *SVertexIterator_t_get(BPy_SVertexIterator *self, void * /*closure*/)
130{
131 return PyFloat_FromDouble(self->sv_it->t());
132}
133
135 /* Wrap. */
136 SVertexIterator_u_doc,
137 "The point parameter at the current point in the 1D element (0 <= u <= 1).\n"
138 "\n"
139 ":type: float");
140
141static PyObject *SVertexIterator_u_get(BPy_SVertexIterator *self, void * /*closure*/)
142{
143 return PyFloat_FromDouble(self->sv_it->u());
144}
145
146static PyGetSetDef BPy_SVertexIterator_getseters[] = {
147 {"object",
149 (setter) nullptr,
150 SVertexIterator_object_doc,
151 nullptr},
152 {"t", (getter)SVertexIterator_t_get, (setter) nullptr, SVertexIterator_t_doc, nullptr},
153 {"u", (getter)SVertexIterator_u_get, (setter) nullptr, SVertexIterator_u_doc, nullptr},
154 {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
155};
156
157/*-----------------------BPy_SVertexIterator type definition ------------------------------*/
158
159PyTypeObject SVertexIterator_Type = {
160 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
161 /*tp_name*/ "SVertexIterator",
162 /*tp_basicsize*/ sizeof(BPy_SVertexIterator),
163 /*tp_itemsize*/ 0,
164 /*tp_dealloc*/ nullptr,
165 /*tp_vectorcall_offset*/ 0,
166 /*tp_getattr*/ nullptr,
167 /*tp_setattr*/ nullptr,
168 /*tp_as_async*/ nullptr,
169 /*tp_repr*/ nullptr,
170 /*tp_as_number*/ nullptr,
171 /*tp_as_sequence*/ nullptr,
172 /*tp_as_mapping*/ nullptr,
173 /*tp_hash*/ nullptr,
174 /*tp_call*/ nullptr,
175 /*tp_str*/ nullptr,
176 /*tp_getattro*/ nullptr,
177 /*tp_setattro*/ nullptr,
178 /*tp_as_buffer*/ nullptr,
179 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
180 /*tp_doc*/ SVertexIterator_doc,
181 /*tp_traverse*/ nullptr,
182 /*tp_clear*/ nullptr,
183 /*tp_richcompare*/ nullptr,
184 /*tp_weaklistoffset*/ 0,
185 /*tp_iter*/ nullptr,
186 /*tp_iternext*/ nullptr,
187 /*tp_methods*/ nullptr,
188 /*tp_members*/ nullptr,
189 /*tp_getset*/ BPy_SVertexIterator_getseters,
190 /*tp_base*/ &Iterator_Type,
191 /*tp_dict*/ nullptr,
192 /*tp_descr_get*/ nullptr,
193 /*tp_descr_set*/ nullptr,
194 /*tp_dictoffset*/ 0,
195 /*tp_init*/ (initproc)SVertexIterator_init,
196 /*tp_alloc*/ nullptr,
197 /*tp_new*/ nullptr,
198};
199
201
202#ifdef __cplusplus
203}
204#endif
PyObject * BPy_SVertex_from_SVertex(SVertex &sv)
PyTypeObject FEdge_Type
PyTypeObject Iterator_Type
static PyObject * SVertexIterator_object_get(BPy_SVertexIterator *self, void *)
static PyGetSetDef BPy_SVertexIterator_getseters[]
static PyObject * SVertexIterator_u_get(BPy_SVertexIterator *self, void *)
PyTypeObject SVertexIterator_Type
PyDoc_STRVAR(SVertexIterator_doc, "Class hierarchy: :class:`Iterator` > :class:`SVertexIterator`\n" "\n" "Class representing an iterator over :class:`SVertex` of a\n" ":class:`ViewEdge`. An instance of an SVertexIterator can be obtained\n" "from a ViewEdge by calling verticesBegin() or verticesEnd().\n" "\n" ".. method:: __init__()\n" " __init__(brother)\n" " __init__(vertex, begin, previous_edge, next_edge, t)" "\n" " Build an SVertexIterator using either the default constructor, copy constructor,\n" " or the overloaded constructor that starts iteration from an SVertex object vertex.\n" "\n" " :arg brother: An SVertexIterator object.\n" " :type brother: :class:`SVertexIterator`\n" " :arg vertex: The SVertex from which the iterator starts iteration.\n" " :type vertex: :class:`SVertex`\n" " :arg begin: The first SVertex of a ViewEdge.\n" " :type begin: :class:`SVertex`\n" " :arg previous_edge: The previous FEdge coming to vertex.\n" " :type previous_edge: :class:`FEdge`\n" " :arg next_edge: The next FEdge going out from vertex.\n" " :type next_edge: :class:`FEdge`\n" " :arg t: The curvilinear abscissa at vertex.\n" " :type t: float")
static int SVertexIterator_init(BPy_SVertexIterator *self, PyObject *args, PyObject *kwds)
static PyObject * SVertexIterator_t_get(BPy_SVertexIterator *self, void *)
PyTypeObject SVertex_Type
PyObject * self
inherits from class Rep
Definition AppCanvas.cpp:20