Blender  V3.3
BPy_SVertexIterator.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include "BPy_SVertexIterator.h"
8 
9 #include "../BPy_Convert.h"
10 #include "../Interface0D/BPy_SVertex.h"
11 #include "../Interface1D/BPy_FEdge.h"
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 using namespace Freestyle;
18 
20 
21 //------------------------INSTANCE METHODS ----------------------------------
22 
24  SVertexIterator_doc,
25  "Class hierarchy: :class:`Iterator` > :class:`SVertexIterator`\n"
26  "\n"
27  "Class representing an iterator over :class:`SVertex` of a\n"
28  ":class:`ViewEdge`. An instance of an SVertexIterator can be obtained\n"
29  "from a ViewEdge by calling verticesBegin() or verticesEnd().\n"
30  "\n"
31  ".. method:: __init__()\n"
32  " __init__(brother)\n"
33  " __init__(vertex, begin, previous_edge, next_edge, t)"
34  "\n"
35  " Build an SVertexIterator using either the default constructor, copy constructor,\n"
36  " or the overloaded constructor that starts iteration from an SVertex object vertex.\n"
37  "\n"
38  " :arg brother: An SVertexIterator object.\n"
39  " :type brother: :class:`SVertexIterator`\n"
40  " :arg vertex: The SVertex from which the iterator starts iteration.\n"
41  " :type vertex: :class:`SVertex`\n"
42  " :arg begin: The first SVertex of a ViewEdge.\n"
43  " :type begin: :class:`SVertex`\n"
44  " :arg previous_edge: The previous FEdge coming to vertex.\n"
45  " :type previous_edge: :class:`FEdge`\n"
46  " :arg next_edge: The next FEdge going out from vertex.\n"
47  " :type next_edge: :class:`FEdge`\n"
48  " :arg t: The curvilinear abscissa at vertex.\n"
49  " :type t: float");
50 
51 static int SVertexIterator_init(BPy_SVertexIterator *self, PyObject *args, PyObject *kwds)
52 {
53  static const char *kwlist_1[] = {"brother", nullptr};
54  static const char *kwlist_2[] = {"vertex", "begin", "previous_edge", "next_edge", "t", nullptr};
55  PyObject *obj1 = nullptr, *obj2 = nullptr, *obj3 = nullptr, *obj4 = nullptr;
56  float t;
57 
58  if (PyArg_ParseTupleAndKeywords(
59  args, kwds, "|O!", (char **)kwlist_1, &SVertexIterator_Type, &obj1)) {
60  if (!obj1) {
61  self->sv_it = new ViewEdgeInternal::SVertexIterator();
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,
72  &SVertex_Type,
73  &obj1,
74  &SVertex_Type,
75  &obj2,
76  &FEdge_Type,
77  &obj3,
78  &FEdge_Type,
79  &obj4,
80  &t)) {
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 
97 PyDoc_STRVAR(SVertexIterator_object_doc,
98  "The SVertex object currently pointed by this iterator.\n"
99  "\n"
100  ":type: :class:`SVertex`");
101 
102 static PyObject *SVertexIterator_object_get(BPy_SVertexIterator *self, void *UNUSED(closure))
103 {
104  if (self->sv_it->isEnd()) {
105  PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
106  return nullptr;
107  }
108  SVertex *sv = self->sv_it->operator->();
109  if (sv) {
110  return BPy_SVertex_from_SVertex(*sv);
111  }
112  Py_RETURN_NONE;
113 }
114 
115 PyDoc_STRVAR(SVertexIterator_t_doc,
116  "The curvilinear abscissa of the current point.\n"
117  "\n"
118  ":type: float");
119 
120 static PyObject *SVertexIterator_t_get(BPy_SVertexIterator *self, void *UNUSED(closure))
121 {
122  return PyFloat_FromDouble(self->sv_it->t());
123 }
124 
125 PyDoc_STRVAR(SVertexIterator_u_doc,
126  "The point parameter at the current point in the 1D element (0 <= u <= 1).\n"
127  "\n"
128  ":type: float");
129 
130 static PyObject *SVertexIterator_u_get(BPy_SVertexIterator *self, void *UNUSED(closure))
131 {
132  return PyFloat_FromDouble(self->sv_it->u());
133 }
134 
135 static PyGetSetDef BPy_SVertexIterator_getseters[] = {
136  {"object",
138  (setter) nullptr,
139  SVertexIterator_object_doc,
140  nullptr},
141  {"t", (getter)SVertexIterator_t_get, (setter) nullptr, SVertexIterator_t_doc, nullptr},
142  {"u", (getter)SVertexIterator_u_get, (setter) nullptr, SVertexIterator_u_doc, nullptr},
143  {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
144 };
145 
146 /*-----------------------BPy_SVertexIterator type definition ------------------------------*/
147 
148 PyTypeObject SVertexIterator_Type = {
149  PyVarObject_HEAD_INIT(nullptr, 0) "SVertexIterator", /* tp_name */
150  sizeof(BPy_SVertexIterator), /* tp_basicsize */
151  0, /* tp_itemsize */
152  nullptr, /* tp_dealloc */
153  0, /* tp_vectorcall_offset */
154  nullptr, /* tp_getattr */
155  nullptr, /* tp_setattr */
156  nullptr, /* tp_reserved */
157  nullptr, /* tp_repr */
158  nullptr, /* tp_as_number */
159  nullptr, /* tp_as_sequence */
160  nullptr, /* tp_as_mapping */
161  nullptr, /* tp_hash */
162  nullptr, /* tp_call */
163  nullptr, /* tp_str */
164  nullptr, /* tp_getattro */
165  nullptr, /* tp_setattro */
166  nullptr, /* tp_as_buffer */
167  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
168  SVertexIterator_doc, /* tp_doc */
169  nullptr, /* tp_traverse */
170  nullptr, /* tp_clear */
171  nullptr, /* tp_richcompare */
172  0, /* tp_weaklistoffset */
173  nullptr, /* tp_iter */
174  nullptr, /* tp_iternext */
175  nullptr, /* tp_methods */
176  nullptr, /* tp_members */
177  BPy_SVertexIterator_getseters, /* tp_getset */
178  &Iterator_Type, /* tp_base */
179  nullptr, /* tp_dict */
180  nullptr, /* tp_descr_get */
181  nullptr, /* tp_descr_set */
182  0, /* tp_dictoffset */
183  (initproc)SVertexIterator_init, /* tp_init */
184  nullptr, /* tp_alloc */
185  nullptr, /* tp_new */
186 };
187 
189 
190 #ifdef __cplusplus
191 }
192 #endif
#define UNUSED(x)
PyObject * BPy_SVertex_from_SVertex(SVertex &sv)
PyTypeObject FEdge_Type
Definition: BPy_FEdge.cpp:344
PyTypeObject Iterator_Type
static PyObject * SVertexIterator_u_get(BPy_SVertexIterator *self, void *UNUSED(closure))
static PyGetSetDef BPy_SVertexIterator_getseters[]
PyTypeObject SVertexIterator_Type
static int SVertexIterator_init(BPy_SVertexIterator *self, PyObject *args, PyObject *kwds)
static PyObject * SVertexIterator_object_get(BPy_SVertexIterator *self, void *UNUSED(closure))
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 PyObject * SVertexIterator_t_get(BPy_SVertexIterator *self, void *UNUSED(closure))
PyTypeObject SVertex_Type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
PyObject * self
Definition: bpy_driver.c:165
inherits from class Rep
Definition: AppCanvas.cpp:18