diff options
Diffstat (limited to 'source/blender')
22 files changed, 228 insertions, 212 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_Convert.cpp b/source/blender/freestyle/intern/python/BPy_Convert.cpp index 332f6061c8f..68b4b9d2e21 100644 --- a/source/blender/freestyle/intern/python/BPy_Convert.cpp +++ b/source/blender/freestyle/intern/python/BPy_Convert.cpp @@ -83,6 +83,23 @@ PyObject * BPy_Id_from_Id( Id& id ) { } PyObject * BPy_Interface0D_from_Interface0D( Interface0D& if0D ) { + if (typeid(if0D) == typeid(CurvePoint)) { + return BPy_CurvePoint_from_CurvePoint_ptr(dynamic_cast<CurvePoint*>(&if0D)); + } else if (typeid(if0D) == typeid(StrokeVertex)) { + return BPy_StrokeVertex_from_StrokeVertex_ptr(dynamic_cast<StrokeVertex*>(&if0D)); + } else if (typeid(if0D) == typeid(SVertex)) { + return BPy_SVertex_from_SVertex_ptr(dynamic_cast<SVertex*>(&if0D)); + } else if (typeid(if0D) == typeid(ViewVertex)) { + return BPy_ViewVertex_from_ViewVertex_ptr(dynamic_cast<ViewVertex*>(&if0D)); + } else if (typeid(if0D) == typeid(NonTVertex)) { + return BPy_NonTVertex_from_NonTVertex_ptr(dynamic_cast<NonTVertex*>(&if0D)); + } else if (typeid(if0D) == typeid(TVertex)) { + return BPy_TVertex_from_TVertex_ptr(dynamic_cast<TVertex*>(&if0D)); + } else if (typeid(if0D) != typeid(Interface0D)) { + string msg("unexpected type: " + if0D.getExactTypeName()); + PyErr_SetString(PyExc_TypeError, msg.c_str()); + return NULL; + } PyObject *py_if0D = Interface0D_Type.tp_new( &Interface0D_Type, 0, 0 ); ((BPy_Interface0D *) py_if0D)->if0D = &if0D; @@ -90,6 +107,17 @@ PyObject * BPy_Interface0D_from_Interface0D( Interface0D& if0D ) { } PyObject * BPy_Interface1D_from_Interface1D( Interface1D& if1D ) { + if (typeid(if1D) == typeid(ViewEdge)) { + return BPy_ViewEdge_from_ViewEdge_ptr(dynamic_cast<ViewEdge*>(&if1D)); + } else if (typeid(if1D) == typeid(Chain)) { + return BPy_Chain_from_Chain_ptr(dynamic_cast<Chain*>(&if1D)); + } else if (typeid(if1D) == typeid(Stroke)) { + return BPy_Stroke_from_Stroke_ptr(dynamic_cast<Stroke*>(&if1D)); + } else if (typeid(if1D) != typeid(Interface1D)) { + string msg("unexpected type: " + if1D.getExactTypeName()); + PyErr_SetString(PyExc_TypeError, msg.c_str()); + return NULL; + } PyObject *py_if1D = Interface1D_Type.tp_new( &Interface1D_Type, 0, 0 ); ((BPy_Interface1D *) py_if1D)->if1D = &if1D; @@ -281,10 +309,11 @@ PyObject * BPy_AdjacencyIterator_from_AdjacencyIterator( AdjacencyIterator& a_it return py_a_it; } -PyObject * BPy_Interface0DIterator_from_Interface0DIterator( Interface0DIterator& if0D_it ) { +PyObject * BPy_Interface0DIterator_from_Interface0DIterator( Interface0DIterator& if0D_it, int reversed ) { PyObject *py_if0D_it = Interface0DIterator_Type.tp_new( &Interface0DIterator_Type, 0, 0 ); ((BPy_Interface0DIterator *) py_if0D_it)->if0D_it = new Interface0DIterator( if0D_it ); ((BPy_Interface0DIterator *) py_if0D_it)->py_it.it = ((BPy_Interface0DIterator *) py_if0D_it)->if0D_it; + ((BPy_Interface0DIterator *) py_if0D_it)->reversed = reversed; return py_if0D_it; } @@ -315,10 +344,11 @@ PyObject * BPy_SVertexIterator_from_SVertexIterator( ViewEdgeInternal::SVertexIt } -PyObject * BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ViewVertexInternal::orientedViewEdgeIterator& ove_it ) { +PyObject * BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ViewVertexInternal::orientedViewEdgeIterator& ove_it, int reversed ) { PyObject *py_ove_it = orientedViewEdgeIterator_Type.tp_new( &orientedViewEdgeIterator_Type, 0, 0 ); ((BPy_orientedViewEdgeIterator *) py_ove_it)->ove_it = new ViewVertexInternal::orientedViewEdgeIterator( ove_it ); ((BPy_orientedViewEdgeIterator *) py_ove_it)->py_it.it = ((BPy_orientedViewEdgeIterator *) py_ove_it)->ove_it; + ((BPy_orientedViewEdgeIterator *) py_ove_it)->reversed = reversed; return py_ove_it; } diff --git a/source/blender/freestyle/intern/python/BPy_Convert.h b/source/blender/freestyle/intern/python/BPy_Convert.h index 3d298c0db9a..70d8a4d9cfc 100644 --- a/source/blender/freestyle/intern/python/BPy_Convert.h +++ b/source/blender/freestyle/intern/python/BPy_Convert.h @@ -97,11 +97,11 @@ PyObject * BPy_Chain_from_Chain_ptr( Chain* c ); PyObject * BPy_ViewShape_from_ViewShape( ViewShape& vs ); PyObject * BPy_AdjacencyIterator_from_AdjacencyIterator( AdjacencyIterator& a_it ); -PyObject * BPy_Interface0DIterator_from_Interface0DIterator( Interface0DIterator& if0D_it ); +PyObject * BPy_Interface0DIterator_from_Interface0DIterator( Interface0DIterator& if0D_it, int reversed ); PyObject * BPy_CurvePointIterator_from_CurvePointIterator( CurveInternal::CurvePointIterator& cp_it ); PyObject * BPy_StrokeVertexIterator_from_StrokeVertexIterator( StrokeInternal::StrokeVertexIterator& sv_it, int reversed); PyObject * BPy_SVertexIterator_from_SVertexIterator( ViewEdgeInternal::SVertexIterator& sv_it ); -PyObject * BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ViewVertexInternal::orientedViewEdgeIterator& ove_it ); +PyObject * BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ViewVertexInternal::orientedViewEdgeIterator& ove_it, int reversed ); PyObject * BPy_ViewEdgeIterator_from_ViewEdgeIterator( ViewEdgeInternal::ViewEdgeIterator& ve_it ); PyObject * BPy_ChainingIterator_from_ChainingIterator( ChainingIterator& c_it ); PyObject * BPy_ChainPredicateIterator_from_ChainPredicateIterator( ChainPredicateIterator& cp_it ); diff --git a/source/blender/freestyle/intern/python/BPy_Interface1D.cpp b/source/blender/freestyle/intern/python/BPy_Interface1D.cpp index c6d6e75d897..613a4f180cc 100644 --- a/source/blender/freestyle/intern/python/BPy_Interface1D.cpp +++ b/source/blender/freestyle/intern/python/BPy_Interface1D.cpp @@ -256,12 +256,12 @@ PyObject *Interface1D_setTimeStamp( BPy_Interface1D *self, PyObject *args) { PyObject * Interface1D_verticesBegin( BPy_Interface1D *self ) { Interface0DIterator if0D_it( self->if1D->verticesBegin() ); - return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 0 ); } PyObject * Interface1D_verticesEnd( BPy_Interface1D *self ) { Interface0DIterator if0D_it( self->if1D->verticesEnd() ); - return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 1 ); } @@ -272,7 +272,7 @@ PyObject * Interface1D_pointsBegin( BPy_Interface1D *self, PyObject *args ) { return NULL; Interface0DIterator if0D_it( self->if1D->pointsBegin(f) ); - return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 0 ); } PyObject * Interface1D_pointsEnd( BPy_Interface1D *self, PyObject *args ) { @@ -282,7 +282,7 @@ PyObject * Interface1D_pointsEnd( BPy_Interface1D *self, PyObject *args ) { return NULL; Interface0DIterator if0D_it( self->if1D->pointsEnd(f) ); - return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 1 ); } /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/blender/freestyle/intern/python/Director.cpp b/source/blender/freestyle/intern/python/Director.cpp index dd4688515a7..45eb9d861e2 100644 --- a/source/blender/freestyle/intern/python/Director.cpp +++ b/source/blender/freestyle/intern/python/Director.cpp @@ -43,88 +43,113 @@ // BinaryPredicate0D: __call__ -int Director_BPy_BinaryPredicate0D___call__( PyObject *obj, Interface0D& i1, Interface0D& i2) { +int Director_BPy_BinaryPredicate0D___call__( BinaryPredicate0D *bp0D, Interface0D& i1, Interface0D& i2 ) { + if (!bp0D->py_bp0D) { // internal error + PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_bp0D) not initialized"); + return -1; + } PyObject *arg1 = BPy_Interface0D_from_Interface0D(i1); PyObject *arg2 = BPy_Interface0D_from_Interface0D(i2); - PyObject *result = PyObject_CallMethod( obj, "__call__", "OO", arg1, arg2 ); + if (!arg1 || !arg2) { + Py_XDECREF(arg1); + Py_XDECREF(arg2); + return -1; + } + PyObject *result = PyObject_CallMethod( bp0D->py_bp0D, "__call__", "OO", arg1, arg2 ); Py_DECREF(arg1); Py_DECREF(arg2); if (!result) return -1; int ret = PyObject_IsTrue(result); Py_DECREF(result); - return ret; + if (ret < 0) + return -1; + bp0D->result = ret; + return 0; } // BinaryPredicate1D: __call__ -int Director_BPy_BinaryPredicate1D___call__( PyObject *obj, Interface1D& i1, Interface1D& i2) { - PyObject *arg1, *arg2; - if (typeid(i1) == typeid(ViewEdge)) { - arg1 = BPy_ViewEdge_from_ViewEdge_ptr(dynamic_cast<ViewEdge*>(&i1)); - arg2 = BPy_ViewEdge_from_ViewEdge_ptr(dynamic_cast<ViewEdge*>(&i2)); - } else if (typeid(i1) == typeid(Chain)) { - arg1 = BPy_Chain_from_Chain_ptr(dynamic_cast<Chain*>(&i1)); - arg2 = BPy_Chain_from_Chain_ptr(dynamic_cast<Chain*>(&i2)); - } else if (typeid(i1) == typeid(Stroke)) { - arg1 = BPy_Stroke_from_Stroke_ptr(dynamic_cast<Stroke*>(&i1)); - arg2 = BPy_Stroke_from_Stroke_ptr(dynamic_cast<Stroke*>(&i2)); - } else { - cerr << "Warning: cast to " + i1.getExactTypeName() + " not implemented" << endl; - arg1 = BPy_Interface1D_from_Interface1D(i1); - arg2 = BPy_Interface1D_from_Interface1D(i2); +int Director_BPy_BinaryPredicate1D___call__( BinaryPredicate1D *bp1D, Interface1D& i1, Interface1D& i2 ) { + if (!bp1D->py_bp1D) { // internal error + PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_bp1D) not initialized"); + return -1; + } + PyObject *arg1 = BPy_Interface1D_from_Interface1D(i1); + PyObject *arg2 = BPy_Interface1D_from_Interface1D(i2); + if (!arg1 || !arg2) { + Py_XDECREF(arg1); + Py_XDECREF(arg2); + return -1; } - PyObject *result = PyObject_CallMethod( obj, "__call__", "OO", arg1, arg2 ); + PyObject *result = PyObject_CallMethod( bp1D->py_bp1D, "__call__", "OO", arg1, arg2 ); Py_DECREF(arg1); Py_DECREF(arg2); if (!result) return -1; int ret = PyObject_IsTrue(result); Py_DECREF(result); - return ret; + if (ret < 0) + return -1; + bp1D->result = ret; + return 0; } // UnaryPredicate0D: __call__ -int Director_BPy_UnaryPredicate0D___call__( PyObject *obj, Interface0DIterator& if0D_it) { - PyObject *arg = BPy_Interface0DIterator_from_Interface0DIterator(if0D_it); - PyObject *result = PyObject_CallMethod( obj, "__call__", "O", arg ); +int Director_BPy_UnaryPredicate0D___call__( UnaryPredicate0D *up0D, Interface0DIterator& if0D_it ) { + if (!up0D->py_up0D) { // internal error + PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_up0D) not initialized"); + return -1; + } + PyObject *arg = BPy_Interface0DIterator_from_Interface0DIterator(if0D_it, 0); + if (!arg) + return -1; + PyObject *result = PyObject_CallMethod( up0D->py_up0D, "__call__", "O", arg ); Py_DECREF(arg); if (!result) return -1; int ret = PyObject_IsTrue(result); Py_DECREF(result); - return ret; + if (ret < 0) + return -1; + up0D->result = ret; + return 0; } // UnaryPredicate1D: __call__ -int Director_BPy_UnaryPredicate1D___call__( PyObject *obj, Interface1D& if1D) { - PyObject *arg; - if (typeid(if1D) == typeid(ViewEdge)) { - arg = BPy_ViewEdge_from_ViewEdge_ptr(dynamic_cast<ViewEdge*>(&if1D)); - } else if (typeid(if1D) == typeid(Chain)) { - arg = BPy_Chain_from_Chain_ptr(dynamic_cast<Chain*>(&if1D)); - } else if (typeid(if1D) == typeid(Stroke)) { - arg = BPy_Stroke_from_Stroke_ptr(dynamic_cast<Stroke*>(&if1D)); - } else { - cerr << "Warning: cast to " + if1D.getExactTypeName() + " not implemented" << endl; - arg = BPy_Interface1D_from_Interface1D(if1D); +int Director_BPy_UnaryPredicate1D___call__( UnaryPredicate1D *up1D, Interface1D& if1D ) { + if (!up1D->py_up1D) { // internal error + PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_up1D) not initialized"); + return -1; } - PyObject *result = PyObject_CallMethod( obj, "__call__", "O", arg ); + PyObject *arg = BPy_Interface1D_from_Interface1D(if1D); + if (!arg) + return -1; + PyObject *result = PyObject_CallMethod( up1D->py_up1D, "__call__", "O", arg ); Py_DECREF(arg); if (!result) return -1; int ret = PyObject_IsTrue(result); Py_DECREF(result); - return ret; + if (ret < 0) + return -1; + up1D->result = ret; + return 0; } // StrokeShader: shade -int Director_BPy_StrokeShader_shade( PyObject *obj, Stroke& s) { +int Director_BPy_StrokeShader_shade( StrokeShader *ss, Stroke& s ) { + if (!ss->py_ss) { // internal error + PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_ss) not initialized"); + return -1; + } PyObject *arg = BPy_Stroke_from_Stroke_ptr(&s); - PyObject *result = PyObject_CallMethod( obj, "shade", "O", arg ); + if (!arg) + return -1; + PyObject *result = PyObject_CallMethod( ss->py_ss, "shade", "O", arg ); Py_DECREF(arg); if (!result) return -1; @@ -133,24 +158,34 @@ int Director_BPy_StrokeShader_shade( PyObject *obj, Stroke& s) { } // ChainingIterator: init, traverse -int Director_BPy_ChainingIterator_init( PyObject *obj ) { - PyObject *result = PyObject_CallMethod( obj, "init", "", 0 ); +int Director_BPy_ChainingIterator_init( ChainingIterator *c_it ) { + if (!c_it->py_c_it) { // internal error + PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_c_it) not initialized"); + return -1; + } + PyObject *result = PyObject_CallMethod( c_it->py_c_it, "init", ""); if (!result) return -1; Py_DECREF(result); return 0; } -int Director_BPy_ChainingIterator_traverse( PyObject *obj, AdjacencyIterator& a_it, ViewEdge **ve ) { +int Director_BPy_ChainingIterator_traverse( ChainingIterator *c_it, AdjacencyIterator& a_it ) { + if (!c_it->py_c_it) { // internal error + PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_c_it) not initialized"); + return -1; + } PyObject *arg = BPy_AdjacencyIterator_from_AdjacencyIterator(a_it); - PyObject *result = PyObject_CallMethod( obj, "traverse", "O", arg ); + if (!arg) + return -1; + PyObject *result = PyObject_CallMethod( c_it->py_c_it, "traverse", "O", arg ); Py_DECREF(arg); if (!result) return -1; if (BPy_ViewEdge_Check(result)) { - *ve = ((BPy_ViewEdge *) result)->ve; + c_it->result = ((BPy_ViewEdge *) result)->ve; } else if (result == Py_None) { - *ve = NULL; + c_it->result = NULL; } else { PyErr_SetString(PyExc_RuntimeError, "traverse method returned a wrong value"); Py_DECREF(result); @@ -164,7 +199,13 @@ int Director_BPy_ChainingIterator_traverse( PyObject *obj, AdjacencyIterator& a_ // BPy_UnaryFunction{0D,1D}: __call__ int Director_BPy_UnaryFunction0D___call__( void *uf0D, PyObject *obj, Interface0DIterator& if0D_it) { - PyObject *arg = BPy_Interface0DIterator_from_Interface0DIterator(if0D_it); + if (!obj) { // internal error + PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_uf0D) not initialized"); + return -1; + } + PyObject *arg = BPy_Interface0DIterator_from_Interface0DIterator(if0D_it, 0); + if (!arg) + return -1; PyObject *result = PyObject_CallMethod( obj, "__call__", "O", arg ); Py_DECREF(arg); if (!result) @@ -218,7 +259,13 @@ int Director_BPy_UnaryFunction0D___call__( void *uf0D, PyObject *obj, Interface0 int Director_BPy_UnaryFunction1D___call__( void *uf1D, PyObject *obj, Interface1D& if1D) { + if (!obj) { // internal error + PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_uf1D) not initialized"); + return -1; + } PyObject *arg = BPy_Interface1D_from_Interface1D(if1D); + if (!arg) + return -1; PyObject *result = PyObject_CallMethod( obj, "__call__", "O", arg ); Py_DECREF(arg); if (!result) diff --git a/source/blender/freestyle/intern/python/Director.h b/source/blender/freestyle/intern/python/Director.h index eecab146a5d..ccce8280cb4 100644 --- a/source/blender/freestyle/intern/python/Director.h +++ b/source/blender/freestyle/intern/python/Director.h @@ -4,6 +4,11 @@ #include "../geometry/Geom.h" #include "../winged_edge/Nature.h" +class UnaryPredicate0D; +class UnaryPredicate1D; +class BinaryPredicate0D; +class BinaryPredicate1D; +class ChainingIterator; class AdjacencyIterator; class FEdge; class Id; @@ -12,6 +17,7 @@ class Interface1D; class Interface0DIterator; class NonTVertex; class Stroke; +class StrokeShader; class SVertex; class TVertex; class ViewEdge; @@ -29,10 +35,10 @@ extern "C" { #endif // BinaryPredicate0D: __call__ -int Director_BPy_BinaryPredicate0D___call__( PyObject *obj, Interface0D& i1, Interface0D& i2); +int Director_BPy_BinaryPredicate0D___call__( BinaryPredicate0D *bp0D, Interface0D& i1, Interface0D& i2 ); // BinaryPredicate1D: __call__ -int Director_BPy_BinaryPredicate1D___call__( PyObject *obj, Interface1D& i1, Interface1D& i2); +int Director_BPy_BinaryPredicate1D___call__( BinaryPredicate1D *bp1D, 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 ); @@ -65,13 +71,13 @@ int Director_BPy_UnaryFunction0D___call__( void *uf0D, PyObject *obj, Interface0 int Director_BPy_UnaryFunction1D___call__( void *uf1D, PyObject *obj, Interface1D& if1D); // UnaryPredicate0D: __call__ -int Director_BPy_UnaryPredicate0D___call__( PyObject *obj, Interface0DIterator& if0D_it); +int Director_BPy_UnaryPredicate0D___call__( UnaryPredicate0D *up0D, Interface0DIterator& if0D_it ); // UnaryPredicate1D: __call__ -int Director_BPy_UnaryPredicate1D___call__( PyObject *obj, Interface1D& if1D); +int Director_BPy_UnaryPredicate1D___call__( UnaryPredicate1D *up1D, Interface1D& if1D ); // StrokeShader: shade -int Director_BPy_StrokeShader_shade( PyObject *obj, Stroke& s); +int Director_BPy_StrokeShader_shade( StrokeShader *ss, Stroke& s ); // Iterator: increment, decrement, isBegin, isEnd void Director_BPy_Iterator_increment( PyObject *obj ); @@ -80,8 +86,8 @@ bool Director_BPy_Iterator_isBegin( PyObject *obj ); bool Director_BPy_Iterator_isEnd( PyObject *obj ); // ChainingIterator: init, traverse -int Director_BPy_ChainingIterator_init( PyObject *obj ); -int Director_BPy_ChainingIterator_traverse( PyObject *obj, AdjacencyIterator& a_it, ViewEdge **ve ); +int Director_BPy_ChainingIterator_init( ChainingIterator *c_it ); +int Director_BPy_ChainingIterator_traverse( ChainingIterator *c_it, AdjacencyIterator& a_it ); diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp index 660125a1251..3d30f38514b 100644 --- a/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp @@ -145,7 +145,7 @@ PyObject * ViewVertex_edgesBegin( BPy_ViewVertex *self ) { Py_RETURN_NONE; ViewVertexInternal::orientedViewEdgeIterator ove_it( self->vv->edgesBegin() ); - return BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ove_it ); + return BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ove_it, 0 ); } PyObject * ViewVertex_edgesEnd( BPy_ViewVertex *self ) { @@ -153,7 +153,7 @@ PyObject * ViewVertex_edgesEnd( BPy_ViewVertex *self ) { Py_RETURN_NONE; ViewVertexInternal::orientedViewEdgeIterator ove_it( self->vv->edgesEnd() ); - return BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ove_it ); + return BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ove_it, 1 ); } @@ -168,7 +168,7 @@ PyObject * ViewVertex_edgesIterator( BPy_ViewVertex *self, PyObject *args ) { ViewEdge *ve = ((BPy_ViewEdge *) py_ve)->ve; ViewVertexInternal::orientedViewEdgeIterator ove_it( self->vv->edgesIterator( ve ) ); - return BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ove_it ); + return BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ove_it, 0 ); } diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp index 84529321f29..4e646de18e6 100644 --- a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp @@ -341,12 +341,12 @@ PyObject *FEdge_setSmooth( BPy_FEdge *self , PyObject *args) { PyObject * FEdge_verticesBegin( BPy_FEdge *self ) { Interface0DIterator if0D_it( self->fe->verticesBegin() ); - return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 0 ); } PyObject * FEdge_verticesEnd( BPy_FEdge *self ) { Interface0DIterator if0D_it( self->fe->verticesEnd() ); - return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 1 ); } @@ -357,7 +357,7 @@ PyObject * FEdge_pointsBegin( BPy_FEdge *self, PyObject *args ) { return NULL; Interface0DIterator if0D_it( self->fe->pointsBegin(f) ); - return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 0 ); } PyObject * FEdge_pointsEnd( BPy_FEdge *self, PyObject *args ) { @@ -367,7 +367,7 @@ PyObject * FEdge_pointsEnd( BPy_FEdge *self, PyObject *args ) { return NULL; Interface0DIterator if0D_it( self->fe->pointsEnd(f) ); - return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 1 ); } /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp index 541391e05a7..a44e2feed5b 100644 --- a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp @@ -204,12 +204,12 @@ PyObject * FrsCurve_nSegments( BPy_FrsCurve *self ) { PyObject * FrsCurve_verticesBegin( BPy_FrsCurve *self ) { Interface0DIterator if0D_it( self->c->verticesBegin() ); - return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 0 ); } PyObject * FrsCurve_verticesEnd( BPy_FrsCurve *self ) { Interface0DIterator if0D_it( self->c->verticesEnd() ); - return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 1 ); } @@ -220,7 +220,7 @@ PyObject * FrsCurve_pointsBegin( BPy_FrsCurve *self, PyObject *args ) { return NULL; Interface0DIterator if0D_it( self->c->pointsBegin(f) ); - return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 0 ); } PyObject * FrsCurve_pointsEnd( BPy_FrsCurve *self, PyObject *args ) { @@ -230,7 +230,7 @@ PyObject * FrsCurve_pointsEnd( BPy_FrsCurve *self, PyObject *args ) { return NULL; Interface0DIterator if0D_it( self->c->pointsEnd(f) ); - return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 1 ); } diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp index 722e1d376ae..89b9478212f 100644 --- a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp @@ -383,12 +383,12 @@ PyObject * Stroke_strokeVerticesSize( BPy_Stroke *self ) { PyObject * Stroke_verticesBegin( BPy_Stroke *self ) { Interface0DIterator if0D_it( self->s->verticesBegin() ); - return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 0 ); } PyObject * Stroke_verticesEnd( BPy_Stroke *self ) { Interface0DIterator if0D_it( self->s->verticesEnd() ); - return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 1 ); } PyObject * Stroke_pointsBegin( BPy_Stroke *self , PyObject *args) { @@ -398,7 +398,7 @@ PyObject * Stroke_pointsBegin( BPy_Stroke *self , PyObject *args) { return NULL; Interface0DIterator if0D_it( self->s->pointsBegin(f) ); - return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 0 ); } PyObject * Stroke_pointsEnd( BPy_Stroke *self , PyObject *args) { @@ -408,7 +408,7 @@ PyObject * Stroke_pointsEnd( BPy_Stroke *self , PyObject *args) { return NULL; Interface0DIterator if0D_it( self->s->pointsEnd(f) ); - return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 1 ); } /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp index 28280a0723f..958d96031e3 100644 --- a/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp @@ -345,12 +345,12 @@ PyObject * ViewEdge_setQI( BPy_ViewEdge *self, PyObject *args ) { PyObject * ViewEdge_verticesBegin( BPy_ViewEdge *self ) { Interface0DIterator if0D_it( self->ve->verticesBegin() ); - return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 0 ); } PyObject * ViewEdge_verticesEnd( BPy_ViewEdge *self ) { Interface0DIterator if0D_it( self->ve->verticesEnd() ); - return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 1 ); } @@ -361,7 +361,7 @@ PyObject * ViewEdge_pointsBegin( BPy_ViewEdge *self, PyObject *args ) { return NULL; Interface0DIterator if0D_it( self->ve->pointsBegin(f) ); - return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 0 ); } PyObject * ViewEdge_pointsEnd( BPy_ViewEdge *self, PyObject *args ) { @@ -371,7 +371,7 @@ PyObject * ViewEdge_pointsEnd( BPy_ViewEdge *self, PyObject *args ) { return NULL; Interface0DIterator if0D_it( self->ve->pointsEnd(f) ); - return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 1 ); } PyObject * ViewEdge_qi( BPy_ViewEdge *self ) { diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp index ad276a7521b..490c8fdf70f 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp @@ -152,7 +152,7 @@ PyObject * CurvePointIterator_u( BPy_CurvePointIterator *self ) { PyObject * CurvePointIterator_castToInterface0DIterator( BPy_CurvePointIterator *self ) { Interface0DIterator it( self->cp_it->castToInterface0DIterator() ); - return BPy_Interface0DIterator_from_Interface0DIterator( it ); + return BPy_Interface0DIterator_from_Interface0DIterator( it, 0 ); } PyObject * CurvePointIterator_getObject(BPy_CurvePointIterator *self) { diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp index 096baad2936..4a9d601de25 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp @@ -10,6 +10,7 @@ extern "C" { /*--------------- Python API function prototypes for Interface0DIterator instance -----------*/ static int Interface0DIterator___init__(BPy_Interface0DIterator *self, PyObject *args); +static PyObject * Interface0DIterator_iternext( BPy_Interface0DIterator *self ); static PyObject * Interface0DIterator_t( BPy_Interface0DIterator *self ); static PyObject * Interface0DIterator_u( BPy_Interface0DIterator *self ); @@ -78,8 +79,8 @@ PyTypeObject Interface0DIterator_Type = { /*** Added in release 2.2 ***/ /* Iterators */ - NULL, /* getiterfunc tp_iter; */ - NULL, /* iternextfunc tp_iternext; */ + PyObject_SelfIter, /* getiterfunc tp_iter; */ + (iternextfunc)Interface0DIterator_iternext, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ BPy_Interface0DIterator_methods, /* struct PyMethodDef *tp_methods; */ @@ -123,10 +124,31 @@ int Interface0DIterator___init__(BPy_Interface0DIterator *self, PyObject *args ) self->if0D_it = new Interface0DIterator(*( ((BPy_Interface0DIterator *) obj)->if0D_it )); self->py_it.it = self->if0D_it; + self->reversed = 0; return 0; } +PyObject * Interface0DIterator_iternext( BPy_Interface0DIterator *self ) { + Interface0D *if0D; + if (self->reversed) { + if (self->if0D_it->isBegin()) { + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + self->if0D_it->decrement(); + if0D = self->if0D_it->operator->(); + } else { + if (self->if0D_it->isEnd()) { + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + if0D = self->if0D_it->operator->(); + self->if0D_it->increment(); + } + return BPy_Interface0D_from_Interface0D( *if0D ); +} + PyObject * Interface0DIterator_t( BPy_Interface0DIterator *self ) { return PyFloat_FromDouble( self->if0D_it->t() ); } @@ -136,23 +158,7 @@ PyObject * Interface0DIterator_u( BPy_Interface0DIterator *self ) { } PyObject * Interface0DIterator_getObject(BPy_Interface0DIterator *self) { - Interface0D &if0D = self->if0D_it->operator*(); - if (typeid(if0D) == typeid(CurvePoint)) { - return BPy_CurvePoint_from_CurvePoint_ptr(dynamic_cast<CurvePoint*>(&if0D)); - } else if (typeid(if0D) == typeid(StrokeVertex)) { - return BPy_StrokeVertex_from_StrokeVertex_ptr(dynamic_cast<StrokeVertex*>(&if0D)); - } else if (typeid(if0D) == typeid(SVertex)) { - return BPy_SVertex_from_SVertex_ptr(dynamic_cast<SVertex*>(&if0D)); - } else if (typeid(if0D) == typeid(ViewVertex)) { - return BPy_ViewVertex_from_ViewVertex_ptr(dynamic_cast<ViewVertex*>(&if0D)); - } else if (typeid(if0D) == typeid(NonTVertex)) { - return BPy_NonTVertex_from_NonTVertex_ptr(dynamic_cast<NonTVertex*>(&if0D)); - } else if (typeid(if0D) == typeid(TVertex)) { - return BPy_TVertex_from_TVertex_ptr(dynamic_cast<TVertex*>(&if0D)); - } else { - cerr << "Warning: cast to " << if0D.getExactTypeName() << " not implemented" << endl; - return BPy_Interface0D_from_Interface0D(if0D); - } + return BPy_Interface0D_from_Interface0D( self->if0D_it->operator*() ); } diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.h index c829d3d9d31..1972763b2eb 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.h +++ b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.h @@ -21,6 +21,7 @@ extern PyTypeObject Interface0DIterator_Type; typedef struct { BPy_Iterator py_it; Interface0DIterator *if0D_it; + int reversed; } BPy_Interface0DIterator; /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp index c6240b527d0..86af40ebc36 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp @@ -137,6 +137,7 @@ int StrokeVertexIterator___init__(BPy_StrokeVertexIterator *self, PyObject *args } self->py_it.it = self->sv_it; + self->reversed = 0; return 0; } @@ -171,7 +172,7 @@ PyObject * StrokeVertexIterator_u( BPy_StrokeVertexIterator *self ) { PyObject * StrokeVertexIterator_castToInterface0DIterator( BPy_StrokeVertexIterator *self ) { Interface0DIterator it( self->sv_it->castToInterface0DIterator() ); - return BPy_Interface0DIterator_from_Interface0DIterator( it ); + return BPy_Interface0DIterator_from_Interface0DIterator( it, 0 ); } PyObject * StrokeVertexIterator_getObject( BPy_StrokeVertexIterator *self) { diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp index 45f6cadeb81..ab7e2cb4e0e 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp @@ -10,6 +10,7 @@ extern "C" { /*--------------- Python API function prototypes for orientedViewEdgeIterator instance -----------*/ static int orientedViewEdgeIterator___init__(BPy_orientedViewEdgeIterator *self, PyObject *args); +static PyObject * orientedViewEdgeIterator_iternext(BPy_orientedViewEdgeIterator *self); static PyObject * orientedViewEdgeIterator_getObject(BPy_orientedViewEdgeIterator *self); @@ -74,8 +75,8 @@ PyTypeObject orientedViewEdgeIterator_Type = { /*** Added in release 2.2 ***/ /* Iterators */ - NULL, /* getiterfunc tp_iter; */ - NULL, /* iternextfunc tp_iternext; */ + PyObject_SelfIter, /* getiterfunc tp_iter; */ + (iternextfunc)orientedViewEdgeIterator_iternext, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ BPy_orientedViewEdgeIterator_methods, /* struct PyMethodDef *tp_methods; */ @@ -124,10 +125,31 @@ int orientedViewEdgeIterator___init__(BPy_orientedViewEdgeIterator *self, PyObje } self->py_it.it = self->ove_it; + self->reversed = 0; return 0; } +PyObject * orientedViewEdgeIterator_iternext( BPy_orientedViewEdgeIterator *self ) { + ViewVertex::directedViewEdge *dve; + if (self->reversed) { + if (self->ove_it->isBegin()) { + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + self->ove_it->decrement(); + dve = self->ove_it->operator->(); + } else { + if (self->ove_it->isEnd()) { + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + dve = self->ove_it->operator->(); + self->ove_it->increment(); + } + return BPy_directedViewEdge_from_directedViewEdge( *dve ); +} + PyObject * orientedViewEdgeIterator_getObject( BPy_orientedViewEdgeIterator *self) { return BPy_directedViewEdge_from_directedViewEdge( self->ove_it->operator*() ); } diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.h index 973d0f2b728..cd9edf1e224 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.h +++ b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.h @@ -22,6 +22,7 @@ extern PyTypeObject orientedViewEdgeIterator_Type; typedef struct { BPy_Iterator py_it; ViewVertexInternal::orientedViewEdgeIterator *ove_it; + int reversed; } BPy_orientedViewEdgeIterator; /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/blender/freestyle/intern/stroke/ChainingIterators.h b/source/blender/freestyle/intern/stroke/ChainingIterators.h index fb04be93b4d..ec093888aea 100755 --- a/source/blender/freestyle/intern/stroke/ChainingIterators.h +++ b/source/blender/freestyle/intern/stroke/ChainingIterators.h @@ -186,16 +186,7 @@ public: * might want to keep. */ virtual int init() { - string name( py_c_it ? PyString_AsString(PyObject_CallMethod(py_c_it, "getExactTypeName", "")) : getExactTypeName() ); - - if( py_c_it && PyObject_HasAttrString(py_c_it, "init") ) { - if (Director_BPy_ChainingIterator_init( py_c_it ) < 0) { - return -1; - } - } else { - cerr << "Warning: " << name << " init() method not implemented" << endl; - } - return 0; + return Director_BPy_ChainingIterator_init( this ); } /*! This method iterates over the potential next @@ -210,16 +201,7 @@ public: * rules by only iterating over the valid ViewEdges. */ virtual int traverse(const AdjacencyIterator &it){ - string name( py_c_it ? PyString_AsString(PyObject_CallMethod(py_c_it, "getExactTypeName", "")) : getExactTypeName() ); - - if( py_c_it && PyObject_HasAttrString(py_c_it, "traverse") ) { - if (Director_BPy_ChainingIterator_traverse(py_c_it, const_cast<AdjacencyIterator &>(it), &result ) < 0) { - return -1; - } - } else { - cerr << "Warning: the " << name << " traverse() method not defined" << endl; - } - return 0; + return Director_BPy_ChainingIterator_traverse( this, const_cast<AdjacencyIterator &>(it) ); } /* accessors */ diff --git a/source/blender/freestyle/intern/stroke/Predicates0D.h b/source/blender/freestyle/intern/stroke/Predicates0D.h index 58aa3e5c86c..2f5d9551b3a 100755 --- a/source/blender/freestyle/intern/stroke/Predicates0D.h +++ b/source/blender/freestyle/intern/stroke/Predicates0D.h @@ -74,18 +74,7 @@ public: * false otherwise. */ virtual int operator()(Interface0DIterator& it) { - string name( py_up0D ? PyString_AsString(PyObject_CallMethod(py_up0D, "getName", "")) : getName() ); - - if( py_up0D && PyObject_HasAttrString(py_up0D, "__call__") ) { - int res = Director_BPy_UnaryPredicate0D___call__(py_up0D, it); - if (res < 0) - return -1; - result = (res == 1); - } else { - cerr << "Warning: " << name << " operator() not implemented" << endl; - result = false; - } - return 0; + return Director_BPy_UnaryPredicate0D___call__(this, it); } }; @@ -129,18 +118,7 @@ public: * \return true or false. */ virtual int operator()(Interface0D& inter1, Interface0D& inter2) { - string name( py_bp0D ? PyString_AsString(PyObject_CallMethod(py_bp0D, "getName", "")) : getName() ); - - if( py_bp0D && PyObject_HasAttrString(py_bp0D, "__call__") ) { - int res = Director_BPy_BinaryPredicate0D___call__(py_bp0D, inter1, inter2); - if (res < 0) - return -1; - result = (res == 1); - } else { - cerr << "Warning: " << name << " operator() not implemented" << endl; - result = false; - } - return 0; + return Director_BPy_BinaryPredicate0D___call__(this, inter1, inter2); } }; diff --git a/source/blender/freestyle/intern/stroke/Predicates1D.h b/source/blender/freestyle/intern/stroke/Predicates1D.h index 6e7ab04783b..6461f6428ab 100755 --- a/source/blender/freestyle/intern/stroke/Predicates1D.h +++ b/source/blender/freestyle/intern/stroke/Predicates1D.h @@ -77,18 +77,7 @@ public: * false otherwise. */ virtual int operator()(Interface1D& inter) { - string name( py_up1D ? PyString_AsString(PyObject_CallMethod(py_up1D, "getName", "")) : getName() ); - - if( py_up1D && PyObject_HasAttrString(py_up1D, "__call__")) { - int res = Director_BPy_UnaryPredicate1D___call__(py_up1D, inter); - if (res < 0) - return -1; - result = (res == 1); - } else { - cerr << "Warning: " << name << " operator() not implemented" << endl; - result = false; - } - return 0; + return Director_BPy_UnaryPredicate1D___call__(this, inter); } }; @@ -131,18 +120,7 @@ public: * \return true or false. */ virtual int operator()(Interface1D& inter1, Interface1D& inter2) { - string name( py_bp1D ? PyString_AsString(PyObject_CallMethod(py_bp1D, "getName", "")) : getName() ); - - if( py_bp1D && PyObject_HasAttrString(py_bp1D, "__call__") ) { - int res = Director_BPy_BinaryPredicate1D___call__(py_bp1D, inter1, inter2); - if (res < 0) - return -1; - result = (res == 1); - } else { - cerr << "Warning: " << name << " operator() not implemented" << endl; - result = false; - } - return 0; + return Director_BPy_BinaryPredicate1D___call__(this, inter1, inter2); } }; diff --git a/source/blender/freestyle/intern/stroke/StrokeShader.h b/source/blender/freestyle/intern/stroke/StrokeShader.h index 031b7cc8acb..63185438e91 100755 --- a/source/blender/freestyle/intern/stroke/StrokeShader.h +++ b/source/blender/freestyle/intern/stroke/StrokeShader.h @@ -116,16 +116,7 @@ public: * as Color, Thickness, Geometry...) */ virtual int shade(Stroke& ioStroke) const { - string name( py_ss ? PyString_AsString(PyObject_CallMethod(py_ss, "getName", "")) : getName() ); - - if( py_ss && PyObject_HasAttrString(py_ss, "shade") ) { - if (Director_BPy_StrokeShader_shade(py_ss, ioStroke) < 0) { - return -1; - } - } else { - cerr << "Warning: " << name << " shade() method not implemented" << endl; - } - return 0; + return Director_BPy_StrokeShader_shade( const_cast<StrokeShader *>(this), ioStroke ); } }; diff --git a/source/blender/freestyle/intern/view_map/Functions0D.h b/source/blender/freestyle/intern/view_map/Functions0D.h index dbd7d558a47..4adbc8a1bf5 100755 --- a/source/blender/freestyle/intern/view_map/Functions0D.h +++ b/source/blender/freestyle/intern/view_map/Functions0D.h @@ -95,16 +95,7 @@ UnaryFunction0D() { py_uf0D = 0;} * \return the result of the function of type T. */ virtual int operator()(Interface0DIterator& iter) { - string name( py_uf0D ? PyString_AsString(PyObject_CallMethod(py_uf0D, "getName", "")) : getName() ); - - if( py_uf0D && PyObject_HasAttrString(py_uf0D, "__call__") ) { - if (Director_BPy_UnaryFunction0D___call__( this, py_uf0D, iter) < 0) { - return -1; - } - } else { - cerr << "Warning: " << name << " operator() not implemented" << endl; - } - return 0; + return Director_BPy_UnaryFunction0D___call__( this, py_uf0D, iter ); } }; diff --git a/source/blender/freestyle/intern/view_map/Functions1D.h b/source/blender/freestyle/intern/view_map/Functions1D.h index 8dbea93dfb0..c4060e0897f 100755 --- a/source/blender/freestyle/intern/view_map/Functions1D.h +++ b/source/blender/freestyle/intern/view_map/Functions1D.h @@ -99,16 +99,7 @@ public: * \return the result of the function of type T. */ virtual int operator()(Interface1D& inter) { - string name( py_uf1D ? PyString_AsString(PyObject_CallMethod(py_uf1D, "getName", "")) : getName() ); - - if( py_uf1D && PyObject_HasAttrString(py_uf1D, "__call__") ) { - if (Director_BPy_UnaryFunction1D___call__( this, py_uf1D, inter) < 0) { - return -1; - } - } else { - cerr << "Warning: " << name << " operator() not implemented" << endl; - } - return 0; + return Director_BPy_UnaryFunction1D___call__( this, py_uf1D, inter ); } /*! Sets the integration method */ @@ -141,17 +132,8 @@ public: } int operator()(Interface1D& inter) { - string name( py_uf1D ? PyString_AsString(PyObject_CallMethod(py_uf1D, "getName", "")) : getName() ); - - if( py_uf1D && PyObject_HasAttrString(py_uf1D, "__call__") ) { - if (Director_BPy_UnaryFunction1D___call__( this, py_uf1D, inter) < 0) { - return -1; - } - } else { - cerr << "Warning: " << name << " operator() not implemented" << endl; - } - return 0; - } + return Director_BPy_UnaryFunction1D___call__( this, py_uf1D, inter ); + } void setIntegrationType(IntegrationType integration) { _integration = integration; } IntegrationType getIntegrationType() const { return _integration; } |