soc-2008-mxcurioni: added (but did not test) ViewMap and Noise classes. Updated ViewShape class accordingly
This commit is contained in:
@@ -96,6 +96,7 @@ python_sources = [
|
||||
prefix + '/Iterator/BPy_ChainSilhouetteIterator.cpp',
|
||||
prefix + '/BPy_MediumType.cpp',
|
||||
prefix + '/BPy_Nature.cpp',
|
||||
prefix + '/BPy_Noise.cpp',
|
||||
prefix + '/BPy_SShape.cpp',
|
||||
prefix + '/BPy_StrokeAttribute.cpp',
|
||||
prefix + '/BPy_StrokeShader.cpp',
|
||||
@@ -103,6 +104,7 @@ python_sources = [
|
||||
prefix + '/BPy_UnaryFunction1D.cpp',
|
||||
prefix + '/BPy_UnaryPredicate0D.cpp',
|
||||
prefix + '/BPy_UnaryPredicate1D.cpp',
|
||||
prefix + '/BPy_ViewMap.cpp',
|
||||
prefix + '/BPy_ViewShape.cpp'
|
||||
]
|
||||
|
||||
|
||||
@@ -930,7 +930,7 @@ FEdge* Controller::SelectFEdge(real x, real y)
|
||||
if (!_ViewMap)
|
||||
return NULL;
|
||||
|
||||
FEdge *fedge = (FEdge*)_ViewMap->GetClosestFEdge(x,y);
|
||||
FEdge *fedge = (FEdge*)_ViewMap->getClosestFEdge(x,y);
|
||||
//ViewEdge *selection = fedge->viewedge();
|
||||
_pView->setSelectedFEdge(fedge);
|
||||
_Canvas->setSelectedFEdge(fedge);
|
||||
@@ -942,7 +942,7 @@ ViewEdge* Controller::SelectViewEdge(real x, real y)
|
||||
if (!_ViewMap)
|
||||
return NULL;
|
||||
|
||||
FEdge *fedge = (FEdge*)_ViewMap->GetClosestFEdge(x,y);
|
||||
FEdge *fedge = (FEdge*)_ViewMap->getClosestFEdge(x,y);
|
||||
ViewEdge *selection = fedge->viewedge();
|
||||
_pView->setSelectedFEdge(fedge);
|
||||
_Canvas->setSelectedFEdge(fedge);
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
#include "BPy_Id.h"
|
||||
#include "BPy_IntegrationType.h"
|
||||
#include "BPy_Interface0D.h"
|
||||
#include "BPy_Iterator.h"
|
||||
#include "Interface0D/BPy_CurvePoint.h"
|
||||
#include "BPy_Interface1D.h"
|
||||
#include "BPy_Iterator.h"
|
||||
#include "BPy_MediumType.h"
|
||||
#include "BPy_Nature.h"
|
||||
#include "BPy_Noise.h"
|
||||
#include "BPy_SShape.h"
|
||||
#include "BPy_StrokeAttribute.h"
|
||||
#include "BPy_StrokeShader.h"
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "BPy_UnaryFunction1D.h"
|
||||
#include "BPy_UnaryPredicate0D.h"
|
||||
#include "BPy_UnaryPredicate1D.h"
|
||||
#include "BPy_ViewMap.h"
|
||||
#include "BPy_ViewShape.h"
|
||||
|
||||
|
||||
@@ -151,6 +152,7 @@ PyObject *Freestyle_Init( void )
|
||||
Interface0D_Init( module );
|
||||
Interface1D_Init( module );
|
||||
Iterator_Init( module );
|
||||
Noise_Init( module );
|
||||
SShape_Init( module );
|
||||
StrokeAttribute_Init( module );
|
||||
StrokeShader_Init( module );
|
||||
@@ -158,6 +160,7 @@ PyObject *Freestyle_Init( void )
|
||||
UnaryFunction1D_Init( module );
|
||||
UnaryPredicate0D_Init( module );
|
||||
UnaryPredicate1D_Init( module );
|
||||
ViewMap_Init( module );
|
||||
ViewShape_Init( module );
|
||||
|
||||
return module;
|
||||
|
||||
@@ -1,48 +1,239 @@
|
||||
PyObject *_wrap_Noise_turbulence1__SWIG_0(PyObject *self , PyObject *args) {
|
||||
#include "BPy_Noise.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*--------------- Python API function prototypes for Noise instance -----------*/
|
||||
static int Noise___init__(BPy_Noise *self, PyObject *args, PyObject *kwds);
|
||||
static void Noise___dealloc__(BPy_Noise *self);
|
||||
static PyObject * Noise___repr__(BPy_Noise *self);
|
||||
|
||||
static PyObject * Noise_turbulence1( BPy_Noise *self, PyObject *args);
|
||||
static PyObject * Noise_turbulence2( BPy_Noise *self, PyObject *args);
|
||||
static PyObject * Noise_turbulence3( BPy_Noise *self, PyObject *args);
|
||||
static PyObject * Noise_smoothNoise1( BPy_Noise *self, PyObject *args);
|
||||
static PyObject * Noise_smoothNoise2( BPy_Noise *self, PyObject *args);
|
||||
static PyObject * Noise_smoothNoise3( BPy_Noise *self, PyObject *args);
|
||||
|
||||
/*----------------------Noise instance definitions ----------------------------*/
|
||||
static PyMethodDef BPy_Noise_methods[] = {
|
||||
{"turbulence1", ( PyCFunction ) Noise_turbulence1, METH_VARARGS, "(float arg, float freq, float amp, unsigned oct=4))Returns a noise value for a 1D element"},
|
||||
{"turbulence2", ( PyCFunction ) Noise_turbulence2, METH_VARARGS, "([x, y], float freq, float amp, unsigned oct=4)))Returns a noise value for a 2D element"},
|
||||
{"turbulence3", ( PyCFunction ) Noise_turbulence3, METH_VARARGS, "([x, y, z], float freq, float amp, unsigned oct=4)))Returns a noise value for a 3D element"},
|
||||
{"smoothNoise1", ( PyCFunction ) Noise_smoothNoise1, METH_VARARGS, "(float arg))Returns a smooth noise value for a 1D element "},
|
||||
{"smoothNoise2", ( PyCFunction ) Noise_smoothNoise2, METH_VARARGS, "([x, y]))Returns a smooth noise value for a 2D element "},
|
||||
{"smoothNoise3", ( PyCFunction ) Noise_smoothNoise3, METH_VARARGS, "([x, y, z))Returns a smooth noise value for a 3D element "},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
/*-----------------------BPy_Noise type definition ------------------------------*/
|
||||
|
||||
PyTypeObject Noise_Type = {
|
||||
PyObject_HEAD_INIT( NULL )
|
||||
0, /* ob_size */
|
||||
"Noise", /* tp_name */
|
||||
sizeof( BPy_Noise ), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
||||
/* methods */
|
||||
(destructor)Noise___dealloc__, /* tp_dealloc */
|
||||
NULL, /* printfunc tp_print; */
|
||||
NULL, /* getattrfunc tp_getattr; */
|
||||
NULL, /* setattrfunc tp_setattr; */
|
||||
NULL, /* tp_compare */
|
||||
(reprfunc)Noise___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_Noise_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)Noise___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 Noise_Init( PyObject *module )
|
||||
{
|
||||
if( module == NULL )
|
||||
return;
|
||||
|
||||
if( PyType_Ready( &Noise_Type ) < 0 )
|
||||
return;
|
||||
|
||||
Py_INCREF( &Noise_Type );
|
||||
PyModule_AddObject(module, "Noise", (PyObject *)&Noise_Type);
|
||||
}
|
||||
|
||||
//------------------------INSTANCE METHODS ----------------------------------
|
||||
|
||||
int Noise___init__(BPy_Noise *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
self->n = new Noise();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Noise___dealloc__(BPy_Noise* self)
|
||||
{
|
||||
delete self->n;
|
||||
self->ob_type->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_Noise_turbulence1__SWIG_1(PyObject *self , PyObject *args) {
|
||||
PyObject * Noise___repr__(BPy_Noise* self)
|
||||
{
|
||||
return PyString_FromFormat("Noise - address: %p", self->n );
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_Noise_turbulence1(PyObject *self, PyObject *args) {
|
||||
PyObject * Noise_turbulence1( BPy_Noise *self , PyObject *args) {
|
||||
float f1, f2, f3;
|
||||
unsigned int i;
|
||||
|
||||
if(!( PyArg_ParseTuple(args, "fff|I", &f1, &f2, &f3, &i) )) {
|
||||
cout << "ERROR: Noise_turbulence1" << endl;
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble( self->n->turbulence1(f1, f2, f3, i) );
|
||||
}
|
||||
|
||||
PyObject * Noise_turbulence2( BPy_Noise *self , PyObject *args) {
|
||||
PyObject *obj1;
|
||||
float f2, f3;
|
||||
unsigned int i;
|
||||
|
||||
if(!( PyArg_ParseTuple(args, "Off|I", &obj1, &f2, &f3, &i) && PyList_Check(obj1) && PyList_Size(obj1) > 1 )) {
|
||||
cout << "ERROR: Noise_turbulence2" << endl;
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
Vec2f v( PyFloat_AsDouble(PyList_GetItem(obj1, 0)), PyFloat_AsDouble(PyList_GetItem(obj1, 1)) );
|
||||
|
||||
return PyFloat_FromDouble( self->n->turbulence2(v, f2, f3, i) );
|
||||
}
|
||||
|
||||
PyObject * Noise_turbulence3( BPy_Noise *self , PyObject *args) {
|
||||
PyObject *obj1;
|
||||
float f2, f3;
|
||||
unsigned int i;
|
||||
|
||||
if(!( PyArg_ParseTuple(args, "Off|I", &obj1, &f2, &f3, &i) && PyList_Check(obj1) && PyList_Size(obj1) > 2 )) {
|
||||
cout << "ERROR: Noise_turbulence3" << endl;
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
Vec3f v( PyFloat_AsDouble(PyList_GetItem(obj1, 0)),
|
||||
PyFloat_AsDouble(PyList_GetItem(obj1, 1)),
|
||||
PyFloat_AsDouble(PyList_GetItem(obj1, 2)) );
|
||||
|
||||
return PyFloat_FromDouble( self->n->turbulence3(v, f2, f3, i) );
|
||||
}
|
||||
|
||||
PyObject * Noise_smoothNoise1( BPy_Noise *self , PyObject *args) {
|
||||
float f;
|
||||
|
||||
if(!( PyArg_ParseTuple(args, "f", &f) )) {
|
||||
cout << "ERROR: Noise_smoothNoise1" << endl;
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble( self->n->smoothNoise1(f) );
|
||||
}
|
||||
|
||||
PyObject * Noise_smoothNoise2( BPy_Noise *self , PyObject *args) {
|
||||
PyObject *obj;
|
||||
|
||||
if(!( PyArg_ParseTuple(args, "O", &obj) && PyList_Check(obj) && PyList_Size(obj) > 1 )) {
|
||||
cout << "ERROR: Noise_smoothNoise2" << endl;
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
Vec2f v( PyFloat_AsDouble(PyList_GetItem(obj, 0)), PyFloat_AsDouble(PyList_GetItem(obj, 1)) );
|
||||
|
||||
return PyFloat_FromDouble( self->n->smoothNoise2(v) );
|
||||
}
|
||||
|
||||
PyObject * Noise_smoothNoise3( BPy_Noise *self , PyObject *args) {
|
||||
PyObject *obj;
|
||||
|
||||
if(!( PyArg_ParseTuple(args, "O", &obj) && PyList_Check(obj) && PyList_Size(obj) > 2 )) {
|
||||
cout << "ERROR: Noise_smoothNoise3" << endl;
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
Vec3f v( PyFloat_AsDouble(PyList_GetItem(obj, 0)),
|
||||
PyFloat_AsDouble(PyList_GetItem(obj, 1)),
|
||||
PyFloat_AsDouble(PyList_GetItem(obj, 2)) );
|
||||
|
||||
return PyFloat_FromDouble( self->n->smoothNoise3(v) );
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_Noise_turbulence2__SWIG_0(PyObject *self , PyObject *args) {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_Noise_turbulence2__SWIG_1(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_Noise_turbulence2(PyObject *self, PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_Noise_turbulence3__SWIG_0(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_Noise_turbulence3__SWIG_1(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_Noise_turbulence3(PyObject *self, PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_Noise_smoothNoise1(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_Noise_smoothNoise2(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_Noise_smoothNoise3(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
36
source/blender/freestyle/intern/python/BPy_Noise.h
Normal file
36
source/blender/freestyle/intern/python/BPy_Noise.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef FREESTYLE_PYTHON_NOISE_H
|
||||
#define FREESTYLE_PYTHON_NOISE_H
|
||||
|
||||
#include "../geometry/Noise.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
extern PyTypeObject Noise_Type;
|
||||
|
||||
#define BPy_Noise_Check(v) (( (PyObject *) v)->ob_type == &Noise_Type)
|
||||
|
||||
/*---------------------------Python BPy_Noise structure definition----------*/
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
Noise *n;
|
||||
} BPy_Noise;
|
||||
|
||||
/*---------------------------Python BPy_Noise visible prototypes-----------*/
|
||||
|
||||
PyMODINIT_FUNC Noise_Init( PyObject *module );
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* FREESTYLE_PYTHON_NOISE_H */
|
||||
@@ -1,104 +1,203 @@
|
||||
PyObject *_wrap_ViewMap_userdata_set(PyObject *self , PyObject *args) {
|
||||
#include "BPy_ViewMap.h"
|
||||
|
||||
#include "BPy_Convert.h"
|
||||
#include "BPy_BBox.h"
|
||||
#include "Interface1D/BPy_FEdge.h"
|
||||
#include "Interface1D/BPy_ViewEdge.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*--------------- Python API function prototypes for ViewMap instance -----------*/
|
||||
static int ViewMap___init__(BPy_ViewMap *self, PyObject *args, PyObject *kwds);
|
||||
static void ViewMap___dealloc__(BPy_ViewMap *self);
|
||||
static PyObject * ViewMap___repr__(BPy_ViewMap* self);
|
||||
|
||||
static PyObject * ViewMap_getClosestViewEdge( BPy_ViewMap *self , PyObject *args);
|
||||
static PyObject * ViewMap_getClosestFEdge( BPy_ViewMap *self , PyObject *args);
|
||||
static PyObject * ViewMap_getScene3dBBox( BPy_ViewMap *self , PyObject *args);
|
||||
static PyObject * ViewMap_setScene3dBBox( BPy_ViewMap *self , PyObject *args);
|
||||
|
||||
/*---------------------- BPy_ViewShape instance definitions ----------------------------*/
|
||||
static PyMethodDef BPy_ViewMap_methods[] = {
|
||||
{"getClosestViewEdge", ( PyCFunction ) ViewMap_getClosestViewEdge, METH_VARARGS, "(double x, double y) Gets the viewedge the nearest to the 2D position specified as argument "},
|
||||
{"getClosestFEdge", ( PyCFunction ) ViewMap_getClosestFEdge, METH_VARARGS, "(double x, double y) Gets the Fedge the nearest to the 2D position specified as argument "},
|
||||
{"getScene3dBBox", ( PyCFunction ) ViewMap_getScene3dBBox, METH_NOARGS, "() Returns the scene 3D bounding box. "},
|
||||
{"setScene3dBBox", ( PyCFunction ) ViewMap_setScene3dBBox, METH_VARARGS, "(BBox bb) Sets the scene 3D bounding box."},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
/*-----------------------BPy_ViewMap type definition ------------------------------*/
|
||||
|
||||
PyTypeObject ViewMap_Type = {
|
||||
PyObject_HEAD_INIT( NULL )
|
||||
0, /* ob_size */
|
||||
"ViewMap", /* tp_name */
|
||||
sizeof( BPy_ViewMap ), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
||||
/* methods */
|
||||
(destructor)ViewMap___dealloc__, /* tp_dealloc */
|
||||
NULL, /* printfunc tp_print; */
|
||||
NULL, /* getattrfunc tp_getattr; */
|
||||
NULL, /* setattrfunc tp_setattr; */
|
||||
NULL, /* tp_compare */
|
||||
(reprfunc)ViewMap___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_ViewMap_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)ViewMap___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 ViewMap_Init( PyObject *module )
|
||||
{
|
||||
if( module == NULL )
|
||||
return;
|
||||
|
||||
if( PyType_Ready( &ViewMap_Type ) < 0 )
|
||||
return;
|
||||
|
||||
Py_INCREF( &ViewMap_Type );
|
||||
PyModule_AddObject(module, "ViewMap", (PyObject *)&ViewMap_Type);
|
||||
}
|
||||
|
||||
//------------------------INSTANCE METHODS ----------------------------------
|
||||
|
||||
int ViewMap___init__(BPy_ViewMap *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
self->vm = new ViewMap();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ViewMap___dealloc__(BPy_ViewMap *self)
|
||||
{
|
||||
delete self->vm;
|
||||
self->ob_type->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
PyObject * ViewMap___repr__(BPy_ViewMap *self)
|
||||
{
|
||||
return PyString_FromFormat("ViewMap - address: %p", self->vm );
|
||||
}
|
||||
|
||||
PyObject * ViewMap_getClosestViewEdge( BPy_ViewMap *self , PyObject *args) {
|
||||
double x, y;
|
||||
|
||||
if(!( PyArg_ParseTuple(args, "dd", &x, &y) )) {
|
||||
cout << "ERROR: ViewMap_getClosestFEdge" << endl;
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
ViewEdge *ve = const_cast<ViewEdge *>( self->vm->getClosestViewEdge(x,y) );
|
||||
if( ve )
|
||||
return BPy_ViewEdge_from_ViewEdge(*ve);
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyObject * ViewMap_getClosestFEdge( BPy_ViewMap *self , PyObject *args) {
|
||||
double x, y;
|
||||
|
||||
if(!( PyArg_ParseTuple(args, "dd", &x, &y) )) {
|
||||
cout << "ERROR: ViewMap_getClosestFEdge" << endl;
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
FEdge *fe = const_cast<FEdge *>( self->vm->getClosestFEdge(x,y) );
|
||||
if( fe )
|
||||
return BPy_FEdge_from_FEdge(*fe);
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyObject * ViewMap_getScene3dBBox( BPy_ViewMap *self , PyObject *args) {
|
||||
BBox<Vec3r> bb( self->vm->getScene3dBBox() );
|
||||
return BPy_BBox_from_BBox( bb );
|
||||
}
|
||||
|
||||
PyObject * ViewMap_setScene3dBBox( BPy_ViewMap *self , PyObject *args) {
|
||||
PyObject *py_bb = 0;
|
||||
|
||||
if(!( PyArg_ParseTuple(args, "O", &py_bb) && BPy_BBox_Check(py_bb) )) {
|
||||
cout << "ERROR: ViewMap_setScene3dBBox" << endl;
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
self->vm->setScene3dBBox(*( ((BPy_BBox *) py_bb)->bb ));
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_userdata_get(PyObject *self , PyObject *args) {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_new_ViewMap(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_delete_ViewMap(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_GetClosestViewEdge(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_GetClosestFEdge(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_getInstance(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_ViewShapes(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_ViewEdges(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_ViewVertices(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_FEdges(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_SVertices(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_viewedges_begin(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_viewedges_end(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_viewedges_size(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_viewShape(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_shapeIdToIndexMap(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_getScene3dBBox(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_AddViewShape(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_AddViewEdge(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_AddViewVertex(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_AddFEdge(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_AddSVertex(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_setScene3dBBox(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_CreateTVertex(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
PyObject *_wrap_ViewMap_InsertViewVertex(PyObject *self , PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
34
source/blender/freestyle/intern/python/BPy_ViewMap.h
Normal file
34
source/blender/freestyle/intern/python/BPy_ViewMap.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef FREESTYLE_PYTHON_VIEWMAP_H
|
||||
#define FREESTYLE_PYTHON_VIEWMAP_H
|
||||
|
||||
#include "../view_map/ViewMap.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
extern PyTypeObject ViewMap_Type;
|
||||
|
||||
#define BPy_ViewMap_Check(v) (( (PyObject *) v)->ob_type == &ViewMap_Type)
|
||||
|
||||
/*---------------------------Python BPy_ViewMap structure definition----------*/
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
ViewMap *vm;
|
||||
} BPy_ViewMap;
|
||||
|
||||
/*---------------------------Python BPy_ViewMap visible prototypes-----------*/
|
||||
|
||||
PyMODINIT_FUNC ViewMap_Init( PyObject *module );
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FREESTYLE_PYTHON_VIEWMAP_H */
|
||||
@@ -16,12 +16,27 @@ static int ViewShape___init__(BPy_ViewShape *self, PyObject *args, PyObject *kwd
|
||||
static void ViewShape___dealloc__(BPy_ViewShape *self);
|
||||
static PyObject * ViewShape___repr__(BPy_ViewShape* self);
|
||||
|
||||
static PyObject * ViewShape_sshape( BPy_ViewShape *self );
|
||||
static PyObject * ViewShape_vertices( BPy_ViewShape *self );
|
||||
static PyObject * ViewShape_edges( BPy_ViewShape *self );
|
||||
static PyObject * ViewShape_getId( BPy_ViewShape *self );
|
||||
static PyObject * ViewShape_setSShape( BPy_ViewShape *self , PyObject *args);
|
||||
static PyObject * ViewShape_setVertices( BPy_ViewShape *self , PyObject *args);
|
||||
static PyObject * ViewShape_setEdges( BPy_ViewShape *self , PyObject *args);
|
||||
static PyObject * ViewShape_AddEdge( BPy_ViewShape *self , PyObject *args);
|
||||
static PyObject * ViewShape_AddVertex( BPy_ViewShape *self , PyObject *args);
|
||||
|
||||
/*---------------------- BPy_ViewShape instance definitions ----------------------------*/
|
||||
static PyMethodDef BPy_ViewShape_methods[] = {
|
||||
//{"AddEdge", ( PyCFunction ) ViewShape_AddEdge, METH_VARARGS, "(FEdge fe )Adds a FEdge to the list of FEdges. "},
|
||||
|
||||
|
||||
{"sshape", ( PyCFunction ) ViewShape_sshape, METH_NOARGS, "() Returns the SShape on top of which this ViewShape is built. "},
|
||||
{"vertices", ( PyCFunction ) ViewShape_vertices, METH_NOARGS, "() Returns the list of ViewVertex contained in this ViewShape."},
|
||||
{"edges", ( PyCFunction ) ViewShape_edges, METH_NOARGS, "() Returns the list of ViewEdge contained in this ViewShape. "},
|
||||
{"getId", ( PyCFunction ) ViewShape_getId, METH_NOARGS, "() Returns the ViewShape id. "},
|
||||
{"setSShape", ( PyCFunction ) ViewShape_setSShape, METH_VARARGS, "(SShape ss) Sets the SShape on top of which the ViewShape is built. "},
|
||||
{"setVertices", ( PyCFunction ) ViewShape_setVertices, METH_VARARGS, "([<ViewVertex>]) Sets the list of ViewVertex contained in this ViewShape."},
|
||||
{"setEdges", ( PyCFunction ) ViewShape_setEdges, METH_VARARGS, "([<ViewEdge>]) Sets the list of ViewEdge contained in this ViewShape."},
|
||||
{"AddEdge", ( PyCFunction ) ViewShape_AddEdge, METH_VARARGS, "(ViewEdge ve) Adds a ViewEdge to the list "},
|
||||
{"AddVertex", ( PyCFunction ) ViewShape_AddVertex, METH_VARARGS, "(ViewVertex ve) Adds a ViewVertex to the list. "},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
@@ -231,7 +246,6 @@ PyObject * ViewShape_setVertices( BPy_ViewShape *self , PyObject *args) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
//void SetEdges (const vector< ViewEdge * > &iEdges)
|
||||
PyObject * ViewShape_setEdges( BPy_ViewShape *self , PyObject *args) {
|
||||
PyObject *list = 0;
|
||||
PyObject *tmp;
|
||||
|
||||
@@ -69,7 +69,7 @@ void ViewMap::AddViewShape(ViewShape *iVShape) {
|
||||
_shapeIdToIndex[iVShape->getId().getFirst()] = _VShapes.size();
|
||||
_VShapes.push_back(iVShape);
|
||||
}
|
||||
const FEdge * ViewMap::GetClosestFEdge(real x, real y) const
|
||||
const FEdge * ViewMap::getClosestFEdge(real x, real y) const
|
||||
{
|
||||
// find the closest of this candidates:
|
||||
real minDist = DBL_MAX;
|
||||
@@ -94,7 +94,7 @@ const FEdge * ViewMap::GetClosestFEdge(real x, real y) const
|
||||
return winner;
|
||||
}
|
||||
|
||||
const ViewEdge * ViewMap::GetClosestViewEdge(real x, real y) const
|
||||
const ViewEdge * ViewMap::getClosestViewEdge(real x, real y) const
|
||||
{
|
||||
// find the closest of this candidates:
|
||||
real minDist = DBL_MAX;
|
||||
|
||||
@@ -99,12 +99,12 @@ public:
|
||||
/*! Gets the viewedge the nearest to the
|
||||
* 2D position specified as argument
|
||||
*/
|
||||
const ViewEdge * GetClosestViewEdge(real x, real y) const ;
|
||||
const ViewEdge * getClosestViewEdge(real x, real y) const ;
|
||||
|
||||
/*! Gets the Fedge the nearest to the
|
||||
* 2D position specified as argument
|
||||
*/
|
||||
const FEdge * GetClosestFEdge(real x, real y) const ;
|
||||
const FEdge * getClosestFEdge(real x, real y) const ;
|
||||
|
||||
/* accessors */
|
||||
/*! The ViewMap is a singleton class. This static method
|
||||
|
||||
Reference in New Issue
Block a user