diff options
Diffstat (limited to 'source')
5 files changed, 90 insertions, 8 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_Convert.cpp b/source/blender/freestyle/intern/python/BPy_Convert.cpp index a3777d6415c..1d9dc372bd0 100644 --- a/source/blender/freestyle/intern/python/BPy_Convert.cpp +++ b/source/blender/freestyle/intern/python/BPy_Convert.cpp @@ -9,11 +9,15 @@ #include "Interface0D/CurvePoint/BPy_StrokeVertex.h" #include "Interface0D/BPy_SVertex.h" #include "Interface0D/BPy_ViewVertex.h" +#include "Interface0D/ViewVertex/BPy_NonTVertex.h" +#include "Interface0D/ViewVertex/BPy_TVertex.h" #include "BPy_Interface1D.h" #include "Interface1D/BPy_FEdge.h" #include "Interface1D/BPy_Stroke.h" #include "Interface1D/BPy_ViewEdge.h" #include "Interface1D/Curve/BPy_Chain.h" +#include "Interface1D/FEdge/BPy_FEdgeSharp.h" +#include "Interface1D/FEdge/BPy_FEdgeSmooth.h" #include "BPy_Nature.h" #include "BPy_MediumType.h" #include "BPy_SShape.h" @@ -102,9 +106,22 @@ PyObject * BPy_SVertex_from_SVertex_ptr( SVertex *sv ) { } PyObject * BPy_FEdge_from_FEdge( FEdge& fe ) { - PyObject *py_fe = FEdge_Type.tp_new( &FEdge_Type, 0, 0 ); - ((BPy_FEdge *) py_fe)->fe = new FEdge( fe ); - ((BPy_FEdge *) py_fe)->py_if1D.if1D = ((BPy_FEdge *) py_fe)->fe; + PyObject *py_fe; + if (typeid(fe) == typeid(FEdgeSharp)) { + py_fe = FEdgeSharp_Type.tp_new( &FEdgeSharp_Type, 0, 0 ); + ((BPy_FEdgeSharp *) py_fe)->fes = new FEdgeSharp( dynamic_cast<FEdgeSharp&>(fe) ); + ((BPy_FEdgeSharp *) py_fe)->py_fe.fe = ((BPy_FEdgeSharp *) py_fe)->fes; + ((BPy_FEdgeSharp *) py_fe)->py_fe.py_if1D.if1D = ((BPy_FEdgeSharp *) py_fe)->fes; + } else if (typeid(fe) == typeid(FEdgeSmooth)) { + py_fe = FEdgeSmooth_Type.tp_new( &FEdgeSmooth_Type, 0, 0 ); + ((BPy_FEdgeSmooth *) py_fe)->fes = new FEdgeSmooth( dynamic_cast<FEdgeSmooth&>(fe) ); + ((BPy_FEdgeSmooth *) py_fe)->py_fe.fe = ((BPy_FEdgeSmooth *) py_fe)->fes; + ((BPy_FEdgeSmooth *) py_fe)->py_fe.py_if1D.if1D = ((BPy_FEdgeSmooth *) py_fe)->fes; + } else { + py_fe = FEdge_Type.tp_new( &FEdge_Type, 0, 0 ); + ((BPy_FEdge *) py_fe)->fe = new FEdge( fe ); + ((BPy_FEdge *) py_fe)->py_if1D.if1D = ((BPy_FEdge *) py_fe)->fe; + } return py_fe; } @@ -162,6 +179,24 @@ PyObject * BPy_ViewVertex_from_ViewVertex_ptr( ViewVertex *vv ) { return py_vv; } +PyObject * BPy_NonTVertex_from_NonTVertex_ptr( NonTVertex *ntv ) { + PyObject *py_ntv = NonTVertex_Type.tp_new( &NonTVertex_Type, 0, 0 ); + ((BPy_NonTVertex *) py_ntv)->ntv = ntv; + ((BPy_NonTVertex *) py_ntv)->py_vv.vv = ((BPy_NonTVertex *) py_ntv)->ntv; + ((BPy_NonTVertex *) py_ntv)->py_vv.py_if0D.if0D = ((BPy_NonTVertex *) py_ntv)->ntv; + + return py_ntv; +} + +PyObject * BPy_TVertex_from_TVertex_ptr( TVertex *tv ) { + PyObject *py_tv = TVertex_Type.tp_new( &TVertex_Type, 0, 0 ); + ((BPy_TVertex *) py_tv)->tv = tv; + ((BPy_TVertex *) py_tv)->py_vv.vv = ((BPy_TVertex *) py_tv)->tv; + ((BPy_TVertex *) py_tv)->py_vv.py_if0D.if0D = ((BPy_TVertex *) py_tv)->tv; + + return py_tv; +} + PyObject * BPy_BBox_from_BBox( BBox< Vec3r > &bb ) { PyObject *py_bb = BBox_Type.tp_new( &BBox_Type, 0, 0 ); ((BPy_BBox *) py_bb)->bb = new BBox< Vec3r >( bb ); diff --git a/source/blender/freestyle/intern/python/BPy_Convert.h b/source/blender/freestyle/intern/python/BPy_Convert.h index 099a8ed5804..3d0e3adf235 100644 --- a/source/blender/freestyle/intern/python/BPy_Convert.h +++ b/source/blender/freestyle/intern/python/BPy_Convert.h @@ -90,6 +90,8 @@ 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_NonTVertex_from_NonTVertex_ptr( NonTVertex *ntv ); +PyObject * BPy_TVertex_from_TVertex_ptr( TVertex *tv ); PyObject * BPy_ViewEdge_from_ViewEdge_ptr( ViewEdge *ve ); PyObject * BPy_Chain_from_Chain_ptr( Chain* c ); PyObject * BPy_ViewShape_from_ViewShape( ViewShape& vs ); diff --git a/source/blender/freestyle/intern/python/Director.cpp b/source/blender/freestyle/intern/python/Director.cpp index 84560de67a8..dd4688515a7 100644 --- a/source/blender/freestyle/intern/python/Director.cpp +++ b/source/blender/freestyle/intern/python/Director.cpp @@ -59,8 +59,21 @@ int Director_BPy_BinaryPredicate0D___call__( PyObject *obj, Interface0D& i1, Int // BinaryPredicate1D: __call__ int Director_BPy_BinaryPredicate1D___call__( PyObject *obj, Interface1D& i1, Interface1D& i2) { - PyObject *arg1 = BPy_Interface1D_from_Interface1D(i1); - PyObject *arg2 = BPy_Interface1D_from_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); + } PyObject *result = PyObject_CallMethod( obj, "__call__", "OO", arg1, arg2 ); Py_DECREF(arg1); Py_DECREF(arg2); @@ -87,7 +100,17 @@ int Director_BPy_UnaryPredicate0D___call__( PyObject *obj, Interface0DIterator& // UnaryPredicate1D: __call__ int Director_BPy_UnaryPredicate1D___call__( PyObject *obj, Interface1D& if1D) { - PyObject *arg = BPy_Interface1D_from_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); + } PyObject *result = PyObject_CallMethod( obj, "__call__", "O", arg ); Py_DECREF(arg); if (!result) diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp index db27f343ebc..87d3ef4ecd0 100644 --- a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp @@ -181,7 +181,13 @@ PyObject * SVertex_normalsSize( BPy_SVertex *self ) { } PyObject * SVertex_viewvertex( BPy_SVertex *self ) { - return BPy_ViewVertex_from_ViewVertex_ptr( self->sv->viewvertex() ); + ViewVertex *vv = self->sv->viewvertex(); + if (!vv) + Py_RETURN_NONE; + if (typeid(*vv) == typeid(NonTVertex)) + return BPy_NonTVertex_from_NonTVertex_ptr( dynamic_cast<NonTVertex*>(vv) ); + else + return BPy_TVertex_from_TVertex_ptr( dynamic_cast<TVertex*>(vv) ); } PyObject *SVertex_setPoint3D( BPy_SVertex *self , PyObject *args) { diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp index 5c35aa612a6..096baad2936 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp @@ -136,7 +136,23 @@ PyObject * Interface0DIterator_u( BPy_Interface0DIterator *self ) { } PyObject * Interface0DIterator_getObject(BPy_Interface0DIterator *self) { - return BPy_Interface0D_from_Interface0D( self->if0D_it->operator*() ); + 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); + } } |