Blender  V2.93
BPy_SVertexIterator.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #include "BPy_SVertexIterator.h"
22 
23 #include "../BPy_Convert.h"
24 #include "../Interface0D/BPy_SVertex.h"
25 #include "../Interface1D/BPy_FEdge.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 using namespace Freestyle;
32 
34 
35 //------------------------INSTANCE METHODS ----------------------------------
36 
38  SVertexIterator_doc,
39  "Class hierarchy: :class:`Iterator` > :class:`SVertexIterator`\n"
40  "\n"
41  "Class representing an iterator over :class:`SVertex` of a\n"
42  ":class:`ViewEdge`. An instance of an SVertexIterator can be obtained\n"
43  "from a ViewEdge by calling verticesBegin() or verticesEnd().\n"
44  "\n"
45  ".. method:: __init__()\n"
46  " __init__(brother)\n"
47  " __init__(vertex, begin, previous_edge, next_edge, t)"
48  "\n"
49  " Build an SVertexIterator using either the default constructor, copy constructor,\n"
50  " or the overloaded constructor that starts iteration from an SVertex object vertex.\n"
51  "\n"
52  " :arg brother: An SVertexIterator object.\n"
53  " :type brother: :class:`SVertexIterator`\n"
54  " :arg vertex: The SVertex from which the iterator starts iteration.\n"
55  " :type vertex: :class:`SVertex`\n"
56  " :arg begin: The first SVertex of a ViewEdge.\n"
57  " :type begin: :class:`SVertex`\n"
58  " :arg previous_edge: The previous FEdge coming to vertex.\n"
59  " :type previous_edge: :class:`FEdge`\n"
60  " :arg next_edge: The next FEdge going out from vertex.\n"
61  " :type next_edge: :class:`FEdge`\n"
62  " :arg t: The curvilinear abscissa at vertex.\n"
63  " :type t: float");
64 
65 static int SVertexIterator_init(BPy_SVertexIterator *self, PyObject *args, PyObject *kwds)
66 {
67  static const char *kwlist_1[] = {"brother", nullptr};
68  static const char *kwlist_2[] = {"vertex", "begin", "previous_edge", "next_edge", "t", nullptr};
69  PyObject *obj1 = nullptr, *obj2 = nullptr, *obj3 = nullptr, *obj4 = nullptr;
70  float t;
71 
72  if (PyArg_ParseTupleAndKeywords(
73  args, kwds, "|O!", (char **)kwlist_1, &SVertexIterator_Type, &obj1)) {
74  if (!obj1) {
75  self->sv_it = new ViewEdgeInternal::SVertexIterator();
76  }
77  else {
78  self->sv_it = new ViewEdgeInternal::SVertexIterator(*(((BPy_SVertexIterator *)obj1)->sv_it));
79  }
80  }
81  else if ((void)PyErr_Clear(),
82  PyArg_ParseTupleAndKeywords(args,
83  kwds,
84  "O!O!O!O!f",
85  (char **)kwlist_2,
86  &SVertex_Type,
87  &obj1,
88  &SVertex_Type,
89  &obj2,
90  &FEdge_Type,
91  &obj3,
92  &FEdge_Type,
93  &obj4,
94  &t)) {
95  self->sv_it = new ViewEdgeInternal::SVertexIterator(((BPy_SVertex *)obj1)->sv,
96  ((BPy_SVertex *)obj2)->sv,
97  ((BPy_FEdge *)obj3)->fe,
98  ((BPy_FEdge *)obj4)->fe,
99  t);
100  }
101  else {
102  PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
103  return -1;
104  }
105  self->py_it.it = self->sv_it;
106  return 0;
107 }
108 
109 /*----------------------SVertexIterator get/setters ----------------------------*/
110 
111 PyDoc_STRVAR(SVertexIterator_object_doc,
112  "The SVertex object currently pointed by this iterator.\n"
113  "\n"
114  ":type: :class:`SVertex`");
115 
116 static PyObject *SVertexIterator_object_get(BPy_SVertexIterator *self, void *UNUSED(closure))
117 {
118  if (self->sv_it->isEnd()) {
119  PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
120  return nullptr;
121  }
122  SVertex *sv = self->sv_it->operator->();
123  if (sv) {
124  return BPy_SVertex_from_SVertex(*sv);
125  }
126  Py_RETURN_NONE;
127 }
128 
129 PyDoc_STRVAR(SVertexIterator_t_doc,
130  "The curvilinear abscissa of the current point.\n"
131  "\n"
132  ":type: float");
133 
134 static PyObject *SVertexIterator_t_get(BPy_SVertexIterator *self, void *UNUSED(closure))
135 {
136  return PyFloat_FromDouble(self->sv_it->t());
137 }
138 
139 PyDoc_STRVAR(SVertexIterator_u_doc,
140  "The point parameter at the current point in the 1D element (0 <= u <= 1).\n"
141  "\n"
142  ":type: float");
143 
144 static PyObject *SVertexIterator_u_get(BPy_SVertexIterator *self, void *UNUSED(closure))
145 {
146  return PyFloat_FromDouble(self->sv_it->u());
147 }
148 
149 static PyGetSetDef BPy_SVertexIterator_getseters[] = {
150  {"object",
152  (setter) nullptr,
153  SVertexIterator_object_doc,
154  nullptr},
155  {"t", (getter)SVertexIterator_t_get, (setter) nullptr, SVertexIterator_t_doc, nullptr},
156  {"u", (getter)SVertexIterator_u_get, (setter) nullptr, SVertexIterator_u_doc, nullptr},
157  {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
158 };
159 
160 /*-----------------------BPy_SVertexIterator type definition ------------------------------*/
161 
162 PyTypeObject SVertexIterator_Type = {
163  PyVarObject_HEAD_INIT(nullptr, 0) "SVertexIterator", /* tp_name */
164  sizeof(BPy_SVertexIterator), /* tp_basicsize */
165  0, /* tp_itemsize */
166  nullptr, /* tp_dealloc */
167  0, /* tp_vectorcall_offset */
168  nullptr, /* tp_getattr */
169  nullptr, /* tp_setattr */
170  nullptr, /* tp_reserved */
171  nullptr, /* tp_repr */
172  nullptr, /* tp_as_number */
173  nullptr, /* tp_as_sequence */
174  nullptr, /* tp_as_mapping */
175  nullptr, /* tp_hash */
176  nullptr, /* tp_call */
177  nullptr, /* tp_str */
178  nullptr, /* tp_getattro */
179  nullptr, /* tp_setattro */
180  nullptr, /* tp_as_buffer */
181  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
182  SVertexIterator_doc, /* tp_doc */
183  nullptr, /* tp_traverse */
184  nullptr, /* tp_clear */
185  nullptr, /* tp_richcompare */
186  0, /* tp_weaklistoffset */
187  nullptr, /* tp_iter */
188  nullptr, /* tp_iternext */
189  nullptr, /* tp_methods */
190  nullptr, /* tp_members */
191  BPy_SVertexIterator_getseters, /* tp_getset */
192  &Iterator_Type, /* tp_base */
193  nullptr, /* tp_dict */
194  nullptr, /* tp_descr_get */
195  nullptr, /* tp_descr_set */
196  0, /* tp_dictoffset */
197  (initproc)SVertexIterator_init, /* tp_init */
198  nullptr, /* tp_alloc */
199  nullptr, /* tp_new */
200 };
201 
203 
204 #ifdef __cplusplus
205 }
206 #endif
#define UNUSED(x)
PyObject * BPy_SVertex_from_SVertex(SVertex &sv)
PyTypeObject FEdge_Type
Definition: BPy_FEdge.cpp:358
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:185
inherits from class Rep
Definition: AppCanvas.cpp:32