[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15648] branches/soc-2008-mxcurioni/source /blender/freestyle: soc-2008-mxcurioni: updated support for Nature class.

Maxime Curioni maxime.curioni at gmail.com
Sun Jul 20 07:01:29 CEST 2008


Revision: 15648
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15648
Author:   mxcurioni
Date:     2008-07-20 07:01:29 +0200 (Sun, 20 Jul 2008)

Log Message:
-----------
soc-2008-mxcurioni: updated support for Nature class.

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Convert.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Convert.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface0D/ViewVertex.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface0D/ViewVertex.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface0D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/FEdge.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Nature.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/ViewMap.h

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript	2008-07-20 04:39:35 UTC (rev 15647)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript	2008-07-20 05:01:29 UTC (rev 15648)
@@ -69,13 +69,14 @@
 					prefix + '/Interface0D.cpp',
 					prefix + '/Interface0D/CurvePoint.cpp',
 					prefix + '/Interface0D/SVertex.cpp',
+					prefix + '/Interface0D/ViewVertex.cpp',
 					prefix + '/Interface1D.cpp',
 					prefix + '/Interface1D/FEdge.cpp',
 					prefix + '/Nature.cpp',
 					prefix + '/UnaryFunction0D.cpp',
 					prefix + '/UnaryFunction1D.cpp',
 					prefix + '/UnaryPredicate0D.cpp',
-					prefix + '/UnaryPredicate1D.cpp'
+					prefix + '/UnaryPredicate1D.cpp',
 				]
 
 sources = 	system_sources + image_sources + geometry_sources + scene_graph_sources \

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Convert.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Convert.cpp	2008-07-20 04:39:35 UTC (rev 15647)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Convert.cpp	2008-07-20 05:01:29 UTC (rev 15648)
@@ -8,47 +8,47 @@
 ///////////////////////////////////////////////////////////////////////////////////////////
 
 
