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:
authorMaxime Curioni <maxime.curioni@gmail.com>2008-07-31 12:50:12 +0400
committerMaxime Curioni <maxime.curioni@gmail.com>2008-07-31 12:50:12 +0400
commit3010f2b753f2397256861816504b8e7d697632db (patch)
treecee975b7fc574c43be0d462447c87056c4bdfc6b /source/blender/freestyle/intern
parenta482f644242456ad6ddf0306e1b37d8855342103 (diff)
soc-2008-mxcurioni: the native Python system now supports cross-language polymorphism for the following classes: BinaryPredicate0D (__call__), BinaryPredicate1D (__call__), UnaryPredicate0D (__call__), UnaryPredicate1D (__call__), StrokeShader (shade), ChainingIterator (init, traverse).
Other methods could easily be supported in the future. The method now works as planned for the contour style. For style modules with Python shaders, there still is a problem that I will fix right away.
Diffstat (limited to 'source/blender/freestyle/intern')
-rw-r--r--source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp1
-rw-r--r--source/blender/freestyle/intern/python/BPy_Convert.cpp9
-rw-r--r--source/blender/freestyle/intern/python/BPy_Convert.h1
-rw-r--r--source/blender/freestyle/intern/python/BPy_Operators.cpp26
-rw-r--r--source/blender/freestyle/intern/python/BPy_StrokeShader.cpp1
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h1
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h1
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp1
-rw-r--r--source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp1
-rw-r--r--source/blender/freestyle/intern/python/Director.cpp82
-rw-r--r--source/blender/freestyle/intern/python/Director.h67
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp2
-rwxr-xr-xsource/blender/freestyle/intern/stroke/ChainingIterators.h38
-rwxr-xr-xsource/blender/freestyle/intern/stroke/Predicates0D.h34
-rwxr-xr-xsource/blender/freestyle/intern/stroke/Predicates1D.h31
-rwxr-xr-xsource/blender/freestyle/intern/stroke/Stroke.h1
-rwxr-xr-xsource/blender/freestyle/intern/stroke/StrokeShader.h15
-rwxr-xr-xsource/blender/freestyle/intern/view_map/Functions0D.h2
-rwxr-xr-xsource/blender/freestyle/intern/view_map/Functions1D.h2
20 files changed, 256 insertions, 62 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp b/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp
index 9c3247b30b8..bcd98a42189 100644
--- a/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp
@@ -127,6 +127,8 @@ PyMODINIT_FUNC BinaryPredicate0D_Init( PyObject *module )
int BinaryPredicate0D___init__(BPy_BinaryPredicate0D *self, PyObject *args, PyObject *kwds)
{
self->bp0D = new BinaryPredicate0D();
+ self->bp0D->py_bp0D = (PyObject *) self;
+
return 0;
}
diff --git a/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp b/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp
index 545807fc277..9f7e0359ec8 100644
--- a/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp
@@ -159,6 +159,7 @@ PyMODINIT_FUNC BinaryPredicate1D_Init( PyObject *module )
int BinaryPredicate1D___init__(BPy_BinaryPredicate1D *self, PyObject *args, PyObject *kwds)
{
self->bp1D = new BinaryPredicate1D();
+ self->bp1D->py_bp1D = (PyObject *) self;
return 0;
}
diff --git a/source/blender/freestyle/intern/python/BPy_Convert.cpp b/source/blender/freestyle/intern/python/BPy_Convert.cpp
index d7b6fa8bd33..0b136b7702f 100644
--- a/source/blender/freestyle/intern/python/BPy_Convert.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Convert.cpp
@@ -11,6 +11,7 @@
#include "Interface0D/BPy_ViewVertex.h"
#include "BPy_Interface1D.h"
#include "Interface1D/BPy_FEdge.h"
+#include "Interface1D/BPy_Stroke.h"
#include "Interface1D/BPy_ViewEdge.h"
#include "BPy_Nature.h"
#include "BPy_MediumType.h"
@@ -115,6 +116,14 @@ PyObject * BPy_Nature_from_Nature( unsigned short n ) {
return py_n;
}
+PyObject * BPy_Stroke_from_Stroke( Stroke& s ) {
+ PyObject *py_s = Stroke_Type.tp_new( &Stroke_Type, 0, 0 );
+ ((BPy_Stroke *) py_s)->s = new Stroke( s );
+ ((BPy_Stroke *) py_s)->py_if1D.if1D = ((BPy_Stroke *) py_s)->s;
+
+ return py_s;
+}
+
PyObject * BPy_StrokeAttribute_from_StrokeAttribute( StrokeAttribute& sa ) {
PyObject *py_sa = StrokeAttribute_Type.tp_new( &StrokeAttribute_Type, 0, 0 );
((BPy_StrokeAttribute *) py_sa)->sa = new StrokeAttribute( sa );
diff --git a/source/blender/freestyle/intern/python/BPy_Convert.h b/source/blender/freestyle/intern/python/BPy_Convert.h
index 9e743f4b233..4bfaf4c1e17 100644
--- a/source/blender/freestyle/intern/python/BPy_Convert.h
+++ b/source/blender/freestyle/intern/python/BPy_Convert.h
@@ -80,6 +80,7 @@ PyObject * BPy_FrsMaterial_from_Material( Material& m );
PyObject * BPy_Nature_from_Nature( unsigned short n );
PyObject * BPy_MediumType_from_MediumType( int n );
PyObject * BPy_SShape_from_SShape( SShape& ss );
+PyObject * BPy_Stroke_from_Stroke( Stroke& s );
PyObject * BPy_StrokeAttribute_from_StrokeAttribute( StrokeAttribute& sa );
PyObject * BPy_StrokeVertex_from_StrokeVertex( StrokeVertex& sv );
PyObject * BPy_SVertex_from_SVertex( SVertex& sv );
diff --git a/source/blender/freestyle/intern/python/BPy_Operators.cpp b/source/blender/freestyle/intern/python/BPy_Operators.cpp
index 850b4cb5bad..ab64f5bc6eb 100644
--- a/source/blender/freestyle/intern/python/BPy_Operators.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Operators.cpp
@@ -164,21 +164,19 @@ PyObject * Operators_select(BPy_Operators* self, PyObject *args)
Py_RETURN_NONE;
}
- UnaryPredicate1D *up1D = ((BPy_UnaryPredicate1D *) obj)->up1D;
- if( PyObject_HasAttrString( obj, "__call__") )
- up1D->setPythonObject( obj );
-
- Operators::select(*up1D);
+ Operators::select(*( ((BPy_UnaryPredicate1D *) obj)->up1D ));
Py_RETURN_NONE;
}
+// CHANGE: first parameter is a chaining iterator, not just a view
+
PyObject * Operators_chain(BPy_Operators* self, PyObject *args)
{
PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0;
if(!( PyArg_ParseTuple(args, "OO|O", &obj1, &obj2, &obj3) &&
- BPy_ViewEdgeIterator_Check(obj1) && ((BPy_ViewEdgeIterator *) obj1)->ve_it &&
+ BPy_ChainingIterator_Check(obj1) && ((BPy_ChainingIterator *) obj1)->c_it &&
BPy_UnaryPredicate1D_Check(obj2) && ((BPy_UnaryPredicate1D *) obj2)->up1D )) {
cout << "ERROR: Operators_chain" << endl;
Py_RETURN_NONE;
@@ -186,12 +184,13 @@ PyObject * Operators_chain(BPy_Operators* self, PyObject *args)
if( !obj3 ) {
- Operators::chain( *( ((BPy_ViewEdgeIterator *) obj1)->ve_it ),
+ Operators::chain( *( ((BPy_ChainingIterator *) obj1)->c_it ),
*( ((BPy_UnaryPredicate1D *) obj2)->up1D ) );
} else if( BPy_UnaryFunction1DVoid_Check(obj3) && ((BPy_UnaryFunction1DVoid *) obj3)->uf1D_void ) {
- Operators::chain( *( ((BPy_ViewEdgeIterator *) obj1)->ve_it ),
+
+ Operators::chain( *( ((BPy_ChainingIterator *) obj1)->c_it ),
*( ((BPy_UnaryPredicate1D *) obj2)->up1D ),
*( ((BPy_UnaryFunction1DVoid *) obj3)->uf1D_void ) );
@@ -209,7 +208,7 @@ PyObject * Operators_bidirectionalChain(BPy_Operators* self, PyObject *args)
cout << "ERROR: Operators_bidirectionalChain" << endl;
Py_RETURN_NONE;
}
-
+
if( !obj2 ) {
Operators::bidirectionalChain( *( ((BPy_ChainingIterator *) obj1)->c_it ) );
@@ -234,7 +233,7 @@ PyObject * Operators_sequentialSplit(BPy_Operators* self, PyObject *args)
cout << "ERROR: Operators_sequentialSplit" << endl;
Py_RETURN_NONE;
}
-
+
if( obj2 && BPy_UnaryPredicate0D_Check(obj2) ) {
Operators::sequentialSplit( *( ((BPy_UnaryPredicate0D *) obj1)->up0D ),
@@ -266,7 +265,7 @@ PyObject * Operators_recursiveSplit(BPy_Operators* self, PyObject *args)
if( BPy_UnaryPredicate1D_Check(obj2) && ((BPy_UnaryPredicate1D *) obj2)->up1D ) {
float f = ( obj3 && PyFloat_Check(obj3) ) ? PyFloat_AsDouble(obj3) : 0.0;
-
+
Operators::recursiveSplit( *( ((BPy_UnaryFunction0DDouble *) obj1)->uf0D_double ),
*( ((BPy_UnaryPredicate1D *) obj2)->up1D ),
f );
@@ -313,8 +312,9 @@ PyObject * Operators_create(BPy_Operators* self, PyObject *args)
vector<StrokeShader *> shaders;
for( int i = 0; i < PyList_Size(obj2); i++) {
PyObject *py_ss = PyList_GetItem(obj2,i);
- if( BPy_StrokeShader_Check(py_ss) )
- shaders.push_back( ((BPy_StrokeShader *) py_ss)->ss );
+
+ if( BPy_StrokeShader_Check(py_ss) )
+ shaders.push_back( ((BPy_StrokeShader *) py_ss)->ss );
}
Operators::create( *( ((BPy_UnaryPredicate1D *) obj1)->up1D ), shaders);
diff --git a/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp b/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp
index a6d2ae1e512..3b756b40d9b 100644
--- a/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp
+++ b/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp
@@ -254,6 +254,7 @@ PyMODINIT_FUNC StrokeShader_Init( PyObject *module )
int StrokeShader___init__(BPy_StrokeShader *self, PyObject *args, PyObject *kwds)
{
self->ss = new StrokeShader();
+ self->ss->py_ss = (PyObject *) self;
return 0;
}
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h b/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h
index 0ab0bfbdc2e..d95230ecccd 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h
+++ b/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h
@@ -18,6 +18,7 @@ extern PyTypeObject UnaryFunction0D_Type;
/*---------------------------Python BPy_UnaryFunction0D structure definition----------*/
typedef struct {
PyObject_HEAD
+ PyObject *py_uf0D;
} BPy_UnaryFunction0D;
/*---------------------------Python BPy_UnaryFunction0D visible prototypes-----------*/
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h b/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h
index f33fcf48da4..571ef8a5d25 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h
+++ b/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h
@@ -18,6 +18,7 @@ extern PyTypeObject UnaryFunction1D_Type;
/*---------------------------Python BPy_UnaryFunction1D structure definition----------*/
typedef struct {
PyObject_HEAD
+ PyObject *py_uf1D;
} BPy_UnaryFunction1D;
/*---------------------------Python BPy_UnaryFunction1D visible prototypes-----------*/
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp
index 4fef63eae9b..db708c7830b 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp
@@ -139,6 +139,7 @@ PyMODINIT_FUNC UnaryPredicate0D_Init( PyObject *module )
int UnaryPredicate0D___init__(BPy_UnaryPredicate0D *self, PyObject *args, PyObject *kwds)
{
self->up0D = new UnaryPredicate0D();
+ self->up0D->py_up0D = (PyObject *) self;
return 0;
}
diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp
index 14eb041c480..f2b2c7b9b53 100644
--- a/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp
@@ -181,6 +181,7 @@ PyMODINIT_FUNC UnaryPredicate1D_Init( PyObject *module )
int UnaryPredicate1D___init__(BPy_UnaryPredicate1D *self, PyObject *args, PyObject *kwds)
{
self->up1D = new UnaryPredicate1D();
+ self->up1D->py_up1D = (PyObject *) self;
return 0;
}
diff --git a/source/blender/freestyle/intern/python/Director.cpp b/source/blender/freestyle/intern/python/Director.cpp
index 6acdc665a0c..d3aff4a65f2 100644
--- a/source/blender/freestyle/intern/python/Director.cpp
+++ b/source/blender/freestyle/intern/python/Director.cpp
@@ -2,11 +2,85 @@
#include "BPy_Convert.h"
-bool director_BPy_UnaryPredicate1D___call__( PyObject *py_up1D, Interface1D& if1D) {
- cout << "Polymorphism works" << endl;
+#include "BPy_BinaryPredicate0D.h"
+#include "BPy_BinaryPredicate1D.h"
+#include "BPy_UnaryFunction0D.h"
+#include "BPy_UnaryFunction1D.h"
+#include "BPy_UnaryPredicate0D.h"
+#include "BPy_UnaryPredicate1D.h"
+#include "BPy_StrokeShader.h"
+#include "Iterator/BPy_ChainingIterator.h"
+#include "Interface1D/BPy_Stroke.h"
+#include "Interface1D/BPy_ViewEdge.h"
- PyObject *method = PyObject_GetAttrString( py_up1D, "__call__");
- PyObject *result = PyObject_CallFunction(method, "O", BPy_Interface1D_from_Interface1D(if1D) );
+// BinaryPredicate0D: __call__
+bool Director_BPy_BinaryPredicate0D___call__( PyObject *obj, Interface0D& i1, Interface0D& i2) {
+ PyObject *result = PyObject_CallMethod( obj, "__call__", "OO", BPy_Interface0D_from_Interface0D(i1), BPy_Interface0D_from_Interface0D(i2) );
+
+ return bool_from_PyBool(result);
+}
+
+
+// BinaryPredicate1D: __call__
+bool Director_BPy_BinaryPredicate1D___call__( PyObject *obj, Interface1D& i1, Interface1D& i2) {
+ PyObject *result = PyObject_CallMethod( obj, "__call__", "OO", BPy_Interface1D_from_Interface1D(i1), BPy_Interface1D_from_Interface1D(i2) );
+
+ return bool_from_PyBool(result);
+}
+
+
+// UnaryPredicate0D: __call__
+bool Director_BPy_UnaryPredicate0D___call__( PyObject *obj, Interface0DIterator& if0D_it) {
+ PyObject *result = PyObject_CallMethod( obj, "__call__", "O", BPy_Interface0DIterator_from_Interface0DIterator(if0D_it) );
+
+ return bool_from_PyBool(result);
+}
+
+
+// UnaryPredicate1D: __call__
+bool Director_BPy_UnaryPredicate1D___call__( PyObject *obj, Interface1D& if1D) {
+ PyObject *result = PyObject_CallMethod( obj, "__call__", "O", BPy_Interface1D_from_Interface1D(if1D) );
return bool_from_PyBool(result);
}
+
+
+// StrokeShader: shade
+void Director_BPy_StrokeShader_shade( PyObject *obj, Stroke& s) {
+ PyObject_CallMethod( obj, "shade", "O", BPy_Stroke_from_Stroke(s) );
+}
+
+// ChainingIterator: init, traverse
+void Director_BPy_ChainingIterator_init( PyObject *obj ) {
+ PyObject_CallMethod( obj, "init", "", 0 );
+}
+
+ViewEdge * Director_BPy_ChainingIterator_traverse( PyObject *obj, AdjacencyIterator& a_it ) {
+ PyObject *result = PyObject_CallMethod( obj, "traverse", "O", BPy_AdjacencyIterator_from_AdjacencyIterator(a_it) );
+
+ return ((BPy_ViewEdge *) result)->ve;
+}
+
+
+// BPy_UnaryFunction{0D,1D}: __call__
+// BPy_UnaryFunction0DDouble
+// BPy_UnaryFunction0DEdgeNature
+// BPy_UnaryFunction0DFloat
+// BPy_UnaryFunction0DId
+// BPy_UnaryFunction0DMaterial
+// BPy_UnaryFunction0DUnsigned
+// BPy_UnaryFunction0DVec2f
+// BPy_UnaryFunction0DVec3f
+// BPy_UnaryFunction0DVectorViewShape
+// BPy_UnaryFunction0DViewShape
+
+// BPy_UnaryFunction1DDouble
+// BPy_UnaryFunction1DEdgeNature
+// BPy_UnaryFunction1DFloat
+// BPy_UnaryFunction1DUnsigned
+// BPy_UnaryFunction1DVec2f
+// BPy_UnaryFunction1DVec3f
+// BPy_UnaryFunction1DVectorViewShape
+// BPy_UnaryFunction1DVoid
+
+
diff --git a/source/blender/freestyle/intern/python/Director.h b/source/blender/freestyle/intern/python/Director.h
index 7114b124ffb..95ab16047a8 100644
--- a/source/blender/freestyle/intern/python/Director.h
+++ b/source/blender/freestyle/intern/python/Director.h
@@ -1,34 +1,65 @@
#ifndef FREESTYLE_PYTHON_DIRECTOR
# define FREESTYLE_PYTHON_DIRECTOR
-#include "../view_map/Interface1D.h"
+class Interface0D;
+class Interface1D;
+class Interface0DIterator;
+class Stroke;
+class AdjacencyIterator;
+class ViewEdge;
#ifdef __cplusplus
extern "C" {
#endif
-///////////////////////////////////////////////////////////////////////////////////////////
-
#include <Python.h>
-// SWIG directors
-// ----------------------------
-// ViewEdgeInternal::ViewEdgeIterator;
-// ChainingIterator;
-// ChainSilhouetteIterator;
-// ChainPredicateIterator;
-// UnaryPredicate0D;
-// UnaryPredicate1D;
-// BinaryPredicate1D;
-// StrokeShader;
-
-bool director_BPy_UnaryPredicate1D___call__( PyObject *py_up1D, Interface1D& if1D);
-
-///////////////////////////////////////////////////////////////////////////////////////////
-
#ifdef __cplusplus
}
#endif
+// BinaryPredicate0D: __call__
+bool Director_BPy_BinaryPredicate0D___call__( PyObject *obj, Interface0D& i1, Interface0D& i2);
+
+// BinaryPredicate1D: __call__
+bool Director_BPy_BinaryPredicate1D___call__( PyObject *obj, Interface1D& i1, Interface1D& i2);
+
+// UnaryPredicate0D: __call__
+bool Director_BPy_UnaryPredicate0D___call__( PyObject *obj, Interface0DIterator& if0D_it);
+
+// UnaryPredicate1D: __call__
+bool Director_BPy_UnaryPredicate1D___call__( PyObject *obj, Interface1D& if1D);
+
+// StrokeShader: shade
+void Director_BPy_StrokeShader_shade( PyObject *obj, Stroke& s);
+
+// ChainingIterator: init, traverse
+void Director_BPy_ChainingIterator_init( PyObject *obj );
+ViewEdge * Director_BPy_ChainingIterator_traverse( PyObject *obj, AdjacencyIterator& a_it );
+
+// BPy_UnaryFunction0DDouble
+double Director_BPy_UnaryFunction0DDouble___call__( PyObject *obj, Interface0DIterator& if0D_it);
+// BPy_UnaryFunction0DEdgeNature
+// BPy_UnaryFunction0DFloat
+// BPy_UnaryFunction0DId
+// BPy_UnaryFunction0DMaterial
+// BPy_UnaryFunction0DUnsigned
+// BPy_UnaryFunction0DVec2f
+// BPy_UnaryFunction0DVec3f
+// BPy_UnaryFunction0DVectorViewShape
+// BPy_UnaryFunction0DViewShape
+
+// BPy_UnaryFunction1DDouble
+// BPy_UnaryFunction1DEdgeNature
+// BPy_UnaryFunction1DFloat
+// BPy_UnaryFunction1DUnsigned
+// BPy_UnaryFunction1DVec2f
+// BPy_UnaryFunction1DVec3f
+// BPy_UnaryFunction1DVectorViewShape
+// BPy_UnaryFunction1DVoid
+void Director_BPy_UnaryFunction1DVoid___call__( PyObject *obj, Interface1D& if1D);
+
+
+
#endif // FREESTYLE_PYTHON_DIRECTOR
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
index 525b0697fa7..f33fe0e17bc 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
@@ -139,6 +139,8 @@ int ChainingIterator___init__(BPy_ChainingIterator *self, PyObject *args )
self->py_ve_it.ve_it = self->c_it;
self->py_ve_it.py_it.it = self->c_it;
+ self->c_it->py_c_it = (PyObject *) self;
+
return 0;
}
diff --git a/source/blender/freestyle/intern/stroke/ChainingIterators.h b/source/blender/freestyle/intern/stroke/ChainingIterators.h
index b01c895d89a..1f33f99db67 100755
--- a/source/blender/freestyle/intern/stroke/ChainingIterators.h
+++ b/source/blender/freestyle/intern/stroke/ChainingIterators.h
@@ -36,6 +36,8 @@
#include "../system/Iterator.h" //soc
+# include "../python/Director.h"
+
//using namespace ViewEdgeInternal;
//
@@ -135,6 +137,9 @@ protected:
bool _increment; //true if we're currently incrementing, false when decrementing
public:
+
+ PyObject *py_c_it;
+
/*! Builds a Chaining Iterator from the first ViewEdge used for iteration
* and its orientation.
* \param iRestrictToSelection
@@ -154,6 +159,7 @@ public:
_restrictToSelection = iRestrictToSelection;
_restrictToUnvisited = iRestrictToUnvisited;
_increment = true;
+ py_c_it = 0;
}
/*! Copy constructor */
@@ -162,6 +168,7 @@ public:
_restrictToSelection = brother._restrictToSelection;
_restrictToUnvisited = brother._restrictToUnvisited;
_increment = brother._increment;
+ py_c_it = brother.py_c_it;
}
/*! Returns the string "ChainingIterator" */
@@ -176,7 +183,16 @@ public:
* history information that you
* might want to keep.
*/
- virtual void init(){}
+ virtual void init() {
+ string name( py_c_it ? PyString_AsString(PyObject_CallMethod(py_c_it, "getExactTypeName", "")) : getExactTypeName() );
+
+ if( py_c_it && PyObject_HasAttrString(py_c_it, "init") ) {
+ Director_BPy_ChainingIterator_init( py_c_it );
+ } else {
+ cerr << "Warning: " << name << " method init() not implemented" << endl;
+ }
+
+ }
/*! This method iterates over the potential next
* ViewEdges and returns the one that will be
@@ -190,10 +206,16 @@ public:
* rules by only iterating over the valid ViewEdges.
*/
virtual ViewEdge * traverse(const AdjacencyIterator &it){
- cerr << "Warning: the traverse method was not defined" << endl;
- return 0;
+ string name( py_c_it ? PyString_AsString(PyObject_CallMethod(py_c_it, "getExactTypeName", "")) : getExactTypeName() );
+
+ if( py_c_it && PyObject_HasAttrString(py_c_it, "traverse") ) {
+ return Director_BPy_ChainingIterator_traverse(py_c_it, const_cast<AdjacencyIterator &>(it) );
+ } else {
+ cerr << "Warning: the " << name << " traverse method was not defined" << endl;
+ return 0;
+ }
}
-
+
/* accessors */
/*! Returns true if the orientation of the current ViewEdge
* corresponds to its natural orientation
@@ -274,6 +296,8 @@ public:
*/
virtual ViewEdge * traverse(const AdjacencyIterator& it);
+ /*! Inits the iterator context */
+ virtual void init() {}
};
//
@@ -368,7 +392,11 @@ public:
* followed next.
* When reaching the end of a chain, 0 is returned.
*/
- virtual ViewEdge * traverse(const AdjacencyIterator &it);
+ virtual ViewEdge * traverse(const AdjacencyIterator &it);
+
+ /*! Inits the iterator context */
+ virtual void init() {}
+
};
#endif // CHAININGITERATORS_H
diff --git a/source/blender/freestyle/intern/stroke/Predicates0D.h b/source/blender/freestyle/intern/stroke/Predicates0D.h
index 4c2dfacdf98..0318c1742ec 100755
--- a/source/blender/freestyle/intern/stroke/Predicates0D.h
+++ b/source/blender/freestyle/intern/stroke/Predicates0D.h
@@ -32,6 +32,8 @@
# include "../view_map/Functions0D.h"
+# include "../python/Director.h"
+
//
// UnaryPredicate0D (base class for predicates in 0D)
//
@@ -48,8 +50,11 @@
class UnaryPredicate0D
{
public:
+
+ PyObject *py_up0D;
+
/*! Default constructor. */
- UnaryPredicate0D() {}
+ UnaryPredicate0D() { py_up0D = 0; }
/*! Destructor. */
virtual ~UnaryPredicate0D() {}
/*! Returns the string of the name
@@ -68,9 +73,16 @@ public:
* false otherwise.
*/
virtual bool operator()(Interface0DIterator& it) {
- cerr << "Warning: operator() not implemented" << endl;
- return false;
+ string name( py_up0D ? PyString_AsString(PyObject_CallMethod(py_up0D, "getName", "")) : getName() );
+
+ if( py_up0D && PyObject_HasAttrString(py_up0D, "__call__") ) {
+ return Director_BPy_UnaryPredicate0D___call__(py_up0D, it);
+ } else {
+ cerr << "Warning: " << name << " operator() not implemented" << endl;
+ return false;
+ }
}
+
};
@@ -88,8 +100,11 @@ public:
class BinaryPredicate0D
{
public:
+
+ PyObject *py_bp0D;
+
/*! Default constructor. */
- BinaryPredicate0D() {}
+ BinaryPredicate0D() { py_bp0D = 0; }
/*! Destructor. */
virtual ~BinaryPredicate0D() {}
/*! Returns the string of the name of the
@@ -108,9 +123,16 @@ public:
* \return true or false.
*/
virtual bool operator()(Interface0D& inter1, Interface0D& inter2) {
- cerr << "Warning: operator() not implemented" << endl;
- return false;
+ string name( py_bp0D ? PyString_AsString(PyObject_CallMethod(py_bp0D, "getName", "")) : getName() );
+
+ if( py_bp0D && PyObject_HasAttrString(py_bp0D, "__call__") ) {
+ return Director_BPy_BinaryPredicate0D___call__(py_bp0D, inter1, inter2);
+ } else {
+ cerr << "Warning: " << name << " operator() not implemented" << endl;
+ return false;
+ }
}
+
};
diff --git a/source/blender/freestyle/intern/stroke/Predicates1D.h b/source/blender/freestyle/intern/stroke/Predicates1D.h
index 98148361bb7..8c6f5a9bfa4 100755
--- a/source/blender/freestyle/intern/stroke/Predicates1D.h
+++ b/source/blender/freestyle/intern/stroke/Predicates1D.h
@@ -58,9 +58,7 @@ public:
PyObject *py_up1D;
/*! Default constructor. */
- UnaryPredicate1D() {
- py_up1D = 0;
- }
+ UnaryPredicate1D() { py_up1D = 0; }
/*! Destructor. */
virtual ~UnaryPredicate1D() {}
/*! Returns the string of the name
@@ -78,17 +76,16 @@ public:
* false otherwise.
*/
virtual bool operator()(Interface1D& inter) {
+ string name( py_up1D ? PyString_AsString(PyObject_CallMethod(py_up1D, "getName", "")) : getName() );
- if( py_up1D ) {
- return director_BPy_UnaryPredicate1D___call__(py_up1D, inter);
+ if( py_up1D && PyObject_HasAttrString(py_up1D, "__call__")) {
+ return Director_BPy_UnaryPredicate1D___call__(py_up1D, inter);
} else {
- cerr << "Warning: operator() not implemented" << endl;
- return false;
+ cerr << "Warning: " << name << " operator() not implemented" << endl;
+ return false;
}
}
- inline void setPythonObject(PyObject *_py_up1D) { py_up1D = _py_up1D; }
-
};
@@ -106,8 +103,11 @@ public:
class BinaryPredicate1D
{
public:
+
+ PyObject *py_bp1D;
+
/*! Default constructor. */
- BinaryPredicate1D() {}
+ BinaryPredicate1D() { py_bp1D = 0; }
/*! Destructor. */
virtual ~BinaryPredicate1D() {}
/*! Returns the string of the name of the
@@ -125,9 +125,16 @@ public:
* \return true or false.
*/
virtual bool operator()(Interface1D& inter1, Interface1D& inter2) {
- cerr << "Warning: operator() not implemented" << endl;
- return false;
+ string name( py_bp1D ? PyString_AsString(PyObject_CallMethod(py_bp1D, "getName", "")) : getName() );
+
+ if( py_bp1D && py_bp1D && PyObject_HasAttrString(py_bp1D, "__call__") ) {
+ return Director_BPy_BinaryPredicate1D___call__(py_bp1D, inter1, inter2);
+ } else {
+ cerr << "Warning: " << name << " operator() not implemented" << endl;
+ return false;
+ }
}
+
};
diff --git a/source/blender/freestyle/intern/stroke/Stroke.h b/source/blender/freestyle/intern/stroke/Stroke.h
index 8e4e5e24a2c..3df57341e5f 100755
--- a/source/blender/freestyle/intern/stroke/Stroke.h
+++ b/source/blender/freestyle/intern/stroke/Stroke.h
@@ -38,6 +38,7 @@
# include "../view_map/Interface1D.h"
# include "../system/StringUtils.h"
+
//
// StrokeAttribute
//
diff --git a/source/blender/freestyle/intern/stroke/StrokeShader.h b/source/blender/freestyle/intern/stroke/StrokeShader.h
index fa1289f6e0f..f92895564d8 100755
--- a/source/blender/freestyle/intern/stroke/StrokeShader.h
+++ b/source/blender/freestyle/intern/stroke/StrokeShader.h
@@ -33,6 +33,8 @@
# include <iostream>
# include <vector>
+# include "../python/Director.h"
+
//
// StrokeShader base class
//
@@ -69,8 +71,11 @@ class Stroke;
class LIB_STROKE_EXPORT StrokeShader
{
public:
+
+ PyObject *py_ss;
+
/*! Default constructor. */
- StrokeShader() {}
+ StrokeShader() { py_ss = 0; }
/*! Destructor. */
virtual ~StrokeShader() {}
/*! Returns the string corresponding to the
@@ -111,7 +116,13 @@ public:
* as Color, Thickness, Geometry...)
*/
virtual void shade(Stroke& ioStroke) const {
- cerr << "Warning: method shade() not implemented" << endl;
+ string name( py_ss ? PyString_AsString(PyObject_CallMethod(py_ss, "getName", "")) : getName() );
+
+ if( py_ss && PyObject_HasAttrString(py_ss, "shade") ) {
+ return Director_BPy_StrokeShader_shade(py_ss, ioStroke);
+ } else {
+ cerr << "Warning: " << name << " method shade() not implemented" << endl;
+ }
}
};
diff --git a/source/blender/freestyle/intern/view_map/Functions0D.h b/source/blender/freestyle/intern/view_map/Functions0D.h
index 3160546da2f..1ad35da8d91 100755
--- a/source/blender/freestyle/intern/view_map/Functions0D.h
+++ b/source/blender/freestyle/intern/view_map/Functions0D.h
@@ -90,7 +90,7 @@ public:
* \return the result of the function of type T.
*/
virtual T operator()(Interface0DIterator& iter) {
- cerr << "Warning: operator() not implemented" << endl;
+ cerr << "Warning: UnaryFunction0D operator() not implemented" << endl;
return T();
}
};
diff --git a/source/blender/freestyle/intern/view_map/Functions1D.h b/source/blender/freestyle/intern/view_map/Functions1D.h
index c92d12ff330..072733b985d 100755
--- a/source/blender/freestyle/intern/view_map/Functions1D.h
+++ b/source/blender/freestyle/intern/view_map/Functions1D.h
@@ -92,7 +92,7 @@ public:
* \return the result of the function of type T.
*/
virtual T operator()(Interface1D& inter) {
- cerr << "Warning: operator() not implemented" << endl;
+ cerr << "Warning: UnaryFunction1D operator() not implemented" << endl;
return T(0);
}
/*! Sets the integration method */