2008-07-23 07:56:08 +00:00
# include "BPy_Stroke.h"
2008-07-23 05:54:34 +00:00
2008-07-23 07:56:08 +00:00
# include "../BPy_Convert.h"
2008-07-24 20:39:13 +00:00
# include "../BPy_Id.h"
2008-07-23 07:56:08 +00:00
# include "../Interface0D/BPy_SVertex.h"
2008-07-24 20:39:13 +00:00
# include "../Interface0D/CurvePoint/BPy_StrokeVertex.h"
2008-07-25 00:18:10 +00:00
# include "../Iterator/BPy_StrokeVertexIterator.h"
2008-07-24 20:39:13 +00:00
# include "../BPy_MediumType.h"
2008-07-23 05:54:34 +00:00
# ifdef __cplusplus
extern " C " {
# endif
///////////////////////////////////////////////////////////////////////////////////////////
/*--------------- Python API function prototypes for Stroke instance -----------*/
static int Stroke___init__ ( BPy_Stroke * self , PyObject * args , PyObject * kwds ) ;
2008-12-01 11:14:33 +00:00
static PyObject * Stroke___iter__ ( PyObject * self ) ;
static Py_ssize_t Stroke_length ( BPy_Stroke * self ) ;
static PyObject * Stroke_item ( BPy_Stroke * self , Py_ssize_t i ) ;
static PyObject * Stroke___getitem__ ( BPy_Stroke * self , PyObject * item ) ;
2008-07-23 05:54:34 +00:00
static PyObject * Stroke_ComputeSampling ( BPy_Stroke * self , PyObject * args ) ;
static PyObject * Stroke_Resample ( BPy_Stroke * self , PyObject * args ) ;
2008-07-25 00:18:10 +00:00
static PyObject * Stroke_InsertVertex ( BPy_Stroke * self , PyObject * args ) ;
2008-07-23 05:54:34 +00:00
static PyObject * Stroke_RemoveVertex ( BPy_Stroke * self , PyObject * args ) ;
static PyObject * Stroke_getMediumType ( BPy_Stroke * self ) ;
static PyObject * Stroke_getTextureId ( BPy_Stroke * self ) ;
static PyObject * Stroke_hasTips ( BPy_Stroke * self ) ;
static PyObject * Stroke_setId ( BPy_Stroke * self , PyObject * args ) ;
static PyObject * Stroke_setLength ( BPy_Stroke * self , PyObject * args ) ;
static PyObject * Stroke_setMediumType ( BPy_Stroke * self , PyObject * args ) ;
static PyObject * Stroke_setTextureId ( BPy_Stroke * self , PyObject * args ) ;
static PyObject * Stroke_setTips ( BPy_Stroke * self , PyObject * args ) ;
2008-07-25 00:18:10 +00:00
static PyObject * Stroke_strokeVerticesBegin ( BPy_Stroke * self , PyObject * args ) ;
static PyObject * Stroke_strokeVerticesEnd ( BPy_Stroke * self ) ;
2008-07-23 05:54:34 +00:00
static PyObject * Stroke_strokeVerticesSize ( BPy_Stroke * self ) ;
/*----------------------Stroke instance definitions ----------------------------*/
static PyMethodDef BPy_Stroke_methods [ ] = {
2008-12-01 11:14:33 +00:00
{ " __getitem__ " , ( PyCFunction ) Stroke___getitem__ , METH_O , " (int i) Returns the i-th StrokeVertex constituting the Stroke. " } ,
2008-07-23 05:54:34 +00:00
{ " ComputeSampling " , ( PyCFunction ) Stroke_ComputeSampling , METH_VARARGS , " (int nVertices) Compute the sampling needed to get nVertices vertices. If the specified number of vertices is less than the actual number of vertices, the actual sampling value is returned. " } ,
2009-03-29 21:50:10 +00:00
{ " Resample " , ( PyCFunction ) Stroke_Resample , METH_VARARGS , " (float f | int n) Resampling method. If the argument is a float, Resamples the curve with a given sampling; if this sampling is < to the actual sampling value, no resampling is done. If the argument is an integer, Resamples the curve so that it eventually has n. That means it is going to add n-vertices_size, if vertices_size is the number of points we already have. Is vertices_size >= n, no resampling is done. " } ,
2008-07-23 05:54:34 +00:00
{ " RemoveVertex " , ( PyCFunction ) Stroke_RemoveVertex , METH_VARARGS , " (StrokeVertex sv) Removes the stroke vertex sv from the stroke. The length and curvilinear abscissa are updated consequently. " } ,
2008-07-25 00:18:10 +00:00
{ " InsertVertex " , ( PyCFunction ) Stroke_InsertVertex , METH_VARARGS , " (StrokeVertex sv, StrokeVertexIterator next) Inserts the stroke vertex iVertex in the stroke before next. The length, curvilinear abscissa are updated consequently. " } ,
2008-07-23 05:54:34 +00:00
{ " getMediumType " , ( PyCFunction ) Stroke_getMediumType , METH_NOARGS , " () Returns the MediumType used for this Stroke. " } ,
{ " getTextureId " , ( PyCFunction ) Stroke_getTextureId , METH_NOARGS , " () Returns the id of the texture used to simulate th marks system for this Stroke. " } ,
{ " hasTips " , ( PyCFunction ) Stroke_hasTips , METH_NOARGS , " () Returns true if this Stroke uses a texture with tips, false otherwise. " } ,
{ " setId " , ( PyCFunction ) Stroke_setId , METH_VARARGS , " (Id id) Sets the Id of the Stroke. " } ,
{ " setLength " , ( PyCFunction ) Stroke_setLength , METH_VARARGS , " (float l) Sets the 2D length of the Stroke. " } ,
{ " setMediumType " , ( PyCFunction ) Stroke_setMediumType , METH_VARARGS , " (MediumType mt) Sets the medium type that must be used for this Stroke. " } ,
{ " setTextureId " , ( PyCFunction ) Stroke_setTextureId , METH_VARARGS , " (unsigned int id) Sets the texture id to be used to simulate the marks system for this Stroke. " } ,
{ " setTips " , ( PyCFunction ) Stroke_setTips , METH_VARARGS , " (bool b) Sets the flag telling whether this stroke is using a texture with tips or not. " } ,
2008-07-25 00:18:10 +00:00
{ " strokeVerticesBegin " , ( PyCFunction ) Stroke_strokeVerticesBegin , METH_VARARGS , " (float t=0.f) Returns a StrokeVertexIterator pointing on the first StrokeVertex of the Stroke. One can specifly a sampling value t to resample the Stroke on the fly if needed. " } ,
{ " strokeVerticesEnd " , ( PyCFunction ) Stroke_strokeVerticesEnd , METH_NOARGS , " () Returns a StrokeVertexIterator pointing after the last StrokeVertex of the Stroke. " } ,
2008-07-23 05:54:34 +00:00
{ " strokeVerticesSize " , ( PyCFunction ) Stroke_strokeVerticesSize , METH_NOARGS , " () Returns the number of StrokeVertex constituing the Stroke. " } ,
{ NULL , NULL , 0 , NULL }
} ;
/*-----------------------BPy_Stroke type definition ------------------------------*/
2008-12-01 11:14:33 +00:00
static PySequenceMethods Stroke_as_sequence = {
( lenfunc ) Stroke_length , /* sq_length */
NULL , /* sq_concat */
NULL , /* sq_repeat */
( ssizeargfunc ) Stroke_item , /* sq_item */
NULL , /* sq_slice */
NULL , /* sq_ass_item */
NULL , /* sq_ass_slice */
NULL , /* sq_contains */
NULL , /* sq_inplace_concat */
NULL , /* sq_inplace_repeat */
} ;
2008-07-23 05:54:34 +00:00
PyTypeObject Stroke_Type = {
2010-04-08 01:13:54 +00:00
PyVarObject_HEAD_INIT ( NULL , 0 )
2009-09-27 00:32:20 +00:00
" Stroke " , /* tp_name */
sizeof ( BPy_Stroke ) , /* 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 */
& Stroke_as_sequence , /* 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 */
" Stroke objects " , /* tp_doc */
0 , /* tp_traverse */
0 , /* tp_clear */
0 , /* tp_richcompare */
0 , /* tp_weaklistoffset */
( getiterfunc ) Stroke___iter__ , /* tp_iter */
0 , /* tp_iternext */
BPy_Stroke_methods , /* tp_methods */
0 , /* tp_members */
0 , /* tp_getset */
& Interface1D_Type , /* tp_base */
0 , /* tp_dict */
0 , /* tp_descr_get */
0 , /* tp_descr_set */
0 , /* tp_dictoffset */
( initproc ) Stroke___init__ , /* tp_init */
0 , /* tp_alloc */
0 , /* tp_new */
2008-07-23 05:54:34 +00:00
} ;
2008-07-09 08:24:13 +00:00
2008-07-23 05:54:34 +00:00
//------------------------INSTANCE METHODS ----------------------------------
2008-07-09 08:24:13 +00:00
2008-07-23 05:54:34 +00:00
// Stroke ()
// template<class InputVertexIterator> Stroke (InputVertexIterator iBegin, InputVertexIterator iEnd)
2008-12-01 11:14:33 +00:00
//
// pb: - need to be able to switch representation: InputVertexIterator <=> position
// - is it even used ? not even in SWIG version
2008-07-09 08:24:13 +00:00
2008-07-23 05:54:34 +00:00
int Stroke___init__ ( BPy_Stroke * self , PyObject * args , PyObject * kwds )
{
2008-12-01 11:14:33 +00:00
PyObject * obj1 = NULL , * obj2 = NULL ;
2008-07-09 08:24:13 +00:00
2008-12-01 11:14:33 +00:00
if ( ! PyArg_ParseTuple ( args , " |OO " , & obj1 , & obj2 ) )
2008-07-23 05:54:34 +00:00
return - 1 ;
2008-07-09 08:24:13 +00:00
2009-08-03 15:19:51 +00:00
if ( ! obj1 ) {
2008-07-23 05:54:34 +00:00
self - > s = new Stroke ( ) ;
2009-08-03 15:19:51 +00:00
} else if ( ! obj2 & & BPy_Stroke_Check ( obj1 ) ) {
2008-12-01 11:14:33 +00:00
self - > s = new Stroke ( * ( ( ( BPy_Stroke * ) obj1 ) - > s ) ) ;
2009-08-03 15:19:51 +00:00
} else if ( obj2 ) {
PyErr_SetString ( PyExc_TypeError ,
2008-12-01 11:14:33 +00:00
" Stroke(InputVertexIterator iBegin, InputVertexIterator iEnd) not implemented " ) ;
2008-07-23 05:54:34 +00:00
return - 1 ;
2009-08-03 15:19:51 +00:00
} else {
PyErr_SetString ( PyExc_TypeError , " invalid argument(s) " ) ;
return - 1 ;
2008-07-23 05:54:34 +00:00
}
2008-07-09 08:24:13 +00:00
2008-07-23 05:54:34 +00:00
self - > py_if1D . if1D = self - > s ;
SWIG/directors dependency removal (cont'd)
* Added to python/BPy_Convert.{cpp,h} 4 utility converters below for
better introspection-based automatic type conversion.
PyObject * Any_BPy_Interface0D_from_Interface0D( Interface0D& if0D );
PyObject * Any_BPy_Interface1D_from_Interface1D( Interface1D& if1D );
PyObject * Any_BPy_FEdge_from_FEdge( FEdge& fe );
PyObject * Any_BPy_ViewVertex_from_ViewVertex( ViewVertex& vv );
There are 4 corresponding converters without the "Any_" prefix. All
calls of them in the code base were replaced with these new converters
so that the introspection-based automatic conversion would take place
universally.
* python/BPy_Convert.{cpp,h}: Those C++ to Python converters having
had a "_ptr" suffix were renamed to a name without the suffix, and
their arguments were changed so as to take a reference (e.g.,
ViewVertex&) instead of a pointer (e.g., ViewVertex *). The changed
converters and their new function prototypes are listed below. These
converters now return a Python wrapper object that retains the passed
reference, instead of retaining a newly created C++ object by the
converters.
// Interface0D converters
PyObject * BPy_Interface0D_from_Interface0D( Interface0D& if0D );
PyObject * BPy_CurvePoint_from_CurvePoint( CurvePoint& cp );
PyObject * BPy_StrokeVertex_from_StrokeVertex( StrokeVertex& sv );
PyObject * BPy_SVertex_from_SVertex( SVertex& sv );
PyObject * BPy_ViewVertex_from_ViewVertex( ViewVertex& vv );
PyObject * BPy_TVertex_from_TVertex( TVertex& tv );
PyObject * BPy_NonTVertex_from_NonTVertex( NonTVertex& ntv );
// Interface1D converters
PyObject * BPy_Interface1D_from_Interface1D( Interface1D& if1D );
PyObject * BPy_Chain_from_Chain( Chain& c );
PyObject * BPy_FEdge_from_FEdge( FEdge& fe );
PyObject * BPy_FEdgeSharp_from_FEdgeSharp( FEdgeSharp& fes );
PyObject * BPy_FEdgeSmooth_from_FEdgeSmooth( FEdgeSmooth& fes );
PyObject * BPy_Stroke_from_Stroke( Stroke& s );
PyObject * BPy_ViewEdge_from_ViewEdge( ViewEdge& ve );
PyObject * BPy_directedViewEdge_from_directedViewEdge( ViewVertex::directedViewEdge& dve );
// some other converters
PyObject * BPy_ViewShape_from_ViewShape( ViewShape& vs );
PyObject * BPy_SShape_from_SShape( SShape& ss );
PyObject * BPy_FrsMaterial_from_FrsMaterial( FrsMaterial& m );
PyObject * BPy_StrokeAttribute_from_StrokeAttribute( StrokeAttribute& sa );
* Added a "borrowed" flag to the definitions of Python types being
used to wrap C++ components of Freestyle's internal data structures.
The flag indicates whether or not a Python wrapper object has a
reference to a C++ object that comprises the internal data structures.
The deallocation routines of the Python types check this flag and
release a wrapped C++ object only when it is not part of the internal
data structures. The following files were modified:
python/BPy_FrsMaterial.{cpp,h}
python/BPy_Interface0D.{cpp,h}
python/BPy_Interface1D.{cpp,h}
python/BPy_SShape.{cpp,h}
python/BPy_StrokeAttribute.{cpp,h}
python/BPy_ViewShape.{cpp,h}
python/Interface0D/BPy_CurvePoint.cpp
python/Interface0D/BPy_SVertex.cpp
python/Interface0D/BPy_ViewVertex.cpp
python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp
python/Interface0D/ViewVertex/BPy_NonTVertex.cpp
python/Interface0D/ViewVertex/BPy_TVertex.cpp
python/Interface1D/BPy_FEdge.cpp
python/Interface1D/BPy_FrsCurve.cpp
python/Interface1D/BPy_Stroke.cpp
python/Interface1D/BPy_ViewEdge.cpp
python/Interface1D/Curve/BPy_Chain.cpp
python/Interface1D/FEdge/BPy_FEdgeSharp.cpp
python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp
* view_map/Interface[01]D.h, python/BPy_Interface[01]D.cpp: Removed
from the Interface0D and Interface1D C++ classes a back pointer to a
Python wrapper object and all "director" calls. These classes (and
their subclasses) are used to build Freestyle's main data structures
(such as a view map and strokes) and their class hierarchy is static.
Python wrappers of these C++ classes are only used to access the data
structures from the Python layer, and not intended to extend the data
structures by subclassing the Python wrappers. Without the necessity
of subclassing in the Python layer, the back pointer to a wrapping
Python object and "director" calls would be useless (actually they
were not used at all), so they were all removed.
* python/Director.{cpp,h}: Removed the definitions of directors that
were no longer used.
* stroke/Stroke.{cpp,h}: Removed an (unused) back pointer to a Python
wrapper object.
* python/BPy_ViewMap.cpp: Fixed a possible null pointer reference.
* python/Interface1D/BPy_FEdge.cpp: Fixed parameter checking in
FEdge___init__().
2009-08-02 16:23:18 +00:00
self - > py_if1D . borrowed = 0 ;
2008-07-09 08:24:13 +00:00
2008-07-23 05:54:34 +00:00
return 0 ;
2008-07-09 08:24:13 +00:00
}
2008-12-01 11:14:33 +00:00
PyObject * Stroke___iter__ ( PyObject * self ) {
StrokeInternal : : StrokeVertexIterator sv_it ( ( ( BPy_Stroke * ) self ) - > s - > strokeVerticesBegin ( ) ) ;
return BPy_StrokeVertexIterator_from_StrokeVertexIterator ( sv_it , 0 ) ;
}
Py_ssize_t Stroke_length ( BPy_Stroke * self ) {
return self - > s - > strokeVerticesSize ( ) ;
}
PyObject * Stroke_item ( BPy_Stroke * self , Py_ssize_t i ) {
if ( i < 0 | | i > = ( Py_ssize_t ) self - > s - > strokeVerticesSize ( ) ) {
PyErr_SetString ( PyExc_IndexError , " subscript index out of range " ) ;
return NULL ;
}
SWIG/directors dependency removal (cont'd)
* Added to python/BPy_Convert.{cpp,h} 4 utility converters below for
better introspection-based automatic type conversion.
PyObject * Any_BPy_Interface0D_from_Interface0D( Interface0D& if0D );
PyObject * Any_BPy_Interface1D_from_Interface1D( Interface1D& if1D );
PyObject * Any_BPy_FEdge_from_FEdge( FEdge& fe );
PyObject * Any_BPy_ViewVertex_from_ViewVertex( ViewVertex& vv );
There are 4 corresponding converters without the "Any_" prefix. All
calls of them in the code base were replaced with these new converters
so that the introspection-based automatic conversion would take place
universally.
* python/BPy_Convert.{cpp,h}: Those C++ to Python converters having
had a "_ptr" suffix were renamed to a name without the suffix, and
their arguments were changed so as to take a reference (e.g.,
ViewVertex&) instead of a pointer (e.g., ViewVertex *). The changed
converters and their new function prototypes are listed below. These
converters now return a Python wrapper object that retains the passed
reference, instead of retaining a newly created C++ object by the
converters.
// Interface0D converters
PyObject * BPy_Interface0D_from_Interface0D( Interface0D& if0D );
PyObject * BPy_CurvePoint_from_CurvePoint( CurvePoint& cp );
PyObject * BPy_StrokeVertex_from_StrokeVertex( StrokeVertex& sv );
PyObject * BPy_SVertex_from_SVertex( SVertex& sv );
PyObject * BPy_ViewVertex_from_ViewVertex( ViewVertex& vv );
PyObject * BPy_TVertex_from_TVertex( TVertex& tv );
PyObject * BPy_NonTVertex_from_NonTVertex( NonTVertex& ntv );
// Interface1D converters
PyObject * BPy_Interface1D_from_Interface1D( Interface1D& if1D );
PyObject * BPy_Chain_from_Chain( Chain& c );
PyObject * BPy_FEdge_from_FEdge( FEdge& fe );
PyObject * BPy_FEdgeSharp_from_FEdgeSharp( FEdgeSharp& fes );
PyObject * BPy_FEdgeSmooth_from_FEdgeSmooth( FEdgeSmooth& fes );
PyObject * BPy_Stroke_from_Stroke( Stroke& s );
PyObject * BPy_ViewEdge_from_ViewEdge( ViewEdge& ve );
PyObject * BPy_directedViewEdge_from_directedViewEdge( ViewVertex::directedViewEdge& dve );
// some other converters
PyObject * BPy_ViewShape_from_ViewShape( ViewShape& vs );
PyObject * BPy_SShape_from_SShape( SShape& ss );
PyObject * BPy_FrsMaterial_from_FrsMaterial( FrsMaterial& m );
PyObject * BPy_StrokeAttribute_from_StrokeAttribute( StrokeAttribute& sa );
* Added a "borrowed" flag to the definitions of Python types being
used to wrap C++ components of Freestyle's internal data structures.
The flag indicates whether or not a Python wrapper object has a
reference to a C++ object that comprises the internal data structures.
The deallocation routines of the Python types check this flag and
release a wrapped C++ object only when it is not part of the internal
data structures. The following files were modified:
python/BPy_FrsMaterial.{cpp,h}
python/BPy_Interface0D.{cpp,h}
python/BPy_Interface1D.{cpp,h}
python/BPy_SShape.{cpp,h}
python/BPy_StrokeAttribute.{cpp,h}
python/BPy_ViewShape.{cpp,h}
python/Interface0D/BPy_CurvePoint.cpp
python/Interface0D/BPy_SVertex.cpp
python/Interface0D/BPy_ViewVertex.cpp
python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp
python/Interface0D/ViewVertex/BPy_NonTVertex.cpp
python/Interface0D/ViewVertex/BPy_TVertex.cpp
python/Interface1D/BPy_FEdge.cpp
python/Interface1D/BPy_FrsCurve.cpp
python/Interface1D/BPy_Stroke.cpp
python/Interface1D/BPy_ViewEdge.cpp
python/Interface1D/Curve/BPy_Chain.cpp
python/Interface1D/FEdge/BPy_FEdgeSharp.cpp
python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp
* view_map/Interface[01]D.h, python/BPy_Interface[01]D.cpp: Removed
from the Interface0D and Interface1D C++ classes a back pointer to a
Python wrapper object and all "director" calls. These classes (and
their subclasses) are used to build Freestyle's main data structures
(such as a view map and strokes) and their class hierarchy is static.
Python wrappers of these C++ classes are only used to access the data
structures from the Python layer, and not intended to extend the data
structures by subclassing the Python wrappers. Without the necessity
of subclassing in the Python layer, the back pointer to a wrapping
Python object and "director" calls would be useless (actually they
were not used at all), so they were all removed.
* python/Director.{cpp,h}: Removed the definitions of directors that
were no longer used.
* stroke/Stroke.{cpp,h}: Removed an (unused) back pointer to a Python
wrapper object.
* python/BPy_ViewMap.cpp: Fixed a possible null pointer reference.
* python/Interface1D/BPy_FEdge.cpp: Fixed parameter checking in
FEdge___init__().
2009-08-02 16:23:18 +00:00
return BPy_StrokeVertex_from_StrokeVertex ( self - > s - > strokeVerticeAt ( i ) ) ;
2008-12-01 11:14:33 +00:00
}
PyObject * Stroke___getitem__ ( BPy_Stroke * self , PyObject * item ) {
long i ;
2009-09-27 00:32:20 +00:00
if ( ! PyLong_Check ( item ) ) {
2008-12-01 11:14:33 +00:00
PyErr_SetString ( PyExc_TypeError , " subscript indices must be integers " ) ;
return NULL ;
}
2009-09-27 00:32:20 +00:00
i = PyLong_AsLong ( item ) ;
if ( i = = - 1 & & PyErr_Occurred ( ) )
return NULL ;
2008-12-01 11:14:33 +00:00
if ( i < 0 ) {
i + = self - > s - > strokeVerticesSize ( ) ;
}
return Stroke_item ( self , i ) ;
}
2008-07-23 05:54:34 +00:00
PyObject * Stroke_ComputeSampling ( BPy_Stroke * self , PyObject * args ) {
int i ;
2008-07-09 08:24:13 +00:00
2009-03-29 21:50:10 +00:00
if ( ! ( PyArg_ParseTuple ( args , " i " , & i ) ) )
return NULL ;
2008-07-09 08:24:13 +00:00
2008-07-23 05:54:34 +00:00
return PyFloat_FromDouble ( self - > s - > ComputeSampling ( i ) ) ;
2008-07-09 08:24:13 +00:00
}
2008-07-23 05:54:34 +00:00
PyObject * Stroke_Resample ( BPy_Stroke * self , PyObject * args ) {
PyObject * obj ;
2008-07-09 08:24:13 +00:00
2009-03-29 21:50:10 +00:00
if ( ! ( PyArg_ParseTuple ( args , " O " , & obj ) ) )
return NULL ;
2008-07-09 08:24:13 +00:00
2009-09-27 00:32:20 +00:00
if ( PyLong_Check ( obj ) )
self - > s - > Resample ( ( int ) PyLong_AsLong ( obj ) ) ;
2008-07-23 05:54:34 +00:00
else if ( PyFloat_Check ( obj ) )
self - > s - > Resample ( ( float ) PyFloat_AsDouble ( obj ) ) ;
2009-03-29 21:50:10 +00:00
else {
PyErr_SetString ( PyExc_TypeError , " invalid argument " ) ;
return NULL ;
}
2008-07-23 05:54:34 +00:00
Py_RETURN_NONE ;
2008-07-09 08:24:13 +00:00
}
2008-07-25 00:18:10 +00:00
PyObject * Stroke_InsertVertex ( BPy_Stroke * self , PyObject * args ) {
PyObject * py_sv = 0 , * py_sv_it = 0 ;
2009-03-29 21:50:10 +00:00
if ( ! ( PyArg_ParseTuple ( args , " O!O! " , & StrokeVertex_Type , & py_sv , & StrokeVertexIterator_Type , & py_sv_it ) ) )
return NULL ;
2008-07-25 00:18:10 +00:00
StrokeVertex * sv = ( ( BPy_StrokeVertex * ) py_sv ) - > sv ;
StrokeInternal : : StrokeVertexIterator sv_it ( * ( ( ( BPy_StrokeVertexIterator * ) py_sv_it ) - > sv_it ) ) ;
self - > s - > InsertVertex ( sv , sv_it ) ;
Py_RETURN_NONE ;
}
2008-07-09 08:24:13 +00:00
2008-07-23 05:54:34 +00:00
PyObject * Stroke_RemoveVertex ( BPy_Stroke * self , PyObject * args ) {
PyObject * py_sv ;
2008-07-09 08:24:13 +00:00
2009-03-29 21:50:10 +00:00
if ( ! ( PyArg_ParseTuple ( args , " O! " , & StrokeVertex_Type , & py_sv ) ) )
return NULL ;
2008-07-09 08:24:13 +00:00
2009-03-29 21:50:10 +00:00
if ( ( ( BPy_StrokeVertex * ) py_sv ) - > sv )
2008-07-23 05:54:34 +00:00
self - > s - > RemoveVertex ( ( ( BPy_StrokeVertex * ) py_sv ) - > sv ) ;
2009-03-29 21:50:10 +00:00
else {
PyErr_SetString ( PyExc_TypeError , " invalid argument " ) ;
return NULL ;
}
2008-07-23 05:54:34 +00:00
Py_RETURN_NONE ;
2008-07-09 08:24:13 +00:00
}
2008-07-23 05:54:34 +00:00
PyObject * Stroke_getMediumType ( BPy_Stroke * self ) {
return BPy_MediumType_from_MediumType ( self - > s - > getMediumType ( ) ) ;
2008-07-09 08:24:13 +00:00
}
2008-07-23 05:54:34 +00:00
PyObject * Stroke_getTextureId ( BPy_Stroke * self ) {
2009-09-27 00:32:20 +00:00
return PyLong_FromLong ( self - > s - > getTextureId ( ) ) ;
2008-07-09 08:24:13 +00:00
}
2008-07-23 05:54:34 +00:00
PyObject * Stroke_hasTips ( BPy_Stroke * self ) {
return PyBool_from_bool ( self - > s - > hasTips ( ) ) ;
2008-07-09 08:24:13 +00:00
}
2008-07-23 05:54:34 +00:00
PyObject * Stroke_setId ( BPy_Stroke * self , PyObject * args ) {
PyObject * py_id ;
2008-07-09 08:24:13 +00:00
2009-03-29 21:50:10 +00:00
if ( ! ( PyArg_ParseTuple ( args , " O! " , & Id_Type , & py_id ) ) )
return NULL ;
2008-07-09 08:24:13 +00:00
2009-03-29 21:50:10 +00:00
self - > s - > setId ( * ( ( ( BPy_Id * ) py_id ) - > id ) ) ;
2008-07-09 08:24:13 +00:00
2008-07-23 05:54:34 +00:00
Py_RETURN_NONE ;
2008-07-09 08:24:13 +00:00
}
2008-07-23 05:54:34 +00:00
PyObject * Stroke_setLength ( BPy_Stroke * self , PyObject * args ) {
float f ;
2008-07-09 08:24:13 +00:00
2009-03-29 21:50:10 +00:00
if ( ! ( PyArg_ParseTuple ( args , " f " , & f ) ) )
return NULL ;
2008-07-09 08:24:13 +00:00
2008-07-23 05:54:34 +00:00
self - > s - > setLength ( f ) ;
2008-07-09 08:24:13 +00:00
2008-07-23 05:54:34 +00:00
Py_RETURN_NONE ;
2008-07-09 08:24:13 +00:00
}
2008-07-23 05:54:34 +00:00
PyObject * Stroke_setMediumType ( BPy_Stroke * self , PyObject * args ) {
PyObject * py_mt ;
2008-07-09 08:24:13 +00:00
2009-03-29 21:50:10 +00:00
if ( ! ( PyArg_ParseTuple ( args , " O! " , & MediumType_Type , & py_mt ) ) )
return NULL ;
2008-07-09 08:24:13 +00:00
2009-09-27 00:32:20 +00:00
self - > s - > setMediumType ( MediumType_from_BPy_MediumType ( py_mt ) ) ;
2008-07-09 08:24:13 +00:00
2008-07-23 05:54:34 +00:00
Py_RETURN_NONE ;
2008-07-09 08:24:13 +00:00
}
2008-07-23 05:54:34 +00:00
PyObject * Stroke_setTextureId ( BPy_Stroke * self , PyObject * args ) {
unsigned int i ;
2008-07-09 08:24:13 +00:00
2009-03-29 21:50:10 +00:00
if ( ! ( PyArg_ParseTuple ( args , " I " , & i ) ) )
return NULL ;
2008-07-09 08:24:13 +00:00
2008-07-23 05:54:34 +00:00
self - > s - > setTextureId ( i ) ;
2008-07-09 08:24:13 +00:00
2008-07-23 05:54:34 +00:00
Py_RETURN_NONE ;
2008-07-09 08:24:13 +00:00
}
2008-07-23 05:54:34 +00:00
PyObject * Stroke_setTips ( BPy_Stroke * self , PyObject * args ) {
PyObject * py_b ;
2008-07-09 08:24:13 +00:00
2009-04-03 20:03:09 +00:00
if ( ! ( PyArg_ParseTuple ( args , " O " , & py_b ) ) )
2009-03-29 21:50:10 +00:00
return NULL ;
2008-07-09 08:24:13 +00:00
2008-07-24 04:48:34 +00:00
self - > s - > setTips ( bool_from_PyBool ( py_b ) ) ;
2008-07-09 08:24:13 +00:00
2008-07-23 05:54:34 +00:00
Py_RETURN_NONE ;
2008-07-09 08:24:13 +00:00
}
2008-07-25 00:18:10 +00:00
PyObject * Stroke_strokeVerticesBegin ( BPy_Stroke * self , PyObject * args ) {
2008-12-01 11:14:33 +00:00
float f = 0 ;
2009-03-29 21:50:10 +00:00
if ( ! ( PyArg_ParseTuple ( args , " |f " , & f ) ) )
return NULL ;
2008-12-01 11:14:33 +00:00
StrokeInternal : : StrokeVertexIterator sv_it ( self - > s - > strokeVerticesBegin ( f ) ) ;
return BPy_StrokeVertexIterator_from_StrokeVertexIterator ( sv_it , 0 ) ;
2008-07-25 00:18:10 +00:00
}
2008-07-09 08:24:13 +00:00
2008-07-25 00:18:10 +00:00
PyObject * Stroke_strokeVerticesEnd ( BPy_Stroke * self ) {
StrokeInternal : : StrokeVertexIterator sv_it ( self - > s - > strokeVerticesEnd ( ) ) ;
2008-12-01 11:14:33 +00:00
return BPy_StrokeVertexIterator_from_StrokeVertexIterator ( sv_it , 1 ) ;
2008-07-25 00:18:10 +00:00
}
PyObject * Stroke_strokeVerticesSize ( BPy_Stroke * self ) {
2009-09-27 00:32:20 +00:00
return PyLong_FromLong ( self - > s - > strokeVerticesSize ( ) ) ;
2008-07-09 08:24:13 +00:00
}
2008-07-25 00:18:10 +00:00
2008-07-23 05:54:34 +00:00
///////////////////////////////////////////////////////////////////////////////////////////
2008-07-09 08:24:13 +00:00
2008-07-23 05:54:34 +00:00
# ifdef __cplusplus
2008-07-09 08:24:13 +00:00
}
2008-07-23 05:54:34 +00:00
# endif