Revision: 21954
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21954
Author:   kjym3
Date:     2009-07-28 02:29:30 +0200 (Tue, 28 Jul 2009)

Log Message:
-----------
* BPy_IntegrationType.cpp: Added a Python wrapper of integrate function.

* Fixed uninitialized fields in the "__init__" methods of UnaryFunction0D
types.  Also added missing argument validation codes to some of the types,
and removed redundant validation error messages.

Modified Paths:
--------------
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.cpp

Modified: 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp
===================================================================
--- 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp
  2009-07-27 22:41:35 UTC (rev 21953)
+++ 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp
  2009-07-28 00:29:30 UTC (rev 21954)
@@ -1,6 +1,10 @@
 #include "BPy_IntegrationType.h"
 
 #include "BPy_Convert.h"
+#include "UnaryFunction0D/BPy_UnaryFunction0DDouble.h"
+#include "UnaryFunction0D/BPy_UnaryFunction0DFloat.h"
+#include "UnaryFunction0D/BPy_UnaryFunction0DUnsigned.h"
+#include "Iterator/BPy_Interface0DIterator.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -10,6 +14,19 @@
 
 static PyObject *BPy_IntegrationType_new(PyTypeObject *type, PyObject *args, 
PyObject *kwds);
 
+static PyObject * Integrator_integrate( PyObject *self, PyObject *args );
+
+/*-----------------------Integrator module 
docstring---------------------------------------*/
+
+static char module_docstring[] = "The Blender.Freestyle.Integrator submodule";
+
+/*-----------------------Integrator module functions 
definitions---------------------------*/
+
+static PyMethodDef module_functions[] = {
+  {"integrate", (PyCFunction)Integrator_integrate, METH_VARARGS, ""},
+  {NULL, NULL, 0, NULL}
+};
+
 /*-----------------------BPy_IntegrationType type definition 
------------------------------*/
 
 PyTypeObject IntegrationType_Type = {
@@ -121,7 +138,7 @@
 //-------------------MODULE INITIALIZATION--------------------------------
 PyMODINIT_FUNC IntegrationType_Init( PyObject *module )
 {      
-       PyObject *tmp;
+       PyObject *tmp, *m, *d, *f;
        
        if( module == NULL )
                return;
@@ -151,9 +168,78 @@
        PyDict_SetItemString( IntegrationType_Type.tp_dict, "LAST", tmp);
        Py_DECREF(tmp);
        
-       
+       m = Py_InitModule3("Blender.Freestyle.Integrator", module_functions, 
module_docstring);
+       if (m == NULL)
+               return;
+       PyModule_AddObject(module, "Integrator", m);
+
+       // from Integrator import *
+       d = PyModule_GetDict(m);
+       for (PyMethodDef *p = module_functions; p->ml_name; p++) {
+               f = PyDict_GetItemString(d, p->ml_name);
+               Py_INCREF(f);
+               PyModule_AddObject(module, p->ml_name, f);
+       }
 }
 
+//------------------------ MODULE FUNCTIONS ----------------------------------
+
+static PyObject * Integrator_integrate( PyObject *self, PyObject *args )
+{
+       PyObject *obj1, *obj4 = 0;
+       BPy_Interface0DIterator *obj2, *obj3;
+
+#if 1
+       if(!( PyArg_ParseTuple(args, "O!O!O!|O!", &UnaryFunction0D_Type, &obj1,
+               &Interface0DIterator_Type, &obj2, &Interface0DIterator_Type, 
&obj3,
+               &IntegrationType_Type, &obj4) ))
+               return NULL;
+#else
+       if(!( PyArg_ParseTuple(args, "OOO|O", &obj1, &obj2, &obj3, &obj4) ))
+               return NULL;
+       if(!BPy_UnaryFunction0D_Check(obj1)) {
+               PyErr_SetString(PyExc_TypeError, "argument 1 must be a 
UnaryFunction0D object");
+               return NULL;
+       }
+       if(!BPy_Interface0DIterator_Check(obj2)) {
+               PyErr_SetString(PyExc_TypeError, "argument 2 must be a 
Interface0DIterator object");
+               return NULL;
+       }
+       if(!BPy_Interface0DIterator_Check(obj3)) {
+               PyErr_SetString(PyExc_TypeError, "argument 3 must be a 
Interface0DIterator object");
+               return NULL;
+       }
+       if(obj4 && !BPy_IntegrationType_Check(obj4)) {
+               PyErr_SetString(PyExc_TypeError, "argument 4 must be a 
IntegrationType object");
+               return NULL;
+       }
+#endif
+
+       Interface0DIterator it(*(obj2->if0D_it)), it_end(*(obj3->if0D_it));
+       IntegrationType t = ( obj4 ) ? 
IntegrationType_from_BPy_IntegrationType( obj4 ) : MEAN;
+
+       if( BPy_UnaryFunction0DDouble_Check(obj1) ) {
+               UnaryFunction0D<double> *fun = ((BPy_UnaryFunction0DDouble 
*)obj1)->uf0D_double;
+               double res = integrate( *fun, it, it_end, t );
+               return PyFloat_FromDouble( res );
+
+       } else if( BPy_UnaryFunction0DFloat_Check(obj1) ) {
+               UnaryFunction0D<float> *fun = ((BPy_UnaryFunction0DFloat 
*)obj1)->uf0D_float;
+               float res = integrate( *fun, it, it_end, t );
+               return PyFloat_FromDouble( res );
+
+       } else if( BPy_UnaryFunction0DUnsigned_Check(obj1) ) {
+               UnaryFunction0D<unsigned int> *fun = 
((BPy_UnaryFunction0DUnsigned *)obj1)->uf0D_unsigned;
+               unsigned int res = integrate( *fun, it, it_end, t );
+               return PyInt_FromLong( res );
+
+       } else {
+               string msg("unsupported function type: " + 
string(obj1->ob_type->tp_name));
+               PyErr_SetString(PyExc_TypeError, msg.c_str());
+               return NULL;
+       }
+}
+
 
///////////////////////////////////////////////////////////////////////////////////////////
 
 #ifdef __cplusplus

Modified: 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.cpp
===================================================================
--- 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.cpp
    2009-07-27 22:41:35 UTC (rev 21953)
+++ 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.cpp
    2009-07-28 00:29:30 UTC (rev 21954)
@@ -9,7 +9,7 @@
 
///////////////////////////////////////////////////////////////////////////////////////////
 
 /*---------------  Python API function prototypes for ShapeIdF0D instance  
-----------*/
-       static int ShapeIdF0D___init__(BPy_ShapeIdF0D* self);
+       static int ShapeIdF0D___init__(BPy_ShapeIdF0D* self, PyObject *args);
 
 /*-----------------------BPy_ShapeIdF0D type definition 
------------------------------*/
 
@@ -98,9 +98,12 @@
 
 //------------------------INSTANCE METHODS ----------------------------------
 
-int ShapeIdF0D___init__( BPy_ShapeIdF0D* self )
+int ShapeIdF0D___init__( BPy_ShapeIdF0D* self, PyObject *args )
 {
+       if( !PyArg_ParseTuple(args, "") )
+               return -1;
        self->py_uf0D_id.uf0D_id = new Functions0D::ShapeIdF0D();
+       self->py_uf0D_id.uf0D_id->py_uf0D = (PyObject *)self;
        return 0;
 }
 

Modified: 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.cpp
===================================================================
--- 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.cpp
     2009-07-27 22:41:35 UTC (rev 21953)
+++ 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.cpp
     2009-07-28 00:29:30 UTC (rev 21954)
@@ -9,7 +9,7 @@
 
///////////////////////////////////////////////////////////////////////////////////////////
 
 /*---------------  Python API function prototypes for MaterialF0D instance  
-----------*/
-       static int MaterialF0D___init__(BPy_MaterialF0D* self);
+       static int MaterialF0D___init__(BPy_MaterialF0D* self, PyObject *args);
 
 /*-----------------------BPy_MaterialF0D type definition 
------------------------------*/
 
@@ -98,9 +98,12 @@
 
 //------------------------INSTANCE METHODS ----------------------------------
 
-int MaterialF0D___init__( BPy_MaterialF0D* self )
+int MaterialF0D___init__( BPy_MaterialF0D* self, PyObject *args )
 {
+       if( !PyArg_ParseTuple(args, "") )
+               return -1;
        self->py_uf0D_material.uf0D_material = new Functions0D::MaterialF0D();
+       self->py_uf0D_material.uf0D_material->py_uf0D = (PyObject *)self;
        return 0;
 }
 

Modified: 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.cpp
===================================================================
--- 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.cpp
 2009-07-27 22:41:35 UTC (rev 21953)
+++ 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.cpp
 2009-07-28 00:29:30 UTC (rev 21954)
@@ -9,7 +9,7 @@
 
///////////////////////////////////////////////////////////////////////////////////////////
 
 /*---------------  Python API function prototypes for CurveNatureF0D instance  
-----------*/
-       static int CurveNatureF0D___init__(BPy_CurveNatureF0D* self);
+       static int CurveNatureF0D___init__(BPy_CurveNatureF0D* self, PyObject 
*args);
 
 /*-----------------------BPy_CurveNatureF0D type definition 
------------------------------*/
 
@@ -98,9 +98,12 @@
 
 //------------------------INSTANCE METHODS ----------------------------------
 
-int CurveNatureF0D___init__( BPy_CurveNatureF0D* self )
+int CurveNatureF0D___init__( BPy_CurveNatureF0D* self, PyObject *args )
 {
+       if( !PyArg_ParseTuple(args, "") )
+               return -1;
        self->py_uf0D_edgenature.uf0D_edgenature = new 
Functions0D::CurveNatureF0D();
+       self->py_uf0D_edgenature.uf0D_edgenature->py_uf0D = (PyObject *)self;
        return 0;
 }
 

Modified: 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.cpp
===================================================================
--- 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.cpp
        2009-07-27 22:41:35 UTC (rev 21953)
+++ 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.cpp
        2009-07-28 00:29:30 UTC (rev 21954)
@@ -9,7 +9,7 @@
 
///////////////////////////////////////////////////////////////////////////////////////////
 
 /*---------------  Python API function prototypes for Normal2DF0D instance  
-----------*/
-       static int Normal2DF0D___init__(BPy_Normal2DF0D* self);
+       static int Normal2DF0D___init__(BPy_Normal2DF0D* self, PyObject *args);
 
 /*-----------------------BPy_Normal2DF0D type definition 
------------------------------*/
 
@@ -98,9 +98,12 @@
 
 //------------------------INSTANCE METHODS ----------------------------------
 
-int Normal2DF0D___init__( BPy_Normal2DF0D* self )
+int Normal2DF0D___init__( BPy_Normal2DF0D* self, PyObject *args )
 {
+       if( !PyArg_ParseTuple(args, "") )
+               return -1;
        self->py_uf0D_vec2f.uf0D_vec2f = new Functions0D::Normal2DF0D();
+       self->py_uf0D_vec2f.uf0D_vec2f->py_uf0D = (PyObject *)self;
        return 0;
 }
 

Modified: 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.cpp
===================================================================

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to