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