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-08-02 01:55:58 +0400
committerMaxime Curioni <maxime.curioni@gmail.com>2008-08-02 01:55:58 +0400
commit7565990db264dbb7771744cea0a1c87b3e11fc3f (patch)
treedb4795f8c46b8cde474112e775708f57a13ccf9e /source/blender/freestyle/intern/view_map
parentc324f0cbc72b47182ba3d7fd1bbd280fcebe3283 (diff)
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).
Diffstat (limited to 'source/blender/freestyle/intern/view_map')
-rwxr-xr-xsource/blender/freestyle/intern/view_map/Functions0D.h19
-rwxr-xr-xsource/blender/freestyle/intern/view_map/Functions1D.h70
-rwxr-xr-xsource/blender/freestyle/intern/view_map/Interface1D.h46
3 files changed, 103 insertions, 32 deletions
diff --git a/source/blender/freestyle/intern/view_map/Functions0D.h b/source/blender/freestyle/intern/view_map/Functions0D.h
index 1ad35da8d91..9543e8c34a6 100755
--- a/source/blender/freestyle/intern/view_map/Functions0D.h
+++ b/source/blender/freestyle/intern/view_map/Functions0D.h
@@ -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
diff --git a/source/blender/freestyle/intern/view_map/Functions1D.h b/source/blender/freestyle/intern/view_map/Functions1D.h
index 072733b985d..c4f8b9f7607 100755
--- a/source/blender/freestyle/intern/view_map/Functions1D.h
+++ b/source/blender/freestyle/intern/view_map/Functions1D.h
@@ -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"*/
diff --git a/source/blender/freestyle/intern/view_map/Interface1D.h b/source/blender/freestyle/intern/view_map/Interface1D.h
index 8c75afc73df..55a2aece91c 100755
--- a/source/blender/freestyle/intern/view_map/Interface1D.h
+++ b/source/blender/freestyle/intern/view_map/Interface1D.h
@@ -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