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-23 09:54:34 +0400
committerMaxime Curioni <maxime.curioni@gmail.com>2008-07-23 09:54:34 +0400
commit0c3f7c2b7e0c9d8ad5945029170fc8ed1f0c1eda (patch)
treea4495ec13a99b806e06b92f9ddfb0f9c15165177
parent48732bf2ab5284316f01babb71aa3e2289f2c0dd (diff)
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.
-rw-r--r--source/blender/freestyle/SConscript3
-rw-r--r--source/blender/freestyle/intern/python/Convert.cpp20
-rw-r--r--source/blender/freestyle/intern/python/Convert.h4
-rw-r--r--source/blender/freestyle/intern/python/Freestyle.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Interface1D.cpp14
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/Stroke.cpp414
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/Stroke.h31
-rw-r--r--source/blender/freestyle/intern/python/MediumType.cpp119
-rw-r--r--source/blender/freestyle/intern/python/MediumType.h33
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader.cpp164
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader.h41
11 files changed, 674 insertions, 171 deletions
diff --git a/source/blender/freestyle/SConscript b/source/blender/freestyle/SConscript
index 65cafb306e5..12b649c362d 100644
--- a/source/blender/freestyle/SConscript
+++ b/source/blender/freestyle/SConscript
@@ -73,8 +73,11 @@ python_sources = [
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',
diff --git a/source/blender/freestyle/intern/python/Convert.cpp b/source/blender/freestyle/intern/python/Convert.cpp
index 5183457a669..410afe99d63 100644
--- a/source/blender/freestyle/intern/python/Convert.cpp
+++ b/source/blender/freestyle/intern/python/Convert.cpp
@@ -82,6 +82,26 @@ PyObject * BPy_StrokeAttribute_from_StrokeAttribute( StrokeAttribute& sa ) {
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
diff --git a/source/blender/freestyle/intern/python/Convert.h b/source/blender/freestyle/intern/python/Convert.h
index 43deae224e3..3caf8bf67f9 100644
--- a/source/blender/freestyle/intern/python/Convert.h
+++ b/source/blender/freestyle/intern/python/Convert.h
@@ -7,9 +7,11 @@ using namespace Geometry;
#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_FEdge_from_FEdge( FEdge& fe );
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 );
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Freestyle.cpp b/source/blender/freestyle/intern/python/Freestyle.cpp
index a5aada0c470..2f93f1f8a74 100644
--- a/source/blender/freestyle/intern/python/Freestyle.cpp
+++ b/source/blender/freestyle/intern/python/Freestyle.cpp
@@ -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 @@ PyObject *Freestyle_Init( void )
Interface1D_Init( module );
Nature_Init( module );
StrokeAttribute_Init( module );
+ StrokeShader_Init( module );
UnaryFunction0D_Init( module );
UnaryFunction1D_Init( module );
UnaryPredicate0D_Init( module );
diff --git a/source/blender/freestyle/intern/python/Interface1D.cpp b/source/blender/freestyle/intern/python/Interface1D.cpp
index 30dd5b349bd..f1a14b5d62f 100644
--- a/source/blender/freestyle/intern/python/Interface1D.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D.cpp
@@ -2,6 +2,8 @@
#include "Convert.h"
#include "Interface1D/FEdge.h"
+#include "Interface1D/Stroke.h"
+#include "MediumType.h"
#ifdef __cplusplus
extern "C" {
@@ -124,6 +126,8 @@ PyTypeObject Interface1D_Type = {
//-------------------MODULE INITIALIZATION--------------------------------
PyMODINIT_FUNC Interface1D_Init( PyObject *module )
{
+ PyObject *tmp;
+
if( module == NULL )
return;
@@ -136,6 +140,16 @@ PyMODINIT_FUNC Interface1D_Init( PyObject *module )
return;
Py_INCREF( &FEdge_Type );
PyModule_AddObject(module, "FEdge", (PyObject *)&FEdge_Type);
+
+ if( PyType_Ready( &Stroke_Type ) < 0 )
+ return;
+ Py_INCREF( &Stroke_Type );
+ PyModule_AddObject(module, "Stroke", (PyObject *)&Stroke_Type);
+
+ tmp = BPy_MediumType_from_MediumType( Stroke::DRY_MEDIUM ); PyDict_SetItemString( Stroke_Type.tp_dict, "DRY_MEDIUM", tmp); Py_DECREF(tmp);
+ tmp = BPy_MediumType_from_MediumType( Stroke::HUMID_MEDIUM ); PyDict_SetItemString( Stroke_Type.tp_dict, "HUMID_MEDIUM", tmp); Py_DECREF(tmp);
+ tmp = BPy_MediumType_from_MediumType( Stroke::OPAQUE_MEDIUM ); PyDict_SetItemString( Stroke_Type.tp_dict, "OPAQUE_MEDIUM", tmp); Py_DECREF(tmp);
+
}
diff --git a/source/blender/freestyle/intern/python/Interface1D/Stroke.cpp b/source/blender/freestyle/intern/python/Interface1D/Stroke.cpp
index fe5feb7068b..9951f21a0e1 100644
--- a/source/blender/freestyle/intern/python/Interface1D/Stroke.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/Stroke.cpp
@@ -1,236 +1,314 @@
-PyObject *Stroke_getExactTypeName(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_getId(PyObject *self , PyObject *args) {
-}
-
-
- PyObject *_wrap_new_Stroke__SWIG_0(PyObject *self , PyObject *args) {
-}
+#include "Stroke.h"
+
+#include "../Convert.h"
+#include "../Interface0D/SVertex.h"
+#include "../../stroke/StrokeIterators.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+/*--------------- 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 );
+
+/*----------------------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 ------------------------------*/
+
+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 */
+
+ NULL, /* PyNumberMethods *tp_as_number; */
+ NULL, /* PySequenceMethods *tp_as_sequence; */
+ NULL, /* PyMappingMethods *tp_as_mapping; */
+
+ /* More standard operations (here for binary compatibility) */
+
+ NULL, /* hashfunc tp_hash; */
+ NULL, /* ternaryfunc tp_call; */
+ NULL, /* reprfunc tp_str; */
+ NULL, /* getattrofunc tp_getattro; */
+ NULL, /* setattrofunc tp_setattro; */
+
+ /* Functions to access object as input/output buffer */
+ NULL, /* PyBufferProcs *tp_as_buffer; */
+
+ /*** Flags to define presence of optional/expanded features ***/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */
+
+ NULL, /* char *tp_doc; Documentation string */
+ /*** Assigned meaning in release 2.0 ***/
+ /* call function for all accessible objects */
+ NULL, /* traverseproc tp_traverse; */
+
+ /* delete references to contained objects */
+ NULL, /* inquiry tp_clear; */
+
+ /*** Assigned meaning in release 2.1 ***/
+ /*** rich comparisons ***/
+ NULL, /* richcmpfunc tp_richcompare; */
+
+ /*** weak reference enabler ***/
+ 0, /* long tp_weaklistoffset; */
+
+ /*** Added in release 2.2 ***/
+ /* Iterators */
+ NULL, /* getiterfunc tp_iter; */
+ NULL, /* iternextfunc tp_iternext; */
+
+ /*** Attribute descriptor and subclassing stuff ***/
+ BPy_Stroke_methods, /* struct PyMethodDef *tp_methods; */
+ NULL, /* struct PyMemberDef *tp_members; */
+ NULL, /* struct PyGetSetDef *tp_getset; */
+ &Interface1D_Type, /* struct _typeobject *tp_base; */
+ NULL, /* PyObject *tp_dict; */
+ NULL, /* descrgetfunc tp_descr_get; */
+ NULL, /* descrsetfunc tp_descr_set; */
+ 0, /* long tp_dictoffset; */
+ (initproc)Stroke___init__, /* initproc tp_init; */
+ NULL, /* allocfunc tp_alloc; */
+ NULL, /* newfunc tp_new; */
+
+ /* Low-level free-memory routine */
+ NULL, /* freefunc tp_free; */
+
+ /* For PyObject_IS_GC */
+ NULL, /* inquiry tp_is_gc; */
+ NULL, /* PyObject *tp_bases; */
+
+ /* method resolution order */
+ NULL, /* PyObject *tp_mro; */
+ NULL, /* PyObject *tp_cache; */
+ NULL, /* PyObject *tp_subclasses; */
+ NULL, /* PyObject *tp_weaklist; */
+ NULL
+};
+//-------------------MODULE INITIALIZATION--------------------------------
- PyObject *_wrap_new_Stroke__SWIG_1(PyObject *self , PyObject *args) {
-}
+//------------------------INSTANCE METHODS ----------------------------------
- PyObject *_wrap_new_Stroke(PyObject *self, PyObject *args) {
-}
+// Stroke ()
+// template<class InputVertexIterator> Stroke (InputVertexIterator iBegin, InputVertexIterator iEnd)
+int Stroke___init__(BPy_Stroke *self, PyObject *args, PyObject *kwds)
+{
+ PyObject *obj1 = 0, *obj2 = 0;
- PyObject *_wrap_delete_Stroke(PyObject *self , PyObject *args) {
-}
+ if (! PyArg_ParseTuple(args, "|OO", &obj1) )
+ return -1;
+ if( !obj1 && !obj2 ){
+ self->s = new Stroke();
-PyObject *Stroke_ComputeSampling(PyObject *self , PyObject *args) {
-}
+ // template<class InputVertexIterator> Stroke (InputVertexIterator iBegin, InputVertexIterator iEnd)
+ //
+ // pb: - need to be able to switch representation: InputVertexIterator <=> position
+ // - is it even used ? not even in SWIG version
+ } else {
+ return -1;
+ }
+ self->py_if1D.if1D = self->s;
-PyObject *Stroke_Resample__SWIG_0(PyObject *self , PyObject *args) {
+ return 0;
}
+PyObject * Stroke_ComputeSampling( BPy_Stroke *self, PyObject *args ) {
+ int i;
-PyObject *Stroke_Resample__SWIG_1(PyObject *self , PyObject *args) {
-}
-
+ if(!( PyArg_ParseTuple(args, "i", &i) )) {
+ cout << "ERROR: Stroke_ComputeSampling" << endl;
+ Py_RETURN_NONE;
+ }
-PyObject *Stroke_Resample(PyObject *self, PyObject *args) {
+ return PyFloat_FromDouble( self->s->ComputeSampling( i ) );
}
+PyObject * Stroke_Resample( BPy_Stroke *self, PyObject *args ) {
+ PyObject *obj;
-PyObject *Stroke_RemoveVertex(PyObject *self , PyObject *args) {
-}
-
+ if(!( PyArg_ParseTuple(args, "O", &obj) )) {
+ cout << "ERROR: Stroke_Resample" << endl;
+ Py_RETURN_NONE;
+ }
-PyObject *Stroke_InsertVertex(PyObject *self , PyObject *args) {
+ if( PyInt_Check(obj) )
+ self->s->Resample( (int) PyInt_AsLong(obj) );
+ else if( PyFloat_Check(obj) )
+ self->s->Resample( (float) PyFloat_AsDouble(obj) );
+
+ Py_RETURN_NONE;
}
-PyObject *Stroke_Render(PyObject *self , PyObject *args) {
-}
+PyObject * Stroke_RemoveVertex( BPy_Stroke *self, PyObject *args ) {
+ PyObject *py_sv;
+ if(!( PyArg_ParseTuple(args, "O", &py_sv) )) {
+ cout << "ERROR: Stroke_RemoveVertex" << endl;
+ Py_RETURN_NONE;
+ }
-PyObject *Stroke_RenderBasic(PyObject *self , PyObject *args) {
+ if( BPy_StrokeVertex_Check(py_sv) && ((BPy_StrokeVertex *) py_sv)->sv )
+ self->s->RemoveVertex( ((BPy_StrokeVertex *) py_sv)->sv );
+
+ Py_RETURN_NONE;
}
+// pb: 'iterator <=> list' correspondence
+// void InsertVertex (StrokeVertex *iVertex, StrokeInternal::StrokeVertexIterator next)
-PyObject *Stroke_getLength2D(PyObject *self , PyObject *args) {
+PyObject * Stroke_getMediumType( BPy_Stroke *self ) {
+ return BPy_MediumType_from_MediumType( self->s->getMediumType() );
}
-
-PyObject *Stroke_getMediumType(PyObject *self , PyObject *args) {
+PyObject * Stroke_getTextureId( BPy_Stroke *self ) {
+ return PyInt_FromLong( self->s->getTextureId() );
}
-
-PyObject *Stroke_getTextureId(PyObject *self , PyObject *args) {
+PyObject * Stroke_hasTips( BPy_Stroke *self ) {
+ return PyBool_from_bool( self->s->hasTips() );
}
-PyObject *Stroke_hasTips(PyObject *self , PyObject *args) {
-}
-
+PyObject *Stroke_setId( BPy_Stroke *self , PyObject *args) {
+ PyObject *py_id;
-PyObject *Stroke_vertices_size(PyObject *self , PyObject *args) {
-}
+ if(!( PyArg_ParseTuple(args, "O", &py_id) && BPy_Id_Check(py_id) )) {
+ cout << "ERROR: Stroke_setId" << endl;
+ Py_RETURN_NONE;
+ }
+ if( ((BPy_Id *) py_id)->id )
+ self->s->setId(*( ((BPy_Id *) py_id)->id ));
-PyObject *Stroke_viewedges_begin__SWIG_0(PyObject *self , PyObject *args) {
+ Py_RETURN_NONE;
}
+PyObject *Stroke_setLength( BPy_Stroke *self , PyObject *args) {
+ float f;
-PyObject *Stroke_viewedges_begin__SWIG_1(PyObject *self , PyObject *args) {
-}
+ if(!( PyArg_ParseTuple(args, "f", &f) )) {
+ cout << "ERROR: Stroke_setLength" << endl;
+ Py_RETURN_NONE;
+ }
+ self->s->setLength( f );
-PyObject *Stroke_viewedges_begin(PyObject *self, PyObject *args) {
+ Py_RETURN_NONE;
}
+PyObject *Stroke_setMediumType( BPy_Stroke *self , PyObject *args) {
+ PyObject *py_mt;
-PyObject *Stroke_viewedges_end__SWIG_0(PyObject *self , PyObject *args) {
-}
+ if(!( PyArg_ParseTuple(args, "O", &py_mt) && BPy_MediumType_Check(py_mt) )) {
+ cout << "ERROR: Stroke_setMediumType" << endl;
+ Py_RETURN_NONE;
+ }
+ self->s->setMediumType( static_cast<Stroke::MediumType>(PyInt_AsLong(py_mt)) );
-PyObject *Stroke_viewedges_end__SWIG_1(PyObject *self , PyObject *args) {
+ Py_RETURN_NONE;
}
+PyObject *Stroke_setTextureId( BPy_Stroke *self , PyObject *args) {
+ unsigned int i;
-PyObject *Stroke_viewedges_end(PyObject *self, PyObject *args) {
-}
+ if(!( PyArg_ParseTuple(args, "I", &i) )) {
+ cout << "ERROR: Stroke_setTextureId" << endl;
+ Py_RETURN_NONE;
+ }
+ self->s->setTextureId( i );
-PyObject *Stroke_viewedges_size(PyObject *self , PyObject *args) {
+ Py_RETURN_NONE;
}
+PyObject *Stroke_setTips( BPy_Stroke *self , PyObject *args) {
+ PyObject *py_b;
-PyObject *Stroke_getBeginningOrientation(PyObject *self , PyObject *args) {
-}
+ if(!( PyArg_ParseTuple(args, "O", &py_b) && PyBool_Check(py_b) )) {
+ cout << "ERROR: Stroke_setTips" << endl;
+ Py_RETURN_NONE;
+ }
+ self->s->setTips( py_b == Py_True );
-PyObject *Stroke_getBeginningOrientationX(PyObject *self , PyObject *args) {
+ Py_RETURN_NONE;
}
-PyObject *Stroke_getBeginningOrientationY(PyObject *self , PyObject *args) {
+PyObject * Stroke_strokeVerticesSize( BPy_Stroke *self ) {
+ return PyInt_FromLong( self->s->strokeVerticesSize() );
}
-PyObject *Stroke_getEndingOrientation(PyObject *self , PyObject *args) {
+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_getEndingOrientationX(PyObject *self , PyObject *args) {
-}
+///////////////////////////////////////////////////////////////////////////////////////////
-PyObject *Stroke_getEndingOrientationY(PyObject *self , PyObject *args) {
+#ifdef __cplusplus
}
-
-
-PyObject *Stroke_SetId(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_SetLength(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_SetMediumType(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_SetTextureId(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_SetTips(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_push_back(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_push_front(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_AddViewEdge(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_SetBeginningOrientation__SWIG_0(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_SetBeginningOrientation__SWIG_1(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_SetBeginningOrientation(PyObject *self, PyObject *args) {
-}
-
-
-PyObject *Stroke_SetEndingOrientation__SWIG_0(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_SetEndingOrientation__SWIG_1(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_SetEndingOrientation(PyObject *self, PyObject *args) {
-}
-
-
-PyObject *Stroke_strokeVerticesBegin__SWIG_0(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_strokeVerticesBegin__SWIG_1(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_strokeVerticesBegin(PyObject *self, PyObject *args) {
-}
-
-
-PyObject *Stroke_strokeVerticesEnd(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_strokeVerticesSize(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_verticesBegin(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_verticesEnd(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_pointsBegin__SWIG_0(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_pointsBegin__SWIG_1(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_pointsBegin(PyObject *self, PyObject *args) {
-}
-
-
-PyObject *Stroke_pointsEnd__SWIG_0(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_pointsEnd__SWIG_1(PyObject *self , PyObject *args) {
-}
-
-
-PyObject *Stroke_pointsEnd(PyObject *self, PyObject *args) {
-}
-
-
+#endif
diff --git a/source/blender/freestyle/intern/python/Interface1D/Stroke.h b/source/blender/freestyle/intern/python/Interface1D/Stroke.h
new file mode 100644
index 00000000000..fc4b426fd53
--- /dev/null
+++ b/source/blender/freestyle/intern/python/Interface1D/Stroke.h
@@ -0,0 +1,31 @@
+#ifndef FREESTYLE_PYTHON_STROKE_H
+#define FREESTYLE_PYTHON_STROKE_H
+
+#include "../Interface1D.h"
+#include "../../stroke/Stroke.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+#include <Python.h>
+
+extern PyTypeObject Stroke_Type;
+
+#define BPy_Stroke_Check(v) (( (PyObject *) v)->ob_type == &Stroke_Type)
+
+/*---------------------------Python BPy_Stroke structure definition----------*/
+typedef struct {
+ BPy_Interface1D py_if1D;
+ Stroke *s;
+} BPy_Stroke;
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREESTYLE_PYTHON_STROKE_H */
diff --git a/source/blender/freestyle/intern/python/MediumType.cpp b/source/blender/freestyle/intern/python/MediumType.cpp
new file mode 100644
index 00000000000..f0c5fcc58a4
--- /dev/null
+++ b/source/blender/freestyle/intern/python/MediumType.cpp
@@ -0,0 +1,119 @@
+#include "MediumType.h"
+
+#include "Convert.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+/*--------------- Python API function prototypes for MediumType instance -----------*/
+static int MediumType___init__(BPy_MediumType *self, PyObject *args, PyObject *kwds);
+
+/*----------------------MediumType instance definitions ----------------------------*/
+static PyMethodDef BPy_MediumType_methods[] = {
+ {NULL, NULL, 0, NULL}
+};
+
+/*-----------------------BPy_MediumType type definition ------------------------------*/
+
+PyTypeObject MediumType_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "MediumType", /* tp_name */
+ sizeof( BPy_MediumType ), /* 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 */
+
+ NULL, /* PyNumberMethods *tp_as_number; */
+ NULL, /* PySequenceMethods *tp_as_sequence; */
+ NULL, /* PyMappingMethods *tp_as_mapping; */
+
+ /* More standard operations (here for binary compatibility) */
+
+ NULL, /* hashfunc tp_hash; */
+ NULL, /* ternaryfunc tp_call; */
+ NULL, /* reprfunc tp_str; */
+ NULL, /* getattrofunc tp_getattro; */
+ NULL, /* setattrofunc tp_setattro; */
+
+ /* Functions to access object as input/output buffer */
+ NULL, /* PyBufferProcs *tp_as_buffer; */
+
+ /*** Flags to define presence of optional/expanded features ***/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */
+
+ NULL, /* char *tp_doc; Documentation string */
+ /*** Assigned meaning in release 2.0 ***/
+ /* call function for all accessible objects */
+ NULL, /* traverseproc tp_traverse; */
+
+ /* delete references to contained objects */
+ NULL, /* inquiry tp_clear; */
+
+ /*** Assigned meaning in release 2.1 ***/
+ /*** rich comparisons ***/
+ NULL, /* richcmpfunc tp_richcompare; */
+
+ /*** weak reference enabler ***/
+ 0, /* long tp_weaklistoffset; */
+
+ /*** Added in release 2.2 ***/
+ /* Iterators */
+ NULL, /* getiterfunc tp_iter; */
+ NULL, /* iternextfunc tp_iternext; */
+
+ /*** Attribute descriptor and subclassing stuff ***/
+ BPy_MediumType_methods, /* struct PyMethodDef *tp_methods; */
+ NULL, /* struct PyMemberDef *tp_members; */
+ NULL, /* struct PyGetSetDef *tp_getset; */
+ &PyInt_Type, /* struct _typeobject *tp_base; */
+ NULL, /* PyObject *tp_dict; */
+ NULL, /* descrgetfunc tp_descr_get; */
+ NULL, /* descrsetfunc tp_descr_set; */
+ 0, /* long tp_dictoffset; */
+ (initproc)MediumType___init__, /* initproc tp_init; */
+ NULL, /* allocfunc tp_alloc; */
+ PyType_GenericNew, /* newfunc tp_new; */
+
+ /* Low-level free-memory routine */
+ NULL, /* freefunc tp_free; */
+
+ /* For PyObject_IS_GC */
+ NULL, /* inquiry tp_is_gc; */
+ NULL, /* PyObject *tp_bases; */
+
+ /* method resolution order */
+ NULL, /* PyObject *tp_mro; */
+ NULL, /* PyObject *tp_cache; */
+ NULL, /* PyObject *tp_subclasses; */
+ NULL, /* PyObject *tp_weaklist; */
+ NULL
+};
+
+//-------------------MODULE INITIALIZATION--------------------------------
+
+int MediumType___init__(BPy_MediumType *self, PyObject *args, PyObject *kwds)
+{
+ if (PyInt_Type.tp_init((PyObject *)self, args, kwds) < 0)
+ return -1;
+
+ return 0;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/source/blender/freestyle/intern/python/MediumType.h b/source/blender/freestyle/intern/python/MediumType.h
new file mode 100644
index 00000000000..d56594e0f68
--- /dev/null
+++ b/source/blender/freestyle/intern/python/MediumType.h
@@ -0,0 +1,33 @@
+#ifndef FREESTYLE_PYTHON_MEDIUMTYPE_H
+#define FREESTYLE_PYTHON_MEDIUMTYPE_H
+
+#include "../stroke/Stroke.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+#include <Python.h>
+
+extern PyTypeObject MediumType_Type;
+
+#define BPy_MediumType_Check(v) (( (PyObject *) v)->ob_type == &MediumType_Type)
+
+/*---------------------------Python BPy_MediumType structure definition----------*/
+typedef struct {
+ PyIntObject i;
+} BPy_MediumType;
+
+/*---------------------------Python BPy_MediumType visible prototypes-----------*/
+
+PyMODINIT_FUNC MediumType_Init( PyObject *module );
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FREESTYLE_PYTHON_MEDIUMTYPE_H */
diff --git a/source/blender/freestyle/intern/python/StrokeShader.cpp b/source/blender/freestyle/intern/python/StrokeShader.cpp
index 268d1fabe36..029f8776c73 100644
--- a/source/blender/freestyle/intern/python/StrokeShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader.cpp
@@ -1,12 +1,170 @@
- PyObject *_wrap_StrokeShader_getName(PyObject *self , PyObject *args) {
+#include "StrokeShader.h"
+
+#include "Convert.h"
+#include "Interface1D/Stroke.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+/*--------------- Python API function prototypes for StrokeShader instance -----------*/
+static int StrokeShader___init__(BPy_StrokeShader *self, PyObject *args, PyObject *kwds);
+static void StrokeShader___dealloc__(BPy_StrokeShader *self);
+static PyObject * StrokeShader___repr__(BPy_StrokeShader *self);
+
+static PyObject * StrokeShader_getName( BPy_StrokeShader *self, PyObject *args);
+static PyObject * StrokeShader_shade( BPy_StrokeShader *self , PyObject *args);
+
+/*----------------------StrokeShader instance definitions ----------------------------*/
+static PyMethodDef BPy_StrokeShader_methods[] = {
+ {"getName", ( PyCFunction ) StrokeShader_getName, METH_NOARGS, "( )Returns the string of the name of the binary predicate."},
+ {"shade", ( PyCFunction ) StrokeShader_shade, METH_VARARGS, "(Stroke s )The shading method. This method must be overloaded by inherited classes. The shading method is designed to modify any Stroke's attribute such as Thickness, Color, Geometry, Texture, Blending mode... The basic way to achieve this operation consists in iterating over the StrokeVertices of the Stroke and to modify each one's StrokeAttribute."},
+ {NULL, NULL, 0, NULL}
+};
+
+/*-----------------------BPy_StrokeShader type definition ------------------------------*/
+
+PyTypeObject StrokeShader_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "StrokeShader", /* tp_name */
+ sizeof( BPy_StrokeShader ), /* tp_basicsize */
+ 0, /* tp_itemsize */
+
+ /* methods */
+ (destructor)StrokeShader___dealloc__, /* tp_dealloc */
+ NULL, /* printfunc tp_print; */
+ NULL, /* getattrfunc tp_getattr; */
+ NULL, /* setattrfunc tp_setattr; */
+ NULL, /* tp_compare */
+ (reprfunc)StrokeShader___repr__, /* tp_repr */
+
+ /* Method suites for standard classes */
+
+ NULL, /* PyNumberMethods *tp_as_number; */
+ NULL, /* PySequenceMethods *tp_as_sequence; */
+ NULL, /* PyMappingMethods *tp_as_mapping; */
+
+ /* More standard operations (here for binary compatibility) */
+
+ NULL, /* hashfunc tp_hash; */
+ NULL, /* ternaryfunc tp_call; */
+ NULL, /* reprfunc tp_str; */
+ NULL, /* getattrofunc tp_getattro; */
+ NULL, /* setattrofunc tp_setattro; */
+
+ /* Functions to access object as input/output buffer */
+ NULL, /* PyBufferProcs *tp_as_buffer; */
+
+ /*** Flags to define presence of optional/expanded features ***/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */
+
+ NULL, /* char *tp_doc; Documentation string */
+ /*** Assigned meaning in release 2.0 ***/
+ /* call function for all accessible objects */
+ NULL, /* traverseproc tp_traverse; */
+
+ /* delete references to contained objects */
+ NULL, /* inquiry tp_clear; */
+
+ /*** Assigned meaning in release 2.1 ***/
+ /*** rich comparisons ***/
+ NULL, /* richcmpfunc tp_richcompare; */
+
+ /*** weak reference enabler ***/
+ 0, /* long tp_weaklistoffset; */
+
+ /*** Added in release 2.2 ***/
+ /* Iterators */
+ NULL, /* getiterfunc tp_iter; */
+ NULL, /* iternextfunc tp_iternext; */
+
+ /*** Attribute descriptor and subclassing stuff ***/
+ BPy_StrokeShader_methods, /* struct PyMethodDef *tp_methods; */
+ NULL, /* struct PyMemberDef *tp_members; */
+ NULL, /* struct PyGetSetDef *tp_getset; */
+ NULL, /* struct _typeobject *tp_base; */
+ NULL, /* PyObject *tp_dict; */
+ NULL, /* descrgetfunc tp_descr_get; */
+ NULL, /* descrsetfunc tp_descr_set; */
+ 0, /* long tp_dictoffset; */
+ (initproc)StrokeShader___init__, /* initproc tp_init; */
+ NULL, /* allocfunc tp_alloc; */
+ PyType_GenericNew, /* newfunc tp_new; */
+
+ /* Low-level free-memory routine */
+ NULL, /* freefunc tp_free; */
+
+ /* For PyObject_IS_GC */
+ NULL, /* inquiry tp_is_gc; */
+ NULL, /* PyObject *tp_bases; */
+
+ /* method resolution order */
+ NULL, /* PyObject *tp_mro; */
+ NULL, /* PyObject *tp_cache; */
+ NULL, /* PyObject *tp_subclasses; */
+ NULL, /* PyObject *tp_weaklist; */
+ NULL
+};
+
+//-------------------MODULE INITIALIZATION--------------------------------
+PyMODINIT_FUNC StrokeShader_Init( PyObject *module )
+{
+ if( module == NULL )
+ return;
+
+ if( PyType_Ready( &StrokeShader_Type ) < 0 )
+ return;
+
+ Py_INCREF( &StrokeShader_Type );
+ PyModule_AddObject(module, "StrokeShader", (PyObject *)&StrokeShader_Type);
}
+//------------------------INSTANCE METHODS ----------------------------------
- PyObject *_wrap_StrokeShader_shade(PyObject *self , PyObject *args) {
+int StrokeShader___init__(BPy_StrokeShader *self, PyObject *args, PyObject *kwds)
+{
+ self->ss = new StrokeShader();
+ return 0;
+}
+
+void StrokeShader___dealloc__(BPy_StrokeShader* self)
+{
+ delete self->ss;
+ self->ob_type->tp_free((PyObject*)self);
}
- PyObject *_wrap_disown_StrokeShader(PyObject *self , PyObject *args) {
+PyObject * StrokeShader___repr__(BPy_StrokeShader* self)
+{
+ return PyString_FromFormat("type: %s - address: %p", self->ss->getName().c_str(), self->ss );
}
+PyObject * StrokeShader_getName( BPy_StrokeShader *self, PyObject *args)
+{
+ return PyString_FromString( self->ss->getName().c_str() );
+}
+
+PyObject *StrokeShader_shade( BPy_StrokeShader *self , PyObject *args) {
+ PyObject *py_s = 0;
+
+ if(!( PyArg_ParseTuple(args, "O", &py_s) && BPy_Stroke_Check(py_s) )) {
+ cout << "ERROR: StrokeShader_shade" << endl;
+ Py_RETURN_NONE;
+ }
+
+ self->ss->shade(*( ((BPy_Stroke *) py_s)->s ));
+
+ Py_RETURN_NONE;
+}
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/freestyle/intern/python/StrokeShader.h b/source/blender/freestyle/intern/python/StrokeShader.h
new file mode 100644
index 00000000000..091eaa50383
--- /dev/null
+++ b/source/blender/freestyle/intern/python/StrokeShader.h
@@ -0,0 +1,41 @@
+#ifndef FREESTYLE_PYTHON_STROKESHADER_H
+#define FREESTYLE_PYTHON_STROKESHADER_H
+
+
+#include "../system/FreestyleConfig.h"
+
+using namespace std;
+
+#include "../stroke/StrokeShader.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+#include <Python.h>
+
+extern PyTypeObject StrokeShader_Type;
+
+#define BPy_StrokeShader_Check(v) (( (PyObject *) v)->ob_type == &StrokeShader_Type)
+
+/*---------------------------Python BPy_StrokeShader structure definition----------*/
+typedef struct {
+ PyObject_HEAD
+ StrokeShader *ss;
+} BPy_StrokeShader;
+
+/*---------------------------Python BPy_StrokeShader visible prototypes-----------*/
+
+PyMODINIT_FUNC StrokeShader_Init( PyObject *module );
+
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* FREESTYLE_PYTHON_STROKESHADER_H */