soc-2008-mxcurioni: Made crucial corrections to stabilize the system. Most of the original styles are supported: stroke attributes are correctly taken into account, Python shaders are supported. Added SamplingShader.

This commit is contained in:
Maxime Curioni
2008-08-02 07:39:49 +00:00
parent 7565990db2
commit e385d69580
42 changed files with 758 additions and 145 deletions

View File

@@ -92,9 +92,9 @@ PyObject * BPy_Interface1D_from_Interface1D( Interface1D& if1D ) {
}
PyObject * BPy_SVertex_from_SVertex( SVertex& sv ) {
PyObject * BPy_SVertex_from_SVertex_ptr( SVertex *sv ) {
PyObject *py_sv = SVertex_Type.tp_new( &SVertex_Type, 0, 0 );
((BPy_SVertex *) py_sv)->sv = new SVertex( sv );
((BPy_SVertex *) py_sv)->sv = sv;
((BPy_SVertex *) py_sv)->py_if0D.if0D = ((BPy_SVertex *) py_sv)->sv;
return py_sv;
@@ -119,18 +119,17 @@ PyObject * BPy_Nature_from_Nature( unsigned short n ) {
return py_n;
}
PyObject * BPy_Stroke_from_Stroke( Stroke& s ) {
PyObject * BPy_Stroke_from_Stroke_ptr( Stroke* s ) {
PyObject *py_s = Stroke_Type.tp_new( &Stroke_Type, 0, 0 );
((BPy_Stroke *) py_s)->s = new Stroke( s );
((BPy_Stroke *) py_s)->s = s;
((BPy_Stroke *) py_s)->py_if1D.if1D = ((BPy_Stroke *) py_s)->s;
return py_s;
}
PyObject * BPy_StrokeAttribute_from_StrokeAttribute( StrokeAttribute& sa ) {
PyObject * BPy_StrokeAttribute_from_StrokeAttribute_ptr( StrokeAttribute *sa ) {
PyObject *py_sa = StrokeAttribute_Type.tp_new( &StrokeAttribute_Type, 0, 0 );
((BPy_StrokeAttribute *) py_sa)->sa = new StrokeAttribute( sa );
((BPy_StrokeAttribute *) py_sa)->sa = sa;
return py_sa;
}
@@ -145,9 +144,9 @@ PyObject * BPy_MediumType_from_MediumType( int n ) {
return py_mt;
}
PyObject * BPy_StrokeVertex_from_StrokeVertex( StrokeVertex& sv ) {
PyObject * BPy_StrokeVertex_from_StrokeVertex_ptr( 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)->sv = 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;
@@ -169,9 +168,9 @@ PyObject * BPy_BBox_from_BBox( BBox< Vec3r > &bb ) {
return py_bb;
}
PyObject * BPy_ViewEdge_from_ViewEdge( ViewEdge& ve ) {
PyObject * BPy_ViewEdge_from_ViewEdge_ptr( ViewEdge* ve ) {
PyObject *py_ve = ViewEdge_Type.tp_new( &ViewEdge_Type, 0, 0 );
((BPy_ViewEdge *) py_ve)->ve = new ViewEdge( ve );
((BPy_ViewEdge *) py_ve)->ve = ve;
((BPy_ViewEdge *) py_ve)->py_if1D.if1D = ((BPy_ViewEdge *) py_ve)->ve;
return py_ve;
@@ -219,7 +218,7 @@ PyObject * BPy_CurvePoint_from_CurvePoint( CurvePoint& cp ) {
PyObject * BPy_directedViewEdge_from_directedViewEdge( ViewVertex::directedViewEdge& dve ) {
PyObject *py_dve = PyList_New(2);
PyList_SetItem( py_dve, 0, BPy_ViewEdge_from_ViewEdge(*(dve.first)) );
PyList_SetItem( py_dve, 0, BPy_ViewEdge_from_ViewEdge_ptr(dve.first) );
PyList_SetItem( py_dve, 1, PyBool_from_bool(dve.second) );
return py_dve;
@@ -316,7 +315,7 @@ PyObject * BPy_ChainSilhouetteIterator_from_ChainSilhouetteIterator( ChainSilhou
//==============================
bool bool_from_PyBool( PyObject *b ) {
return b == Py_True;
return (b == Py_True || PyInt_AsLong(b) != 0);
}
IntegrationType IntegrationType_from_BPy_IntegrationType( PyObject* obj ) {

View File

@@ -82,12 +82,12 @@ PyObject * BPy_FrsMaterial_from_Material( Material& m );
PyObject * BPy_Nature_from_Nature( unsigned short n );
PyObject * BPy_MediumType_from_MediumType( int n );
PyObject * BPy_SShape_from_SShape( SShape& ss );
PyObject * BPy_Stroke_from_Stroke( Stroke& s );
PyObject * BPy_StrokeAttribute_from_StrokeAttribute( StrokeAttribute& sa );
PyObject * BPy_StrokeVertex_from_StrokeVertex( StrokeVertex& sv );
PyObject * BPy_SVertex_from_SVertex( SVertex& sv );
PyObject * BPy_Stroke_from_Stroke_ptr( Stroke* s );
PyObject * BPy_StrokeAttribute_from_StrokeAttribute_ptr( StrokeAttribute *sa );
PyObject * BPy_StrokeVertex_from_StrokeVertex_ptr( StrokeVertex *sv );
PyObject * BPy_SVertex_from_SVertex_ptr( SVertex *sv );
PyObject * BPy_ViewVertex_from_ViewVertex_ptr( ViewVertex *vv );
PyObject * BPy_ViewEdge_from_ViewEdge( ViewEdge& ve );
PyObject * BPy_ViewEdge_from_ViewEdge_ptr( ViewEdge *ve );
PyObject * BPy_ViewShape_from_ViewShape( ViewShape& vs );
PyObject * BPy_AdjacencyIterator_from_AdjacencyIterator( AdjacencyIterator& a_it );

View File

@@ -183,12 +183,14 @@ PyMODINIT_FUNC Interface0D_Init( PyObject *module )
int Interface0D___init__(BPy_Interface0D *self, PyObject *args, PyObject *kwds)
{
self->if0D = new Interface0D();
self->if0D->py_if0D = (PyObject *)self;
return 0;
}
void Interface0D___dealloc__(BPy_Interface0D* self)
{
delete self->if0D;
if( self->if0D->py_if0D )
delete self->if0D;
self->ob_type->tp_free((PyObject*)self);
}

View File

@@ -204,7 +204,8 @@ int Interface1D___init__(BPy_Interface1D *self, PyObject *args, PyObject *kwds)
void Interface1D___dealloc__(BPy_Interface1D* self)
{
delete self->if1D;
if( self->if1D->py_if1D )
delete self->if1D;
self->ob_type->tp_free((PyObject*)self);
}

View File

@@ -227,10 +227,6 @@ PyObject * Iterator_isEnd(BPy_Iterator* self) {
return PyBool_from_bool( self->it->isEnd() );
}
PyObject * Iterator_getObject(BPy_Iterator* self) {
return PyBool_from_bool( self->it->isEnd() );
}
///////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -24,28 +24,27 @@ static PyObject * Operators_sequentialSplit(BPy_Operators* self, PyObject *args)
static PyObject * Operators_recursiveSplit(BPy_Operators* self, PyObject *args);
static PyObject * Operators_sort(BPy_Operators* self, PyObject *args);
static PyObject * Operators_create(BPy_Operators* self, PyObject *args);
static PyObject * Operators_getViewEdgesSize( BPy_Operators* self);
static PyObject * Operators_getChainsSize( BPy_Operators* self);
static PyObject * Operators_getStrokesSize( BPy_Operators* self);
/*----------------------Operators instance definitions ----------------------------*/
static PyMethodDef BPy_Operators_methods[] = {
{"select", ( PyCFunction ) Operators_select, METH_VARARGS | METH_STATIC,
"select operator"},
{"bidirectionalChain", ( PyCFunction ) Operators_bidirectionalChain, METH_VARARGS | METH_STATIC,
"select operator"},
"bidirectionalChain operator"},
{"sequentialSplit", ( PyCFunction ) Operators_sequentialSplit, METH_VARARGS | METH_STATIC,
"select operator"},
"sequentialSplit operator"},
{"recursiveSplit", ( PyCFunction ) Operators_recursiveSplit, METH_VARARGS | METH_STATIC,
"select operator"},
"recursiveSplit operator"},
{"sort", ( PyCFunction ) Operators_sort, METH_VARARGS | METH_STATIC,
"select operator"},
"sort operator"},
{"create", ( PyCFunction ) Operators_create, METH_VARARGS | METH_STATIC,
"select operator"},
"create operator"},
{"getViewEdgesSize", ( PyCFunction ) Operators_getViewEdgesSize, METH_NOARGS | METH_STATIC, ""},
{"getChainsSize", ( PyCFunction ) Operators_getChainsSize, METH_NOARGS | METH_STATIC, ""},
{"getStrokesSize", ( PyCFunction ) Operators_getStrokesSize, METH_NOARGS | METH_STATIC, ""},
{NULL, NULL, 0, NULL}
};
@@ -322,6 +321,19 @@ PyObject * Operators_create(BPy_Operators* self, PyObject *args)
Py_RETURN_NONE;
}
PyObject * Operators_getViewEdgesSize( BPy_Operators* self) {
return PyInt_FromLong( Operators::getViewEdgesSize() );
}
PyObject * Operators_getChainsSize( BPy_Operators* self ) {
return PyInt_FromLong( Operators::getChainsSize() );
}
PyObject * Operators_getStrokesSize( BPy_Operators* self) {
return PyInt_FromLong( Operators::getStrokesSize() );
}
///////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus

View File

@@ -228,7 +228,7 @@ PyObject * SShape_getVertexList( BPy_SShape *self ) {
vector< SVertex * >::iterator it;
for( it = vertices.begin(); it != vertices.end(); it++ ) {
PyList_Append( py_vertices, BPy_SVertex_from_SVertex(*( *it )) );
PyList_Append( py_vertices, BPy_SVertex_from_SVertex_ptr(*it) );
}
return py_vertices;

View File

@@ -199,6 +199,7 @@ int StrokeAttribute___init__(BPy_StrokeAttribute *self, PyObject *args, PyObject
return -1;
}
self->sa->py_sa = (PyObject *) self;
return 0;
@@ -206,7 +207,8 @@ int StrokeAttribute___init__(BPy_StrokeAttribute *self, PyObject *args, PyObject
void StrokeAttribute___dealloc__(BPy_StrokeAttribute* self)
{
delete self->sa;
if( self->sa->py_sa )
delete self->sa;
self->ob_type->tp_free((PyObject*)self);
}
@@ -384,7 +386,7 @@ PyObject * StrokeAttribute_setThickness( BPy_StrokeAttribute *self, PyObject *ar
PyFloat_AsDouble( PyList_GetItem(obj1, 1) ) );
self->sa->setThickness( v );
} else if( obj1 && obj2 ){
self->sa->setThickness( PyFloat_AsDouble(obj1),

View File

@@ -17,6 +17,7 @@
#include "StrokeShader/BPy_IncreasingThicknessShader.h"
#include "StrokeShader/BPy_PolygonalizationShader.h"
#include "StrokeShader/BPy_SamplingShader.h"
#include "StrokeShader/BPy_SmoothingShader.h"
#include "StrokeShader/BPy_SpatialNoiseShader.h"
#include "StrokeShader/BPy_streamShader.h"
#include "StrokeShader/BPy_StrokeTextureShader.h"
@@ -212,6 +213,11 @@ PyMODINIT_FUNC StrokeShader_Init( PyObject *module )
Py_INCREF( &SamplingShader_Type );
PyModule_AddObject(module, "SamplingShader", (PyObject *)&SamplingShader_Type);
if( PyType_Ready( &SmoothingShader_Type ) < 0 )
return;
Py_INCREF( &SmoothingShader_Type );
PyModule_AddObject(module, "SmoothingShader", (PyObject *)&SmoothingShader_Type);
if( PyType_Ready( &SpatialNoiseShader_Type ) < 0 )
return;
Py_INCREF( &SpatialNoiseShader_Type );

View File

@@ -174,6 +174,8 @@ PyObject * UnaryPredicate0D___call__( BPy_UnaryPredicate0D *self, PyObject *args
if( if0D_it )
return PyBool_from_bool( self->up0D->operator()(*if0D_it) );
else
cerr << "ERROR: UnaryPredicate0D___call__ (no Interface0DIterator)" << endl;
Py_RETURN_NONE;
}

View File

@@ -216,6 +216,8 @@ PyObject * UnaryPredicate1D___call__( BPy_UnaryPredicate1D *self, PyObject *args
if( if1D )
return PyBool_from_bool( self->up1D->operator()(*if1D) );
else
cerr << "ERROR: UnaryPredicate1D___call__ (no Interface1D)" << endl;
Py_RETURN_NONE;
}

View File

@@ -157,7 +157,7 @@ PyObject * ViewMap_getClosestViewEdge( BPy_ViewMap *self , PyObject *args) {
ViewEdge *ve = const_cast<ViewEdge *>( self->vm->getClosestViewEdge(x,y) );
if( ve )
return BPy_ViewEdge_from_ViewEdge(*ve);
return BPy_ViewEdge_from_ViewEdge_ptr(ve);
Py_RETURN_NONE;
}

View File

@@ -198,7 +198,7 @@ PyObject * ViewShape_edges( BPy_ViewShape *self ) {
vector< ViewEdge * >::iterator it;
for( it = edges.begin(); it != edges.end(); it++ ) {
PyList_Append( py_edges, BPy_ViewEdge_from_ViewEdge(*( *it )) );
PyList_Append( py_edges, BPy_ViewEdge_from_ViewEdge_ptr(*it) );
}
return py_edges;

View File

@@ -13,6 +13,11 @@
#include "BPy_StrokeShader.h"
#include "Iterator/BPy_ChainingIterator.h"
#include "Iterator/BPy_Interface0DIterator.h"
#include "Interface0D/BPy_SVertex.h"
#include "Interface0D/BPy_ViewVertex.h"
#include "Interface0D/ViewVertex/BPy_NonTVertex.h"
#include "Interface0D/ViewVertex/BPy_TVertex.h"
#include "Interface1D/BPy_FEdge.h"
#include "Interface1D/BPy_Stroke.h"
#include "Interface1D/BPy_ViewEdge.h"
#include "BPy_ViewShape.h"
@@ -28,6 +33,15 @@
#include "UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h"
#include "UnaryFunction0D/BPy_UnaryFunction0DViewShape.h"
#include "UnaryFunction1D/BPy_UnaryFunction1DDouble.h"
#include "UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.h"
#include "UnaryFunction1D/BPy_UnaryFunction1DFloat.h"
#include "UnaryFunction1D/BPy_UnaryFunction1DUnsigned.h"
#include "UnaryFunction1D/BPy_UnaryFunction1DVec2f.h"
#include "UnaryFunction1D/BPy_UnaryFunction1DVec3f.h"
#include "UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h"
// BinaryPredicate0D: __call__
bool Director_BPy_BinaryPredicate0D___call__( PyObject *obj, Interface0D& i1, Interface0D& i2) {
PyObject *result = PyObject_CallMethod( obj, "__call__", "OO", BPy_Interface0D_from_Interface0D(i1), BPy_Interface0D_from_Interface0D(i2) );
@@ -62,7 +76,7 @@ bool Director_BPy_UnaryPredicate1D___call__( PyObject *obj, Interface1D& if1D) {
// StrokeShader: shade
void Director_BPy_StrokeShader_shade( PyObject *obj, Stroke& s) {
PyObject_CallMethod( obj, "shade", "O", BPy_Stroke_from_Stroke(s) );
PyObject_CallMethod( obj, "shade", "O", BPy_Stroke_from_Stroke_ptr(&s) );
}
// ChainingIterator: init, traverse
@@ -89,7 +103,6 @@ void Director_BPy_UnaryFunction0D___call__( void *uf0D, PyObject *obj, Interface
((UnaryFunction0D<Nature::EdgeNature> *) uf0D)->result = EdgeNature_from_BPy_Nature(result);
} else if ( BPy_UnaryFunction0DFloat_Check(obj) ) {
((UnaryFunction0D<float> *) uf0D)->result = PyFloat_AsDouble(result);
} else if ( BPy_UnaryFunction0DId_Check(obj) ) {
@@ -129,20 +142,45 @@ void Director_BPy_UnaryFunction0D___call__( void *uf0D, PyObject *obj, Interface
void Director_BPy_UnaryFunction1D___call__( void *uf1D, PyObject *obj, Interface1D& if1D) {
// BPy_UnaryFunction1DDouble
// BPy_UnaryFunction1DEdgeNature
// BPy_UnaryFunction1DFloat
// BPy_UnaryFunction1DUnsigned
// BPy_UnaryFunction1DVec2f
// BPy_UnaryFunction1DVec3f
// BPy_UnaryFunction1DVectorViewShape
// BPy_UnaryFunction1DVoid
PyObject *result = PyObject_CallMethod( obj, "__call__", "O", BPy_Interface1D_from_Interface1D(if1D) );
if( BPy_UnaryFunction1DDouble_Check(obj) ) {
((UnaryFunction1D<double> *) uf1D)->result = PyFloat_AsDouble(result);
} else if ( BPy_UnaryFunction1DEdgeNature_Check(obj) ) {
((UnaryFunction1D<Nature::EdgeNature> *) uf1D)->result = EdgeNature_from_BPy_Nature(result);
} else if ( BPy_UnaryFunction1DFloat_Check(obj) ) {
((UnaryFunction1D<float> *) uf1D)->result = PyFloat_AsDouble(result);
} else if ( BPy_UnaryFunction1DUnsigned_Check(obj) ) {
((UnaryFunction1D<unsigned> *) uf1D)->result = PyInt_AsLong(result);
} else if ( BPy_UnaryFunction1DVec2f_Check(obj) ) {
Vec2f *v = Vec2f_ptr_from_Vector( result );
((UnaryFunction1D<Vec2f> *) uf1D)->result = *v;
delete v;
} else if ( BPy_UnaryFunction1DVec3f_Check(obj) ) {
Vec3f *v = Vec3f_ptr_from_Vector( result );
((UnaryFunction1D<Vec3f> *) uf1D)->result = *v;
delete v;
} else if ( BPy_UnaryFunction1DVectorViewShape_Check(obj) ) {
vector<ViewShape*> vec;
for( int i = 1; i < PyList_Size(result); i++) {
ViewShape *b = ( (BPy_ViewShape *) PyList_GetItem(result, i) )->vs;
vec.push_back( b );
}
((UnaryFunction1D< vector<ViewShape*> > *) uf1D)->result = vec;
}
}
// BPy_Iterator: increment, decrement, isBegin, isEnd
// Iterator: increment, decrement, isBegin, isEnd
void Director_BPy_Iterator_increment( PyObject *obj ) {
PyObject_CallMethod( obj, "increment", "", 0 );
}
@@ -163,7 +201,106 @@ bool Director_BPy_Iterator_isEnd( PyObject *obj ) {
return bool_from_PyBool(result);
}
// BPy_Interface1D: verticesBegin, verticesEnd, pointsBegin, pointsEnd
// Interface0D: getX, getY, getZ, getPoint3D, getProjectedX, getProjectedY, getProjectedZ, getPoint2D, getFEdge, getId, getNature, castToSVertex, castToViewVertex, castToNonTVertex, castToTVertex
double Director_BPy_Interface0D_getX( PyObject *obj ) {
PyObject *result = PyObject_CallMethod( obj, "getX", "", 0 );
return PyFloat_AsDouble(result);
}
double Director_BPy_Interface0D_getY( PyObject *obj ) {
PyObject *result = PyObject_CallMethod( obj, "getY", "", 0 );
return PyFloat_AsDouble(result);
}
double Director_BPy_Interface0D_getZ( PyObject *obj ) {
PyObject *result = PyObject_CallMethod( obj, "getZ", "", 0 );
return PyFloat_AsDouble(result);
}
Geometry::Vec3f Director_BPy_Interface0D_getPoint3D( PyObject *obj ) {
PyObject *result = PyObject_CallMethod( obj, "getPoint3D", "", 0 );
Geometry::Vec3f *v_ref = Vec3f_ptr_from_Vector( result );
Geometry::Vec3f v(*v_ref);
delete v_ref;
return v;
}
double Director_BPy_Interface0D_getProjectedX( PyObject *obj ) {
PyObject *result = PyObject_CallMethod( obj, "getProjectedX", "", 0 );
return PyFloat_AsDouble(result);
}
double Director_BPy_Interface0D_getProjectedY( PyObject *obj ) {
PyObject *result = PyObject_CallMethod( obj, "getProjectedY", "", 0 );
return PyFloat_AsDouble(result);
}
double Director_BPy_Interface0D_getProjectedZ( PyObject *obj ) {
PyObject *result = PyObject_CallMethod( obj, "getProjectedZ", "", 0 );
return PyFloat_AsDouble(result);
}
Geometry::Vec2f Director_BPy_Interface0D_getPoint2D( PyObject *obj ) {
PyObject *result = PyObject_CallMethod( obj, "getPoint2D", "", 0 );
Geometry::Vec2f *v_ref = Vec2f_ptr_from_Vector( result );
Geometry::Vec2f v(*v_ref);
delete v_ref;
return v;
}
FEdge * Director_BPy_Interface0D_getFEdge( PyObject *obj ) {
PyObject *result = PyObject_CallMethod( obj, "getFEdge", "", 0 );
return ((BPy_FEdge *) result)->fe;
}
Id Director_BPy_Interface0D_getId( PyObject *obj ) {
PyObject *result = PyObject_CallMethod( obj, "getId", "", 0 );
return *( ((BPy_Id *) result)->id );
}
Nature::EdgeNature Director_BPy_Interface0D_getNature( PyObject *obj ) {
PyObject *result = PyObject_CallMethod( obj, "getNature", "", 0 );
return EdgeNature_from_BPy_Nature(result);
}
SVertex * Director_BPy_Interface0D_castToSVertex( PyObject *obj ) {
PyObject *result = PyObject_CallMethod( obj, "castToSVertex", "", 0 );
return ((BPy_SVertex *) result)->sv;
}
ViewVertex * Director_BPy_Interface0D_castToViewVertex( PyObject *obj ) {
PyObject *result = PyObject_CallMethod( obj, "castToViewVertex", "", 0 );
return ((BPy_ViewVertex *) result)->vv;
}
NonTVertex * Director_BPy_Interface0D_castToNonTVertex( PyObject *obj ) {
PyObject *result = PyObject_CallMethod( obj, "castToNonTVertex", "", 0 );
return ((BPy_NonTVertex *) result)->ntv;
}
TVertex * Director_BPy_Interface0D_castToTVertex( PyObject *obj ) {
PyObject *result = PyObject_CallMethod( obj, "castToTVertex", "", 0 );
return ((BPy_TVertex *) result)->tv;
}
// Interface1D: verticesBegin, verticesEnd, pointsBegin, pointsEnd
Interface0DIterator Director_BPy_Interface1D_verticesBegin( PyObject *obj ){
PyObject *result = PyObject_CallMethod( obj, "verticesBegin", "", 0 );
@@ -188,3 +325,20 @@ Interface0DIterator Director_BPy_Interface1D_pointsEnd( PyObject *obj ){
return *( ((BPy_Interface0DIterator *) result)->if0D_it );
}
double Director_BPy_Interface1D_getLength2D( PyObject *obj ) {
PyObject *result = PyObject_CallMethod( obj, "getLength2D", "", 0 );
return PyFloat_AsDouble(result);
}
Id Director_BPy_Interface1D_getId( PyObject *obj ) {
PyObject *result = PyObject_CallMethod( obj, "getId", "", 0 );
return *( ((BPy_Id *) result)->id );
}
Nature::EdgeNature Director_BPy_Interface1D_getNature( PyObject *obj ) {
PyObject *result = PyObject_CallMethod( obj, "getNature", "", 0 );
return EdgeNature_from_BPy_Nature( result );
}

View File

@@ -1,12 +1,22 @@
#ifndef FREESTYLE_PYTHON_DIRECTOR
# define FREESTYLE_PYTHON_DIRECTOR
#include "../geometry/Geom.h"
#include "../winged_edge/Nature.h"
class AdjacencyIterator;
class FEdge;
class Id;
class Interface0D;
class Interface1D;
class Interface0DIterator;
class NonTVertex;
class Stroke;
class AdjacencyIterator;
class SVertex;
class TVertex;
class ViewEdge;
class ViewVertex;
#ifdef __cplusplus
extern "C" {
@@ -24,6 +34,36 @@ bool Director_BPy_BinaryPredicate0D___call__( PyObject *obj, Interface0D& i1, In
// BinaryPredicate1D: __call__
bool Director_BPy_BinaryPredicate1D___call__( PyObject *obj, Interface1D& i1, Interface1D& i2);
// Interface0D: getX, getY, getZ, getPoint3D, getProjectedX, getProjectedY, getProjectedZ, getPoint2D, getFEdge, getId, getNature, castToSVertex, castToViewVertex, castToNonTVertex, castToTVertex
double Director_BPy_Interface0D_getX( PyObject *obj );
double Director_BPy_Interface0D_getY( PyObject *obj );
double Director_BPy_Interface0D_getZ( PyObject *obj );
Geometry::Vec3f Director_BPy_Interface0D_getPoint3D( PyObject *obj );
double Director_BPy_Interface0D_getProjectedX( PyObject *obj );
double Director_BPy_Interface0D_getProjectedY( PyObject *obj );
double Director_BPy_Interface0D_getProjectedZ( PyObject *obj );
Geometry::Vec2f Director_BPy_Interface0D_getPoint2D( PyObject *obj );
FEdge * Director_BPy_Interface0D_getFEdge( PyObject *obj );
Id Director_BPy_Interface0D_getId( PyObject *obj );
Nature::EdgeNature Director_BPy_Interface0D_getNature( PyObject *obj );
SVertex * Director_BPy_Interface0D_castToSVertex( PyObject *obj );
ViewVertex * Director_BPy_Interface0D_castToViewVertex( PyObject *obj );
NonTVertex * Director_BPy_Interface0D_castToNonTVertex( PyObject *obj );
TVertex * Director_BPy_Interface0D_castToTVertex( PyObject *obj );
// Interface1D: verticesBegin, verticesEnd, pointsBegin, pointsEnd, getLength2D, getId, getNature
Interface0DIterator Director_BPy_Interface1D_verticesBegin( PyObject *obj );
Interface0DIterator Director_BPy_Interface1D_verticesEnd( PyObject *obj );
Interface0DIterator Director_BPy_Interface1D_pointsBegin( PyObject *obj );
Interface0DIterator Director_BPy_Interface1D_pointsEnd( PyObject *obj );
double Director_BPy_Interface1D_getLength2D( PyObject *obj );
Id Director_BPy_Interface1D_getId( PyObject *obj );
Nature::EdgeNature Director_BPy_Interface1D_getNature( PyObject *obj );
// UnaryFunction{0D,1D}: __call__
void Director_BPy_UnaryFunction0D___call__( void *uf0D, PyObject *obj, Interface0DIterator& if0D_it);
void Director_BPy_UnaryFunction1D___call__( void *uf1D, PyObject *obj, Interface1D& if1D);
// UnaryPredicate0D: __call__
bool Director_BPy_UnaryPredicate0D___call__( PyObject *obj, Interface0DIterator& if0D_it);
@@ -33,25 +73,17 @@ bool Director_BPy_UnaryPredicate1D___call__( PyObject *obj, Interface1D& if1D);
// StrokeShader: shade
void Director_BPy_StrokeShader_shade( PyObject *obj, Stroke& s);
// ChainingIterator: init, traverse
void Director_BPy_ChainingIterator_init( PyObject *obj );
ViewEdge * Director_BPy_ChainingIterator_traverse( PyObject *obj, AdjacencyIterator& a_it );
// BPy_UnaryFunction{0D,1D}: __call__
void Director_BPy_UnaryFunction0D___call__( void *uf0D, PyObject *obj, Interface0DIterator& if0D_it);
void Director_BPy_UnaryFunction1D___call__( void *uf1D, PyObject *obj, Interface1D& if1D);
// BPy_Iterator: increment, decrement, isBegin, isEnd
// Iterator: increment, decrement, isBegin, isEnd
void Director_BPy_Iterator_increment( PyObject *obj );
void Director_BPy_Iterator_decrement( PyObject *obj );
bool Director_BPy_Iterator_isBegin( PyObject *obj );
bool Director_BPy_Iterator_isEnd( PyObject *obj );
// BPy_Interface1D: verticesBegin, verticesEnd, pointsBegin, pointsEnd
Interface0DIterator Director_BPy_Interface1D_verticesBegin( PyObject *obj );
Interface0DIterator Director_BPy_Interface1D_verticesEnd( PyObject *obj );
Interface0DIterator Director_BPy_Interface1D_pointsBegin( PyObject *obj );
Interface0DIterator Director_BPy_Interface1D_pointsEnd( PyObject *obj );
// ChainingIterator: init, traverse
void Director_BPy_ChainingIterator_init( PyObject *obj );
ViewEdge * Director_BPy_ChainingIterator_traverse( PyObject *obj, AdjacencyIterator& a_it );

View File

@@ -167,14 +167,14 @@ PyObject * CurvePoint___copy__( BPy_CurvePoint *self ) {
PyObject * CurvePoint_A( BPy_CurvePoint *self ) {
if( SVertex *A = self->cp->A() )
return BPy_SVertex_from_SVertex( *A );
return BPy_SVertex_from_SVertex_ptr( A );
Py_RETURN_NONE;
}
PyObject * CurvePoint_B( BPy_CurvePoint *self ) {
if( SVertex *B = self->cp->B() )
return BPy_SVertex_from_SVertex( *B );
return BPy_SVertex_from_SVertex_ptr( B );
Py_RETURN_NONE;
}

View File

@@ -183,8 +183,7 @@ PyObject * StrokeVertex_getPoint( BPy_StrokeVertex *self ) {
}
PyObject * StrokeVertex_attribute( BPy_StrokeVertex *self ) {
StrokeAttribute sa( self->sv->attribute() );
return BPy_StrokeAttribute_from_StrokeAttribute( sa );
return BPy_StrokeAttribute_from_StrokeAttribute_ptr( &(self->sv->attribute()) );
}
PyObject * StrokeVertex_curvilinearAbscissa( BPy_StrokeVertex *self ) {

View File

@@ -165,7 +165,7 @@ PyObject * NonTVertex_castToNonTVertex( BPy_NonTVertex *self ) {
PyObject * NonTVertex_svertex( BPy_NonTVertex *self ) {
if( self->ntv->svertex() ){
return BPy_SVertex_from_SVertex(*( self->ntv->svertex() ));
return BPy_SVertex_from_SVertex_ptr( self->ntv->svertex() );
}
Py_RETURN_NONE;

View File

@@ -155,7 +155,7 @@ PyObject * TVertex_castToTVertex( BPy_TVertex *self ) {
PyObject * TVertex_frontSVertex( BPy_TVertex *self ) {
if( self->tv->frontSVertex() ){
return BPy_SVertex_from_SVertex(*( self->tv->frontSVertex() ));
return BPy_SVertex_from_SVertex_ptr( self->tv->frontSVertex() );
}
Py_RETURN_NONE;
@@ -163,7 +163,7 @@ PyObject * TVertex_frontSVertex( BPy_TVertex *self ) {
PyObject * TVertex_backSVertex( BPy_TVertex *self ) {
if( self->tv->backSVertex() ){
return BPy_SVertex_from_SVertex(*( self->tv->backSVertex() ));
return BPy_SVertex_from_SVertex_ptr( self->tv->backSVertex() );
}
Py_RETURN_NONE;
@@ -219,7 +219,7 @@ PyObject * TVertex_getSVertex( BPy_TVertex *self, PyObject *args) {
SVertex *sv = self->tv->getSVertex( ((BPy_FEdge *) py_fe)->fe );
if( sv ){
return BPy_SVertex_from_SVertex(*( sv ));
return BPy_SVertex_from_SVertex_ptr( sv );
}
Py_RETURN_NONE;
@@ -235,7 +235,7 @@ PyObject * TVertex_mate( BPy_TVertex *self, PyObject *args) {
ViewEdge *ve = self->tv->mate( ((BPy_ViewEdge *) py_ve)->ve );
if( ve ){
return BPy_ViewEdge_from_ViewEdge(*( ve ));
return BPy_ViewEdge_from_ViewEdge_ptr( ve );
}
Py_RETURN_NONE;

View File

@@ -185,7 +185,7 @@ PyObject * FEdge___copy__( BPy_FEdge *self ) {
PyObject * FEdge_vertexA( BPy_FEdge *self ) {
if( self->fe->vertexA() ){
return BPy_SVertex_from_SVertex( *(self->fe->vertexA()) );
return BPy_SVertex_from_SVertex_ptr( self->fe->vertexA() );
}
Py_RETURN_NONE;
@@ -193,7 +193,7 @@ PyObject * FEdge_vertexA( BPy_FEdge *self ) {
PyObject * FEdge_vertexB( BPy_FEdge *self ) {
if( self->fe->vertexB() ){
return BPy_SVertex_from_SVertex( *(self->fe->vertexB()) );
return BPy_SVertex_from_SVertex_ptr( self->fe->vertexB() );
}
Py_RETURN_NONE;
@@ -209,7 +209,7 @@ PyObject * FEdge___getitem__( BPy_FEdge *self, PyObject *args ) {
}
if( SVertex *v = self->fe->operator[](i) )
return BPy_SVertex_from_SVertex( *v );
return BPy_SVertex_from_SVertex_ptr( v );
Py_RETURN_NONE;
}
@@ -230,7 +230,7 @@ PyObject * FEdge_previousEdge( BPy_FEdge *self ) {
PyObject * FEdge_viewedge( BPy_FEdge *self ) {
if( ViewEdge *ve = self->fe->viewedge() )
return BPy_ViewEdge_from_ViewEdge( *ve );
return BPy_ViewEdge_from_ViewEdge_ptr( ve );
Py_RETURN_NONE;
}

View File

@@ -143,7 +143,7 @@ PyObject * AdjacencyIterator_getObject(BPy_AdjacencyIterator *self) {
ViewEdge *ve = self->a_it->operator*();
if( ve )
return BPy_ViewEdge_from_ViewEdge( *ve );
return BPy_ViewEdge_from_ViewEdge_ptr( ve );
Py_RETURN_NONE;
}

View File

@@ -180,7 +180,7 @@ PyObject * ChainingIterator_getObject( BPy_ChainingIterator *self) {
ViewEdge *ve = self->c_it->operator*();
if( ve )
return BPy_ViewEdge_from_ViewEdge( *ve );
return BPy_ViewEdge_from_ViewEdge_ptr( ve );
Py_RETURN_NONE;
}

View File

@@ -160,7 +160,12 @@ PyObject * SVertexIterator_u( BPy_SVertexIterator *self ) {
}
PyObject * SVertexIterator_getObject( BPy_SVertexIterator *self) {
return BPy_SVertex_from_SVertex( self->sv_it->operator*() );
SVertex *sv = self->sv_it->operator->();
if( sv )
return BPy_SVertex_from_SVertex_ptr( sv );
Py_RETURN_NONE;
}

View File

@@ -155,7 +155,11 @@ PyObject * StrokeVertexIterator_castToInterface0DIterator( BPy_StrokeVertexItera
}
PyObject * StrokeVertexIterator_getObject( BPy_StrokeVertexIterator *self) {
return BPy_StrokeVertex_from_StrokeVertex( self->sv_it->operator*() );
StrokeVertex *sv = self->sv_it->operator->();
if( sv )
return BPy_StrokeVertex_from_StrokeVertex_ptr( sv );
Py_RETURN_NONE;
}

View File

@@ -150,7 +150,7 @@ int ViewEdgeIterator___init__(BPy_ViewEdgeIterator *self, PyObject *args )
PyObject *ViewEdgeIterator_getCurrentEdge( BPy_ViewEdgeIterator *self ) {
if( self->ve_it->getCurrentEdge() )
return BPy_ViewEdge_from_ViewEdge(*( self->ve_it->getCurrentEdge() ));
return BPy_ViewEdge_from_ViewEdge_ptr( self->ve_it->getCurrentEdge() );
Py_RETURN_NONE;
}
@@ -171,7 +171,7 @@ PyObject *ViewEdgeIterator_setCurrentEdge( BPy_ViewEdgeIterator *self, PyObject
PyObject *ViewEdgeIterator_getBegin( BPy_ViewEdgeIterator *self ) {
if( self->ve_it->getBegin() )
return BPy_ViewEdge_from_ViewEdge(*( self->ve_it->getBegin() ));
return BPy_ViewEdge_from_ViewEdge_ptr( self->ve_it->getBegin() );
Py_RETURN_NONE;
}
@@ -216,7 +216,7 @@ PyObject * ViewEdgeIterator_getObject( BPy_ViewEdgeIterator *self) {
ViewEdge *ve = self->ve_it->operator*();
if( ve )
return BPy_ViewEdge_from_ViewEdge( *ve );
return BPy_ViewEdge_from_ViewEdge_ptr( ve );
Py_RETURN_NONE;
}

View File

@@ -0,0 +1,120 @@
#include "BPy_SmoothingShader.h"
#include "../../stroke/AdvancedStrokeShaders.h"
#ifdef __cplusplus
extern "C" {
#endif
///////////////////////////////////////////////////////////////////////////////////////////
/*--------------- Python API function prototypes for SmoothingShader instance -----------*/
static int SmoothingShader___init__( BPy_SmoothingShader* self, PyObject *args);
/*-----------------------BPy_SmoothingShader type definition ------------------------------*/
PyTypeObject SmoothingShader_Type = {
PyObject_HEAD_INIT( NULL )
0, /* ob_size */
"SmoothingShader", /* tp_name */
sizeof( BPy_SmoothingShader ), /* 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 ***/
NULL, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
NULL, /* struct PyGetSetDef *tp_getset; */
&StrokeShader_Type, /* struct _typeobject *tp_base; */
NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */
NULL, /* descrsetfunc tp_descr_set; */
0, /* long tp_dictoffset; */
(initproc)SmoothingShader___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
};
//------------------------INSTANCE METHODS ----------------------------------
int SmoothingShader___init__( BPy_SmoothingShader* self, PyObject *args)
{
int i1;
double d2, d3, d4, d5, d6, d7, d8;
if(!( PyArg_ParseTuple(args, "iddddddd", &i1, &d2, &d3, &d4, &d5, &d6, &d7, &d8) )) {
cout << "ERROR: SmoothingShader___init__" << endl;
return -1;
}
self->py_ss.ss = new SmoothingShader::SmoothingShader(i1, d2, d3, d4, d5, d6, d7, d8);
return 0;
}
///////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,31 @@
#ifndef FREESTYLE_PYTHONSMOOTHINGSHADER_H
#define FREESTYLE_PYTHONSMOOTHINGSHADER_H
#include "../BPy_StrokeShader.h"
#ifdef __cplusplus
extern "C" {
#endif
///////////////////////////////////////////////////////////////////////////////////////////
#include <Python.h>
extern PyTypeObject SmoothingShader_Type;
#define BPy_SmoothingShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &SmoothingShader_Type) )
/*---------------------------Python BPy_SmoothingShader structure definition----------*/
typedef struct {
BPy_StrokeShader py_ss;
} BPy_SmoothingShader;
///////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif
#endif /* FREESTYLE_PYTHONSMOOTHINGSHADER_H */

View File

@@ -107,7 +107,7 @@ int SpatialNoiseShader___init__( BPy_SpatialNoiseShader* self, PyObject *args)
if(!( PyArg_ParseTuple(args, "ffiOO", &f1, &f2, &i3, &obj4, &obj5)
&& PyList_Check(obj4) && PyBool_Check(obj5) )) {
&& PyBool_Check(obj4) && PyBool_Check(obj5) )) {
cout << "ERROR: SpatialNoiseShader___init__" << endl;
return -1;
}

View File

@@ -105,7 +105,7 @@ int StrokeTextureShader___init__( BPy_StrokeTextureShader* self, PyObject *args)
const char *s1;
PyObject *obj2 = 0, *obj3 = 0;
if(!( PyArg_ParseTuple(args, "s|00", &s1, &obj2, &obj3) )) {
if(!( PyArg_ParseTuple(args, "s|OO", &s1, &obj2, &obj3) )) {
cout << "ERROR: StrokeTextureShader___init__" << endl;
return -1;
}

View File

@@ -126,6 +126,11 @@ namespace StrokeShaders {
}
/*! Destructor.*/
virtual ~IncreasingThicknessShader() {}
virtual string getName() const {
return "IncreasingThicknessShader";
}
/*! The shading method. */
virtual void shade(Stroke& stroke) const;
@@ -165,6 +170,11 @@ namespace StrokeShaders {
}
/*! Destructor.*/
virtual ~ConstrainedIncreasingThicknessShader() {}
virtual string getName() const {
return "ConstrainedIncreasingThicknessShader";
}
/*! The shading method. */
virtual void shade(Stroke& stroke) const;
};
@@ -192,6 +202,10 @@ namespace StrokeShaders {
}
virtual ~LengthDependingThicknessShader() {}
virtual string getName() const {
return "LengthDependingThicknessShader";
}
virtual void shade(Stroke& stroke) const;
};
@@ -228,6 +242,11 @@ namespace StrokeShaders {
_aThickness = 0;
}
}
virtual string getName() const {
return "ThicknessVariationPatternShader";
}
/*! The shading method. */
virtual void shade(Stroke& stroke) const;
@@ -258,6 +277,11 @@ namespace StrokeShaders {
* The period of the noise signal
*/
ThicknessNoiseShader(float iAmplitude, float iPeriod);
virtual string getName() const {
return "ThicknessNoiseShader";
}
/*! The shading method. */
virtual void shade(Stroke& stroke) const;
};
@@ -347,6 +371,11 @@ namespace StrokeShaders {
_colorMax[2] = iBM;
_colorMax[3] = iAlphaM;
}
virtual string getName() const {
return "IncreasingColorShader";
}
/*! The shading method. */
virtual void shade(Stroke& stroke) const;
};
@@ -376,6 +405,11 @@ namespace StrokeShaders {
_aVariation = 0;
}
}
virtual string getName() const {
return "ColorVariationPatternShader";
}
/*! The shading method. */
virtual void shade(Stroke& stroke) const;
@@ -400,6 +434,10 @@ namespace StrokeShaders {
: StrokeShader()
{_coefficient=coeff;}
virtual string getName() const {
return "MaterialColorShader";
}
virtual void shade(Stroke& stroke) const;
};
@@ -416,6 +454,11 @@ namespace StrokeShaders {
_orientation=iOrientation;
_orientation.normalize();
}
virtual string getName() const {
return "CalligraphicColorShader";
}
virtual void shade(Stroke& stroke) const;
};
@@ -438,6 +481,11 @@ namespace StrokeShaders {
* The period of the noise signal
*/
ColorNoiseShader(float iAmplitude, float iPeriod);
virtual string getName() const {
return "ColorNoiseShader";
}
/*! The shading method. */
virtual void shade(Stroke& stroke) const;
};
@@ -477,6 +525,11 @@ namespace StrokeShaders {
{
_textureId = id;
}
virtual string getName() const {
return "TextureAssignerShader";
}
/*! The shading method */
virtual void shade(Stroke& stroke) const;
@@ -526,6 +579,11 @@ namespace StrokeShaders {
_mediumType = mediumType;
_tips = iTips;
}
virtual string getName() const {
return "StrokeTextureShader";
}
/*! The shading method */
virtual void shade(Stroke& stroke) const;
@@ -554,6 +612,11 @@ namespace StrokeShaders {
{
_amount = iAmount;
}
virtual string getName() const {
return "BackboneStretcherShader";
}
/*! The shading method */
virtual void shade(Stroke& stroke) const;
};
@@ -577,6 +640,11 @@ namespace StrokeShaders {
{
_sampling = sampling;
}
virtual string getName() const {
return "SamplingShader";
}
/*! The shading method */
virtual void shade(Stroke& stroke) const;
};
@@ -593,6 +661,10 @@ namespace StrokeShaders {
_amount = iAmount;
}
virtual string getName() const {
return "ExternalContourStretcherShader";
}
virtual void shade(Stroke& stroke) const;
};
@@ -604,6 +676,10 @@ namespace StrokeShaders {
: StrokeShader()
{}
virtual string getName() const {
return "BSplineShader";
}
virtual void shade(Stroke& stroke) const;
};
@@ -630,6 +706,10 @@ namespace StrokeShaders {
: StrokeShader()
{_error=error;}
virtual string getName() const {
return "BezierCurveShader";
}
/*! The shading method */
virtual void shade(Stroke& stroke) const;
};
@@ -661,6 +741,11 @@ namespace StrokeShaders {
_amount = iAmount;
_curvatureThreshold = iThreshold;
}
virtual string getName() const {
return "InflateShader";
}
/*! The shading method */
virtual void shade(Stroke& stroke) const;
};
@@ -690,6 +775,11 @@ namespace StrokeShaders {
*/
PolygonalizationShader(float iError) : StrokeShader()
{_error = iError;}
virtual string getName() const {
return "PolygonalizationShader";
}
/*! The shading method */
virtual void shade(Stroke& stroke) const;
};
@@ -720,6 +810,11 @@ namespace StrokeShaders {
*/
GuidingLinesShader(float iOffset) : StrokeShader()
{_offset = iOffset;}
virtual string getName() const {
return "GuidingLinesShader";
}
/*! The shading method */
virtual void shade(Stroke& stroke) const;
};
@@ -739,6 +834,10 @@ namespace StrokeShaders {
/*! Destructor. */
virtual ~TipRemoverShader () {}
/*! The shading method */
virtual string getName() const {
return "TipRemoverShader";
}
virtual void shade(Stroke &stroke) const;
protected:

View File

@@ -814,10 +814,14 @@ Stroke* createStroke(Interface1D& inter) {
inline void applyShading(Stroke& stroke, vector<StrokeShader*>& shaders) {
for (vector<StrokeShader*>::iterator it = shaders.begin();
it != shaders.end();
++it)
(*it)->shade(stroke);
for (vector<StrokeShader*>::iterator it = shaders.begin(); it != shaders.end(); ++it) {
StrokeShader *ss = *it;
string name( ss->py_ss ? PyString_AsString(PyObject_CallMethod(ss->py_ss, "getName", "")) : ss->getName() );
cout << "Shading: " << name << endl;
(*it)->shade(stroke);
}
}
@@ -832,7 +836,8 @@ void Operators::create(UnaryPredicate1D& pred, vector<StrokeShader*> shaders) {
++it) {
if (!pred(**it))
continue;
Stroke* stroke = createStroke(**it);
Stroke* stroke = createStroke(**it);
if (stroke) {
applyShading(*stroke, shaders);
canvas->RenderStroke(stroke);

View File

@@ -45,6 +45,9 @@ StrokeAttribute::StrokeAttribute()
_userAttributesVec2f = 0;
_userAttributesVec3f = 0;
_visible = true;
py_sa = 0;
}
StrokeAttribute::StrokeAttribute(const StrokeAttribute& iBrother)
{
@@ -66,6 +69,10 @@ StrokeAttribute::StrokeAttribute(const StrokeAttribute& iBrother)
_userAttributesVec3f = new Vec3fMap(*iBrother._userAttributesVec3f);
else
_userAttributesVec3f = 0;
py_sa = 0;
}
StrokeAttribute::StrokeAttribute( float iRColor, float iGColor, float iBColor,
float iAlpha,
@@ -85,6 +92,9 @@ StrokeAttribute::StrokeAttribute( float iRColor, float iGColor, float iBColor,
_userAttributesReal = 0;
_userAttributesVec2f = 0;
_userAttributesVec3f = 0;
py_sa = 0;
}
StrokeAttribute::StrokeAttribute(const StrokeAttribute& a1, const StrokeAttribute& a2, float t)
@@ -136,7 +146,9 @@ StrokeAttribute::StrokeAttribute(const StrokeAttribute& a1, const StrokeAttribut
_userAttributesVec3f = 0;
}
py_sa = 0;
}
StrokeAttribute::~StrokeAttribute()
{
if(_userAttributesReal){
@@ -404,11 +416,8 @@ Stroke::Stroke(const Stroke& iBrother)
_mediumType = iBrother._mediumType;
_textureId = iBrother._textureId;
_tips = iBrother._tips;
_rep = new StrokeRep(*(iBrother._rep));
if( iBrother._rep )
_rep = new StrokeRep(*(iBrother._rep));
else
_rep = new StrokeRep(this);
}
Stroke::~Stroke()

View File

@@ -52,6 +52,8 @@ class LIB_STROKE_EXPORT StrokeAttribute
{
public:
PyObject *py_sa;
/*! default constructor */
StrokeAttribute();
/*! Copy constructor */

View File

@@ -82,7 +82,7 @@ public:
* shader's name.
*/
virtual string getName() const {
return "StrokeShader";
return "StrokeShader";
}
/*! The shading method. This method must
* be overloaded by inherited classes.
@@ -119,7 +119,7 @@ public:
string name( py_ss ? PyString_AsString(PyObject_CallMethod(py_ss, "getName", "")) : getName() );
if( py_ss && PyObject_HasAttrString(py_ss, "shade") ) {
return Director_BPy_StrokeShader_shade(py_ss, ioStroke);
Director_BPy_StrokeShader_shade(py_ss, ioStroke);
} else {
cerr << "Warning: " << name << " method shade() not implemented" << endl;
}

View File

@@ -40,6 +40,7 @@ using namespace std;
#include "../system/Iterator.h" //soc
#include "../python/Director.h"
//
// Interface0D
@@ -56,6 +57,10 @@ class Interface0D
{
public:
PyObject *py_if0D;
/*! Default constructor */
Interface0D() { py_if0D = 0; }
virtual ~Interface0D() {}; //soc
/*! Returns the string "Interface0D".*/
@@ -67,94 +72,187 @@ public:
/*! Returns the 3D x coordinate of the point. */
virtual real getX() const {
cerr << "Warning: method getX() not implemented" << endl;
return 0;
string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
if( py_if0D && PyObject_HasAttrString(py_if0D, "getX") ) {
return Director_BPy_Interface0D_getX(py_if0D);
} else {
cerr << "Warning: " << name << " getX() not implemented" << endl;
return 0;
}
}
/*! Returns the 3D y coordinate of the point. */
virtual real getY() const {
cerr << "Warning: method getY() not implemented" << endl;
return 0;
string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
if( py_if0D && PyObject_HasAttrString(py_if0D, "getY") ) {
return Director_BPy_Interface0D_getY(py_if0D);
} else {
cerr << "Warning: " << name << " getY() not implemented" << endl;
return 0;
}
}
/*! Returns the 3D z coordinate of the point. */
virtual real getZ() const {
cerr << "Warning: method getZ() not implemented" << endl;
return 0;
string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
if( py_if0D && PyObject_HasAttrString(py_if0D, "getZ") ) {
return Director_BPy_Interface0D_getZ(py_if0D);
} else {
cerr << "Warning: " << name << " getZ() not implemented" << endl;
return 0;
}
}
/*! Returns the 3D point. */
virtual Geometry::Vec3f getPoint3D() const {
cerr << "Warning: method getPoint3D() not implemented" << endl;
return 0;
string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
if( py_if0D && PyObject_HasAttrString(py_if0D, "getPoint3D") ) {
return Director_BPy_Interface0D_getPoint3D(py_if0D);
} else {
cerr << "Warning: " << name << " getPoint3D() not implemented" << endl;
return 0;
}
}
/*! Returns the 2D x coordinate of the point. */
virtual real getProjectedX() const {
cerr << "Warning: method getProjectedX() not implemented" << endl;
return 0;
string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
if( py_if0D && PyObject_HasAttrString(py_if0D, "getProjectedX") ) {
return Director_BPy_Interface0D_getProjectedX(py_if0D);
} else {
cerr << "Warning: " << name << " getProjectedX() not implemented" << endl;
return 0;
}
}
/*! Returns the 2D y coordinate of the point. */
virtual real getProjectedY() const {
cerr << "Warning: method getProjectedY() not implemented" << endl;
return 0;
string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
if( py_if0D && PyObject_HasAttrString(py_if0D, "getProjectedY") ) {
return Director_BPy_Interface0D_getProjectedY(py_if0D);
} else {
cerr << "Warning: " << name << " getProjectedY() not implemented" << endl;
return 0;
}
}
/*! Returns the 2D z coordinate of the point. */
virtual real getProjectedZ() const {
cerr << "Warning: method getProjectedZ() not implemented" << endl;
return 0;
string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
if( py_if0D && PyObject_HasAttrString(py_if0D, "getProjectedZ") ) {
return Director_BPy_Interface0D_getProjectedZ(py_if0D);
} else {
cerr << "Warning: " << name << " getProjectedZ() not implemented" << endl;
return 0;
}
}
/*! Returns the 2D point. */
virtual Geometry::Vec2f getPoint2D() const {
cerr << "Warning: method getPoint2D() not implemented" << endl;
return 0;
}
string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
if( py_if0D && PyObject_HasAttrString(py_if0D, "getPoint2D") ) {
return Director_BPy_Interface0D_getPoint2D(py_if0D);
} else {
cerr << "Warning: " << name << " getPoint2D() not implemented" << endl;
return 0;
}
}
/*! Returns the FEdge that lies between this Interface0D and the
* Interface0D given as argument. */
virtual FEdge* getFEdge(Interface0D&) {
cerr << "Warning: method getFEdge() not implemented" << endl;
return 0;
string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
if( py_if0D && PyObject_HasAttrString(py_if0D, "getFEdge") ) {
return Director_BPy_Interface0D_getFEdge(py_if0D);
} else {
cerr << "Warning: " << name << " getFEdge() not implemented" << endl;
return 0;
}
}
/*! Returns the Id of the point. */
virtual Id getId() const {
cerr << "Warning: method getId() not implemented" << endl;
return Id(0, 0);
string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
if( py_if0D && PyObject_HasAttrString(py_if0D, "getId") ) {
return Director_BPy_Interface0D_getId(py_if0D);
} else {
cerr << "Warning: " << name << " getId() not implemented" << endl;
return 0;
}
}
/*! Returns the nature of the point. */
virtual Nature::VertexNature getNature() const {
cerr << "Warning: method getNature() not implemented" << endl;
return Nature::POINT;
}
string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
if( py_if0D && PyObject_HasAttrString(py_if0D, "getNature") ) {
return Director_BPy_Interface0D_getNature(py_if0D);
} else {
cerr << "Warning: " << name << " getNature() not implemented" << endl;
return Nature::POINT;
}
}
/*! Cast the Interface0D in SVertex if it can be. */
virtual SVertex * castToSVertex(){
cerr << "Warning: can't cast this Interface0D in SVertex" << endl;
return 0;
string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
if( py_if0D && PyObject_HasAttrString(py_if0D, "castToSVertex") ) {
return Director_BPy_Interface0D_castToSVertex(py_if0D);
} else {
cerr << "Warning: " << name << " castToSVertex() not implemented" << endl;
return 0;
}
}
/*! Cast the Interface0D in ViewVertex if it can be. */
virtual ViewVertex * castToViewVertex(){
cerr << "Warning: can't cast this Interface0D in ViewVertex" << endl;
return 0;
string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
if( py_if0D && PyObject_HasAttrString(py_if0D, "castToViewVertex") ) {
return Director_BPy_Interface0D_castToViewVertex(py_if0D);
} else {
cerr << "Warning: " << name << " castToViewVertex() not implemented" << endl;
return 0;
}
}
/*! Cast the Interface0D in NonTVertex if it can be. */
virtual NonTVertex * castToNonTVertex(){
cerr << "Warning: can't cast this Interface0D in NonTVertex" << endl;
return 0;
string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
if( py_if0D && PyObject_HasAttrString(py_if0D, "castToNonTVertex") ) {
return Director_BPy_Interface0D_castToNonTVertex(py_if0D);
} else {
cerr << "Warning: " << name << " castToNonTVertex() not implemented" << endl;
return 0;
}
}
/*! Cast the Interface0D in TVertex if it can be. */
virtual TVertex * castToTVertex(){
cerr << "Warning: can't cast this Interface0D in TVertex" << endl;
return 0;
string name( py_if0D ? PyString_AsString(PyObject_CallMethod(py_if0D, "getExactTypeName", "")) : getExactTypeName() );
if( py_if0D && PyObject_HasAttrString(py_if0D, "castToTVertex") ) {
return Director_BPy_Interface0D_castToTVertex(py_if0D);
} else {
cerr << "Warning: " << name << " castToTVertex() not implemented" << endl;
return 0;
}
}
};

View File

@@ -212,22 +212,41 @@ public:
/*! Returns the 2D length of the 1D element. */
virtual real getLength2D() const {
cerr << "Warning: method getLength2D() not implemented" << endl;
return 0;
string name( py_if1D ? PyString_AsString(PyObject_CallMethod(py_if1D, "getExactTypeName", "")) : getExactTypeName() );
if( py_if1D && PyObject_HasAttrString(py_if1D, "getLength2D") ) {
return Director_BPy_Interface1D_getLength2D(py_if1D);
} else {
cerr << "Warning: " << name << " getLength2D() not implemented" << endl;
return 0;
}
}
/*! Returns the Id of the 1D element .*/
virtual Id getId() const {
cerr << "Warning: method getId() not implemented" << endl;
return Id(0, 0);
}
string name( py_if1D ? PyString_AsString(PyObject_CallMethod(py_if1D, "getExactTypeName", "")) : getExactTypeName() );
if( py_if1D && PyObject_HasAttrString(py_if1D, "getId") ) {
return Director_BPy_Interface1D_getId(py_if1D);
} else {
cerr << "Warning: " << name << " getId() not implemented" << endl;
return Id(0, 0);
}
}
// FIXME: ce truc n'a rien a faire la...(c une requete complexe qui doit etre ds les Function1D)
/*! Returns the nature of the 1D element. */
virtual Nature::EdgeNature getNature() const {
cerr << "Warning: method getNature() not implemented" << endl;
return Nature::NO_FEATURE;
}
string name( py_if1D ? PyString_AsString(PyObject_CallMethod(py_if1D, "getExactTypeName", "")) : getExactTypeName() );
if( py_if1D && PyObject_HasAttrString(py_if1D, "getNature") ) {
return Director_BPy_Interface1D_getNature(py_if1D);
} else {
cerr << "Warning: " << name << " getNature() not implemented" << endl;
return Nature::NO_FEATURE;
}
}
/*! Returns the time stamp of the 1D element. Mainly used for selection. */
virtual unsigned getTimeStamp() const {

View File

@@ -37,6 +37,8 @@ class pyChainSilhouetteIterator(ChainingIterator):
ChainingIterator.__init__(self, stayInSelection, 1,None,1)
def getExactTypeName(self):
return "pyChainSilhouetteIterator"
def init(self):
pass
def traverse(self, iter):
winner = None
it = AdjacencyIterator(iter)
@@ -88,6 +90,8 @@ class pyChainSilhouetteGenericIterator(ChainingIterator):
ChainingIterator.__init__(self, stayInSelection, stayInUnvisited,None,1)
def getExactTypeName(self):
return "pyChainSilhouetteGenericIterator"
def init(self):
pass
def traverse(self, iter):
winner = None
it = AdjacencyIterator(iter)
@@ -384,6 +388,8 @@ class pyFillOcclusionsAbsoluteChainingIterator(ChainingIterator):
self._length = float(length)
def getExactTypeName(self):
return "pySmallFillOcclusionsChainingIterator"
def init(self):
pass
def traverse(self, iter):
winner = None
winnerOrientation = 0
@@ -665,6 +671,8 @@ class pyNoIdChainSilhouetteIterator(ChainingIterator):
ChainingIterator.__init__(self, stayInSelection, 1,None,1)
def getExactTypeName(self):
return "pyChainSilhouetteIterator"
def init(self):
pass
def traverse(self, iter):
winner = None
it = AdjacencyIterator(iter)

View File

@@ -1,3 +1,4 @@
from Blender.Mathutils import Vector
import Blender.Freestyle
class BBox(Blender.Freestyle.BBox):
@@ -174,6 +175,9 @@ class PolygonalizationShader(Blender.Freestyle.PolygonalizationShader):
class SamplingShader(Blender.Freestyle.SamplingShader):
pass
class SmoothingShader(Blender.Freestyle.SmoothingShader):
pass
class SpatialNoiseShader(Blender.Freestyle.SpatialNoiseShader):
pass

View File

@@ -32,7 +32,6 @@ from PredicatesB1D import *
from Functions0D import *
from shaders import *
Operators.select(QuantitativeInvisibilityUP1D(0))
Operators.bidirectionalChain(ChainSilhouetteIterator(),NotUP1D(QuantitativeInvisibilityUP1D(0)))
## Splits strokes at points of highest 2D curavture
@@ -48,11 +47,13 @@ shaders_list = [
pySamplingShader(10),
BezierCurveShader(30),
SamplingShader(50),
ConstantThicknessShader(10),
pyNonLinearVaryingThicknessShader(4,25, 0.6),
TextureAssignerShader(6),
ConstantColorShader(0.2, 0.2, 0.2,1.0),
TipRemoverShader(10)
]
## Use the causal density to avoid cluttering
Operators.create(pyDensityUP1D(8,0.4, IntegrationType.MEAN), shaders_list)

View File

@@ -34,7 +34,7 @@ Operators.select(upred)
Operators.bidirectionalChain(ChainSilhouetteIterator(), NotUP1D(upred))
shaders_list = [
SamplingShader(4),
SpatialNoiseShader(4, 150, 2, 1, 1),
SpatialNoiseShader(4, 150, 2, True, True),
IncreasingThicknessShader(2, 5),
BackboneStretcherShader(20),
IncreasingColorShader(1,0,0,1,0,1,0,1),

View File

@@ -55,11 +55,11 @@ upred = QuantitativeInvisibilityUP1D(0)
Operators.select(upred)
Operators.bidirectionalChain(ChainSilhouetteIterator(), NotUP1D(upred))
## starting and stopping predicates:
start = pyVertexNatureUP0D(Nature.NON_Nature.T_VERTEX)
start = pyVertexNatureUP0D(Nature.NON_T_VERTEX)
stop = pyBackTVertexUP0D()
Operators.sequentialSplit(start, stop, 10)
shaders_list = [
SpatialNoiseShader(7, 120, 2, 1, 1),
SpatialNoiseShader(7, 120, 2, True, True),
IncreasingThicknessShader(5, 8),
ConstantColorShader(0.2, 0.2, 0.2, 1),
TextureAssignerShader(4)

View File

@@ -28,6 +28,7 @@
from freestyle_init import *
from logical_operators import *
from PredicatesU0D import *
from PredicatesU1D import *
from Functions0D import *