diff options
author | Maxime Curioni <maxime.curioni@gmail.com> | 2008-08-02 01:55:58 +0400 |
---|---|---|
committer | Maxime Curioni <maxime.curioni@gmail.com> | 2008-08-02 01:55:58 +0400 |
commit | 7565990db264dbb7771744cea0a1c87b3e11fc3f (patch) | |
tree | db4795f8c46b8cde474112e775708f57a13ccf9e /source/blender/freestyle/intern/python/BPy_Convert.cpp | |
parent | c324f0cbc72b47182ba3d7fd1bbd280fcebe3283 (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/python/BPy_Convert.cpp')
-rw-r--r-- | source/blender/freestyle/intern/python/BPy_Convert.cpp | 61 |
1 files changed, 45 insertions, 16 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_Convert.cpp b/source/blender/freestyle/intern/python/BPy_Convert.cpp index e7d98440683..a1c26aaf622 100644 --- a/source/blender/freestyle/intern/python/BPy_Convert.cpp +++ b/source/blender/freestyle/intern/python/BPy_Convert.cpp @@ -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); +} /////////////////////////////////////////////////////////////////////////////////////////// |