1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
|
#include "BPy_StrokeVertex.h"
#include "../../BPy_Convert.h"
#include "../../BPy_StrokeAttribute.h"
#include "../../Interface0D/BPy_SVertex.h"
#ifdef __cplusplus
extern "C" {
#endif
///////////////////////////////////////////////////////////////////////////////////////////
//------------------------INSTANCE METHODS ----------------------------------
static char StrokeVertex___doc__[] =
"Class to define a stroke vertex.\n"
"\n"
".. method:: __init__()\n"
"\n"
" Default constructor.\n"
"\n"
".. method:: __init__(iBrother)\n"
"\n"
" Copy constructor.\n"
"\n"
" :arg iBrother: A StrokeVertex object.\n"
" :type iBrother: :class:`StrokeVertex`\n"
"\n"
".. method:: __init__(iA, iB, t3)\n"
"\n"
" Builds a stroke vertex from 2 stroke vertices and an interpolation\n"
" parameter.\n"
"\n"
" :arg iA: The first StrokeVertex.\n"
" :type iA: :class:`StrokeVertex`\n"
" :arg iB: The second StrokeVertex.\n"
" :type iB: :class:`StrokeVertex`\n"
" :arg t3: An interpolation parameter.\n"
" :type t3: float\n"
"\n"
".. method:: __init__(iPoint)\n"
"\n"
" Builds a stroke vertex from a CurvePoint\n"
"\n"
" :arg iPoint: A CurvePoint object.\n"
" :type iPoint: :class:`CurvePoint`\n"
"\n"
".. method:: __init__(iSVertex)\n"
"\n"
" Builds a stroke vertex from a SVertex\n"
"\n"
" :arg iSVertex: An SVertex object.\n"
" :type iSVertex: :class:`SVertex`\n"
"\n"
".. method:: __init__(iSVertex, iAttribute)\n"
"\n"
" Builds a stroke vertex from an SVertex and a StrokeAttribute object.\n"
"\n"
" :arg iSVertex: An SVertex object.\n"
" :type iSVertex: :class:`SVertex`\n"
" :arg iAttribute: A StrokeAttribute object.\n"
" :type iAttribute: :class:`StrokeAttribute`\n";
static int StrokeVertex___init__(BPy_StrokeVertex *self, PyObject *args, PyObject *kwds)
{
PyObject *obj1 = 0, *obj2 = 0 , *obj3 = 0;
if (! PyArg_ParseTuple(args, "|OOO!", &obj1, &obj2, &PyFloat_Type, &obj3) )
return -1;
if( !obj1 ){
self->sv = new StrokeVertex();
} else if( !obj2 && BPy_StrokeVertex_Check(obj1) && ((BPy_StrokeVertex *) obj1)->sv ) {
self->sv = new StrokeVertex( *(((BPy_StrokeVertex *) obj1)->sv) );
} else if( !obj2 && BPy_CurvePoint_Check(obj1) && ((BPy_CurvePoint *) obj1)->cp ) {
self->sv = new StrokeVertex( ((BPy_CurvePoint *) obj1)->cp );
} else if( !obj2 && BPy_SVertex_Check(obj1) && ((BPy_SVertex *) obj1)->sv ) {
self->sv = new StrokeVertex( ((BPy_SVertex *) obj1)->sv );
} else if( obj3 && BPy_StrokeVertex_Check(obj1) && BPy_StrokeVertex_Check(obj2) ) {
StrokeVertex *sv1 = ((BPy_StrokeVertex *) obj1)->sv;
StrokeVertex *sv2 = ((BPy_StrokeVertex *) obj2)->sv;
if( !sv1 || ( sv1->A() == 0 && sv1->B() == 0 ) ) {
PyErr_SetString(PyExc_TypeError, "argument 1 is an invalid StrokeVertex object");
return -1;
}
if( !sv2 || ( sv2->A() == 0 && sv2->B() == 0 ) ) {
PyErr_SetString(PyExc_TypeError, "argument 2 is an invalid StrokeVertex object");
return -1;
}
self->sv = new StrokeVertex( sv1, sv2, PyFloat_AsDouble( obj3 ) );
} else {
PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
return -1;
}
self->py_cp.cp = self->sv;
self->py_cp.py_if0D.if0D = self->sv;
self->py_cp.py_if0D.borrowed = 0;
return 0;
}
static char StrokeVertex_x___doc__[] =
".. method:: x()\n"
"\n"
" Returns the 2D point X coordinate.\n"
"\n"
" :return: The X coordinate.\n"
" :rtype: float\n";
static PyObject * StrokeVertex_x( BPy_StrokeVertex *self ) {
return PyFloat_FromDouble( self->sv->x() );
}
static char StrokeVertex_y___doc__[] =
".. method:: y()\n"
"\n"
" Returns the 2D point Y coordinate.\n"
"\n"
" :return: The Y coordinate.\n"
" :rtype: float\n";
static PyObject * StrokeVertex_y( BPy_StrokeVertex *self ) {
return PyFloat_FromDouble( self->sv->y() );
}
static char StrokeVertex_getPoint___doc__[] =
".. method:: getPoint()\n"
"\n"
" Returns the 2D point coordinates as a two-dimensional vector.\n"
"\n"
" :return: The 2D coordinates.\n"
" :rtype: :class:`Mathutils.Vector`\n";
static PyObject * StrokeVertex_getPoint( BPy_StrokeVertex *self ) {
Vec2f v( self->sv->getPoint() );
return Vector_from_Vec2f( v );
}
static char StrokeVertex_attribute___doc__[] =
".. method:: attribute()\n"
"\n"
" Returns the StrokeAttribute for this StrokeVertex.\n"
"\n"
" :return: The StrokeAttribute object.\n"
" :rtype: :class:`StrokeAttribute`\n";
static PyObject * StrokeVertex_attribute( BPy_StrokeVertex *self ) {
return BPy_StrokeAttribute_from_StrokeAttribute( self->sv->attribute() );
}
static char StrokeVertex_curvilinearAbscissa___doc__[] =
".. method:: curvilinearAbscissa()\n"
"\n"
" Returns the curvilinear abscissa.\n"
"\n"
" :return: The curvilinear abscissa.\n"
" :rtype: float\n";
static PyObject * StrokeVertex_curvilinearAbscissa( BPy_StrokeVertex *self ) {
return PyFloat_FromDouble( self->sv->curvilinearAbscissa() );
}
static char StrokeVertex_strokeLength___doc__[] =
".. method:: strokeLength()\n"
"\n"
" Returns the length of the Stroke to which this StrokeVertex belongs\n"
"\n"
" :return: The stroke length.\n"
" :rtype: float\n";
static PyObject * StrokeVertex_strokeLength( BPy_StrokeVertex *self ) {
return PyFloat_FromDouble( self->sv->strokeLength() );
}
static char StrokeVertex_u___doc__[] =
".. method:: u()\n"
"\n"
" Returns the curvilinear abscissa of this StrokeVertex in the Stroke\n"
"\n"
" :return: The curvilinear abscissa.\n"
" :rtype: float\n";
static PyObject * StrokeVertex_u( BPy_StrokeVertex *self ) {
return PyFloat_FromDouble( self->sv->u() );
}
static char StrokeVertex_setX___doc__[] =
".. method:: setX(x)\n"
"\n"
" Sets the 2D point X coordinate.\n"
"\n"
" :arg x: The X coordinate.\n"
" :type x: float\n";
static PyObject *StrokeVertex_setX( BPy_StrokeVertex *self , PyObject *args) {
double r;
if(!( PyArg_ParseTuple(args, "d", &r) ))
return NULL;
self->sv->setX( r );
Py_RETURN_NONE;
}
static char StrokeVertex_setY___doc__[] =
".. method:: setY(y)\n"
"\n"
" Sets the 2D point Y coordinate.\n"
"\n"
" :arg y: The Y coordinate.\n"
" :type y: float\n";
static PyObject *StrokeVertex_setY( BPy_StrokeVertex *self , PyObject *args) {
double r;
if(!( PyArg_ParseTuple(args, "d", &r) ))
return NULL;
self->sv->setY( r );
Py_RETURN_NONE;
}
static char StrokeVertex_setPoint___doc__[] =
".. method:: setPoint(x, y)\n"
"\n"
" Sets the 2D point X and Y coordinates.\n"
"\n"
" :arg x: The X coordinate.\n"
" :type x: float\n"
" :arg y: The Y coordinate.\n"
" :type y: float\n"
"\n"
".. method:: SetPoint(p)\n"
"\n"
" Sets the 2D point X and Y coordinates.\n"
"\n"
" :arg p: A two-dimensional vector.\n"
" :type p: :class:`Mathutils.Vector`, list or tuple of 2 real numbers\n";
static PyObject *StrokeVertex_setPoint( BPy_StrokeVertex *self , PyObject *args) {
PyObject *obj1 = 0, *obj2 = 0;
if(!( PyArg_ParseTuple(args, "O|O", &obj1, &obj2) ))
return NULL;
if( obj1 && !obj2 ){
Vec2f *v = Vec2f_ptr_from_PyObject(obj1);
if( !v ) {
PyErr_SetString(PyExc_TypeError, "argument 1 must be a 2D vector (either a list of 2 elements or Vector)");
return NULL;
}
self->sv->setPoint( *v );
delete v;
} else if( PyFloat_Check(obj1) && obj2 && PyFloat_Check(obj2) ){
self->sv->setPoint( PyFloat_AsDouble(obj1), PyFloat_AsDouble(obj2) );
} else {
PyErr_SetString(PyExc_TypeError, "invalid arguments");
return NULL;
}
Py_RETURN_NONE;
}
static char StrokeVertex_setAttribute___doc__[] =
".. method:: setAttribute(iAttribute)\n"
"\n"
" Sets the attribute.\n"
"\n"
" :arg iAttribute: A StrokeAttribute object.\n"
" :type iAttribute: :class:`StrokeAttribute`\n";
static PyObject *StrokeVertex_setAttribute( BPy_StrokeVertex *self , PyObject *args) {
PyObject *py_sa;
if(!( PyArg_ParseTuple(args, "O!", &StrokeAttribute_Type, &py_sa) ))
return NULL;
self->sv->setAttribute(*( ((BPy_StrokeAttribute *) py_sa)->sa ));
Py_RETURN_NONE;
}
static char StrokeVertex_setCurvilinearAbscissa___doc__[] =
".. method:: setCurvilinearAbscissa(iAbscissa)\n"
"\n"
" Sets the curvilinear abscissa of this StrokeVertex in the Stroke\n"
"\n"
" :arg iAbscissa: The curvilinear abscissa.\n"
" :type iAbscissa: float\n";
static PyObject *StrokeVertex_setCurvilinearAbscissa( BPy_StrokeVertex *self , PyObject *args) {
double r;
if(!( PyArg_ParseTuple(args, "d", &r) ))
return NULL;
self->sv->setCurvilinearAbscissa( r );
Py_RETURN_NONE;
}
static char StrokeVertex_setStrokeLength___doc__[] =
".. method:: setStrokeLength(iLength)\n"
"\n"
" Sets the stroke length (it is only a value retained by the\n"
" StrokeVertex, and it won't change the real stroke length).\n"
"\n"
" :arg iLength: The stroke length.\n"
" :type iLength: float\n";
static PyObject *StrokeVertex_setStrokeLength( BPy_StrokeVertex *self , PyObject *args) {
double r;
if(!( PyArg_ParseTuple(args, "d", &r) ))
return NULL;
self->sv->setStrokeLength( r );
Py_RETURN_NONE;
}
// real operator[] (const int i) const
// real & operator[] (const int i)
/*----------------------StrokeVertex instance definitions ----------------------------*/
static PyMethodDef BPy_StrokeVertex_methods[] = {
// {"__copy__", ( PyCFunction ) StrokeVertex___copy__, METH_NOARGS, "() Cloning method."},
{"x", ( PyCFunction ) StrokeVertex_x, METH_NOARGS, StrokeVertex_x___doc__},
{"y", ( PyCFunction ) StrokeVertex_y, METH_NOARGS, StrokeVertex_y___doc__},
{"getPoint", ( PyCFunction ) StrokeVertex_getPoint, METH_NOARGS, StrokeVertex_getPoint___doc__},
{"attribute", ( PyCFunction ) StrokeVertex_attribute, METH_NOARGS, StrokeVertex_attribute___doc__},
{"curvilinearAbscissa", ( PyCFunction ) StrokeVertex_curvilinearAbscissa, METH_NOARGS, StrokeVertex_curvilinearAbscissa___doc__},
{"strokeLength", ( PyCFunction ) StrokeVertex_strokeLength, METH_NOARGS, StrokeVertex_strokeLength___doc__},
{"u", ( PyCFunction ) StrokeVertex_u, METH_NOARGS, StrokeVertex_u___doc__},
{"setX", ( PyCFunction ) StrokeVertex_setX, METH_VARARGS, StrokeVertex_setX___doc__},
{"setY", ( PyCFunction ) StrokeVertex_setY, METH_VARARGS, StrokeVertex_setY___doc__},
{"setPoint", ( PyCFunction ) StrokeVertex_setPoint, METH_VARARGS, StrokeVertex_setPoint___doc__},
{"setAttribute", ( PyCFunction ) StrokeVertex_setAttribute, METH_VARARGS, StrokeVertex_setAttribute___doc__},
{"setCurvilinearAbscissa", ( PyCFunction ) StrokeVertex_setCurvilinearAbscissa, METH_VARARGS, StrokeVertex_setCurvilinearAbscissa___doc__},
{"setStrokeLength", ( PyCFunction ) StrokeVertex_setStrokeLength, METH_VARARGS, StrokeVertex_setStrokeLength___doc__},
{NULL, NULL, 0, NULL}
};
/*-----------------------BPy_StrokeVertex type definition ------------------------------*/
PyTypeObject StrokeVertex_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
"StrokeVertex", /* tp_name */
sizeof(BPy_StrokeVertex), /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
StrokeVertex___doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
BPy_StrokeVertex_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
&CurvePoint_Type, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)StrokeVertex___init__, /* tp_init */
0, /* tp_alloc */
0, /* tp_new */
};
///////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif
|