diff options
Diffstat (limited to 'source/blender/freestyle/intern/python')
29 files changed, 457 insertions, 90 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_Convert.cpp b/source/blender/freestyle/intern/python/BPy_Convert.cpp index a1c26aaf622..5f4b7098f29 100644 --- a/source/blender/freestyle/intern/python/BPy_Convert.cpp +++ b/source/blender/freestyle/intern/python/BPy_Convert.cpp @@ -92,9 +92,9 @@ PyObject * BPy_Interface1D_from_Interface1D( Interface1D& if1D ) { } -PyObject * BPy_SVertex_from_SVertex( SVertex& sv ) { +PyObject * BPy_SVertex_from_SVertex_ptr( SVertex *sv ) { PyObject *py_sv = SVertex_Type.tp_new( &SVertex_Type, 0, 0 ); - ((BPy_SVertex *) py_sv)->sv = new SVertex( sv ); + ((BPy_SVertex *) py_sv)->sv = sv; ((BPy_SVertex *) py_sv)->py_if0D.if0D = ((BPy_SVertex *) py_sv)->sv; return py_sv; @@ -119,18 +119,17 @@ PyObject * BPy_Nature_from_Nature( unsigned short n ) { return py_n; } -PyObject * BPy_Stroke_from_Stroke( Stroke& s ) { +PyObject * BPy_Stroke_from_Stroke_ptr( Stroke* s ) { PyObject *py_s = Stroke_Type.tp_new( &Stroke_Type, 0, 0 ); - ((BPy_Stroke *) py_s)->s = new Stroke( s ); + ((BPy_Stroke *) py_s)->s = s; ((BPy_Stroke *) py_s)->py_if1D.if1D = ((BPy_Stroke *) py_s)->s; return py_s; } -PyObject * BPy_StrokeAttribute_from_StrokeAttribute( StrokeAttribute& sa ) { +PyObject * BPy_StrokeAttribute_from_StrokeAttribute_ptr( StrokeAttribute *sa ) { PyObject *py_sa = StrokeAttribute_Type.tp_new( &StrokeAttribute_Type, 0, 0 ); - ((BPy_StrokeAttribute *) py_sa)->sa = new StrokeAttribute( sa ); - + ((BPy_StrokeAttribute *) py_sa)->sa = sa; return py_sa; } @@ -145,9 +144,9 @@ PyObject * BPy_MediumType_from_MediumType( int n ) { return py_mt; } -PyObject * BPy_StrokeVertex_from_StrokeVertex( StrokeVertex& sv ) { +PyObject * BPy_StrokeVertex_from_StrokeVertex_ptr( StrokeVertex *sv ) { PyObject *py_sv = StrokeVertex_Type.tp_new( &StrokeVertex_Type, 0, 0 ); - ((BPy_StrokeVertex *) py_sv)->sv = new StrokeVertex( sv ); + ((BPy_StrokeVertex *) py_sv)->sv = sv; ((BPy_StrokeVertex *) py_sv)->py_cp.cp = ((BPy_StrokeVertex *) py_sv)->sv; ((BPy_StrokeVertex *) py_sv)->py_cp.py_if0D.if0D = ((BPy_StrokeVertex *) py_sv)->sv; @@ -169,9 +168,9 @@ PyObject * BPy_BBox_from_BBox( BBox< Vec3r > &bb ) { return py_bb; } -PyObject * BPy_ViewEdge_from_ViewEdge( ViewEdge& ve ) { +PyObject * BPy_ViewEdge_from_ViewEdge_ptr( ViewEdge* ve ) { PyObject *py_ve = ViewEdge_Type.tp_new( &ViewEdge_Type, 0, 0 ); - ((BPy_ViewEdge *) py_ve)->ve = new ViewEdge( ve ); + ((BPy_ViewEdge *) py_ve)->ve = ve; ((BPy_ViewEdge *) py_ve)->py_if1D.if1D = ((BPy_ViewEdge *) py_ve)->ve; return py_ve; @@ -219,7 +218,7 @@ PyObject * BPy_CurvePoint_from_CurvePoint( CurvePoint& cp ) { PyObject * BPy_directedViewEdge_from_directedViewEdge( ViewVertex::directedViewEdge& dve ) { PyObject *py_dve = PyList_New(2); - PyList_SetItem( py_dve, 0, BPy_ViewEdge_from_ViewEdge(*(dve.first)) ); + PyList_SetItem( py_dve, 0, BPy_ViewEdge_from_ViewEdge_ptr(dve.first) ); PyList_SetItem( py_dve, 1, PyBool_from_bool(dve.second) ); return py_dve; @@ -316,7 +315,7 @@ PyObject * BPy_ChainSilhouetteIterator_from_ChainSilhouetteIterator( ChainSilhou //============================== bool bool_from_PyBool( PyObject *b ) { - return b == Py_True; + return (b == Py_True || PyInt_AsLong(b) != 0); } IntegrationType IntegrationType_from_BPy_IntegrationType( PyObject* obj ) { diff --git a/source/blender/freestyle/intern/python/BPy_Convert.h b/source/blender/freestyle/intern/python/BPy_Convert.h index 5bfdef56278..10efb2e5246 100644 --- a/source/blender/freestyle/intern/python/BPy_Convert.h +++ b/source/blender/freestyle/intern/python/BPy_Convert.h @@ -82,12 +82,12 @@ PyObject * BPy_FrsMaterial_from_Material( Material& m ); PyObject * BPy_Nature_from_Nature( unsigned short n ); PyObject * BPy_MediumType_from_MediumType( int n ); PyObject * BPy_SShape_from_SShape( SShape& ss ); -PyObject * BPy_Stroke_from_Stroke( Stroke& s ); -PyObject * BPy_StrokeAttribute_from_StrokeAttribute( StrokeAttribute& sa ); -PyObject * BPy_StrokeVertex_from_StrokeVertex( StrokeVertex& sv ); -PyObject * BPy_SVertex_from_SVertex( SVertex& sv ); +PyObject * BPy_Stroke_from_Stroke_ptr( Stroke* s ); +PyObject * BPy_StrokeAttribute_from_StrokeAttribute_ptr( StrokeAttribute *sa ); +PyObject * BPy_StrokeVertex_from_StrokeVertex_ptr( StrokeVertex *sv ); +PyObject * BPy_SVertex_from_SVertex_ptr( SVertex *sv ); PyObject * BPy_ViewVertex_from_ViewVertex_ptr( ViewVertex *vv ); -PyObject * BPy_ViewEdge_from_ViewEdge( ViewEdge& ve ); +PyObject * BPy_ViewEdge_from_ViewEdge_ptr( ViewEdge *ve ); PyObject * BPy_ViewShape_from_ViewShape( ViewShape& vs ); PyObject * BPy_AdjacencyIterator_from_AdjacencyIterator( AdjacencyIterator& a_it ); diff --git a/source/blender/freestyle/intern/python/BPy_Interface0D.cpp b/source/blender/freestyle/intern/python/BPy_Interface0D.cpp index 506fc3b4e9d..78bd4176658 100644 --- a/source/blender/freestyle/intern/python/BPy_Interface0D.cpp +++ b/source/blender/freestyle/intern/python/BPy_Interface0D.cpp @@ -183,12 +183,14 @@ PyMODINIT_FUNC Interface0D_Init( PyObject *module ) int Interface0D___init__(BPy_Interface0D *self, PyObject *args, PyObject *kwds) { self->if0D = new Interface0D(); + self->if0D->py_if0D = (PyObject *)self; return 0; } void Interface0D___dealloc__(BPy_Interface0D* self) { - delete self->if0D; + if( self->if0D->py_if0D ) + delete self->if0D; self->ob_type->tp_free((PyObject*)self); } diff --git a/source/blender/freestyle/intern/python/BPy_Interface1D.cpp b/source/blender/freestyle/intern/python/BPy_Interface1D.cpp index 8d2549ebf2c..cfa9c3066a1 100644 --- a/source/blender/freestyle/intern/python/BPy_Interface1D.cpp +++ b/source/blender/freestyle/intern/python/BPy_Interface1D.cpp @@ -204,7 +204,8 @@ int Interface1D___init__(BPy_Interface1D *self, PyObject *args, PyObject *kwds) void Interface1D___dealloc__(BPy_Interface1D* self) { - delete self->if1D; + if( self->if1D->py_if1D ) + delete self->if1D; self->ob_type->tp_free((PyObject*)self); } diff --git a/source/blender/freestyle/intern/python/BPy_Iterator.cpp b/source/blender/freestyle/intern/python/BPy_Iterator.cpp index 23dd68e0aa8..5c19dfd29ac 100644 --- a/source/blender/freestyle/intern/python/BPy_Iterator.cpp +++ b/source/blender/freestyle/intern/python/BPy_Iterator.cpp @@ -227,10 +227,6 @@ PyObject * Iterator_isEnd(BPy_Iterator* self) { return PyBool_from_bool( self->it->isEnd() ); } -PyObject * Iterator_getObject(BPy_Iterator* self) { - return PyBool_from_bool( self->it->isEnd() ); -} - /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/blender/freestyle/intern/python/BPy_Operators.cpp b/source/blender/freestyle/intern/python/BPy_Operators.cpp index ab64f5bc6eb..c1b0b59daae 100644 --- a/source/blender/freestyle/intern/python/BPy_Operators.cpp +++ b/source/blender/freestyle/intern/python/BPy_Operators.cpp @@ -24,28 +24,27 @@ static PyObject * Operators_sequentialSplit(BPy_Operators* self, PyObject *args) static PyObject * Operators_recursiveSplit(BPy_Operators* self, PyObject *args); static PyObject * Operators_sort(BPy_Operators* self, PyObject *args); static PyObject * Operators_create(BPy_Operators* self, PyObject *args); +static PyObject * Operators_getViewEdgesSize( BPy_Operators* self); +static PyObject * Operators_getChainsSize( BPy_Operators* self); +static PyObject * Operators_getStrokesSize( BPy_Operators* self); /*----------------------Operators instance definitions ----------------------------*/ static PyMethodDef BPy_Operators_methods[] = { {"select", ( PyCFunction ) Operators_select, METH_VARARGS | METH_STATIC, "select operator"}, - {"bidirectionalChain", ( PyCFunction ) Operators_bidirectionalChain, METH_VARARGS | METH_STATIC, - "select operator"}, - + "bidirectionalChain operator"}, {"sequentialSplit", ( PyCFunction ) Operators_sequentialSplit, METH_VARARGS | METH_STATIC, - "select operator"}, - + "sequentialSplit operator"}, {"recursiveSplit", ( PyCFunction ) Operators_recursiveSplit, METH_VARARGS | METH_STATIC, - "select operator"}, - + "recursiveSplit operator"}, {"sort", ( PyCFunction ) Operators_sort, METH_VARARGS | METH_STATIC, - "select operator"}, - + "sort operator"}, {"create", ( PyCFunction ) Operators_create, METH_VARARGS | METH_STATIC, - "select operator"}, - - + "create operator"}, + {"getViewEdgesSize", ( PyCFunction ) Operators_getViewEdgesSize, METH_NOARGS | METH_STATIC, ""}, + {"getChainsSize", ( PyCFunction ) Operators_getChainsSize, METH_NOARGS | METH_STATIC, ""}, + {"getStrokesSize", ( PyCFunction ) Operators_getStrokesSize, METH_NOARGS | METH_STATIC, ""}, {NULL, NULL, 0, NULL} }; @@ -322,6 +321,19 @@ PyObject * Operators_create(BPy_Operators* self, PyObject *args) Py_RETURN_NONE; } +PyObject * Operators_getViewEdgesSize( BPy_Operators* self) { + return PyInt_FromLong( Operators::getViewEdgesSize() ); +} + +PyObject * Operators_getChainsSize( BPy_Operators* self ) { + return PyInt_FromLong( Operators::getChainsSize() ); +} + +PyObject * Operators_getStrokesSize( BPy_Operators* self) { + return PyInt_FromLong( Operators::getStrokesSize() ); +} + + /////////////////////////////////////////////////////////////////////////////////////////// #ifdef __cplusplus diff --git a/source/blender/freestyle/intern/python/BPy_SShape.cpp b/source/blender/freestyle/intern/python/BPy_SShape.cpp index ab8a39d6193..529090d5815 100644 --- a/source/blender/freestyle/intern/python/BPy_SShape.cpp +++ b/source/blender/freestyle/intern/python/BPy_SShape.cpp @@ -228,7 +228,7 @@ PyObject * SShape_getVertexList( BPy_SShape *self ) { vector< SVertex * >::iterator it; for( it = vertices.begin(); it != vertices.end(); it++ ) { - PyList_Append( py_vertices, BPy_SVertex_from_SVertex(*( *it )) ); + PyList_Append( py_vertices, BPy_SVertex_from_SVertex_ptr(*it) ); } return py_vertices; diff --git a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp index 541ef4f4516..cc4c8288233 100644 --- a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp +++ b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp @@ -199,6 +199,7 @@ int StrokeAttribute___init__(BPy_StrokeAttribute *self, PyObject *args, PyObject return -1; } + self->sa->py_sa = (PyObject *) self; return 0; @@ -206,7 +207,8 @@ int StrokeAttribute___init__(BPy_StrokeAttribute *self, PyObject *args, PyObject void StrokeAttribute___dealloc__(BPy_StrokeAttribute* self) { - delete self->sa; + if( self->sa->py_sa ) + delete self->sa; self->ob_type->tp_free((PyObject*)self); } @@ -384,7 +386,7 @@ PyObject * StrokeAttribute_setThickness( BPy_StrokeAttribute *self, PyObject *ar PyFloat_AsDouble( PyList_GetItem(obj1, 1) ) ); self->sa->setThickness( v ); - + } else if( obj1 && obj2 ){ self->sa->setThickness( PyFloat_AsDouble(obj1), diff --git a/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp b/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp index 3b756b40d9b..6560bda3167 100644 --- a/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp +++ b/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp @@ -17,6 +17,7 @@ #include "StrokeShader/BPy_IncreasingThicknessShader.h" #include "StrokeShader/BPy_PolygonalizationShader.h" #include "StrokeShader/BPy_SamplingShader.h" +#include "StrokeShader/BPy_SmoothingShader.h" #include "StrokeShader/BPy_SpatialNoiseShader.h" #include "StrokeShader/BPy_streamShader.h" #include "StrokeShader/BPy_StrokeTextureShader.h" @@ -212,6 +213,11 @@ PyMODINIT_FUNC StrokeShader_Init( PyObject *module ) Py_INCREF( &SamplingShader_Type ); PyModule_AddObject(module, "SamplingShader", (PyObject *)&SamplingShader_Type); + if( PyType_Ready( &SmoothingShader_Type ) < 0 ) + return; + Py_INCREF( &SmoothingShader_Type ); + PyModule_AddObject(module, "SmoothingShader", (PyObject *)&SmoothingShader_Type); + if( PyType_Ready( &SpatialNoiseShader_Type ) < 0 ) return; Py_INCREF( &SpatialNoiseShader_Type ); diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp index db708c7830b..f751d092920 100644 --- a/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp +++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp @@ -174,6 +174,8 @@ PyObject * UnaryPredicate0D___call__( BPy_UnaryPredicate0D *self, PyObject *args if( if0D_it ) return PyBool_from_bool( self->up0D->operator()(*if0D_it) ); + else + cerr << "ERROR: UnaryPredicate0D___call__ (no Interface0DIterator)" << endl; Py_RETURN_NONE; } diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp index f2b2c7b9b53..0ae76b5eae6 100644 --- a/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp +++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp @@ -216,6 +216,8 @@ PyObject * UnaryPredicate1D___call__( BPy_UnaryPredicate1D *self, PyObject *args if( if1D ) return PyBool_from_bool( self->up1D->operator()(*if1D) ); + else + cerr << "ERROR: UnaryPredicate1D___call__ (no Interface1D)" << endl; Py_RETURN_NONE; } diff --git a/source/blender/freestyle/intern/python/BPy_ViewMap.cpp b/source/blender/freestyle/intern/python/BPy_ViewMap.cpp index e8633770c8c..c010236964a 100644 --- a/source/blender/freestyle/intern/python/BPy_ViewMap.cpp +++ b/source/blender/freestyle/intern/python/BPy_ViewMap.cpp @@ -157,7 +157,7 @@ PyObject * ViewMap_getClosestViewEdge( BPy_ViewMap *self , PyObject *args) { ViewEdge *ve = const_cast<ViewEdge *>( self->vm->getClosestViewEdge(x,y) ); if( ve ) - return BPy_ViewEdge_from_ViewEdge(*ve); + return BPy_ViewEdge_from_ViewEdge_ptr(ve); Py_RETURN_NONE; } diff --git a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp index a87859491b4..fd676c54c7b 100644 --- a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp +++ b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp @@ -198,7 +198,7 @@ PyObject * ViewShape_edges( BPy_ViewShape *self ) { vector< ViewEdge * >::iterator it; for( it = edges.begin(); it != edges.end(); it++ ) { - PyList_Append( py_edges, BPy_ViewEdge_from_ViewEdge(*( *it )) ); + PyList_Append( py_edges, BPy_ViewEdge_from_ViewEdge_ptr(*it) ); } return py_edges; diff --git a/source/blender/freestyle/intern/python/Director.cpp b/source/blender/freestyle/intern/python/Director.cpp index b3188554c09..153ea79eabf 100644 --- a/source/blender/freestyle/intern/python/Director.cpp +++ b/source/blender/freestyle/intern/python/Director.cpp @@ -13,6 +13,11 @@ #include "BPy_StrokeShader.h" #include "Iterator/BPy_ChainingIterator.h" #include "Iterator/BPy_Interface0DIterator.h" +#include "Interface0D/BPy_SVertex.h" +#include "Interface0D/BPy_ViewVertex.h" +#include "Interface0D/ViewVertex/BPy_NonTVertex.h" +#include "Interface0D/ViewVertex/BPy_TVertex.h" +#include "Interface1D/BPy_FEdge.h" #include "Interface1D/BPy_Stroke.h" #include "Interface1D/BPy_ViewEdge.h" #include "BPy_ViewShape.h" @@ -28,6 +33,15 @@ #include "UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h" #include "UnaryFunction0D/BPy_UnaryFunction0DViewShape.h" +#include "UnaryFunction1D/BPy_UnaryFunction1DDouble.h" +#include "UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.h" +#include "UnaryFunction1D/BPy_UnaryFunction1DFloat.h" +#include "UnaryFunction1D/BPy_UnaryFunction1DUnsigned.h" +#include "UnaryFunction1D/BPy_UnaryFunction1DVec2f.h" +#include "UnaryFunction1D/BPy_UnaryFunction1DVec3f.h" +#include "UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h" + + // BinaryPredicate0D: __call__ bool Director_BPy_BinaryPredicate0D___call__( PyObject *obj, Interface0D& i1, Interface0D& i2) { PyObject *result = PyObject_CallMethod( obj, "__call__", "OO", BPy_Interface0D_from_Interface0D(i1), BPy_Interface0D_from_Interface0D(i2) ); @@ -62,7 +76,7 @@ bool Director_BPy_UnaryPredicate1D___call__( PyObject *obj, Interface1D& if1D) { // StrokeShader: shade void Director_BPy_StrokeShader_shade( PyObject *obj, Stroke& s) { - PyObject_CallMethod( obj, "shade", "O", BPy_Stroke_from_Stroke(s) ); + PyObject_CallMethod( obj, "shade", "O", BPy_Stroke_from_Stroke_ptr(&s) ); } // ChainingIterator: init, traverse @@ -89,7 +103,6 @@ void Director_BPy_UnaryFunction0D___call__( void *uf0D, PyObject *obj, Interface ((UnaryFunction0D<Nature::EdgeNature> *) uf0D)->result = EdgeNature_from_BPy_Nature(result); } else if ( BPy_UnaryFunction0DFloat_Check(obj) ) { - ((UnaryFunction0D<float> *) uf0D)->result = PyFloat_AsDouble(result); } else if ( BPy_UnaryFunction0DId_Check(obj) ) { @@ -129,20 +142,45 @@ void Director_BPy_UnaryFunction0D___call__( void *uf0D, PyObject *obj, Interface void Director_BPy_UnaryFunction1D___call__( void *uf1D, PyObject *obj, Interface1D& if1D) { -// BPy_UnaryFunction1DDouble -// BPy_UnaryFunction1DEdgeNature -// BPy_UnaryFunction1DFloat -// BPy_UnaryFunction1DUnsigned -// BPy_UnaryFunction1DVec2f -// BPy_UnaryFunction1DVec3f -// BPy_UnaryFunction1DVectorViewShape -// BPy_UnaryFunction1DVoid + PyObject *result = PyObject_CallMethod( obj, "__call__", "O", BPy_Interface1D_from_Interface1D(if1D) ); + + if( BPy_UnaryFunction1DDouble_Check(obj) ) { + ((UnaryFunction1D<double> *) uf1D)->result = PyFloat_AsDouble(result); + } else if ( BPy_UnaryFunction1DEdgeNature_Check(obj) ) { + ((UnaryFunction1D<Nature::EdgeNature> *) uf1D)->result = EdgeNature_from_BPy_Nature(result); + + } else if ( BPy_UnaryFunction1DFloat_Check(obj) ) { + ((UnaryFunction1D<float> *) uf1D)->result = PyFloat_AsDouble(result); + + } else if ( BPy_UnaryFunction1DUnsigned_Check(obj) ) { + ((UnaryFunction1D<unsigned> *) uf1D)->result = PyInt_AsLong(result); + + } else if ( BPy_UnaryFunction1DVec2f_Check(obj) ) { + Vec2f *v = Vec2f_ptr_from_Vector( result ); + ((UnaryFunction1D<Vec2f> *) uf1D)->result = *v; + delete v; + + } else if ( BPy_UnaryFunction1DVec3f_Check(obj) ) { + Vec3f *v = Vec3f_ptr_from_Vector( result ); + ((UnaryFunction1D<Vec3f> *) uf1D)->result = *v; + delete v; + + } else if ( BPy_UnaryFunction1DVectorViewShape_Check(obj) ) { + vector<ViewShape*> vec; + for( int i = 1; i < PyList_Size(result); i++) { + ViewShape *b = ( (BPy_ViewShape *) PyList_GetItem(result, i) )->vs; + vec.push_back( b ); + } + + ((UnaryFunction1D< vector<ViewShape*> > *) uf1D)->result = vec; + + } } -// BPy_Iterator: increment, decrement, isBegin, isEnd +// Iterator: increment, decrement, isBegin, isEnd void Director_BPy_Iterator_increment( PyObject *obj ) { PyObject_CallMethod( obj, "increment", "", 0 ); } @@ -163,7 +201,106 @@ bool Director_BPy_Iterator_isEnd( PyObject *obj ) { return bool_from_PyBool(result); } -// BPy_Interface1D: verticesBegin, verticesEnd, pointsBegin, pointsEnd +// Interface0D: getX, getY, getZ, getPoint3D, getProjectedX, getProjectedY, getProjectedZ, getPoint2D, getFEdge, getId, getNature, castToSVertex, castToViewVertex, castToNonTVertex, castToTVertex +double Director_BPy_Interface0D_getX( PyObject *obj ) { + PyObject *result = PyObject_CallMethod( obj, "getX", "", 0 ); + + return PyFloat_AsDouble(result); +} + +double Director_BPy_Interface0D_getY( PyObject *obj ) { + PyObject *result = PyObject_CallMethod( obj, "getY", "", 0 ); + + return PyFloat_AsDouble(result); +} + +double Director_BPy_Interface0D_getZ( PyObject *obj ) { + PyObject *result = PyObject_CallMethod( obj, "getZ", "", 0 ); + + return PyFloat_AsDouble(result); +} + +Geometry::Vec3f Director_BPy_Interface0D_getPoint3D( PyObject *obj ) { + PyObject *result = PyObject_CallMethod( obj, "getPoint3D", "", 0 ); + + Geometry::Vec3f *v_ref = Vec3f_ptr_from_Vector( result ); + Geometry::Vec3f v(*v_ref); + delete v_ref; + + return v; +} + +double Director_BPy_Interface0D_getProjectedX( PyObject *obj ) { + PyObject *result = PyObject_CallMethod( obj, "getProjectedX", "", 0 ); + + return PyFloat_AsDouble(result); +} + +double Director_BPy_Interface0D_getProjectedY( PyObject *obj ) { + PyObject *result = PyObject_CallMethod( obj, "getProjectedY", "", 0 ); + + return PyFloat_AsDouble(result); +} + +double Director_BPy_Interface0D_getProjectedZ( PyObject *obj ) { + PyObject *result = PyObject_CallMethod( obj, "getProjectedZ", "", 0 ); + + return PyFloat_AsDouble(result); +} + +Geometry::Vec2f Director_BPy_Interface0D_getPoint2D( PyObject *obj ) { + PyObject *result = PyObject_CallMethod( obj, "getPoint2D", "", 0 ); + + Geometry::Vec2f *v_ref = Vec2f_ptr_from_Vector( result ); + Geometry::Vec2f v(*v_ref); + delete v_ref; + + return v; +} + +FEdge * Director_BPy_Interface0D_getFEdge( PyObject *obj ) { + PyObject *result = PyObject_CallMethod( obj, "getFEdge", "", 0 ); + + return ((BPy_FEdge *) result)->fe; +} + +Id Director_BPy_Interface0D_getId( PyObject *obj ) { + PyObject *result = PyObject_CallMethod( obj, "getId", "", 0 ); + + return *( ((BPy_Id *) result)->id ); +} + +Nature::EdgeNature Director_BPy_Interface0D_getNature( PyObject *obj ) { + PyObject *result = PyObject_CallMethod( obj, "getNature", "", 0 ); + + return EdgeNature_from_BPy_Nature(result); +} + +SVertex * Director_BPy_Interface0D_castToSVertex( PyObject *obj ) { + PyObject *result = PyObject_CallMethod( obj, "castToSVertex", "", 0 ); + + return ((BPy_SVertex *) result)->sv; +} + +ViewVertex * Director_BPy_Interface0D_castToViewVertex( PyObject *obj ) { + PyObject *result = PyObject_CallMethod( obj, "castToViewVertex", "", 0 ); + + return ((BPy_ViewVertex *) result)->vv; +} + +NonTVertex * Director_BPy_Interface0D_castToNonTVertex( PyObject *obj ) { + PyObject *result = PyObject_CallMethod( obj, "castToNonTVertex", "", 0 ); + + return ((BPy_NonTVertex *) result)->ntv; +} + +TVertex * Director_BPy_Interface0D_castToTVertex( PyObject *obj ) { + PyObject *result = PyObject_CallMethod( obj, "castToTVertex", "", 0 ); + + return ((BPy_TVertex *) result)->tv; +} + +// Interface1D: verticesBegin, verticesEnd, pointsBegin, pointsEnd Interface0DIterator Director_BPy_Interface1D_verticesBegin( PyObject *obj ){ PyObject *result = PyObject_CallMethod( obj, "verticesBegin", "", 0 ); @@ -188,3 +325,20 @@ Interface0DIterator Director_BPy_Interface1D_pointsEnd( PyObject *obj ){ return *( ((BPy_Interface0DIterator *) result)->if0D_it ); } +double Director_BPy_Interface1D_getLength2D( PyObject *obj ) { + PyObject *result = PyObject_CallMethod( obj, "getLength2D", "", 0 ); + + return PyFloat_AsDouble(result); +} + +Id Director_BPy_Interface1D_getId( PyObject *obj ) { + PyObject *result = PyObject_CallMethod( obj, "getId", "", 0 ); + + return *( ((BPy_Id *) result)->id ); +} + +Nature::EdgeNature Director_BPy_Interface1D_getNature( PyObject *obj ) { + PyObject *result = PyObject_CallMethod( obj, "getNature", "", 0 ); + + return EdgeNature_from_BPy_Nature( result ); +}
\ No newline at end of file diff --git a/source/blender/freestyle/intern/python/Director.h b/source/blender/freestyle/intern/python/Director.h index 27afa3bbe3e..22bf80c5c14 100644 --- a/source/blender/freestyle/intern/python/Director.h +++ b/source/blender/freestyle/intern/python/Director.h @@ -1,12 +1,22 @@ #ifndef FREESTYLE_PYTHON_DIRECTOR # define FREESTYLE_PYTHON_DIRECTOR +#include "../geometry/Geom.h" +#include "../winged_edge/Nature.h" + +class AdjacencyIterator; +class FEdge; +class Id; class Interface0D; class Interface1D; class Interface0DIterator; +class NonTVertex; class Stroke; -class AdjacencyIterator; +class SVertex; +class TVertex; class ViewEdge; +class ViewVertex; + #ifdef __cplusplus extern "C" { @@ -24,6 +34,36 @@ bool Director_BPy_BinaryPredicate0D___call__( PyObject *obj, Interface0D& i1, In // BinaryPredicate1D: __call__ bool Director_BPy_BinaryPredicate1D___call__( PyObject *obj, Interface1D& i1, Interface1D& i2); +// Interface0D: getX, getY, getZ, getPoint3D, getProjectedX, getProjectedY, getProjectedZ, getPoint2D, getFEdge, getId, getNature, castToSVertex, castToViewVertex, castToNonTVertex, castToTVertex +double Director_BPy_Interface0D_getX( PyObject *obj ); +double Director_BPy_Interface0D_getY( PyObject *obj ); +double Director_BPy_Interface0D_getZ( PyObject *obj ); +Geometry::Vec3f Director_BPy_Interface0D_getPoint3D( PyObject *obj ); +double Director_BPy_Interface0D_getProjectedX( PyObject *obj ); +double Director_BPy_Interface0D_getProjectedY( PyObject *obj ); +double Director_BPy_Interface0D_getProjectedZ( PyObject *obj ); +Geometry::Vec2f Director_BPy_Interface0D_getPoint2D( PyObject *obj ); +FEdge * Director_BPy_Interface0D_getFEdge( PyObject *obj ); +Id Director_BPy_Interface0D_getId( PyObject *obj ); +Nature::EdgeNature Director_BPy_Interface0D_getNature( PyObject *obj ); +SVertex * Director_BPy_Interface0D_castToSVertex( PyObject *obj ); +ViewVertex * Director_BPy_Interface0D_castToViewVertex( PyObject *obj ); +NonTVertex * Director_BPy_Interface0D_castToNonTVertex( PyObject *obj ); +TVertex * Director_BPy_Interface0D_castToTVertex( PyObject *obj ); + +// Interface1D: verticesBegin, verticesEnd, pointsBegin, pointsEnd, getLength2D, getId, getNature +Interface0DIterator Director_BPy_Interface1D_verticesBegin( PyObject *obj ); +Interface0DIterator Director_BPy_Interface1D_verticesEnd( PyObject *obj ); +Interface0DIterator Director_BPy_Interface1D_pointsBegin( PyObject *obj ); +Interface0DIterator Director_BPy_Interface1D_pointsEnd( PyObject *obj ); +double Director_BPy_Interface1D_getLength2D( PyObject *obj ); +Id Director_BPy_Interface1D_getId( PyObject *obj ); +Nature::EdgeNature Director_BPy_Interface1D_getNature( PyObject *obj ); + +// UnaryFunction{0D,1D}: __call__ +void Director_BPy_UnaryFunction0D___call__( void *uf0D, PyObject *obj, Interface0DIterator& if0D_it); +void Director_BPy_UnaryFunction1D___call__( void *uf1D, PyObject *obj, Interface1D& if1D); + // UnaryPredicate0D: __call__ bool Director_BPy_UnaryPredicate0D___call__( PyObject *obj, Interface0DIterator& if0D_it); @@ -33,25 +73,17 @@ bool Director_BPy_UnaryPredicate1D___call__( PyObject *obj, Interface1D& if1D); // StrokeShader: shade void Director_BPy_StrokeShader_shade( PyObject *obj, Stroke& s); -// ChainingIterator: init, traverse -void Director_BPy_ChainingIterator_init( PyObject *obj ); -ViewEdge * Director_BPy_ChainingIterator_traverse( PyObject *obj, AdjacencyIterator& a_it ); - -// BPy_UnaryFunction{0D,1D}: __call__ -void Director_BPy_UnaryFunction0D___call__( void *uf0D, PyObject *obj, Interface0DIterator& if0D_it); -void Director_BPy_UnaryFunction1D___call__( void *uf1D, PyObject *obj, Interface1D& if1D); - -// BPy_Iterator: increment, decrement, isBegin, isEnd +// Iterator: increment, decrement, isBegin, isEnd void Director_BPy_Iterator_increment( PyObject *obj ); void Director_BPy_Iterator_decrement( PyObject *obj ); bool Director_BPy_Iterator_isBegin( PyObject *obj ); bool Director_BPy_Iterator_isEnd( PyObject *obj ); -// BPy_Interface1D: verticesBegin, verticesEnd, pointsBegin, pointsEnd -Interface0DIterator Director_BPy_Interface1D_verticesBegin( PyObject *obj ); -Interface0DIterator Director_BPy_Interface1D_verticesEnd( PyObject *obj ); -Interface0DIterator Director_BPy_Interface1D_pointsBegin( PyObject *obj ); -Interface0DIterator Director_BPy_Interface1D_pointsEnd( PyObject *obj ); +// ChainingIterator: init, traverse +void Director_BPy_ChainingIterator_init( PyObject *obj ); +ViewEdge * Director_BPy_ChainingIterator_traverse( PyObject *obj, AdjacencyIterator& a_it ); + + diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp index 7fce126d309..cb2e30f841a 100644 --- a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp @@ -167,14 +167,14 @@ PyObject * CurvePoint___copy__( BPy_CurvePoint *self ) { PyObject * CurvePoint_A( BPy_CurvePoint *self ) { if( SVertex *A = self->cp->A() ) - return BPy_SVertex_from_SVertex( *A ); + return BPy_SVertex_from_SVertex_ptr( A ); Py_RETURN_NONE; } PyObject * CurvePoint_B( BPy_CurvePoint *self ) { if( SVertex *B = self->cp->B() ) - return BPy_SVertex_from_SVertex( *B ); + return BPy_SVertex_from_SVertex_ptr( B ); Py_RETURN_NONE; } diff --git a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp index 3616e69447f..1e2d34c2767 100644 --- a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp @@ -183,8 +183,7 @@ PyObject * StrokeVertex_getPoint( BPy_StrokeVertex *self ) { } PyObject * StrokeVertex_attribute( BPy_StrokeVertex *self ) { - StrokeAttribute sa( self->sv->attribute() ); - return BPy_StrokeAttribute_from_StrokeAttribute( sa ); + return BPy_StrokeAttribute_from_StrokeAttribute_ptr( &(self->sv->attribute()) ); } PyObject * StrokeVertex_curvilinearAbscissa( BPy_StrokeVertex *self ) { diff --git a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp index 206674a20a5..74c91856bbd 100644 --- a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp @@ -165,7 +165,7 @@ PyObject * NonTVertex_castToNonTVertex( BPy_NonTVertex *self ) { PyObject * NonTVertex_svertex( BPy_NonTVertex *self ) { if( self->ntv->svertex() ){ - return BPy_SVertex_from_SVertex(*( self->ntv->svertex() )); + return BPy_SVertex_from_SVertex_ptr( self->ntv->svertex() ); } Py_RETURN_NONE; diff --git a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp index ab8bb72604c..83ec27818fa 100644 --- a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp @@ -155,7 +155,7 @@ PyObject * TVertex_castToTVertex( BPy_TVertex *self ) { PyObject * TVertex_frontSVertex( BPy_TVertex *self ) { if( self->tv->frontSVertex() ){ - return BPy_SVertex_from_SVertex(*( self->tv->frontSVertex() )); + return BPy_SVertex_from_SVertex_ptr( self->tv->frontSVertex() ); } Py_RETURN_NONE; @@ -163,7 +163,7 @@ PyObject * TVertex_frontSVertex( BPy_TVertex *self ) { PyObject * TVertex_backSVertex( BPy_TVertex *self ) { if( self->tv->backSVertex() ){ - return BPy_SVertex_from_SVertex(*( self->tv->backSVertex() )); + return BPy_SVertex_from_SVertex_ptr( self->tv->backSVertex() ); } Py_RETURN_NONE; @@ -219,7 +219,7 @@ PyObject * TVertex_getSVertex( BPy_TVertex *self, PyObject *args) { SVertex *sv = self->tv->getSVertex( ((BPy_FEdge *) py_fe)->fe ); if( sv ){ - return BPy_SVertex_from_SVertex(*( sv )); + return BPy_SVertex_from_SVertex_ptr( sv ); } Py_RETURN_NONE; @@ -235,7 +235,7 @@ PyObject * TVertex_mate( BPy_TVertex *self, PyObject *args) { ViewEdge *ve = self->tv->mate( ((BPy_ViewEdge *) py_ve)->ve ); if( ve ){ - return BPy_ViewEdge_from_ViewEdge(*( ve )); + return BPy_ViewEdge_from_ViewEdge_ptr( ve ); } Py_RETURN_NONE; diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp index 369dd7c61a5..0718c18b253 100644 --- a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp @@ -185,7 +185,7 @@ PyObject * FEdge___copy__( BPy_FEdge *self ) { PyObject * FEdge_vertexA( BPy_FEdge *self ) { if( self->fe->vertexA() ){ - return BPy_SVertex_from_SVertex( *(self->fe->vertexA()) ); + return BPy_SVertex_from_SVertex_ptr( self->fe->vertexA() ); } Py_RETURN_NONE; @@ -193,7 +193,7 @@ PyObject * FEdge_vertexA( BPy_FEdge *self ) { PyObject * FEdge_vertexB( BPy_FEdge *self ) { if( self->fe->vertexB() ){ - return BPy_SVertex_from_SVertex( *(self->fe->vertexB()) ); + return BPy_SVertex_from_SVertex_ptr( self->fe->vertexB() ); } Py_RETURN_NONE; @@ -209,7 +209,7 @@ PyObject * FEdge___getitem__( BPy_FEdge *self, PyObject *args ) { } if( SVertex *v = self->fe->operator[](i) ) - return BPy_SVertex_from_SVertex( *v ); + return BPy_SVertex_from_SVertex_ptr( v ); Py_RETURN_NONE; } @@ -230,7 +230,7 @@ PyObject * FEdge_previousEdge( BPy_FEdge *self ) { PyObject * FEdge_viewedge( BPy_FEdge *self ) { if( ViewEdge *ve = self->fe->viewedge() ) - return BPy_ViewEdge_from_ViewEdge( *ve ); + return BPy_ViewEdge_from_ViewEdge_ptr( ve ); Py_RETURN_NONE; } diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp index 139db9dd73f..9b92ac4a3a0 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp @@ -143,7 +143,7 @@ PyObject * AdjacencyIterator_getObject(BPy_AdjacencyIterator *self) { ViewEdge *ve = self->a_it->operator*(); if( ve ) - return BPy_ViewEdge_from_ViewEdge( *ve ); + return BPy_ViewEdge_from_ViewEdge_ptr( ve ); Py_RETURN_NONE; } diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp index f33fe0e17bc..05822f4c6fe 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp @@ -180,7 +180,7 @@ PyObject * ChainingIterator_getObject( BPy_ChainingIterator *self) { ViewEdge *ve = self->c_it->operator*(); if( ve ) - return BPy_ViewEdge_from_ViewEdge( *ve ); + return BPy_ViewEdge_from_ViewEdge_ptr( ve ); Py_RETURN_NONE; } diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp index 383480b8a9d..c10d3406909 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp @@ -160,7 +160,12 @@ PyObject * SVertexIterator_u( BPy_SVertexIterator *self ) { } PyObject * SVertexIterator_getObject( BPy_SVertexIterator *self) { - return BPy_SVertex_from_SVertex( self->sv_it->operator*() ); + SVertex *sv = self->sv_it->operator->(); + + if( sv ) + return BPy_SVertex_from_SVertex_ptr( sv ); + + Py_RETURN_NONE; } diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp index 0b1554a1cb7..1994cb9ce6d 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp @@ -155,7 +155,11 @@ PyObject * StrokeVertexIterator_castToInterface0DIterator( BPy_StrokeVertexItera } PyObject * StrokeVertexIterator_getObject( BPy_StrokeVertexIterator *self) { - return BPy_StrokeVertex_from_StrokeVertex( self->sv_it->operator*() ); + StrokeVertex *sv = self->sv_it->operator->(); + if( sv ) + return BPy_StrokeVertex_from_StrokeVertex_ptr( sv ); + + Py_RETURN_NONE; } diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp index 0547c173249..16e2750f4a7 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp @@ -150,7 +150,7 @@ int ViewEdgeIterator___init__(BPy_ViewEdgeIterator *self, PyObject *args ) PyObject *ViewEdgeIterator_getCurrentEdge( BPy_ViewEdgeIterator *self ) { if( self->ve_it->getCurrentEdge() ) - return BPy_ViewEdge_from_ViewEdge(*( self->ve_it->getCurrentEdge() )); + return BPy_ViewEdge_from_ViewEdge_ptr( self->ve_it->getCurrentEdge() ); Py_RETURN_NONE; } @@ -171,7 +171,7 @@ PyObject *ViewEdgeIterator_setCurrentEdge( BPy_ViewEdgeIterator *self, PyObject PyObject *ViewEdgeIterator_getBegin( BPy_ViewEdgeIterator *self ) { if( self->ve_it->getBegin() ) - return BPy_ViewEdge_from_ViewEdge(*( self->ve_it->getBegin() )); + return BPy_ViewEdge_from_ViewEdge_ptr( self->ve_it->getBegin() ); Py_RETURN_NONE; } @@ -216,7 +216,7 @@ PyObject * ViewEdgeIterator_getObject( BPy_ViewEdgeIterator *self) { ViewEdge *ve = self->ve_it->operator*(); if( ve ) - return BPy_ViewEdge_from_ViewEdge( *ve ); + return BPy_ViewEdge_from_ViewEdge_ptr( ve ); Py_RETURN_NONE; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp new file mode 100644 index 00000000000..80acce599ca --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp @@ -0,0 +1,120 @@ +#include "BPy_SmoothingShader.h" + +#include "../../stroke/AdvancedStrokeShaders.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +/*--------------- Python API function prototypes for SmoothingShader instance -----------*/ + static int SmoothingShader___init__( BPy_SmoothingShader* self, PyObject *args); + +/*-----------------------BPy_SmoothingShader type definition ------------------------------*/ + +PyTypeObject SmoothingShader_Type = { + PyObject_HEAD_INIT( NULL ) + 0, /* ob_size */ + "SmoothingShader", /* tp_name */ + sizeof( BPy_SmoothingShader ), /* tp_basicsize */ + 0, /* tp_itemsize */ + + /* methods */ + NULL, /* tp_dealloc */ + NULL, /* printfunc tp_print; */ + NULL, /* getattrfunc tp_getattr; */ + NULL, /* setattrfunc tp_setattr; */ + NULL, /* tp_compare */ + NULL, /* tp_repr */ + + /* Method suites for standard classes */ + + NULL, /* PyNumberMethods *tp_as_number; */ + NULL, /* PySequenceMethods *tp_as_sequence; */ + NULL, /* PyMappingMethods *tp_as_mapping; */ + + /* More standard operations (here for binary compatibility) */ + + NULL, /* hashfunc tp_hash; */ + NULL, /* ternaryfunc tp_call; */ + NULL, /* reprfunc tp_str; */ + NULL, /* getattrofunc tp_getattro; */ + NULL, /* setattrofunc tp_setattro; */ + + /* Functions to access object as input/output buffer */ + NULL, /* PyBufferProcs *tp_as_buffer; */ + + /*** Flags to define presence of optional/expanded features ***/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */ + + NULL, /* char *tp_doc; Documentation string */ + /*** Assigned meaning in release 2.0 ***/ + /* call function for all accessible objects */ + NULL, /* traverseproc tp_traverse; */ + + /* delete references to contained objects */ + NULL, /* inquiry tp_clear; */ + + /*** Assigned meaning in release 2.1 ***/ + /*** rich comparisons ***/ + NULL, /* richcmpfunc tp_richcompare; */ + + /*** weak reference enabler ***/ + 0, /* long tp_weaklistoffset; */ + + /*** Added in release 2.2 ***/ + /* Iterators */ + NULL, /* getiterfunc tp_iter; */ + NULL, /* iternextfunc tp_iternext; */ + + /*** Attribute descriptor and subclassing stuff ***/ + NULL, /* struct PyMethodDef *tp_methods; */ + NULL, /* struct PyMemberDef *tp_members; */ + NULL, /* struct PyGetSetDef *tp_getset; */ + &StrokeShader_Type, /* struct _typeobject *tp_base; */ + NULL, /* PyObject *tp_dict; */ + NULL, /* descrgetfunc tp_descr_get; */ + NULL, /* descrsetfunc tp_descr_set; */ + 0, /* long tp_dictoffset; */ + (initproc)SmoothingShader___init__, /* initproc tp_init; */ + NULL, /* allocfunc tp_alloc; */ + NULL, /* newfunc tp_new; */ + + /* Low-level free-memory routine */ + NULL, /* freefunc tp_free; */ + + /* For PyObject_IS_GC */ + NULL, /* inquiry tp_is_gc; */ + NULL, /* PyObject *tp_bases; */ + + /* method resolution order */ + NULL, /* PyObject *tp_mro; */ + NULL, /* PyObject *tp_cache; */ + NULL, /* PyObject *tp_subclasses; */ + NULL, /* PyObject *tp_weaklist; */ + NULL +}; + +//------------------------INSTANCE METHODS ---------------------------------- + +int SmoothingShader___init__( BPy_SmoothingShader* self, PyObject *args) +{ + int i1; + double d2, d3, d4, d5, d6, d7, d8; + + if(!( PyArg_ParseTuple(args, "iddddddd", &i1, &d2, &d3, &d4, &d5, &d6, &d7, &d8) )) { + cout << "ERROR: SmoothingShader___init__" << endl; + return -1; + } + + self->py_ss.ss = new SmoothingShader::SmoothingShader(i1, d2, d3, d4, d5, d6, d7, d8); + return 0; + +} + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.h new file mode 100644 index 00000000000..18d6ca3cc30 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHONSMOOTHINGSHADER_H +#define FREESTYLE_PYTHONSMOOTHINGSHADER_H + +#include "../BPy_StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject SmoothingShader_Type; + +#define BPy_SmoothingShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &SmoothingShader_Type) ) + +/*---------------------------Python BPy_SmoothingShader structure definition----------*/ +typedef struct { + BPy_StrokeShader py_ss; +} BPy_SmoothingShader; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHONSMOOTHINGSHADER_H */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp index 272884e1645..f8780b7baee 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp @@ -107,7 +107,7 @@ int SpatialNoiseShader___init__( BPy_SpatialNoiseShader* self, PyObject *args) if(!( PyArg_ParseTuple(args, "ffiOO", &f1, &f2, &i3, &obj4, &obj5) - && PyList_Check(obj4) && PyBool_Check(obj5) )) { + && PyBool_Check(obj4) && PyBool_Check(obj5) )) { cout << "ERROR: SpatialNoiseShader___init__" << endl; return -1; } diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureShader.cpp index 4d5a56db24b..480a5b2d2ff 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureShader.cpp @@ -105,7 +105,7 @@ int StrokeTextureShader___init__( BPy_StrokeTextureShader* self, PyObject *args) const char *s1; PyObject *obj2 = 0, *obj3 = 0; - if(!( PyArg_ParseTuple(args, "s|00", &s1, &obj2, &obj3) )) { + if(!( PyArg_ParseTuple(args, "s|OO", &s1, &obj2, &obj3) )) { cout << "ERROR: StrokeTextureShader___init__" << endl; return -1; } |