-PyObject *PyBool_from_bool( bool b ){
+PyObject * PyBool_from_bool( bool b ){
 	return PyBool_FromLong( b ? 1 : 0);
 }
 
 
-PyObject *Vector_from_Vec2f( Vec2f& vec ) {
+PyObject * Vector_from_Vec2f( Vec2f& vec ) {
 	float vec_data[2]; // because vec->_coord is protected
 
 	vec_data[0] = vec.x();		vec_data[1] = vec.y();
 	return newVectorObject( vec_data, 2, Py_NEW);
 }
 
-PyObject *Vector_from_Vec3f( Vec3f& vec ) {
+PyObject * Vector_from_Vec3f( Vec3f& vec ) {
 	float vec_data[3]; // because vec->_coord is protected
 	
 	vec_data[0] = vec.x();		vec_data[1] = vec.y(); 		vec_data[2] = vec.z(); 
 	return newVectorObject( vec_data, 3, Py_NEW);
 }
 
-PyObject *Vector_from_Vec3r( Vec3r& vec ) {
+PyObject * Vector_from_Vec3r( Vec3r& vec ) {
 	float vec_data[3]; // because vec->_coord is protected
 	
 	vec_data[0] = vec.x();		vec_data[1] = vec.y(); 		vec_data[2] = vec.z(); 
 	return newVectorObject( vec_data, 3, Py_NEW);
 }
 
-PyObject *BPy_Id_from_Id( Id& id ) {
+PyObject * BPy_Id_from_Id( Id& id ) {
 	PyObject *py_id = Id_Type.tp_new( &Id_Type, 0, 0 );
 	((BPy_Id *) py_id)->id = new Id( id.getFirst(), id.getSecond() );
 
 	return py_id;
 }
 
-PyObject *BPy_Interface0D_from_Interface0D( Interface0D& if0D ) {
+PyObject * BPy_Interface0D_from_Interface0D( Interface0D& if0D ) {
 	PyObject *py_if0D =  Interface0D_Type.tp_new( &Interface0D_Type, 0, 0 );
 	((BPy_Interface0D *) py_if0D)->if0D = &if0D;
 
 	return py_if0D;
 }
 
-PyObject *BPy_SVertex_from_SVertex( SVertex& sv ) {
+PyObject * BPy_SVertex_from_SVertex( SVertex& sv ) {
 	PyObject *py_sv = SVertex_Type.tp_new( &SVertex_Type, 0, 0 );
 	((BPy_SVertex *) py_sv)->sv = new SVertex( sv );
 	((BPy_SVertex *) py_sv)->py_if0D.if0D = ((BPy_SVertex *) py_sv)->sv;
@@ -56,7 +56,7 @@
 	return py_sv;
 }
 
-PyObject *BPy_FEdge_from_FEdge( FEdge& fe ) {
+PyObject * BPy_FEdge_from_FEdge( FEdge& fe ) {
 	PyObject *py_fe = FEdge_Type.tp_new( &FEdge_Type, 0, 0 );
 	((BPy_FEdge *) py_fe)->fe = new FEdge( fe );
 	((BPy_FEdge *) py_fe)->py_if1D.if1D = ((BPy_FEdge *) py_fe)->fe;
@@ -64,7 +64,17 @@
 	return py_fe;
 }
 
+PyObject * BPy_Nature_from_Nature( unsigned short n ) {
+	PyObject *py_n =  Nature_Type.tp_new( &Nature_Type, 0, 0 );
 
+	PyObject *args = PyTuple_New(1);
+	PyTuple_SetItem( args, 0, PyInt_FromLong(n) );
+	Nature_Type.tp_init( py_n, args, 0 );
+	Py_DECREF(args);
+
+	return py_n;
+}
+
 ///////////////////////////////////////////////////////////////////////////////////////////
 
 #ifdef __cplusplus

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Convert.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Convert.h	2008-07-20 04:39:35 UTC (rev 15647)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Convert.h	2008-07-20 05:01:29 UTC (rev 15648)
@@ -9,6 +9,7 @@
 #include "Interface0D.h"
 #include "Interface0D/SVertex.h"
 #include "Interface1D/FEdge.h"
+#include "Nature.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -30,6 +31,7 @@
 PyObject * BPy_SVertex_from_SVertex( SVertex& sv );
 PyObject * BPy_FEdge_from_FEdge( FEdge& fe );
 PyObject * BPy_Interface0D_from_Interface0D( Interface0D& if0D );
+PyObject * BPy_Nature_from_Nature( unsigned short n );
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface0D/ViewVertex.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface0D/ViewVertex.cpp	2008-07-20 04:39:35 UTC (rev 15647)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface0D/ViewVertex.cpp	2008-07-20 05:01:29 UTC (rev 15648)
@@ -1,7 +1,6 @@
-#include "SVertex.h"
+#include "ViewVertex.h"
 
 #include "../Convert.h"
-#include "../Id.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -11,12 +10,12 @@
 
 /*---------------  Python API function prototypes for ViewVertex instance  -----------*/
 static int ViewVertex___init__(BPy_ViewVertex *self);
-//static PyObject * ViewVertex___copy__( BPy_ViewVertex *self );
+static PyObject * ViewVertex_setNature( BPy_ViewVertex *self, PyObject *args );
 
 
 /*----------------------ViewVertex instance definitions ----------------------------*/
 static PyMethodDef BPy_ViewVertex_methods[] = {
-//	{"__copy__", ( PyCFunction ) ViewVertex___copy__, METH_NOARGS, "( )Cloning method."},
+	{"setNature", ( PyCFunction ) ViewVertex_setNature, METH_VARARGS, "(Nature n )Sets the nature of the vertex."},
 	{NULL, NULL, 0, NULL}
 };
 
@@ -111,13 +110,8 @@
 //------------------------INSTANCE METHODS ----------------------------------
 
 int ViewVertex___init__(BPy_ViewVertex *self )
-{
-	PyObject *py_point = 0;
-	BPy_Id *py_id = 0;
-
-	self->vv = new ViewVertex();
-	self->py_if0D.if0D = self->vv;
-	
+{	
+	self->py_if0D.if0D = new Interface0D();
 	return 0;
 }
 
@@ -127,12 +121,27 @@
 // 	py_vv = (BPy_ViewVertex *) ViewVertex_Type.tp_new( &ViewVertex_Type, 0, 0 );
 // 	
 // 	py_vv->vv = self->vv->duplicate();
-// 	py_svertex->py_if0D.if0D = py_svertex->sv;
+// 	py_svertex->py_if0D.if->sv;
 // 
 // 	return (PyObject *) py_svertex;
 // }
 
+PyObject * ViewVertex_setNature( BPy_ViewVertex *self, PyObject *args ) {
+	PyObject *py_n;
 
+	if(!( PyArg_ParseTuple(args, "O", &py_n) && BPy_Nature_Check(py_n) )) {
+		cout << "ERROR: ViewVertex_setNature" << endl;
+		Py_RETURN_NONE;
+	}
+	
+	PyObject *i = (PyObject *) &( ((BPy_Nature *) py_n)->i );
+	((ViewVertex *) self->py_if0D.if0D)->setNature( PyInt_AsLong(i) );
+
+	Py_RETURN_NONE;
+}
+
+
+
 ///////////////////////////////////////////////////////////////////////////////////////////
 
 #ifdef __cplusplus
@@ -141,9 +150,7 @@
 
 
 // virtual string 	getExactTypeName () const
-//  	ViewVertex ()
-// virtual 	~ViewVertex ()
-// virtual Nature::VertexNature 	getNature () const
+
 // void 	setNature (Nature::VertexNature iNature)
 // virtual ViewVertexInternal::orientedViewEdgeIterator 	edgesBegin ()=0
 // virtual ViewVertexInternal::orientedViewEdgeIterator 	edgesEnd ()=0

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface0D/ViewVertex.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface0D/ViewVertex.h	2008-07-20 04:39:35 UTC (rev 15647)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface0D/ViewVertex.h	2008-07-20 05:01:29 UTC (rev 15648)
@@ -21,7 +21,6 @@
 /*---------------------------Python BPy_ViewVertex structure definition----------*/
 typedef struct {
 	BPy_Interface0D py_if0D;
-	ViewVertex *vv;
 } BPy_ViewVertex;
 
 ///////////////////////////////////////////////////////////////////////////////////////////

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface0D.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface0D.cpp	2008-07-20 04:39:35 UTC (rev 15647)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface0D.cpp	2008-07-20 05:01:29 UTC (rev 15648)
@@ -3,7 +3,9 @@
 #include "Convert.h"
 #include "Interface0D/CurvePoint.h"
 #include "Interface0D/SVertex.h"
+#include "Interface0D/ViewVertex.h"
 #include "Interface1D/FEdge.h"
+#include "Nature.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -152,6 +154,11 @@
 	Py_INCREF( &SVertex_Type );
 	PyModule_AddObject(module, "SVertex", (PyObject *)&SVertex_Type);	
 	
+	if( PyType_Ready( &ViewVertex_Type ) < 0 )
+		return;
+	Py_INCREF( &ViewVertex_Type );
+	PyModule_AddObject(module, "ViewVertex", (PyObject *)&ViewVertex_Type);
+	
 }
 
 //------------------------INSTANCE METHODS ----------------------------------
@@ -243,8 +250,7 @@
 
 
 PyObject *Interface0D_getNature( BPy_Interface0D *self ) {
-	// VertexNature
-	Py_RETURN_NONE;
+	return BPy_Nature_from_Nature( self->if0D->getNature() );
 }
 
 

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/FEdge.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/FEdge.cpp	2008-07-20 04:39:35 UTC (rev 15647)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/FEdge.cpp	2008-07-20 05:01:29 UTC (rev 15648)
@@ -26,6 +26,7 @@
 static PyObject * FEdge_SetNextEdge( BPy_FEdge *self , PyObject *args);
 static PyObject * FEdge_SetPreviousEdge( BPy_FEdge *self , PyObject *args);
 static PyObject * FEdge_SetSmooth( BPy_FEdge *self , PyObject *args); 
+static PyObject * FEdge_SetNature( BPy_FEdge *self, PyObject *args );
 
 /*----------------------FEdge instance definitions ----------------------------*/
 static PyMethodDef BPy_FEdge_methods[] = {	
@@ -44,6 +45,7 @@

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list