Blender V5.0
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\n");
42static int CurvePointIterator_init(BPy_CurvePointIterator *self, PyObject *args, PyObject *kwds)
43{
44 static const char *kwlist_1[] = {"brother", nullptr};
45 static const char *kwlist_2[] = {"step", nullptr};
46 PyObject *brother = nullptr;
47 float step;
48
49 if (PyArg_ParseTupleAndKeywords(
50 args, kwds, "|O!", (char **)kwlist_1, &CurvePointIterator_Type, &brother))
51 {
52 if (!brother) {
54 }
55 else {
57 *(((BPy_CurvePointIterator *)brother)->cp_it));
58 }
59 }
60 else if ((void)PyErr_Clear(),
61 PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist_2, &step))
62 {
64 }
65 else {
66 PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
67 return -1;
68 }
69 self->py_it.it = self->cp_it;
70 return 0;
71}
72
73/*----------------------CurvePointIterator get/setters ----------------------------*/
74
76 /* Wrap. */
77 CurvePointIterator_object_doc,
78 "The CurvePoint object currently pointed by this iterator.\n"
79 "\n"
80 ":type: :class:`CurvePoint`\n");
81static PyObject *CurvePointIterator_object_get(BPy_CurvePointIterator *self, void * /*closure*/)
82{
83 if (self->cp_it->isEnd()) {
84 PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
85 return nullptr;
86 }
87 return BPy_CurvePoint_from_CurvePoint(self->cp_it->operator*());
88}
89
91 /* Wrap. */
92 CurvePointIterator_t_doc,
93 "The curvilinear abscissa of the current point.\n"
94 "\n"
95 ":type: float\n");
96static PyObject *CurvePointIterator_t_get(BPy_CurvePointIterator *self, void * /*closure*/)
97{
98 return PyFloat_FromDouble(self->cp_it->t());
99}
100
102 /* Wrap. */
103 CurvePointIterator_u_doc,
104 "The point parameter at the current point in the stroke (0 <= u <= 1).\n"
105 "\n"
106 ":type: float\n");
107static PyObject *CurvePointIterator_u_get(BPy_CurvePointIterator *self, void * /*closure*/)
108{
109 return PyFloat_FromDouble(self->cp_it->u());
110}
111
112static PyGetSetDef BPy_CurvePointIterator_getseters[] = {
113 {"object",
115 (setter) nullptr,
116 CurvePointIterator_object_doc,
117 nullptr},
118 {"t", (getter)CurvePointIterator_t_get, (setter) nullptr, CurvePointIterator_t_doc, nullptr},
119 {"u", (getter)CurvePointIterator_u_get, (setter) nullptr, CurvePointIterator_u_doc, nullptr},
120 {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
121};
122
123/*-----------------------BPy_CurvePointIterator type definition ------------------------------*/
124
126 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
127 /*tp_name*/ "CurvePointIterator",
128 /*tp_basicsize*/ sizeof(BPy_CurvePointIterator),
129 /*tp_itemsize*/ 0,
130 /*tp_dealloc*/ nullptr,
131 /*tp_vectorcall_offset*/ 0,
132 /*tp_getattr*/ nullptr,
133 /*tp_setattr*/ nullptr,
134 /*tp_as_async*/ nullptr,
135 /*tp_repr*/ nullptr,
136 /*tp_as_number*/ nullptr,
137 /*tp_as_sequence*/ nullptr,
138 /*tp_as_mapping*/ nullptr,
139 /*tp_hash*/ nullptr,
140 /*tp_call*/ nullptr,
141 /*tp_str*/ nullptr,
142 /*tp_getattro*/ nullptr,
143 /*tp_setattro*/ nullptr,
144 /*tp_as_buffer*/ nullptr,
145 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
146 /*tp_doc*/ CurvePointIterator_doc,
147 /*tp_traverse*/ nullptr,
148 /*tp_clear*/ nullptr,
149 /*tp_richcompare*/ nullptr,
150 /*tp_weaklistoffset*/ 0,
151 /*tp_iter*/ nullptr,
152 /*tp_iternext*/ nullptr,
153 /*tp_methods*/ nullptr,
154 /*tp_members*/ nullptr,
156 /*tp_base*/ &Iterator_Type,
157 /*tp_dict*/ nullptr,
158 /*tp_descr_get*/ nullptr,
159 /*tp_descr_set*/ nullptr,
160 /*tp_dictoffset*/ 0,
161 /*tp_init*/ (initproc)CurvePointIterator_init,
162 /*tp_alloc*/ nullptr,
163 /*tp_new*/ nullptr,
164};
165
PyObject * BPy_CurvePoint_from_CurvePoint(CurvePoint &cp)
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\n")
static PyObject * CurvePointIterator_object_get(BPy_CurvePointIterator *self, void *)
static int CurvePointIterator_init(BPy_CurvePointIterator *self, PyObject *args, PyObject *kwds)
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