Blender V5.0
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\n");
49static int SVertexIterator_init(BPy_SVertexIterator *self, PyObject *args, PyObject *kwds)
50{
51 static const char *kwlist_1[] = {"brother", nullptr};
52 static const char *kwlist_2[] = {"vertex", "begin", "previous_edge", "next_edge", "t", nullptr};
53 PyObject *obj1 = nullptr, *obj2 = nullptr, *obj3 = nullptr, *obj4 = nullptr;
54 float t;
55
56 if (PyArg_ParseTupleAndKeywords(
57 args, kwds, "|O!", (char **)kwlist_1, &SVertexIterator_Type, &obj1))
58 {
59 if (!obj1) {
61 }
62 else {
63 self->sv_it = new ViewEdgeInternal::SVertexIterator(*(((BPy_SVertexIterator *)obj1)->sv_it));
64 }
65 }
66 else if ((void)PyErr_Clear(),
67 PyArg_ParseTupleAndKeywords(args,
68 kwds,
69 "O!O!O!O!f",
70 (char **)kwlist_2,
72 &obj1,
74 &obj2,
76 &obj3,
78 &obj4,
79 &t))
80 {
81 self->sv_it = new ViewEdgeInternal::SVertexIterator(((BPy_SVertex *)obj1)->sv,
82 ((BPy_SVertex *)obj2)->sv,
83 ((BPy_FEdge *)obj3)->fe,
84 ((BPy_FEdge *)obj4)->fe,
85 t);
86 }
87 else {
88 PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
89 return -1;
90 }
91 self->py_it.it = self->sv_it;
92 return 0;
93}
94
95/*----------------------SVertexIterator get/setters ----------------------------*/
96
98 /* Wrap. */
99 SVertexIterator_object_doc,
100 "The SVertex object currently pointed by this iterator.\n"
101 "\n"
102 ":type: :class:`SVertex`\n");
103static PyObject *SVertexIterator_object_get(BPy_SVertexIterator *self, void * /*closure*/)
104{
105 if (self->sv_it->isEnd()) {
106 PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
107 return nullptr;
108 }
109 SVertex *sv = self->sv_it->operator->();
110 if (sv) {
111 return BPy_SVertex_from_SVertex(*sv);
112 }
113 Py_RETURN_NONE;
114}
115
117 /* Wrap. */
118 SVertexIterator_t_doc,
119 "The curvilinear abscissa of the current point.\n"
120 "\n"
121 ":type: float\n");
122static PyObject *SVertexIterator_t_get(BPy_SVertexIterator *self, void * /*closure*/)
123{
124 return PyFloat_FromDouble(self->sv_it->t());
125}
126
128 /* Wrap. */
129 SVertexIterator_u_doc,
130 "The point parameter at the current point in the 1D element (0 <= u <= 1).\n"
131 "\n"
132 ":type: float\n");
133static PyObject *SVertexIterator_u_get(BPy_SVertexIterator *self, void * /*closure*/)
134{
135 return PyFloat_FromDouble(self->sv_it->u());
136}
137
138static PyGetSetDef BPy_SVertexIterator_getseters[] = {
139 {"object",
141 (setter) nullptr,
142 SVertexIterator_object_doc,
143 nullptr},
144 {"t", (getter)SVertexIterator_t_get, (setter) nullptr, SVertexIterator_t_doc, nullptr},
145 {"u", (getter)SVertexIterator_u_get, (setter) nullptr, SVertexIterator_u_doc, nullptr},
146 {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
147};
148
149/*-----------------------BPy_SVertexIterator type definition ------------------------------*/
150
151PyTypeObject SVertexIterator_Type = {
152 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
153 /*tp_name*/ "SVertexIterator",
154 /*tp_basicsize*/ sizeof(BPy_SVertexIterator),
155 /*tp_itemsize*/ 0,
156 /*tp_dealloc*/ nullptr,
157 /*tp_vectorcall_offset*/ 0,
158 /*tp_getattr*/ nullptr,
159 /*tp_setattr*/ nullptr,
160 /*tp_as_async*/ nullptr,
161 /*tp_repr*/ nullptr,
162 /*tp_as_number*/ nullptr,
163 /*tp_as_sequence*/ nullptr,
164 /*tp_as_mapping*/ nullptr,
165 /*tp_hash*/ nullptr,
166 /*tp_call*/ nullptr,
167 /*tp_str*/ nullptr,
168 /*tp_getattro*/ nullptr,
169 /*tp_setattro*/ nullptr,
170 /*tp_as_buffer*/ nullptr,
171 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
172 /*tp_doc*/ SVertexIterator_doc,
173 /*tp_traverse*/ nullptr,
174 /*tp_clear*/ nullptr,
175 /*tp_richcompare*/ nullptr,
176 /*tp_weaklistoffset*/ 0,
177 /*tp_iter*/ nullptr,
178 /*tp_iternext*/ nullptr,
179 /*tp_methods*/ nullptr,
180 /*tp_members*/ nullptr,
181 /*tp_getset*/ BPy_SVertexIterator_getseters,
182 /*tp_base*/ &Iterator_Type,
183 /*tp_dict*/ nullptr,
184 /*tp_descr_get*/ nullptr,
185 /*tp_descr_set*/ nullptr,
186 /*tp_dictoffset*/ 0,
187 /*tp_init*/ (initproc)SVertexIterator_init,
188 /*tp_alloc*/ nullptr,
189 /*tp_new*/ nullptr,
190};
191
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
static int SVertexIterator_init(BPy_SVertexIterator *self, PyObject *args, PyObject *kwds)
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\n")
static PyObject * SVertexIterator_t_get(BPy_SVertexIterator *self, void *)
PyTypeObject SVertex_Type
PyObject * self
inherits from class Rep
Definition AppCanvas.cpp:20