soc-2008-mxcurioni: made considerable changes to support cross-language polymorphism...
authorMaxime Curioni <maxime.curioni@gmail.com>
Fri, 1 Aug 2008 21:55:58 +0000 (21:55 +0000)
committerMaxime Curioni <maxime.curioni@gmail.com>
Fri, 1 Aug 2008 21:55:58 +0000 (21:55 +0000)
32 files changed:
source/blender/freestyle/intern/image/Image.h
source/blender/freestyle/intern/python/BPy_Convert.cpp
source/blender/freestyle/intern/python/BPy_Convert.h
source/blender/freestyle/intern/python/BPy_Interface1D.cpp
source/blender/freestyle/intern/python/Director.cpp
source/blender/freestyle/intern/python/Director.h
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.h
source/blender/freestyle/intern/stroke/Operators.cpp
source/blender/freestyle/intern/stroke/Operators.h
source/blender/freestyle/intern/stroke/Predicates1D.h
source/blender/freestyle/intern/stroke/Stroke.cpp
source/blender/freestyle/intern/view_map/Functions0D.h
source/blender/freestyle/intern/view_map/Functions1D.h
source/blender/freestyle/intern/view_map/Interface1D.h

index 83d6785e32fbcae4b0621aa76997c1d798182cbe..e1e47c0ec43ac161cc1b1eede753588b64f12956 100755 (executable)
  *  size w*h, and access these pixels using x,y coordinates 
  *  specified in the whole image coordinate system.
  */
