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-25 04:18:10 +0400
committerMaxime Curioni <maxime.curioni@gmail.com>2008-07-25 04:18:10 +0400
commitd8d9839ab31f774d6e8bcdda00cac31db0995d41 (patch)
tree434aa70753adb24d079f42e8df8f86b8cbafc31d /source/blender/freestyle/intern/python/Interface0D
parentfc97e91a3efd7dec5f21ec0a8ba6b81a1db7b72d (diff)
soc-2008-mxcurioni: Added iterator capability to FEdge and Stroke. Recoded parts of ViewVertex, SVertex and Convert to support these changes.
Diffstat (limited to 'source/blender/freestyle/intern/python/Interface0D')
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp6
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp56
2 files changed, 50 insertions, 12 deletions
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
index 233ee3f10b5..748cbc8f1db 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
@@ -15,6 +15,7 @@ static int SVertex___init__(BPy_SVertex *self, PyObject *args, PyObject *kwds);
static PyObject * SVertex___copy__( BPy_SVertex *self );
static PyObject * SVertex_normals( BPy_SVertex *self );
static PyObject * SVertex_normalsSize( BPy_SVertex *self );
+static PyObject * SVertex_viewvertex( BPy_SVertex *self );
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);
@@ -26,6 +27,7 @@ static PyMethodDef BPy_SVertex_methods[] = {
{"__copy__", ( PyCFunction ) SVertex___copy__, METH_NOARGS, "( )Cloning method."},
{"normals", ( PyCFunction ) SVertex_normals, METH_NOARGS, "Returns the normals for this Vertex as a list. In a smooth surface, a vertex has exactly one normal. In a sharp surface, a vertex can have any number of normals."},
{"normalsSize", ( PyCFunction ) SVertex_normalsSize, METH_NOARGS, "Returns the number of different normals for this vertex." },
+ {"viewvertex", ( PyCFunction ) SVertex_viewvertex, METH_NOARGS, "If this SVertex is also a ViewVertex, this method returns a pointer onto this ViewVertex. 0 is returned otherwise." },
{"setPoint3D", ( PyCFunction ) SVertex_setPoint3D, METH_VARARGS, "Sets the 3D coordinates of the SVertex." },
{"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." },
@@ -178,6 +180,10 @@ PyObject * SVertex_normalsSize( BPy_SVertex *self ) {
return PyInt_FromLong( self->sv->normalsSize() );
}
+PyObject * SVertex_viewvertex( BPy_SVertex *self ) {
+ return BPy_ViewVertex_from_ViewVertex_ptr( self->sv->viewvertex() );
+}
+
PyObject *SVertex_setPoint3D( BPy_SVertex *self , PyObject *args) {
PyObject *py_point;
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp
index 2c68dc0e2e3..ba06d071977 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp
@@ -1,6 +1,7 @@
#include "BPy_ViewVertex.h"
#include "../BPy_Convert.h"
+#include "../Interface1D/BPy_ViewEdge.h"
#include "../BPy_Nature.h"
#ifdef __cplusplus
@@ -12,11 +13,16 @@ extern "C" {
/*--------------- Python API function prototypes for ViewVertex instance -----------*/
static int ViewVertex___init__(BPy_ViewVertex *self);
static PyObject * ViewVertex_setNature( BPy_ViewVertex *self, PyObject *args );
-
+static PyObject * ViewVertex_edgesBegin( BPy_ViewVertex *self );
+static PyObject * ViewVertex_edgesEnd( BPy_ViewVertex *self );
+static PyObject * ViewVertex_edgesIterator( BPy_ViewVertex *self, PyObject *args );
/*----------------------ViewVertex instance definitions ----------------------------*/
static PyMethodDef BPy_ViewVertex_methods[] = {
{"setNature", ( PyCFunction ) ViewVertex_setNature, METH_VARARGS, "(Nature n )Sets the nature of the vertex."},
+ {"edgesBegin", ( PyCFunction ) ViewVertex_edgesBegin, METH_NOARGS, "() Returns an iterator over the ViewEdges that goes to or comes from this ViewVertex pointing to the first ViewEdge of the list. The orientedViewEdgeIterator allows to iterate in CCW order over these ViewEdges and to get the orientation for each ViewEdge (incoming/outgoing). "},
+ {"edgesEnd", ( PyCFunction ) ViewVertex_edgesEnd, METH_NOARGS, "() Returns an orientedViewEdgeIterator over the ViewEdges around this ViewVertex, pointing after the last ViewEdge."},
+ {"edgesIterator", ( PyCFunction ) ViewVertex_edgesIterator, METH_VARARGS, "(ViewEdge ve) Returns an orientedViewEdgeIterator pointing to the ViewEdge given as argument. "},
{NULL, NULL, 0, NULL}
};
@@ -112,6 +118,7 @@ PyTypeObject ViewVertex_Type = {
int ViewVertex___init__(BPy_ViewVertex *self )
{
+ self->vv = 0; // ViewVertex is abstract
self->py_if0D.if0D = new Interface0D();
return 0;
}
@@ -121,6 +128,9 @@ int ViewVertex___init__(BPy_ViewVertex *self )
PyObject * ViewVertex_setNature( BPy_ViewVertex *self, PyObject *args ) {
PyObject *py_n;
+ if( !self->vv )
+ Py_RETURN_NONE;
+
if(!( PyArg_ParseTuple(args, "O", &py_n) && BPy_Nature_Check(py_n) )) {
cout << "ERROR: ViewVertex_setNature" << endl;
Py_RETURN_NONE;
@@ -132,21 +142,43 @@ PyObject * ViewVertex_setNature( BPy_ViewVertex *self, PyObject *args ) {
Py_RETURN_NONE;
}
-//PyObject * ViewVertex_edgesBegin( BPy_ViewVertex *self ) {
- // orientedViewEdgeIterator ove( self->vv->edgesBegin() )
- // return BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ove );
-//}
+PyObject * ViewVertex_edgesBegin( BPy_ViewVertex *self ) {
+ if( !self->vv )
+ Py_RETURN_NONE;
+
+ ViewVertexInternal::orientedViewEdgeIterator ove_it( self->vv->edgesBegin() );
+ return BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ove_it );
+}
-///////////////////////////////////////////////////////////////////////////////////////////
+PyObject * ViewVertex_edgesEnd( BPy_ViewVertex *self ) {
+ if( !self->vv )
+ Py_RETURN_NONE;
+
+ ViewVertexInternal::orientedViewEdgeIterator ove_it( self->vv->edgesEnd() );
+ return BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ove_it );
+}
-#ifdef __cplusplus
+
+PyObject * ViewVertex_edgesIterator( BPy_ViewVertex *self, PyObject *args ) {
+ PyObject *py_ve;
+
+ if( !self->vv )
+ Py_RETURN_NONE;
+
+ if(!( PyArg_ParseTuple(args, "O", &py_ve) && BPy_ViewEdge_Check(py_ve) )) {
+ cout << "ERROR: ViewVertex_setNature" << endl;
+ Py_RETURN_NONE;
+ }
+
+ ViewEdge *ve = ((BPy_ViewEdge *) py_ve)->ve;
+ ViewVertexInternal::orientedViewEdgeIterator ove_it( self->vv->edgesIterator( ve ) );
+ return BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ove_it );
}
-#endif
+///////////////////////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+}
+#endif
-// virtual ViewVertexInternal::orientedViewEdgeIterator edgesBegin ()=0
-// virtual ViewVertexInternal::orientedViewEdgeIterator edgesEnd ()=0
-// virtual ViewVertexInternal::orientedViewEdgeIterator edgesIterator (ViewEdge *iEdge)=0
-//