Blender V4.5
BPy_CurvePointIterator.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"
13
14using namespace Freestyle;
15
17
18//------------------------INSTANCE METHODS ----------------------------------
19
21 /* Wrap. */
22 CurvePointIterator_doc,
23 "Class hierarchy: :class:`Iterator` > :class:`CurvePointIterator`\n"
24 "\n"
25 "Class representing an iterator on a curve. Allows an iterating\n"
26 "outside initial vertices. A CurvePoint is instantiated and returned\n"
27 "through the .object attribute.\n"
28 "\n"
29 ".. method:: __init__()\n"
30 " __init__(brother)\n"
31 " __init__(step=0.0)\n"
32 "\n"
33 " Builds a CurvePointIterator object using either the default constructor,\n"
34 " copy constructor, or the overloaded constructor.\n"
35 "\n"
36 " :arg brother: A CurvePointIterator object.\n"
37 " :type brother: :class:`CurvePointIterator`\n"
38 " :arg step: A resampling resolution with which the curve is resampled.\n"
39 " If zero, no resampling is done (i.e., the iterator iterates over\n"
40 " initial vertices).\n"
41 " :type step: float");
42
43static int CurvePointIterator_init(BPy_CurvePointIterator *self, PyObject *args, PyObject *kwds)
44{
45 static const char *kwlist_1[] = {"brother", nullptr};
46 static const char *kwlist_2[] = {"step", nullptr};
47 PyObject *brother = nullptr;
48 float step;
49
50 if (PyArg_ParseTupleAndKeywords(
51 args, kwds, "|O!", (char **)kwlist_1, &CurvePointIterator_Type, &brother))
52 {
53 if (!brother) {
55 }
56 else {
58 *(((BPy_CurvePointIterator *)brother)->cp_it));
59 }
60 }
61 else if ((void)PyErr_Clear(),
62 PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist_2, &step))
63 {
65 }
66 else {
67 PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
68 return -1;
69 }
70 self->py_it.it = self->cp_it;
71 return 0;
72}
73
74/*----------------------CurvePointIterator get/setters ----------------------------*/
75
77 /* Wrap. */
78 CurvePointIterator_object_doc,
79 "The CurvePoint object currently pointed by this iterator.\n"
80 "\n"
81 ":type: :class:`CurvePoint`");
82
83static PyObject *CurvePointIterator_object_get(BPy_CurvePointIterator *self, void * /*closure*/)
84{
85 if (self->cp_it->isEnd()) {
86 PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
87 return nullptr;
88 }
89 return BPy_CurvePoint_from_CurvePoint(self->cp_it->operator*());
90}
91
93 /* Wrap. */
94 CurvePointIterator_t_doc,
95 "The curvilinear abscissa of the current point.\n"
96 "\n"
97 ":type: float");
98
99static PyObject *CurvePointIterator_t_get(BPy_CurvePointIterator *self, void * /*closure*/)
100{
101 return PyFloat_FromDouble(self->cp_it->t());
102}
103
105 /* Wrap. */
106 CurvePointIterator_u_doc,
107 "The point parameter at the current point in the stroke (0 <= u <= 1).\n"
108 "\n"
109 ":type: float");
110
111static PyObject *CurvePointIterator_u_get(BPy_CurvePointIterator *self, void * /*closure*/)
112{
113 return PyFloat_FromDouble(self->cp_it->u());
114}
115
116static PyGetSetDef BPy_CurvePointIterator_getseters[] = {
117 {"object",
119 (setter) nullptr,
120 CurvePointIterator_object_doc,
121 nullptr},
122 {"t", (getter)CurvePointIterator_t_get, (setter) nullptr, CurvePointIterator_t_doc, nullptr},
123 {"u", (getter)CurvePointIterator_u_get, (setter) nullptr, CurvePointIterator_u_doc, nullptr},
124 {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
125};
126
127/*-----------------------BPy_CurvePointIterator type definition ------------------------------*/
128
130 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
131 /*tp_name*/ "CurvePointIterator",
132 /*tp_basicsize*/ sizeof(BPy_CurvePointIterator),
133 /*tp_itemsize*/ 0,
134 /*tp_dealloc*/ nullptr,
135 /*tp_vectorcall_offset*/ 0,
136 /*tp_getattr*/ nullptr,
137 /*tp_setattr*/ nullptr,
138 /*tp_as_async*/ nullptr,
139 /*tp_repr*/ nullptr,
140 /*tp_as_number*/ nullptr,
141 /*tp_as_sequence*/ nullptr,
142 /*tp_as_mapping*/ nullptr,
143 /*tp_hash*/ nullptr,
144 /*tp_call*/ nullptr,
145 /*tp_str*/ nullptr,
146 /*tp_getattro*/ nullptr,
147 /*tp_setattro*/ nullptr,
148 /*tp_as_buffer*/ nullptr,
149 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
150 /*tp_doc*/ CurvePointIterator_doc,
151 /*tp_traverse*/ nullptr,
152 /*tp_clear*/ nullptr,
153 /*tp_richcompare*/ nullptr,
154 /*tp_weaklistoffset*/ 0,
155 /*tp_iter*/ nullptr,
156 /*tp_iternext*/ nullptr,
157 /*tp_methods*/ nullptr,
158 /*tp_members*/ nullptr,
160 /*tp_base*/ &Iterator_Type,
161 /*tp_dict*/ nullptr,
162 /*tp_descr_get*/ nullptr,
163 /*tp_descr_set*/ nullptr,
164 /*tp_dictoffset*/ 0,
165 /*tp_init*/ (initproc)CurvePointIterator_init,
166 /*tp_alloc*/ nullptr,
167 /*tp_new*/ nullptr,
168};
169
PyObject * BPy_CurvePoint_from_CurvePoint(CurvePoint &cp)
static PyObject * CurvePointIterator_object_get(BPy_CurvePointIterator *self, void *)
static int CurvePointIterator_init(BPy_CurvePointIterator *self, PyObject *args, PyObject *kwds)
PyDoc_STRVAR(CurvePointIterator_doc, "Class hierarchy: :class:`Iterator` > :class:`CurvePointIterator`\n" "\n" "Class representing an iterator on a curve. Allows an iterating\n" "outside initial vertices. A CurvePoint is instantiated and returned\n" "through the .object attribute.\n" "\n" ".. method:: __init__()\n" " __init__(brother)\n" " __init__(step=0.0)\n" "\n" " Builds a CurvePointIterator object using either the default constructor,\n" " copy constructor, or the overloaded constructor.\n" "\n" " :arg brother: A CurvePointIterator object.\n" " :type brother: :class:`CurvePointIterator`\n" " :arg step: A resampling resolution with which the curve is resampled.\n" " If zero, no resampling is done (i.e., the iterator iterates over\n" " initial vertices).\n" " :type step: float")
static PyGetSetDef BPy_CurvePointIterator_getseters[]
static PyObject * CurvePointIterator_t_get(BPy_CurvePointIterator *self, void *)
PyTypeObject CurvePointIterator_Type
static PyObject * CurvePointIterator_u_get(BPy_CurvePointIterator *self, void *)
PyTypeObject Iterator_Type
PyObject * self
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
inherits from class Rep
Definition AppCanvas.cpp:20