-class Image
+class FrsImage
 {
  public:
 
    /*! Default constructor */
-  Image() {
+  FrsImage() {
     _storedWidth = 0;
     _storedHeight = 0;
     _width = 0;
@@ -59,7 +59,7 @@ class Image
   }
 
   /*! Copy constructor */
-  Image(const Image& brother) {
+  FrsImage(const FrsImage& brother) {
     _storedWidth = brother._storedWidth;
     _storedHeight = brother._storedHeight;
     _width = brother._width;
@@ -68,10 +68,10 @@ class Image
     _Oy = brother._Oy;
   }
 
-  /*! Builds an image from its width and height.
+  /*! Builds an FrsImage from its width and height.
    *  The memory is allocated consequently.
    */
-  Image(unsigned w, unsigned h) {
+  FrsImage(unsigned w, unsigned h) {
     _width = w;
     _height = h;
     _storedWidth = w;
@@ -98,7 +98,7 @@ class Image
    *    The x-abscissa of the origin of the rectangle that will actually 
    *    be stored.
    */
-  Image(unsigned w, unsigned h, unsigned sw, unsigned sh, unsigned ox, unsigned oy) {
+  FrsImage(unsigned w, unsigned h, unsigned sw, unsigned sh, unsigned ox, unsigned oy) {
     _width = w;
     _height = h;
     _storedWidth = sw;
@@ -108,7 +108,7 @@ class Image
   }
 
   /*! Operator= */
-  Image& operator=(const Image& brother) {
+  FrsImage& operator=(const FrsImage& brother) {
     _width = brother._width;
     _height = brother._height;
     _storedWidth = brother._storedWidth;
@@ -119,7 +119,7 @@ class Image
   }
 
   /*! Destructor */
-  virtual ~Image() {}
+  virtual ~FrsImage() {}
 
   /*! Returns the width of the complete image */
   inline unsigned width() const {
@@ -181,24 +181,24 @@ class Image
 //
 ///////////////////////////////////////////////////////////////////////////////
 
-class RGBImage : public Image
+class RGBImage : public FrsImage
 {
  public:
 
-  RGBImage() : Image() {
+  RGBImage() : FrsImage() {
     _rgb = 0;
   }
 
-  RGBImage(const RGBImage& brother) : Image(brother) {
+  RGBImage(const RGBImage& brother) : FrsImage(brother) {
     _rgb = new float[3 * _storedWidth * _storedHeight];
     memcpy(_rgb, brother._rgb, 3 * _storedWidth * _storedHeight * sizeof(float));
   }
 
-  RGBImage(unsigned w, unsigned h) : Image(w, h) {
+  RGBImage(unsigned w, unsigned h) : FrsImage(w, h) {
     _rgb = new float[3 * _width * _height];
   }
 
-  RGBImage(float* rgb, unsigned w, unsigned h) : Image(w, h) {
+  RGBImage(float* rgb, unsigned w, unsigned h) : FrsImage(w, h) {
     _rgb = new float[3 * _width * _height];
     memcpy(_rgb, rgb, 3 * _width * _height * sizeof(float));
   }
@@ -218,13 +218,13 @@ class RGBImage : public Image
    *  \param sh
    *    The height of the part of the image we want to store and work on
    */
-  RGBImage(float* rgb, unsigned w, unsigned h, unsigned sw, unsigned sh, unsigned ox, unsigned oy) : Image(w, h, sw, sh, ox, oy) {
+  RGBImage(float* rgb, unsigned w, unsigned h, unsigned sw, unsigned sh, unsigned ox, unsigned oy) : FrsImage(w, h, sw, sh, ox, oy) {
     _rgb = new float[3 * _storedWidth * _storedHeight];
     memcpy(_rgb, rgb, 3 * _storedWidth * _storedHeight * sizeof(float));
   }
 
   RGBImage& operator=(const RGBImage& brother) {
-    dynamic_cast<Image&>(*this) = brother;
+    dynamic_cast<FrsImage&>(*this) = brother;
     _rgb = new float[3 * _storedWidth * _storedHeight];
     memcpy(_rgb, brother._rgb, 3 * _storedWidth * _storedHeight * sizeof(float));
     return* this;
@@ -296,25 +296,25 @@ class RGBImage : public Image
 //
 ///////////////////////////////////////////////////////////////////////////////
 
-class GrayImage : public Image
+class GrayImage : public FrsImage
 {
  public:
 
-  GrayImage() : Image() {
+  GrayImage() : FrsImage() {
     _lvl = 0;
   }
 
-  GrayImage(const GrayImage& brother) : Image(brother) {
+  GrayImage(const GrayImage& brother) : FrsImage(brother) {
     _lvl = new float[_storedWidth*_storedHeight];
     memcpy(_lvl, brother._lvl, _storedWidth*_storedHeight*sizeof(*_lvl));
   }
 
   /*! Builds an empty gray image */
-  GrayImage(unsigned w, unsigned h) : Image(w, h) {
+  GrayImage(unsigned w, unsigned h) : FrsImage(w, h) {
     _lvl = new float[_width*_height];
   }
 
-  GrayImage(float* lvl, unsigned w, unsigned h) : Image(w, h) {
+  GrayImage(float* lvl, unsigned w, unsigned h) : FrsImage(w, h) {
     _lvl = new float[_width*_height];
     memcpy(_lvl, lvl, _width*_height*sizeof(*_lvl));
   }
@@ -334,13 +334,13 @@ class GrayImage : public Image
    *  \param sh
    *    The height of the part of the image we want to store and work on
    */
-  GrayImage(float* lvl, unsigned w, unsigned h, unsigned sw, unsigned sh, unsigned ox, unsigned oy) : Image(w, h, sw, sh, ox, oy) {
+  GrayImage(float* lvl, unsigned w, unsigned h, unsigned sw, unsigned sh, unsigned ox, unsigned oy) : FrsImage(w, h, sw, sh, ox, oy) {
     _lvl = new float[_storedWidth*_storedHeight];
     memcpy(_lvl, lvl, _storedWidth*_storedHeight*sizeof(float));
   }
 
   GrayImage& operator=(const GrayImage& brother) {
-    dynamic_cast<Image&>(*this) = brother;
+    dynamic_cast<FrsImage&>(*this) = brother;
     _lvl = new float[_storedWidth * _storedHeight];
     memcpy(_lvl, brother._lvl, _storedWidth * _storedHeight * sizeof(float));
   return *this;
index e7d98440683bd4833d85df9c7f5d2526176c9c66..a1c26aaf6229a2dd2dcb2cf494a68a9f51273bb7 100644 (file)
@@ -39,14 +39,15 @@ extern "C" {
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 
+//==============================
+// C++ => Python
+//==============================
+
 
 PyObject * PyBool_from_bool( bool b ){
        return PyBool_FromLong( b ? 1 : 0);
 }
 
-bool bool_from_PyBool( PyObject *b ) {
-       return b == Py_True;
-}
 
 PyObject * Vector_from_Vec2f( Vec2f& vec ) {
        float vec_data[2]; // because vec->_coord is protected
@@ -224,19 +225,6 @@ PyObject * BPy_directedViewEdge_from_directedViewEdge( ViewVertex::directedViewE
        return py_dve;
 }
 
-
-//==============================
-// Constants
-//==============================
-
-IntegrationType IntegrationType_from_BPy_IntegrationType( PyObject* obj ) {
-       return static_cast<IntegrationType>( PyInt_AsLong(obj) );
-}
-
-Stroke::MediumType MediumType_from_BPy_MediumType( PyObject* obj ) {
-       return static_cast<Stroke::MediumType>( PyInt_AsLong(obj) );
-}
-
 //==============================
 // Iterators
 //==============================
@@ -323,7 +311,48 @@ PyObject * BPy_ChainSilhouetteIterator_from_ChainSilhouetteIterator( ChainSilhou
 }
 
 
+//==============================
+// Python => C++
+//==============================
+
+bool bool_from_PyBool( PyObject *b ) {
+       return b == Py_True;
+}
+
+IntegrationType IntegrationType_from_BPy_IntegrationType( PyObject* obj ) {
+       return static_cast<IntegrationType>( PyInt_AsLong(obj) );
+}
+
+Stroke::MediumType MediumType_from_BPy_MediumType( PyObject* obj ) {
+       return static_cast<Stroke::MediumType>( PyInt_AsLong(obj) );
+}
 
+Nature::EdgeNature EdgeNature_from_BPy_Nature( PyObject* obj ) {
+       return static_cast<Nature::EdgeNature>( PyInt_AsLong(obj) );
+}
+
+Vec2f * Vec2f_ptr_from_Vector( PyObject* obj ) {
+       float x = PyFloat_AsDouble( PyObject_GetAttrString(obj,"x") );
+       float y = PyFloat_AsDouble( PyObject_GetAttrString(obj,"y") );
+       
+       return new Vec2f(x,y);
+}
+
+Vec3f * Vec3f_ptr_from_Vector( PyObject* obj ) {
+       float x = PyFloat_AsDouble( PyObject_GetAttrString(obj,"x") );
+       float y = PyFloat_AsDouble( PyObject_GetAttrString(obj,"y") );
+       float z = PyFloat_AsDouble( PyObject_GetAttrString(obj,"z") );
+       
+       return new Vec3f(x,y,z);
+}
+
+Vec3r * Vec3r_ptr_from_Vector( PyObject* obj ) {
+       double x = PyFloat_AsDouble( PyObject_GetAttrString(obj,"x") );
+       double y = PyFloat_AsDouble( PyObject_GetAttrString(obj,"y") );
+       double z = PyFloat_AsDouble( PyObject_GetAttrString(obj,"z") );
+       
+       return new Vec3r(x,y,z);
+}
 
 
 ///////////////////////////////////////////////////////////////////////////////////////////
index 4bfaf4c1e173ecacb31f59bbbd1473e6eeb9cf24..5bfdef56278df70f8c9f8ee1b2abc561cb5ecd9c 100644 (file)
@@ -23,6 +23,9 @@ using namespace Geometry;
 // Material
 #include "../scene_graph/Material.h"
 
+// Nature::VertexNature, Nature::EdgeNature
+#include "../winged_edge/Nature.h"
+
 // Stroke, StrokeAttribute, StrokeVertex
 #include "../stroke/Stroke.h"
 
@@ -58,16 +61,15 @@ extern "C" {
 #include "api2_2x/vector.h"
 #include "api2_2x/gen_utils.h"
 
-PyObject * PyBool_from_bool( bool b );
-bool bool_from_PyBool( PyObject *b );
+//==============================
+// C++ => Python
+//==============================
 
+PyObject * PyBool_from_bool( bool b );
 PyObject * Vector_from_Vec2f( Vec2f& v );
 PyObject * Vector_from_Vec3f( Vec3f& v );
 PyObject * Vector_from_Vec3r( Vec3r& v );
 
-IntegrationType IntegrationType_from_BPy_IntegrationType( PyObject* obj );
-Stroke::MediumType MediumType_from_BPy_MediumType( PyObject* obj );
-
 PyObject * BPy_BBox_from_BBox( BBox< Vec3r > &bb );
 PyObject * BPy_CurvePoint_from_CurvePoint( CurvePoint& cp );
 PyObject * BPy_directedViewEdge_from_directedViewEdge( ViewVertex::directedViewEdge& dve );
@@ -99,8 +101,19 @@ PyObject * BPy_ChainingIterator_from_ChainingIterator( ChainingIterator& c_it );
 PyObject * BPy_ChainPredicateIterator_from_ChainPredicateIterator( ChainPredicateIterator& cp_it );
 PyObject * BPy_ChainSilhouetteIterator_from_ChainSilhouetteIterator( ChainSilhouetteIterator& cs_it );
 
+//==============================
+// Python => C++
+//==============================
+
+bool bool_from_PyBool( PyObject *b );
+IntegrationType IntegrationType_from_BPy_IntegrationType( PyObject* obj );
+Stroke::MediumType MediumType_from_BPy_MediumType( PyObject* obj );
+Nature::EdgeNature EdgeNature_from_BPy_Nature( PyObject* obj );
+Vec2f * Vec2f_ptr_from_Vector( PyObject* obj );
+Vec3f * Vec3f_ptr_from_Vector( PyObject* obj );
+Vec3r * Vec3r_ptr_from_Vector( PyObject* obj );
+
 
-   
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 
index 3db9531da4b6715bfc4d827da31f54910c8c3774..8d2549ebf2cf0ee47c6461df98d978a87d5b37fe 100644 (file)
@@ -30,6 +30,10 @@ static PyObject *Interface1D_getId( BPy_Interface1D *self );
 static PyObject *Interface1D_getNature( BPy_Interface1D *self );
 static PyObject *Interface1D_getTimeStamp( BPy_Interface1D *self );
 static PyObject *Interface1D_setTimeStamp( BPy_Interface1D *self, PyObject *args);
+static PyObject * Interface1D_verticesBegin( BPy_Interface1D *self );
+static PyObject * Interface1D_verticesEnd( BPy_Interface1D *self );
+static PyObject * Interface1D_pointsBegin( BPy_Interface1D *self, PyObject *args );
+static PyObject * Interface1D_pointsEnd( BPy_Interface1D *self, PyObject *args );
 
 /*----------------------Interface1D instance definitions ----------------------------*/
 static PyMethodDef BPy_Interface1D_methods[] = {
@@ -41,6 +45,11 @@ static PyMethodDef BPy_Interface1D_methods[] = {
        {"getNature", ( PyCFunction ) Interface1D_getNature, METH_NOARGS, "Returns the nature of the 1D element"},
        {"getTimeStamp", ( PyCFunction ) Interface1D_getTimeStamp, METH_NOARGS, "Returns the time stamp of the 1D element. Mainly used for selection"},
        {"setTimeStamp", ( PyCFunction ) Interface1D_setTimeStamp, METH_VARARGS, "Sets the time stamp for the 1D element"},
+       {"verticesBegin", ( PyCFunction ) Interface1D_verticesBegin, METH_NOARGS, ""},
+       {"verticesEnd", ( PyCFunction ) Interface1D_verticesEnd, METH_NOARGS, ""},
+       {"pointsBegin", ( PyCFunction ) Interface1D_pointsBegin, METH_VARARGS, ""},
+       {"pointsEnd", ( PyCFunction ) Interface1D_pointsEnd, METH_VARARGS, ""},
+
        {NULL, NULL, 0, NULL}
 };
 
@@ -189,6 +198,7 @@ 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;
        return 0;
 }
 
@@ -245,6 +255,41 @@ PyObject *Interface1D_setTimeStamp( BPy_Interface1D *self, PyObject *args) {
        Py_RETURN_NONE;
 }
 
+PyObject * Interface1D_verticesBegin( BPy_Interface1D *self ) {
+       Interface0DIterator if0D_it( self->if1D->verticesBegin() );
+       return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it );
+}
+
+PyObject * Interface1D_verticesEnd( BPy_Interface1D *self ) {
+       Interface0DIterator if0D_it( self->if1D->verticesEnd() );
+       return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it );
+}
+
+
+PyObject * Interface1D_pointsBegin( BPy_Interface1D *self, PyObject *args ) {
+       float f = 0;
+
+       if(!( PyArg_ParseTuple(args, "|f", &f)  )) {
+               cout << "ERROR: Interface1D_pointsBegin" << endl;
+               Py_RETURN_NONE;
+       }
+       
+       Interface0DIterator if0D_it( self->if1D->pointsBegin(f) );
+       return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it );
+}
+
+PyObject * Interface1D_pointsEnd( BPy_Interface1D *self, PyObject *args ) {
+       float f = 0;
+
+       if(!( PyArg_ParseTuple(args, "|f", &f)  )) {
+               cout << "ERROR: Interface1D_pointsEnd" << endl;
+               Py_RETURN_NONE;
+       }
+       
+       Interface0DIterator if0D_it( self->if1D->pointsEnd(f) );
+       return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it );
+}
+
 ///////////////////////////////////////////////////////////////////////////////////////////
 
 #ifdef __cplusplus
index 42677919ca59cf8e76b7826810852e26efa2e515..b3188554c091e677d188e271d3ffccdd63816d2f 100644 (file)
@@ -4,14 +4,29 @@
 
 #include "BPy_BinaryPredicate0D.h"
 #include "BPy_BinaryPredicate1D.h"
+#include "BPy_FrsMaterial.h"
+#include "BPy_Id.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 "Iterator/BPy_Interface0DIterator.h"
 #include "Interface1D/BPy_Stroke.h"
 #include "Interface1D/BPy_ViewEdge.h"
+#include "BPy_ViewShape.h"
+
+#include "UnaryFunction0D/BPy_UnaryFunction0DDouble.h"
+#include "UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.h"
+#include "UnaryFunction0D/BPy_UnaryFunction0DFloat.h"
+#include "UnaryFunction0D/BPy_UnaryFunction0DId.h"
+#include "UnaryFunction0D/BPy_UnaryFunction0DMaterial.h"
+#include "UnaryFunction0D/BPy_UnaryFunction0DUnsigned.h"
+#include "UnaryFunction0D/BPy_UnaryFunction0DVec2f.h"
+#include "UnaryFunction0D/BPy_UnaryFunction0DVec3f.h"
+#include "UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h"
+#include "UnaryFunction0D/BPy_UnaryFunction0DViewShape.h"
 
 //   BinaryPredicate0D: __call__
 bool Director_BPy_BinaryPredicate0D___call__( PyObject *obj, Interface0D& i1, Interface0D& i2) {
@@ -61,17 +76,58 @@ ViewEdge * Director_BPy_ChainingIterator_traverse( PyObject *obj, AdjacencyItera
        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
+void Director_BPy_UnaryFunction0D___call__( void *uf0D, PyObject *obj, Interface0DIterator& if0D_it) {
+
+       PyObject *result = PyObject_CallMethod( obj, "__call__", "O", BPy_Interface0DIterator_from_Interface0DIterator(if0D_it) );
+       
+       if( BPy_UnaryFunction0DDouble_Check(obj) ) {    
+               ((UnaryFunction0D<double> *) uf0D)->result = PyFloat_AsDouble(result);
+
+       } else if ( BPy_UnaryFunction0DEdgeNature_Check(obj) ) {
+               ((UnaryFunction0D<Nature::EdgeNature> *) uf0D)->result = EdgeNature_from_BPy_Nature(result);
+       
+       } else if ( BPy_UnaryFunction0DFloat_Check(obj) ) {
+
+               ((UnaryFunction0D<float> *) uf0D)->result = PyFloat_AsDouble(result);
+       
+       } else if ( BPy_UnaryFunction0DId_Check(obj) ) {
+               ((UnaryFunction0D<Id> *) uf0D)->result = *( ((BPy_Id *) result)->id );
+       
+       } else if ( BPy_UnaryFunction0DMaterial_Check(obj) ) {
+               ((UnaryFunction0D<Material> *) uf0D)->result = *( ((BPy_FrsMaterial *) result)->m );
+       
+       } else if ( BPy_UnaryFunction0DUnsigned_Check(obj) ) {
+               ((UnaryFunction0D<unsigned> *) uf0D)->result = PyInt_AsLong(result);
+       
+       } else if ( BPy_UnaryFunction0DVec2f_Check(obj) ) {
+               Vec2f *v = Vec2f_ptr_from_Vector( result );
+               ((UnaryFunction0D<Vec2f> *) uf0D)->result = *v;
+               delete v; 
+       
+       } else if ( BPy_UnaryFunction0DVec3f_Check(obj) ) {
+               Vec3f *v = Vec3f_ptr_from_Vector( result );
+               ((UnaryFunction0D<Vec3f> *) uf0D)->result = *v;
+               delete v;
+       
+       } else if ( BPy_UnaryFunction0DVectorViewShape_Check(obj) ) {
+               vector<ViewShape*> vec;
+               for( int i = 0; i < PyList_Size(result); i++) {
+                       ViewShape *b = ( (BPy_ViewShape *) PyList_GetItem(result, i) )->vs;
+                       vec.push_back( b );
+               }
+                       
+               ((UnaryFunction0D< vector<ViewShape*> > *) uf0D)->result = vec;
+       
+       } else if ( BPy_UnaryFunction0DViewShape_Check(obj) ) {
+               ((UnaryFunction0D<ViewShape*> *) uf0D)->result = ((BPy_ViewShape *) result)->vs;
+       
+       }       
+
+}
+
+void Director_BPy_UnaryFunction1D___call__( void *uf1D, PyObject *obj, Interface1D& if1D) {
 
 // BPy_UnaryFunction1DDouble
 // BPy_UnaryFunction1DEdgeNature
@@ -82,6 +138,10 @@ ViewEdge * Director_BPy_ChainingIterator_traverse( PyObject *obj, AdjacencyItera
 // BPy_UnaryFunction1DVectorViewShape
 // BPy_UnaryFunction1DVoid
 
+
+}
+
+
 // BPy_Iterator: increment, decrement, isBegin, isEnd
 void Director_BPy_Iterator_increment( PyObject *obj ) {
        PyObject_CallMethod( obj, "increment", "", 0 );
@@ -103,5 +163,28 @@ bool Director_BPy_Iterator_isEnd( PyObject *obj ) {
        return bool_from_PyBool(result);
 }
 
+// BPy_Interface1D: verticesBegin, verticesEnd, pointsBegin, pointsEnd
+Interface0DIterator Director_BPy_Interface1D_verticesBegin( PyObject *obj ){
+       PyObject *result = PyObject_CallMethod( obj, "verticesBegin", "", 0 );
+
+       return *( ((BPy_Interface0DIterator *) result)->if0D_it );
+}
+
+Interface0DIterator Director_BPy_Interface1D_verticesEnd( PyObject *obj ){
+       PyObject *result =  PyObject_CallMethod( obj, "verticesEnd", "", 0 );
+
+       return *( ((BPy_Interface0DIterator *) result)->if0D_it );
+}
+
+Interface0DIterator Director_BPy_Interface1D_pointsBegin( PyObject *obj ){
+       PyObject *result =  PyObject_CallMethod( obj, "pointsBegin", "", 0 );
 
+       return *( ((BPy_Interface0DIterator *) result)->if0D_it );
+}
+
+Interface0DIterator Director_BPy_Interface1D_pointsEnd( PyObject *obj ){
+       PyObject *result =  PyObject_CallMethod( obj, "pointsEnd", "", 0 );
+
+       return *( ((BPy_Interface0DIterator *) result)->if0D_it );
+}
 
index 2a67be237f5338d846969735980f8c62c8372d38..27afa3bbe3e2757ead38a43cca341c5390a222bd 100644 (file)
@@ -37,27 +37,9 @@ void Director_BPy_StrokeShader_shade( PyObject *obj, Stroke& s);
 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);
+// BPy_UnaryFunction{0D,1D}: __call__
+void Director_BPy_UnaryFunction0D___call__( void *uf0D, PyObject *obj, Interface0DIterator& if0D_it);
+void Director_BPy_UnaryFunction1D___call__( void *uf1D, PyObject *obj, Interface1D& if1D);
 
 // BPy_Iterator: increment, decrement, isBegin, isEnd
 void Director_BPy_Iterator_increment( PyObject *obj );
@@ -65,4 +47,12 @@ void Director_BPy_Iterator_decrement( PyObject *obj );
 bool Director_BPy_Iterator_isBegin( PyObject *obj );
 bool Director_BPy_Iterator_isEnd( PyObject *obj );
 
+// BPy_Interface1D: verticesBegin, verticesEnd, pointsBegin, pointsEnd
+Interface0DIterator Director_BPy_Interface1D_verticesBegin( PyObject *obj );
+Interface0DIterator Director_BPy_Interface1D_verticesEnd( PyObject *obj );
+Interface0DIterator Director_BPy_Interface1D_pointsBegin( PyObject *obj );
+Interface0DIterator Director_BPy_Interface1D_pointsEnd( PyObject *obj );
+
+
+
 #endif // FREESTYLE_PYTHON_DIRECTOR
index e7ac46122b610e634ad0d71666fa0ecb1837a71e..45f5c297b8a81cf209cc7404eb3d39fd06a4e780 100644 (file)
@@ -14,6 +14,8 @@
 #include "UnaryFunction0D_double/BPy_LocalAverageDepthF0D.h"
 #include "UnaryFunction0D_double/BPy_ZDiscontinuityF0D.h"
 
+#include "../Director.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -190,6 +192,7 @@ PyMODINIT_FUNC UnaryFunction0DDouble_Init( PyObject *module ) {
 int UnaryFunction0DDouble___init__(BPy_UnaryFunction0DDouble* self)
 {
        self->uf0D_double = new UnaryFunction0D<double>();
+       self->uf0D_double->py_uf0D = (PyObject *)self;
        return 0;
 }
 
@@ -219,7 +222,8 @@ PyObject * UnaryFunction0DDouble___call__( BPy_UnaryFunction0DDouble *self, PyOb
                return NULL;
        }
        
-       double d = self->uf0D_double->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it ));
+       double d = self->uf0D_double->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it));
+               
        return PyFloat_FromDouble( d );
 
 }
index 3dfcb74cddd9f3bc9fb12889f642fa65995cfda8..79f8ff1f648d932f532f0b6aed6965cb2d50f2b6 100644 (file)
@@ -135,6 +135,7 @@ PyMODINIT_FUNC UnaryFunction0DEdgeNature_Init( PyObject *module ) {
 int UnaryFunction0DEdgeNature___init__(BPy_UnaryFunction0DEdgeNature* self)
 {
        self->uf0D_edgenature = new UnaryFunction0D<Nature::EdgeNature>();
+       self->uf0D_edgenature->py_uf0D = (PyObject *)self;
        return 0;
 }
 
index 2c11eb92ed505ad08dd741ff80090411b244de66..bff5fa962c15a4da6d472ee6b0f3efdab1718fa7 100644 (file)
@@ -164,6 +164,7 @@ PyMODINIT_FUNC UnaryFunction0DFloat_Init( PyObject *module ) {
 int UnaryFunction0DFloat___init__(BPy_UnaryFunction0DFloat* self)
 {
        self->uf0D_float = new UnaryFunction0D<float>();
+       self->uf0D_float->py_uf0D = (PyObject *)self;
        return 0;
 }
 
index 2d6cbf09be1ca03fd3429f754076e94cc9717bce..6e21f5f687e1dd3aac72f30cd3a38fa98ccace1c 100644 (file)
@@ -135,6 +135,7 @@ PyMODINIT_FUNC UnaryFunction0DId_Init( PyObject *module ) {
 int UnaryFunction0DId___init__(BPy_UnaryFunction0DId* self)
 {
        self->uf0D_id = new UnaryFunction0D<Id>();
+       self->uf0D_id->py_uf0D = (PyObject *)self;
        return 0;
 }
 
index 733acce6ab823150f63e76493a930bf2531a5ca8..2aef794617a04dc1df16b6c0c81330310398734c 100644 (file)
@@ -135,6 +135,7 @@ PyMODINIT_FUNC UnaryFunction0DMaterial_Init( PyObject *module ) {
 int UnaryFunction0DMaterial___init__(BPy_UnaryFunction0DMaterial* self)
 {
        self->uf0D_material = new UnaryFunction0D<Material>();
+       self->uf0D_material->py_uf0D = (PyObject *)self;
        return 0;
 }
 
index a7d8e9f42a775a66a55499890fcc791063669f32..2d33419032b8ddea818960d5bbe2b7cd7c5fd344 100644 (file)
@@ -135,6 +135,7 @@ PyMODINIT_FUNC UnaryFunction0DUnsigned_Init( PyObject *module ) {
 int UnaryFunction0DUnsigned___init__(BPy_UnaryFunction0DUnsigned* self)
 {
        self->uf0D_unsigned = new UnaryFunction0D<unsigned int>();
+       self->uf0D_unsigned->py_uf0D = (PyObject *)self;
        return 0;
 }
 
index fb7fc4f19fe5501c6e2d555bf05c7dc604e959b1..3eedf16c5757fe6c10368e99c6420df0d3dfb504 100644 (file)
@@ -141,6 +141,7 @@ PyMODINIT_FUNC UnaryFunction0DVec2f_Init( PyObject *module ) {
 int UnaryFunction0DVec2f___init__(BPy_UnaryFunction0DVec2f* self)
 {
        self->uf0D_vec2f = new UnaryFunction0D<Vec2f>();
+       self->uf0D_vec2f->py_uf0D = (PyObject *)self;
        return 0;
 }
 
index d0412d7c7d0e8122f93359a98a6eb6c31b01ecde..aa77d17b18b73ec176e40bb18810893130b54a2c 100644 (file)
@@ -135,6 +135,7 @@ PyMODINIT_FUNC UnaryFunction0DVec3f_Init( PyObject *module ) {
 int UnaryFunction0DVec3f___init__(BPy_UnaryFunction0DVec3f* self)
 {
        self->uf0D_vec3f = new UnaryFunction0D<Vec3f>();
+       self->uf0D_vec3f->py_uf0D = (PyObject *)self;
        return 0;
 }
 
index 02aef4e28cf8d8bc51745bf69b6a07b207054445..93bea5c114e785a029a492bb78c9211bcdb8e556 100644 (file)
@@ -135,6 +135,7 @@ PyMODINIT_FUNC UnaryFunction0DVectorViewShape_Init( PyObject *module ) {
 int UnaryFunction0DVectorViewShape___init__(BPy_UnaryFunction0DVectorViewShape* self)
 {
        self->uf0D_vectorviewshape = new UnaryFunction0D< std::vector<ViewShape*> >();
+       self->uf0D_vectorviewshape->py_uf0D = (PyObject *)self;
        return 0;
 }
 
index eb2fceb3f06c51d3a21de29890d5dfa27da49681..a9714e0b2c63b3b1c173a53971b55af94680ee7f 100644 (file)
@@ -141,6 +141,7 @@ PyMODINIT_FUNC UnaryFunction0DViewShape_Init( PyObject *module ) {
 int UnaryFunction0DViewShape___init__(BPy_UnaryFunction0DViewShape* self)
 {
        self->uf0D_viewshape = new UnaryFunction0D<ViewShape*>();
+       self->uf0D_viewshape->py_uf0D = (PyObject *)self;
        return 0;
 }
 
index 887d1273e60ada74121a0a31aae76838a7504ffb..c3fc04c8b1e0207c8f36e273f1a4eecdac206a74 100644 (file)
@@ -231,6 +231,8 @@ int UnaryFunction1DDouble___init__(BPy_UnaryFunction1DDouble* self, PyObject *ar
                self->uf1D_double = new UnaryFunction1D<double>( IntegrationType_from_BPy_IntegrationType(obj) );
        }
        
+       self->uf1D_double->py_uf1D = (PyObject *)self;
+       
        return 0;
 }
 
index d4d7f6424943250f5adfbc5a598b419c03065072..78d63020062250759de14fffd8df5ee588b12528 100644 (file)
@@ -152,6 +152,8 @@ int UnaryFunction1DEdgeNature___init__(BPy_UnaryFunction1DEdgeNature* self, PyOb
                self->uf1D_edgenature = new UnaryFunction1D<Nature::EdgeNature>( IntegrationType_from_BPy_IntegrationType(obj) );
        }
        
+       self->uf1D_edgenature->py_uf1D = (PyObject *)self;
+       
        return 0;
 }
 void UnaryFunction1DEdgeNature___dealloc__(BPy_UnaryFunction1DEdgeNature* self)
index f4c8a9e53ce7e495edb33a54aa44f9ac5c8fb077..a424d7862a6cabcb8700b18f72c97b56701ca285 100644 (file)
@@ -145,6 +145,8 @@ int UnaryFunction1DFloat___init__(BPy_UnaryFunction1DFloat* self, PyObject *args
                self->uf1D_float = new UnaryFunction1D<float>( IntegrationType_from_BPy_IntegrationType(obj) );
        }
        
+       self->uf1D_float->py_uf1D = (PyObject *)self;
+       
        return 0;
 }
 void UnaryFunction1DFloat___dealloc__(BPy_UnaryFunction1DFloat* self)
index ef75f3bad5b9105268315ff580c4dd865a9569db..297116d2112627b79bbe9d980400db6a72d3f850 100644 (file)
@@ -152,6 +152,8 @@ int UnaryFunction1DUnsigned___init__(BPy_UnaryFunction1DUnsigned* self, PyObject
                self->uf1D_unsigned = new UnaryFunction1D<unsigned int>( IntegrationType_from_BPy_IntegrationType(obj) );
        }
        
+       self->uf1D_unsigned->py_uf1D = (PyObject *)self;
+       
        return 0;
 }
 void UnaryFunction1DUnsigned___dealloc__(BPy_UnaryFunction1DUnsigned* self)
index e0fa12c66e6529188c6eb32e2e27bbefe1938b5e..1d3f1c708b5b3bae939effb8844c564cc49d0722 100644 (file)
@@ -158,6 +158,8 @@ int UnaryFunction1DVec2f___init__(BPy_UnaryFunction1DVec2f* self, PyObject *args
                self->uf1D_vec2f = new UnaryFunction1D<Vec2f>( IntegrationType_from_BPy_IntegrationType(obj) );
        }
        
+       self->uf1D_vec2f->py_uf1D = (PyObject *)self;
+       
        return 0;
 }
 void UnaryFunction1DVec2f___dealloc__(BPy_UnaryFunction1DVec2f* self)
index 3a3c7d4e8355e4e6ff50617fa20ebc78bca57311..1b4c7b281d38e76ecca85eccfb94eee07b673935 100644 (file)
@@ -152,6 +152,8 @@ int UnaryFunction1DVec3f___init__(BPy_UnaryFunction1DVec3f* self, PyObject *args
                self->uf1D_vec3f = new UnaryFunction1D<Vec3f>( IntegrationType_from_BPy_IntegrationType(obj) );
        }
        
+       self->uf1D_vec3f->py_uf1D = (PyObject *)self;
+       
        return 0;
 }
 void UnaryFunction1DVec3f___dealloc__(BPy_UnaryFunction1DVec3f* self)
index c0b25403706e09fe89765e2cf7cd5fc96076a5e6..36f5fc442bfc88a51daac95b2d7416f52af8cc49 100644 (file)
@@ -165,6 +165,8 @@ int UnaryFunction1DVectorViewShape___init__(BPy_UnaryFunction1DVectorViewShape*
                self->uf1D_vectorviewshape = new UnaryFunction1D< std::vector<ViewShape*> >( IntegrationType_from_BPy_IntegrationType(obj) );
        }
        
+       self->uf1D_vectorviewshape->py_uf1D = (PyObject *)self;
+       
        return 0;
 }
 
index 99cc6838997efd29a8f3b52f76de800506e2f8b0..9d5178a299dda5c1bf27dae4c121e5b3b7cbaf67 100644 (file)
@@ -161,11 +161,13 @@ int UnaryFunction1DVoid___init__(BPy_UnaryFunction1DVoid* self, PyObject *args)
        }
        
        if( !obj )
-               self->uf1D_void = new UnaryFunction1D<void>();
+               self->uf1D_void = new UnaryFunction1D_void();
        else {
-               self->uf1D_void = new UnaryFunction1D<void>( IntegrationType_from_BPy_IntegrationType(obj) );
+               self->uf1D_void = new UnaryFunction1D_void( IntegrationType_from_BPy_IntegrationType(obj) );
        }
        
+       self->uf1D_void->py_uf1D = (PyObject *)self;
+       
        return 0;
 }
 
index 3e8ad431ec4126b6108ffa494fac939b9a11fbbe..34615bb4b27aa009e0b446707f18ba034ff08812 100644 (file)
@@ -18,7 +18,7 @@ extern PyTypeObject UnaryFunction1DVoid_Type;
 /*---------------------------Python BPy_UnaryFunction1DVoid structure definition----------*/
 typedef struct {
        BPy_UnaryFunction1D py_uf1D;
-       UnaryFunction1D<void> *uf1D_void;
+       UnaryFunction1D_void *uf1D_void;
 } BPy_UnaryFunction1DVoid;
 
 /*---------------------------Python BPy_UnaryFunction1DVoid visible prototypes-----------*/
index fe1ac27b04ec4dc77bb74b17f40962a57fef97a8..39914cbef1a2ac61bca2d68419095c1f5596a55a 100755 (executable)
@@ -65,7 +65,7 @@ void Operators::select(UnaryPredicate1D& pred) {
 
 void Operators::chain(ViewEdgeInternal::ViewEdgeIterator& it,
                      UnaryPredicate1D& pred,
-                     UnaryFunction1D<void>& modifier) {
+                     UnaryFunction1D_void& modifier) {
   if (_current_view_edges_set.empty())
     return;
 
@@ -137,7 +137,7 @@ void Operators::chain(ViewEdgeInternal::ViewEdgeIterator& it,
 
 //void Operators::bidirectionalChain(ViewEdgeIterator& it,
 //                                UnaryPredicate1D& pred,
-//                                UnaryFunction1D<void>& modifier) {
+//                                UnaryFunction1D_void& modifier) {
 //  if (_current_view_edges_set.empty())
 //    return;
 //
index 96ecd0aa75b0b52356c09f4e3cc27725bb612ab3..804ee4d7056379ac91fada86fc969c34e5dab414 100755 (executable)
@@ -85,7 +85,7 @@ public:
    */
   static void chain(ViewEdgeInternal::ViewEdgeIterator& it,
                    UnaryPredicate1D& pred,
-                   UnaryFunction1D<void>& modifier);
+                   UnaryFunction1D_void& modifier);
 
   /*! Builds a set of chains from the current set of ViewEdges.
    *  Each ViewEdge of the current list starts a new chain. The chaining
index 8c6f5a9bfa49912fe5388c2ff66c118f69333fc3..014d5a1130e861f4b74a7026df171f39c0547d89 100755 (executable)
@@ -127,7 +127,7 @@ public:
   virtual bool operator()(Interface1D& inter1, Interface1D& inter2) {
        string name( py_bp1D ? PyString_AsString(PyObject_CallMethod(py_bp1D, "getName", "")) : getName() );
        
-       if( py_bp1D && py_bp1D && PyObject_HasAttrString(py_bp1D, "__call__") ) {
+       if( py_bp1D && PyObject_HasAttrString(py_bp1D, "__call__") ) {
                return Director_BPy_BinaryPredicate1D___call__(py_bp1D, inter1, inter2);
        } else {
                cerr << "Warning: " << name << " operator() not implemented" << endl;
index b1d6e466215435ca2e93f1ee39d9e2ca22bd7fdb..a1277611a90d91863c8e1e8820235a00f847acfa 100755 (executable)
@@ -404,9 +404,11 @@ Stroke::Stroke(const Stroke& iBrother)
   _mediumType = iBrother._mediumType;
   _textureId = iBrother._textureId;
   _tips = iBrother._tips;
-  
-       if(iBrother._rep) 
+
+       if( iBrother._rep )
                _rep = new StrokeRep(*(iBrother._rep));
+       else
+               _rep = new StrokeRep(this);
 }
 
 Stroke::~Stroke()
index 1ad35da8d917ed8330a0fa21e1ba539b8c192224..9543e8c34a68ef1cc8a4f1450fa0ed2afc0da264 100755 (executable)
@@ -43,6 +43,8 @@ class SShape;
 
 using namespace Geometry;
 
+#include "../python/Director.h"
+
 //
 // UnaryFunction0D (base class for functions in 0D)
 //
@@ -70,12 +72,15 @@ class /*LIB_VIEW_MAP_EXPORT*/ UnaryFunction0D
 {
 public:
 
+       T result;
+       PyObject *py_uf0D;
+
   /*! The type of the value
    *  returned by the functor.
    */
   typedef T ReturnedValueType;
   /*! Default constructor. */
-  UnaryFunction0D() {}
+UnaryFunction0D() { py_uf0D  = 0;}
   /*! Destructor; */
   virtual ~UnaryFunction0D() {}
   /*! Returns the string "UnaryFunction0D" */
@@ -90,9 +95,17 @@ public:
    *  \return the result of the function of type T.
    */
   virtual T operator()(Interface0DIterator& iter) {
-    cerr << "Warning: UnaryFunction0D operator() not implemented" << endl;
-    return T();
+       string name( py_uf0D ? PyString_AsString(PyObject_CallMethod(py_uf0D, "getName", "")) : getName() );
+       
+       if( py_uf0D && PyObject_HasAttrString(py_uf0D, "__call__") ) {
+               Director_BPy_UnaryFunction0D___call__( this, py_uf0D, iter);
+               return result;
+       } else {
+               cerr << "Warning: " << name << " operator() not implemented" << endl;
+           return T();
+       }
   }
+
 };
 
 # ifdef SWIG
index 072733b985d631d0b9b0be063fbd47b8874186ae..c4f8b9f76078aee98b9a97926154b642bbe3406c 100755 (executable)
@@ -36,6 +36,9 @@
 # include "Functions0D.h"
 # include "Interface1D.h"
 # include "../system/FreestyleConfig.h"
+
+#include "../python/Director.h"
+
 //
 // UnaryFunction1D (base class for functions in 1D)
 //
@@ -62,6 +65,10 @@ template <class T>
 class /*LIB_VIEW_MAP_EXPORT*/ UnaryFunction1D
 {
 public:
+
+       T result;
+       PyObject *py_uf1D;
+
   /*! The type of the value
    *  returned by the functor.
    */
@@ -92,9 +99,17 @@ public:
    *  \return the result of the function of type T.
    */
   virtual T operator()(Interface1D& inter) {
-    cerr << "Warning: UnaryFunction1D operator() not implemented" << endl;
-    return T(0);
+       string name( py_uf1D ? PyString_AsString(PyObject_CallMethod(py_uf1D, "getName", "")) : getName() );
+
+       if( py_uf1D && PyObject_HasAttrString(py_uf1D, "__call__") ) {
+               Director_BPy_UnaryFunction1D___call__( this, py_uf1D, inter);
+               return result;
+       } else {
+               cerr << "Warning: " << name << " operator() not implemented" << endl;
+           return T(0);
+       }
   }
+       
   /*! Sets the integration method */
   void setIntegrationType(IntegrationType integration) {
     _integration = integration;
@@ -109,22 +124,37 @@ protected:
   IntegrationType _integration;
 };
 
-# ifdef SWIG
-%feature("director")                   UnaryFunction1D<void>;
-%feature("director")                   UnaryFunction1D<unsigned>;
-%feature("director")                   UnaryFunction1D<float>;
-%feature("director")                   UnaryFunction1D<double>;
-%feature("director")                   UnaryFunction1D<Vec2f>;
-%feature("director")                   UnaryFunction1D<Vec3f>;
 
-%template(UnaryFunction1DVoid)         UnaryFunction1D<void>;
-%template(UnaryFunction1DUnsigned)     UnaryFunction1D<unsigned>;
-%template(UnaryFunction1DFloat)                UnaryFunction1D<float>;
-%template(UnaryFunction1DDouble)       UnaryFunction1D<double>;
-%template(UnaryFunction1DVec2f)                UnaryFunction1D<Vec2f>;
-%template(UnaryFunction1DVec3f)                UnaryFunction1D<Vec3f>;
-%template(UnaryFunction1DVectorViewShape)              UnaryFunction1D<std::vector<ViewShape*> >;
-# endif // SWIG
+class  UnaryFunction1D_void
+{
+public:
+
+       PyObject *py_uf1D;
+
+       UnaryFunction1D_void(){_integration = MEAN;}
+       UnaryFunction1D_void(IntegrationType iType){_integration = iType;}
+       virtual ~UnaryFunction1D_void() {}
+       
+       virtual string getName() const {
+               return "UnaryFunction1D_void";
+       }
+       
+       void operator()(Interface1D& inter) {
+               string name( py_uf1D ? PyString_AsString(PyObject_CallMethod(py_uf1D, "getName", "")) : getName() );
+
+               if( py_uf1D && PyObject_HasAttrString(py_uf1D, "__call__") ) {
+                       Director_BPy_UnaryFunction1D___call__( this, py_uf1D, inter);
+               } else {
+                       cerr << "Warning: " << name << " operator() not implemented" << endl;
+               }
+         }
+       
+       void setIntegrationType(IntegrationType integration) { _integration = integration; }
+       IntegrationType getIntegrationType() const { return _integration; }
+       
+       protected:
+               IntegrationType _integration;
+};
 
 
 //
@@ -385,7 +415,7 @@ namespace Functions1D {
 
   // TimeStampF1D
 /*! Returns the time stamp of the Interface1D. */
-  class LIB_VIEW_MAP_EXPORT TimeStampF1D : public UnaryFunction1D<void>
+  class LIB_VIEW_MAP_EXPORT TimeStampF1D : public UnaryFunction1D_void
   {
   public:
     /*! Returns the string "TimeStampF1D"*/
@@ -398,7 +428,7 @@ namespace Functions1D {
 
   // IncrementChainingTimeStampF1D
 /*! Increments the chaining time stamp of the Interface1D. */
-  class LIB_VIEW_MAP_EXPORT IncrementChainingTimeStampF1D : public UnaryFunction1D<void>
+  class LIB_VIEW_MAP_EXPORT IncrementChainingTimeStampF1D : public UnaryFunction1D_void
   {
   public:
     /*! Returns the string "IncrementChainingTimeStampF1D"*/
@@ -411,7 +441,7 @@ namespace Functions1D {
 
   // ChainingTimeStampF1D
 /*! Sets the chaining time stamp of the Interface1D. */
-  class LIB_VIEW_MAP_EXPORT ChainingTimeStampF1D : public UnaryFunction1D<void>
+  class LIB_VIEW_MAP_EXPORT ChainingTimeStampF1D : public UnaryFunction1D_void
   {
   public:
     /*! Returns the string "ChainingTimeStampF1D"*/
index 8c75afc73df7d3b0aadbd2f922ac457413b83d85..55a2aece91c6f4ada6d0af30443ce7a846e45294 100755 (executable)
@@ -38,6 +38,8 @@
 # include "../winged_edge/Nature.h"
 # include "Functions0D.h"
 
+#include "../python/Director.h"
+
 using namespace std;
 /*! \file Interface1D.h
  *  Interface1D and related tools definitions
@@ -125,8 +127,10 @@ class Interface1D
 {
 public:
 
+       PyObject *py_if1D;
+
   /*! Default constructor */
-  Interface1D() {_timeStamp=0;}
+       Interface1D() {_timeStamp=0; py_if1D = 0; }
    virtual ~Interface1D() {}; //soc
 
   /*! Returns the string "Interface1D" .*/
@@ -140,16 +144,28 @@ public:
    *  pointing to the first vertex.
    */
   virtual Interface0DIterator verticesBegin() {
-           cerr << "Warning: method verticesBegin() not implemented" << endl;
-           return Interface0DIterator();
+               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();
+               }
   }
        
   /*! Returns an iterator over the Interface1D vertices,
    *  pointing after the last vertex.
    */
   virtual Interface0DIterator verticesEnd(){
-           cerr << "Warning: method verticesEnd() not implemented" << endl;
-           return Interface0DIterator();
+               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();
+               }
   }
 
   /*! Returns an iterator over the Interface1D points,
@@ -162,8 +178,14 @@ public:
    *    this 1D element.
    */
   virtual Interface0DIterator pointsBegin(float t=0.f) {
-           cerr << "Warning: method pointsBegin() not implemented" << endl;
-           return Interface0DIterator();
+               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();
+               }
   }
 
   /*! Returns an iterator over the Interface1D points,
@@ -176,8 +198,14 @@ public:
    *    this 1D element.
    */
   virtual Interface0DIterator pointsEnd(float t=0.f) {
-           cerr << "Warning: method pointsEnd() not implemented" << endl;
-           return Interface0DIterator();
+               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();
+               }
   }
 
   // Data access methods