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-18 06:55:23 +0400
committerMaxime Curioni <maxime.curioni@gmail.com>2008-07-18 06:55:23 +0400
commitd3973dac717da1557a9a8d50f5c13e25ae75eaa8 (patch)
treede60800b4b5d74989680f746dbfcb99934c7f825 /source/blender/freestyle/intern/python/Interface0D
parente4748940c0a61171d5c4e45d8d5a9637d05ac429 (diff)
soc-2008-mxcurioni: FEdge class added. Modifed converting functions to passing-by-reference format. Improved the type checking for FEdge and CurvePoint. Modified FEdge C++ class to test for null vertices. Updated previous classes to support FEdge.
So far, whenever a Python object is created from its corresponding C++ object, the input object reference is copied into a new object. Due to Freestyle's functions (especially regarding the way it is iterated), it is currently impossible to deal with a pointer-based Python object. It is not a real drawback, just an aspect to keep in mind.
Diffstat (limited to 'source/blender/freestyle/intern/python/Interface0D')
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/CurvePoint.cpp9
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/SVertex.cpp24
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/SVertex.h33
3 files changed, 57 insertions, 9 deletions
diff --git a/source/blender/freestyle/intern/python/Interface0D/CurvePoint.cpp b/source/blender/freestyle/intern/python/Interface0D/CurvePoint.cpp
index 5a81f07973d..f76fc9c9931 100644
--- a/source/blender/freestyle/intern/python/Interface0D/CurvePoint.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/CurvePoint.cpp
@@ -1,7 +1,6 @@
#include "CurvePoint.h"
#include "../Convert.h"
-#include "../../stroke/Curve.h"
#ifdef __cplusplus
extern "C" {
@@ -166,15 +165,15 @@ PyObject * CurvePoint___copy__( BPy_CurvePoint *self ) {
}
PyObject * CurvePoint_A( BPy_CurvePoint *self ) {
- if( self->cp->A() )
- return BPy_SVertex_from_SVertex( *(self->cp->A()) );
+ if( SVertex *A = self->cp->A() )
+ return BPy_SVertex_from_SVertex( *A );
Py_RETURN_NONE;
}
PyObject * CurvePoint_B( BPy_CurvePoint *self ) {
- if( self->cp->B() )
- return BPy_SVertex_from_SVertex( *(self->cp->B()) );
+ if( SVertex *B = self->cp->B() )
+ return BPy_SVertex_from_SVertex( *B );
Py_RETURN_NONE;
}
diff --git a/source/blender/freestyle/intern/python/Interface0D/SVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/SVertex.cpp
index fd5b372a1d9..eb91d7daf10 100644
--- a/source/blender/freestyle/intern/python/Interface0D/SVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/SVertex.cpp
@@ -18,6 +18,8 @@ static PyObject * SVertex_SetPoint3D( BPy_SVertex *self , PyObject *args);
static PyObject * SVertex_SetPoint2D( BPy_SVertex *self , PyObject *args);
static PyObject * SVertex_AddNormal( BPy_SVertex *self , PyObject *args);
static PyObject * SVertex_SetId( BPy_SVertex *self , PyObject *args);
+static PyObject *SVertex_AddFEdge( BPy_SVertex *self , PyObject *args);
+
/*----------------------SVertex instance definitions ----------------------------*/
static PyMethodDef BPy_SVertex_methods[] = {
{"__copy__", ( PyCFunction ) SVertex___copy__, METH_NOARGS, "( )Cloning method."},
@@ -27,6 +29,7 @@ static PyMethodDef BPy_SVertex_methods[] = {
{"SetPoint2D", ( PyCFunction ) SVertex_SetPoint2D, METH_VARARGS, "Sets the 3D projected coordinates of the SVertex." },
{"AddNormal", ( PyCFunction ) SVertex_AddNormal, METH_VARARGS, "Adds a normal to the Svertex's set of normals. If the same normal is already in the set, nothing changes." },
{"SetId", ( PyCFunction ) SVertex_SetId, METH_VARARGS, "Sets the Id." },
+ {"AddFEdge", ( PyCFunction ) SVertex_AddFEdge, METH_VARARGS, "Add an FEdge to the list of edges emanating from this SVertex." },
{NULL, NULL, 0, NULL}
};
@@ -163,7 +166,8 @@ PyObject * SVertex_normals( BPy_SVertex *self ) {
normals = self->sv->normals();
for( set< Vec3r >::iterator set_iterator = normals.begin(); set_iterator != normals.end(); set_iterator++ ) {
- PyList_Append( py_normals, Vector_from_Vec3r(*set_iterator) );
+ Vec3r v( *set_iterator );
+ PyList_Append( py_normals, Vector_from_Vec3r(v) );
}
return py_normals;
@@ -215,8 +219,6 @@ PyObject *SVertex_AddNormal( BPy_SVertex *self , PyObject *args) {
cout << "ERROR: SVertex_AddNormal" << endl;
Py_RETURN_NONE;
}
-
- cout << "yoyo" << endl;
Vec3r n( PyFloat_AsDouble( PyList_GetItem(py_normal, 0) ),
PyFloat_AsDouble( PyList_GetItem(py_normal, 1) ),
@@ -239,9 +241,23 @@ PyObject *SVertex_SetId( BPy_SVertex *self , PyObject *args) {
Py_RETURN_NONE;
}
+PyObject *SVertex_AddFEdge( BPy_SVertex *self , PyObject *args) {
+ PyObject *py_fe;
+
+ if(!( PyArg_ParseTuple(args, "O", &py_fe) && BPy_FEdge_Check(py_fe) )) {
+ cout << "ERROR: SVertex_AddFEdge" << endl;
+ Py_RETURN_NONE;
+ }
+
+ self->sv->AddFEdge( ((BPy_FEdge *) py_fe)->fe );
+
+ Py_RETURN_NONE;
+}
+
+
// virtual bool operator== (const SVertex &iBrother)
// ViewVertex * viewvertex ()
-// void AddFEdge (FEdge *iFEdge)
+
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Interface0D/SVertex.h b/source/blender/freestyle/intern/python/Interface0D/SVertex.h
new file mode 100644
index 00000000000..ac89133ab55
--- /dev/null
+++ b/source/blender/freestyle/intern/python/Interface0D/SVertex.h
@@ -0,0 +1,33 @@
+#ifndef FREESTYLE_PYTHON_SVERTEX_H
+#define FREESTYLE_PYTHON_SVERTEX_H
+
+#include "../../view_map/Silhouette.h"
+#include "../Interface0D.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+#include <Python.h>
+
+extern PyTypeObject SVertex_Type;
+
+#define BPy_SVertex_Check(v) \
+ ((v)->ob_type == &SVertex_Type)
+
+/*---------------------------Python BPy_SVertex structure definition----------*/
+typedef struct {
+ BPy_Interface0D py_if0D;
+ SVertex *sv;
+} BPy_SVertex;
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREESTYLE_PYTHON_SVERTEX_H */