Blender V5.3
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__(*args, **kwargs)\n"
30 "\n"
31 " Accepted call signatures:\n"
32 "\n"
33 " - ``__init__()``\n"
34 " - ``__init__(brother)``\n"
35 " - ``__init__(step=0.0)``\n"
36 "\n"
37 " Builds a CurvePointIterator object using either the default constructor,\n"
38 " copy constructor, or the overloaded constructor.\n"
39 "\n"
40 " :param brother: A CurvePointIterator object.\n"
41 " :type brother: :class:`CurvePointIterator`\n"
42 " :param step: A resampling resolution with which the curve is resampled.\n"
43 " If zero, no resampling is done (i.e., the iterator iterates over\n"
44 " initial vertices).\n"
45 " :type step: float\n");
46static int CurvePointIterator_init(BPy_CurvePointIterator *self, PyObject *args, PyObject *kwds)
47{
48 static const char *kwlist_1[] = {"brother", nullptr};
49 static const char *kwlist_2[] = {"step", nullptr};
50 PyObject *brother = nullptr;
51 float step;
52
53 if (PyArg_ParseTupleAndKeywords(args,
54 kwds,
55 "|" /* Optional arguments. */
56 "O!" /* `brother` */
57 ":__init__",
58 (char **)kwlist_1,
60 &brother))
61 {
62 if (!brother) {
64 }
65 else {
67 *(((BPy_CurvePointIterator *)brother)->cp_it));
68 }
69 }
70 else if ((void)PyErr_Clear(),
71 PyArg_ParseTupleAndKeywords(args,
72 kwds,
73 "f" /* `step` */
74 ":__init__",
75 (char **)kwlist_2,
76 &step))
77 {
79 }
80 else {
81 PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
82 return -1;
83 }
84 self->py_it.it = self->cp_it;
85 return 0;
86}
87
88/*----------------------CurvePointIterator get/setters ----------------------------*/
89
91 /* Wrap. */
92 CurvePointIterator_object_doc,
93 "The CurvePoint object currently pointed by this iterator.\n"
94 "\n"
95 ":type: :class:`CurvePoint`\n");
96static PyObject *CurvePointIterator_object_get(BPy_CurvePointIterator *self, void * /*closure*/)
97{
98 if (self->cp_it->isEnd()) {
99 PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
100 return nullptr;
101 }
102 return BPy_CurvePoint_from_CurvePoint(self->cp_it->operator*());
103}
104
106 /* Wrap. */
107 CurvePointIterator_t_doc,
108 "The curvilinear abscissa of the current point.\n"
109 "\n"
110 ":type: float\n");
111static PyObject *CurvePointIterator_t_get(BPy_CurvePointIterator *self, void * /*closure*/)
112{
113 return PyFloat_FromDouble(self->cp_it->t());
114}
115
117 /* Wrap. */
118 CurvePointIterator_u_doc,
119 "The point parameter at the current point in the stroke (0 <= u <= 1).\n"
120 "\n"
121 ":type: float\n");
122static PyObject *CurvePointIterator_u_get(BPy_CurvePointIterator *self, void * /*closure*/)
123{
124 return PyFloat_FromDouble(self->cp_it->u());
125}
126
127static PyGetSetDef BPy_CurvePointIterator_getseters[] = {
128 {"object",
130 (setter) nullptr,
131 CurvePointIterator_object_doc,
132 nullptr},
133 {"t", (getter)CurvePointIterator_t_get, (setter) nullptr, CurvePointIterator_t_doc, nullptr},
134 {"u", (getter)CurvePointIterator_u_get, (setter) nullptr, CurvePointIterator_u_doc, nullptr},
135 {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
136};
137
138/*-----------------------BPy_CurvePointIterator type definition ------------------------------*/
139
141 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
142 /*tp_name*/ "CurvePointIterator",
143 /*tp_basicsize*/ sizeof(BPy_CurvePointIterator),
144 /*tp_itemsize*/ 0,
145 /*tp_dealloc*/ nullptr,
146 /*tp_vectorcall_offset*/ 0,
147 /*tp_getattr*/ nullptr,
148 /*tp_setattr*/ nullptr,
149 /*tp_as_async*/ nullptr,
150 /*tp_repr*/ nullptr,
151 /*tp_as_number*/ nullptr,
152 /*tp_as_sequence*/ nullptr,
153 /*tp_as_mapping*/ nullptr,
154 /*tp_hash*/ nullptr,
155 /*tp_call*/ nullptr,
156 /*tp_str*/ nullptr,
157 /*tp_getattro*/ nullptr,
158 /*tp_setattro*/ nullptr,
159 /*tp_as_buffer*/ nullptr,
160 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
161 /*tp_doc*/ CurvePointIterator_doc,
162 /*tp_traverse*/ nullptr,
163 /*tp_clear*/ nullptr,
164 /*tp_richcompare*/ nullptr,
165 /*tp_weaklistoffset*/ 0,
166 /*tp_iter*/ nullptr,
167 /*tp_iternext*/ nullptr,
168 /*tp_methods*/ nullptr,
169 /*tp_members*/ nullptr,
171 /*tp_base*/ &Iterator_Type,
172 /*tp_dict*/ nullptr,
173 /*tp_descr_get*/ nullptr,
174 /*tp_descr_set*/ nullptr,
175 /*tp_dictoffset*/ 0,
176 /*tp_init*/ (initproc)CurvePointIterator_init,
177 /*tp_alloc*/ nullptr,
178 /*tp_new*/ nullptr,
179};
180
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)
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 *)
PyDoc_STRVAR(FalseBP1D___doc__, "Class hierarchy: :class:`freestyle.types.BinaryPredicate1D` > :class:`FalseBP1D`\n" "\n" ".. method:: __call__(inter1, inter2)\n" "\n" " Always returns false.\n" "\n" " :param inter1: The first Interface1D object.\n" " :type inter1: :class:`freestyle.types.Interface1D`\n" " :param inter2: The second Interface1D object.\n" " :type inter2: :class:`freestyle.types.Interface1D`\n" " :return: False.\n" " :rtype: bool\n")
PyTypeObject Iterator_Type
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
inherits from class Rep
Definition AppCanvas.cpp:20
Freestyle::CurveInternal::CurvePointIterator * cp_it
PyObject_HEAD Freestyle::Iterator * it