Revision: 15747
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15747
Author: mxcurioni
Date: 2008-07-25 02:18:10 +0200 (Fri, 25 Jul 2008)
Log Message:
-----------
soc-2008-mxcurioni: Added iterator capability to FEdge and Stroke. Recoded
parts of ViewVertex, SVertex and Convert to support these changes.
Modified Paths:
--------------
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Convert.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Convert.h
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
Modified:
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Convert.cpp
===================================================================
---
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Convert.cpp
2008-07-24 22:49:29 UTC (rev 15746)
+++
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Convert.cpp
2008-07-25 00:18:10 UTC (rev 15747)
@@ -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 @@
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
Modified:
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Convert.h
===================================================================
---
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Convert.h
2008-07-24 22:49:29 UTC (rev 15746)
+++
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Convert.h
2008-07-25 00:18:10 UTC (rev 15747)
@@ -33,6 +33,8 @@
// - ViewEdgeInternal
//##########################################################
+// StrokeInternal::StrokeVertexIterator
+#include "../stroke/StrokeIterators.h"
#ifdef __cplusplus
extern "C" {
@@ -57,7 +59,6 @@
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_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
Modified:
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
===================================================================
---
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
2008-07-24 22:49:29 UTC (rev 15746)
+++
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
2008-07-25 00:18:10 UTC (rev 15747)
@@ -15,6 +15,7 @@
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 @@
{"__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 @@
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;
Modified:
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp
===================================================================
---
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp
2008-07-24 22:49:29 UTC (rev 15746)
+++
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp
2008-07-25 00:18:10 UTC (rev 15747)
@@ -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 @@
/*--------------- 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 @@
int ViewVertex___init__(BPy_ViewVertex *self )
{
+ self->vv = 0; // ViewVertex is abstract
self->py_if0D.if0D = new Interface0D();
return 0;
}
@@ -121,6 +128,9 @@
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 @@
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 );
+}
+
+
+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 );
+}
+
+
///////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif
-
-
-
-// virtual ViewVertexInternal::orientedViewEdgeIterator edgesBegin ()=0
-// virtual ViewVertexInternal::orientedViewEdgeIterator edgesEnd ()=0
-// virtual ViewVertexInternal::orientedViewEdgeIterator edgesIterator
(ViewEdge *iEdge)=0
-//
Modified:
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
===================================================================
---
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
2008-07-24 22:49:29 UTC (rev 15746)
+++
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
2008-07-25 00:18:10 UTC (rev 15747)
@@ -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
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs