[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15912] branches/soc-2008-mxcurioni/source /blender/freestyle/intern: soc-2008-mxcurioni: made considerable changes to support cross-language polymorphism for UnaryFunction0D , Interface0D, Interface1D.

Maxime Curioni maxime.curioni at gmail.com
Fri Aug 1 23:55:59 CEST 2008


Revision: 15912
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15912
Author:   mxcurioni
Date:     2008-08-01 23:55:58 +0200 (Fri, 01 Aug 2008)

Log Message:
-----------
soc-2008-mxcurioni: made considerable changes to support cross-language polymorphism for UnaryFunction0D, Interface0D, Interface1D. Add to change UnaryFunction1D<void> to static UnaryFunction1D_void. Resolved namespace collision on the Image class (changed to FrsImage). There is greater support for style modules but somehow, some do not show anything yet (japanese_bigbrush being an example).

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/image/Image.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Convert.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Convert.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Interface1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Director.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Director.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Operators.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Operators.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Predicates1D.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Stroke.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/Functions0D.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/Functions1D.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/Interface1D.h

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/image/Image.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/image/Image.h	2008-08-01 21:37:36 UTC (rev 15911)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/image/Image.h	2008-08-01 21:55:58 UTC (rev 15912)
@@ -44,12 +44,12 @@
  *  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 @@
   }
 
   /*! Copy constructor */
-  Image(const Image& brother) {
+  FrsImage(const FrsImage& brother) {
     _storedWidth = brother._storedWidth;
     _storedHeight = brother._storedHeight;
     _width = brother._width;
@@ -68,10 +68,10 @@
     _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 @@
    *    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 @@
   }
 
   /*! Operator= */
-  Image& operator=(const Image& brother) {
+  FrsImage& operator=(const FrsImage& brother) {
     _width = brother._width;
     _height = brother._height;
     _storedWidth = brother._storedWidth;
@@ -119,7 +119,7 @@
   }
 
   /*! Destructor */
-  virtual ~Image() {}
+  virtual ~FrsImage() {}
 
   /*! Returns the width of the complete image */
   inline unsigned width() const {
@@ -181,24 +181,24 @@
 //
 ///////////////////////////////////////////////////////////////////////////////
 
-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 @@
    *  \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 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 @@
    *  \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;

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Convert.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Convert.cpp	2008-08-01 21:37:36 UTC (rev 15911)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Convert.cpp	2008-08-01 21:55:58 UTC (rev 15912)
@@ -39,14 +39,15 @@
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 
+//==============================
+// 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,20 +225,7 @@
 	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,9 +311,50 @@
 }
 
 
+//==============================
+// 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);
+}
+
+
 ///////////////////////////////////////////////////////////////////////////////////////////
 
 #ifdef __cplusplus

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Convert.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Convert.h	2008-08-01 21:37:36 UTC (rev 15911)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Convert.h	2008-08-01 21:55:58 UTC (rev 15912)
@@ -23,6 +23,9 @@
 // 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 @@
 #include "api2_2x/vector.h"
 #include "api2_2x/gen_utils.h"
 
+//==============================
+// C++ => Python
+//==============================
+
 PyObject * PyBool_from_bool( bool b );
-bool bool_from_PyBool( PyObject *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,9 +101,20 @@
 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 );
 
+
+

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list