soc-2008-mxcurioni: Reimplemented the Freestyle Python API's files to be correctly used as classes and not submodules. Added and integrated object lifecycle functions (__new__, __alloc__, __repr__) for the previous classes: BinaryPredicate0D, BinaryPredicate1D, Id, Interface0D, Interface1D. All of these classes were tested within Blender's Python interpreter with simple test cases and their getter/setters were corrected.

Interface0DIterator was modified to allow BPy_Interface1D to be instantiated: verticesBegin(), verticesEnd(), pointsBegin(float) and pointsEnd(float) are not pure virtual functions anymore. If they are called directly from  BPy_Interface1D (instead of its subclasses), an error message is displayed.
This commit is contained in:
Maxime Curioni
2008-07-15 01:07:19 +00:00
parent 8398730043
commit 96e52b09da
14 changed files with 454 additions and 234 deletions

View File

@@ -9,18 +9,22 @@ extern "C" {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
/*--------------- Python API function prototypes for BinaryPredicate0D instance -----------*/
static PyObject * BinaryPredicate0D___new__(PyTypeObject *type, PyObject *args, PyObject *kwds);
static void BinaryPredicate0D___dealloc__(BPy_BinaryPredicate0D *self);
static PyObject * BinaryPredicate0D___repr__(BPy_BinaryPredicate0D *self);
/*-----------------------Python API function prototypes for the BinaryPredicate0D module--*/ static PyObject * BinaryPredicate0D_getName( BPy_BinaryPredicate0D *self, PyObject *args);
//static PyObject *Freestyle_testOutput( BPy_Freestyle * self ); static PyObject * BinaryPredicate0D___call__( BPy_BinaryPredicate0D *self, PyObject *args);
/*-----------------------BinaryPredicate0D module doc strings-----------------------------*/
static char M_BinaryPredicate0D_doc[] = "The Blender.Freestyle.BinaryPredicate0D submodule"; /*----------------------BinaryPredicate0D instance definitions ----------------------------*/
/*----------------------BinaryPredicate0D module method def----------------------------*/ static PyMethodDef BPy_BinaryPredicate0D_methods[] = {
struct PyMethodDef M_BinaryPredicate0D_methods[] = { {"getName", ( PyCFunction ) BinaryPredicate0D_getName, METH_NOARGS, " Returns the string of the name of the binary predicate."},
// {"testOutput", ( PyCFunction ) Freestyle_testOutput, METH_NOARGS, "() - Return Curve Data name"}, {"__call__", ( PyCFunction ) BinaryPredicate0D___call__, METH_VARARGS, "BinaryPredicate0DInterface0D, Interface0D . Must be overloaded by inherited classes. It evaluates a relation between two Interface0D." },
{NULL, NULL, 0, NULL} {NULL, NULL, 0, NULL}
}; };
/*-----------------------BPy_Freestyle method def------------------------------*/ /*-----------------------BPy_BinaryPredicate0D type definition ------------------------------*/
PyTypeObject BinaryPredicate0D_Type = { PyTypeObject BinaryPredicate0D_Type = {
PyObject_HEAD_INIT( NULL ) PyObject_HEAD_INIT( NULL )
@@ -30,12 +34,12 @@ PyTypeObject BinaryPredicate0D_Type = {
0, /* tp_itemsize */ 0, /* tp_itemsize */
/* methods */ /* methods */
NULL, /* tp_dealloc */ (destructor)BinaryPredicate0D___dealloc__, /* tp_dealloc */
NULL, /* printfunc tp_print; */ NULL, /* printfunc tp_print; */
NULL, /* getattrfunc tp_getattr; */ NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */ NULL, /* setattrfunc tp_setattr; */
NULL, /* tp_compare */ NULL, /* tp_compare */
NULL, /* tp_repr */ (reprfunc)BinaryPredicate0D___repr__, /* tp_repr */
/* Method suites for standard classes */ /* Method suites for standard classes */
@@ -78,17 +82,17 @@ PyTypeObject BinaryPredicate0D_Type = {
NULL, /* iternextfunc tp_iternext; */ NULL, /* iternextfunc tp_iternext; */
/*** Attribute descriptor and subclassing stuff ***/ /*** Attribute descriptor and subclassing stuff ***/
NULL, /* struct PyMethodDef *tp_methods; */ BPy_BinaryPredicate0D_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */ NULL, /* struct PyMemberDef *tp_members; */
NULL, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct PyGetSetDef *tp_getset; */
NULL, /* struct _typeobject *tp_base; */ NULL, /* struct _typeobject *tp_base; */
NULL, /* PyObject *tp_dict; */ NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */ NULL, /* descrgetfunc tp_descr_get; */
NULL, /* descrsetfunc tp_descr_set; */ NULL, /* descrsetfunc tp_descr_set; */
0, /* long tp_dictoffset; */ 0, /* long tp_dictoffset; */
NULL, /* initproc tp_init; */ NULL, /* initproc tp_init; */
NULL, /* allocfunc tp_alloc; */ NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */ (newfunc)BinaryPredicate0D___new__, /* newfunc tp_new; */
/* Low-level free-memory routine */ /* Low-level free-memory routine */
NULL, /* freefunc tp_free; */ NULL, /* freefunc tp_free; */
@@ -106,35 +110,60 @@ PyTypeObject BinaryPredicate0D_Type = {
}; };
//-------------------MODULE INITIALIZATION-------------------------------- //-------------------MODULE INITIALIZATION--------------------------------
PyObject *BinaryPredicate0D_Init( void ) PyMODINIT_FUNC BinaryPredicate0D_Init( PyObject *module )
{ {
PyObject *submodule; if( module == NULL )
return;
if( PyType_Ready( &BinaryPredicate0D_Type ) < 0 ) if( PyType_Ready( &BinaryPredicate0D_Type ) < 0 )
return NULL; return;
submodule = Py_InitModule3( "Blender.Freestyle.BinaryPredicate0D", M_BinaryPredicate0D_methods, M_BinaryPredicate0D_doc ); Py_INCREF( &BinaryPredicate0D_Type );
PyModule_AddObject(module, "BinaryPredicate0D", (PyObject *)&BinaryPredicate0D_Type);
return submodule;
} }
//------------------------INSTANCE METHODS ---------------------------------- //------------------------INSTANCE METHODS ----------------------------------
PyObject *BinaryPredicate0D_getName( BPy_BinaryPredicate0D *self, PyObject *args) PyObject * BinaryPredicate0D___new__(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
BPy_BinaryPredicate0D *self;
self = (BPy_BinaryPredicate0D *)type->tp_alloc(type, 0);
if (self != NULL) {
self->bp0D = new BinaryPredicate0D();
}
return (PyObject *)self;
}
void BinaryPredicate0D___dealloc__(BPy_BinaryPredicate0D* self)
{
delete self->bp0D;
self->ob_type->tp_free((PyObject*)self);
}
PyObject * BinaryPredicate0D___repr__(BPy_BinaryPredicate0D* self)
{
return PyString_FromFormat("type: %s - address: %p", self->bp0D->getName().c_str(), self->bp0D );
}
PyObject * BinaryPredicate0D_getName( BPy_BinaryPredicate0D *self, PyObject *args)
{ {
return PyString_FromString( self->bp0D->getName().c_str() ); return PyString_FromString( self->bp0D->getName().c_str() );
} }
PyObject *BinaryPredicate0D___call__( BPy_BinaryPredicate0D *self, PyObject *args) PyObject * BinaryPredicate0D___call__( BPy_BinaryPredicate0D *self, PyObject *args)
{ {
BPy_BinaryPredicate0D *obj1; BPy_Interface0D *obj1, *obj2;
BPy_Interface0D *obj2, *obj3;
bool b; bool b;
if (!PyArg_ParseTuple(args,(char *)"OOO:BinaryPredicate0D___call__", &obj1, obj2, &obj3)) if( !PyArg_ParseTuple(args,(char *)"OO:BinaryPredicate0D___call__", &obj1, obj2) ) {
cout << "ERROR: BinaryPredicate0D___call__ " << endl; cout << "ERROR: BinaryPredicate0D___call__ " << endl;
return NULL;
}
b = self->bp0D->operator()( *(obj2->if0D) , *(obj3->if0D) ); b = self->bp0D->operator()( *(obj1->if0D) , *(obj2->if0D) );
return PyBool_from_bool( b ); return PyBool_from_bool( b );
} }

View File

@@ -24,7 +24,7 @@ typedef struct {
/*---------------------------Python BPy_BinaryPredicate0D visible prototypes-----------*/ /*---------------------------Python BPy_BinaryPredicate0D visible prototypes-----------*/
PyObject *BinaryPredicate0D_Init( void ); PyMODINIT_FUNC BinaryPredicate0D_Init( PyObject *module );
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -9,33 +9,36 @@ extern "C" {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
/*--------------- Python API function prototypes for BinaryPredicate1D instance -----------*/
static PyObject * BinaryPredicate1D___new__(PyTypeObject *type, PyObject *args, PyObject *kwds);
static void BinaryPredicate1D___dealloc__(BPy_BinaryPredicate1D *self);
static PyObject * BinaryPredicate1D___repr__(BPy_BinaryPredicate1D *self);
/*-----------------------Python API function prototypes for the BinaryPredicate1D module--*/ static PyObject * BinaryPredicate1D_getName( BPy_BinaryPredicate1D *self, PyObject *args);
//static PyObject *Freestyle_testOutput( BPy_Freestyle * self ); static PyObject * BinaryPredicate1D___call__( BPy_BinaryPredicate1D *self, PyObject *args);
/*-----------------------BinaryPredicate1D module doc strings-----------------------------*/
static char M_BinaryPredicate1D_doc[] = "The Blender.Freestyle.BinaryPredicate1D submodule"; /*----------------------BinaryPredicate1D instance definitions ----------------------------*/
/*----------------------BinaryPredicate1D module method def----------------------------*/ static PyMethodDef BPy_BinaryPredicate1D_methods[] = {
struct PyMethodDef M_BinaryPredicate1D_methods[] = { {"getName", ( PyCFunction ) BinaryPredicate1D_getName, METH_NOARGS, " Returns the string of the name of the binary predicate."},
// {"testOutput", ( PyCFunction ) Freestyle_testOutput, METH_NOARGS, "() - Return Curve Data name"}, {"__call__", ( PyCFunction ) BinaryPredicate1D___call__, METH_VARARGS, "BinaryPredicate1DInterface1D, Interface1D . Must be overloaded by inherited classes. It evaluates a relation between two Interface1D." },
{NULL, NULL, 0, NULL} {NULL, NULL, 0, NULL}
}; };
/*-----------------------BPy_Freestyle method def------------------------------*/ /*-----------------------BPy_BinaryPredicate1D type definition ------------------------------*/
PyTypeObject BinaryPredicate1D_Type = { PyTypeObject BinaryPredicate1D_Type = {
PyObject_HEAD_INIT( NULL ) PyObject_HEAD_INIT( NULL )
0, /* ob_size */ 0, /* ob_size */
"BinaryPredicate1D", /* tp_name */ "BinaryPredicate1D", /* tp_name */
sizeof( BPy_BinaryPredicate1D ), /* tp_basicsize */ sizeof( BPy_BinaryPredicate1D ), /* tp_basicsize */
0, /* tp_itemsize */ 0, /* tp_itemsize */
/* methods */ /* methods */
NULL, /* tp_dealloc */ (destructor)BinaryPredicate1D___dealloc__, /* tp_dealloc */
NULL, /* printfunc tp_print; */ NULL, /* printfunc tp_print; */
NULL, /* getattrfunc tp_getattr; */ NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */ NULL, /* setattrfunc tp_setattr; */
NULL, /* tp_compare */ NULL, /* tp_compare */
NULL, /* tp_repr */ (reprfunc)BinaryPredicate1D___repr__, /* tp_repr */
/* Method suites for standard classes */ /* Method suites for standard classes */
@@ -78,17 +81,17 @@ PyTypeObject BinaryPredicate1D_Type = {
NULL, /* iternextfunc tp_iternext; */ NULL, /* iternextfunc tp_iternext; */
/*** Attribute descriptor and subclassing stuff ***/ /*** Attribute descriptor and subclassing stuff ***/
NULL, /* struct PyMethodDef *tp_methods; */ BPy_BinaryPredicate1D_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */ NULL, /* struct PyMemberDef *tp_members; */
NULL, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct PyGetSetDef *tp_getset; */
NULL, /* struct _typeobject *tp_base; */ NULL, /* struct _typeobject *tp_base; */
NULL, /* PyObject *tp_dict; */ NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */ NULL, /* descrgetfunc tp_descr_get; */
NULL, /* descrsetfunc tp_descr_set; */ NULL, /* descrsetfunc tp_descr_set; */
0, /* long tp_dictoffset; */ 0, /* long tp_dictoffset; */
NULL, /* initproc tp_init; */ NULL, /* initproc tp_init; */
NULL, /* allocfunc tp_alloc; */ NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */ BinaryPredicate1D___new__, /* newfunc tp_new; */
/* Low-level free-memory routine */ /* Low-level free-memory routine */
NULL, /* freefunc tp_free; */ NULL, /* freefunc tp_free; */
@@ -106,20 +109,44 @@ PyTypeObject BinaryPredicate1D_Type = {
}; };
//-------------------MODULE INITIALIZATION-------------------------------- //-------------------MODULE INITIALIZATION--------------------------------
PyObject *BinaryPredicate1D_Init( void ) PyMODINIT_FUNC BinaryPredicate1D_Init( PyObject *module )
{ {
PyObject *submodule; if( module == NULL )
return;
if( PyType_Ready( &BinaryPredicate1D_Type ) < 0 ) if( PyType_Ready( &BinaryPredicate1D_Type ) < 0 )
return NULL; return;
submodule = Py_InitModule3( "Blender.Freestyle.BinaryPredicate1D", M_BinaryPredicate1D_methods, M_BinaryPredicate1D_doc ); Py_INCREF( &BinaryPredicate1D_Type );
PyModule_AddObject(module, "BinaryPredicate1D", (PyObject *)&BinaryPredicate1D_Type);
return submodule;
} }
//------------------------INSTANCE METHODS ---------------------------------- //------------------------INSTANCE METHODS ----------------------------------
PyObject * BinaryPredicate1D___new__(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
BPy_BinaryPredicate1D *self;
self = (BPy_BinaryPredicate1D *)type->tp_alloc(type, 0);
if (self != NULL) {
self->bp1D = new BinaryPredicate1D();
}
return (PyObject *)self;
}
void BinaryPredicate1D___dealloc__(BPy_BinaryPredicate1D* self)
{
delete self->bp1D;
self->ob_type->tp_free((PyObject*)self);
}
PyObject * BinaryPredicate1D___repr__(BPy_BinaryPredicate1D* self)
{
return PyString_FromFormat("type: %s - address: %p", self->bp1D->getName().c_str(), self->bp1D );
}
PyObject *BinaryPredicate1D_getName( BPy_BinaryPredicate1D *self, PyObject *args) PyObject *BinaryPredicate1D_getName( BPy_BinaryPredicate1D *self, PyObject *args)
{ {
return PyString_FromString( self->bp1D->getName().c_str() ); return PyString_FromString( self->bp1D->getName().c_str() );
@@ -127,14 +154,15 @@ PyObject *BinaryPredicate1D_getName( BPy_BinaryPredicate1D *self, PyObject *args
PyObject *BinaryPredicate1D___call__( BPy_BinaryPredicate1D *self, PyObject *args) PyObject *BinaryPredicate1D___call__( BPy_BinaryPredicate1D *self, PyObject *args)
{ {
BPy_BinaryPredicate1D *obj1; BPy_Interface1D *obj1, *obj2;
BPy_Interface1D *obj2, *obj3;
bool b; bool b;
if (!PyArg_ParseTuple(args,(char *)"OOO:BinaryPredicate1D___call__", &obj1, &obj2, &obj3)) if( !PyArg_ParseTuple(args,(char *)"OO:BinaryPredicate1D___call__", &obj1, &obj2) ) {
cout << "ERROR: BinaryPredicate1D___call__ " << endl; cout << "ERROR: BinaryPredicate1D___call__ " << endl;
return NULL;
}
b = self->bp1D->operator()( *(obj2->if1D) , *(obj3->if1D) ); b = self->bp1D->operator()( *(obj1->if1D) , *(obj2->if1D) );
return PyBool_from_bool( b ); return PyBool_from_bool( b );
} }

View File

@@ -24,8 +24,7 @@ typedef struct {
/*---------------------------Python BPy_BinaryPredicate1D visible prototypes-----------*/ /*---------------------------Python BPy_BinaryPredicate1D visible prototypes-----------*/
PyObject *BinaryPredicate1D_Init( void ); PyMODINIT_FUNC BinaryPredicate1D_Init( PyObject *module );
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -32,7 +32,7 @@ PyObject *PyBool_from_bool( bool b ){
PyObject *Vector_from_Vec2f( Vec2f vec ) { PyObject *Vector_from_Vec2f( Vec2f vec ) {
float vec_data[2]; // because vec->_coord is protected float vec_data[2]; // because vec->_coord is protected
vec_data[0] = vec.x(); vec_data[1] = vec.y(); vec_data[0] = vec.x(); vec_data[1] = vec.y();
return newVectorObject( vec_data, 3, Py_NEW); return newVectorObject( vec_data, 2, Py_NEW);
} }
PyObject *Vector_from_Vec3f( Vec3f vec ) { PyObject *Vector_from_Vec3f( Vec3f vec ) {
@@ -47,6 +47,16 @@ PyObject *Vector_from_Vec3r( Vec3r vec ) {
return newVectorObject( vec_data, 3, Py_NEW); return newVectorObject( vec_data, 3, Py_NEW);
} }
PyObject *BPy_Id_from_Id( Id id ) {
BPy_Id *py_id;
py_id = (BPy_Id *) Id_Type.tp_new( &Id_Type, 0, 0 );
py_id->id->setFirst( id.getFirst() );
py_id->id->setSecond( id.getSecond() );
return (PyObject *)py_id;
}
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -4,6 +4,8 @@
#include "../geometry/Geom.h" #include "../geometry/Geom.h"
using namespace Geometry; using namespace Geometry;
#include "Id.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@@ -22,6 +24,8 @@ PyObject *Vector_from_Vec2f( Vec2f v );
PyObject *Vector_from_Vec3f( Vec3f v ); PyObject *Vector_from_Vec3f( Vec3f v );
PyObject *Vector_from_Vec3r( Vec3r v ); PyObject *Vector_from_Vec3r( Vec3r v );
PyObject *BPy_Id_from_Id( Id id );
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -111,22 +111,22 @@ PyTypeObject Freestyle_Type = {
//-------------------MODULE INITIALIZATION-------------------------------- //-------------------MODULE INITIALIZATION--------------------------------
PyObject *Freestyle_Init( void ) PyObject *Freestyle_Init( void )
{ {
PyObject *submodule; PyObject *module;
PyObject *dict;
if( PyType_Ready( &Freestyle_Type ) < 0 ) if( PyType_Ready( &Freestyle_Type ) < 0 )
return NULL; return NULL;
submodule = Py_InitModule3( "Blender.Freestyle", M_Freestyle_methods, M_Freestyle_doc ); // initialize modules
module = Py_InitModule3( "Blender.Freestyle", M_Freestyle_methods, M_Freestyle_doc );
dict = PyModule_GetDict( submodule );
PyDict_SetItemString( dict, "BinaryPredicate0D", BinaryPredicate0D_Init() );
PyDict_SetItemString( dict, "BinaryPredicate1D", BinaryPredicate1D_Init() );
PyDict_SetItemString( dict, "Interface0D", Interface0D_Init() );
PyDict_SetItemString( dict, "Interface1D", Interface1D_Init() );
PyDict_SetItemString( dict, "Id", Id_Init() );
return submodule; // attach its classes (adding the object types to the module)
BinaryPredicate0D_Init( module );
BinaryPredicate1D_Init( module );
Id_Init( module );
Interface0D_Init( module );
Interface1D_Init( module );
return module;
} }
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -8,33 +8,48 @@ extern "C" {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
/*--------------- Python API function prototypes for Id instance -----------*/
static PyObject * Id___new__(PyTypeObject *type, PyObject *args, PyObject *kwds);
static void Id___dealloc__(BPy_Id *self);
static int Id___init__(BPy_Id *self, PyObject *args, PyObject *kwds);
static PyObject * Id___repr__(BPy_Id* self);
/*-----------------------Python API function prototypes for the Id module--*/ static PyObject * Id_getFirst( BPy_Id *self );
//static PyObject *Freestyle_testOutput( BPy_Freestyle * self ); static PyObject * Id_getSecond( BPy_Id *self);
/*-----------------------Id module doc strings-----------------------------*/ static PyObject * Id_setFirst( BPy_Id *self , PyObject *args);
static char M_Id_doc[] = "The Blender.Freestyle.Id submodule"; static PyObject * Id_setSecond( BPy_Id *self , PyObject *args);
/*----------------------Id module method def----------------------------*/ static PyObject * Id___eq__( BPy_Id *self , PyObject *args);
struct PyMethodDef M_Id_methods[] = { static PyObject * Id___ne__( BPy_Id *self , PyObject *args);
// {"testOutput", ( PyCFunction ) Freestyle_testOutput, METH_NOARGS, "() - Return Curve Data name"}, static PyObject * Id___lt__( BPy_Id *self , PyObject *args);
/*----------------------Id instance definitions ----------------------------*/
static PyMethodDef BPy_Id_methods[] = {
{"getFirst", ( PyCFunction ) Id_getFirst, METH_NOARGS, "Returns the first Id number"},
{"getSecond", ( PyCFunction ) Id_getSecond, METH_NOARGS, "Returns the second Id number" },
{"setFirst", ( PyCFunction ) Id_setFirst, METH_VARARGS, "Sets the first number constituing the Id" },
{"setSecond", ( PyCFunction ) Id_setSecond, METH_VARARGS, "Sets the second number constituing the Id" },
{"__eq__", ( PyCFunction ) Id___eq__, METH_VARARGS, "Operator ==" },
{"__ne__", ( PyCFunction ) Id___ne__, METH_VARARGS, "Operator !=" },
{"__lt__", ( PyCFunction ) Id___lt__, METH_VARARGS, "Operator <" },
{NULL, NULL, 0, NULL} {NULL, NULL, 0, NULL}
}; };
/*-----------------------BPy_Freestyle method def------------------------------*/ /*-----------------------BPy_Id type definition ------------------------------*/
PyTypeObject Id_Type = { PyTypeObject Id_Type = {
PyObject_HEAD_INIT( NULL ) PyObject_HEAD_INIT( NULL )
0, /* ob_size */ 0, /* ob_size */
"Id", /* tp_name */ "Id", /* tp_name */
sizeof( BPy_Id ), /* tp_basicsize */ sizeof( BPy_Id ), /* tp_basicsize */
0, /* tp_itemsize */ 0, /* tp_itemsize */
/* methods */ /* methods */
NULL, /* tp_dealloc */ (destructor)Id___dealloc__, /* tp_dealloc */
NULL, /* printfunc tp_print; */ NULL, /* printfunc tp_print; */
NULL, /* getattrfunc tp_getattr; */ NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */ NULL, /* setattrfunc tp_setattr; */
NULL, /* tp_compare */ NULL, /* tp_compare */
NULL, /* tp_repr */ (reprfunc)Id___repr__, /* tp_repr */
/* Method suites for standard classes */ /* Method suites for standard classes */
@@ -77,17 +92,17 @@ PyTypeObject Id_Type = {
NULL, /* iternextfunc tp_iternext; */ NULL, /* iternextfunc tp_iternext; */
/*** Attribute descriptor and subclassing stuff ***/ /*** Attribute descriptor and subclassing stuff ***/
NULL, /* struct PyMethodDef *tp_methods; */ BPy_Id_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */ NULL, /* struct PyMemberDef *tp_members; */
NULL, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct PyGetSetDef *tp_getset; */
NULL, /* struct _typeobject *tp_base; */ NULL, /* struct _typeobject *tp_base; */
NULL, /* PyObject *tp_dict; */ NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */ NULL, /* descrgetfunc tp_descr_get; */
NULL, /* descrsetfunc tp_descr_set; */ NULL, /* descrsetfunc tp_descr_set; */
0, /* long tp_dictoffset; */ 0, /* long tp_dictoffset; */
NULL, /* initproc tp_init; */ (initproc)Id___init__, /* initproc tp_init; */
NULL, /* allocfunc tp_alloc; */ NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */ Id___new__, /* newfunc tp_new; */
/* Low-level free-memory routine */ /* Low-level free-memory routine */
NULL, /* freefunc tp_free; */ NULL, /* freefunc tp_free; */
@@ -105,20 +120,57 @@ PyTypeObject Id_Type = {
}; };
//-------------------MODULE INITIALIZATION-------------------------------- //-------------------MODULE INITIALIZATION--------------------------------
PyObject *Id_Init( void ) PyMODINIT_FUNC Id_Init( PyObject *module )
{ {
PyObject *submodule; if( module == NULL )
return;
if( PyType_Ready( &Id_Type ) < 0 ) if( PyType_Ready( &Id_Type ) < 0 )
return NULL; return;
submodule = Py_InitModule3( "Blender.Freestyle.Id", M_Id_methods, M_Id_doc ); Py_INCREF( &Id_Type );
PyModule_AddObject(module, "Id", (PyObject *)&Id_Type);
return submodule;
} }
//------------------------INSTANCE METHODS ---------------------------------- //------------------------INSTANCE METHODS ----------------------------------
PyObject * Id___new__(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
BPy_Id *self;
self = (BPy_Id *)type->tp_alloc(type, 0);
if (self != NULL) {
self->id = new Id();
}
return (PyObject *)self;
}
void Id___dealloc__(BPy_Id* self)
{
delete self->id;
self->ob_type->tp_free((PyObject*)self);
}
int Id___init__(BPy_Id *self, PyObject *args, PyObject *kwds)
{
int first = 0, second = 0;
static char *kwlist[] = {"first", "second", NULL};
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|ii", kwlist, &first, &second) )
return -1;
self->id->setFirst( first );
self->id->setSecond( second );
return 0;
}
PyObject * Id___repr__(BPy_Id* self)
{
return PyString_FromFormat("[ first: %i, second: %i ](BPy_Id)", self->id->getFirst(), self->id->getSecond() );
}
PyObject *Id_getFirst( BPy_Id *self ) { PyObject *Id_getFirst( BPy_Id *self ) {
return PyInt_FromLong( self->id->getFirst() ); return PyInt_FromLong( self->id->getFirst() );
} }
@@ -130,14 +182,13 @@ PyObject *Id_getSecond( BPy_Id *self) {
PyObject *Id_setFirst( BPy_Id *self , PyObject *args) { PyObject *Id_setFirst( BPy_Id *self , PyObject *args) {
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
unsigned int i; unsigned int i;
if( !PyArg_ParseTuple(args, (char *)"OO:Id_setFirst", &obj1, &obj2) ) if( !PyArg_ParseTuple(args, (char *)"i:Id_setFirst", i) ) {
cout << "ERROR: Id_setFirst" << endl; cout << "ERROR: Id_setFirst" << endl;
Py_RETURN_NONE;
}
i = static_cast<unsigned int>( PyInt_AsLong(obj2) );
self->id->setFirst( i ); self->id->setFirst( i );
Py_RETURN_NONE; Py_RETURN_NONE;
@@ -145,48 +196,50 @@ PyObject *Id_setFirst( BPy_Id *self , PyObject *args) {
PyObject *Id_setSecond( BPy_Id *self , PyObject *args) { PyObject *Id_setSecond( BPy_Id *self , PyObject *args) {
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
unsigned int i; unsigned int i;
if( !PyArg_ParseTuple(args, (char *)"OO:Id_setSecond", &obj1, &obj2) ) if( !PyArg_ParseTuple(args, (char *)"i:Id_setSecond", i) ) {
cout << "ERROR: Id_setSecond" << endl; cout << "ERROR: Id_setSecond" << endl;
Py_RETURN_NONE;
}
i = static_cast<unsigned int>( PyInt_AsLong(obj2) );
self->id->setSecond( i ); self->id->setSecond( i );
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyObject *Id___eq__( BPy_Id *self , PyObject *args) { PyObject *Id___eq__( BPy_Id *self , PyObject *args) {
BPy_Id * obj1 = 0 ; BPy_Id * other = 0 ;
BPy_Id * obj2 = 0 ;
if( !PyArg_ParseTuple(args, (char *)"OO:Id___eq__", &obj1, &obj2) ) if( !PyArg_ParseTuple(args, (char *)"O:Id___eq__", &other) ) {
cout << "ERROR: Id___eq__" << endl; cout << "ERROR: Id___eq__" << endl;
Py_RETURN_NONE;
}
return PyBool_from_bool( obj1->id == obj2->id ); return PyBool_from_bool( self->id == other->id );
} }
PyObject *Id___ne__(PyObject *self , PyObject *args) { PyObject *Id___ne__(BPy_Id *self , PyObject *args) {
BPy_Id * obj1 = 0 ; BPy_Id * other = 0 ;
BPy_Id * obj2 = 0 ;
if( !PyArg_ParseTuple(args, (char *)"OO:Id___ne__", &obj1, &obj2) ) if( !PyArg_ParseTuple(args, (char *)"O:Id___ne__", &other) ) {
cout << "ERROR: Id___ne__" << endl; cout << "ERROR: Id___ne__" << endl;
Py_RETURN_NONE;
return PyBool_from_bool( obj1->id != obj2->id ); }
return PyBool_from_bool( self->id != other->id );
} }
PyObject *Id___lt__(PyObject *self , PyObject *args) { PyObject *Id___lt__(BPy_Id *self , PyObject *args) {
BPy_Id * obj1 = 0 ; BPy_Id * other = 0 ;
BPy_Id * obj2 = 0 ;
if( !PyArg_ParseTuple(args, (char *)"OO:Id___lt__", &obj1, &obj2) ) if( !PyArg_ParseTuple(args, (char *)"O:Id___lt__", &other) ) {
cout << "ERROR: Id___lt__" << endl; cout << "ERROR: Id___lt__" << endl;
Py_RETURN_NONE;
return PyBool_from_bool( obj1->id < obj2->id ); }
return PyBool_from_bool( self->id <= other->id );
} }

View File

@@ -27,8 +27,7 @@ typedef struct {
/*---------------------------Python BPy_Id visible prototypes-----------*/ /*---------------------------Python BPy_Id visible prototypes-----------*/
PyObject *Id_Init( void ); PyMODINIT_FUNC Id_Init( PyObject *module );
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -8,18 +8,42 @@ extern "C" {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
/*--------------- Python API function prototypes for Interface0D instance -----------*/
static PyObject * Interface0D___new__(PyTypeObject *type, PyObject *args, PyObject *kwds);
static void Interface0D___dealloc__(BPy_Interface0D *self);
static PyObject * Interface0D___repr__(BPy_Interface0D *self);
/*-----------------------Python API function prototypes for the Interface0D module--*/ static PyObject *Interface0D_getExactTypeName( BPy_Interface0D *self );
//static PyObject *Freestyle_testOutput( BPy_Freestyle * self ); static PyObject *Interface0D_getX( BPy_Interface0D *self );
/*-----------------------Interface0D module doc strings-----------------------------*/ static PyObject *Interface0D_getY( BPy_Interface0D *self );
static char M_Interface0D_doc[] = "The Blender.Freestyle.Interface0D submodule"; static PyObject *Interface0D_getZ( BPy_Interface0D *self );
/*----------------------Interface0D module method def----------------------------*/ static PyObject *Interface0D_getPoint3D( BPy_Interface0D *self );
struct PyMethodDef M_Interface0D_methods[] = { static PyObject *Interface0D_getProjectedX( BPy_Interface0D *self );
// {"testOutput", ( PyCFunction ) Freestyle_testOutput, METH_NOARGS, "() - Return Curve Data name"}, static PyObject *Interface0D_getProjectedY( BPy_Interface0D *self );
static PyObject *Interface0D_getProjectedZ( BPy_Interface0D *self );
static PyObject *Interface0D_getPoint2D( BPy_Interface0D *self );
static PyObject *Interface0D_getFEdge( BPy_Interface0D *self );
static PyObject *Interface0D_getId( BPy_Interface0D *self );
static PyObject *Interface0D_getNature( BPy_Interface0D *self );
/*----------------------Interface0D instance definitions ----------------------------*/
static PyMethodDef BPy_Interface0D_methods[] = {
{"getExactTypeName", ( PyCFunction ) Interface0D_getExactTypeName, METH_NOARGS, " Returns the string of the name of the interface."},
{"getX", ( PyCFunction ) Interface0D_getX, METH_NOARGS, " Returns the 3D x coordinate of the point. "},
{"getY", ( PyCFunction ) Interface0D_getY, METH_NOARGS, " Returns the 3D y coordinate of the point. "},
{"getZ", ( PyCFunction ) Interface0D_getZ, METH_NOARGS, " Returns the 3D z coordinate of the point. "},
{"getPoint3D", ( PyCFunction ) Interface0D_getPoint3D, METH_NOARGS, "() Returns the 3D point."},
{"getProjectedX", ( PyCFunction ) Interface0D_getProjectedX, METH_NOARGS, "() Returns the 2D x coordinate of the point."},
{"getProjectedY", ( PyCFunction ) Interface0D_getProjectedY, METH_NOARGS, "() Returns the 2D y coordinate of the point."},
{"getProjectedZ", ( PyCFunction ) Interface0D_getProjectedZ, METH_NOARGS, "() Returns the 2D z coordinate of the point."},
{"getPoint2D", ( PyCFunction ) Interface0D_getPoint2D, METH_NOARGS, "() Returns the 2D point."},
{"getFEdge", ( PyCFunction ) Interface0D_getFEdge, METH_NOARGS, "() Returns the FEdge that lies between this Interface0D and the Interface0D given as argument."},
{"getId", ( PyCFunction ) Interface0D_getId, METH_NOARGS, "() Returns the Id of the point."},
{"getNature", ( PyCFunction ) Interface0D_getNature, METH_NOARGS, "() Returns the nature of the point."},
{NULL, NULL, 0, NULL} {NULL, NULL, 0, NULL}
}; };
/*-----------------------BPy_Freestyle method def------------------------------*/ /*-----------------------BPy_Interface0D type definition ------------------------------*/
PyTypeObject Interface0D_Type = { PyTypeObject Interface0D_Type = {
PyObject_HEAD_INIT( NULL ) PyObject_HEAD_INIT( NULL )
@@ -29,12 +53,12 @@ PyTypeObject Interface0D_Type = {
0, /* tp_itemsize */ 0, /* tp_itemsize */
/* methods */ /* methods */
NULL, /* tp_dealloc */ (destructor)Interface0D___dealloc__, /* tp_dealloc */
NULL, /* printfunc tp_print; */ NULL, /* printfunc tp_print; */
NULL, /* getattrfunc tp_getattr; */ NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */ NULL, /* setattrfunc tp_setattr; */
NULL, /* tp_compare */ NULL, /* tp_compare */
NULL, /* tp_repr */ (reprfunc)Interface0D___repr__, /* tp_repr */
/* Method suites for standard classes */ /* Method suites for standard classes */
@@ -77,17 +101,17 @@ PyTypeObject Interface0D_Type = {
NULL, /* iternextfunc tp_iternext; */ NULL, /* iternextfunc tp_iternext; */
/*** Attribute descriptor and subclassing stuff ***/ /*** Attribute descriptor and subclassing stuff ***/
NULL, /* struct PyMethodDef *tp_methods; */ BPy_Interface0D_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */ NULL, /* struct PyMemberDef *tp_members; */
NULL, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct PyGetSetDef *tp_getset; */
NULL, /* struct _typeobject *tp_base; */ NULL, /* struct _typeobject *tp_base; */
NULL, /* PyObject *tp_dict; */ NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */ NULL, /* descrgetfunc tp_descr_get; */
NULL, /* descrsetfunc tp_descr_set; */ NULL, /* descrsetfunc tp_descr_set; */
0, /* long tp_dictoffset; */ 0, /* long tp_dictoffset; */
NULL, /* initproc tp_init; */ NULL, /* initproc tp_init; */
NULL, /* allocfunc tp_alloc; */ NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */ (newfunc)Interface0D___new__, /* newfunc tp_new; */
/* Low-level free-memory routine */ /* Low-level free-memory routine */
NULL, /* freefunc tp_free; */ NULL, /* freefunc tp_free; */
@@ -105,20 +129,43 @@ PyTypeObject Interface0D_Type = {
}; };
//-------------------MODULE INITIALIZATION-------------------------------- //-------------------MODULE INITIALIZATION--------------------------------
PyObject *Interface0D_Init( void ) PyMODINIT_FUNC Interface0D_Init( PyObject *module )
{ {
PyObject *submodule; if( module == NULL )
return;
if( PyType_Ready( &Interface0D_Type ) < 0 ) if( PyType_Ready( &Interface0D_Type ) < 0 )
return NULL; return;
submodule = Py_InitModule3( "Blender.Freestyle.Interface0D", M_Interface0D_methods, M_Interface0D_doc ); Py_INCREF( &Interface0D_Type );
PyModule_AddObject(module, "Interface0D", (PyObject *)&Interface0D_Type);
return submodule;
} }
//------------------------INSTANCE METHODS ---------------------------------- //------------------------INSTANCE METHODS ----------------------------------
PyObject * Interface0D___new__(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
BPy_Interface0D *self;
self = (BPy_Interface0D *)type->tp_alloc(type, 0);
if (self != NULL) {
self->if0D = new Interface0D();
}
return (PyObject *)self;
}
void Interface0D___dealloc__(BPy_Interface0D* self)
{
delete self->if0D;
self->ob_type->tp_free((PyObject*)self);
}
PyObject * Interface0D___repr__(BPy_Interface0D* self)
{
return PyString_FromFormat("type: %s - address: %p", self->if0D->getExactTypeName().c_str(), self->if0D );
}
PyObject *Interface0D_getExactTypeName( BPy_Interface0D *self ) { PyObject *Interface0D_getExactTypeName( BPy_Interface0D *self ) {
return PyString_FromString( self->if0D->getExactTypeName().c_str() ); return PyString_FromString( self->if0D->getExactTypeName().c_str() );
} }
@@ -170,7 +217,7 @@ PyObject *Interface0D_getFEdge( BPy_Interface0D *self ) {
PyObject *Interface0D_getId( BPy_Interface0D *self ) { PyObject *Interface0D_getId( BPy_Interface0D *self ) {
// Id return BPy_Id_from_Id( self->if0D->getId() );
} }

View File

@@ -24,8 +24,7 @@ typedef struct {
/*---------------------------Python BPy_Interface0D visible prototypes-----------*/ /*---------------------------Python BPy_Interface0D visible prototypes-----------*/
PyObject *Interface0D_Init( void ); PyMODINIT_FUNC Interface0D_Init( PyObject *module );
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -8,18 +8,34 @@ extern "C" {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
/*--------------- Python API function prototypes for Interface1D instance -----------*/
static PyObject * Interface1D___new__(PyTypeObject *type, PyObject *args, PyObject *kwds);
static void Interface1D___dealloc__(BPy_Interface1D *self);
static PyObject * Interface1D___repr__(BPy_Interface1D *self);
/*-----------------------Python API function prototypes for the Interface1D module--*/ static PyObject *Interface1D_getExactTypeName( BPy_Interface1D *self );
//static PyObject *Freestyle_testOutput( BPy_Freestyle * self ); static PyObject *Interface1D_getVertices( BPy_Interface1D *self );
/*-----------------------Interface1D module doc strings-----------------------------*/ static PyObject *Interface1D_getPoints( BPy_Interface1D *self );
static char M_Interface1D_doc[] = "The Blender.Freestyle.Interface1D submodule"; static PyObject *Interface1D_getLength2D( BPy_Interface1D *self );
/*----------------------Interface1D module method def----------------------------*/ static PyObject *Interface1D_getId( BPy_Interface1D *self );
struct PyMethodDef M_Interface1D_methods[] = { static PyObject *Interface1D_getNature( BPy_Interface1D *self );
// {"testOutput", ( PyCFunction ) Freestyle_testOutput, METH_NOARGS, "() - Return Curve Data name"}, static PyObject *Interface1D_getTimeStamp( BPy_Interface1D *self );
static PyObject *Interface1D_setTimeStamp( BPy_Interface1D *self, PyObject *args);
/*----------------------Interface1D instance definitions ----------------------------*/
static PyMethodDef BPy_Interface1D_methods[] = {
{"getExactTypeName", ( PyCFunction ) Interface1D_getExactTypeName, METH_NOARGS, " Returns the string of the name of the interface."},
{"getVertices", ( PyCFunction ) Interface1D_getVertices, METH_NOARGS, "Returns the vertices"},
{"getPoints", ( PyCFunction ) Interface1D_getPoints, METH_NOARGS, "Returns the points. The difference with getVertices() is that here we can iterate over points of the 1D element at any given sampling. At each call, a virtual point is created."},
{"getLength2D", ( PyCFunction ) Interface1D_getLength2D, METH_NOARGS, "Returns the 2D length of the 1D element"},
{"getId", ( PyCFunction ) Interface1D_getId, METH_NOARGS, "Returns the Id of the 1D element"},
{"getNature", ( PyCFunction ) Interface1D_getNature, METH_NOARGS, "Returns the nature of the 1D element"},
{"getTimeStamp", ( PyCFunction ) Interface1D_getTimeStamp, METH_NOARGS, "Returns the time stamp of the 1D element. Mainly used for selection"},
{"setTimeStamp", ( PyCFunction ) Interface1D_setTimeStamp, METH_VARARGS, "Sets the time stamp for the 1D element"},
{NULL, NULL, 0, NULL} {NULL, NULL, 0, NULL}
}; };
/*-----------------------BPy_Freestyle method def------------------------------*/ /*-----------------------BPy_Interface1D type definition ------------------------------*/
PyTypeObject Interface1D_Type = { PyTypeObject Interface1D_Type = {
PyObject_HEAD_INIT( NULL ) PyObject_HEAD_INIT( NULL )
@@ -29,12 +45,12 @@ PyTypeObject Interface1D_Type = {
0, /* tp_itemsize */ 0, /* tp_itemsize */
/* methods */ /* methods */
NULL, /* tp_dealloc */ (destructor)Interface1D___dealloc__, /* tp_dealloc */
NULL, /* printfunc tp_print; */ NULL, /* printfunc tp_print; */
NULL, /* getattrfunc tp_getattr; */ NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */ NULL, /* setattrfunc tp_setattr; */
NULL, /* tp_compare */ NULL, /* tp_compare */
NULL, /* tp_repr */ (reprfunc)Interface1D___repr__, /* tp_repr */
/* Method suites for standard classes */ /* Method suites for standard classes */
@@ -77,17 +93,17 @@ PyTypeObject Interface1D_Type = {
NULL, /* iternextfunc tp_iternext; */ NULL, /* iternextfunc tp_iternext; */
/*** Attribute descriptor and subclassing stuff ***/ /*** Attribute descriptor and subclassing stuff ***/
NULL, /* struct PyMethodDef *tp_methods; */ BPy_Interface1D_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */ NULL, /* struct PyMemberDef *tp_members; */
NULL, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct PyGetSetDef *tp_getset; */
NULL, /* struct _typeobject *tp_base; */ NULL, /* struct _typeobject *tp_base; */
NULL, /* PyObject *tp_dict; */ NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */ NULL, /* descrgetfunc tp_descr_get; */
NULL, /* descrsetfunc tp_descr_set; */ NULL, /* descrsetfunc tp_descr_set; */
0, /* long tp_dictoffset; */ 0, /* long tp_dictoffset; */
NULL, /* initproc tp_init; */ NULL, /* initproc tp_init; */
NULL, /* allocfunc tp_alloc; */ NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */ (newfunc)Interface1D___new__, /* newfunc tp_new; */
/* Low-level free-memory routine */ /* Low-level free-memory routine */
NULL, /* freefunc tp_free; */ NULL, /* freefunc tp_free; */
@@ -105,31 +121,53 @@ PyTypeObject Interface1D_Type = {
}; };
//-------------------MODULE INITIALIZATION-------------------------------- //-------------------MODULE INITIALIZATION--------------------------------
PyObject *Interface1D_Init( void ) PyMODINIT_FUNC Interface1D_Init( PyObject *module )
{ {
PyObject *submodule; if( module == NULL )
return;
if( PyType_Ready( &Interface1D_Type ) < 0 ) if( PyType_Ready( &Interface1D_Type ) < 0 )
return NULL; return;
submodule = Py_InitModule3( "Blender.Freestyle.Interface1D", M_Interface1D_methods, M_Interface1D_doc ); Py_INCREF( &Interface1D_Type );
PyModule_AddObject(module, "Interface1D", (PyObject *)&Interface1D_Type);
return submodule;
} }
//------------------------INSTANCE METHODS ---------------------------------- //------------------------INSTANCE METHODS ----------------------------------
PyObject * Interface1D___new__(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
BPy_Interface1D *self;
self = (BPy_Interface1D *)type->tp_alloc(type, 0);
if (self != NULL) {
self->if1D = new Interface1D();
}
return (PyObject *)self;
}
void Interface1D___dealloc__(BPy_Interface1D* self)
{
delete self->if1D;
self->ob_type->tp_free((PyObject*)self);
}
PyObject * Interface1D___repr__(BPy_Interface1D* self)
{
return PyString_FromFormat("type: %s - address: %p", self->if1D->getExactTypeName().c_str(), self->if1D );
}
PyObject *Interface1D_getExactTypeName( BPy_Interface1D *self ) { PyObject *Interface1D_getExactTypeName( BPy_Interface1D *self ) {
return PyString_FromString( self->if1D->getExactTypeName().c_str() ); return PyString_FromString( self->if1D->getExactTypeName().c_str() );
} }
PyObject *Interface1D_getVertices( BPy_Interface1D *self ) { PyObject *Interface1D_getVertices( BPy_Interface1D *self ) {
// Vector return PyList_New(0);
} }
PyObject *Interface1D_getPoints( BPy_Interface1D *self ) { PyObject *Interface1D_getPoints( BPy_Interface1D *self ) {
// Vector return PyList_New(0);
} }
PyObject *Interface1D_getLength2D( BPy_Interface1D *self ) { PyObject *Interface1D_getLength2D( BPy_Interface1D *self ) {
@@ -137,7 +175,7 @@ PyObject *Interface1D_getLength2D( BPy_Interface1D *self ) {
} }
PyObject *Interface1D_getId( BPy_Interface1D *self ) { PyObject *Interface1D_getId( BPy_Interface1D *self ) {
// Id return BPy_Id_from_Id( self->if1D->getId() );
} }
PyObject *Interface1D_getNature( BPy_Interface1D *self ) { PyObject *Interface1D_getNature( BPy_Interface1D *self ) {
@@ -149,14 +187,13 @@ PyObject *Interface1D_getTimeStamp( BPy_Interface1D *self ) {
} }
PyObject *Interface1D_setTimeStamp( BPy_Interface1D *self, PyObject *args) { PyObject *Interface1D_setTimeStamp( BPy_Interface1D *self, PyObject *args) {
PyObject * obj1 = 0 ; int timestamp = 0 ;
PyObject * obj2 = 0 ;
unsigned int timestamp; if( !PyArg_ParseTuple(args, (char *)"i:Interface1D_setTimeStamp", &timestamp) ) {
if( !PyArg_ParseTuple(args, (char *)"OO:Interface1D_setTimeStamp", &obj1, &obj2) )
cout << "ERROR: Interface1D_setTimeStamp" << endl; cout << "ERROR: Interface1D_setTimeStamp" << endl;
Py_RETURN_NONE;
}
timestamp = static_cast<unsigned int>( PyInt_AsLong(obj2) );
self->if1D->setTimeStamp( timestamp ); self->if1D->setTimeStamp( timestamp );
Py_RETURN_NONE; Py_RETURN_NONE;

View File

@@ -24,7 +24,7 @@ typedef struct {
/*---------------------------Python BPy_Interface1D visible prototypes-----------*/ /*---------------------------Python BPy_Interface1D visible prototypes-----------*/
PyObject *Interface1D_Init( void ); PyMODINIT_FUNC Interface1D_Init( PyObject *module );
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -139,11 +139,19 @@ public:
/*! Returns an iterator over the Interface1D vertices, /*! Returns an iterator over the Interface1D vertices,
* pointing to the first vertex. * pointing to the first vertex.
*/ */
virtual Interface0DIterator verticesBegin() = 0; virtual Interface0DIterator verticesBegin() {
cerr << "Warning: method verticesBegin() not implemented" << endl;
return Interface0DIterator();
}
/*! Returns an iterator over the Interface1D vertices, /*! Returns an iterator over the Interface1D vertices,
* pointing after the last vertex. * pointing after the last vertex.
*/ */
virtual Interface0DIterator verticesEnd() = 0; virtual Interface0DIterator verticesEnd(){
cerr << "Warning: method verticesEnd() not implemented" << endl;
return Interface0DIterator();
}
/*! Returns an iterator over the Interface1D points, /*! Returns an iterator over the Interface1D points,
* pointing to the first point. The difference with * pointing to the first point. The difference with
* verticesBegin() is that here we can iterate over * verticesBegin() is that here we can iterate over
@@ -153,7 +161,11 @@ public:
* The sampling with which we want to iterate over points of * The sampling with which we want to iterate over points of
* this 1D element. * this 1D element.
*/ */
virtual Interface0DIterator pointsBegin(float t=0.f) = 0; virtual Interface0DIterator pointsBegin(float t=0.f) {
cerr << "Warning: method pointsBegin() not implemented" << endl;
return Interface0DIterator();
}
/*! Returns an iterator over the Interface1D points, /*! Returns an iterator over the Interface1D points,
* pointing after the last point. The difference with * pointing after the last point. The difference with
* verticesEnd() is that here we can iterate over * verticesEnd() is that here we can iterate over
@@ -163,7 +175,10 @@ public:
* The sampling with which we want to iterate over points of * The sampling with which we want to iterate over points of
* this 1D element. * this 1D element.
*/ */
virtual Interface0DIterator pointsEnd(float t=0.f) = 0; virtual Interface0DIterator pointsEnd(float t=0.f) {
cerr << "Warning: method pointsEnd() not implemented" << endl;
return Interface0DIterator();
}
// Data access methods // Data access methods