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
parentfc97e91a3efd7dec5f21ec0a8ba6b81a1db7b72d (diff)
soc-2008-mxcurioni: Added iterator capability to FEdge and Stroke. Recoded parts of ViewVertex, SVertex and Convert to support these changes.
-rw-r--r--source/blender/freestyle/intern/python/BPy_Convert.cpp16
-rw-r--r--source/blender/freestyle/intern/python/BPy_Convert.h7
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp6
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp56
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp102
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp90
6 files changed, 217 insertions, 60 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_Convert.cpp b/source/blender/freestyle/intern/python/BPy_Convert.cpp
index bab9da8332e..6ab2dc9ebfb 100644
--- a/source/blender/freestyle/intern/python/BPy_Convert.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Convert.cpp
@@ -9,7 +9,9 @@
#include "Interface0D/BPy_ViewVertex.h"
#include "Interface1D/BPy_FEdge.h"
#include "Interface1D/BPy_ViewEdge.h"
+#include "Iterator/BPy_Interface0DIterator.h"
#include "Iterator/BPy_orientedViewEdgeIterator.h"
+#include "Iterator/BPy_StrokeVertexIterator.h"
#include "BPy_SShape.h"
#include "BPy_Nature.h"
#include "BPy_MediumType.h"
@@ -157,6 +159,20 @@ PyObject * BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ViewVerte
return py_ove_it;
}
+PyObject * BPy_Interface0DIterator_from_Interface0DIterator( Interface0DIterator& if0D_it ) {
+ PyObject *py_if0D_it = Interface0DIterator_Type.tp_new( &Interface0DIterator_Type, 0, 0 );
+ ((BPy_Interface0DIterator *) py_if0D_it)->if0D_it = new Interface0DIterator( if0D_it );
+
+ return py_if0D_it;
+}
+
+PyObject * BPy_StrokeVertexIterator_from_StrokeVertexIterator( StrokeInternal::StrokeVertexIterator& sv_it) {
+ PyObject *py_sv_it = StrokeVertexIterator_Type.tp_new( &StrokeVertexIterator_Type, 0, 0 );
+ ((BPy_StrokeVertexIterator*) py_sv_it)->sv_it = new StrokeInternal::StrokeVertexIterator( sv_it );
+
+ return py_sv_it;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
diff --git a/source/blender/freestyle/intern/python/BPy_Convert.h b/source/blender/freestyle/intern/python/BPy_Convert.h
index 87d902f28a8..05f002656c7 100644
--- a/source/blender/freestyle/intern/python/BPy_Convert.h
+++ b/source/blender/freestyle/intern/python/BPy_Convert.h
@@ -33,6 +33,8 @@ using namespace Geometry;
// - ViewEdgeInternal
//##########################################################
+// StrokeInternal::StrokeVertexIterator
+#include "../stroke/StrokeIterators.h"
#ifdef __cplusplus
extern "C" {
@@ -57,7 +59,6 @@ PyObject * BPy_Id_from_Id( Id& id );
PyObject * BPy_Interface0D_from_Interface0D( Interface0D& if0D );
PyObject * BPy_Nature_from_Nature( unsigned short n );
PyObject * BPy_MediumType_from_MediumType( int n );
-PyObject * BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ViewVertexInternal::orientedViewEdgeIterator& ove_it );
PyObject * BPy_SShape_from_SShape( SShape& ss );
PyObject * BPy_StrokeAttribute_from_StrokeAttribute( StrokeAttribute& sa );
PyObject * BPy_StrokeVertex_from_StrokeVertex( StrokeVertex& sv );
@@ -65,6 +66,10 @@ PyObject * BPy_SVertex_from_SVertex( SVertex& sv );
PyObject * BPy_ViewVertex_from_ViewVertex_ptr( ViewVertex *vv );
PyObject * BPy_ViewEdge_from_ViewEdge( ViewEdge& ve );
+PyObject * BPy_Interface0DIterator_from_Interface0DIterator( Interface0DIterator& if0D_it );
+PyObject * BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ViewVertexInternal::orientedViewEdgeIterator& ove_it );
+PyObject * BPy_StrokeVertexIterator_from_StrokeVertexIterator( StrokeInternal::StrokeVertexIterator& sv_it);
+
///////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
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
-//
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
index bee852a96cb..3eaad2bd8c4 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
@@ -3,6 +3,7 @@
#include "../BPy_Convert.h"
#include "../BPy_Id.h"
#include "../Interface0D/BPy_SVertex.h"
+#include "../Interface1D/BPy_ViewEdge.h"
#include "../BPy_Nature.h"
#ifdef __cplusplus
@@ -19,8 +20,7 @@ static PyObject * FEdge_vertexB( BPy_FEdge *self );
static PyObject * FEdge___getitem__( BPy_FEdge *self, PyObject *args );
static PyObject * FEdge_nextEdge( BPy_FEdge *self );
static PyObject * FEdge_previousEdge( BPy_FEdge *self );
-static PyObject * FEdge_getVertices( BPy_FEdge *self );
-static PyObject * FEdge_getPoints( BPy_FEdge *self );
+static PyObject * FEdge_viewedge( BPy_FEdge *self );
static PyObject * FEdge_isSmooth( BPy_FEdge *self );
static PyObject * FEdge_setVertexA( BPy_FEdge *self , PyObject *args);
static PyObject * FEdge_setVertexB( BPy_FEdge *self , PyObject *args);
@@ -29,6 +29,11 @@ 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 );
+static PyObject * FEdge_setViewEdge( BPy_FEdge *self, PyObject *args );
+static PyObject * FEdge_verticesBegin( BPy_FEdge *self );
+static PyObject * FEdge_verticesEnd( BPy_FEdge *self );
+static PyObject * FEdge_pointsBegin( BPy_FEdge *self, PyObject *args );
+static PyObject * FEdge_pointsEnd( BPy_FEdge *self, PyObject *args );
/*----------------------FEdge instance definitions ----------------------------*/
static PyMethodDef BPy_FEdge_methods[] = {
@@ -38,8 +43,7 @@ static PyMethodDef BPy_FEdge_methods[] = {
{"__getitem__", ( PyCFunction ) FEdge___getitem__, METH_VARARGS, "(int i) Returns the first SVertex if i=0, the seccond SVertex if i=1."},
{"nextEdge", ( PyCFunction ) FEdge_nextEdge, METH_NOARGS, "() Returns the FEdge following this one in the ViewEdge. If this FEdge is the last of the ViewEdge, 0 is returned."},
{"previousEdge", ( PyCFunction ) FEdge_previousEdge, METH_NOARGS, "Returns the Edge preceding this one in the ViewEdge. If this FEdge is the first one of the ViewEdge, 0 is returned."},
- {"getVertices", ( PyCFunction ) FEdge_getVertices, METH_NOARGS, "Returns the vertices"},
- {"getPoints", ( PyCFunction ) FEdge_getPoints, METH_NOARGS, "Returns the points. The difference with getVertices() is that here we can iterate over points of the 1D element at any given sampling. At each call, a virtual point is created."},
+ {"viewedge", ( PyCFunction ) FEdge_viewedge, METH_NOARGS, "Returns a pointer to the ViewEdge to which this FEdge belongs to."},
{"isSmooth", ( PyCFunction ) FEdge_isSmooth, METH_NOARGS, "() Returns true if this FEdge is a smooth FEdge."},
{"setVertexA", ( PyCFunction ) FEdge_setVertexA, METH_VARARGS, "(SVertex v) Sets the first SVertex. ."},
{"setVertexB", ( PyCFunction ) FEdge_setVertexB, METH_VARARGS, "(SVertex v) Sets the second SVertex. "},
@@ -47,7 +51,12 @@ 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. "},
+ {"setViewEdge", ( PyCFunction ) FEdge_setViewEdge, METH_VARARGS, "(ViewEdge ve) Sets the ViewEdge to which this FEdge belongs to."},
{"setNature", ( PyCFunction ) FEdge_setNature, METH_VARARGS, "(Nature n) Sets the nature of this FEdge. "},
+ {"verticesBegin", ( PyCFunction ) FEdge_verticesBegin, METH_NOARGS, "() Returns an iterator over the 2 (!) SVertex pointing to the first SVertex."},
+ {"verticesEnd", ( PyCFunction ) FEdge_verticesEnd, METH_NOARGS, "() Returns an iterator over the 2 (!) SVertex pointing after the last SVertex. "},
+ {"pointsBegin", ( PyCFunction ) FEdge_pointsBegin, METH_VARARGS, "(float t=0) Returns an iterator over the FEdge points, pointing to the first point. The difference with verticesBegin() is that here we can iterate over points of the FEdge at a any given sampling t. Indeed, for each iteration, a virtual point is created."},
+ {"pointsEnd", ( PyCFunction ) FEdge_pointsEnd, METH_VARARGS, "(float t=0) Returns an iterator over the FEdge points, pointing after the last point. The difference with verticesEnd() is that here we can iterate over points of the FEdge at a any given sampling t. Indeed, for each iteration, a virtual point is created."},
{NULL, NULL, 0, NULL}
};
@@ -219,6 +228,13 @@ PyObject * FEdge_previousEdge( BPy_FEdge *self ) {
Py_RETURN_NONE;
}
+PyObject * FEdge_viewedge( BPy_FEdge *self ) {
+ if( ViewEdge *ve = self->fe->viewedge() )
+ return BPy_ViewEdge_from_ViewEdge( *ve );
+
+ Py_RETURN_NONE;
+}
+
PyObject * FEdge_isSmooth( BPy_FEdge *self ) {
return PyBool_from_bool( self->fe->isSmooth() );
}
@@ -289,6 +305,37 @@ PyObject *FEdge_setPreviousEdge( 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 );
+ self->fe->setNature( PyInt_AsLong(i) );
+
+ Py_RETURN_NONE;
+}
+
+
+PyObject * FEdge_setViewEdge( BPy_FEdge *self, PyObject *args ) {
+ PyObject *py_ve;
+
+ if(!( PyArg_ParseTuple(args, "O", &py_ve) && BPy_ViewEdge_Check(py_ve) )) {
+ cout << "ERROR: FEdge_setViewEdge" << endl;
+ Py_RETURN_NONE;
+ }
+
+ ViewEdge *ve = ((BPy_ViewEdge *) py_ve)->ve;
+ self->fe->setViewEdge( ve );
+
+ Py_RETURN_NONE;
+}
+
+
+
PyObject *FEdge_setSmooth( BPy_FEdge *self , PyObject *args) {
int b;
@@ -302,40 +349,41 @@ 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) );
+PyObject * FEdge_verticesBegin( BPy_FEdge *self ) {
+ Interface0DIterator if0D_it( self->fe->verticesBegin() );
+ return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it );
+}
- Py_RETURN_NONE;
+PyObject * FEdge_verticesEnd( BPy_FEdge *self ) {
+ Interface0DIterator if0D_it( self->fe->verticesEnd() );
+ return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it );
}
-PyObject *FEdge_getVertices( BPy_FEdge *self ) {
- PyObject *py_vertices = PyList_New(NULL);
-
- for( Interface0DIterator it = self->fe->verticesBegin(); it != self->fe->verticesEnd(); it++ ) {
- PyList_Append( py_vertices, BPy_Interface0D_from_Interface0D( *it ) );
+
+PyObject * FEdge_pointsBegin( BPy_FEdge *self, PyObject *args ) {
+ float f = 0;
+
+ if(!( PyArg_ParseTuple(args, "|f", &f) )) {
+ cout << "ERROR: FEdge_pointsBegin" << endl;
+ Py_RETURN_NONE;
}
- return py_vertices;
+ Interface0DIterator if0D_it( self->fe->pointsBegin(f) );
+ return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it );
}
-PyObject *FEdge_getPoints( BPy_FEdge *self ) {
- PyObject *py_points = PyList_New(NULL);
-
- for( Interface0DIterator it = self->fe->pointsBegin(); it != self->fe->pointsEnd(); it++ ) {
- PyList_Append( py_points, BPy_Interface0D_from_Interface0D( *it ) );
+PyObject * FEdge_pointsEnd( BPy_FEdge *self, PyObject *args ) {
+ float f = 0;
+
+ if(!( PyArg_ParseTuple(args, "|f", &f) )) {
+ cout << "ERROR: FEdge_pointsEnd" << endl;
+ Py_RETURN_NONE;
}
- return py_points;
+ Interface0DIterator if0D_it( self->fe->pointsEnd(f) );
+ return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it );
}
-
///////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
index 6e5be90bc82..af4e882a672 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
@@ -4,10 +4,9 @@
#include "../BPy_Id.h"
#include "../Interface0D/BPy_SVertex.h"
#include "../Interface0D/CurvePoint/BPy_StrokeVertex.h"
+#include "../Iterator/BPy_StrokeVertexIterator.h"
#include "../BPy_MediumType.h"
-#include "../../stroke/StrokeIterators.h"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -19,7 +18,7 @@ static int Stroke___init__(BPy_Stroke *self, PyObject *args, PyObject *kwds);
static PyObject * Stroke_ComputeSampling( BPy_Stroke *self, PyObject *args );
static PyObject * Stroke_Resample( BPy_Stroke *self, PyObject *args );
-//static PyObject * Stroke_InsertVertex( BPy_Stroke *self, PyObject *args );
+static PyObject * Stroke_InsertVertex( BPy_Stroke *self, PyObject *args );
static PyObject * Stroke_RemoveVertex( BPy_Stroke *self, PyObject *args );
static PyObject * Stroke_getMediumType( BPy_Stroke *self );
static PyObject * Stroke_getTextureId( BPy_Stroke *self );
@@ -29,14 +28,20 @@ static PyObject * Stroke_setLength( BPy_Stroke *self , PyObject *args);
static PyObject * Stroke_setMediumType( BPy_Stroke *self , PyObject *args);
static PyObject * Stroke_setTextureId( BPy_Stroke *self , PyObject *args);
static PyObject * Stroke_setTips( BPy_Stroke *self , PyObject *args);
+static PyObject * Stroke_strokeVerticesBegin( BPy_Stroke *self , PyObject *args);
+static PyObject * Stroke_strokeVerticesEnd( BPy_Stroke *self );
static PyObject * Stroke_strokeVerticesSize( BPy_Stroke *self );
-static PyObject * Stroke_getStrokeVertices( BPy_Stroke *self );
+static PyObject * Stroke_verticesBegin( BPy_Stroke *self );
+static PyObject * Stroke_verticesEnd( BPy_Stroke *self );
+static PyObject * Stroke_pointsBegin( BPy_Stroke *self , PyObject *args);
+static PyObject * Stroke_pointsEnd( BPy_Stroke *self , PyObject *args);
/*----------------------Stroke instance definitions ----------------------------*/
static PyMethodDef BPy_Stroke_methods[] = {
{"ComputeSampling", ( PyCFunction ) Stroke_ComputeSampling, METH_VARARGS, "(int nVertices) Compute the sampling needed to get nVertices vertices. If the specified number of vertices is less than the actual number of vertices, the actual sampling value is returned."},
{"Resample", ( PyCFunction ) Stroke_Resample, METH_VARARGS, "(float f | int n) Resampling method. If the argument is a float, Resamples the curve with a given sampling; if this sampling is < to the actual sampling value, no resampling is done. If the argument is an integer, Resamples the curve so that it eventually has n. That means it is going to add n-vertices_size, if vertices_size is the number of points we already have. Is vertices_size >= n, no resampling is done."},
{"RemoveVertex", ( PyCFunction ) Stroke_RemoveVertex, METH_VARARGS, "(StrokeVertex sv) Removes the stroke vertex sv from the stroke. The length and curvilinear abscissa are updated consequently."},
+ {"InsertVertex", ( PyCFunction ) Stroke_InsertVertex, METH_VARARGS, "(StrokeVertex sv, StrokeVertexIterator next) Inserts the stroke vertex iVertex in the stroke before next. The length, curvilinear abscissa are updated consequently."},
{"getMediumType", ( PyCFunction ) Stroke_getMediumType, METH_NOARGS, "() Returns the MediumType used for this Stroke."},
{"getTextureId", ( PyCFunction ) Stroke_getTextureId, METH_NOARGS, "() Returns the id of the texture used to simulate th marks system for this Stroke."},
{"hasTips", ( PyCFunction ) Stroke_hasTips, METH_NOARGS, "() Returns true if this Stroke uses a texture with tips, false otherwise."},
@@ -45,9 +50,14 @@ static PyMethodDef BPy_Stroke_methods[] = {
{"setMediumType", ( PyCFunction ) Stroke_setMediumType, METH_VARARGS, "(MediumType mt) Sets the medium type that must be used for this Stroke."},
{"setTextureId", ( PyCFunction ) Stroke_setTextureId, METH_VARARGS, "(unsigned int id) Sets the texture id to be used to simulate the marks system for this Stroke."},
{"setTips", ( PyCFunction ) Stroke_setTips, METH_VARARGS, "(bool b) Sets the flag telling whether this stroke is using a texture with tips or not."},
+ {"strokeVerticesBegin", ( PyCFunction ) Stroke_strokeVerticesBegin, METH_VARARGS, "(float t=0.f) Returns a StrokeVertexIterator pointing on the first StrokeVertex of the Stroke. One can specifly a sampling value t to resample the Stroke on the fly if needed. "},
+ {"strokeVerticesEnd", ( PyCFunction ) Stroke_strokeVerticesEnd, METH_NOARGS, "() Returns a StrokeVertexIterator pointing after the last StrokeVertex of the Stroke."},
{"strokeVerticesSize", ( PyCFunction ) Stroke_strokeVerticesSize, METH_NOARGS, "() Returns the number of StrokeVertex constituing the Stroke."},
- {"getStrokeVertices", ( PyCFunction ) Stroke_getStrokeVertices, METH_NOARGS, "() Returns the stroke vertices. The difference with vertices() is that here we can iterate over points of the 1D element at a any given sampling. Indeed, for each iteration, a virtual point is created."},
- //{"InsertVertex", ( PyCFunction ) Stroke_InsertVertex, METH_NOARGS, "(StrokeVertex sv, int i) Inserts the stroke vertex iVertex in the stroke before i. The length, curvilinear abscissa are updated consequently."},
+ {"verticesBegin", ( PyCFunction ) Stroke_verticesBegin, METH_NOARGS, "() Returns an Interface0DIterator pointing on the first StrokeVertex of the Stroke. "},
+ {"verticesEnd", ( PyCFunction ) Stroke_verticesEnd, METH_NOARGS, "() Returns an Interface0DIterator pointing after the last StrokeVertex of the Stroke. "},
+ {"pointsBegin", ( PyCFunction ) Stroke_pointsBegin, METH_VARARGS, "(float t=0.f) Returns an iterator over the Interface1D points, pointing to the first point. The difference with verticesBegin() is that here we can iterate over points of the 1D element at a any given sampling t. Indeed, for each iteration, a virtual point is created. "},
+ {"pointsEnd", ( PyCFunction ) Stroke_pointsEnd, METH_VARARGS, "(float t=0.f) Returns an iterator over the Interface1D points, pointing after the last point. The difference with verticesEnd() is that here we can iterate over points of the 1D element at a any given sampling t. Indeed, for each iteration, a virtual point is created. "},
+
{NULL, NULL, 0, NULL}
};
@@ -194,6 +204,21 @@ PyObject * Stroke_Resample( BPy_Stroke *self, PyObject *args ) {
Py_RETURN_NONE;
}
+PyObject * Stroke_InsertVertex( BPy_Stroke *self, PyObject *args ) {
+ PyObject *py_sv = 0, *py_sv_it = 0;
+
+ if(!( PyArg_ParseTuple(args, "OO", &py_sv, &py_sv_it) &&
+ BPy_StrokeVertex_Check(py_sv) && BPy_StrokeVertexIterator_Check(py_sv_it) )) {
+ cout << "ERROR: Stroke_InsertVertex" << endl;
+ Py_RETURN_NONE;
+ }
+
+ StrokeVertex *sv = ((BPy_StrokeVertex *) py_sv)->sv;
+ StrokeInternal::StrokeVertexIterator sv_it(*( ((BPy_StrokeVertexIterator *) py_sv_it)->sv_it ));
+ self->s->InsertVertex( sv, sv_it );
+
+ Py_RETURN_NONE;
+}
PyObject * Stroke_RemoveVertex( BPy_Stroke *self, PyObject *args ) {
PyObject *py_sv;
@@ -209,9 +234,6 @@ PyObject * Stroke_RemoveVertex( BPy_Stroke *self, PyObject *args ) {
Py_RETURN_NONE;
}
-// pb: 'iterator <=> list' correspondence
-// void InsertVertex (StrokeVertex *iVertex, StrokeInternal::StrokeVertexIterator next)
-
PyObject * Stroke_getMediumType( BPy_Stroke *self ) {
return BPy_MediumType_from_MediumType( self->s->getMediumType() );
}
@@ -291,26 +313,54 @@ PyObject *Stroke_setTips( BPy_Stroke *self , PyObject *args) {
Py_RETURN_NONE;
}
+PyObject * Stroke_strokeVerticesBegin( BPy_Stroke *self , PyObject *args) {
+ StrokeInternal::StrokeVertexIterator sv_it( self->s->strokeVerticesBegin() );
+ return BPy_StrokeVertexIterator_from_StrokeVertexIterator( sv_it );
+}
-PyObject * Stroke_strokeVerticesSize( BPy_Stroke *self ) {
+PyObject * Stroke_strokeVerticesEnd( BPy_Stroke *self ) {
+ StrokeInternal::StrokeVertexIterator sv_it( self->s->strokeVerticesEnd() );
+ return BPy_StrokeVertexIterator_from_StrokeVertexIterator( sv_it );
+}
+
+PyObject * Stroke_strokeVerticesSize( BPy_Stroke *self ) {
return PyInt_FromLong( self->s->strokeVerticesSize() );
}
+PyObject * Stroke_verticesBegin( BPy_Stroke *self ) {
+ Interface0DIterator if0D_it( self->s->verticesBegin() );
+ return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it );
+}
-PyObject *Stroke_getStrokeVertices( BPy_Stroke *self ) {
- PyObject *py_stroke_vertices = PyList_New(NULL);
-
- for( StrokeInternal::StrokeVertexIterator it = self->s->strokeVerticesBegin();
- it != self->s->strokeVerticesEnd();
- it++ ) {
- PyList_Append( py_stroke_vertices, BPy_StrokeVertex_from_StrokeVertex( *it ) );
- }
-
- return py_stroke_vertices;
+PyObject * Stroke_verticesEnd( BPy_Stroke *self ) {
+ Interface0DIterator if0D_it( self->s->verticesEnd() );
+ return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it );
}
+PyObject * Stroke_pointsBegin( BPy_Stroke *self , PyObject *args) {
+ float f = 0;
+ if(!( PyArg_ParseTuple(args, "|f", &f) )) {
+ cout << "ERROR: Stroke_pointsBegin" << endl;
+ Py_RETURN_NONE;
+ }
+
+ Interface0DIterator if0D_it( self->s->pointsBegin(f) );
+ return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it );
+}
+PyObject * Stroke_pointsEnd( BPy_Stroke *self , PyObject *args) {
+ float f = 0;
+
+ if(!( PyArg_ParseTuple(args, "|f", &f) )) {
+ cout << "ERROR: Stroke_pointsEnd" << endl;
+ Py_RETURN_NONE;
+ }
+
+ Interface0DIterator if0D_it( self->s->pointsEnd(f) );
+ return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it );
+}
+
///////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus