Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2009-08-02 20:23:18 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2009-08-02 20:23:18 +0400
commitacf97994bc9b5a9be1fc6cdd3907eaa198719b11 (patch)
treefeda501e6f4429e7eb2515bfeafdc4475e66b2b6 /source/blender/freestyle/intern
parent6d1ad351f3d619eb8c6b509292c3517c93afd51b (diff)
SWIG/directors dependency removal (cont'd)
* Added to python/BPy_Convert.{cpp,h} 4 utility converters below for better introspection-based automatic type conversion. PyObject * Any_BPy_Interface0D_from_Interface0D( Interface0D& if0D ); PyObject * Any_BPy_Interface1D_from_Interface1D( Interface1D& if1D ); PyObject * Any_BPy_FEdge_from_FEdge( FEdge& fe ); PyObject * Any_BPy_ViewVertex_from_ViewVertex( ViewVertex& vv ); There are 4 corresponding converters without the "Any_" prefix. All calls of them in the code base were replaced with these new converters so that the introspection-based automatic conversion would take place universally. * python/BPy_Convert.{cpp,h}: Those C++ to Python converters having had a "_ptr" suffix were renamed to a name without the suffix, and their arguments were changed so as to take a reference (e.g., ViewVertex&) instead of a pointer (e.g., ViewVertex *). The changed converters and their new function prototypes are listed below. These converters now return a Python wrapper object that retains the passed reference, instead of retaining a newly created C++ object by the converters. // Interface0D converters PyObject * BPy_Interface0D_from_Interface0D( Interface0D& if0D ); PyObject * BPy_CurvePoint_from_CurvePoint( CurvePoint& cp ); PyObject * BPy_StrokeVertex_from_StrokeVertex( StrokeVertex& sv ); PyObject * BPy_SVertex_from_SVertex( SVertex& sv ); PyObject * BPy_ViewVertex_from_ViewVertex( ViewVertex& vv ); PyObject * BPy_TVertex_from_TVertex( TVertex& tv ); PyObject * BPy_NonTVertex_from_NonTVertex( NonTVertex& ntv ); // Interface1D converters PyObject * BPy_Interface1D_from_Interface1D( Interface1D& if1D ); PyObject * BPy_Chain_from_Chain( Chain& c ); PyObject * BPy_FEdge_from_FEdge( FEdge& fe ); PyObject * BPy_FEdgeSharp_from_FEdgeSharp( FEdgeSharp& fes ); PyObject * BPy_FEdgeSmooth_from_FEdgeSmooth( FEdgeSmooth& fes ); PyObject * BPy_Stroke_from_Stroke( Stroke& s ); PyObject * BPy_ViewEdge_from_ViewEdge( ViewEdge& ve ); PyObject * BPy_directedViewEdge_from_directedViewEdge( ViewVertex::directedViewEdge& dve ); // some other converters PyObject * BPy_ViewShape_from_ViewShape( ViewShape& vs ); PyObject * BPy_SShape_from_SShape( SShape& ss ); PyObject * BPy_FrsMaterial_from_FrsMaterial( FrsMaterial& m ); PyObject * BPy_StrokeAttribute_from_StrokeAttribute( StrokeAttribute& sa ); * Added a "borrowed" flag to the definitions of Python types being used to wrap C++ components of Freestyle's internal data structures. The flag indicates whether or not a Python wrapper object has a reference to a C++ object that comprises the internal data structures. The deallocation routines of the Python types check this flag and release a wrapped C++ object only when it is not part of the internal data structures. The following files were modified: python/BPy_FrsMaterial.{cpp,h} python/BPy_Interface0D.{cpp,h} python/BPy_Interface1D.{cpp,h} python/BPy_SShape.{cpp,h} python/BPy_StrokeAttribute.{cpp,h} python/BPy_ViewShape.{cpp,h} python/Interface0D/BPy_CurvePoint.cpp python/Interface0D/BPy_SVertex.cpp python/Interface0D/BPy_ViewVertex.cpp python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp python/Interface0D/ViewVertex/BPy_NonTVertex.cpp python/Interface0D/ViewVertex/BPy_TVertex.cpp python/Interface1D/BPy_FEdge.cpp python/Interface1D/BPy_FrsCurve.cpp python/Interface1D/BPy_Stroke.cpp python/Interface1D/BPy_ViewEdge.cpp python/Interface1D/Curve/BPy_Chain.cpp python/Interface1D/FEdge/BPy_FEdgeSharp.cpp python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp * view_map/Interface[01]D.h, python/BPy_Interface[01]D.cpp: Removed from the Interface0D and Interface1D C++ classes a back pointer to a Python wrapper object and all "director" calls. These classes (and their subclasses) are used to build Freestyle's main data structures (such as a view map and strokes) and their class hierarchy is static. Python wrappers of these C++ classes are only used to access the data structures from the Python layer, and not intended to extend the data structures by subclassing the Python wrappers. Without the necessity of subclassing in the Python layer, the back pointer to a wrapping Python object and "director" calls would be useless (actually they were not used at all), so they were all removed. * python/Director.{cpp,h}: Removed the definitions of directors that were no longer used. * stroke/Stroke.{cpp,h}: Removed an (unused) back pointer to a Python wrapper object. * python/BPy_ViewMap.cpp: Fixed a possible null pointer reference. * python/Interface1D/BPy_FEdge.cpp: Fixed parameter checking in FEdge___init__().
Diffstat (limited to 'source/blender/freestyle/intern')
-rw-r--r--source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_Convert.cpp188
-rw-r--r--source/blender/freestyle/intern/python/BPy_Convert.h27
-rw-r--r--source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp4
-rw-r--r--source/blender/freestyle/intern/python/BPy_FrsMaterial.h1
-rw-r--r--source/blender/freestyle/intern/python/BPy_Interface0D.cpp49
-rw-r--r--source/blender/freestyle/intern/python/BPy_Interface0D.h1
-rw-r--r--source/blender/freestyle/intern/python/BPy_Interface1D.cpp4
-rw-r--r--source/blender/freestyle/intern/python/BPy_Interface1D.h1
-rw-r--r--source/blender/freestyle/intern/python/BPy_SShape.cpp10
-rw-r--r--source/blender/freestyle/intern/python/BPy_SShape.h1
-rw-r--r--source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp4
-rw-r--r--source/blender/freestyle/intern/python/BPy_StrokeAttribute.h1
-rw-r--r--source/blender/freestyle/intern/python/BPy_ViewMap.cpp7
-rw-r--r--source/blender/freestyle/intern/python/BPy_ViewShape.cpp11
-rw-r--r--source/blender/freestyle/intern/python/BPy_ViewShape.h1
-rw-r--r--source/blender/freestyle/intern/python/Director.cpp209
-rw-r--r--source/blender/freestyle/intern/python/Director.h47
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp12
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp12
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp1
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp3
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp10
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp19
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp36
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp1
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp3
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp31
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp1
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp1
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp1
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp6
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp7
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp4
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp4
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp12
-rwxr-xr-xsource/blender/freestyle/intern/stroke/Stroke.cpp12
-rwxr-xr-xsource/blender/freestyle/intern/stroke/Stroke.h4
-rwxr-xr-xsource/blender/freestyle/intern/view_map/Interface0D.h171
-rwxr-xr-xsource/blender/freestyle/intern/view_map/Interface1D.h86
42 files changed, 388 insertions, 621 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp b/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp
index f8e4afb2400..7a651dafc02 100644
--- a/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp
+++ b/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp
@@ -144,7 +144,7 @@ ContextFunctions_GetSelectedFEdgeCF( PyObject *self )
{
FEdge *fe = ContextFunctions::GetSelectedFEdgeCF();
if( fe )
- return BPy_FEdge_from_FEdge( *fe );
+ return Any_BPy_FEdge_from_FEdge( *fe );
Py_RETURN_NONE;
}
diff --git a/source/blender/freestyle/intern/python/BPy_Convert.cpp b/source/blender/freestyle/intern/python/BPy_Convert.cpp
index 2eff0b9ed64..cdf20ea4e5f 100644
--- a/source/blender/freestyle/intern/python/BPy_Convert.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Convert.cpp
@@ -82,74 +82,124 @@ PyObject * BPy_Id_from_Id( Id& id ) {
return py_id;
}
-PyObject * BPy_Interface0D_from_Interface0D( Interface0D& if0D ) {
+PyObject * Any_BPy_Interface0D_from_Interface0D( Interface0D& if0D ) {
if (typeid(if0D) == typeid(CurvePoint)) {
- return BPy_CurvePoint_from_CurvePoint_ptr(dynamic_cast<CurvePoint*>(&if0D));
+ return BPy_CurvePoint_from_CurvePoint(dynamic_cast<CurvePoint&>(if0D));
} else if (typeid(if0D) == typeid(StrokeVertex)) {
- return BPy_StrokeVertex_from_StrokeVertex_ptr(dynamic_cast<StrokeVertex*>(&if0D));
+ return BPy_StrokeVertex_from_StrokeVertex(dynamic_cast<StrokeVertex&>(if0D));
} else if (typeid(if0D) == typeid(SVertex)) {
- return BPy_SVertex_from_SVertex_ptr(dynamic_cast<SVertex*>(&if0D));
+ return BPy_SVertex_from_SVertex(dynamic_cast<SVertex&>(if0D));
} else if (typeid(if0D) == typeid(ViewVertex)) {
- return BPy_ViewVertex_from_ViewVertex_ptr(dynamic_cast<ViewVertex*>(&if0D));
+ return BPy_ViewVertex_from_ViewVertex(dynamic_cast<ViewVertex&>(if0D));
} else if (typeid(if0D) == typeid(NonTVertex)) {
- return BPy_NonTVertex_from_NonTVertex_ptr(dynamic_cast<NonTVertex*>(&if0D));
+ return BPy_NonTVertex_from_NonTVertex(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;
+ return BPy_TVertex_from_TVertex(dynamic_cast<TVertex&>(if0D));
+ } else if (typeid(if0D) == typeid(Interface0D)) {
+ return BPy_Interface0D_from_Interface0D(if0D);
+ }
+ string msg("unexpected type: " + if0D.getExactTypeName());
+ PyErr_SetString(PyExc_TypeError, msg.c_str());
+ return NULL;
+}
+
+PyObject * Any_BPy_Interface1D_from_Interface1D( Interface1D& if1D ) {
+ if (typeid(if1D) == typeid(ViewEdge)) {
+ return BPy_ViewEdge_from_ViewEdge(dynamic_cast<ViewEdge&>(if1D));
+ } else if (typeid(if1D) == typeid(Chain)) {
+ return BPy_Chain_from_Chain(dynamic_cast<Chain&>(if1D));
+ } else if (typeid(if1D) == typeid(Stroke)) {
+ return BPy_Stroke_from_Stroke(dynamic_cast<Stroke&>(if1D));
+ } else if (typeid(if1D) == typeid(FEdgeSharp)) {
+ return BPy_FEdgeSharp_from_FEdgeSharp(dynamic_cast<FEdgeSharp&>(if1D));
+ } else if (typeid(if1D) == typeid(FEdgeSmooth)) {
+ return BPy_FEdgeSmooth_from_FEdgeSmooth(dynamic_cast<FEdgeSmooth&>(if1D));
+ } else if (typeid(if1D) == typeid(FEdge)) {
+ return BPy_FEdge_from_FEdge(dynamic_cast<FEdge&>(if1D));
+ } else if (typeid(if1D) == typeid(Interface1D)) {
+ return BPy_Interface1D_from_Interface1D( if1D );
+ }
+ string msg("unexpected type: " + if1D.getExactTypeName());
+ PyErr_SetString(PyExc_TypeError, msg.c_str());
+ return NULL;
+}
+
+PyObject * Any_BPy_FEdge_from_FEdge( FEdge& fe ) {
+ if (typeid(fe) == typeid(FEdgeSharp)) {
+ return BPy_FEdgeSharp_from_FEdgeSharp( dynamic_cast<FEdgeSharp&>(fe) );
+ } else if (typeid(fe) == typeid(FEdgeSmooth)) {
+ return BPy_FEdgeSmooth_from_FEdgeSmooth( dynamic_cast<FEdgeSmooth&>(fe) );
+ } else if (typeid(fe) == typeid(FEdge)) {
+ return BPy_FEdge_from_FEdge( fe );
}
+ string msg("unexpected type: " + fe.getExactTypeName());
+ PyErr_SetString(PyExc_TypeError, msg.c_str());
+ return NULL;
+}
+
+PyObject * Any_BPy_ViewVertex_from_ViewVertex( ViewVertex& vv ) {
+ if (typeid(vv) == typeid(NonTVertex)) {
+ return BPy_NonTVertex_from_NonTVertex( dynamic_cast<NonTVertex&>(vv) );
+ } else if (typeid(vv) == typeid(TVertex)) {
+ return BPy_TVertex_from_TVertex( dynamic_cast<TVertex&>(vv) );
+ } else if (typeid(vv) == typeid(ViewVertex)) {
+ return BPy_ViewVertex_from_ViewVertex( vv );
+ }
+ string msg("unexpected type: " + vv.getExactTypeName());
+ PyErr_SetString(PyExc_TypeError, msg.c_str());
+ return NULL;
+}
+
+PyObject * BPy_Interface0D_from_Interface0D( Interface0D& if0D ) {
PyObject *py_if0D = Interface0D_Type.tp_new( &Interface0D_Type, 0, 0 );
((BPy_Interface0D *) py_if0D)->if0D = &if0D;
+ ((BPy_Interface0D *) py_if0D)->borrowed = 1;
return py_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;
+ ((BPy_Interface1D *) py_if1D)->borrowed = 1;
return py_if1D;
}
-
-PyObject * BPy_SVertex_from_SVertex_ptr( SVertex *sv ) {
+PyObject * BPy_SVertex_from_SVertex( SVertex& sv ) {
PyObject *py_sv = SVertex_Type.tp_new( &SVertex_Type, 0, 0 );
- ((BPy_SVertex *) py_sv)->sv = sv;
+ ((BPy_SVertex *) py_sv)->sv = &sv;
((BPy_SVertex *) py_sv)->py_if0D.if0D = ((BPy_SVertex *) py_sv)->sv;
+ ((BPy_SVertex *) py_sv)->py_if0D.borrowed = 1;
return py_sv;
}
+PyObject * BPy_FEdgeSharp_from_FEdgeSharp( FEdgeSharp& fes ) {
+ PyObject *py_fe = FEdgeSharp_Type.tp_new( &FEdgeSharp_Type, 0, 0 );
+ ((BPy_FEdgeSharp *) py_fe)->fes = &fes;
+ ((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;
+ ((BPy_FEdgeSharp *) py_fe)->py_fe.py_if1D.borrowed = 1;
+
+ return py_fe;
+}
+
+PyObject * BPy_FEdgeSmooth_from_FEdgeSmooth( FEdgeSmooth& fes ) {
+ PyObject *py_fe = FEdgeSmooth_Type.tp_new( &FEdgeSmooth_Type, 0, 0 );
+ ((BPy_FEdgeSmooth *) py_fe)->fes = &fes;
+ ((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;
+ ((BPy_FEdgeSmooth *) py_fe)->py_fe.py_if1D.borrowed = 1;
+
+ return py_fe;
+}
+
PyObject * BPy_FEdge_from_FEdge( FEdge& 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;
- }
+ PyObject *py_fe = FEdge_Type.tp_new( &FEdge_Type, 0, 0 );
+ ((BPy_FEdge *) py_fe)->fe = &fe;
+ ((BPy_FEdge *) py_fe)->py_if1D.if1D = ((BPy_FEdge *) py_fe)->fe;
+ ((BPy_FEdge *) py_fe)->py_if1D.borrowed = 1;
return py_fe;
}
@@ -165,17 +215,19 @@ PyObject * BPy_Nature_from_Nature( unsigned short n ) {
return py_n;
}
-PyObject * BPy_Stroke_from_Stroke_ptr( Stroke* s ) {
+PyObject * BPy_Stroke_from_Stroke( Stroke& s ) {
PyObject *py_s = Stroke_Type.tp_new( &Stroke_Type, 0, 0 );
- ((BPy_Stroke *) py_s)->s = s;
+ ((BPy_Stroke *) py_s)->s = &s;
((BPy_Stroke *) py_s)->py_if1D.if1D = ((BPy_Stroke *) py_s)->s;
+ ((BPy_Stroke *) py_s)->py_if1D.borrowed = 1;
return py_s;
}
-PyObject * BPy_StrokeAttribute_from_StrokeAttribute_ptr( StrokeAttribute *sa ) {
+PyObject * BPy_StrokeAttribute_from_StrokeAttribute( StrokeAttribute& sa ) {
PyObject *py_sa = StrokeAttribute_Type.tp_new( &StrokeAttribute_Type, 0, 0 );
- ((BPy_StrokeAttribute *) py_sa)->sa = sa;
+ ((BPy_StrokeAttribute *) py_sa)->sa = &sa;
+ ((BPy_StrokeAttribute *) py_sa)->borrowed = 1;
return py_sa;
}
@@ -190,37 +242,41 @@ PyObject * BPy_MediumType_from_MediumType( int n ) {
return py_mt;
}
-PyObject * BPy_StrokeVertex_from_StrokeVertex_ptr( StrokeVertex *sv ) {
+PyObject * BPy_StrokeVertex_from_StrokeVertex( StrokeVertex& sv ) {
PyObject *py_sv = StrokeVertex_Type.tp_new( &StrokeVertex_Type, 0, 0 );
- ((BPy_StrokeVertex *) py_sv)->sv = 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;
+ ((BPy_StrokeVertex *) py_sv)->py_cp.py_if0D.borrowed = 1;
return py_sv;
}
-PyObject * BPy_ViewVertex_from_ViewVertex_ptr( ViewVertex *vv ) {
+PyObject * BPy_ViewVertex_from_ViewVertex( ViewVertex& vv ) {
PyObject *py_vv = ViewVertex_Type.tp_new( &ViewVertex_Type, 0, 0 );
- ((BPy_ViewVertex *) py_vv)->vv = vv;
+ ((BPy_ViewVertex *) py_vv)->vv = &vv;
((BPy_ViewVertex *) py_vv)->py_if0D.if0D = ((BPy_ViewVertex *) py_vv)->vv;
+ ((BPy_ViewVertex *) py_vv)->py_if0D.borrowed = 1;
return py_vv;
}
-PyObject * BPy_NonTVertex_from_NonTVertex_ptr( NonTVertex *ntv ) {
+PyObject * BPy_NonTVertex_from_NonTVertex( NonTVertex& ntv ) {
PyObject *py_ntv = NonTVertex_Type.tp_new( &NonTVertex_Type, 0, 0 );
- ((BPy_NonTVertex *) py_ntv)->ntv = ntv;
+ ((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;
+ ((BPy_NonTVertex *) py_ntv)->py_vv.py_if0D.borrowed = 1;
return py_ntv;
}
-PyObject * BPy_TVertex_from_TVertex_ptr( TVertex *tv ) {
+PyObject * BPy_TVertex_from_TVertex( TVertex& tv ) {
PyObject *py_tv = TVertex_Type.tp_new( &TVertex_Type, 0, 0 );
- ((BPy_TVertex *) py_tv)->tv = tv;
+ ((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;
+ ((BPy_TVertex *) py_tv)->py_vv.py_if0D.borrowed = 1;
return py_tv;
}
@@ -232,39 +288,44 @@ PyObject * BPy_BBox_from_BBox( BBox< Vec3r > &bb ) {
return py_bb;
}
-PyObject * BPy_ViewEdge_from_ViewEdge_ptr( ViewEdge* ve ) {
+PyObject * BPy_ViewEdge_from_ViewEdge( ViewEdge& ve ) {
PyObject *py_ve = ViewEdge_Type.tp_new( &ViewEdge_Type, 0, 0 );
- ((BPy_ViewEdge *) py_ve)->ve = ve;
+ ((BPy_ViewEdge *) py_ve)->ve = &ve;
((BPy_ViewEdge *) py_ve)->py_if1D.if1D = ((BPy_ViewEdge *) py_ve)->ve;
+ ((BPy_ViewEdge *) py_ve)->py_if1D.borrowed = 1;
return py_ve;
}
-PyObject * BPy_Chain_from_Chain_ptr( Chain* c ) {
+PyObject * BPy_Chain_from_Chain( Chain& c ) {
PyObject *py_c = Chain_Type.tp_new( &Chain_Type, 0, 0 );
- ((BPy_Chain *) py_c)->c = c;
+ ((BPy_Chain *) py_c)->c = &c;
((BPy_Chain *) py_c)->py_c.c = ((BPy_Chain *) py_c)->c;
((BPy_Chain *) py_c)->py_c.py_if1D.if1D = ((BPy_Chain *) py_c)->c;
+ ((BPy_Chain *) py_c)->py_c.py_if1D.borrowed = 1;
return py_c;
}
PyObject * BPy_SShape_from_SShape( SShape& ss ) {
PyObject *py_ss = SShape_Type.tp_new( &SShape_Type, 0, 0 );
- ((BPy_SShape *) py_ss)->ss = new SShape( ss );
+ ((BPy_SShape *) py_ss)->ss = &ss;
+ ((BPy_SShape *) py_ss)->borrowed = 1;
return py_ss;
}
PyObject * BPy_ViewShape_from_ViewShape( ViewShape& vs ) {
PyObject *py_vs = ViewShape_Type.tp_new( &ViewShape_Type, 0, 0 );
- ((BPy_ViewShape *) py_vs)->vs = new ViewShape( vs );
+ ((BPy_ViewShape *) py_vs)->vs = &vs;
+ ((BPy_ViewShape *) py_vs)->borrowed = 1;
return py_vs;
}
PyObject * BPy_FrsMaterial_from_FrsMaterial( FrsMaterial& m ){
PyObject *py_m = FrsMaterial_Type.tp_new( &FrsMaterial_Type, 0, 0 );
- ((BPy_FrsMaterial*) py_m)->m = new FrsMaterial( m );
+ ((BPy_FrsMaterial*) py_m)->m = &m;
+ ((BPy_FrsMaterial*) py_m)->borrowed = 1;
return py_m;
}
@@ -280,10 +341,11 @@ PyObject * BPy_IntegrationType_from_IntegrationType( int i ) {
return py_it;
}
-PyObject * BPy_CurvePoint_from_CurvePoint_ptr( CurvePoint *cp ) {
+PyObject * BPy_CurvePoint_from_CurvePoint( CurvePoint& cp ) {
PyObject *py_cp = CurvePoint_Type.tp_new( &CurvePoint_Type, 0, 0 );
- ((BPy_CurvePoint*) py_cp)->cp = cp;
+ ((BPy_CurvePoint*) py_cp)->cp = &cp;
((BPy_CurvePoint*) py_cp)->py_if0D.if0D = ((BPy_CurvePoint*) py_cp)->cp;
+ ((BPy_CurvePoint*) py_cp)->py_if0D.borrowed = 1;
return py_cp;
}
@@ -291,7 +353,7 @@ PyObject * BPy_CurvePoint_from_CurvePoint_ptr( CurvePoint *cp ) {
PyObject * BPy_directedViewEdge_from_directedViewEdge( ViewVertex::directedViewEdge& dve ) {
PyObject *py_dve = PyTuple_New(2);
- PyTuple_SetItem( py_dve, 0, BPy_ViewEdge_from_ViewEdge_ptr(dve.first) );
+ PyTuple_SetItem( py_dve, 0, BPy_ViewEdge_from_ViewEdge(*(dve.first)) );
PyTuple_SetItem( py_dve, 1, PyBool_from_bool(dve.second) );
return py_dve;
diff --git a/source/blender/freestyle/intern/python/BPy_Convert.h b/source/blender/freestyle/intern/python/BPy_Convert.h
index 70d8a4d9cfc..3e34b4d2bcc 100644
--- a/source/blender/freestyle/intern/python/BPy_Convert.h
+++ b/source/blender/freestyle/intern/python/BPy_Convert.h
@@ -73,10 +73,17 @@ PyObject * Vector_from_Vec2f( Vec2f& v );
PyObject * Vector_from_Vec3f( Vec3f& v );
PyObject * Vector_from_Vec3r( Vec3r& v );
+PyObject * Any_BPy_Interface0D_from_Interface0D( Interface0D& if0D );
+PyObject * Any_BPy_Interface1D_from_Interface1D( Interface1D& if1D );
+PyObject * Any_BPy_FEdge_from_FEdge( FEdge& fe );
+PyObject * Any_BPy_ViewVertex_from_ViewVertex( ViewVertex& vv );
+
PyObject * BPy_BBox_from_BBox( BBox< Vec3r > &bb );
-PyObject * BPy_CurvePoint_from_CurvePoint_ptr( CurvePoint *cp );
+PyObject * BPy_CurvePoint_from_CurvePoint( CurvePoint& cp );
PyObject * BPy_directedViewEdge_from_directedViewEdge( ViewVertex::directedViewEdge& dve );
PyObject * BPy_FEdge_from_FEdge( FEdge& fe );
+PyObject * BPy_FEdgeSharp_from_FEdgeSharp( FEdgeSharp& fes );
+PyObject * BPy_FEdgeSmooth_from_FEdgeSmooth( FEdgeSmooth& fes );
PyObject * BPy_Id_from_Id( Id& id );
PyObject * BPy_Interface0D_from_Interface0D( Interface0D& if0D );
PyObject * BPy_Interface1D_from_Interface1D( Interface1D& if1D );
@@ -85,15 +92,15 @@ PyObject * BPy_FrsMaterial_from_FrsMaterial( FrsMaterial& 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_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_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_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_ViewVertex_from_ViewVertex( ViewVertex& vv );
+PyObject * BPy_NonTVertex_from_NonTVertex( NonTVertex& ntv );
+PyObject * BPy_TVertex_from_TVertex( TVertex& tv );
+PyObject * BPy_ViewEdge_from_ViewEdge( ViewEdge& ve );
+PyObject * BPy_Chain_from_Chain( Chain& c );
PyObject * BPy_ViewShape_from_ViewShape( ViewShape& vs );
PyObject * BPy_AdjacencyIterator_from_AdjacencyIterator( AdjacencyIterator& a_it );
diff --git a/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp b/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp
index 982318610a1..05b60075855 100644
--- a/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp
+++ b/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp
@@ -196,13 +196,15 @@ int FrsMaterial___init__(BPy_FrsMaterial *self, PyObject *args, PyObject *kwds)
PyErr_SetString(PyExc_TypeError, "invalid arguments");
return -1;
}
+ self->borrowed = 0;
return 0;
}
void FrsMaterial___dealloc__( BPy_FrsMaterial* self)
{
- delete self->m;
+ if( self->m && !self->borrowed )
+ delete self->m;
self->ob_type->tp_free((PyObject*)self);
}
diff --git a/source/blender/freestyle/intern/python/BPy_FrsMaterial.h b/source/blender/freestyle/intern/python/BPy_FrsMaterial.h
index 95264180f2f..9d6629127f9 100644
--- a/source/blender/freestyle/intern/python/BPy_FrsMaterial.h
+++ b/source/blender/freestyle/intern/python/BPy_FrsMaterial.h
@@ -19,6 +19,7 @@ extern PyTypeObject FrsMaterial_Type;
typedef struct {
PyObject_HEAD
FrsMaterial *m;
+ int borrowed; /* non-zero if *m is a borrowed object */
} BPy_FrsMaterial;
/*---------------------------Python BPy_FrsMaterial visible prototypes-----------*/
diff --git a/source/blender/freestyle/intern/python/BPy_Interface0D.cpp b/source/blender/freestyle/intern/python/BPy_Interface0D.cpp
index 11d7cec7058..4bb357e28be 100644
--- a/source/blender/freestyle/intern/python/BPy_Interface0D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Interface0D.cpp
@@ -183,13 +183,13 @@ 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;
+ self->borrowed = 0;
return 0;
}
void Interface0D___dealloc__(BPy_Interface0D* self)
{
- if( self->if0D && self->if0D->py_if0D )
+ if( self->if0D && !self->borrowed )
delete self->if0D;
self->ob_type->tp_free((PyObject*)self);
}
@@ -205,43 +205,65 @@ PyObject *Interface0D_getExactTypeName( BPy_Interface0D *self ) {
PyObject *Interface0D_getX( BPy_Interface0D *self ) {
- return PyFloat_FromDouble( self->if0D->getX() );
+ double x = self->if0D->getX();
+ if (PyErr_Occurred())
+ return NULL;
+ return PyFloat_FromDouble( x );
}
PyObject *Interface0D_getY( BPy_Interface0D *self ) {
- return PyFloat_FromDouble( self->if0D->getY() );
+ double y = self->if0D->getY();
+ if (PyErr_Occurred())
+ return NULL;
+ return PyFloat_FromDouble( y );
}
PyObject *Interface0D_getZ( BPy_Interface0D *self ) {
- return PyFloat_FromDouble( self->if0D->getZ() );
+ double z = self->if0D->getZ();
+ if (PyErr_Occurred())
+ return NULL;
+ return PyFloat_FromDouble( z );
}
PyObject *Interface0D_getPoint3D( BPy_Interface0D *self ) {
Vec3f v( self->if0D->getPoint3D() );
+ if (PyErr_Occurred())
+ return NULL;
return Vector_from_Vec3f( v );
}
PyObject *Interface0D_getProjectedX( BPy_Interface0D *self ) {
- return PyFloat_FromDouble( self->if0D->getProjectedX() );
+ double x = self->if0D->getProjectedX();
+ if (PyErr_Occurred())
+ return NULL;
+ return PyFloat_FromDouble( x );
}
PyObject *Interface0D_getProjectedY( BPy_Interface0D *self ) {
- return PyFloat_FromDouble( self->if0D->getProjectedY() );
+ double y = self->if0D->getProjectedY();
+ if (PyErr_Occurred())
+ return NULL;
+ return PyFloat_FromDouble( y );
}
PyObject *Interface0D_getProjectedZ( BPy_Interface0D *self ) {
- return PyFloat_FromDouble( self->if0D->getProjectedZ() );
+ double z = self->if0D->getProjectedZ();
+ if (PyErr_Occurred())
+ return NULL;
+ return PyFloat_FromDouble( z );
}
PyObject *Interface0D_getPoint2D( BPy_Interface0D *self ) {
Vec2f v( self->if0D->getPoint2D() );
+ if (PyErr_Occurred())
+ return NULL;
return Vector_from_Vec2f( v );
}
@@ -253,8 +275,10 @@ PyObject *Interface0D_getFEdge( BPy_Interface0D *self, PyObject *args ) {
return NULL;
FEdge *fe = self->if0D->getFEdge(*( ((BPy_Interface0D *) py_if0D)->if0D ));
+ if (PyErr_Occurred())
+ return NULL;
if( fe )
- return BPy_FEdge_from_FEdge( *fe );
+ return Any_BPy_FEdge_from_FEdge( *fe );
Py_RETURN_NONE;
}
@@ -262,12 +286,17 @@ PyObject *Interface0D_getFEdge( BPy_Interface0D *self, PyObject *args ) {
PyObject *Interface0D_getId( BPy_Interface0D *self ) {
Id id( self->if0D->getId() );
+ if (PyErr_Occurred())
+ return NULL;
return BPy_Id_from_Id( id );
}
PyObject *Interface0D_getNature( BPy_Interface0D *self ) {
- return BPy_Nature_from_Nature( self->if0D->getNature() );
+ Nature::VertexNature nature = self->if0D->getNature();
+ if (PyErr_Occurred())
+ return NULL;
+ return BPy_Nature_from_Nature( nature );
}
diff --git a/source/blender/freestyle/intern/python/BPy_Interface0D.h b/source/blender/freestyle/intern/python/BPy_Interface0D.h
index a55deb80a6f..673c12e6b8d 100644
--- a/source/blender/freestyle/intern/python/BPy_Interface0D.h
+++ b/source/blender/freestyle/intern/python/BPy_Interface0D.h
@@ -19,6 +19,7 @@ extern PyTypeObject Interface0D_Type;
typedef struct {
PyObject_HEAD
Interface0D *if0D;
+ int borrowed; /* non-zero if *if0D is a borrowed object */
} BPy_Interface0D;
/*---------------------------Python BPy_Interface0D visible prototypes-----------*/
diff --git a/source/blender/freestyle/intern/python/BPy_Interface1D.cpp b/source/blender/freestyle/intern/python/BPy_Interface1D.cpp
index 613a4f180cc..7fe7c4de07a 100644
--- a/source/blender/freestyle/intern/python/BPy_Interface1D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Interface1D.cpp
@@ -198,13 +198,13 @@ PyMODINIT_FUNC Interface1D_Init( PyObject *module )
int Interface1D___init__(BPy_Interface1D *self, PyObject *args, PyObject *kwds)
{
self->if1D = new Interface1D();
- self->if1D->py_if1D = (PyObject *) self;
+ self->borrowed = 0;
return 0;
}
void Interface1D___dealloc__(BPy_Interface1D* self)
{
- if( self->if1D && self->if1D->py_if1D )
+ if( self->if1D && !self->borrowed )
delete self->if1D;
self->ob_type->tp_free((PyObject*)self);
}
diff --git a/source/blender/freestyle/intern/python/BPy_Interface1D.h b/source/blender/freestyle/intern/python/BPy_Interface1D.h
index 14971bf88f5..25ca84fdf42 100644
--- a/source/blender/freestyle/intern/python/BPy_Interface1D.h
+++ b/source/blender/freestyle/intern/python/BPy_Interface1D.h
@@ -19,6 +19,7 @@ extern PyTypeObject Interface1D_Type;
typedef struct {
PyObject_HEAD
Interface1D *if1D;
+ int borrowed; /* non-zero if *if1D is a borrowed object */
} BPy_Interface1D;
/*---------------------------Python BPy_Interface1D visible prototypes-----------*/
diff --git a/source/blender/freestyle/intern/python/BPy_SShape.cpp b/source/blender/freestyle/intern/python/BPy_SShape.cpp
index 48faf65a569..01971acbc75 100644
--- a/source/blender/freestyle/intern/python/BPy_SShape.cpp
+++ b/source/blender/freestyle/intern/python/BPy_SShape.cpp
@@ -155,13 +155,15 @@ int SShape___init__(BPy_SShape *self, PyObject *args, PyObject *kwds)
} else {
self->ss = new SShape(*( ((BPy_SShape *) obj)->ss ));
}
-
+ self->borrowed = 0;
+
return 0;
}
void SShape___dealloc__(BPy_SShape *self)
{
- delete self->ss;
+ if( self->ss && !self->borrowed )
+ delete self->ss;
self->ob_type->tp_free((PyObject*)self);
}
@@ -222,7 +224,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_ptr(*it) );
+ PyList_Append( py_vertices, BPy_SVertex_from_SVertex(*( *it )) );
}
return py_vertices;
@@ -236,7 +238,7 @@ PyObject * SShape_getEdgeList( BPy_SShape *self ) {
vector< FEdge * >::iterator it;
for( it = edges.begin(); it != edges.end(); it++ ) {
- PyList_Append( py_edges, BPy_FEdge_from_FEdge(*( *it )) );
+ PyList_Append( py_edges, Any_BPy_FEdge_from_FEdge(*( *it )) );
}
return py_edges;
diff --git a/source/blender/freestyle/intern/python/BPy_SShape.h b/source/blender/freestyle/intern/python/BPy_SShape.h
index 5ca4d9abefe..61e2257b2a5 100644
--- a/source/blender/freestyle/intern/python/BPy_SShape.h
+++ b/source/blender/freestyle/intern/python/BPy_SShape.h
@@ -19,6 +19,7 @@ extern PyTypeObject SShape_Type;
typedef struct {
PyObject_HEAD
SShape *ss;
+ int borrowed; /* non-zero if *ss is a borrowed object */
} BPy_SShape;
/*---------------------------Python BPy_SShape visible prototypes-----------*/
diff --git a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
index c603acac9b4..2c9512792fa 100644
--- a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
+++ b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
@@ -200,7 +200,7 @@ int StrokeAttribute___init__(BPy_StrokeAttribute *self, PyObject *args, PyObject
return -1;
}
- self->sa->py_sa = (PyObject *) self;
+ self->borrowed = 0;
return 0;
@@ -208,7 +208,7 @@ int StrokeAttribute___init__(BPy_StrokeAttribute *self, PyObject *args, PyObject
void StrokeAttribute___dealloc__(BPy_StrokeAttribute* self)
{
- if( self->sa && self->sa->py_sa )
+ if( self->sa && !self->borrowed )
delete self->sa;
self->ob_type->tp_free((PyObject*)self);
}
diff --git a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h
index a2100c3b0f6..ad4ae095b72 100644
--- a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h
+++ b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h
@@ -19,6 +19,7 @@ extern PyTypeObject StrokeAttribute_Type;
typedef struct {
PyObject_HEAD
StrokeAttribute *sa;
+ int borrowed; /* non-zero if *sa is a borrowed reference */
} BPy_StrokeAttribute;
/*---------------------------Python BPy_StrokeAttribute visible prototypes-----------*/
diff --git a/source/blender/freestyle/intern/python/BPy_ViewMap.cpp b/source/blender/freestyle/intern/python/BPy_ViewMap.cpp
index 0203a093d74..30ede27eb69 100644
--- a/source/blender/freestyle/intern/python/BPy_ViewMap.cpp
+++ b/source/blender/freestyle/intern/python/BPy_ViewMap.cpp
@@ -138,7 +138,8 @@ int ViewMap___init__(BPy_ViewMap *self, PyObject *args, PyObject *kwds)
void ViewMap___dealloc__(BPy_ViewMap *self)
{
- delete self->vm;
+ if( self->vm )
+ delete self->vm;
self->ob_type->tp_free((PyObject*)self);
}
@@ -155,7 +156,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_ptr(ve);
+ return BPy_ViewEdge_from_ViewEdge(*ve);
Py_RETURN_NONE;
}
@@ -168,7 +169,7 @@ PyObject * ViewMap_getClosestFEdge( BPy_ViewMap *self , PyObject *args) {
FEdge *fe = const_cast<FEdge *>( self->vm->getClosestFEdge(x,y) );
if( fe )
- return BPy_FEdge_from_FEdge(*fe);
+ return Any_BPy_FEdge_from_FEdge(*fe);
Py_RETURN_NONE;
}
diff --git a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp
index 09803b45aa5..454d1af0d67 100644
--- a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp
+++ b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp
@@ -160,13 +160,15 @@ int ViewShape___init__(BPy_ViewShape *self, PyObject *args, PyObject *kwds)
PyErr_SetString(PyExc_TypeError, "invalid argument");
return -1;
}
+ self->borrowed = 0;
return 0;
}
void ViewShape___dealloc__(BPy_ViewShape *self)
{
- delete self->vs;
+ if( self->vs && !self->borrowed )
+ delete self->vs;
self->ob_type->tp_free((PyObject*)self);
}
@@ -176,8 +178,7 @@ PyObject * ViewShape___repr__(BPy_ViewShape *self)
}
PyObject * ViewShape_sshape( BPy_ViewShape *self ) {
- SShape ss(*( self->vs->sshape() ));
- return BPy_SShape_from_SShape( ss );
+ return BPy_SShape_from_SShape( *(self->vs->sshape()) );
}
@@ -188,7 +189,7 @@ PyObject * ViewShape_vertices( BPy_ViewShape *self ) {
vector< ViewVertex * >::iterator it;
for( it = vertices.begin(); it != vertices.end(); it++ ) {
- PyList_Append( py_vertices, BPy_ViewVertex_from_ViewVertex_ptr( *it ) );
+ PyList_Append( py_vertices, Any_BPy_ViewVertex_from_ViewVertex(*( *it )) );
}
return py_vertices;
@@ -202,7 +203,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_ptr(*it) );
+ PyList_Append( py_edges, BPy_ViewEdge_from_ViewEdge(*( *it )) );
}
return py_edges;
diff --git a/source/blender/freestyle/intern/python/BPy_ViewShape.h b/source/blender/freestyle/intern/python/BPy_ViewShape.h
index a7d01c098d2..fa14f6ff480 100644
--- a/source/blender/freestyle/intern/python/BPy_ViewShape.h
+++ b/source/blender/freestyle/intern/python/BPy_ViewShape.h
@@ -19,6 +19,7 @@ extern PyTypeObject ViewShape_Type;
typedef struct {
PyObject_HEAD
ViewShape *vs;
+ int borrowed; /* non-zero if *vs a borrowed object */
} BPy_ViewShape;
/*---------------------------Python BPy_ViewShape visible prototypes-----------*/
diff --git a/source/blender/freestyle/intern/python/Director.cpp b/source/blender/freestyle/intern/python/Director.cpp
index 45eb9d861e2..cc2b00bdc69 100644
--- a/source/blender/freestyle/intern/python/Director.cpp
+++ b/source/blender/freestyle/intern/python/Director.cpp
@@ -13,11 +13,6 @@
#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"
@@ -48,8 +43,8 @@ int Director_BPy_BinaryPredicate0D___call__( BinaryPredicate0D *bp0D, Interface0
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 *arg1 = Any_BPy_Interface0D_from_Interface0D(i1);
+ PyObject *arg2 = Any_BPy_Interface0D_from_Interface0D(i2);
if (!arg1 || !arg2) {
Py_XDECREF(arg1);
Py_XDECREF(arg2);
@@ -75,8 +70,8 @@ int Director_BPy_BinaryPredicate1D___call__( BinaryPredicate1D *bp1D, Interface1
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);
+ PyObject *arg1 = Any_BPy_Interface1D_from_Interface1D(i1);
+ PyObject *arg2 = Any_BPy_Interface1D_from_Interface1D(i2);
if (!arg1 || !arg2) {
Py_XDECREF(arg1);
Py_XDECREF(arg2);
@@ -124,7 +119,7 @@ int Director_BPy_UnaryPredicate1D___call__( UnaryPredicate1D *up1D, Interface1D&
PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_up1D) not initialized");
return -1;
}
- PyObject *arg = BPy_Interface1D_from_Interface1D(if1D);
+ PyObject *arg = Any_BPy_Interface1D_from_Interface1D(if1D);
if (!arg)
return -1;
PyObject *result = PyObject_CallMethod( up1D->py_up1D, "__call__", "O", arg );
@@ -146,7 +141,7 @@ int Director_BPy_StrokeShader_shade( StrokeShader *ss, Stroke& s ) {
PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_ss) not initialized");
return -1;
}
- PyObject *arg = BPy_Stroke_from_Stroke_ptr(&s);
+ PyObject *arg = BPy_Stroke_from_Stroke(s);
if (!arg)
return -1;
PyObject *result = PyObject_CallMethod( ss->py_ss, "shade", "O", arg );
@@ -263,7 +258,7 @@ int Director_BPy_UnaryFunction1D___call__( void *uf1D, PyObject *obj, Interface1
PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_uf1D) not initialized");
return -1;
}
- PyObject *arg = BPy_Interface1D_from_Interface1D(if1D);
+ PyObject *arg = Any_BPy_Interface1D_from_Interface1D(if1D);
if (!arg)
return -1;
PyObject *result = PyObject_CallMethod( obj, "__call__", "O", arg );
@@ -307,193 +302,3 @@ int Director_BPy_UnaryFunction1D___call__( void *uf1D, PyObject *obj, Interface1
Py_DECREF(result);
return 0;
}
-
-
-// Iterator: increment, decrement, isBegin, isEnd
-void Director_BPy_Iterator_increment( PyObject *obj ) {
- PyObject *result = PyObject_CallMethod( obj, "increment", "", 0 );
- Py_DECREF(result);
-}
-
-void Director_BPy_Iterator_decrement( PyObject *obj ) {
- PyObject *result = PyObject_CallMethod( obj, "decrement", "", 0 );
- Py_DECREF(result);
-}
-
-bool Director_BPy_Iterator_isBegin( PyObject *obj ) {
- PyObject *result = PyObject_CallMethod( obj, "isBegin", "", 0 );
- bool ret = bool_from_PyBool(result);
- Py_DECREF(result);
- return ret;
-}
-
-bool Director_BPy_Iterator_isEnd( PyObject *obj ) {
- PyObject *result = PyObject_CallMethod( obj, "isEnd", "", 0 );
- bool ret = bool_from_PyBool(result);
- Py_DECREF(result);
- return ret;
-}
-
-// 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 );
- double ret = PyFloat_AsDouble(result);
- Py_DECREF(result);
- return ret;
-}
-
-double Director_BPy_Interface0D_getY( PyObject *obj ) {
- PyObject *result = PyObject_CallMethod( obj, "getY", "", 0 );
- double ret = PyFloat_AsDouble(result);
- Py_DECREF(result);
- return ret;
-}
-
-double Director_BPy_Interface0D_getZ( PyObject *obj ) {
- PyObject *result = PyObject_CallMethod( obj, "getZ", "", 0 );
- double ret = PyFloat_AsDouble(result);
- Py_DECREF(result);
- return ret;
-}
-
-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);
- Py_DECREF(result);
- delete v_ref;
-
- return v;
-}
-
-double Director_BPy_Interface0D_getProjectedX( PyObject *obj ) {
- PyObject *result = PyObject_CallMethod( obj, "getProjectedX", "", 0 );
- double ret = PyFloat_AsDouble(result);
- Py_DECREF(result);
- return ret;
-}
-
-double Director_BPy_Interface0D_getProjectedY( PyObject *obj ) {
- PyObject *result = PyObject_CallMethod( obj, "getProjectedY", "", 0 );
- double ret = PyFloat_AsDouble(result);
- Py_DECREF(result);
- return ret;
-}
-
-double Director_BPy_Interface0D_getProjectedZ( PyObject *obj ) {
- PyObject *result = PyObject_CallMethod( obj, "getProjectedZ", "", 0 );
- double ret = PyFloat_AsDouble(result);
- Py_DECREF(result);
- return ret;
-}
-
-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);
- Py_DECREF(result);
- delete v_ref;
-
- return v;
-}
-
-FEdge * Director_BPy_Interface0D_getFEdge( PyObject *obj ) {
- PyObject *result = PyObject_CallMethod( obj, "getFEdge", "", 0 );
- FEdge *ret = ((BPy_FEdge *) result)->fe;
- Py_DECREF(result);
- return ret;
-}
-
-Id Director_BPy_Interface0D_getId( PyObject *obj ) {
- PyObject *result = PyObject_CallMethod( obj, "getId", "", 0 );
- Id ret = *( ((BPy_Id *) result)->id );
- Py_DECREF(result);
- return ret;
-}
-
-Nature::EdgeNature Director_BPy_Interface0D_getNature( PyObject *obj ) {
- PyObject *result = PyObject_CallMethod( obj, "getNature", "", 0 );
- Nature::EdgeNature ret = EdgeNature_from_BPy_Nature(result);
- Py_DECREF(result);
- return ret;
-}
-
-SVertex * Director_BPy_Interface0D_castToSVertex( PyObject *obj ) {
- PyObject *result = PyObject_CallMethod( obj, "castToSVertex", "", 0 );
- SVertex *ret = ((BPy_SVertex *) result)->sv;
- Py_DECREF(result);
- return ret;
-}
-
-ViewVertex * Director_BPy_Interface0D_castToViewVertex( PyObject *obj ) {
- PyObject *result = PyObject_CallMethod( obj, "castToViewVertex", "", 0 );
- ViewVertex *ret = ((BPy_ViewVertex *) result)->vv;
- Py_DECREF(result);
- return ret;
-}
-
-NonTVertex * Director_BPy_Interface0D_castToNonTVertex( PyObject *obj ) {
- PyObject *result = PyObject_CallMethod( obj, "castToNonTVertex", "", 0 );
- NonTVertex *ret = ((BPy_NonTVertex *) result)->ntv;
- Py_DECREF(result);
- return ret;
-}
-
-TVertex * Director_BPy_Interface0D_castToTVertex( PyObject *obj ) {
- PyObject *result = PyObject_CallMethod( obj, "castToTVertex", "", 0 );
- TVertex *ret = ((BPy_TVertex *) result)->tv;
- Py_DECREF(result);
- return ret;
-}
-
-// Interface1D: verticesBegin, verticesEnd, pointsBegin, pointsEnd
-Interface0DIterator Director_BPy_Interface1D_verticesBegin( PyObject *obj ){
- PyObject *result = PyObject_CallMethod( obj, "verticesBegin", "", 0 );
- Interface0DIterator ret = *( ((BPy_Interface0DIterator *) result)->if0D_it );
- Py_DECREF(result);
- return ret;
-}
-
-Interface0DIterator Director_BPy_Interface1D_verticesEnd( PyObject *obj ){
- PyObject *result = PyObject_CallMethod( obj, "verticesEnd", "", 0 );
- Interface0DIterator ret = *( ((BPy_Interface0DIterator *) result)->if0D_it );
- Py_DECREF(result);
- return ret;
-}
-
-Interface0DIterator Director_BPy_Interface1D_pointsBegin( PyObject *obj ){
- PyObject *result = PyObject_CallMethod( obj, "pointsBegin", "", 0 );
- Interface0DIterator ret = *( ((BPy_Interface0DIterator *) result)->if0D_it );
- Py_DECREF(result);
- return ret;
-}
-
-Interface0DIterator Director_BPy_Interface1D_pointsEnd( PyObject *obj ){
- PyObject *result = PyObject_CallMethod( obj, "pointsEnd", "", 0 );
- Interface0DIterator ret = *( ((BPy_Interface0DIterator *) result)->if0D_it );
- Py_DECREF(result);
- return ret;
-}
-
-double Director_BPy_Interface1D_getLength2D( PyObject *obj ) {
- PyObject *result = PyObject_CallMethod( obj, "getLength2D", "", 0 );
- double ret = PyFloat_AsDouble(result);
- Py_DECREF(result);
- return ret;
-}
-
-Id Director_BPy_Interface1D_getId( PyObject *obj ) {
- PyObject *result = PyObject_CallMethod( obj, "getId", "", 0 );
- Id ret = *( ((BPy_Id *) result)->id );
- Py_DECREF(result);
- return ret;
-}
-
-Nature::EdgeNature Director_BPy_Interface1D_getNature( PyObject *obj ) {
- PyObject *result = PyObject_CallMethod( obj, "getNature", "", 0 );
- Nature::EdgeNature ret = EdgeNature_from_BPy_Nature(result);
- Py_DECREF(result);
- return ret;
-}
diff --git a/source/blender/freestyle/intern/python/Director.h b/source/blender/freestyle/intern/python/Director.h
index ccce8280cb4..667d4a65942 100644
--- a/source/blender/freestyle/intern/python/Director.h
+++ b/source/blender/freestyle/intern/python/Director.h
@@ -1,28 +1,17 @@
#ifndef FREESTYLE_PYTHON_DIRECTOR
# define FREESTYLE_PYTHON_DIRECTOR
-#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;
class Interface0D;
class Interface1D;
class Interface0DIterator;
-class NonTVertex;
class Stroke;
class StrokeShader;
-class SVertex;
-class TVertex;
-class ViewEdge;
-class ViewVertex;
-
#ifdef __cplusplus
extern "C" {
@@ -40,32 +29,6 @@ int Director_BPy_BinaryPredicate0D___call__( BinaryPredicate0D *bp0D, Interface0
// BinaryPredicate1D: __call__
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 );
-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__
int Director_BPy_UnaryFunction0D___call__( void *uf0D, PyObject *obj, Interface0DIterator& if0D_it);
int Director_BPy_UnaryFunction1D___call__( void *uf1D, PyObject *obj, Interface1D& if1D);
@@ -79,18 +42,8 @@ int Director_BPy_UnaryPredicate1D___call__( UnaryPredicate1D *up1D, Interface1D&
// StrokeShader: shade
int Director_BPy_StrokeShader_shade( StrokeShader *ss, Stroke& s );
-// 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 );
-
// ChainingIterator: init, traverse
int Director_BPy_ChainingIterator_init( ChainingIterator *c_it );
int Director_BPy_ChainingIterator_traverse( ChainingIterator *c_it, AdjacencyIterator& a_it );
-
-
-
-
#endif // FREESTYLE_PYTHON_DIRECTOR
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp
index 5c739f9cd29..85ccae1c247 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp
@@ -152,6 +152,7 @@ int CurvePoint___init__(BPy_CurvePoint *self, PyObject *args, PyObject *kwds)
}
self->py_if0D.if0D = self->cp;
+ self->py_if0D.borrowed = 0;
return 0;
}
@@ -163,20 +164,23 @@ PyObject * CurvePoint___copy__( BPy_CurvePoint *self ) {
py_cp->cp = new CurvePoint( *(self->cp) );
py_cp->py_if0D.if0D = py_cp->cp;
+ py_cp->py_if0D.borrowed = 0;
return (PyObject *) py_cp;
}
PyObject * CurvePoint_A( BPy_CurvePoint *self ) {
- if( SVertex *A = self->cp->A() )
- return BPy_SVertex_from_SVertex_ptr( A );
+ SVertex *A = self->cp->A();
+ if( A )
+ return BPy_SVertex_from_SVertex( *A );
Py_RETURN_NONE;
}
PyObject * CurvePoint_B( BPy_CurvePoint *self ) {
- if( SVertex *B = self->cp->B() )
- return BPy_SVertex_from_SVertex_ptr( B );
+ SVertex *B = self->cp->B();
+ if( B )
+ return BPy_SVertex_from_SVertex( *B );
Py_RETURN_NONE;
}
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
index 46fd1c64758..b3005570843 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
@@ -151,6 +151,7 @@ int SVertex___init__(BPy_SVertex *self, PyObject *args, PyObject *kwds)
}
self->py_if0D.if0D = self->sv;
+ self->py_if0D.borrowed = 0;
return 0;
}
@@ -162,6 +163,7 @@ PyObject * SVertex___copy__( BPy_SVertex *self ) {
py_svertex->sv = self->sv->duplicate();
py_svertex->py_if0D.if0D = py_svertex->sv;
+ py_svertex->py_if0D.borrowed = 0;
return (PyObject *) py_svertex;
}
@@ -188,12 +190,10 @@ PyObject * SVertex_normalsSize( BPy_SVertex *self ) {
PyObject * SVertex_viewvertex( BPy_SVertex *self ) {
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) );
+ if( vv )
+ return Any_BPy_ViewVertex_from_ViewVertex( *vv );
+
+ Py_RETURN_NONE;
}
PyObject *SVertex_setPoint3D( BPy_SVertex *self , PyObject *args) {
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp
index f37e868bdbd..edccf65f53a 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp
@@ -120,6 +120,7 @@ int ViewVertex___init__(BPy_ViewVertex *self )
{
self->vv = 0; // ViewVertex is abstract
self->py_if0D.if0D = new Interface0D();
+ self->py_if0D.borrowed = 0;
return 0;
}
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 969aa1d7216..b3e709540b3 100644
--- a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp
@@ -166,6 +166,7 @@ int StrokeVertex___init__(BPy_StrokeVertex *self, PyObject *args, PyObject *kwds
self->py_cp.cp = self->sv;
self->py_cp.py_if0D.if0D = self->sv;
+ self->py_cp.py_if0D.borrowed = 0;
return 0;
}
@@ -184,7 +185,7 @@ PyObject * StrokeVertex_getPoint( BPy_StrokeVertex *self ) {
}
PyObject * StrokeVertex_attribute( BPy_StrokeVertex *self ) {
- return BPy_StrokeAttribute_from_StrokeAttribute_ptr( &(self->sv->attribute()) );
+ return BPy_StrokeAttribute_from_StrokeAttribute( 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 e21a4264410..a5948deea7a 100644
--- a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp
@@ -139,6 +139,7 @@ int NonTVertex___init__(BPy_NonTVertex *self, PyObject *args, PyObject *kwds)
self->py_vv.vv = self->ntv;
self->py_vv.py_if0D.if0D = self->ntv;
+ self->py_vv.py_if0D.borrowed = 0;
return 0;
}
@@ -151,16 +152,17 @@ PyObject * NonTVertex_castToSVertex( BPy_NonTVertex *self ) {
}
PyObject * NonTVertex_castToViewVertex( BPy_NonTVertex *self ) {
- return BPy_ViewVertex_from_ViewVertex_ptr( self->ntv->castToViewVertex() );
+ return BPy_ViewVertex_from_ViewVertex( *(self->ntv->castToViewVertex()) );
}
PyObject * NonTVertex_castToNonTVertex( BPy_NonTVertex *self ) {
- return BPy_NonTVertex_from_NonTVertex_ptr( self->ntv->castToNonTVertex() );
+ return BPy_NonTVertex_from_NonTVertex( *(self->ntv->castToNonTVertex()) );
}
PyObject * NonTVertex_svertex( BPy_NonTVertex *self ) {
- if( self->ntv->svertex() ){
- return BPy_SVertex_from_SVertex_ptr( self->ntv->svertex() );
+ SVertex *v = self->ntv->svertex();
+ if( v ){
+ return BPy_SVertex_from_SVertex( *v );
}
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 4ac3d3dd170..6eb97055576 100644
--- a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp
@@ -134,30 +134,33 @@ int TVertex___init__(BPy_TVertex *self, PyObject *args, PyObject *kwds)
self->tv = new TVertex();
self->py_vv.vv = self->tv;
self->py_vv.py_if0D.if0D = self->tv;
+ self->py_vv.py_if0D.borrowed = 0;
return 0;
}
PyObject * TVertex_castToViewVertex( BPy_TVertex *self ) {
- return BPy_ViewVertex_from_ViewVertex_ptr( self->tv->castToViewVertex() );
+ return BPy_ViewVertex_from_ViewVertex( *(self->tv->castToViewVertex()) );
}
PyObject * TVertex_castToTVertex( BPy_TVertex *self ) {
- return BPy_TVertex_from_TVertex_ptr( self->tv->castToTVertex() );
+ return BPy_TVertex_from_TVertex( *(self->tv->castToTVertex()) );
}
PyObject * TVertex_frontSVertex( BPy_TVertex *self ) {
- if( self->tv->frontSVertex() ){
- return BPy_SVertex_from_SVertex_ptr( self->tv->frontSVertex() );
+ SVertex *v = self->tv->frontSVertex();
+ if( v ){
+ return BPy_SVertex_from_SVertex( *v );
}
Py_RETURN_NONE;
}
PyObject * TVertex_backSVertex( BPy_TVertex *self ) {
- if( self->tv->backSVertex() ){
- return BPy_SVertex_from_SVertex_ptr( self->tv->backSVertex() );
+ SVertex *v = self->tv->backSVertex();
+ if( v ){
+ return BPy_SVertex_from_SVertex( *v );
}
Py_RETURN_NONE;
@@ -205,7 +208,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_ptr( sv );
+ return BPy_SVertex_from_SVertex( *sv );
}
Py_RETURN_NONE;
@@ -219,7 +222,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_ptr( ve );
+ return BPy_ViewEdge_from_ViewEdge( *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 4e646de18e6..ccdcbe98c69 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
@@ -155,12 +155,12 @@ int FEdge___init__(BPy_FEdge *self, PyObject *args, PyObject *kwds)
PyObject *obj1 = 0, *obj2 = 0;
- if (! PyArg_ParseTuple(args, "|OO", &obj1, &obj2) )
+ if (! PyArg_ParseTuple(args, "|O!O!", &SVertex_Type, &obj1, &SVertex_Type, &obj2) )
return -1;
if( !obj1 && !obj2 ){
self->fe = new FEdge();
- } else if( BPy_SVertex_Check(obj1) && BPy_SVertex_Check(obj2) ) {
+ } else if( obj1 && obj2 ) {
self->fe = new FEdge( ((BPy_SVertex *) obj1)->sv, ((BPy_SVertex *) obj2)->sv );
} else {
PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
@@ -168,6 +168,7 @@ int FEdge___init__(BPy_FEdge *self, PyObject *args, PyObject *kwds)
}
self->py_if1D.if1D = self->fe;
+ self->py_if1D.borrowed = 0;
return 0;
}
@@ -180,21 +181,24 @@ PyObject * FEdge___copy__( BPy_FEdge *self ) {
py_fe->fe = new FEdge( *(self->fe) );
py_fe->py_if1D.if1D = py_fe->fe;
+ py_fe->py_if1D.borrowed = 0;
return (PyObject *) py_fe;
}
PyObject * FEdge_vertexA( BPy_FEdge *self ) {
- if( self->fe->vertexA() ){
- return BPy_SVertex_from_SVertex_ptr( self->fe->vertexA() );
+ SVertex *A = self->fe->vertexA();
+ if( A ){
+ return BPy_SVertex_from_SVertex( *A );
}
Py_RETURN_NONE;
}
PyObject * FEdge_vertexB( BPy_FEdge *self ) {
- if( self->fe->vertexB() ){
- return BPy_SVertex_from_SVertex_ptr( self->fe->vertexB() );
+ SVertex *B = self->fe->vertexB();
+ if( B ){
+ return BPy_SVertex_from_SVertex( *B );
}
Py_RETURN_NONE;
@@ -211,29 +215,33 @@ PyObject * FEdge___getitem__( BPy_FEdge *self, PyObject *args ) {
return NULL;
}
- if( SVertex *v = self->fe->operator[](i) )
- return BPy_SVertex_from_SVertex_ptr( v );
+ SVertex *v = self->fe->operator[](i);
+ if( v )
+ return BPy_SVertex_from_SVertex( *v );
Py_RETURN_NONE;
}
PyObject * FEdge_nextEdge( BPy_FEdge *self ) {
- if( FEdge *fe = self->fe->nextEdge() )
- return BPy_FEdge_from_FEdge( *fe );
+ FEdge *fe = self->fe->nextEdge();
+ if( fe )
+ return Any_BPy_FEdge_from_FEdge( *fe );
Py_RETURN_NONE;
}
PyObject * FEdge_previousEdge( BPy_FEdge *self ) {
- if( FEdge *fe = self->fe->previousEdge() )
- return BPy_FEdge_from_FEdge( *fe );
+ FEdge *fe = self->fe->previousEdge();
+ if( fe )
+ return Any_BPy_FEdge_from_FEdge( *fe );
Py_RETURN_NONE;
}
PyObject * FEdge_viewedge( BPy_FEdge *self ) {
- if( ViewEdge *ve = self->fe->viewedge() )
- return BPy_ViewEdge_from_ViewEdge_ptr( ve );
+ ViewEdge *ve = self->fe->viewedge();
+ if( ve )
+ return BPy_ViewEdge_from_ViewEdge( *ve );
Py_RETURN_NONE;
}
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
index a44e2feed5b..2194748ef4e 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
@@ -149,6 +149,7 @@ int FrsCurve___init__(BPy_FrsCurve *self, PyObject *args, PyObject *kwds)
}
self->py_if1D.if1D = self->c;
+ self->py_if1D.borrowed = 0;
return 0;
}
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
index 89b9478212f..38cba3f1275 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
@@ -198,6 +198,7 @@ int Stroke___init__(BPy_Stroke *self, PyObject *args, PyObject *kwds)
}
self->py_if1D.if1D = self->s;
+ self->py_if1D.borrowed = 0;
return 0;
}
@@ -216,7 +217,7 @@ PyObject * Stroke_item( BPy_Stroke *self, Py_ssize_t i ) {
PyErr_SetString(PyExc_IndexError, "subscript index out of range");
return NULL;
}
- return BPy_StrokeVertex_from_StrokeVertex_ptr( self->s->strokeVerticeAt(i) );
+ return BPy_StrokeVertex_from_StrokeVertex( self->s->strokeVerticeAt(i) );
}
PyObject * Stroke___getitem__( BPy_Stroke *self, PyObject *item ) {
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp
index 958d96031e3..ba0c4756b9b 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp
@@ -163,54 +163,61 @@ int ViewEdge___init__(BPy_ViewEdge *self, PyObject *args, PyObject *kwds)
{
self->ve = new ViewEdge();
self->py_if1D.if1D = self->ve;
+ self->py_if1D.borrowed = 0;
return 0;
}
PyObject * ViewEdge_A( BPy_ViewEdge *self ) {
- if( self->ve->A() ){
- return BPy_ViewVertex_from_ViewVertex_ptr( self->ve->A() );
+ ViewVertex *v = self->ve->A();
+ if( v ){
+ return Any_BPy_ViewVertex_from_ViewVertex( *v );
}
Py_RETURN_NONE;
}
PyObject * ViewEdge_B( BPy_ViewEdge *self ) {
- if( self->ve->B() ){
- return BPy_ViewVertex_from_ViewVertex_ptr( self->ve->B() );
+ ViewVertex *v = self->ve->B();
+ if( v ){
+ return Any_BPy_ViewVertex_from_ViewVertex( *v );
}
Py_RETURN_NONE;
}
PyObject * ViewEdge_fedgeA( BPy_ViewEdge *self ) {
- if( self->ve->fedgeA() ){
- return BPy_FEdge_from_FEdge(*( self->ve->fedgeA() ));
+ FEdge *A = self->ve->fedgeA();
+ if( A ){
+ return Any_BPy_FEdge_from_FEdge( *A );
}
Py_RETURN_NONE;
}
PyObject * ViewEdge_fedgeB( BPy_ViewEdge *self ) {
- if( self->ve->fedgeB() ){
- return BPy_FEdge_from_FEdge(*( self->ve->fedgeB() ));
+ FEdge *B = self->ve->fedgeB();
+ if( B ){
+ return Any_BPy_FEdge_from_FEdge( *B );
}
Py_RETURN_NONE;
}
PyObject * ViewEdge_viewShape( BPy_ViewEdge *self ) {
- if( self->ve->viewShape() ){
- return BPy_ViewShape_from_ViewShape(*( self->ve->viewShape() ));
+ ViewShape *vs = self->ve->viewShape();
+ if( vs ){
+ return BPy_ViewShape_from_ViewShape( *vs );
}
Py_RETURN_NONE;
}
PyObject * ViewEdge_aShape( BPy_ViewEdge *self ) {
- if( self->ve->aShape() ){
- return BPy_ViewShape_from_ViewShape(*( self->ve->aShape() ));
+ ViewShape *vs = self->ve->aShape();
+ if( vs ){
+ return BPy_ViewShape_from_ViewShape( *vs );
}
Py_RETURN_NONE;
diff --git a/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp b/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp
index 5714f415d80..a80388bd76c 100644
--- a/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp
@@ -137,6 +137,7 @@ int Chain___init__(BPy_Chain *self, PyObject *args, PyObject *kwds)
self->py_c.c = self->c;
self->py_c.py_if1D.if1D = self->c;
+ self->py_c.py_if1D.borrowed = 0;
return 0;
}
diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp
index aa0ba7dfc46..7f60098a4d1 100644
--- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp
@@ -148,6 +148,7 @@ int FEdgeSharp___init__(BPy_FEdgeSharp *self, PyObject *args, PyObject *kwds)
self->py_fe.fe = self->fes;
self->py_fe.py_if1D.if1D = self->fes;
+ self->py_fe.py_if1D.borrowed = 0;
return 0;
}
diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp
index 9913503db58..c19ef463f22 100644
--- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp
@@ -140,6 +140,7 @@ int FEdgeSmooth___init__(BPy_FEdgeSmooth *self, PyObject *args, PyObject *kwds)
self->py_fe.fe = self->fes;
self->py_fe.py_if1D.if1D = self->fes;
+ self->py_fe.py_if1D.borrowed = 0;
return 0;
}
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
index 71105c6896c..99404b2f907 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
@@ -148,9 +148,9 @@ PyObject * AdjacencyIterator_iternext(BPy_AdjacencyIterator *self) {
PyErr_SetNone(PyExc_StopIteration);
return NULL;
}
- ViewEdge *ve = self->a_it->operator->();
+ ViewEdge *ve = self->a_it->operator*();
self->a_it->increment();
- return BPy_ViewEdge_from_ViewEdge_ptr( ve );
+ return BPy_ViewEdge_from_ViewEdge( *ve );
}
PyObject * AdjacencyIterator_isIncoming(BPy_AdjacencyIterator *self) {
@@ -161,7 +161,7 @@ PyObject * AdjacencyIterator_getObject(BPy_AdjacencyIterator *self) {
ViewEdge *ve = self->a_it->operator*();
if( ve )
- return BPy_ViewEdge_from_ViewEdge_ptr( ve );
+ return BPy_ViewEdge_from_ViewEdge( *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 40a984c2cab..678510c1f7d 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
@@ -180,8 +180,9 @@ PyObject *ChainingIterator_traverse( BPy_ChainingIterator *self, PyObject *args
PyObject *ChainingIterator_getVertex( BPy_ChainingIterator *self ) {
- if( self->c_it->getVertex() )
- return BPy_ViewVertex_from_ViewVertex_ptr( self->c_it->getVertex() );
+ ViewVertex *v = self->c_it->getVertex();
+ if( v )
+ return Any_BPy_ViewVertex_from_ViewVertex( *v );
Py_RETURN_NONE;
}
@@ -194,7 +195,7 @@ PyObject * ChainingIterator_getObject( BPy_ChainingIterator *self) {
ViewEdge *ve = self->c_it->operator*();
if( ve )
- return BPy_ViewEdge_from_ViewEdge_ptr( ve );
+ return BPy_ViewEdge_from_ViewEdge( *ve );
Py_RETURN_NONE;
}
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
index 490c8fdf70f..a98053a89a8 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
@@ -156,7 +156,7 @@ PyObject * CurvePointIterator_castToInterface0DIterator( BPy_CurvePointIterator
}
PyObject * CurvePointIterator_getObject(BPy_CurvePointIterator *self) {
- return BPy_CurvePoint_from_CurvePoint_ptr( &(self->cp_it->operator*()) );
+ return BPy_CurvePoint_from_CurvePoint( self->cp_it->operator*() );
}
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
index 4a9d601de25..165d368158f 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
@@ -146,7 +146,7 @@ PyObject * Interface0DIterator_iternext( BPy_Interface0DIterator *self ) {
if0D = self->if0D_it->operator->();
self->if0D_it->increment();
}
- return BPy_Interface0D_from_Interface0D( *if0D );
+ return Any_BPy_Interface0D_from_Interface0D( *if0D );
}
PyObject * Interface0DIterator_t( BPy_Interface0DIterator *self ) {
@@ -158,7 +158,7 @@ PyObject * Interface0DIterator_u( BPy_Interface0DIterator *self ) {
}
PyObject * Interface0DIterator_getObject(BPy_Interface0DIterator *self) {
- return BPy_Interface0D_from_Interface0D( self->if0D_it->operator*() );
+ return Any_BPy_Interface0D_from_Interface0D( self->if0D_it->operator*() );
}
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
index f7cca5941b4..7bc9c31326c 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
@@ -164,7 +164,7 @@ PyObject * SVertexIterator_getObject( BPy_SVertexIterator *self) {
SVertex *sv = self->sv_it->operator->();
if( sv )
- return BPy_SVertex_from_SVertex_ptr( sv );
+ return BPy_SVertex_from_SVertex( *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 86af40ebc36..25caf684b59 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
@@ -159,7 +159,7 @@ PyObject * StrokeVertexIterator_iternext( BPy_StrokeVertexIterator *self ) {
sv = self->sv_it->operator->();
self->sv_it->increment();
}
- return BPy_StrokeVertex_from_StrokeVertex_ptr( sv );
+ return BPy_StrokeVertex_from_StrokeVertex( *sv );
}
PyObject * StrokeVertexIterator_t( BPy_StrokeVertexIterator *self ) {
@@ -178,7 +178,7 @@ PyObject * StrokeVertexIterator_castToInterface0DIterator( BPy_StrokeVertexItera
PyObject * StrokeVertexIterator_getObject( BPy_StrokeVertexIterator *self) {
StrokeVertex *sv = self->sv_it->operator->();
if( sv )
- return BPy_StrokeVertex_from_StrokeVertex_ptr( sv );
+ return BPy_StrokeVertex_from_StrokeVertex( *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 ae1ceaf5da1..0385b8078ce 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp
@@ -157,8 +157,9 @@ int ViewEdgeIterator___init__(BPy_ViewEdgeIterator *self, PyObject *args )
PyObject *ViewEdgeIterator_getCurrentEdge( BPy_ViewEdgeIterator *self ) {
- if( self->ve_it->getCurrentEdge() )
- return BPy_ViewEdge_from_ViewEdge_ptr( self->ve_it->getCurrentEdge() );
+ ViewEdge *ve = self->ve_it->getCurrentEdge();
+ if( ve )
+ return BPy_ViewEdge_from_ViewEdge( *ve );
Py_RETURN_NONE;
}
@@ -176,8 +177,9 @@ PyObject *ViewEdgeIterator_setCurrentEdge( BPy_ViewEdgeIterator *self, PyObject
PyObject *ViewEdgeIterator_getBegin( BPy_ViewEdgeIterator *self ) {
- if( self->ve_it->getBegin() )
- return BPy_ViewEdge_from_ViewEdge_ptr( self->ve_it->getBegin() );
+ ViewEdge *ve = self->ve_it->getBegin();
+ if( ve )
+ return BPy_ViewEdge_from_ViewEdge( *ve );
Py_RETURN_NONE;
}
@@ -218,7 +220,7 @@ PyObject * ViewEdgeIterator_getObject( BPy_ViewEdgeIterator *self) {
ViewEdge *ve = self->ve_it->operator*();
if( ve )
- return BPy_ViewEdge_from_ViewEdge_ptr( ve );
+ return BPy_ViewEdge_from_ViewEdge( *ve );
Py_RETURN_NONE;
}
diff --git a/source/blender/freestyle/intern/stroke/Stroke.cpp b/source/blender/freestyle/intern/stroke/Stroke.cpp
index 01a71f2d4eb..f6cefdfee34 100755
--- a/source/blender/freestyle/intern/stroke/Stroke.cpp
+++ b/source/blender/freestyle/intern/stroke/Stroke.cpp
@@ -45,9 +45,6 @@ StrokeAttribute::StrokeAttribute()
_userAttributesVec2f = 0;
_userAttributesVec3f = 0;
_visible = true;
-
- py_sa = 0;
-
}
StrokeAttribute::StrokeAttribute(const StrokeAttribute& iBrother)
{
@@ -69,10 +66,6 @@ StrokeAttribute::StrokeAttribute(const StrokeAttribute& iBrother)
_userAttributesVec3f = new Vec3fMap(*iBrother._userAttributesVec3f);
else
_userAttributesVec3f = 0;
-
- py_sa = 0;
-
-
}
StrokeAttribute::StrokeAttribute( float iRColor, float iGColor, float iBColor,
float iAlpha,
@@ -92,9 +85,6 @@ StrokeAttribute::StrokeAttribute( float iRColor, float iGColor, float iBColor,
_userAttributesReal = 0;
_userAttributesVec2f = 0;
_userAttributesVec3f = 0;
-
-py_sa = 0;
-
}
StrokeAttribute::StrokeAttribute(const StrokeAttribute& a1, const StrokeAttribute& a2, float t)
@@ -145,8 +135,6 @@ StrokeAttribute::StrokeAttribute(const StrokeAttribute& a1, const StrokeAttribut
}else{
_userAttributesVec3f = 0;
}
-
- py_sa = 0;
}
StrokeAttribute::~StrokeAttribute()
diff --git a/source/blender/freestyle/intern/stroke/Stroke.h b/source/blender/freestyle/intern/stroke/Stroke.h
index a6a025e44a0..796b5dc9e2d 100755
--- a/source/blender/freestyle/intern/stroke/Stroke.h
+++ b/source/blender/freestyle/intern/stroke/Stroke.h
@@ -52,8 +52,6 @@ class LIB_STROKE_EXPORT StrokeAttribute
{
public:
- PyObject *py_sa;
-
/*! default constructor */
StrokeAttribute();
/*! Copy constructor */
@@ -550,7 +548,7 @@ public:
inline unsigned int strokeVerticesSize() const {return _Vertices.size();}
/*! Returns the i-th StrokeVertex constituting the Stroke. */
- inline StrokeVertex* strokeVerticeAt(unsigned int i) {return _Vertices.at(i);}
+ inline StrokeVertex& strokeVerticeAt(unsigned int i) {return *(_Vertices.at(i));}
// Iterator access (Interface1D)
/*! Returns an Interface0DIterator pointing on the first StrokeVertex of the
diff --git a/source/blender/freestyle/intern/view_map/Interface0D.h b/source/blender/freestyle/intern/view_map/Interface0D.h
index c24fbaf9063..5108524cdd3 100755
--- a/source/blender/freestyle/intern/view_map/Interface0D.h
+++ b/source/blender/freestyle/intern/view_map/Interface0D.h
@@ -40,7 +40,15 @@ using namespace std;
#include "../system/Iterator.h" //soc
-#include "../python/Director.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <Python.h>
+
+#ifdef __cplusplus
+}
+#endif
//
// Interface0D
@@ -56,13 +64,11 @@ class TVertex;
class Interface0D
{
public:
-
- PyObject *py_if0D;
-
- /*! Default constructor */
- Interface0D() { py_if0D = 0; }
- virtual ~Interface0D() {}; //soc
+ /*! Default constructor */
+ Interface0D() {}
+ virtual ~Interface0D() {}; //soc
+
/*! Returns the string "Interface0D".*/
virtual string getExactTypeName() const {
return "Interface0D";
@@ -72,185 +78,94 @@ public:
/*! Returns the 3D x coordinate of the point. */
virtual real getX() const {
- string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
-
- if( py_if0D && PyObject_HasAttrString(py_if0D, "getX") ) {
- return Director_BPy_Interface0D_getX(py_if0D);
- } else {
- cerr << "Warning: " << name << " getX() not implemented" << endl;
- return 0;
- }
+ PyErr_SetString(PyExc_TypeError, "method getX() not properly overridden");
+ return 0;
}
-
/*! Returns the 3D y coordinate of the point. */
virtual real getY() const {
- string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
-
- if( py_if0D && PyObject_HasAttrString(py_if0D, "getY") ) {
- return Director_BPy_Interface0D_getY(py_if0D);
- } else {
- cerr << "Warning: " << name << " getY() not implemented" << endl;
- return 0;
- }
+ PyErr_SetString(PyExc_TypeError, "method getY() not properly overridden");
+ return 0;
}
/*! Returns the 3D z coordinate of the point. */
virtual real getZ() const {
- string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
-
- if( py_if0D && PyObject_HasAttrString(py_if0D, "getZ") ) {
- return Director_BPy_Interface0D_getZ(py_if0D);
- } else {
- cerr << "Warning: " << name << " getZ() not implemented" << endl;
- return 0;
- }
+ PyErr_SetString(PyExc_TypeError, "method getZ() not properly overridden");
+ return 0;
}
/*! Returns the 3D point. */
virtual Geometry::Vec3f getPoint3D() const {
- string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
-
- if( py_if0D && PyObject_HasAttrString(py_if0D, "getPoint3D") ) {
- return Director_BPy_Interface0D_getPoint3D(py_if0D);
- } else {
- cerr << "Warning: " << name << " getPoint3D() not implemented" << endl;
- return 0;
- }
+ PyErr_SetString(PyExc_TypeError, "method getPoint3D() not properly overridden");
+ return 0;
}
/*! Returns the 2D x coordinate of the point. */
virtual real getProjectedX() const {
- string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
-
- if( py_if0D && PyObject_HasAttrString(py_if0D, "getProjectedX") ) {
- return Director_BPy_Interface0D_getProjectedX(py_if0D);
- } else {
- cerr << "Warning: " << name << " getProjectedX() not implemented" << endl;
- return 0;
- }
+ PyErr_SetString(PyExc_TypeError, "method getProjectedX() not properly overridden");
+ return 0;
}
/*! Returns the 2D y coordinate of the point. */
virtual real getProjectedY() const {
- string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
-
- if( py_if0D && PyObject_HasAttrString(py_if0D, "getProjectedY") ) {
- return Director_BPy_Interface0D_getProjectedY(py_if0D);
- } else {
- cerr << "Warning: " << name << " getProjectedY() not implemented" << endl;
- return 0;
- }
+ PyErr_SetString(PyExc_TypeError, "method getProjectedY() not properly overridden");
+ return 0;
}
/*! Returns the 2D z coordinate of the point. */
virtual real getProjectedZ() const {
- string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
-
- if( py_if0D && PyObject_HasAttrString(py_if0D, "getProjectedZ") ) {
- return Director_BPy_Interface0D_getProjectedZ(py_if0D);
- } else {
- cerr << "Warning: " << name << " getProjectedZ() not implemented" << endl;
- return 0;
- }
+ PyErr_SetString(PyExc_TypeError, "method getProjectedZ() not properly overridden");
+ return 0;
}
/*! Returns the 2D point. */
virtual Geometry::Vec2f getPoint2D() const {
- string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
-
- if( py_if0D && PyObject_HasAttrString(py_if0D, "getPoint2D") ) {
- return Director_BPy_Interface0D_getPoint2D(py_if0D);
- } else {
- cerr << "Warning: " << name << " getPoint2D() not implemented" << endl;
- return 0;
- }
+ PyErr_SetString(PyExc_TypeError, "method getPoint2D() not properly overridden");
+ return 0;
}
/*! Returns the FEdge that lies between this Interface0D and the
* Interface0D given as argument. */
virtual FEdge* getFEdge(Interface0D&) {
- string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
-
- if( py_if0D && PyObject_HasAttrString(py_if0D, "getFEdge") ) {
- return Director_BPy_Interface0D_getFEdge(py_if0D);
- } else {
- cerr << "Warning: " << name << " getFEdge() not implemented" << endl;
- return 0;
- }
+ PyErr_SetString(PyExc_TypeError, "method getFEdge() not properly overridden");
+ return 0;
}
/*! Returns the Id of the point. */
virtual Id getId() const {
- string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
-
- if( py_if0D && PyObject_HasAttrString(py_if0D, "getId") ) {
- return Director_BPy_Interface0D_getId(py_if0D);
- } else {
- cerr << "Warning: " << name << " getId() not implemented" << endl;
- return 0;
- }
+ PyErr_SetString(PyExc_TypeError, "method getId() not properly overridden");
+ return 0;
}
/*! Returns the nature of the point. */
virtual Nature::VertexNature getNature() const {
- string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
-
- if( py_if0D && PyObject_HasAttrString(py_if0D, "getNature") ) {
- return Director_BPy_Interface0D_getNature(py_if0D);
- } else {
- cerr << "Warning: " << name << " getNature() not implemented" << endl;
- return Nature::POINT;
- }
+ PyErr_SetString(PyExc_TypeError, "method getNature() not properly overridden");
+ return Nature::POINT;
}
/*! Cast the Interface0D in SVertex if it can be. */
virtual SVertex * castToSVertex(){
- string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
-
- if( py_if0D && PyObject_HasAttrString(py_if0D, "castToSVertex") ) {
- return Director_BPy_Interface0D_castToSVertex(py_if0D);
- } else {
- cerr << "Warning: " << name << " castToSVertex() not implemented" << endl;
- return 0;
- }
+ PyErr_SetString(PyExc_TypeError, "method castToSVertex() not properly overridden");
+ return 0;
}
/*! Cast the Interface0D in ViewVertex if it can be. */
virtual ViewVertex * castToViewVertex(){
- string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
-
- if( py_if0D && PyObject_HasAttrString(py_if0D, "castToViewVertex") ) {
- return Director_BPy_Interface0D_castToViewVertex(py_if0D);
- } else {
- cerr << "Warning: " << name << " castToViewVertex() not implemented" << endl;
- return 0;
- }
+ PyErr_SetString(PyExc_TypeError, "method castToViewVertex() not properly overridden");
+ return 0;
}
/*! Cast the Interface0D in NonTVertex if it can be. */
virtual NonTVertex * castToNonTVertex(){
- string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
-
- if( py_if0D && PyObject_HasAttrString(py_if0D, "castToNonTVertex") ) {
- return Director_BPy_Interface0D_castToNonTVertex(py_if0D);
- } else {
- cerr << "Warning: " << name << " castToNonTVertex() not implemented" << endl;
- return 0;
- }
+ PyErr_SetString(PyExc_TypeError, "method castToNonTVertex() not properly overridden");
+ return 0;
}
/*! Cast the Interface0D in TVertex if it can be. */
virtual TVertex * castToTVertex(){
- string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
-
- if( py_if0D && PyObject_HasAttrString(py_if0D, "castToTVertex") ) {
- return Director_BPy_Interface0D_castToTVertex(py_if0D);
- } else {
- cerr << "Warning: " << name << " castToTVertex() not implemented" << endl;
- return 0;
- }
+ PyErr_SetString(PyExc_TypeError, "method castToTVertex() not properly overridden");
+ return 0;
}
};
diff --git a/source/blender/freestyle/intern/view_map/Interface1D.h b/source/blender/freestyle/intern/view_map/Interface1D.h
index c626bcbef80..17dee3973de 100755
--- a/source/blender/freestyle/intern/view_map/Interface1D.h
+++ b/source/blender/freestyle/intern/view_map/Interface1D.h
@@ -38,7 +38,15 @@
# include "../winged_edge/Nature.h"
# include "Functions0D.h"
-#include "../python/Director.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <Python.h>
+
+#ifdef __cplusplus
+}
+#endif
using namespace std;
/*! \file Interface1D.h
@@ -133,11 +141,9 @@ class Interface1D
{
public:
- PyObject *py_if1D;
-
/*! Default constructor */
- Interface1D() {_timeStamp=0; py_if1D = 0; }
- virtual ~Interface1D() {}; //soc
+ Interface1D() {_timeStamp=0;}
+ virtual ~Interface1D() {}; //soc
/*! Returns the string "Interface1D" .*/
virtual string getExactTypeName() const {
@@ -150,28 +156,16 @@ public:
* pointing to the first vertex.
*/
virtual Interface0DIterator verticesBegin() {
- string name( py_if1D ? PyString_AsString(PyObject_CallMethod(py_if1D, "getExactTypeName", "")) : getExactTypeName() );
-
- if( py_if1D && PyObject_HasAttrString(py_if1D, "verticesBegin") ) {
- return Director_BPy_Interface1D_verticesBegin(py_if1D);
- } else {
- cerr << "Warning: " << name << " verticesBegin() not implemented" << endl;
- return Interface0DIterator();
- }
+ PyErr_SetString(PyExc_TypeError, "method verticesBegin() not properly overridden");
+ return Interface0DIterator();
}
/*! Returns an iterator over the Interface1D vertices,
* pointing after the last vertex.
*/
virtual Interface0DIterator verticesEnd(){
- string name( py_if1D ? PyString_AsString(PyObject_CallMethod(py_if1D, "getExactTypeName", "")) : getExactTypeName() );
-
- if( py_if1D && PyObject_HasAttrString(py_if1D, "verticesEnd") ) {
- return Director_BPy_Interface1D_verticesEnd(py_if1D);
- } else {
- cerr << "Warning: " << name << " verticesEnd() not implemented" << endl;
- return Interface0DIterator();
- }
+ PyErr_SetString(PyExc_TypeError, "method verticesEnd() not properly overridden");
+ return Interface0DIterator();
}
/*! Returns an iterator over the Interface1D points,
@@ -184,14 +178,8 @@ public:
* this 1D element.
*/
virtual Interface0DIterator pointsBegin(float t=0.f) {
- string name( py_if1D ? PyString_AsString(PyObject_CallMethod(py_if1D, "getExactTypeName", "")) : getExactTypeName() );
-
- if( py_if1D && PyObject_HasAttrString(py_if1D, "pointsBegin") ) {
- return Director_BPy_Interface1D_pointsBegin(py_if1D);
- } else {
- cerr << "Warning: " << name << " pointsBegin() not implemented" << endl;
- return Interface0DIterator();
- }
+ PyErr_SetString(PyExc_TypeError, "method pointsBegin() not properly overridden");
+ return Interface0DIterator();
}
/*! Returns an iterator over the Interface1D points,
@@ -204,54 +192,30 @@ public:
* this 1D element.
*/
virtual Interface0DIterator pointsEnd(float t=0.f) {
- string name( py_if1D ? PyString_AsString(PyObject_CallMethod(py_if1D, "getExactTypeName", "")) : getExactTypeName() );
-
- if( py_if1D && PyObject_HasAttrString(py_if1D, "pointsEnd") ) {
- return Director_BPy_Interface1D_pointsEnd(py_if1D);
- } else {
- cerr << "Warning: " << name << " pointsEnd() not implemented" << endl;
- return Interface0DIterator();
- }
+ PyErr_SetString(PyExc_TypeError, "method pointsEnd() not properly overridden");
+ return Interface0DIterator();
}
// Data access methods
/*! Returns the 2D length of the 1D element. */
virtual real getLength2D() const {
- string name( py_if1D ? PyString_AsString(PyObject_CallMethod(py_if1D, "getExactTypeName", "")) : getExactTypeName() );
-
- if( py_if1D && PyObject_HasAttrString(py_if1D, "getLength2D") ) {
- return Director_BPy_Interface1D_getLength2D(py_if1D);
- } else {
- cerr << "Warning: " << name << " getLength2D() not implemented" << endl;
- return 0;
- }
+ PyErr_SetString(PyExc_TypeError, "method getLength2D() not properly overridden");
+ return 0;
}
/*! Returns the Id of the 1D element .*/
virtual Id getId() const {
- string name( py_if1D ? PyString_AsString(PyObject_CallMethod(py_if1D, "getExactTypeName", "")) : getExactTypeName() );
-
- if( py_if1D && PyObject_HasAttrString(py_if1D, "getId") ) {
- return Director_BPy_Interface1D_getId(py_if1D);
- } else {
- cerr << "Warning: " << name << " getId() not implemented" << endl;
- return Id(0, 0);
- }
+ PyErr_SetString(PyExc_TypeError, "method getId() not properly overridden");
+ return Id(0, 0);
}
// FIXME: ce truc n'a rien a faire la...(c une requete complexe qui doit etre ds les Function1D)
/*! Returns the nature of the 1D element. */
virtual Nature::EdgeNature getNature() const {
- string name( py_if1D ? PyString_AsString(PyObject_CallMethod(py_if1D, "getExactTypeName", "")) : getExactTypeName() );
-
- if( py_if1D && PyObject_HasAttrString(py_if1D, "getNature") ) {
- return Director_BPy_Interface1D_getNature(py_if1D);
- } else {
- cerr << "Warning: " << name << " getNature() not implemented" << endl;
- return Nature::NO_FEATURE;
- }
+ PyErr_SetString(PyExc_TypeError, "method getNature() not properly overridden");
+ return Nature::NO_FEATURE;
}
/*! Returns the time stamp of the 1D element. Mainly used for selection. */