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-07-20 09:01:29 +0400
committerMaxime Curioni <maxime.curioni@gmail.com>2008-07-20 09:01:29 +0400
commitab722884d3684808b17f76ae742ef59dccf4f8e2 (patch)
treeaf1d982347fccef4c3121bd9bc4157716e45f335 /source/blender/freestyle/intern/python
parent16d7d12123d25a353043cefe2c9e4664476224d7 (diff)
soc-2008-mxcurioni: updated support for Nature class.
Diffstat (limited to 'source/blender/freestyle/intern/python')
-rw-r--r--source/blender/freestyle/intern/python/Convert.cpp26
-rw-r--r--source/blender/freestyle/intern/python/Convert.h2
-rw-r--r--source/blender/freestyle/intern/python/Interface0D.cpp10
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/ViewVertex.cpp37
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/ViewVertex.h1
-rw-r--r--source/blender/freestyle/intern/python/Interface1D.cpp3
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/FEdge.cpp16
-rw-r--r--source/blender/freestyle/intern/python/Nature.cpp14
8 files changed, 74 insertions, 35 deletions
diff --git a/source/blender/freestyle/intern/python/Convert.cpp b/source/blender/freestyle/intern/python/Convert.cpp
index 42250fbe97b..9cd2a098253 100644
--- a/source/blender/freestyle/intern/python/Convert.cpp
+++ b/source/blender/freestyle/intern/python/Convert.cpp
@@ -8,47 +8,47 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-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 @@ PyObject *BPy_SVertex_from_SVertex( SVertex& sv ) {
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,6 +64,16 @@ PyObject *BPy_FEdge_from_FEdge( FEdge& fe ) {
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;
+}
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Convert.h b/source/blender/freestyle/intern/python/Convert.h
index ce38f8cbc22..2346d420813 100644
--- a/source/blender/freestyle/intern/python/Convert.h
+++ b/source/blender/freestyle/intern/python/Convert.h
@@ -9,6 +9,7 @@ using namespace Geometry;
#include "Interface0D.h"
#include "Interface0D/SVertex.h"
#include "Interface1D/FEdge.h"
+#include "Nature.h"
#ifdef __cplusplus
extern "C" {
@@ -30,6 +31,7 @@ PyObject * BPy_Id_from_Id( Id& id );
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 );
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Interface0D.cpp b/source/blender/freestyle/intern/python/Interface0D.cpp
index 39c2146e015..469e2bc4c79 100644
--- a/source/blender/freestyle/intern/python/Interface0D.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D.cpp
@@ -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 @@ PyMODINIT_FUNC Interface0D_Init( PyObject *module )
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_getId( BPy_Interface0D *self ) {
PyObject *Interface0D_getNature( BPy_Interface0D *self ) {
- // VertexNature
- Py_RETURN_NONE;
+ return BPy_Nature_from_Nature( self->if0D->getNature() );
}
diff --git a/source/blender/freestyle/intern/python/Interface0D/ViewVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/ViewVertex.cpp
index 66583d21605..6168d1fb711 100644
--- a/source/blender/freestyle/intern/python/Interface0D/ViewVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/ViewVertex.cpp
@@ -1,7 +1,6 @@
-#include "SVertex.h"
+#include "ViewVertex.h"
#include "../Convert.h"
-#include "../Id.h"
#ifdef __cplusplus
extern "C" {
@@ -11,12 +10,12 @@ extern "C" {
/*--------------- 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 @@ PyTypeObject ViewVertex_Type = {
//------------------------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,11 +121,26 @@ int ViewVertex___init__(BPy_ViewVertex *self )
// 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;
+}
+
+
///////////////////////////////////////////////////////////////////////////////////////////
@@ -141,9 +150,7 @@ int ViewVertex___init__(BPy_ViewVertex *self )
// 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
diff --git a/source/blender/freestyle/intern/python/Interface0D/ViewVertex.h b/source/blender/freestyle/intern/python/Interface0D/ViewVertex.h
index b869df377fc..98eeb504a3d 100644
--- a/source/blender/freestyle/intern/python/Interface0D/ViewVertex.h
+++ b/source/blender/freestyle/intern/python/Interface0D/ViewVertex.h
@@ -21,7 +21,6 @@ extern PyTypeObject ViewVertex_Type;
/*---------------------------Python BPy_ViewVertex structure definition----------*/
typedef struct {
BPy_Interface0D py_if0D;
- ViewVertex *vv;
} BPy_ViewVertex;
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Interface1D.cpp b/source/blender/freestyle/intern/python/Interface1D.cpp
index 971403b3354..30dd5b349bd 100644
--- a/source/blender/freestyle/intern/python/Interface1D.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D.cpp
@@ -180,8 +180,7 @@ PyObject *Interface1D_getId( BPy_Interface1D *self ) {
}
PyObject *Interface1D_getNature( BPy_Interface1D *self ) {
- // EdgeNature
- Py_RETURN_NONE;
+ return BPy_Nature_from_Nature( self->if1D->getNature() );
}
PyObject *Interface1D_getTimeStamp( BPy_Interface1D *self ) {
diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge.cpp
index e8e5c6787e3..6a00ad66123 100644
--- a/source/blender/freestyle/intern/python/Interface1D/FEdge.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/FEdge.cpp
@@ -26,6 +26,7 @@ static PyObject * FEdge_SetId( BPy_FEdge *self , PyObject *args);
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 @@ static PyMethodDef BPy_FEdge_methods[] = {
{"SetNextEdge", ( PyCFunction ) FEdge_SetNextEdge, METH_VARARGS, "(FEdge e) Sets the pointer to the next FEdge. "},
{"SetPreviousEdge", ( PyCFunction ) FEdge_SetPreviousEdge, METH_VARARGS, "(FEdge e) Sets the pointer to the previous FEdge. "},
{"SetSmooth", ( PyCFunction ) FEdge_SetSmooth, METH_VARARGS, "(bool b) Sets the flag telling whether this FEdge is smooth or sharp. true for Smooth, false for Sharp. "},
+ {"SetNature", ( PyCFunction ) FEdge_SetNature, METH_VARARGS, "(Nature n) Sets the nature of this FEdge. "},
{NULL, NULL, 0, NULL}
};
@@ -298,6 +300,20 @@ PyObject *FEdge_SetSmooth( BPy_FEdge *self , PyObject *args) {
Py_RETURN_NONE;
}
+PyObject * FEdge_SetNature( BPy_FEdge *self, PyObject *args ) {
+ PyObject *py_n;
+
+ if(!( PyArg_ParseTuple(args, "O", &py_n) && BPy_Nature_Check(py_n) )) {
+ cout << "ERROR: FEdge_setNature" << endl;
+ Py_RETURN_NONE;
+ }
+
+ PyObject *i = (PyObject *) &( ((BPy_Nature *) py_n)->i );
+ ((FEdge *) self->py_if1D.if1D)->SetNature( PyInt_AsLong(i) );
+
+ Py_RETURN_NONE;
+}
+
PyObject *FEdge_getVertices( BPy_FEdge *self ) {
PyObject *py_vertices = PyList_New(NULL);
diff --git a/source/blender/freestyle/intern/python/Nature.cpp b/source/blender/freestyle/intern/python/Nature.cpp
index fb4ba6bae37..14357949022 100644
--- a/source/blender/freestyle/intern/python/Nature.cpp
+++ b/source/blender/freestyle/intern/python/Nature.cpp
@@ -123,13 +123,13 @@ PyMODINIT_FUNC Nature_Init( PyObject *module )
tmp = PyInt_FromLong( Nature::CUSP ); PyDict_SetItemString( Nature_Type.tp_dict, "CUSP", tmp); Py_DECREF(tmp);
// EdgeNature
- tmp = PyInt_FromLong( Nature::NO_FEATURE ); PyDict_SetItemString( Nature_Type.tp_dict, "NO_FEATURE", tmp); Py_DECREF(tmp);
- tmp = PyInt_FromLong( Nature::SILHOUETTE ); PyDict_SetItemString( Nature_Type.tp_dict, "SILHOUETTE", tmp); Py_DECREF(tmp);
- tmp = PyInt_FromLong( Nature::BORDER ); PyDict_SetItemString( Nature_Type.tp_dict, "BORDER", tmp); Py_DECREF(tmp);
- tmp = PyInt_FromLong( Nature::CREASE ); PyDict_SetItemString( Nature_Type.tp_dict, "CREASE", tmp); Py_DECREF(tmp);
- tmp = PyInt_FromLong( Nature::RIDGE ); PyDict_SetItemString( Nature_Type.tp_dict, "RIDGE", tmp); Py_DECREF(tmp);
- tmp = PyInt_FromLong( Nature::VALLEY ); PyDict_SetItemString( Nature_Type.tp_dict, "VALLEY", tmp); Py_DECREF(tmp);
- tmp = PyInt_FromLong( Nature::SUGGESTIVE_CONTOUR ); PyDict_SetItemString( Nature_Type.tp_dict, "SUGGESTIVE_CONTOUR", tmp); Py_DECREF(tmp);
+ tmp = BPy_Nature_from_Nature( Nature::NO_FEATURE ); PyDict_SetItemString( Nature_Type.tp_dict, "NO_FEATURE", tmp); Py_DECREF(tmp);
+ tmp = BPy_Nature_from_Nature( Nature::SILHOUETTE ); PyDict_SetItemString( Nature_Type.tp_dict, "SILHOUETTE", tmp); Py_DECREF(tmp);
+ tmp = BPy_Nature_from_Nature( Nature::BORDER ); PyDict_SetItemString( Nature_Type.tp_dict, "BORDER", tmp); Py_DECREF(tmp);
+ tmp = BPy_Nature_from_Nature( Nature::CREASE ); PyDict_SetItemString( Nature_Type.tp_dict, "CREASE", tmp); Py_DECREF(tmp);
+ tmp = BPy_Nature_from_Nature( Nature::RIDGE ); PyDict_SetItemString( Nature_Type.tp_dict, "RIDGE", tmp); Py_DECREF(tmp);
+ tmp = BPy_Nature_from_Nature( Nature::VALLEY ); PyDict_SetItemString( Nature_Type.tp_dict, "VALLEY", tmp); Py_DECREF(tmp);
+ tmp = BPy_Nature_from_Nature( Nature::SUGGESTIVE_CONTOUR ); PyDict_SetItemString( Nature_Type.tp_dict, "SUGGESTIVE_CONTOUR", tmp); Py_DECREF(tmp);
}