[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15705] branches/soc-2008-mxcurioni/source /blender/freestyle: soc-2008-mxcurioni: implemented (without testing) StrokeShader, Stroke and MediumType (used by Stroke to define medium types ) classes.

Maxime Curioni maxime.curioni at gmail.com
Wed Jul 23 07:54:35 CEST 2008


Revision: 15705
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15705
Author:   mxcurioni
Date:     2008-07-23 07:54:34 +0200 (Wed, 23 Jul 2008)

Log Message:
-----------
soc-2008-mxcurioni: implemented (without testing) StrokeShader, Stroke and MediumType (used by Stroke to define medium types) classes. The Stroke class is missing the InsertVertex method.

Before porting other classes, I'll resolve the List (Python) <=> Iterator (C++) correspondence problem by implementing a general class appropriately suited for the task.

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Convert.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Convert.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Freestyle.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/Stroke.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader.cpp

Added Paths:
-----------
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/Stroke.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/MediumType.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/MediumType.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader.h

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript	2008-07-23 02:31:56 UTC (rev 15704)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript	2008-07-23 05:54:34 UTC (rev 15705)
@@ -73,8 +73,11 @@
 					prefix + '/Interface0D/ViewVertex.cpp',
 					prefix + '/Interface1D.cpp',
 					prefix + '/Interface1D/FEdge.cpp',
+					prefix + '/Interface1D/Stroke.cpp',
 					prefix + '/Nature.cpp',
+					prefix + '/MediumType.cpp',
 					prefix + '/StrokeAttribute.cpp',
+					prefix + '/StrokeShader.cpp',
 					prefix + '/UnaryFunction0D.cpp',
 					prefix + '/UnaryFunction1D.cpp',
 					prefix + '/UnaryPredicate0D.cpp',

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Convert.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Convert.cpp	2008-07-23 02:31:56 UTC (rev 15704)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Convert.cpp	2008-07-23 05:54:34 UTC (rev 15705)
@@ -82,6 +82,26 @@
 	return py_sa;	
 }
 
+PyObject * BPy_MediumType_from_MediumType( unsigned short n ) {
+	PyObject *py_mt =  MediumType_Type.tp_new( &MediumType_Type, 0, 0 );
+
+	PyObject *args = PyTuple_New(1);
+	PyTuple_SetItem( args, 0, PyInt_FromLong(n) );
+	MediumType_Type.tp_init( py_mt, args, 0 );
+	Py_DECREF(args);
+
+	return py_mt;
+}
+
+PyObject * BPy_StrokeVertex_from_StrokeVertex( StrokeVertex& sv ) {
+	PyObject *py_sv = StrokeVertex_Type.tp_new( &StrokeVertex_Type, 0, 0 );
+	((BPy_StrokeVertex *) py_sv)->sv = new StrokeVertex( sv );
+	((BPy_StrokeVertex *) py_sv)->py_cp.cp = ((BPy_StrokeVertex *) py_sv)->sv;
+	((BPy_StrokeVertex *) py_sv)->py_cp.py_if0D.if0D = ((BPy_StrokeVertex *) py_sv)->sv;
+
+	return py_sv;
+}
+
 ///////////////////////////////////////////////////////////////////////////////////////////
 
 #ifdef __cplusplus

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Convert.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Convert.h	2008-07-23 02:31:56 UTC (rev 15704)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Convert.h	2008-07-23 05:54:34 UTC (rev 15705)
@@ -7,9 +7,11 @@
 #include "Id.h"
 #include "IntegrationType.h"
 #include "Interface0D.h"
+#include "Interface0D/CurvePoint/StrokeVertex.h"
 #include "Interface0D/SVertex.h"
 #include "Interface1D/FEdge.h"
 #include "Nature.h"
+#include "MediumType.h"
 #include "StrokeAttribute.h"
 
 #ifdef __cplusplus
@@ -32,7 +34,9 @@
 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( unsigned short n );
 PyObject * BPy_StrokeAttribute_from_StrokeAttribute( StrokeAttribute& sa );
