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/Functions1D.h
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/Functions1D.h')
-rwxr-xr-xsource/blender/freestyle/intern/view_map/Functions1D.h70
1 files changed, 50 insertions, 20 deletions
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"*/