+PyObject * BPy_StrokeVertex_from_StrokeVertex( StrokeVertex& sv );
 PyObject * BPy_SVertex_from_SVertex( SVertex& sv );
 
 ///////////////////////////////////////////////////////////////////////////////////////////

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Freestyle.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Freestyle.cpp	2008-07-23 02:31:56 UTC (rev 15704)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Freestyle.cpp	2008-07-23 05:54:34 UTC (rev 15705)
@@ -9,6 +9,7 @@
 #include "Interface1D.h"
 #include "Nature.h"
 #include "StrokeAttribute.h"
+#include "StrokeShader.h"
 #include "UnaryFunction0D.h"
 #include "UnaryFunction1D.h"
 #include "UnaryPredicate0D.h"
@@ -136,6 +137,7 @@
 	Interface1D_Init( module );
 	Nature_Init( module );
 	StrokeAttribute_Init( module );
+	StrokeShader_Init( module );
 	UnaryFunction0D_Init( module );
 	UnaryFunction1D_Init( module );
 	UnaryPredicate0D_Init( module );

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/Stroke.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/Stroke.cpp	2008-07-23 02:31:56 UTC (rev 15704)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D/Stroke.cpp	2008-07-23 05:54:34 UTC (rev 15705)
@@ -1,236 +1,314 @@
-PyObject *Stroke_getExactTypeName(PyObject *self , PyObject *args) {
-}
+#include "Stroke.h"
 
+#include "../Convert.h"
+#include "../Interface0D/SVertex.h"
+#include "../../stroke/StrokeIterators.h"
 
-PyObject *Stroke_getId(PyObject *self , PyObject *args) {
-}
+#ifdef __cplusplus
+extern "C" {
+#endif
 
+///////////////////////////////////////////////////////////////////////////////////////////
 
- PyObject *_wrap_new_Stroke__SWIG_0(PyObject *self , PyObject *args) {
-}
+/*---------------  Python API function prototypes for Stroke instance  -----------*/
+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_RemoveVertex( BPy_Stroke *self, PyObject *args );
+static PyObject * Stroke_getMediumType( BPy_Stroke *self );
+static PyObject * Stroke_getTextureId( BPy_Stroke *self );
+static PyObject * Stroke_hasTips( BPy_Stroke *self );
+static PyObject * Stroke_setId( BPy_Stroke *self , PyObject *args);
+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_strokeVerticesSize( BPy_Stroke *self );
+static PyObject * Stroke_getStrokeVertices( BPy_Stroke *self );
 
- PyObject *_wrap_new_Stroke__SWIG_1(PyObject *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."},
+	{"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."},
+	{"setId", ( PyCFunction ) Stroke_setId, METH_VARARGS, "(Id id) Sets the Id of the Stroke."},
+	{"setLength", ( PyCFunction ) Stroke_setLength, METH_VARARGS, "(float l) Sets the 2D length of the Stroke."},
+	{"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."},
+	{"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."},
+	{NULL, NULL, 0, NULL}
+};
 
+/*-----------------------BPy_Stroke type definition ------------------------------*/
 
- PyObject *_wrap_new_Stroke(PyObject *self, PyObject *args) {
-}
+PyTypeObject Stroke_Type = {
+	PyObject_HEAD_INIT( NULL ) 
+	0,							/* ob_size */
+	"Stroke",				/* tp_name */
+	sizeof( BPy_Stroke ),	/* tp_basicsize */
+	0,							/* tp_itemsize */
+	
+	/* methods */
+	NULL,	/* tp_dealloc */
+	NULL,                       				/* printfunc tp_print; */
+	NULL,                       				/* getattrfunc tp_getattr; */
+	NULL,                       				/* setattrfunc tp_setattr; */
+	NULL,										/* tp_compare */
+	NULL,					/* tp_repr */
 
+	/* Method suites for standard classes */
 
- PyObject *_wrap_delete_Stroke(PyObject *self , PyObject *args) {
-}
+	NULL,                       /* PyNumberMethods *tp_as_number; */
+	NULL,                       /* PySequenceMethods *tp_as_sequence; */
+	NULL,                       /* PyMappingMethods *tp_as_mapping; */
 
+	/* More standard operations (here for binary compatibility) */
 
-PyObject *Stroke_ComputeSampling(PyObject *self , PyObject *args) {
-}
+	NULL,						/* hashfunc tp_hash; */
+	NULL,                       /* ternaryfunc tp_call; */
+	NULL,                       /* reprfunc tp_str; */

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list