diff options
Diffstat (limited to 'source/blender/freestyle/intern/python')
312 files changed, 30432 insertions, 0 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_BBox.cpp b/source/blender/freestyle/intern/python/BPy_BBox.cpp new file mode 100644 index 00000000000..0acd32bad58 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_BBox.cpp @@ -0,0 +1,100 @@ +#include "BPy_BBox.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- +int BBox_Init( PyObject *module ) +{ + if( module == NULL ) + return -1; + + if( PyType_Ready( &BBox_Type ) < 0 ) + return -1; + + Py_INCREF( &BBox_Type ); + PyModule_AddObject(module, "BBox", (PyObject *)&BBox_Type); + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char BBox___doc__[] = +"Class for representing a bounding box.\n"; + +static int BBox___init__(BPy_BBox *self, PyObject *args, PyObject *kwds) +{ + if(!( PyArg_ParseTuple(args, "") )) + return -1; + self->bb = new BBox< Vec3r>(); + return 0; +} + +static void BBox___dealloc__(BPy_BBox* self) +{ + delete self->bb; + Py_TYPE(self)->tp_free((PyObject*)self); +} + + +static PyObject * BBox___repr__(BPy_BBox* self) +{ + return PyUnicode_FromFormat("BBox - address: %p", self->bb ); +} + +/*----------------------BBox instance definitions ----------------------------*/ +static PyMethodDef BPy_BBox_methods[] = { + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_BBox type definition ------------------------------*/ + +PyTypeObject BBox_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "BBox", /* tp_name */ + sizeof(BPy_BBox), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)BBox___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)BBox___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + BBox___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_BBox_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)BBox___init__, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/BPy_BBox.h b/source/blender/freestyle/intern/python/BPy_BBox.h new file mode 100644 index 00000000000..f8282187da0 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_BBox.h @@ -0,0 +1,38 @@ +#ifndef FREESTYLE_PYTHON_BBOX_H +#define FREESTYLE_PYTHON_BBOX_H + +#include <Python.h> + +#include "../geometry/BBox.h" +#include "../geometry/Geom.h" +using namespace Geometry; + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +extern PyTypeObject BBox_Type; + +#define BPy_BBox_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &BBox_Type) ) + +/*---------------------------Python BPy_BBox structure definition----------*/ +typedef struct { + PyObject_HEAD + BBox<Vec3r> *bb; +} BPy_BBox; + +/*---------------------------Python BPy_BBox visible prototypes-----------*/ + +int BBox_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_BBOX_H */ diff --git a/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp b/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp new file mode 100644 index 00000000000..693d35b1f60 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp @@ -0,0 +1,166 @@ +#include "BPy_BinaryPredicate0D.h" + +#include "BPy_Convert.h" +#include "BPy_Interface0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- +int BinaryPredicate0D_Init( PyObject *module ) +{ + if( module == NULL ) + return -1; + + if( PyType_Ready( &BinaryPredicate0D_Type ) < 0 ) + return -1; + + Py_INCREF( &BinaryPredicate0D_Type ); + PyModule_AddObject(module, "BinaryPredicate0D", (PyObject *)&BinaryPredicate0D_Type); + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char BinaryPredicate0D___doc__[] = +"Base class for binary predicates working on :class:`Interface0D`\n" +"objects. A BinaryPredicate0D is typically an ordering relation\n" +"between two Interface0D objects. The predicate evaluates a relation\n" +"between the two Interface0D instances and returns a boolean value (true\n" +"or false). It is used by invoking the __call__() method.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __call__(inter1, inter2)\n" +"\n" +" Must be overload by inherited classes. It evaluates a relation\n" +" between two Interface0D objects.\n" +"\n" +" :arg inter1: The first Interface0D object.\n" +" :type inter1: :class:`Interface0D`\n" +" :arg inter2: The second Interface0D object.\n" +" :type inter2: :class:`Interface0D`\n" +" :return: True or false.\n" +" :rtype: bool\n"; + +static int BinaryPredicate0D___init__(BPy_BinaryPredicate0D *self, PyObject *args, PyObject *kwds) +{ + if ( !PyArg_ParseTuple(args, "") ) + return -1; + self->bp0D = new BinaryPredicate0D(); + self->bp0D->py_bp0D = (PyObject *) self; + + return 0; +} + +static void BinaryPredicate0D___dealloc__(BPy_BinaryPredicate0D* self) +{ + if (self->bp0D) + delete self->bp0D; + Py_TYPE(self)->tp_free((PyObject*)self); +} + + +static PyObject * BinaryPredicate0D___repr__(BPy_BinaryPredicate0D* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->bp0D->getName().c_str(), self->bp0D ); +} + +static char BinaryPredicate0D_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the binary 0D predicate.\n" +"\n" +" :return: The name of the binary 0D predicate.\n" +" :rtype: str\n"; + +static PyObject * BinaryPredicate0D_getName( BPy_BinaryPredicate0D *self, PyObject *args) +{ + return PyUnicode_FromString( self->bp0D->getName().c_str() ); +} + +static PyObject * BinaryPredicate0D___call__( BPy_BinaryPredicate0D *self, PyObject *args, PyObject *kwds) +{ + BPy_Interface0D *obj1, *obj2; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } + if( !PyArg_ParseTuple(args, "O!O!", &Interface0D_Type, &obj1, &Interface0D_Type, &obj2) ) + return NULL; + + if( typeid(*(self->bp0D)) == typeid(BinaryPredicate0D) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); + return NULL; + } + if (self->bp0D->operator()( *(obj1->if0D) , *(obj2->if0D) ) < 0) { + if (!PyErr_Occurred()) { + string msg(self->bp0D->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return PyBool_from_bool( self->bp0D->result ); + +} + +/*----------------------BinaryPredicate0D instance definitions ----------------------------*/ +static PyMethodDef BPy_BinaryPredicate0D_methods[] = { + {"getName", ( PyCFunction ) BinaryPredicate0D_getName, METH_NOARGS, BinaryPredicate0D_getName___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_BinaryPredicate0D type definition ------------------------------*/ + +PyTypeObject BinaryPredicate0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "BinaryPredicate0D", /* tp_name */ + sizeof(BPy_BinaryPredicate0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)BinaryPredicate0D___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)BinaryPredicate0D___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)BinaryPredicate0D___call__, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + BinaryPredicate0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_BinaryPredicate0D_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)BinaryPredicate0D___init__, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.h b/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.h new file mode 100644 index 00000000000..6a9a0775608 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.h @@ -0,0 +1,36 @@ +#ifndef FREESTYLE_PYTHON_BINARYPREDICATE0D_H +#define FREESTYLE_PYTHON_BINARYPREDICATE0D_H + +#include <Python.h> + +#include "../stroke/Predicates0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +extern PyTypeObject BinaryPredicate0D_Type; + +#define BPy_BinaryPredicate0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &BinaryPredicate0D_Type) ) + +/*---------------------------Python BPy_BinaryPredicate0D structure definition----------*/ +typedef struct { + PyObject_HEAD + BinaryPredicate0D *bp0D; +} BPy_BinaryPredicate0D; + +/*---------------------------Python BPy_BinaryPredicate0D visible prototypes-----------*/ + +int BinaryPredicate0D_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_BINARYPREDICATE0D_H */ diff --git a/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp b/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp new file mode 100644 index 00000000000..e690a6d51c1 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp @@ -0,0 +1,193 @@ +#include "BPy_BinaryPredicate1D.h" + +#include "BPy_Convert.h" +#include "BPy_Interface1D.h" + +#include "BinaryPredicate1D/BPy_FalseBP1D.h" +#include "BinaryPredicate1D/BPy_Length2DBP1D.h" +#include "BinaryPredicate1D/BPy_SameShapeIdBP1D.h" +#include "BinaryPredicate1D/BPy_TrueBP1D.h" +#include "BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- +int BinaryPredicate1D_Init( PyObject *module ) +{ + if( module == NULL ) + return -1; + + if( PyType_Ready( &BinaryPredicate1D_Type ) < 0 ) + return -1; + Py_INCREF( &BinaryPredicate1D_Type ); + PyModule_AddObject(module, "BinaryPredicate1D", (PyObject *)&BinaryPredicate1D_Type); + + if( PyType_Ready( &FalseBP1D_Type ) < 0 ) + return -1; + Py_INCREF( &FalseBP1D_Type ); + PyModule_AddObject(module, "FalseBP1D", (PyObject *)&FalseBP1D_Type); + + if( PyType_Ready( &Length2DBP1D_Type ) < 0 ) + return -1; + Py_INCREF( &Length2DBP1D_Type ); + PyModule_AddObject(module, "Length2DBP1D", (PyObject *)&Length2DBP1D_Type); + + if( PyType_Ready( &SameShapeIdBP1D_Type ) < 0 ) + return -1; + Py_INCREF( &SameShapeIdBP1D_Type ); + PyModule_AddObject(module, "SameShapeIdBP1D", (PyObject *)&SameShapeIdBP1D_Type); + + if( PyType_Ready( &TrueBP1D_Type ) < 0 ) + return -1; + Py_INCREF( &TrueBP1D_Type ); + PyModule_AddObject(module, "TrueBP1D", (PyObject *)&TrueBP1D_Type); + + if( PyType_Ready( &ViewMapGradientNormBP1D_Type ) < 0 ) + return -1; + Py_INCREF( &ViewMapGradientNormBP1D_Type ); + PyModule_AddObject(module, "ViewMapGradientNormBP1D", (PyObject *)&ViewMapGradientNormBP1D_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char BinaryPredicate1D___doc__[] = +"Base class for binary predicates working on :class:`Interface1D`\n" +"objects. A BinaryPredicate1D is typically an ordering relation\n" +"between two Interface1D objects. The predicate evaluates a relation\n" +"between the two Interface1D instances and returns a boolean value (true\n" +"or false). It is used by invoking the __call__() method.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __call__(inter1, inter2)\n" +"\n" +" Must be overload by inherited classes. It evaluates a relation\n" +" between two Interface1D objects.\n" +"\n" +" :arg inter1: The first Interface1D object.\n" +" :type inter1: :class:`Interface1D`\n" +" :arg inter2: The second Interface1D object.\n" +" :type inter2: :class:`Interface1D`\n" +" :return: True or false.\n" +" :rtype: bool\n"; + +static int BinaryPredicate1D___init__(BPy_BinaryPredicate1D *self, PyObject *args, PyObject *kwds) +{ + if ( !PyArg_ParseTuple(args, "") ) + return -1; + self->bp1D = new BinaryPredicate1D(); + self->bp1D->py_bp1D = (PyObject *) self; + return 0; +} + +static void BinaryPredicate1D___dealloc__(BPy_BinaryPredicate1D* self) +{ + if (self->bp1D) + delete self->bp1D; + Py_TYPE(self)->tp_free((PyObject*)self); +} + +static PyObject * BinaryPredicate1D___repr__(BPy_BinaryPredicate1D* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->bp1D->getName().c_str(), self->bp1D ); +} + +static char BinaryPredicate1D_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the binary 1D predicate.\n" +"\n" +" :return: The name of the binary 1D predicate.\n" +" :rtype: str\n"; + +static PyObject *BinaryPredicate1D_getName( BPy_BinaryPredicate1D *self, PyObject *args) +{ + return PyUnicode_FromString( self->bp1D->getName().c_str() ); +} + +static PyObject *BinaryPredicate1D___call__( BPy_BinaryPredicate1D *self, PyObject *args, PyObject *kwds) +{ + BPy_Interface1D *obj1, *obj2; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } + if( !PyArg_ParseTuple(args, "O!O!", &Interface1D_Type, &obj1, &Interface1D_Type, &obj2) ) + return NULL; + + if( typeid(*(self->bp1D)) == typeid(BinaryPredicate1D) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); + return NULL; + } + if (self->bp1D->operator()( *(obj1->if1D) , *(obj2->if1D) ) < 0) { + if (!PyErr_Occurred()) { + string msg(self->bp1D->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return PyBool_from_bool( self->bp1D->result ); +} + +/*----------------------BinaryPredicate1D instance definitions ----------------------------*/ +static PyMethodDef BPy_BinaryPredicate1D_methods[] = { + {"getName", ( PyCFunction ) BinaryPredicate1D_getName, METH_NOARGS, BinaryPredicate1D_getName___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_BinaryPredicate1D type definition ------------------------------*/ +PyTypeObject BinaryPredicate1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "BinaryPredicate1D", /* tp_name */ + sizeof(BPy_BinaryPredicate1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)BinaryPredicate1D___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)BinaryPredicate1D___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)BinaryPredicate1D___call__, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + BinaryPredicate1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_BinaryPredicate1D_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)BinaryPredicate1D___init__, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.h b/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.h new file mode 100644 index 00000000000..5a993f84f5b --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.h @@ -0,0 +1,35 @@ +#ifndef FREESTYLE_PYTHON_BINARYPREDICATE1D_H +#define FREESTYLE_PYTHON_BINARYPREDICATE1D_H + +#include <Python.h> + +#include "../stroke/Predicates1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +extern PyTypeObject BinaryPredicate1D_Type; + +#define BPy_BinaryPredicate1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &BinaryPredicate1D_Type) ) + +/*---------------------------Python BPy_BinaryPredicate1D structure definition----------*/ +typedef struct { + PyObject_HEAD + BinaryPredicate1D *bp1D; +} BPy_BinaryPredicate1D; + +/*---------------------------Python BPy_BinaryPredicate1D visible prototypes-----------*/ + +int BinaryPredicate1D_Init( PyObject *module ); + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_BINARYPREDICATE1D_H */ diff --git a/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp b/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp new file mode 100644 index 00000000000..5c824981aa3 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp @@ -0,0 +1,262 @@ +#include "BPy_ContextFunctions.h" +#include "BPy_Convert.h" + +#include "../stroke/ContextFunctions.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------ MODULE FUNCTIONS ---------------------------------- + +static char ContextFunctions_GetTimeStampCF___doc__[] = +".. function:: GetTimeStampCF()\n" +"\n" +" Returns the system time stamp.\n" +"\n" +" :return: The system time stamp.\n" +" :rtype: int\n"; + +static PyObject * +ContextFunctions_GetTimeStampCF( PyObject* self ) +{ + return PyLong_FromLong( ContextFunctions::GetTimeStampCF() ); +} + +static char ContextFunctions_GetCanvasWidthCF___doc__[] = +".. method:: GetCanvasWidthCF()\n" +"\n" +" Returns the canvas width.\n" +"\n" +" :return: The canvas width.\n" +" :rtype: int\n"; + +static PyObject * +ContextFunctions_GetCanvasWidthCF( PyObject* self ) +{ + return PyLong_FromLong( ContextFunctions::GetCanvasWidthCF() ); +} + +static char ContextFunctions_GetCanvasHeightCF___doc__[] = +".. method:: GetCanvasHeightCF()\n" +"\n" +" Returns the canvas height.\n" +"\n" +" :return: The canvas height.\n" +" :rtype: int\n"; + +static PyObject * +ContextFunctions_GetCanvasHeightCF( PyObject* self ) +{ + return PyLong_FromLong( ContextFunctions::GetCanvasHeightCF() ); +} + +static char ContextFunctions_LoadMapCF___doc__[] = +".. function:: LoadMapCF(iFileName, iMapName, iNbLevels=4, iSigma=1.0)\n" +"\n" +" Loads an image map for further reading.\n" +"\n" +" :arg iFileName: The name of the image file.\n" +" :type iFileName: str\n" +" :arg iMapName: The name that will be used to access this image.\n" +" :type iMapName: str\n" +" :arg iNbLevels: The number of levels in the map pyramid\n" +" (default = 4). If iNbLevels == 0, the complete pyramid is\n" +" built.\n" +" :type iNbLevels: int\n" +" :arg iSigma: The sigma value of the gaussian function.\n" +" :type iSigma: float\n"; + +static PyObject * +ContextFunctions_LoadMapCF( PyObject *self, PyObject *args ) +{ + char *fileName, *mapName; + unsigned nbLevels; + float sigma; + + if( !PyArg_ParseTuple(args, "ssIf", &fileName, &mapName, &nbLevels, &sigma) ) + return NULL; + + ContextFunctions::LoadMapCF(fileName, mapName, nbLevels, sigma); + + Py_RETURN_NONE; +} + +static char ContextFunctions_ReadMapPixelCF___doc__[] = +".. function:: ReadMapPixelCF(iMapName, level, x, y)\n" +"\n" +" Reads a pixel in a user-defined map.\n" +"\n" +" :arg iMapName: The name of the map.\n" +" :type iMapName: str\n" +" :arg level: The level of the pyramid in which we wish to read the\n" +" pixel.\n" +" :type level: int\n" +" :arg x: The x coordinate of the pixel we wish to read. The origin\n" +" is in the lower-left corner.\n" +" :type x: int\n" +" :arg y: The y coordinate of the pixel we wish to read. The origin\n" +" is in the lower-left corner.\n" +" :type y: int\n" +" :return: The floating-point value stored for that pixel.\n" +" :rtype: float\n"; + +static PyObject * +ContextFunctions_ReadMapPixelCF( PyObject *self, PyObject *args ) +{ + char *mapName; + int level; + unsigned x, y; + + if( !PyArg_ParseTuple(args, "siII", &mapName, &level, &x, &y) ) + return NULL; + + float f = ContextFunctions::ReadMapPixelCF(mapName, level, x, y); + + return PyFloat_FromDouble( f ); +} + +static char ContextFunctions_ReadCompleteViewMapPixelCF___doc__[] = +".. function:: ReadCompleteViewMapPixelCF(level, x, y)\n" +"\n" +" Reads a pixel in the complete view map.\n" +"\n" +" :arg level: The level of the pyramid in which we wish to read the\n" +" pixel.\n" +" :type level: int\n" +" :arg x: The x coordinate of the pixel we wish to read. The origin\n" +" is in the lower-left corner.\n" +" :type x: int\n" +" :arg y: The y coordinate of the pixel we wish to read. The origin\n" +" is in the lower-left corner.\n" +" :type y: int\n" +" :return: The floating-point value stored for that pixel.\n" +" :rtype: float\n"; + +static PyObject * +ContextFunctions_ReadCompleteViewMapPixelCF( PyObject *self, PyObject *args ) +{ + int level; + unsigned x, y; + + if( !PyArg_ParseTuple(args, "iII", &level, &x, &y) ) + return NULL; + + float f = ContextFunctions::ReadCompleteViewMapPixelCF(level, x, y); + + return PyFloat_FromDouble( f ); +} + +static char ContextFunctions_ReadDirectionalViewMapPixelCF___doc__[] = +".. function:: ReadDirectionalViewMapPixelCF(iOrientation, level, x, y)\n" +"\n" +" Reads a pixel in one of the oriented view map images.\n" +"\n" +" :arg iOrientation: The number telling which orientation we want to\n" +" check.\n" +" :type iOrientation: int\n" +" :arg level: The level of the pyramid in which we wish to read the\n" +" pixel.\n" +" :type level: int\n" +" :arg x: The x coordinate of the pixel we wish to read. The origin\n" +" is in the lower-left corner.\n" +" :type x: int\n" +" :arg y: The y coordinate of the pixel we wish to read. The origin\n" +" is in the lower-left corner.\n" +" :type y: int\n" +" :return: The floating-point value stored for that pixel.\n" +" :rtype: float\n"; + +static PyObject * +ContextFunctions_ReadDirectionalViewMapPixelCF( PyObject *self, PyObject *args ) +{ + int orientation, level; + unsigned x, y; + + if( !PyArg_ParseTuple(args, "iiII", &orientation, &level, &x, &y) ) + return NULL; + + float f = ContextFunctions::ReadDirectionalViewMapPixelCF(orientation, level, x, y); + + return PyFloat_FromDouble( f ); +} + +static char ContextFunctions_GetSelectedFEdgeCF___doc__[] = +".. function:: GetSelectedFEdgeCF()\n" +"\n" +" Returns the selected FEdge.\n" +"\n" +" :return: The selected FEdge.\n" +" :rtype: :class:`FEdge`\n"; + +static PyObject * +ContextFunctions_GetSelectedFEdgeCF( PyObject *self ) +{ + FEdge *fe = ContextFunctions::GetSelectedFEdgeCF(); + if( fe ) + return Any_BPy_FEdge_from_FEdge( *fe ); + + Py_RETURN_NONE; +} + +/*-----------------------ContextFunctions module docstring-------------------------------*/ + +static char module_docstring[] = "The Blender Freestyle.ContextFunctions submodule\n\n"; + +/*-----------------------ContextFunctions module functions definitions-------------------*/ + +static PyMethodDef module_functions[] = { + {"GetTimeStampCF", (PyCFunction)ContextFunctions_GetTimeStampCF, METH_NOARGS, ContextFunctions_GetTimeStampCF___doc__}, + {"GetCanvasWidthCF", (PyCFunction)ContextFunctions_GetCanvasWidthCF, METH_NOARGS, ContextFunctions_GetCanvasWidthCF___doc__}, + {"GetCanvasHeightCF", (PyCFunction)ContextFunctions_GetCanvasHeightCF, METH_NOARGS, ContextFunctions_GetCanvasHeightCF___doc__}, + {"LoadMapCF", (PyCFunction)ContextFunctions_LoadMapCF, METH_VARARGS, ContextFunctions_LoadMapCF___doc__}, + {"ReadMapPixelCF", (PyCFunction)ContextFunctions_ReadMapPixelCF, METH_VARARGS, ContextFunctions_ReadMapPixelCF___doc__}, + {"ReadCompleteViewMapPixelCF", (PyCFunction)ContextFunctions_ReadCompleteViewMapPixelCF, METH_VARARGS, ContextFunctions_ReadCompleteViewMapPixelCF___doc__}, + {"ReadDirectionalViewMapPixelCF", (PyCFunction)ContextFunctions_ReadDirectionalViewMapPixelCF, METH_VARARGS, ContextFunctions_ReadDirectionalViewMapPixelCF___doc__}, + {"GetSelectedFEdgeCF", (PyCFunction)ContextFunctions_GetSelectedFEdgeCF, METH_NOARGS, ContextFunctions_GetSelectedFEdgeCF___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------ContextFunctions module definition--------------------------------*/ + +static PyModuleDef module_definition = { + PyModuleDef_HEAD_INIT, + "Freestyle.ContextFunctions", + module_docstring, + -1, + module_functions +}; + +//------------------- MODULE INITIALIZATION -------------------------------- + +int ContextFunctions_Init( PyObject *module ) +{ + PyObject *m, *d, *f; + + if( module == NULL ) + return -1; + + m = PyModule_Create(&module_definition); + if (m == NULL) + return -1; + Py_INCREF(m); + PyModule_AddObject(module, "ContextFunctions", m); + + // from ContextFunctions import * + d = PyModule_GetDict(m); + for (PyMethodDef *p = module_functions; p->ml_name; p++) { + f = PyDict_GetItemString(d, p->ml_name); + Py_INCREF(f); + PyModule_AddObject(module, p->ml_name, f); + } + + return 0; +} + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/BPy_ContextFunctions.h b/source/blender/freestyle/intern/python/BPy_ContextFunctions.h new file mode 100644 index 00000000000..fafeff3e974 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_ContextFunctions.h @@ -0,0 +1,18 @@ +#ifndef FREESTYLE_PYTHON_CONTEXTFUNCTIONS_H +#define FREESTYLE_PYTHON_CONTEXTFUNCTIONS_H + +#include <Python.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------Python BPy_ContextFunctions visible prototypes-----------*/ + +int ContextFunctions_Init( PyObject *module ); + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_CONTEXTFUNCTIONS_H */ diff --git a/source/blender/freestyle/intern/python/BPy_Convert.cpp b/source/blender/freestyle/intern/python/BPy_Convert.cpp new file mode 100644 index 00000000000..e3f979fea8f --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_Convert.cpp @@ -0,0 +1,609 @@ +#include "BPy_Convert.h" + +#include "BPy_BBox.h" +#include "BPy_FrsMaterial.h" +#include "BPy_Id.h" +#include "BPy_IntegrationType.h" +#include "BPy_Interface0D.h" +#include "Interface0D/BPy_CurvePoint.h" +#include "Interface0D/CurvePoint/BPy_StrokeVertex.h" +#include "Interface0D/BPy_SVertex.h" +#include "Interface0D/BPy_ViewVertex.h" +#include "Interface0D/ViewVertex/BPy_NonTVertex.h" +#include "Interface0D/ViewVertex/BPy_TVertex.h" +#include "BPy_Interface1D.h" +#include "Interface1D/BPy_FEdge.h" +#include "Interface1D/BPy_Stroke.h" +#include "Interface1D/BPy_ViewEdge.h" +#include "Interface1D/Curve/BPy_Chain.h" +#include "Interface1D/FEdge/BPy_FEdgeSharp.h" +#include "Interface1D/FEdge/BPy_FEdgeSmooth.h" +#include "BPy_Nature.h" +#include "BPy_MediumType.h" +#include "BPy_SShape.h" +#include "BPy_StrokeAttribute.h" +#include "BPy_ViewShape.h" + +#include "Iterator/BPy_AdjacencyIterator.h" +#include "Iterator/BPy_ChainPredicateIterator.h" +#include "Iterator/BPy_ChainSilhouetteIterator.h" +#include "Iterator/BPy_ChainingIterator.h" +#include "Iterator/BPy_CurvePointIterator.h" +#include "Iterator/BPy_Interface0DIterator.h" +#include "Iterator/BPy_SVertexIterator.h" +#include "Iterator/BPy_StrokeVertexIterator.h" +#include "Iterator/BPy_ViewEdgeIterator.h" +#include "Iterator/BPy_orientedViewEdgeIterator.h" + +#include "../stroke/StrokeRep.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/////////////////////////////////////////////////////////////////////////////////////////// + +//============================== +// C++ => Python +//============================== + + +PyObject * PyBool_from_bool( bool b ){ + return PyBool_FromLong( b ? 1 : 0); +} + + +PyObject * Vector_from_Vec2f( Vec2f& vec ) { + float vec_data[2]; // because vec->_coord is protected + + vec_data[0] = vec.x(); vec_data[1] = vec.y(); + return newVectorObject( vec_data, 2, Py_NEW, NULL); +} + +PyObject * Vector_from_Vec3f( Vec3f& vec ) { + float vec_data[3]; // because vec->_coord is protected + + vec_data[0] = vec.x(); vec_data[1] = vec.y(); vec_data[2] = vec.z(); + return newVectorObject( vec_data, 3, Py_NEW, NULL); +} + +PyObject * Vector_from_Vec3r( Vec3r& vec ) { + float vec_data[3]; // because vec->_coord is protected + + vec_data[0] = vec.x(); vec_data[1] = vec.y(); vec_data[2] = vec.z(); + return newVectorObject( vec_data, 3, Py_NEW, NULL); +} + +PyObject * BPy_Id_from_Id( Id& id ) { + PyObject *py_id = Id_Type.tp_new( &Id_Type, 0, 0 ); + ((BPy_Id *) py_id)->id = new Id( id.getFirst(), id.getSecond() ); + + return py_id; +} + +PyObject * Any_BPy_Interface0D_from_Interface0D( Interface0D& if0D ) { + if (typeid(if0D) == typeid(CurvePoint)) { + return BPy_CurvePoint_from_CurvePoint(dynamic_cast<CurvePoint&>(if0D)); + } else if (typeid(if0D) == typeid(StrokeVertex)) { + return BPy_StrokeVertex_from_StrokeVertex(dynamic_cast<StrokeVertex&>(if0D)); + } else if (typeid(if0D) == typeid(SVertex)) { + return BPy_SVertex_from_SVertex(dynamic_cast<SVertex&>(if0D)); + } else if (typeid(if0D) == typeid(ViewVertex)) { + return BPy_ViewVertex_from_ViewVertex(dynamic_cast<ViewVertex&>(if0D)); + } else if (typeid(if0D) == typeid(NonTVertex)) { + return BPy_NonTVertex_from_NonTVertex(dynamic_cast<NonTVertex&>(if0D)); + } else if (typeid(if0D) == typeid(TVertex)) { + return BPy_TVertex_from_TVertex(dynamic_cast<TVertex&>(if0D)); + } else if (typeid(if0D) == typeid(Interface0D)) { + return BPy_Interface0D_from_Interface0D(if0D); + } + string msg("unexpected type: " + if0D.getExactTypeName()); + PyErr_SetString(PyExc_TypeError, msg.c_str()); + return NULL; +} + +PyObject * Any_BPy_Interface1D_from_Interface1D( Interface1D& if1D ) { + if (typeid(if1D) == typeid(ViewEdge)) { + return BPy_ViewEdge_from_ViewEdge(dynamic_cast<ViewEdge&>(if1D)); + } else if (typeid(if1D) == typeid(Chain)) { + return BPy_Chain_from_Chain(dynamic_cast<Chain&>(if1D)); + } else if (typeid(if1D) == typeid(Stroke)) { + return BPy_Stroke_from_Stroke(dynamic_cast<Stroke&>(if1D)); + } else if (typeid(if1D) == typeid(FEdgeSharp)) { + return BPy_FEdgeSharp_from_FEdgeSharp(dynamic_cast<FEdgeSharp&>(if1D)); + } else if (typeid(if1D) == typeid(FEdgeSmooth)) { + return BPy_FEdgeSmooth_from_FEdgeSmooth(dynamic_cast<FEdgeSmooth&>(if1D)); + } else if (typeid(if1D) == typeid(FEdge)) { + return BPy_FEdge_from_FEdge(dynamic_cast<FEdge&>(if1D)); + } else if (typeid(if1D) == typeid(Interface1D)) { + return BPy_Interface1D_from_Interface1D( if1D ); + } + string msg("unexpected type: " + if1D.getExactTypeName()); + PyErr_SetString(PyExc_TypeError, msg.c_str()); + return NULL; +} + +PyObject * Any_BPy_FEdge_from_FEdge( FEdge& fe ) { + if (typeid(fe) == typeid(FEdgeSharp)) { + return BPy_FEdgeSharp_from_FEdgeSharp( dynamic_cast<FEdgeSharp&>(fe) ); + } else if (typeid(fe) == typeid(FEdgeSmooth)) { + return BPy_FEdgeSmooth_from_FEdgeSmooth( dynamic_cast<FEdgeSmooth&>(fe) ); + } else if (typeid(fe) == typeid(FEdge)) { + return BPy_FEdge_from_FEdge( fe ); + } + string msg("unexpected type: " + fe.getExactTypeName()); + PyErr_SetString(PyExc_TypeError, msg.c_str()); + return NULL; +} + +PyObject * Any_BPy_ViewVertex_from_ViewVertex( ViewVertex& vv ) { + if (typeid(vv) == typeid(NonTVertex)) { + return BPy_NonTVertex_from_NonTVertex( dynamic_cast<NonTVertex&>(vv) ); + } else if (typeid(vv) == typeid(TVertex)) { + return BPy_TVertex_from_TVertex( dynamic_cast<TVertex&>(vv) ); + } else if (typeid(vv) == typeid(ViewVertex)) { + return BPy_ViewVertex_from_ViewVertex( vv ); + } + string msg("unexpected type: " + vv.getExactTypeName()); + PyErr_SetString(PyExc_TypeError, msg.c_str()); + return NULL; +} + +PyObject * BPy_Interface0D_from_Interface0D( Interface0D& if0D ) { + PyObject *py_if0D = Interface0D_Type.tp_new( &Interface0D_Type, 0, 0 ); + ((BPy_Interface0D *) py_if0D)->if0D = &if0D; + ((BPy_Interface0D *) py_if0D)->borrowed = 1; + + return py_if0D; +} + +PyObject * BPy_Interface1D_from_Interface1D( Interface1D& if1D ) { + PyObject *py_if1D = Interface1D_Type.tp_new( &Interface1D_Type, 0, 0 ); + ((BPy_Interface1D *) py_if1D)->if1D = &if1D; + ((BPy_Interface1D *) py_if1D)->borrowed = 1; + + return py_if1D; +} + +PyObject * BPy_SVertex_from_SVertex( SVertex& sv ) { + PyObject *py_sv = SVertex_Type.tp_new( &SVertex_Type, 0, 0 ); + ((BPy_SVertex *) py_sv)->sv = &sv; + ((BPy_SVertex *) py_sv)->py_if0D.if0D = ((BPy_SVertex *) py_sv)->sv; + ((BPy_SVertex *) py_sv)->py_if0D.borrowed = 1; + + return py_sv; +} + +PyObject * BPy_FEdgeSharp_from_FEdgeSharp( FEdgeSharp& fes ) { + PyObject *py_fe = FEdgeSharp_Type.tp_new( &FEdgeSharp_Type, 0, 0 ); + ((BPy_FEdgeSharp *) py_fe)->fes = &fes; + ((BPy_FEdgeSharp *) py_fe)->py_fe.fe = ((BPy_FEdgeSharp *) py_fe)->fes; + ((BPy_FEdgeSharp *) py_fe)->py_fe.py_if1D.if1D = ((BPy_FEdgeSharp *) py_fe)->fes; + ((BPy_FEdgeSharp *) py_fe)->py_fe.py_if1D.borrowed = 1; + + return py_fe; +} + +PyObject * BPy_FEdgeSmooth_from_FEdgeSmooth( FEdgeSmooth& fes ) { + PyObject *py_fe = FEdgeSmooth_Type.tp_new( &FEdgeSmooth_Type, 0, 0 ); + ((BPy_FEdgeSmooth *) py_fe)->fes = &fes; + ((BPy_FEdgeSmooth *) py_fe)->py_fe.fe = ((BPy_FEdgeSmooth *) py_fe)->fes; + ((BPy_FEdgeSmooth *) py_fe)->py_fe.py_if1D.if1D = ((BPy_FEdgeSmooth *) py_fe)->fes; + ((BPy_FEdgeSmooth *) py_fe)->py_fe.py_if1D.borrowed = 1; + + return py_fe; +} + +PyObject * BPy_FEdge_from_FEdge( FEdge& fe ) { + PyObject *py_fe = FEdge_Type.tp_new( &FEdge_Type, 0, 0 ); + ((BPy_FEdge *) py_fe)->fe = &fe; + ((BPy_FEdge *) py_fe)->py_if1D.if1D = ((BPy_FEdge *) py_fe)->fe; + ((BPy_FEdge *) py_fe)->py_if1D.borrowed = 1; + + return py_fe; +} + +PyObject * BPy_Nature_from_Nature( unsigned short n ) { + PyObject *py_n; + + PyObject *args = PyTuple_New(1); + PyTuple_SetItem( args, 0, PyLong_FromLong(n) ); + py_n = Nature_Type.tp_new(&Nature_Type, args, NULL); + Py_DECREF(args); + + return py_n; +} + +PyObject * BPy_Stroke_from_Stroke( Stroke& s ) { + PyObject *py_s = Stroke_Type.tp_new( &Stroke_Type, 0, 0 ); + ((BPy_Stroke *) py_s)->s = &s; + ((BPy_Stroke *) py_s)->py_if1D.if1D = ((BPy_Stroke *) py_s)->s; + ((BPy_Stroke *) py_s)->py_if1D.borrowed = 1; + + return py_s; +} + +PyObject * BPy_StrokeAttribute_from_StrokeAttribute( StrokeAttribute& sa ) { + PyObject *py_sa = StrokeAttribute_Type.tp_new( &StrokeAttribute_Type, 0, 0 ); + ((BPy_StrokeAttribute *) py_sa)->sa = &sa; + ((BPy_StrokeAttribute *) py_sa)->borrowed = 1; + return py_sa; +} + +PyObject * BPy_MediumType_from_MediumType( Stroke::MediumType n ) { + PyObject *py_mt; + + PyObject *args = PyTuple_New(1); + PyTuple_SetItem( args, 0, PyLong_FromLong(n) ); + py_mt = MediumType_Type.tp_new( &MediumType_Type, args, NULL ); + 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 = &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; + ((BPy_StrokeVertex *) py_sv)->py_cp.py_if0D.borrowed = 1; + + return py_sv; +} + +PyObject * BPy_ViewVertex_from_ViewVertex( ViewVertex& vv ) { + PyObject *py_vv = ViewVertex_Type.tp_new( &ViewVertex_Type, 0, 0 ); + ((BPy_ViewVertex *) py_vv)->vv = &vv; + ((BPy_ViewVertex *) py_vv)->py_if0D.if0D = ((BPy_ViewVertex *) py_vv)->vv; + ((BPy_ViewVertex *) py_vv)->py_if0D.borrowed = 1; + + return py_vv; +} + +PyObject * BPy_NonTVertex_from_NonTVertex( NonTVertex& ntv ) { + PyObject *py_ntv = NonTVertex_Type.tp_new( &NonTVertex_Type, 0, 0 ); + ((BPy_NonTVertex *) py_ntv)->ntv = &ntv; + ((BPy_NonTVertex *) py_ntv)->py_vv.vv = ((BPy_NonTVertex *) py_ntv)->ntv; + ((BPy_NonTVertex *) py_ntv)->py_vv.py_if0D.if0D = ((BPy_NonTVertex *) py_ntv)->ntv; + ((BPy_NonTVertex *) py_ntv)->py_vv.py_if0D.borrowed = 1; + + return py_ntv; +} + +PyObject * BPy_TVertex_from_TVertex( TVertex& tv ) { + PyObject *py_tv = TVertex_Type.tp_new( &TVertex_Type, 0, 0 ); + ((BPy_TVertex *) py_tv)->tv = &tv; + ((BPy_TVertex *) py_tv)->py_vv.vv = ((BPy_TVertex *) py_tv)->tv; + ((BPy_TVertex *) py_tv)->py_vv.py_if0D.if0D = ((BPy_TVertex *) py_tv)->tv; + ((BPy_TVertex *) py_tv)->py_vv.py_if0D.borrowed = 1; + + return py_tv; +} + +PyObject * BPy_BBox_from_BBox( BBox< Vec3r > &bb ) { + PyObject *py_bb = BBox_Type.tp_new( &BBox_Type, 0, 0 ); + ((BPy_BBox *) py_bb)->bb = new BBox< Vec3r >( bb ); + + return py_bb; +} + +PyObject * BPy_ViewEdge_from_ViewEdge( ViewEdge& ve ) { + PyObject *py_ve = ViewEdge_Type.tp_new( &ViewEdge_Type, 0, 0 ); + ((BPy_ViewEdge *) py_ve)->ve = &ve; + ((BPy_ViewEdge *) py_ve)->py_if1D.if1D = ((BPy_ViewEdge *) py_ve)->ve; + ((BPy_ViewEdge *) py_ve)->py_if1D.borrowed = 1; + + return py_ve; +} + +PyObject * BPy_Chain_from_Chain( Chain& c ) { + PyObject *py_c = Chain_Type.tp_new( &Chain_Type, 0, 0 ); + ((BPy_Chain *) py_c)->c = &c; + ((BPy_Chain *) py_c)->py_c.c = ((BPy_Chain *) py_c)->c; + ((BPy_Chain *) py_c)->py_c.py_if1D.if1D = ((BPy_Chain *) py_c)->c; + ((BPy_Chain *) py_c)->py_c.py_if1D.borrowed = 1; + return py_c; +} + +PyObject * BPy_SShape_from_SShape( SShape& ss ) { + PyObject *py_ss = SShape_Type.tp_new( &SShape_Type, 0, 0 ); + ((BPy_SShape *) py_ss)->ss = &ss; + ((BPy_SShape *) py_ss)->borrowed = 1; + + return py_ss; +} + +PyObject * BPy_ViewShape_from_ViewShape( ViewShape& vs ) { + PyObject *py_vs = ViewShape_Type.tp_new( &ViewShape_Type, 0, 0 ); + ((BPy_ViewShape *) py_vs)->vs = &vs; + ((BPy_ViewShape *) py_vs)->borrowed = 1; + + return py_vs; +} + +PyObject * BPy_FrsMaterial_from_FrsMaterial( FrsMaterial& m ){ + PyObject *py_m = FrsMaterial_Type.tp_new( &FrsMaterial_Type, 0, 0 ); + ((BPy_FrsMaterial*) py_m)->m = &m; + ((BPy_FrsMaterial*) py_m)->borrowed = 1; + + return py_m; +} + +PyObject * BPy_IntegrationType_from_IntegrationType( IntegrationType i ) { + PyObject *py_it; + + PyObject *args = PyTuple_New(1); + PyTuple_SetItem( args, 0, PyLong_FromLong(i) ); + py_it = IntegrationType_Type.tp_new( &IntegrationType_Type, args, NULL ); + Py_DECREF(args); + + return py_it; +} + +PyObject * BPy_CurvePoint_from_CurvePoint( CurvePoint& cp ) { + PyObject *py_cp = CurvePoint_Type.tp_new( &CurvePoint_Type, 0, 0 ); + ((BPy_CurvePoint*) py_cp)->cp = &cp; + ((BPy_CurvePoint*) py_cp)->py_if0D.if0D = ((BPy_CurvePoint*) py_cp)->cp; + ((BPy_CurvePoint*) py_cp)->py_if0D.borrowed = 1; + + return py_cp; +} + +PyObject * BPy_directedViewEdge_from_directedViewEdge( ViewVertex::directedViewEdge& dve ) { + PyObject *py_dve = PyTuple_New(2); + + PyTuple_SetItem( py_dve, 0, BPy_ViewEdge_from_ViewEdge(*(dve.first)) ); + PyTuple_SetItem( py_dve, 1, PyBool_from_bool(dve.second) ); + + return py_dve; +} + +//============================== +// Iterators +//============================== + +PyObject * BPy_AdjacencyIterator_from_AdjacencyIterator( AdjacencyIterator& a_it ) { + PyObject *py_a_it = AdjacencyIterator_Type.tp_new( &AdjacencyIterator_Type, 0, 0 ); + ((BPy_AdjacencyIterator *) py_a_it)->a_it = new AdjacencyIterator( a_it ); + ((BPy_AdjacencyIterator *) py_a_it)->py_it.it = ((BPy_AdjacencyIterator *) py_a_it)->a_it; + + return py_a_it; +} + +PyObject * BPy_Interface0DIterator_from_Interface0DIterator( Interface0DIterator& if0D_it, int reversed ) { + PyObject *py_if0D_it = Interface0DIterator_Type.tp_new( &Interface0DIterator_Type, 0, 0 ); + ((BPy_Interface0DIterator *) py_if0D_it)->if0D_it = new Interface0DIterator( if0D_it ); + ((BPy_Interface0DIterator *) py_if0D_it)->py_it.it = ((BPy_Interface0DIterator *) py_if0D_it)->if0D_it; + ((BPy_Interface0DIterator *) py_if0D_it)->reversed = reversed; + + return py_if0D_it; +} + +PyObject * BPy_CurvePointIterator_from_CurvePointIterator( CurveInternal::CurvePointIterator& cp_it ) { + PyObject *py_cp_it = CurvePointIterator_Type.tp_new( &CurvePointIterator_Type, 0, 0 ); + ((BPy_CurvePointIterator *) py_cp_it)->cp_it = new CurveInternal::CurvePointIterator( cp_it ); + ((BPy_CurvePointIterator *) py_cp_it)->py_it.it = ((BPy_CurvePointIterator *) py_cp_it)->cp_it; + + return py_cp_it; +} + +PyObject * BPy_StrokeVertexIterator_from_StrokeVertexIterator( StrokeInternal::StrokeVertexIterator& sv_it, int reversed) { + PyObject *py_sv_it = StrokeVertexIterator_Type.tp_new( &StrokeVertexIterator_Type, 0, 0 ); + ((BPy_StrokeVertexIterator *) py_sv_it)->sv_it = new StrokeInternal::StrokeVertexIterator( sv_it ); + ((BPy_StrokeVertexIterator *) py_sv_it)->py_it.it = ((BPy_StrokeVertexIterator *) py_sv_it)->sv_it; + ((BPy_StrokeVertexIterator *) py_sv_it)->reversed = reversed; + + return py_sv_it; +} + +PyObject * BPy_SVertexIterator_from_SVertexIterator( ViewEdgeInternal::SVertexIterator& sv_it ) { + PyObject *py_sv_it = SVertexIterator_Type.tp_new( &SVertexIterator_Type, 0, 0 ); + ((BPy_SVertexIterator *) py_sv_it)->sv_it = new ViewEdgeInternal::SVertexIterator( sv_it ); + ((BPy_SVertexIterator *) py_sv_it)->py_it.it = ((BPy_SVertexIterator *) py_sv_it)->sv_it; + + return py_sv_it; +} + + +PyObject * BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ViewVertexInternal::orientedViewEdgeIterator& ove_it, int reversed ) { + PyObject *py_ove_it = orientedViewEdgeIterator_Type.tp_new( &orientedViewEdgeIterator_Type, 0, 0 ); + ((BPy_orientedViewEdgeIterator *) py_ove_it)->ove_it = new ViewVertexInternal::orientedViewEdgeIterator( ove_it ); + ((BPy_orientedViewEdgeIterator *) py_ove_it)->py_it.it = ((BPy_orientedViewEdgeIterator *) py_ove_it)->ove_it; + ((BPy_orientedViewEdgeIterator *) py_ove_it)->reversed = reversed; + + return py_ove_it; +} + +PyObject * BPy_ViewEdgeIterator_from_ViewEdgeIterator( ViewEdgeInternal::ViewEdgeIterator& ve_it ) { + PyObject *py_ve_it = ViewEdgeIterator_Type.tp_new( &ViewEdgeIterator_Type, 0, 0 ); + ((BPy_ViewEdgeIterator *) py_ve_it)->ve_it = new ViewEdgeInternal::ViewEdgeIterator( ve_it ); + ((BPy_ViewEdgeIterator *) py_ve_it)->py_it.it = ((BPy_ViewEdgeIterator *) py_ve_it)->ve_it; + + return py_ve_it; +} + +PyObject * BPy_ChainingIterator_from_ChainingIterator( ChainingIterator& c_it ) { + PyObject *py_c_it = ChainingIterator_Type.tp_new( &ChainingIterator_Type, 0, 0 ); + ((BPy_ChainingIterator *) py_c_it)->c_it = new ChainingIterator( c_it ); + ((BPy_ChainingIterator *) py_c_it)->py_ve_it.py_it.it = ((BPy_ChainingIterator *) py_c_it)->c_it; + + return py_c_it; +} + +PyObject * BPy_ChainPredicateIterator_from_ChainPredicateIterator( ChainPredicateIterator& cp_it ) { + PyObject *py_cp_it = ChainPredicateIterator_Type.tp_new( &ChainPredicateIterator_Type, 0, 0 ); + ((BPy_ChainPredicateIterator *) py_cp_it)->cp_it = new ChainPredicateIterator( cp_it ); + ((BPy_ChainPredicateIterator *) py_cp_it)->py_c_it.py_ve_it.py_it.it = ((BPy_ChainPredicateIterator *) py_cp_it)->cp_it; + + return py_cp_it; +} + +PyObject * BPy_ChainSilhouetteIterator_from_ChainSilhouetteIterator( ChainSilhouetteIterator& cs_it ) { + PyObject *py_cs_it = ChainSilhouetteIterator_Type.tp_new( &ChainSilhouetteIterator_Type, 0, 0 ); + ((BPy_ChainSilhouetteIterator *) py_cs_it)->cs_it = new ChainSilhouetteIterator( cs_it ); + ((BPy_ChainSilhouetteIterator *) py_cs_it)->py_c_it.py_ve_it.py_it.it = ((BPy_ChainSilhouetteIterator *) py_cs_it)->cs_it; + + return py_cs_it; +} + + +//============================== +// Python => C++ +//============================== + +bool bool_from_PyBool( PyObject *b ) { + return PyObject_IsTrue(b) != 0; +} + +IntegrationType IntegrationType_from_BPy_IntegrationType( PyObject* obj ) { + return static_cast<IntegrationType>( PyLong_AsLong(obj) ); +} + +Stroke::MediumType MediumType_from_BPy_MediumType( PyObject* obj ) { + return static_cast<Stroke::MediumType>( PyLong_AsLong(obj) ); +} + +Nature::EdgeNature EdgeNature_from_BPy_Nature( PyObject* obj ) { + return static_cast<Nature::EdgeNature>( PyLong_AsLong(obj) ); +} + +Vec2f * Vec2f_ptr_from_PyObject( PyObject* obj ) { + Vec2f *v; + if( (v = Vec2f_ptr_from_Vector( obj )) ) + return v; + if( (v = Vec2f_ptr_from_PyList( obj )) ) + return v; + if( (v = Vec2f_ptr_from_PyTuple( obj )) ) + return v; + return NULL; +} + +Vec3f * Vec3f_ptr_from_PyObject( PyObject* obj ) { + Vec3f *v; + if( (v = Vec3f_ptr_from_Vector( obj )) ) + return v; + if( (v = Vec3f_ptr_from_PyList( obj )) ) + return v; + if( (v = Vec3f_ptr_from_PyTuple( obj )) ) + return v; + return NULL; +} + +Vec3r * Vec3r_ptr_from_PyObject( PyObject* obj ) { + Vec3r *v; + if( (v = Vec3r_ptr_from_Vector( obj )) ) + return v; + if( (v = Vec3r_ptr_from_PyList( obj )) ) + return v; + if( (v = Vec3r_ptr_from_PyTuple( obj )) ) + return v; + return NULL; +} + +Vec2f * Vec2f_ptr_from_Vector( PyObject* obj ) { + PyObject *v; + if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 2) + return NULL; + v = PyObject_GetAttrString(obj,"x"); + float x = PyFloat_AsDouble( v ); + Py_DECREF( v ); + v = PyObject_GetAttrString(obj,"y"); + float y = PyFloat_AsDouble( v ); + Py_DECREF( v ); + + return new Vec2f(x,y); +} + +Vec3f * Vec3f_ptr_from_Vector( PyObject* obj ) { + PyObject *v; + if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 3) + return NULL; + v = PyObject_GetAttrString(obj,"x"); + float x = PyFloat_AsDouble( v ); + Py_DECREF( v ); + v = PyObject_GetAttrString(obj,"y"); + float y = PyFloat_AsDouble( v ); + Py_DECREF( v ); + v = PyObject_GetAttrString(obj,"z"); + float z = PyFloat_AsDouble( v ); + Py_DECREF( v ); + + return new Vec3f(x,y,z); +} + +Vec3r * Vec3r_ptr_from_Vector( PyObject* obj ) { + PyObject *v; + if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 3) + return NULL; + v = PyObject_GetAttrString(obj,"x"); + double x = PyFloat_AsDouble( v ); + Py_DECREF( v ); + v = PyObject_GetAttrString(obj,"y"); + double y = PyFloat_AsDouble( v ); + Py_DECREF( v ); + v = PyObject_GetAttrString(obj,"z"); + double z = PyFloat_AsDouble( v ); + Py_DECREF( v ); + + return new Vec3r(x,y,z); +} + +Vec2f * Vec2f_ptr_from_PyList( PyObject* obj ) { + if( !PyList_Check(obj) || PyList_Size(obj) != 2 ) + return NULL; + float x = PyFloat_AsDouble(PyList_GetItem(obj, 0)); + float y = PyFloat_AsDouble(PyList_GetItem(obj, 1)); + return new Vec2f(x,y); +} + +Vec3f * Vec3f_ptr_from_PyList( PyObject* obj ) { + if( !PyList_Check(obj) || PyList_Size(obj) != 3 ) + return NULL; + float x = PyFloat_AsDouble(PyList_GetItem(obj, 0)); + float y = PyFloat_AsDouble(PyList_GetItem(obj, 1)); + float z = PyFloat_AsDouble(PyList_GetItem(obj, 2)); + return new Vec3f(x,y,z); +} + +Vec3r * Vec3r_ptr_from_PyList( PyObject* obj ) { + if( !PyList_Check(obj) || PyList_Size(obj) != 3 ) + return NULL; + float x = PyFloat_AsDouble(PyList_GetItem(obj, 0)); + float y = PyFloat_AsDouble(PyList_GetItem(obj, 1)); + float z = PyFloat_AsDouble(PyList_GetItem(obj, 2)); + return new Vec3r(x,y,z); +} + +Vec2f * Vec2f_ptr_from_PyTuple( PyObject* obj ) { + if( !PyTuple_Check(obj) || PyTuple_Size(obj) != 2 ) + return NULL; + float x = PyFloat_AsDouble(PyTuple_GetItem(obj, 0)); + float y = PyFloat_AsDouble(PyTuple_GetItem(obj, 1)); + return new Vec2f(x,y); +} + +Vec3f * Vec3f_ptr_from_PyTuple( PyObject* obj ) { + if( !PyTuple_Check(obj) || PyTuple_Size(obj) != 3 ) + return NULL; + float x = PyFloat_AsDouble(PyTuple_GetItem(obj, 0)); + float y = PyFloat_AsDouble(PyTuple_GetItem(obj, 1)); + float z = PyFloat_AsDouble(PyTuple_GetItem(obj, 2)); + return new Vec3f(x,y,z); +} + +Vec3r * Vec3r_ptr_from_PyTuple( PyObject* obj ) { + if( !PyTuple_Check(obj) || PyTuple_Size(obj) != 3 ) + return NULL; + float x = PyFloat_AsDouble(PyTuple_GetItem(obj, 0)); + float y = PyFloat_AsDouble(PyTuple_GetItem(obj, 1)); + float z = PyFloat_AsDouble(PyTuple_GetItem(obj, 2)); + return new Vec3r(x,y,z); +} + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/BPy_Convert.h b/source/blender/freestyle/intern/python/BPy_Convert.h new file mode 100644 index 00000000000..7e4e07472d8 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_Convert.h @@ -0,0 +1,147 @@ +#ifndef FREESTYLE_PYTHON_CONVERT_H +#define FREESTYLE_PYTHON_CONVERT_H + +#include <Python.h> +#include <typeinfo> + +#include "../geometry/Geom.h" +using namespace Geometry; + +// BBox +#include "../geometry/BBox.h" + +// FEdge, FEdgeSharp, FEdgeSmooth, SShape, SVertex, FEdgeInternal::SVertexIterator +#include "../view_map/Silhouette.h" + +// Id +#include "../system/Id.h" + +// Interface0D, Interface0DIteratorNested, Interface0DIterator +#include "../view_map/Interface0D.h" + +// Interface1D +#include "../view_map/Interface1D.h" + +// FrsMaterial +#include "../scene_graph/FrsMaterial.h" + +// Nature::VertexNature, Nature::EdgeNature +#include "../winged_edge/Nature.h" + +// Stroke, StrokeAttribute, StrokeVertex +#include "../stroke/Stroke.h" + +// NonTVertex, TVertex, ViewEdge, ViewMap, ViewShape, ViewVertex +#include "../view_map/ViewMap.h" + +// CurvePoint, Curve +#include "../stroke/Curve.h" + +// Chain +#include "../stroke/Chain.h" + +//====== ITERATORS + +// AdjacencyIterator, ChainingIterator, ChainSilhouetteIterator, ChainPredicateIterator +#include "../stroke/ChainingIterators.h" + +// ViewVertexInternal::orientedViewEdgeIterator +// ViewEdgeInternal::SVertexIterator +// ViewEdgeInternal::ViewEdgeIterator +#include "../view_map/ViewMapIterators.h" + +// StrokeInternal::StrokeVertexIterator +#include "../stroke/StrokeIterators.h" + +// CurveInternal::CurvePointIterator +#include "../stroke/CurveIterators.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include "generic/mathutils.h" + +//============================== +// C++ => Python +//============================== + +PyObject * PyBool_from_bool( bool b ); +PyObject * Vector_from_Vec2f( Vec2f& v ); +PyObject * Vector_from_Vec3f( Vec3f& v ); +PyObject * Vector_from_Vec3r( Vec3r& v ); + +PyObject * Any_BPy_Interface0D_from_Interface0D( Interface0D& if0D ); +PyObject * Any_BPy_Interface1D_from_Interface1D( Interface1D& if1D ); +PyObject * Any_BPy_FEdge_from_FEdge( FEdge& fe ); +PyObject * Any_BPy_ViewVertex_from_ViewVertex( ViewVertex& vv ); + +PyObject * BPy_BBox_from_BBox( BBox< Vec3r > &bb ); +PyObject * BPy_CurvePoint_from_CurvePoint( CurvePoint& cp ); +PyObject * BPy_directedViewEdge_from_directedViewEdge( ViewVertex::directedViewEdge& dve ); +PyObject * BPy_FEdge_from_FEdge( FEdge& fe ); +PyObject * BPy_FEdgeSharp_from_FEdgeSharp( FEdgeSharp& fes ); +PyObject * BPy_FEdgeSmooth_from_FEdgeSmooth( FEdgeSmooth& fes ); +PyObject * BPy_Id_from_Id( Id& id ); +PyObject * BPy_Interface0D_from_Interface0D( Interface0D& if0D ); +PyObject * BPy_Interface1D_from_Interface1D( Interface1D& if1D ); +PyObject * BPy_IntegrationType_from_IntegrationType( IntegrationType i ); +PyObject * BPy_FrsMaterial_from_FrsMaterial( FrsMaterial& m ); +PyObject * BPy_Nature_from_Nature( unsigned short n ); +PyObject * BPy_MediumType_from_MediumType( Stroke::MediumType 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_ViewVertex_from_ViewVertex( ViewVertex& vv ); +PyObject * BPy_NonTVertex_from_NonTVertex( NonTVertex& ntv ); +PyObject * BPy_TVertex_from_TVertex( TVertex& tv ); +PyObject * BPy_ViewEdge_from_ViewEdge( ViewEdge& ve ); +PyObject * BPy_Chain_from_Chain( Chain& c ); +PyObject * BPy_ViewShape_from_ViewShape( ViewShape& vs ); + +PyObject * BPy_AdjacencyIterator_from_AdjacencyIterator( AdjacencyIterator& a_it ); +PyObject * BPy_Interface0DIterator_from_Interface0DIterator( Interface0DIterator& if0D_it, int reversed ); +PyObject * BPy_CurvePointIterator_from_CurvePointIterator( CurveInternal::CurvePointIterator& cp_it ); +PyObject * BPy_StrokeVertexIterator_from_StrokeVertexIterator( StrokeInternal::StrokeVertexIterator& sv_it, int reversed); +PyObject * BPy_SVertexIterator_from_SVertexIterator( ViewEdgeInternal::SVertexIterator& sv_it ); +PyObject * BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ViewVertexInternal::orientedViewEdgeIterator& ove_it, int reversed ); +PyObject * BPy_ViewEdgeIterator_from_ViewEdgeIterator( ViewEdgeInternal::ViewEdgeIterator& ve_it ); +PyObject * BPy_ChainingIterator_from_ChainingIterator( ChainingIterator& c_it ); +PyObject * BPy_ChainPredicateIterator_from_ChainPredicateIterator( ChainPredicateIterator& cp_it ); +PyObject * BPy_ChainSilhouetteIterator_from_ChainSilhouetteIterator( ChainSilhouetteIterator& cs_it ); + +//============================== +// Python => C++ +//============================== + +bool bool_from_PyBool( PyObject *b ); +IntegrationType IntegrationType_from_BPy_IntegrationType( PyObject* obj ); +Stroke::MediumType MediumType_from_BPy_MediumType( PyObject* obj ); +Nature::EdgeNature EdgeNature_from_BPy_Nature( PyObject* obj ); +Vec2f * Vec2f_ptr_from_PyObject( PyObject* obj ); +Vec3f * Vec3f_ptr_from_PyObject( PyObject* obj ); +Vec3r * Vec3r_ptr_from_PyObject( PyObject* obj ); +Vec2f * Vec2f_ptr_from_Vector( PyObject* obj ); +Vec3f * Vec3f_ptr_from_Vector( PyObject* obj ); +Vec3r * Vec3r_ptr_from_Vector( PyObject* obj ); +Vec2f * Vec2f_ptr_from_PyList( PyObject* obj ); +Vec3f * Vec3f_ptr_from_PyList( PyObject* obj ); +Vec3r * Vec3r_ptr_from_PyList( PyObject* obj ); +Vec2f * Vec2f_ptr_from_PyTuple( PyObject* obj ); +Vec3f * Vec3f_ptr_from_PyTuple( PyObject* obj ); +Vec3r * Vec3r_ptr_from_PyTuple( PyObject* obj ); + + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_CONVERT_H */ diff --git a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp new file mode 100644 index 00000000000..36a49141fb9 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp @@ -0,0 +1,508 @@ +#include "BPy_Freestyle.h" + +#include "BPy_BBox.h" +#include "BPy_BinaryPredicate0D.h" +#include "BPy_BinaryPredicate1D.h" +#include "BPy_ContextFunctions.h" +#include "BPy_Convert.h" +#include "BPy_FrsMaterial.h" +#include "BPy_FrsNoise.h" +#include "BPy_Id.h" +#include "BPy_IntegrationType.h" +#include "BPy_Interface0D.h" +#include "BPy_Interface1D.h" +#include "BPy_Iterator.h" +#include "BPy_MediumType.h" +#include "BPy_Nature.h" +#include "BPy_Operators.h" +#include "BPy_SShape.h" +#include "BPy_StrokeAttribute.h" +#include "BPy_StrokeShader.h" +#include "BPy_UnaryFunction0D.h" +#include "BPy_UnaryFunction1D.h" +#include "BPy_UnaryPredicate0D.h" +#include "BPy_UnaryPredicate1D.h" +#include "BPy_ViewMap.h" +#include "BPy_ViewShape.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------ MODULE FUNCTIONS ---------------------------------- + +#include "FRS_freestyle.h" +#include "RNA_access.h" +#include "bpy_rna.h" /* pyrna_struct_CreatePyObject() */ + +static char Freestyle_getCurrentScene___doc__[] = +".. function:: getCurrentScene()\n" +"\n" +" Returns the current scene.\n" +"\n" +" :return: The current scene.\n" +" :rtype: :class:`bpy.types.Scene`\n"; + +static PyObject *Freestyle_getCurrentScene( PyObject *self ) +{ + if (!freestyle_scene) { + PyErr_SetString(PyExc_TypeError, "current scene not available"); + return NULL; + } + PointerRNA ptr_scene; + RNA_pointer_create(NULL, &RNA_Scene, freestyle_scene, &ptr_scene); + return pyrna_struct_CreatePyObject(&ptr_scene); +} + +#include "DNA_material_types.h" + +static int ramp_blend_type(const char *type) +{ + if (!strcmp(type, "MIX")) return MA_RAMP_BLEND; + if (!strcmp(type, "ADD")) return MA_RAMP_ADD; + if (!strcmp(type, "MULTIPLY")) return MA_RAMP_MULT; + if (!strcmp(type, "SUBTRACT")) return MA_RAMP_SUB; + if (!strcmp(type, "SCREEN")) return MA_RAMP_SCREEN; + if (!strcmp(type, "DIVIDE")) return MA_RAMP_DIV; + if (!strcmp(type, "DIFFERENCE")) return MA_RAMP_DIFF; + if (!strcmp(type, "DARKEN")) return MA_RAMP_DARK; + if (!strcmp(type, "LIGHTEN")) return MA_RAMP_LIGHT; + if (!strcmp(type, "OVERLAY")) return MA_RAMP_OVERLAY; + if (!strcmp(type, "DODGE")) return MA_RAMP_DODGE; + if (!strcmp(type, "BURN")) return MA_RAMP_BURN; + if (!strcmp(type, "HUE")) return MA_RAMP_HUE; + if (!strcmp(type, "SATURATION")) return MA_RAMP_SAT; + if (!strcmp(type, "VALUE")) return MA_RAMP_VAL; + if (!strcmp(type, "COLOR")) return MA_RAMP_COLOR; + if (!strcmp(type, "SOFT LIGHT")) return MA_RAMP_SOFT; + if (!strcmp(type, "LINEAR LIGHT")) return MA_RAMP_LINEAR; + return -1; +} + +#include "BKE_material.h" /* ramp_blend() */ + +static char Freestyle_blendRamp___doc__[] = +".. function:: blendRamp(type, color1, fac, color2)\n" +"\n" +" Blend two colors according to a ramp blend type.\n" +"\n" +" :arg type: Ramp blend type.\n" +" :type type: int\n" +" :arg color1: 1st color.\n" +" :type color1: :class:`mathutils.Vector`, list or tuple of 3 real numbers\n" +" :arg fac: Blend factor.\n" +" :type fac: float\n" +" :arg color2: 1st color.\n" +" :type color2: :class:`mathutils.Vector`, list or tuple of 3 real numbers\n" +" :return: Blended color in RGB format.\n" +" :rtype: :class:`mathutils.Vector`\n"; + +static PyObject *Freestyle_blendRamp( PyObject *self, PyObject *args ) +{ + PyObject *obj1, *obj2; + char *s; + int type; + Vec3f *v1 = NULL, *v2 = NULL; + float a[3], fac, b[3]; + + if (!PyArg_ParseTuple(args, "sOfO", &s, &obj1, &fac, &obj2)) + return NULL; + type = ramp_blend_type(s); + if (type < 0) { + PyErr_SetString(PyExc_TypeError, "argument 1 is an unknown ramp blend type"); + goto error; + } + v1 = Vec3f_ptr_from_PyObject(obj1); + if (!v1) { + PyErr_SetString(PyExc_TypeError, "argument 2 must be a 3D vector (either a tuple/list of 3 elements or Vector)"); + goto error; + } + v2 = Vec3f_ptr_from_PyObject(obj2); + if (!v2) { + PyErr_SetString(PyExc_TypeError, "argument 4 must be a 3D vector (either a tuple/list of 3 elements or Vector)"); + goto error; + } + a[0] = v1->x(); b[0] = v2->x(); + a[1] = v1->y(); b[1] = v2->y(); + a[2] = v1->z(); b[2] = v2->z(); + ramp_blend(type, &a[0], &a[1], &a[2], fac, b); + delete v1; + delete v2; + return newVectorObject( a, 3, Py_NEW, NULL); + +error: + if (v1) delete v1; + if (v2) delete v2; + return NULL; +} + +#include "BKE_texture.h" /* do_colorband() */ + +static char Freestyle_evaluateColorRamp___doc__[] = +".. function:: evaluateColorRamp(ramp, in)\n" +"\n" +" Evaluate a color ramp at a point in the interval 0 to 1.\n" +"\n" +" :arg ramp: Color ramp object.\n" +" :type ramp: :class:`bpy.types.ColorRamp`\n" +" :arg in: Value in the interval 0 to 1.\n" +" :type in: float\n" +" :return: color in RGBA format.\n" +" :rtype: :class:`mathutils.Vector`\n"; + +static PyObject *Freestyle_evaluateColorRamp( PyObject *self, PyObject *args ) +{ + BPy_StructRNA *py_srna; + ColorBand *coba; + float in, out[4]; + + if(!( PyArg_ParseTuple(args, "O!f", &pyrna_struct_Type, &py_srna, &in) )) + return NULL; + if(!RNA_struct_is_a(py_srna->ptr.type, &RNA_ColorRamp)) { + PyErr_SetString(PyExc_TypeError, "1st argument is not a ColorRamp object"); + return NULL; + } + coba = (ColorBand *)py_srna->ptr.data; + if (!do_colorband(coba, in, out)) { + PyErr_SetString(PyExc_ValueError, "failed to evaluate the color ramp"); + return NULL; + } + return newVectorObject( out, 4, Py_NEW, NULL); +} + +#include "DNA_color_types.h" +#include "BKE_colortools.h" /* curvemapping_evaluateF() */ + +static char Freestyle_evaluateCurveMappingF___doc__[] = +".. function:: evaluateCurveMappingF(cumap, cur, value)\n" +"\n" +" Evaluate a curve mapping at a point in the interval 0 to 1.\n" +"\n" +" :arg cumap: Curve mapping object.\n" +" :type cumap: :class:`bpy.types.CurveMapping`\n" +" :arg cur: Index of the curve to be used (0 <= cur <= 3).\n" +" :type cur: int\n" +" :arg value: Input value in the interval 0 to 1.\n" +" :type value: float\n" +" :return: Mapped output value.\n" +" :rtype: float\n"; + +static PyObject *Freestyle_evaluateCurveMappingF( PyObject *self, PyObject *args ) +{ + BPy_StructRNA *py_srna; + CurveMapping *cumap; + int cur; + float value; + + if(!( PyArg_ParseTuple(args, "O!if", &pyrna_struct_Type, &py_srna, &cur, &value) )) + return NULL; + if(!RNA_struct_is_a(py_srna->ptr.type, &RNA_CurveMapping)) { + PyErr_SetString(PyExc_TypeError, "1st argument is not a CurveMapping object"); + return NULL; + } + if (cur < 0 || cur > 3) { + PyErr_SetString(PyExc_ValueError, "2nd argument is out of range"); + return NULL; + } + cumap = (CurveMapping *)py_srna->ptr.data; + /* disable extrapolation if enabled */ + if ((cumap->cm[cur].flag & CUMA_EXTEND_EXTRAPOLATE)) { + cumap->cm[cur].flag &= ~( CUMA_EXTEND_EXTRAPOLATE ); + curvemapping_changed(cumap, 0); + } + return PyFloat_FromDouble(curvemapping_evaluateF(cumap, cur, value)); +} + +/*-----------------------Freestyle module docstring----------------------------*/ + +static char module_docstring[] = +"This module provides classes for defining line drawing rules (such as\n" +"predicates, functions, chaining iterators, and stroke shaders), as well\n" +"as helper functions for style module writing.\n" +"\n" +"Class hierarchy:\n" +"\n" +"- :class:`BBox`\n" +"- :class:`BinaryPredicate0D`\n" +"- :class:`BinaryPredicate1D`\n" +"\n" +" - :class:`FalseBP1D`\n" +" - :class:`Length2DBP1D`\n" +" - :class:`SameShapeIdBP1D`\n" +" - :class:`TrueBP1D`\n" +" - :class:`ViewMapGradientNormBP1D`\n" +"\n" +"- :class:`Id`\n" +"- :class:`Interface0D`\n" +"\n" +" - :class:`CurvePoint`\n" +"\n" +" - :class:`StrokeVertex`\n" +"\n" +" - :class:`SVertex`\n" +" - :class:`ViewVertex`\n" +"\n" +" - :class:`NonTVertex`\n" +" - :class:`TVertex`\n" +"\n" +"- :class:`Interface1D`\n" +"\n" +" - :class:`Curve`\n" +"\n" +" - :class:`Chain`\n" +"\n" +" - :class:`FEdge`\n" +"\n" +" - :class:`FEdgeSharp`\n" +" - :class:`FEdgeSmooth`\n" +"\n" +" - :class:`Stroke`\n" +" - :class:`ViewEdge`\n" +"\n" +"- :class:`Iterator`\n" +"\n" +" - :class:`AdjacencyIterator`\n" +" - :class:`CurvePointIterator`\n" +" - :class:`Interface0DIterator`\n" +" - :class:`SVertexIterator`\n" +" - :class:`StrokeVertexIterator`\n" +" - :class:`ViewEdgeIterator`\n" +"\n" +" - :class:`ChainingIterator`\n" +"\n" +" - :class:`ChainPredicateIterator`\n" +" - :class:`ChainSilhouetteIterator`\n" +"\n" +" - :class:`orientedViewEdgeIterator`\n" +"\n" +"- :class:`Material`\n" +"- :class:`Noise`\n" +"- :class:`Operators`\n" +"- :class:`SShape`\n" +"- :class:`StrokeAttribute`\n" +"- :class:`StrokeShader`\n" +"\n" +" - :class:`BackboneStretcherShader`\n" +" - :class:`BezierCurveShader`\n" +" - :class:`CalligraphicShader`\n" +" - :class:`ColorNoiseShader`\n" +" - :class:`ColorVariationPatternShader`\n" +" - :class:`ConstantColorShader`\n" +" - :class:`ConstantThicknessShader`\n" +" - :class:`ConstrainedIncreasingThicknessShader`\n" +" - :class:`GuidingLinesShader`\n" +" - :class:`IncreasingColorShader`\n" +" - :class:`IncreasingThicknessShader`\n" +" - :class:`PolygonalizationShader`\n" +" - :class:`SamplingShader`\n" +" - :class:`SmoothingShader`\n" +" - :class:`SpatialNoiseShader`\n" +" - :class:`StrokeTextureShader`\n" +" - :class:`TextureAssignerShader`\n" +" - :class:`ThicknessNoiseShader`\n" +" - :class:`ThicknessVariationPatternShader`\n" +" - :class:`TipRemoverShader`\n" +" - :class:`fstreamShader`\n" +" - :class:`streamShader`\n" +"\n" +"- :class:`UnaryFunction0D`\n" +"\n" +" - :class:`UnaryFunction0DDouble`\n" +"\n" +" - :class:`Curvature2DAngleF0D`\n" +" - :class:`DensityF0D`\n" +" - :class:`GetProjectedXF0D`\n" +" - :class:`GetProjectedYF0D`\n" +" - :class:`GetProjectedZF0D`\n" +" - :class:`GetXF0D`\n" +" - :class:`GetYF0D`\n" +" - :class:`GetZF0D`\n" +" - :class:`LocalAverageDepthF0D`\n" +" - :class:`ZDiscontinuityF0D`\n" +"\n" +" - :class:`UnaryFunction0DEdgeNature`\n" +"\n" +" - :class:`CurveNatureF0D`\n" +"\n" +" - :class:`UnaryFunction0DFloat`\n" +"\n" +" - :class:`GetCurvilinearAbscissaF0D`\n" +" - :class:`GetParameterF0D`\n" +" - :class:`GetViewMapGradientNormF0D`\n" +" - :class:`ReadCompleteViewMapPixelF0D`\n" +" - :class:`ReadMapPixelF0D`\n" +" - :class:`ReadSteerableViewMapPixelF0D`\n" +"\n" +" - :class:`UnaryFunction0DId`\n" +"\n" +" - :class:`ShapeIdF0D`\n" +"\n" +" - :class:`UnaryFunction0DMaterial`\n" +"\n" +" - :class:`MaterialF0D`\n" +"\n" +" - :class:`UnaryFunction0DUnsigned`\n" +"\n" +" - :class:`QuantitativeInvisibilityF0D`\n" +"\n" +" - :class:`UnaryFunction0DVec2f`\n" +"\n" +" - :class:`Normal2DF0D`\n" +" - :class:`VertexOrientation2DF0D`\n" +"\n" +" - :class:`UnaryFunction0DVec3f`\n" +"\n" +" - :class:`VertexOrientation3DF0D`\n" +"\n" +" - :class:`UnaryFunction0DVectorViewShape`\n" +"\n" +" - :class:`GetOccludersF0D`\n" +"\n" +" - :class:`UnaryFunction0DViewShape`\n" +"\n" +" - :class:`GetOccludeeF0D`\n" +" - :class:`GetShapeF0D`\n" +"\n" +"- :class:`UnaryFunction1D`\n" +"\n" +" - :class:`UnaryFunction1DDouble`\n" +"\n" +" - :class:`Curvature2DAngleF1D`\n" +" - :class:`DensityF1D`\n" +" - :class:`GetCompleteViewMapDensityF1D`\n" +" - :class:`GetDirectionalViewMapDensityF1D`\n" +" - :class:`GetProjectedXF1D`\n" +" - :class:`GetProjectedYF1D`\n" +" - :class:`GetProjectedZF1D`\n" +" - :class:`GetSteerableViewMapDensityF1D`\n" +" - :class:`GetViewMapGradientNormF1D`\n" +" - :class:`GetXF1D`\n" +" - :class:`GetYF1D`\n" +" - :class:`GetZF1D`\n" +" - :class:`LocalAverageDepthF1D`\n" +" - :class:`ZDiscontinuityF1D`\n" +"\n" +" - :class:`UnaryFunction1DEdgeNature`\n" +"\n" +" - :class:`CurveNatureF1D`\n" +"\n" +" - :class:`UnaryFunction1DFloat`\n" +" - :class:`UnaryFunction1DUnsigned`\n" +"\n" +" - :class:`QuantitativeInvisibilityF1D`\n" +"\n" +" - :class:`UnaryFunction1DVec2f`\n" +"\n" +" - :class:`Normal2DF1D`\n" +" - :class:`Orientation2DF1D`\n" +"\n" +" - :class:`UnaryFunction1DVec3f`\n" +"\n" +" - :class:`Orientation3DF1D`\n" +"\n" +" - :class:`UnaryFunction1DVectorViewShape`\n" +"\n" +" - :class:`GetOccludeeF1D`\n" +" - :class:`GetOccludersF1D`\n" +" - :class:`GetShapeF1D`\n" +"\n" +" - :class:`UnaryFunction1DVoid`\n" +"\n" +" - :class:`ChainingTimeStampF1D`\n" +" - :class:`IncrementChainingTimeStampF1D`\n" +" - :class:`TimeStampF1D`\n" +"\n" +"- :class:`UnaryPredicate0D`\n" +"\n" +" - :class:`FalseUP0D`\n" +" - :class:`TrueUP0D`\n" +"\n" +"- :class:`UnaryPredicate1D`\n" +"\n" +" - :class:`ContourUP1D`\n" +" - :class:`DensityLowerThanUP1D`\n" +" - :class:`EqualToChainingTimeStampUP1D`\n" +" - :class:`EqualToTimeStampUP1D`\n" +" - :class:`ExternalContourUP1D`\n" +" - :class:`FalseUP1D`\n" +" - :class:`QuantitativeInvisibilityUP1D`\n" +" - :class:`ShapeUP1D`\n" +" - :class:`TrueUP1D`\n" +"\n" +"- :class:`ViewMap`\n" +"- :class:`ViewShape`\n" +"- :class:`IntegrationType`\n" +"- :class:`MediumType`\n" +"- :class:`Nature`\n" +"\n"; + +/*-----------------------Freestyle module method def---------------------------*/ + +static PyMethodDef module_functions[] = { + {"getCurrentScene", ( PyCFunction ) Freestyle_getCurrentScene, METH_NOARGS, Freestyle_getCurrentScene___doc__}, + {"blendRamp", ( PyCFunction ) Freestyle_blendRamp, METH_VARARGS, Freestyle_blendRamp___doc__}, + {"evaluateColorRamp", ( PyCFunction ) Freestyle_evaluateColorRamp, METH_VARARGS, Freestyle_evaluateColorRamp___doc__}, + {"evaluateCurveMappingF", ( PyCFunction ) Freestyle_evaluateCurveMappingF, METH_VARARGS, Freestyle_evaluateCurveMappingF___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------Freestyle module definition---------------------------*/ + +static PyModuleDef module_definition = { + PyModuleDef_HEAD_INIT, + "Freestyle", + module_docstring, + -1, + module_functions +}; + +//-------------------MODULE INITIALIZATION-------------------------------- +PyObject *Freestyle_Init( void ) +{ + PyObject *module; + + // initialize modules + module = PyModule_Create(&module_definition); + if (!module) + return NULL; + PyDict_SetItemString(PySys_GetObject("modules"), module_definition.m_name, module); + + // attach its classes (adding the object types to the module) + + // those classes have to be initialized before the others + MediumType_Init( module ); + Nature_Init( module ); + + BBox_Init( module ); + BinaryPredicate0D_Init( module ); + BinaryPredicate1D_Init( module ); + ContextFunctions_Init( module ); + FrsMaterial_Init( module ); + FrsNoise_Init( module ); + Id_Init( module ); + IntegrationType_Init( module ); + Interface0D_Init( module ); + Interface1D_Init( module ); + Iterator_Init( module ); + Operators_Init( module ); + SShape_Init( module ); + StrokeAttribute_Init( module ); + StrokeShader_Init( module ); + UnaryFunction0D_Init( module ); + UnaryFunction1D_Init( module ); + UnaryPredicate0D_Init( module ); + UnaryPredicate1D_Init( module ); + ViewMap_Init( module ); + ViewShape_Init( module ); + + return module; +} + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/BPy_Freestyle.h b/source/blender/freestyle/intern/python/BPy_Freestyle.h new file mode 100644 index 00000000000..8ade4b5ff4d --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_Freestyle.h @@ -0,0 +1,22 @@ +#ifndef FREESTYLE_PYTHON_FREESTYLE_H +#define FREESTYLE_PYTHON_FREESTYLE_H + +#include <Python.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +/*---------------------------Python BPy_Freestyle visible prototypes-----------*/ + +PyObject *Freestyle_Init( void ); + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_FREESTYLE_H */ diff --git a/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp b/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp new file mode 100644 index 00000000000..b33a9096e81 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp @@ -0,0 +1,599 @@ +#include "BPy_FrsMaterial.h" + +#include "BPy_Convert.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- +int FrsMaterial_Init( PyObject *module ) +{ + if( module == NULL ) + return -1; + + if( PyType_Ready( &FrsMaterial_Type ) < 0 ) + return -1; + + Py_INCREF( &FrsMaterial_Type ); + PyModule_AddObject(module, "Material", (PyObject *)&FrsMaterial_Type); + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char FrsMaterial___doc__[] = +"Class defining a material.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(m)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg m: A Material object.\n" +" :type m: :class:`Material`\n" +"\n" +".. method:: __init__(iDiffuse, iAmbiant, iSpecular, iEmission, iShininess)\n" +"\n" +" Builds a Material from its diffuse, ambiant, specular, emissive\n" +" colors and a shininess coefficient.\n" +"\n" +" :arg iDiffuse: The diffuse color.\n" +" :type iDiffuse: :class:`mathutils.Vector`, list of tuple of 4 float values\n" +" :arg iAmbiant: The ambiant color.\n" +" :type iAmbiant: :class:`mathutils.Vector`, list of tuple of 4 float values\n" +" :arg iSpecular: The specular color.\n" +" :type iSpecular: :class:`mathutils.Vector`, list of tuple of 4 float values\n" +" :arg iEmission: The emissive color.\n" +" :type iEmission: :class:`mathutils.Vector`, list of tuple of 4 float values\n" +" :arg iShininess: The shininess coefficient.\n" +" :type iShininess: :class:`mathutils.Vector`, list of tuple of 4 float values\n"; + +static int Vec4(PyObject *obj, float *v) +{ + if (VectorObject_Check(obj) && ((VectorObject *)obj)->size == 4) { + for (int i = 0; i < 4; i++) + v[i] = ((VectorObject *)obj)->vec[i]; + } else if( PyList_Check(obj) && PyList_Size(obj) == 4 ) { + for (int i = 0; i < 4; i++) + v[i] = PyFloat_AsDouble(PyList_GetItem(obj, i)); + } else if( PyTuple_Check(obj) && PyTuple_Size(obj) == 4 ) { + for (int i = 0; i < 4; i++) + v[i] = PyFloat_AsDouble(PyTuple_GetItem(obj, i)); + } else { + return 0; + } + return 1; +} + +static int FrsMaterial___init__(BPy_FrsMaterial *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0, *obj4 = 0; + float f1[4], f2[4], f3[4], f4[4], f5 = 0.; + + if (! PyArg_ParseTuple(args, "|OOOOf", &obj1, &obj2, &obj3, &obj4, &f5) ) + return -1; + + if( !obj1 ){ + self->m = new FrsMaterial(); + + } else if( BPy_FrsMaterial_Check(obj1) && !obj2 ) { + FrsMaterial *m = ((BPy_FrsMaterial *) obj1)->m; + if( !m ) { + PyErr_SetString(PyExc_RuntimeError, "invalid FrsMaterial object"); + return -1; + } + self->m = new FrsMaterial( *m ); + + } else if( Vec4(obj1, f1) && obj2 && Vec4(obj2, f2) && obj3 && Vec4(obj3, f3) && obj4 && Vec4(obj4, f4) ) { + self->m = new FrsMaterial(f1, f2, f3, f4, f5); + + } else { + PyErr_SetString(PyExc_TypeError, "invalid argument(s)"); + return -1; + } + self->borrowed = 0; + + return 0; +} + +static void FrsMaterial___dealloc__( BPy_FrsMaterial* self) +{ + if( self->m && !self->borrowed ) + delete self->m; + Py_TYPE(self)->tp_free((PyObject*)self); +} + + +static PyObject * FrsMaterial___repr__( BPy_FrsMaterial* self) +{ + return PyUnicode_FromFormat("Material - address: %p", self->m ); +} + +static char FrsMaterial_diffuse___doc__[] = +".. method:: diffuse()\n" +"\n" +" Returns the diffuse color.\n" +"\n" +" :return: The diffuse color.\n" +" :rtype: Tuple of 4 float values\n"; + +static PyObject * FrsMaterial_diffuse( BPy_FrsMaterial* self) { + const float *diffuse = self->m->diffuse(); + PyObject *py_diffuse = PyTuple_New(4); + + PyTuple_SetItem( py_diffuse, 0, PyFloat_FromDouble( diffuse[0] ) ); + PyTuple_SetItem( py_diffuse, 1, PyFloat_FromDouble( diffuse[1] ) ); + PyTuple_SetItem( py_diffuse, 2, PyFloat_FromDouble( diffuse[2] ) ); + PyTuple_SetItem( py_diffuse, 3, PyFloat_FromDouble( diffuse[3] ) ); + + return py_diffuse; +} + +static char FrsMaterial_diffuseR___doc__[] = +".. method:: diffuseR()\n" +"\n" +" Returns the red component of the diffuse color.\n" +"\n" +" :return: The red component of the diffuse color.\n" +" :rtype: float\n"; + +static PyObject * FrsMaterial_diffuseR( BPy_FrsMaterial* self) { + return PyFloat_FromDouble( self->m->diffuseR() ); +} + +static char FrsMaterial_diffuseG___doc__[] = +".. method:: diffuseG()\n" +"\n" +" Returns the green component of the diffuse color.\n" +"\n" +" :return: The green component of the diffuse color.\n" +" :rtype: float\n"; + +static PyObject * FrsMaterial_diffuseG( BPy_FrsMaterial* self) { + return PyFloat_FromDouble( self->m->diffuseG() ); +} + +static char FrsMaterial_diffuseB___doc__[] = +".. method:: diffuseB()\n" +"\n" +" Returns the blue component of the diffuse color.\n" +"\n" +" :return: The blue component of the diffuse color.\n" +" :rtype: float\n"; + +static PyObject * FrsMaterial_diffuseB( BPy_FrsMaterial* self) { + return PyFloat_FromDouble( self->m->diffuseB() ); +} + +static char FrsMaterial_diffuseA___doc__[] = +".. method:: diffuseA()\n" +"\n" +" Returns the alpha component of the diffuse color.\n" +"\n" +" :return: The alpha component of the diffuse color.\n" +" :rtype: float\n"; + +static PyObject * FrsMaterial_diffuseA( BPy_FrsMaterial* self) { + return PyFloat_FromDouble( self->m->diffuseA() ); +} + +static char FrsMaterial_specular___doc__[] = +".. method:: specular()\n" +"\n" +" Returns the specular color.\n" +"\n" +" :return: The specular color.\n" +" :rtype: Tuple of 4 float values\n"; + +static PyObject * FrsMaterial_specular( BPy_FrsMaterial* self) { + const float *specular = self->m->specular(); + PyObject *py_specular = PyTuple_New(4); + + PyTuple_SetItem( py_specular, 0, PyFloat_FromDouble( specular[0] ) ); + PyTuple_SetItem( py_specular, 1, PyFloat_FromDouble( specular[1] ) ); + PyTuple_SetItem( py_specular, 2, PyFloat_FromDouble( specular[2] ) ); + PyTuple_SetItem( py_specular, 3, PyFloat_FromDouble( specular[3] ) ); + + return py_specular; +} + +static char FrsMaterial_specularR___doc__[] = +".. method:: specularR()\n" +"\n" +" Returns the red component of the specular color.\n" +"\n" +" :return: The red component of the specular color.\n" +" :rtype: float\n"; + +static PyObject * FrsMaterial_specularR( BPy_FrsMaterial* self) { + return PyFloat_FromDouble( self->m->specularR() ); +} + +static char FrsMaterial_specularG___doc__[] = +".. method:: specularG()\n" +"\n" +" Returns the green component of the specular color.\n" +"\n" +" :return: The green component of the specular color.\n" +" :rtype: float\n"; + +static PyObject * FrsMaterial_specularG( BPy_FrsMaterial* self) { + return PyFloat_FromDouble( self->m->specularG() ); +} + +static char FrsMaterial_specularB___doc__[] = +".. method:: specularB()\n" +"\n" +" Returns the blue component of the specular color.\n" +"\n" +" :return: The blue component of the specular color.\n" +" :rtype: float\n"; + +static PyObject * FrsMaterial_specularB( BPy_FrsMaterial* self) { + return PyFloat_FromDouble( self->m->specularB() ); +} + +static char FrsMaterial_specularA___doc__[] = +".. method:: specularA()\n" +"\n" +" Returns the alpha component of the specular color.\n" +"\n" +" :return: The alpha component of the specular color.\n" +" :rtype: float\n"; + +static PyObject * FrsMaterial_specularA( BPy_FrsMaterial* self) { + return PyFloat_FromDouble( self->m->specularA() ); +} + +static char FrsMaterial_ambient___doc__[] = +".. method:: ambient()\n" +"\n" +" Returns the ambiant color.\n" +"\n" +" :return: The ambiant color.\n" +" :rtype: Tuple of 4 float values\n"; + +static PyObject * FrsMaterial_ambient( BPy_FrsMaterial* self) { + const float *ambient = self->m->ambient(); + PyObject *py_ambient = PyTuple_New(4); + + PyTuple_SetItem( py_ambient, 0, PyFloat_FromDouble( ambient[0] ) ); + PyTuple_SetItem( py_ambient, 1, PyFloat_FromDouble( ambient[1] ) ); + PyTuple_SetItem( py_ambient, 2, PyFloat_FromDouble( ambient[2] ) ); + PyTuple_SetItem( py_ambient, 3, PyFloat_FromDouble( ambient[3] ) ); + + return py_ambient; +} + +static char FrsMaterial_ambientR___doc__[] = +".. method:: ambientR()\n" +"\n" +" Returns the red component of the ambiant color.\n" +"\n" +" :return: The red component of the ambiant color.\n" +" :rtype: float\n"; + +static PyObject * FrsMaterial_ambientR( BPy_FrsMaterial* self) { + return PyFloat_FromDouble( self->m->ambientR() ); +} + +static char FrsMaterial_ambientG___doc__[] = +".. method:: ambientG()\n" +"\n" +" Returns the green component of the ambiant color.\n" +"\n" +" :return: The green component of the ambiant color.\n" +" :rtype: float\n"; + +static PyObject * FrsMaterial_ambientG( BPy_FrsMaterial* self) { + return PyFloat_FromDouble( self->m->ambientG() ); +} + +static char FrsMaterial_ambientB___doc__[] = +".. method:: ambientB()\n" +"\n" +" Returns the blue component of the ambiant color.\n" +"\n" +" :return: The blue component of the ambiant color.\n" +" :rtype: float\n"; + +static PyObject * FrsMaterial_ambientB( BPy_FrsMaterial* self) { + return PyFloat_FromDouble( self->m->ambientB() ); +} + +static char FrsMaterial_ambientA___doc__[] = +".. method:: ambientA()\n" +"\n" +" Returns the alpha component of the ambiant color.\n" +"\n" +" :return: The alpha component of the ambiant color.\n" +" :rtype: float\n"; + +static PyObject * FrsMaterial_ambientA( BPy_FrsMaterial* self) { + return PyFloat_FromDouble( self->m->ambientA() ); +} + +static char FrsMaterial_emission___doc__[] = +".. method:: emission()\n" +"\n" +" Returns the emissive color.\n" +"\n" +" :return: the emissive color.\n" +" :rtype: Tuple of 4 float values\n"; + +static PyObject * FrsMaterial_emission( BPy_FrsMaterial* self) { + const float *emission = self->m->emission(); + PyObject *py_emission = PyTuple_New(4); + + PyTuple_SetItem( py_emission, 0, PyFloat_FromDouble( emission[0] ) ); + PyTuple_SetItem( py_emission, 1, PyFloat_FromDouble( emission[1] ) ); + PyTuple_SetItem( py_emission, 2, PyFloat_FromDouble( emission[2] ) ); + PyTuple_SetItem( py_emission, 3, PyFloat_FromDouble( emission[3] ) ); + + return py_emission; +} + +static char FrsMaterial_emissionR___doc__[] = +".. method:: emissionR()\n" +"\n" +" Returns the red component of the emissive color.\n" +"\n" +" :return: The red component of the emissive color.\n" +" :rtype: float\n"; + +static PyObject * FrsMaterial_emissionR( BPy_FrsMaterial* self) { + return PyFloat_FromDouble( self->m->emissionR() ); +} + +static char FrsMaterial_emissionG___doc__[] = +".. method:: emissionG()\n" +"\n" +" Returns the green component of the emissive color.\n" +"\n" +" :return: The green component of the emissive color.\n" +" :rtype: float\n"; + +static PyObject * FrsMaterial_emissionG( BPy_FrsMaterial* self) { + return PyFloat_FromDouble( self->m->emissionG() ); +} + +static char FrsMaterial_emissionB___doc__[] = +".. method:: emissionB()\n" +"\n" +" Returns the blue component of the emissive color.\n" +"\n" +" :return: The blue component of the emissive color.\n" +" :rtype: float\n"; + +static PyObject * FrsMaterial_emissionB( BPy_FrsMaterial* self) { + return PyFloat_FromDouble( self->m->emissionB() ); +} + +static char FrsMaterial_emissionA___doc__[] = +".. method:: emissionA()\n" +"\n" +" Returns the alpha component of the emissive color.\n" +"\n" +" :return: The alpha component of the emissive color.\n" +" :rtype: float\n"; + +static PyObject * FrsMaterial_emissionA( BPy_FrsMaterial* self) { + return PyFloat_FromDouble( self->m->emissionA() ); +} + +static char FrsMaterial_shininess___doc__[] = +".. method:: shininess()\n" +"\n" +" Returns the shininess coefficient.\n" +"\n" +" :return: Shininess\n" +" :rtype: float\n"; + +static PyObject * FrsMaterial_shininess( BPy_FrsMaterial* self) { + return PyFloat_FromDouble( self->m->shininess() ); +} + +static char FrsMaterial_setDiffuse___doc__[] = +".. method:: setDiffuse(r, g, b, a)\n" +"\n" +" Sets the diffuse color.\n" +"\n" +" :arg r: Red component.\n" +" :type r: float\n" +" :arg g: Green component.\n" +" :type g: float\n" +" :arg b: Blue component.\n" +" :type b: float\n" +" :arg a: Alpha component.\n" +" :type a: float\n"; + +static PyObject * FrsMaterial_setDiffuse( BPy_FrsMaterial *self, PyObject *args ) { + float f1, f2, f3, f4; + + if(!( PyArg_ParseTuple(args, "ffff", &f1, &f2, &f3, &f4) )) + return NULL; + + self->m->setDiffuse(f1, f2, f3, f4); + + Py_RETURN_NONE; +} + +static char FrsMaterial_setSpecular___doc__[] = +".. method:: setSpecular(r, g, b, a)\n" +"\n" +" Sets the specular color.\n" +"\n" +" :arg r: Red component.\n" +" :type r: float\n" +" :arg g: Green component.\n" +" :type g: float\n" +" :arg b: Blue component.\n" +" :type b: float\n" +" :arg a: Alpha component.\n" +" :type a: float\n"; + +static PyObject * FrsMaterial_setSpecular( BPy_FrsMaterial *self, PyObject *args ) { + float f1, f2, f3, f4; + + if(!( PyArg_ParseTuple(args, "ffff", &f1, &f2, &f3, &f4) )) + return NULL; + + self->m->setSpecular(f1, f2, f3, f4); + + Py_RETURN_NONE; +} + +static char FrsMaterial_setAmbient___doc__[] = +".. method:: setAmbient(r, g, b, a)\n" +"\n" +" Sets the ambiant color.\n" +"\n" +" :arg r: Red component.\n" +" :type r: float\n" +" :arg g: Green component.\n" +" :type g: float\n" +" :arg b: Blue component.\n" +" :type b: float\n" +" :arg a: Alpha component.\n" +" :type a: float\n"; + +static PyObject * FrsMaterial_setAmbient( BPy_FrsMaterial *self, PyObject *args ) { + float f1, f2, f3, f4; + + if(!( PyArg_ParseTuple(args, "ffff", &f1, &f2, &f3, &f4) )) + return NULL; + + self->m->setAmbient(f1, f2, f3, f4); + + Py_RETURN_NONE; +} + +static char FrsMaterial_setEmission___doc__[] = +".. method:: setEmission(r, g, b, a)\n" +"\n" +" Sets the emissive color.\n" +"\n" +" :arg r: Red component.\n" +" :type r: float\n" +" :arg g: Green component.\n" +" :type g: float\n" +" :arg b: Blue component.\n" +" :type b: float\n" +" :arg a: Alpha component.\n" +" :type a: float\n"; + +static PyObject * FrsMaterial_setEmission( BPy_FrsMaterial *self, PyObject *args ) { + float f1, f2, f3, f4; + + if(!( PyArg_ParseTuple(args, "ffff", &f1, &f2, &f3, &f4) )) + return NULL; + + self->m->setEmission(f1, f2, f3, f4); + + Py_RETURN_NONE; +} + +static char FrsMaterial_setShininess___doc__[] = +".. method:: setShininess(s)\n" +"\n" +" Sets the shininess.\n" +"\n" +" :arg s: Shininess.\n" +" :type s: float\n"; + +static PyObject * FrsMaterial_setShininess( BPy_FrsMaterial *self, PyObject *args ) { + float f; + + if(!( PyArg_ParseTuple(args, "f", &f) )) + return NULL; + + self->m->setShininess(f); + + Py_RETURN_NONE; +} + +/*----------------------FrsMaterial instance definitions ----------------------------*/ +static PyMethodDef BPy_FrsMaterial_methods[] = { + {"diffuse", ( PyCFunction ) FrsMaterial_diffuse, METH_NOARGS, FrsMaterial_diffuse___doc__}, + {"diffuseR", ( PyCFunction ) FrsMaterial_diffuseR, METH_NOARGS, FrsMaterial_diffuseR___doc__}, + {"diffuseG", ( PyCFunction ) FrsMaterial_diffuseG, METH_NOARGS, FrsMaterial_diffuseG___doc__}, + {"diffuseB", ( PyCFunction ) FrsMaterial_diffuseB, METH_NOARGS, FrsMaterial_diffuseB___doc__}, + {"diffuseA", ( PyCFunction ) FrsMaterial_diffuseA, METH_NOARGS, FrsMaterial_diffuseA___doc__}, + {"specular", ( PyCFunction ) FrsMaterial_specular, METH_NOARGS, FrsMaterial_specular___doc__}, + {"specularR", ( PyCFunction ) FrsMaterial_specularR, METH_NOARGS, FrsMaterial_specularR___doc__}, + {"specularG", ( PyCFunction ) FrsMaterial_specularG, METH_NOARGS, FrsMaterial_specularG___doc__}, + {"specularB", ( PyCFunction ) FrsMaterial_specularB, METH_NOARGS, FrsMaterial_specularB___doc__}, + {"specularA", ( PyCFunction ) FrsMaterial_specularA, METH_NOARGS, FrsMaterial_specularA___doc__}, + {"ambient", ( PyCFunction ) FrsMaterial_ambient, METH_NOARGS, FrsMaterial_ambient___doc__}, + {"ambientR", ( PyCFunction ) FrsMaterial_ambientR, METH_NOARGS, FrsMaterial_ambientR___doc__}, + {"ambientG", ( PyCFunction ) FrsMaterial_ambientG, METH_NOARGS, FrsMaterial_ambientG___doc__}, + {"ambientB", ( PyCFunction ) FrsMaterial_ambientB, METH_NOARGS, FrsMaterial_ambientB___doc__}, + {"ambientA", ( PyCFunction ) FrsMaterial_ambientA, METH_NOARGS, FrsMaterial_ambientA___doc__}, + {"emission", ( PyCFunction ) FrsMaterial_emission, METH_NOARGS, FrsMaterial_emission___doc__}, + {"emissionR", ( PyCFunction ) FrsMaterial_emissionR, METH_NOARGS, FrsMaterial_emissionR___doc__}, + {"emissionG", ( PyCFunction ) FrsMaterial_emissionG, METH_NOARGS, FrsMaterial_emissionG___doc__}, + {"emissionB", ( PyCFunction ) FrsMaterial_emissionB, METH_NOARGS, FrsMaterial_emissionB___doc__}, + {"emissionA", ( PyCFunction ) FrsMaterial_emissionA, METH_NOARGS, FrsMaterial_emissionA___doc__}, + {"shininess", ( PyCFunction ) FrsMaterial_shininess, METH_NOARGS, FrsMaterial_shininess___doc__}, + {"setDiffuse", ( PyCFunction ) FrsMaterial_setDiffuse, METH_NOARGS, FrsMaterial_setDiffuse___doc__}, + {"setSpecular", ( PyCFunction ) FrsMaterial_setSpecular, METH_NOARGS, FrsMaterial_setSpecular___doc__}, + {"setAmbient", ( PyCFunction ) FrsMaterial_setAmbient, METH_NOARGS, FrsMaterial_setAmbient___doc__}, + {"setEmission", ( PyCFunction ) FrsMaterial_setEmission, METH_NOARGS, FrsMaterial_setEmission___doc__}, + {"setShininess", ( PyCFunction ) FrsMaterial_setShininess, METH_NOARGS, FrsMaterial_setShininess___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_FrsMaterial type definition ------------------------------*/ + +PyTypeObject FrsMaterial_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "Material", /* tp_name */ + sizeof(BPy_FrsMaterial), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)FrsMaterial___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)FrsMaterial___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + FrsMaterial___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_FrsMaterial_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)FrsMaterial___init__, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/BPy_FrsMaterial.h b/source/blender/freestyle/intern/python/BPy_FrsMaterial.h new file mode 100644 index 00000000000..f541e1bb529 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_FrsMaterial.h @@ -0,0 +1,37 @@ +#ifndef FREESTYLE_PYTHON_FRSMATERIAL_H +#define FREESTYLE_PYTHON_FRSMATERIAL_H + +#include <Python.h> + +#include "../scene_graph/FrsMaterial.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +extern PyTypeObject FrsMaterial_Type; + +#define BPy_FrsMaterial_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &FrsMaterial_Type) ) + +/*---------------------------Python BPy_FrsMaterial structure definition----------*/ +typedef struct { + PyObject_HEAD + FrsMaterial *m; + int borrowed; /* non-zero if *m is a borrowed object */ +} BPy_FrsMaterial; + +/*---------------------------Python BPy_FrsMaterial visible prototypes-----------*/ + +int FrsMaterial_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_FRSMATERIAL_H */ diff --git a/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp b/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp new file mode 100644 index 00000000000..bd2b5a4dad0 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp @@ -0,0 +1,274 @@ +#include "BPy_FrsNoise.h" +#include "BPy_Convert.h" + +#include <sstream> + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- +int FrsNoise_Init( PyObject *module ) +{ + if( module == NULL ) + return -1; + + if( PyType_Ready( &FrsNoise_Type ) < 0 ) + return -1; + + Py_INCREF( &FrsNoise_Type ); + PyModule_AddObject(module, "Noise", (PyObject *)&FrsNoise_Type); + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char FrsNoise___doc__[] = +"Class to provide Perlin noise functionalities.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a Noise object.\n"; + +static int FrsNoise___init__(BPy_FrsNoise *self, PyObject *args, PyObject *kwds) +{ + if(!( PyArg_ParseTuple(args, "") )) + return -1; + self->n = new Noise(); + return 0; +} + +static void FrsNoise___dealloc__(BPy_FrsNoise* self) +{ + delete self->n; + Py_TYPE(self)->tp_free((PyObject*)self); +} + + +static PyObject * FrsNoise___repr__(BPy_FrsNoise* self) +{ + return PyUnicode_FromFormat("Noise - address: %p", self->n ); +} + +static char FrsNoise_turbulence1___doc__[] = +".. method:: turbulence1(v, freq, amp, oct=4)\n" +"\n" +" Returns a noise value for a 1D element.\n" +"\n" +" :arg v: One-dimensional sample point.\n" +" :type v: float\n" +" :arg freq: Noise frequency.\n" +" :type freq: float\n" +" :arg amp: Amplitude.\n" +" :type amp: float\n" +" :arg oct: Number of octaves.\n" +" :type oct: int\n" +" :return: A noise value.\n" +" :rtype: float\n"; + +static PyObject * FrsNoise_turbulence1( BPy_FrsNoise *self , PyObject *args) { + float f1, f2, f3; + unsigned int i = 4; + + if(!( PyArg_ParseTuple(args, "fff|I", &f1, &f2, &f3, &i) )) + return NULL; + + return PyFloat_FromDouble( self->n->turbulence1(f1, f2, f3, i) ); +} + +static char FrsNoise_turbulence2___doc__[] = +".. method:: turbulence2(v, freq, amp, oct=4)\n" +"\n" +" Returns a noise value for a 2D element.\n" +"\n" +" :arg v: Two-dimensional sample point.\n" +" :type v: :class:`mathutils.Vector`, list or tuple of 2 real numbers\n" +" :arg freq: Noise frequency.\n" +" :type freq: float\n" +" :arg amp: Amplitude.\n" +" :type amp: float\n" +" :arg oct: Number of octaves.\n" +" :type oct: int\n" +" :return: A noise value.\n" +" :rtype: float\n"; + +static PyObject * FrsNoise_turbulence2( BPy_FrsNoise *self , PyObject *args) { + PyObject *obj1; + float f2, f3; + unsigned int i = 4; + + if(!( PyArg_ParseTuple(args, "Off|I", &obj1, &f2, &f3, &i) )) + return NULL; + Vec2f *v = Vec2f_ptr_from_PyObject(obj1); + if( !v ) { + PyErr_SetString(PyExc_TypeError, "argument 1 must be a 2D vector (either a list of 2 elements or Vector)"); + return NULL; + } + float t = self->n->turbulence2(*v, f2, f3, i); + delete v; + return PyFloat_FromDouble( t ); +} + +static char FrsNoise_turbulence3___doc__[] = +".. method:: turbulence3(v, freq, amp, oct=4)\n" +"\n" +" Returns a noise value for a 3D element.\n" +"\n" +" :arg v: Three-dimensional sample point.\n" +" :type v: :class:`mathutils.Vector`, list or tuple of 3 real numbers\n" +" :arg freq: Noise frequency.\n" +" :type freq: float\n" +" :arg amp: Amplitude.\n" +" :type amp: float\n" +" :arg oct: Number of octaves.\n" +" :type oct: int\n" +" :return: A noise value.\n" +" :rtype: float\n"; + +static PyObject * FrsNoise_turbulence3( BPy_FrsNoise *self , PyObject *args) { + PyObject *obj1; + float f2, f3; + unsigned int i = 4; + + if(!( PyArg_ParseTuple(args, "Off|I", &obj1, &f2, &f3, &i) )) + return NULL; + Vec3f *v = Vec3f_ptr_from_PyObject(obj1); + if( !v ) { + PyErr_SetString(PyExc_TypeError, "argument 1 must be a 3D vector (either a list of 3 elements or Vector)"); + return NULL; + } + float t = self->n->turbulence3(*v, f2, f3, i); + delete v; + return PyFloat_FromDouble( t ); +} + +static char FrsNoise_smoothNoise1___doc__[] = +".. method:: smoothNoise1(v)\n" +"\n" +" Returns a smooth noise value for a 1D element.\n" +"\n" +" :arg v: One-dimensional sample point.\n" +" :type v: float\n" +" :return: A smooth noise value.\n" +" :rtype: float\n"; + +static PyObject * FrsNoise_smoothNoise1( BPy_FrsNoise *self , PyObject *args) { + float f; + + if(!( PyArg_ParseTuple(args, "f", &f) )) + return NULL; + + return PyFloat_FromDouble( self->n->smoothNoise1(f) ); +} + +static char FrsNoise_smoothNoise2___doc__[] = +".. method:: smoothNoise2(v)\n" +"\n" +" Returns a smooth noise value for a 2D element.\n" +"\n" +" :arg v: Two-dimensional sample point.\n" +" :type v: :class:`mathutils.Vector`, list or tuple of 2 real numbers\n" +" :return: A smooth noise value.\n" +" :rtype: float\n"; + +static PyObject * FrsNoise_smoothNoise2( BPy_FrsNoise *self , PyObject *args) { + PyObject *obj; + + if(!( PyArg_ParseTuple(args, "O", &obj) )) + return NULL; + Vec2f *v = Vec2f_ptr_from_PyObject(obj); + if( !v ) { + PyErr_SetString(PyExc_TypeError, "argument 1 must be a 2D vector (either a list of 2 elements or Vector)"); + return NULL; + } + float t = self->n->smoothNoise2(*v); + delete v; + return PyFloat_FromDouble( t ); +} + +static char FrsNoise_smoothNoise3___doc__[] = +".. method:: smoothNoise3(v)\n" +"\n" +" Returns a smooth noise value for a 3D element.\n" +"\n" +" :arg v: Three-dimensional sample point.\n" +" :type v: :class:`mathutils.Vector`, list or tuple of 3 real numbers\n" +" :return: A smooth noise value.\n" +" :rtype: float\n"; + +static PyObject * FrsNoise_smoothNoise3( BPy_FrsNoise *self , PyObject *args) { + PyObject *obj; + + if(!( PyArg_ParseTuple(args, "O", &obj) )) + return NULL; + Vec3f *v = Vec3f_ptr_from_PyObject(obj); + if( !v ) { + PyErr_SetString(PyExc_TypeError, "argument 1 must be a 3D vector (either a list of 3 elements or Vector)"); + return NULL; + } + float t = self->n->smoothNoise3(*v); + delete v; + return PyFloat_FromDouble( t ); +} + +/*----------------------FrsNoise instance definitions ----------------------------*/ +static PyMethodDef BPy_FrsNoise_methods[] = { + {"turbulence1", ( PyCFunction ) FrsNoise_turbulence1, METH_VARARGS, FrsNoise_turbulence1___doc__}, + {"turbulence2", ( PyCFunction ) FrsNoise_turbulence2, METH_VARARGS, FrsNoise_turbulence2___doc__}, + {"turbulence3", ( PyCFunction ) FrsNoise_turbulence3, METH_VARARGS, FrsNoise_turbulence3___doc__}, + {"smoothNoise1", ( PyCFunction ) FrsNoise_smoothNoise1, METH_VARARGS, FrsNoise_smoothNoise1___doc__}, + {"smoothNoise2", ( PyCFunction ) FrsNoise_smoothNoise2, METH_VARARGS, FrsNoise_smoothNoise2___doc__}, + {"smoothNoise3", ( PyCFunction ) FrsNoise_smoothNoise3, METH_VARARGS, FrsNoise_smoothNoise3___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_FrsNoise type definition ------------------------------*/ + +PyTypeObject FrsNoise_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "Noise", /* tp_name */ + sizeof(BPy_FrsNoise), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)FrsNoise___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)FrsNoise___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + FrsNoise___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_FrsNoise_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)FrsNoise___init__, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/BPy_FrsNoise.h b/source/blender/freestyle/intern/python/BPy_FrsNoise.h new file mode 100644 index 00000000000..00b4f3375bc --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_FrsNoise.h @@ -0,0 +1,36 @@ +#ifndef FREESTYLE_PYTHON_FRSNOISE_H +#define FREESTYLE_PYTHON_FRSNOISE_H + +#include <Python.h> + +#include "../geometry/Noise.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +extern PyTypeObject FrsNoise_Type; + +#define BPy_FrsNoise_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &FrsNoise_Type) ) + +/*---------------------------Python BPy_FrsNoise structure definition----------*/ +typedef struct { + PyObject_HEAD + Noise *n; +} BPy_FrsNoise; + +/*---------------------------Python BPy_FrsNoise visible prototypes-----------*/ + +int FrsNoise_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_FRSNOISE_H */ diff --git a/source/blender/freestyle/intern/python/BPy_Id.cpp b/source/blender/freestyle/intern/python/BPy_Id.cpp new file mode 100644 index 00000000000..9254badd95d --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_Id.cpp @@ -0,0 +1,222 @@ +#include "BPy_Id.h" + +#include "BPy_Convert.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- +int Id_Init( PyObject *module ) +{ + if( module == NULL ) + return -1; + + if( PyType_Ready( &Id_Type ) < 0 ) + return -1; + + Py_INCREF( &Id_Type ); + PyModule_AddObject(module, "Id", (PyObject *)&Id_Type); + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char Id___doc__[] = +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(iBrother)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg iBrother: An Id object.\n" +" :type iBrother: :class:`Id`\n" +"\n" +".. method:: __init__(iFirst)\n" +"\n" +" Builds an Id from an integer. The second number is set to 0.\n" +"\n" +" :arg iFirst: The first Id number.\n" +" :type iFirst: int\n" +"\n" +".. method:: __init__(iFirst, iSecond)\n" +"\n" +" Builds the Id from the two numbers.\n" +"\n" +" :arg iFirst: The first Id number.\n" +" :type iFirst: int\n" +" :arg iSecond: The second Id number.\n" +" :type iSecond: int\n"; + +static int Id___init__(BPy_Id *self, PyObject *args, PyObject *kwds) +{ + int first = 0, second = 0; + static char *kwlist[] = {"first", "second", NULL}; + + if (! PyArg_ParseTupleAndKeywords(args, kwds, "|ii", kwlist, &first, &second) ) + return -1; + + self->id = new Id( first, second ); + + return 0; +} + +static void Id___dealloc__(BPy_Id* self) +{ + delete self->id; + Py_TYPE(self)->tp_free((PyObject*)self); +} + +static PyObject * Id___repr__(BPy_Id* self) +{ + return PyUnicode_FromFormat("[ first: %i, second: %i ](BPy_Id)", self->id->getFirst(), self->id->getSecond() ); +} + +static char Id_getFirst___doc__[] = +".. method:: getFirst()\n" +"\n" +" Returns the first Id number.\n" +"\n" +" :return: The first Id number.\n" +" :rtype: int\n"; + +static PyObject *Id_getFirst( BPy_Id *self ) { + return PyLong_FromLong( self->id->getFirst() ); +} + +static char Id_getSecond___doc__[] = +".. method:: getSecond()\n" +"\n" +" Returns the second Id number.\n" +"\n" +" :return: The second Id number.\n" +" :rtype: int\n"; + +static PyObject *Id_getSecond( BPy_Id *self) { + return PyLong_FromLong( self->id->getSecond() ); +} + +static char Id_setFirst___doc__[] = +".. method:: setFirst(iFirst)\n" +"\n" +" Sets the first number constituting the Id.\n" +"\n" +" :arg iFirst: The first number constituting the Id.\n" +" :type iFirst: int\n"; + +static PyObject *Id_setFirst( BPy_Id *self , PyObject *args) { + unsigned int i; + + if( !PyArg_ParseTuple(args, "i", &i) ) + return NULL; + + self->id->setFirst( i ); + + Py_RETURN_NONE; +} + +static char Id_setSecond___doc__[] = +".. method:: setSecond(iSecond)\n" +"\n" +" Sets the second number constituting the Id.\n" +"\n" +" :arg iSecond: The second number constituting the Id.\n" +" :type iSecond: int\n"; + +static PyObject *Id_setSecond( BPy_Id *self , PyObject *args) { + unsigned int i; + + if( !PyArg_ParseTuple(args, "i", &i) ) + return NULL; + + self->id->setSecond( i ); + + Py_RETURN_NONE; +} + +static PyObject * Id_RichCompare(BPy_Id *o1, BPy_Id *o2, int opid) { + switch(opid){ + case Py_LT: + return PyBool_from_bool( o1->id->operator<(*(o2->id)) ); + break; + case Py_LE: + return PyBool_from_bool( o1->id->operator<(*(o2->id)) || o1->id->operator<(*(o2->id)) ); + break; + case Py_EQ: + return PyBool_from_bool( o1->id->operator==(*(o2->id)) ); + break; + case Py_NE: + return PyBool_from_bool( o1->id->operator!=(*(o2->id)) ); + break; + case Py_GT: + return PyBool_from_bool(!( o1->id->operator<(*(o2->id)) || o1->id->operator<(*(o2->id)) )); + break; + case Py_GE: + return PyBool_from_bool(!( o1->id->operator<(*(o2->id)) )); + break; + } + + Py_RETURN_NONE; +} + +/*----------------------Id instance definitions ----------------------------*/ +static PyMethodDef BPy_Id_methods[] = { + {"getFirst", ( PyCFunction ) Id_getFirst, METH_NOARGS, Id_getFirst___doc__}, + {"getSecond", ( PyCFunction ) Id_getSecond, METH_NOARGS, Id_getSecond___doc__}, + {"setFirst", ( PyCFunction ) Id_setFirst, METH_VARARGS, Id_setFirst___doc__}, + {"setSecond", ( PyCFunction ) Id_setSecond, METH_VARARGS, Id_setSecond___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_Id type definition ------------------------------*/ + +PyTypeObject Id_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "Id", /* tp_name */ + sizeof(BPy_Id), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)Id___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)Id___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + Id___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + (richcmpfunc)Id_RichCompare, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_Id_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Id___init__, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/BPy_Id.h b/source/blender/freestyle/intern/python/BPy_Id.h new file mode 100644 index 00000000000..10f370f8a80 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_Id.h @@ -0,0 +1,36 @@ +#ifndef FREESTYLE_PYTHON_ID_H +#define FREESTYLE_PYTHON_ID_H + +#include <Python.h> +#include <iostream> +using namespace std; + +#include "../system/Id.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +extern PyTypeObject Id_Type; + +#define BPy_Id_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &Id_Type) ) + +/*---------------------------Python BPy_Id structure definition----------*/ +typedef struct { + PyObject_HEAD + Id *id; +} BPy_Id; + +/*---------------------------Python BPy_Id visible prototypes-----------*/ + +int Id_Init( PyObject *module ); + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_ID_H */ diff --git a/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp b/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp new file mode 100644 index 00000000000..9ce20632a25 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp @@ -0,0 +1,250 @@ +#include "BPy_IntegrationType.h" + +#include "BPy_Convert.h" +#include "UnaryFunction0D/BPy_UnaryFunction0DDouble.h" +#include "UnaryFunction0D/BPy_UnaryFunction0DFloat.h" +#include "UnaryFunction0D/BPy_UnaryFunction0DUnsigned.h" +#include "Iterator/BPy_Interface0DIterator.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------ MODULE FUNCTIONS ---------------------------------- + +static char Integrator_integrate___doc__[] = +".. function:: integrate(fun, it, it_end, integration_type)\n" +"\n" +" Returns a single value from a set of values evaluated at each 0D\n" +" element of this 1D element.\n" +"\n" +" :arg fun: The UnaryFunction0D used to compute a value at each\n" +" Interface0D.\n" +" :type fun: :class:`UnaryFunction0D`\n" +" :arg it: The Interface0DIterator used to iterate over the 0D\n" +" elements of this 1D element. The integration will occur over\n" +" the 0D elements starting from the one pointed by it.\n" +" :type it: :class:`Interface0DIterator`\n" +" :arg it_end: The Interface0DIterator pointing the end of the 0D\n" +" elements of the 1D element.\n" +" :type it_end: :class:`Interface0DIterator`\n" +" :arg integration_type: The integration method used to compute a\n" +" single value from a set of values.\n" +" :type integration_type: :class:`IntegrationType`\n" +" :return: The single value obtained for the 1D element. The return\n" +" value type is float if fun is of the :class:`UnaryFunction0DDouble`\n" +" or :class:`UnaryFunction0DFloat` type, and int if fun is of the\n" +" :class:`UnaryFunction0DUnsigned` type.\n" +" :rtype: int or float\n"; + +static PyObject * Integrator_integrate( PyObject *self, PyObject *args ) +{ + PyObject *obj1, *obj4 = 0; + BPy_Interface0DIterator *obj2, *obj3; + +#if 1 + if(!( PyArg_ParseTuple(args, "O!O!O!|O!", &UnaryFunction0D_Type, &obj1, + &Interface0DIterator_Type, &obj2, &Interface0DIterator_Type, &obj3, + &IntegrationType_Type, &obj4) )) + return NULL; +#else + if(!( PyArg_ParseTuple(args, "OOO|O", &obj1, &obj2, &obj3, &obj4) )) + return NULL; + if(!BPy_UnaryFunction0D_Check(obj1)) { + PyErr_SetString(PyExc_TypeError, "argument 1 must be a UnaryFunction0D object"); + return NULL; + } + if(!BPy_Interface0DIterator_Check(obj2)) { + PyErr_SetString(PyExc_TypeError, "argument 2 must be a Interface0DIterator object"); + return NULL; + } + if(!BPy_Interface0DIterator_Check(obj3)) { + PyErr_SetString(PyExc_TypeError, "argument 3 must be a Interface0DIterator object"); + return NULL; + } + if(obj4 && !BPy_IntegrationType_Check(obj4)) { + PyErr_SetString(PyExc_TypeError, "argument 4 must be a IntegrationType object"); + return NULL; + } +#endif + + Interface0DIterator it(*(obj2->if0D_it)), it_end(*(obj3->if0D_it)); + IntegrationType t = ( obj4 ) ? IntegrationType_from_BPy_IntegrationType( obj4 ) : MEAN; + + if( BPy_UnaryFunction0DDouble_Check(obj1) ) { + UnaryFunction0D<double> *fun = ((BPy_UnaryFunction0DDouble *)obj1)->uf0D_double; + double res = integrate( *fun, it, it_end, t ); + return PyFloat_FromDouble( res ); + + } else if( BPy_UnaryFunction0DFloat_Check(obj1) ) { + UnaryFunction0D<float> *fun = ((BPy_UnaryFunction0DFloat *)obj1)->uf0D_float; + float res = integrate( *fun, it, it_end, t ); + return PyFloat_FromDouble( res ); + + } else if( BPy_UnaryFunction0DUnsigned_Check(obj1) ) { + UnaryFunction0D<unsigned int> *fun = ((BPy_UnaryFunction0DUnsigned *)obj1)->uf0D_unsigned; + unsigned int res = integrate( *fun, it, it_end, t ); + return PyLong_FromLong( res ); + + } else { + string msg("unsupported function type: " + string(obj1->ob_type->tp_name)); + PyErr_SetString(PyExc_TypeError, msg.c_str()); + return NULL; + } +} + +/*-----------------------Integrator module docstring---------------------------------------*/ + +static char module_docstring[] = "The Blender Freestyle.Integrator submodule\n\n"; + +/*-----------------------Integrator module functions definitions---------------------------*/ + +static PyMethodDef module_functions[] = { + {"integrate", (PyCFunction) Integrator_integrate, METH_VARARGS, Integrator_integrate___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------Integrator module definition--------------------------------------*/ + +static PyModuleDef module_definition = { + PyModuleDef_HEAD_INIT, + "Freestyle.Integrator", + module_docstring, + -1, + module_functions +}; + +/*-----------------------BPy_IntegrationType type definition ------------------------------*/ + +static char IntegrationType___doc__[] = +"Class hierarchy: int > :class:`IntegrationType`\n" +"\n" +"Different integration methods that can be invoked to integrate into a\n" +"single value the set of values obtained from each 0D element of an 1D\n" +"element:\n" +"\n" +"* IntegrationType.MEAN: The value computed for the 1D element is the\n" +" mean of the values obtained for the 0D elements.\n" +"* IntegrationType.MIN: The value computed for the 1D element is the\n" +" minimum of the values obtained for the 0D elements.\n" +"* IntegrationType.MAX: The value computed for the 1D element is the\n" +" maximum of the values obtained for the 0D elements.\n" +"* IntegrationType.FIRST: The value computed for the 1D element is the\n" +" first of the values obtained for the 0D elements.\n" +"* IntegrationType.LAST: The value computed for the 1D element is the\n" +" last of the values obtained for the 0D elements.\n"; + +PyTypeObject IntegrationType_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "IntegrationType", /* tp_name */ + sizeof(PyLongObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + IntegrationType___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &PyLong_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/*-----------------------BPy_IntegrationType instance definitions -------------------------*/ + +static PyLongObject _IntegrationType_MEAN = { + PyVarObject_HEAD_INIT(&IntegrationType_Type, 1) + { MEAN } +}; +static PyLongObject _IntegrationType_MIN = { + PyVarObject_HEAD_INIT(&IntegrationType_Type, 1) + { MIN } +}; +static PyLongObject _IntegrationType_MAX = { + PyVarObject_HEAD_INIT(&IntegrationType_Type, 1) + { MAX } +}; +static PyLongObject _IntegrationType_FIRST = { + PyVarObject_HEAD_INIT(&IntegrationType_Type, 1) + { FIRST } +}; +static PyLongObject _IntegrationType_LAST = { + PyVarObject_HEAD_INIT(&IntegrationType_Type, 1) + { LAST } +}; + +#define BPy_IntegrationType_MEAN ((PyObject *)&_IntegrationType_MEAN) +#define BPy_IntegrationType_MIN ((PyObject *)&_IntegrationType_MIN) +#define BPy_IntegrationType_MAX ((PyObject *)&_IntegrationType_MAX) +#define BPy_IntegrationType_FIRST ((PyObject *)&_IntegrationType_FIRST) +#define BPy_IntegrationType_LAST ((PyObject *)&_IntegrationType_LAST) + +//-------------------MODULE INITIALIZATION-------------------------------- +int IntegrationType_Init( PyObject *module ) +{ + PyObject *m, *d, *f; + + if( module == NULL ) + return -1; + + if( PyType_Ready( &IntegrationType_Type ) < 0 ) + return -1; + Py_INCREF( &IntegrationType_Type ); + PyModule_AddObject(module, "IntegrationType", (PyObject *)&IntegrationType_Type); + + PyDict_SetItemString( IntegrationType_Type.tp_dict, "MEAN", BPy_IntegrationType_MEAN); + PyDict_SetItemString( IntegrationType_Type.tp_dict, "MIN", BPy_IntegrationType_MIN); + PyDict_SetItemString( IntegrationType_Type.tp_dict, "MAX", BPy_IntegrationType_MAX); + PyDict_SetItemString( IntegrationType_Type.tp_dict, "FIRST", BPy_IntegrationType_FIRST); + PyDict_SetItemString( IntegrationType_Type.tp_dict, "LAST", BPy_IntegrationType_LAST); + + m = PyModule_Create(&module_definition); + if (m == NULL) + return -1; + Py_INCREF(m); + PyModule_AddObject(module, "Integrator", m); + + // from Integrator import * + d = PyModule_GetDict(m); + for (PyMethodDef *p = module_functions; p->ml_name; p++) { + f = PyDict_GetItemString(d, p->ml_name); + Py_INCREF(f); + PyModule_AddObject(module, p->ml_name, f); + } + + return 0; +} + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + diff --git a/source/blender/freestyle/intern/python/BPy_IntegrationType.h b/source/blender/freestyle/intern/python/BPy_IntegrationType.h new file mode 100644 index 00000000000..f15ae8309e3 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_IntegrationType.h @@ -0,0 +1,28 @@ +#ifndef FREESTYLE_PYTHON_INTEGRATIONTYPE_H +#define FREESTYLE_PYTHON_INTEGRATIONTYPE_H + +#include <Python.h> + +#include "../view_map/Interface1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +extern PyTypeObject IntegrationType_Type; + +#define BPy_IntegrationType_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &IntegrationType_Type) ) + +/*---------------------------Python BPy_IntegrationType visible prototypes-----------*/ + +int IntegrationType_Init( PyObject *module ); + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_INTEGRATIONTYPE_H */ diff --git a/source/blender/freestyle/intern/python/BPy_Interface0D.cpp b/source/blender/freestyle/intern/python/BPy_Interface0D.cpp new file mode 100644 index 00000000000..11af30439cf --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_Interface0D.cpp @@ -0,0 +1,354 @@ +#include "BPy_Interface0D.h" + +#include "BPy_Convert.h" +#include "Interface0D/BPy_CurvePoint.h" +#include "Interface0D/CurvePoint/BPy_StrokeVertex.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 "BPy_Nature.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- +int Interface0D_Init( PyObject *module ) +{ + if( module == NULL ) + return -1; + + if( PyType_Ready( &Interface0D_Type ) < 0 ) + return -1; + Py_INCREF( &Interface0D_Type ); + PyModule_AddObject(module, "Interface0D", (PyObject *)&Interface0D_Type); + + if( PyType_Ready( &CurvePoint_Type ) < 0 ) + return -1; + Py_INCREF( &CurvePoint_Type ); + PyModule_AddObject(module, "CurvePoint", (PyObject *)&CurvePoint_Type); + + if( PyType_Ready( &SVertex_Type ) < 0 ) + return -1; + Py_INCREF( &SVertex_Type ); + PyModule_AddObject(module, "SVertex", (PyObject *)&SVertex_Type); + + if( PyType_Ready( &ViewVertex_Type ) < 0 ) + return -1; + Py_INCREF( &ViewVertex_Type ); + PyModule_AddObject(module, "ViewVertex", (PyObject *)&ViewVertex_Type); + + if( PyType_Ready( &StrokeVertex_Type ) < 0 ) + return -1; + Py_INCREF( &StrokeVertex_Type ); + PyModule_AddObject(module, "StrokeVertex", (PyObject *)&StrokeVertex_Type); + + if( PyType_Ready( &NonTVertex_Type ) < 0 ) + return -1; + Py_INCREF( &NonTVertex_Type ); + PyModule_AddObject(module, "NonTVertex", (PyObject *)&NonTVertex_Type); + + if( PyType_Ready( &TVertex_Type ) < 0 ) + return -1; + Py_INCREF( &TVertex_Type ); + PyModule_AddObject(module, "TVertex", (PyObject *)&TVertex_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char Interface0D___doc__[] = +"Base class for any 0D element.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n"; + +static int Interface0D___init__(BPy_Interface0D *self, PyObject *args, PyObject *kwds) +{ + if ( !PyArg_ParseTuple(args, "") ) + return -1; + self->if0D = new Interface0D(); + self->borrowed = 0; + return 0; +} + +static void Interface0D___dealloc__(BPy_Interface0D* self) +{ + if( self->if0D && !self->borrowed ) + delete self->if0D; + Py_TYPE(self)->tp_free((PyObject*)self); +} + +static PyObject * Interface0D___repr__(BPy_Interface0D* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->if0D->getExactTypeName().c_str(), self->if0D ); +} + +static char Interface0D_getExactTypeName___doc__[] = +".. method:: getExactTypeName()\n" +"\n" +" Returns the name of the 0D element.\n" +"\n" +" :return: Name of the interface.\n" +" :rtype: str\n"; + +static PyObject *Interface0D_getExactTypeName( BPy_Interface0D *self ) { + return PyUnicode_FromString( self->if0D->getExactTypeName().c_str() ); +} + +static char Interface0D_getX___doc__[] = +".. method:: getX()\n" +"\n" +" Returns the X coordinate of the 3D point of the 0D element.\n" +"\n" +" :return: The X coordinate of the 3D point.\n" +" :rtype: float\n"; + +static PyObject *Interface0D_getX( BPy_Interface0D *self ) { + double x = self->if0D->getX(); + if (PyErr_Occurred()) + return NULL; + return PyFloat_FromDouble( x ); +} + +static char Interface0D_getY___doc__[] = +".. method:: getY()\n" +"\n" +" Returns the Y coordinate of the 3D point of the 0D element.\n" +"\n" +" :return: The Y coordinate of the 3D point.\n" +" :rtype: float\n"; + +static PyObject *Interface0D_getY( BPy_Interface0D *self ) { + double y = self->if0D->getY(); + if (PyErr_Occurred()) + return NULL; + return PyFloat_FromDouble( y ); +} + +static char Interface0D_getZ___doc__[] = +".. method:: getZ()\n" +"\n" +" Returns the Z coordinate of the 3D point of the 0D element.\n" +"\n" +" :return: The Z coordinate of the 3D point.\n" +" :rtype: float\n"; + +static PyObject *Interface0D_getZ( BPy_Interface0D *self ) { + double z = self->if0D->getZ(); + if (PyErr_Occurred()) + return NULL; + return PyFloat_FromDouble( z ); +} + +static char Interface0D_getPoint3D___doc__[] = +".. method:: getPoint3D()\n" +"\n" +" Returns the location of the 0D element in the 3D space.\n" +"\n" +" :return: The 3D point of the 0D element.\n" +" :rtype: :class:`mathutils.Vector`\n"; + +static PyObject *Interface0D_getPoint3D( BPy_Interface0D *self ) { + Vec3f v( self->if0D->getPoint3D() ); + if (PyErr_Occurred()) + return NULL; + return Vector_from_Vec3f( v ); +} + +static char Interface0D_getProjectedX___doc__[] = +".. method:: getProjectedX()\n" +"\n" +" Returns the X coordinate of the 2D point of the 0D element.\n" +"\n" +" :return: The X coordinate of the 2D point.\n" +" :rtype: float\n"; + +static PyObject *Interface0D_getProjectedX( BPy_Interface0D *self ) { + double x = self->if0D->getProjectedX(); + if (PyErr_Occurred()) + return NULL; + return PyFloat_FromDouble( x ); +} + +static char Interface0D_getProjectedY___doc__[] = +".. method:: getProjectedY()\n" +"\n" +" Returns the Y coordinate of the 2D point of the 0D element.\n" +"\n" +" :return: The Y coordinate of the 2D point.\n" +" :rtype: float\n"; + +static PyObject *Interface0D_getProjectedY( BPy_Interface0D *self ) { + double y = self->if0D->getProjectedY(); + if (PyErr_Occurred()) + return NULL; + return PyFloat_FromDouble( y ); +} + +static char Interface0D_getProjectedZ___doc__[] = +".. method:: getProjectedZ()\n" +"\n" +" Returns the Z coordinate of the 2D point of the 0D element.\n" +"\n" +" :return: The Z coordinate of the 2D point.\n" +" :rtype: float\n"; + +static PyObject *Interface0D_getProjectedZ( BPy_Interface0D *self ) { + double z = self->if0D->getProjectedZ(); + if (PyErr_Occurred()) + return NULL; + return PyFloat_FromDouble( z ); +} + +static char Interface0D_getPoint2D___doc__[] = +".. method:: getPoint2D()\n" +"\n" +" Returns the location of the 0D element in the 2D space.\n" +"\n" +" :return: The 2D point of the 0D element.\n" +" :rtype: :class:`mathutils.Vector`\n"; + +static PyObject *Interface0D_getPoint2D( BPy_Interface0D *self ) { + Vec2f v( self->if0D->getPoint2D() ); + if (PyErr_Occurred()) + return NULL; + return Vector_from_Vec2f( v ); +} + +static char Interface0D_getFEdge___doc__[] = +".. method:: getFEdge(inter)\n" +"\n" +" Returns the FEdge that lies between this 0D element and the 0D\n" +" element given as the argument.\n" +"\n" +" :arg inter: A 0D element.\n" +" :type inter: :class:`Interface0D`\n" +" :return: The FEdge lying between the two 0D elements.\n" +" :rtype: :class:`FEdge`\n"; + +static PyObject *Interface0D_getFEdge( BPy_Interface0D *self, PyObject *args ) { + PyObject *py_if0D; + + if(!( PyArg_ParseTuple(args, "O!", &Interface0D_Type, &py_if0D) )) + return NULL; + + FEdge *fe = self->if0D->getFEdge(*( ((BPy_Interface0D *) py_if0D)->if0D )); + if (PyErr_Occurred()) + return NULL; + if( fe ) + return Any_BPy_FEdge_from_FEdge( *fe ); + + Py_RETURN_NONE; +} + +static char Interface0D_getId___doc__[] = +".. method:: getId()\n" +"\n" +" Returns the identifier of the 0D element.\n" +"\n" +" :return: The identifier of the 0D element.\n" +" :rtype: :class:`Id`\n"; + +static PyObject *Interface0D_getId( BPy_Interface0D *self ) { + Id id( self->if0D->getId() ); + if (PyErr_Occurred()) + return NULL; + return BPy_Id_from_Id( id ); +} + +static char Interface0D_getNature___doc__[] = +".. method:: getNature()\n" +"\n" +" Returns the nature of the 0D element.\n" +"\n" +" :return: The nature of the 0D element.\n" +" :rtype: :class:`Nature`\n"; + +static PyObject *Interface0D_getNature( BPy_Interface0D *self ) { + Nature::VertexNature nature = self->if0D->getNature(); + if (PyErr_Occurred()) + return NULL; + return BPy_Nature_from_Nature( nature ); +} + +/*----------------------Interface0D instance definitions ----------------------------*/ +static PyMethodDef BPy_Interface0D_methods[] = { + {"getExactTypeName", ( PyCFunction ) Interface0D_getExactTypeName, METH_NOARGS, Interface0D_getExactTypeName___doc__}, + {"getX", ( PyCFunction ) Interface0D_getX, METH_NOARGS, Interface0D_getX___doc__}, + {"getY", ( PyCFunction ) Interface0D_getY, METH_NOARGS, Interface0D_getY___doc__}, + {"getZ", ( PyCFunction ) Interface0D_getZ, METH_NOARGS, Interface0D_getZ___doc__}, + {"getPoint3D", ( PyCFunction ) Interface0D_getPoint3D, METH_NOARGS, Interface0D_getPoint3D___doc__}, + {"getProjectedX", ( PyCFunction ) Interface0D_getProjectedX, METH_NOARGS, Interface0D_getProjectedX___doc__}, + {"getProjectedY", ( PyCFunction ) Interface0D_getProjectedY, METH_NOARGS, Interface0D_getProjectedY___doc__}, + {"getProjectedZ", ( PyCFunction ) Interface0D_getProjectedZ, METH_NOARGS, Interface0D_getProjectedZ___doc__}, + {"getPoint2D", ( PyCFunction ) Interface0D_getPoint2D, METH_NOARGS, Interface0D_getPoint2D___doc__}, + {"getFEdge", ( PyCFunction ) Interface0D_getFEdge, METH_VARARGS, Interface0D_getFEdge___doc__}, + {"getId", ( PyCFunction ) Interface0D_getId, METH_NOARGS, Interface0D_getId___doc__}, + {"getNature", ( PyCFunction ) Interface0D_getNature, METH_NOARGS, Interface0D_getNature___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_Interface0D type definition ------------------------------*/ + +PyTypeObject Interface0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "Interface0D", /* tp_name */ + sizeof(BPy_Interface0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)Interface0D___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)Interface0D___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + Interface0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_Interface0D_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Interface0D___init__, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ + 0 /* tp_del */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + diff --git a/source/blender/freestyle/intern/python/BPy_Interface0D.h b/source/blender/freestyle/intern/python/BPy_Interface0D.h new file mode 100644 index 00000000000..25134db5352 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_Interface0D.h @@ -0,0 +1,35 @@ +#ifndef FREESTYLE_PYTHON_INTERFACE0D_H +#define FREESTYLE_PYTHON_INTERFACE0D_H + +#include <Python.h> + +#include "../view_map/Interface0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +extern PyTypeObject Interface0D_Type; + +#define BPy_Interface0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &Interface0D_Type) ) + +/*---------------------------Python BPy_Interface0D structure definition----------*/ +typedef struct { + PyObject_HEAD + Interface0D *if0D; + int borrowed; /* non-zero if *if0D is a borrowed object */ +} BPy_Interface0D; + +/*---------------------------Python BPy_Interface0D visible prototypes-----------*/ + +int Interface0D_Init( PyObject *module ); + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_INTERFACE0D_H */ diff --git a/source/blender/freestyle/intern/python/BPy_Interface1D.cpp b/source/blender/freestyle/intern/python/BPy_Interface1D.cpp new file mode 100644 index 00000000000..7b4bdddf70c --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_Interface1D.cpp @@ -0,0 +1,337 @@ +#include "BPy_Interface1D.h" + +#include "BPy_Convert.h" +#include "Interface1D/BPy_FrsCurve.h" +#include "Interface1D/Curve/BPy_Chain.h" +#include "Interface1D/BPy_FEdge.h" +#include "Interface1D/FEdge/BPy_FEdgeSharp.h" +#include "Interface1D/FEdge/BPy_FEdgeSmooth.h" +#include "Interface1D/BPy_Stroke.h" +#include "Interface1D/BPy_ViewEdge.h" + +#include "BPy_MediumType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- +int Interface1D_Init( PyObject *module ) +{ + if( module == NULL ) + return -1; + + if( PyType_Ready( &Interface1D_Type ) < 0 ) + return -1; + Py_INCREF( &Interface1D_Type ); + PyModule_AddObject(module, "Interface1D", (PyObject *)&Interface1D_Type); + + if( PyType_Ready( &FrsCurve_Type ) < 0 ) + return -1; + Py_INCREF( &FrsCurve_Type ); + PyModule_AddObject(module, "Curve", (PyObject *)&FrsCurve_Type); + + if( PyType_Ready( &Chain_Type ) < 0 ) + return -1; + Py_INCREF( &Chain_Type ); + PyModule_AddObject(module, "Chain", (PyObject *)&Chain_Type); + + if( PyType_Ready( &FEdge_Type ) < 0 ) + return -1; + Py_INCREF( &FEdge_Type ); + PyModule_AddObject(module, "FEdge", (PyObject *)&FEdge_Type); + + if( PyType_Ready( &FEdgeSharp_Type ) < 0 ) + return -1; + Py_INCREF( &FEdgeSharp_Type ); + PyModule_AddObject(module, "FEdgeSharp", (PyObject *)&FEdgeSharp_Type); + + if( PyType_Ready( &FEdgeSmooth_Type ) < 0 ) + return -1; + Py_INCREF( &FEdgeSmooth_Type ); + PyModule_AddObject(module, "FEdgeSmooth", (PyObject *)&FEdgeSmooth_Type); + + if( PyType_Ready( &Stroke_Type ) < 0 ) + return -1; + Py_INCREF( &Stroke_Type ); + PyModule_AddObject(module, "Stroke", (PyObject *)&Stroke_Type); + + PyDict_SetItemString( Stroke_Type.tp_dict, "DRY_MEDIUM", BPy_MediumType_DRY_MEDIUM ); + PyDict_SetItemString( Stroke_Type.tp_dict, "HUMID_MEDIUM", BPy_MediumType_HUMID_MEDIUM ); + PyDict_SetItemString( Stroke_Type.tp_dict, "OPAQUE_MEDIUM", BPy_MediumType_OPAQUE_MEDIUM ); + + if( PyType_Ready( &ViewEdge_Type ) < 0 ) + return -1; + Py_INCREF( &ViewEdge_Type ); + PyModule_AddObject(module, "ViewEdge", (PyObject *)&ViewEdge_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char Interface1D___doc__[] = +"Base class for any 1D element.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n"; + +static int Interface1D___init__(BPy_Interface1D *self, PyObject *args, PyObject *kwds) +{ + if ( !PyArg_ParseTuple(args, "") ) + return -1; + self->if1D = new Interface1D(); + self->borrowed = 0; + return 0; +} + +static void Interface1D___dealloc__(BPy_Interface1D* self) +{ + if( self->if1D && !self->borrowed ) + delete self->if1D; + Py_TYPE(self)->tp_free((PyObject*)self); +} + +static PyObject * Interface1D___repr__(BPy_Interface1D* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->if1D->getExactTypeName().c_str(), self->if1D ); +} + +static char Interface1D_getExactTypeName___doc__[] = +".. method:: getExactTypeName()\n" +"\n" +" Returns the string of the name of the 1D element.\n" +"\n" +" :return: The name of the 1D element.\n" +" :rtype: str\n"; + +static PyObject *Interface1D_getExactTypeName( BPy_Interface1D *self ) { + return PyUnicode_FromString( self->if1D->getExactTypeName().c_str() ); +} + +#if 0 +static PyObject *Interface1D_getVertices( BPy_Interface1D *self ) { + return PyList_New(0); +} + +static PyObject *Interface1D_getPoints( BPy_Interface1D *self ) { + return PyList_New(0); +} +#endif + +static char Interface1D_getLength2D___doc__[] = +".. method:: getLength2D()\n" +"\n" +" Returns the 2D length of the 1D element.\n" +"\n" +" :return: The 2D length of the 1D element.\n" +" :rtype: float\n"; + +static PyObject *Interface1D_getLength2D( BPy_Interface1D *self ) { + return PyFloat_FromDouble( (double) self->if1D->getLength2D() ); +} + +static char Interface1D_getId___doc__[] = +".. method:: getId()\n" +"\n" +" Returns the Id of the 1D element .\n" +"\n" +" :return: The Id of the 1D element .\n" +" :rtype: :class:`Id`\n"; + +static PyObject *Interface1D_getId( BPy_Interface1D *self ) { + Id id( self->if1D->getId() ); + return BPy_Id_from_Id( id ); +} + +static char Interface1D_getNature___doc__[] = +".. method:: getNature()\n" +"\n" +" Returns the nature of the 1D element.\n" +"\n" +" :return: The nature of the 1D element.\n" +" :rtype: :class:`Nature`\n"; + +static PyObject *Interface1D_getNature( BPy_Interface1D *self ) { + return BPy_Nature_from_Nature( self->if1D->getNature() ); +} + +static char Interface1D_getTimeStamp___doc__[] = +".. method:: getTimeStamp()\n" +"\n" +" Returns the time stamp of the 1D element. Mainly used for selection.\n" +"\n" +" :return: The time stamp of the 1D element.\n" +" :rtype: int\n"; + +static PyObject *Interface1D_getTimeStamp( BPy_Interface1D *self ) { + return PyLong_FromLong( self->if1D->getTimeStamp() ); +} + +static char Interface1D_setTimeStamp___doc__[] = +".. method:: setTimeStamp(iTimeStamp)\n" +"\n" +" Sets the time stamp for the 1D element.\n" +"\n" +" :arg iTimeStamp: A time stamp.\n" +" :type iTimeStamp: int\n"; + +static PyObject *Interface1D_setTimeStamp( BPy_Interface1D *self, PyObject *args) { + int timestamp = 0 ; + + if( !PyArg_ParseTuple(args, "i", ×tamp) ) + return NULL; + + self->if1D->setTimeStamp( timestamp ); + + Py_RETURN_NONE; +} + +static char Interface1D_verticesBegin___doc__[] = +".. method:: verticesBegin()\n" +"\n" +" Returns an iterator over the Interface1D vertices, pointing to the\n" +" first vertex.\n" +"\n" +" :return: An Interface0DIterator pointing to the first vertex.\n" +" :rtype: :class:`Interface0DIterator`\n"; + +static PyObject * Interface1D_verticesBegin( BPy_Interface1D *self ) { + Interface0DIterator if0D_it( self->if1D->verticesBegin() ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 0 ); +} + +static char Interface1D_verticesEnd___doc__[] = +".. method:: verticesEnd()\n" +"\n" +" Returns an iterator over the Interface1D vertices, pointing after\n" +" the last vertex.\n" +"\n" +" :return: An Interface0DIterator pointing after the last vertex.\n" +" :rtype: :class:`Interface0DIterator`\n"; + +static PyObject * Interface1D_verticesEnd( BPy_Interface1D *self ) { + Interface0DIterator if0D_it( self->if1D->verticesEnd() ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 1 ); +} + +static char Interface1D_pointsBegin___doc__[] = +".. method:: pointsBegin(t=0.0)\n" +"\n" +" Returns an iterator over the Interface1D points, pointing to the\n" +" first point. The difference with verticesBegin() is that here we can\n" +" iterate over points of the 1D element at a any given sampling.\n" +" Indeed, for each iteration, a virtual point is created.\n" +"\n" +" :arg t: A sampling with which we want to iterate over points of\n" +" this 1D element.\n" +" :type t: float\n" +" :return: An Interface0DIterator pointing to the first point.\n" +" :rtype: :class:`Interface0DIterator`\n"; + +static PyObject * Interface1D_pointsBegin( BPy_Interface1D *self, PyObject *args ) { + float f = 0; + + if(!( PyArg_ParseTuple(args, "|f", &f) )) + return NULL; + + Interface0DIterator if0D_it( self->if1D->pointsBegin(f) ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 0 ); +} + +static char Interface1D_pointsEnd___doc__[] = +".. method:: pointsEnd(t=0.0)\n" +"\n" +" Returns an iterator over the Interface1D points, pointing after the\n" +" last point. The difference with verticesEnd() is that here we can\n" +" iterate over points of the 1D element at a given sampling. Indeed,\n" +" for each iteration, a virtual point is created.\n" +"\n" +" :arg t: A sampling with which we want to iterate over points of\n" +" this 1D element.\n" +" :type t: float\n" +" :return: An Interface0DIterator pointing after the last point.\n" +" :rtype: :class:`Interface0DIterator`\n"; + +static PyObject * Interface1D_pointsEnd( BPy_Interface1D *self, PyObject *args ) { + float f = 0; + + if(!( PyArg_ParseTuple(args, "|f", &f) )) + return NULL; + + Interface0DIterator if0D_it( self->if1D->pointsEnd(f) ); + return BPy_Interface0DIterator_from_Interface0DIterator( if0D_it, 1 ); +} + +/*----------------------Interface1D instance definitions ----------------------------*/ +static PyMethodDef BPy_Interface1D_methods[] = { + {"getExactTypeName", ( PyCFunction ) Interface1D_getExactTypeName, METH_NOARGS, Interface1D_getExactTypeName___doc__}, +#if 0 + {"getVertices", ( PyCFunction ) Interface1D_getVertices, METH_NOARGS, "Returns the vertices"}, + {"getPoints", ( PyCFunction ) Interface1D_getPoints, METH_NOARGS, "Returns the points. The difference with getVertices() is that here we can iterate over points of the 1D element at any given sampling. At each call, a virtual point is created."}, +#endif + {"getLength2D", ( PyCFunction ) Interface1D_getLength2D, METH_NOARGS, Interface1D_getLength2D___doc__}, + {"getId", ( PyCFunction ) Interface1D_getId, METH_NOARGS, Interface1D_getId___doc__}, + {"getNature", ( PyCFunction ) Interface1D_getNature, METH_NOARGS, Interface1D_getNature___doc__}, + {"getTimeStamp", ( PyCFunction ) Interface1D_getTimeStamp, METH_NOARGS, Interface1D_getTimeStamp___doc__}, + {"setTimeStamp", ( PyCFunction ) Interface1D_setTimeStamp, METH_VARARGS, Interface1D_setTimeStamp___doc__}, + {"verticesBegin", ( PyCFunction ) Interface1D_verticesBegin, METH_NOARGS, Interface1D_verticesBegin___doc__}, + {"verticesEnd", ( PyCFunction ) Interface1D_verticesEnd, METH_NOARGS, Interface1D_verticesEnd___doc__}, + {"pointsBegin", ( PyCFunction ) Interface1D_pointsBegin, METH_VARARGS, Interface1D_pointsBegin___doc__}, + {"pointsEnd", ( PyCFunction ) Interface1D_pointsEnd, METH_VARARGS, Interface1D_pointsEnd___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_Interface1D type definition ------------------------------*/ + +PyTypeObject Interface1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "Interface1D", /* tp_name */ + sizeof(BPy_Interface1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)Interface1D___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)Interface1D___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + Interface1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_Interface1D_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Interface1D___init__, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + diff --git a/source/blender/freestyle/intern/python/BPy_Interface1D.h b/source/blender/freestyle/intern/python/BPy_Interface1D.h new file mode 100644 index 00000000000..75eefa1836f --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_Interface1D.h @@ -0,0 +1,36 @@ +#ifndef FREESTYLE_PYTHON_INTERFACE1D_H +#define FREESTYLE_PYTHON_INTERFACE1D_H + +#include <Python.h> + +#include "../view_map/Interface1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +extern PyTypeObject Interface1D_Type; + +#define BPy_Interface1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &Interface1D_Type) ) + +/*---------------------------Python BPy_Interface1D structure definition----------*/ +typedef struct { + PyObject_HEAD + Interface1D *if1D; + int borrowed; /* non-zero if *if1D is a borrowed object */ +} BPy_Interface1D; + +/*---------------------------Python BPy_Interface1D visible prototypes-----------*/ + +int Interface1D_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_INTERFACE1D_H */ diff --git a/source/blender/freestyle/intern/python/BPy_Iterator.cpp b/source/blender/freestyle/intern/python/BPy_Iterator.cpp new file mode 100644 index 00000000000..dd7d3783d81 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_Iterator.cpp @@ -0,0 +1,229 @@ +#include "BPy_Iterator.h" + +#include "BPy_Convert.h" +#include "Iterator/BPy_AdjacencyIterator.h" +#include "Iterator/BPy_Interface0DIterator.h" +#include "Iterator/BPy_CurvePointIterator.h" +#include "Iterator/BPy_StrokeVertexIterator.h" +#include "Iterator/BPy_SVertexIterator.h" +#include "Iterator/BPy_orientedViewEdgeIterator.h" +#include "Iterator/BPy_ViewEdgeIterator.h" +#include "Iterator/BPy_ChainingIterator.h" +#include "Iterator/BPy_ChainPredicateIterator.h" +#include "Iterator/BPy_ChainSilhouetteIterator.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- +int Iterator_Init( PyObject *module ) +{ + if( module == NULL ) + return -1; + + if( PyType_Ready( &Iterator_Type ) < 0 ) + return -1; + Py_INCREF( &Iterator_Type ); + PyModule_AddObject(module, "Iterator", (PyObject *)&Iterator_Type); + + if( PyType_Ready( &AdjacencyIterator_Type ) < 0 ) + return -1; + Py_INCREF( &AdjacencyIterator_Type ); + PyModule_AddObject(module, "AdjacencyIterator", (PyObject *)&AdjacencyIterator_Type); + + if( PyType_Ready( &Interface0DIterator_Type ) < 0 ) + return -1; + Py_INCREF( &Interface0DIterator_Type ); + PyModule_AddObject(module, "Interface0DIterator", (PyObject *)&Interface0DIterator_Type); + + if( PyType_Ready( &CurvePointIterator_Type ) < 0 ) + return -1; + Py_INCREF( &CurvePointIterator_Type ); + PyModule_AddObject(module, "CurvePointIterator", (PyObject *)&CurvePointIterator_Type); + + if( PyType_Ready( &StrokeVertexIterator_Type ) < 0 ) + return -1; + Py_INCREF( &StrokeVertexIterator_Type ); + PyModule_AddObject(module, "StrokeVertexIterator", (PyObject *)&StrokeVertexIterator_Type); + + if( PyType_Ready( &SVertexIterator_Type ) < 0 ) + return -1; + Py_INCREF( &SVertexIterator_Type ); + PyModule_AddObject(module, "SVertexIterator", (PyObject *)&SVertexIterator_Type); + + if( PyType_Ready( &orientedViewEdgeIterator_Type ) < 0 ) + return -1; + Py_INCREF( &orientedViewEdgeIterator_Type ); + PyModule_AddObject(module, "orientedViewEdgeIterator", (PyObject *)&orientedViewEdgeIterator_Type); + + if( PyType_Ready( &ViewEdgeIterator_Type ) < 0 ) + return -1; + Py_INCREF( &ViewEdgeIterator_Type ); + PyModule_AddObject(module, "ViewEdgeIterator", (PyObject *)&ViewEdgeIterator_Type); + + if( PyType_Ready( &ChainingIterator_Type ) < 0 ) + return -1; + Py_INCREF( &ChainingIterator_Type ); + PyModule_AddObject(module, "ChainingIterator", (PyObject *)&ChainingIterator_Type); + + if( PyType_Ready( &ChainPredicateIterator_Type ) < 0 ) + return -1; + Py_INCREF( &ChainPredicateIterator_Type ); + PyModule_AddObject(module, "ChainPredicateIterator", (PyObject *)&ChainPredicateIterator_Type); + + if( PyType_Ready( &ChainSilhouetteIterator_Type ) < 0 ) + return -1; + Py_INCREF( &ChainSilhouetteIterator_Type ); + PyModule_AddObject(module, "ChainSilhouetteIterator", (PyObject *)&ChainSilhouetteIterator_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char Iterator___doc__[] = +"Base class to define iterators.\n"; + +static void Iterator___dealloc__(BPy_Iterator* self) +{ + if (self->it) + delete self->it; + Py_TYPE(self)->tp_free((PyObject*)self); +} + +static PyObject * Iterator___repr__(BPy_Iterator* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->it->getExactTypeName().c_str(), self->it ); +} + +static char Iterator_getExactTypeName___doc__[] = +".. method:: getExactTypeName()\n" +"\n" +" Returns the name of the iterator.\n" +"\n" +" :return: The name of the iterator.\n" +" :rtype: str\n"; + +static PyObject * Iterator_getExactTypeName(BPy_Iterator* self) { + return PyUnicode_FromString( self->it->getExactTypeName().c_str() ); +} + +static char Iterator_increment___doc__[] = +".. method:: increment()\n" +"\n" +" Makes the iterator point the next element.\n"; + +static PyObject * Iterator_increment(BPy_Iterator* self) { + if (self->it->isEnd()) { + PyErr_SetString(PyExc_RuntimeError , "cannot increment any more"); + return NULL; + } + self->it->increment(); + + Py_RETURN_NONE; +} + +static char Iterator_decrement___doc__[] = +".. method:: decrement()\n" +"\n" +" Makes the iterator point the previous element.\n"; + +static PyObject * Iterator_decrement(BPy_Iterator* self) { + if (self->it->isBegin()) { + PyErr_SetString(PyExc_RuntimeError , "cannot decrement any more"); + return NULL; + } + self->it->decrement(); + + Py_RETURN_NONE; +} + +static char Iterator_isBegin___doc__[] = +".. method:: isBegin()\n" +"\n" +" Returns true if the interator points the first element.\n" +"\n" +" :return: True if the interator points the first element.\n" +" :rtype: bool\n"; + +static PyObject * Iterator_isBegin(BPy_Iterator* self) { + return PyBool_from_bool( self->it->isBegin() ); +} + +static char Iterator_isEnd___doc__[] = +".. method:: isEnd()\n" +"\n" +" Returns true if the interator points the last element.\n" +"\n" +" :return: True if the interator points the last element.\n" +" :rtype: bool\n"; + +static PyObject * Iterator_isEnd(BPy_Iterator* self) { + return PyBool_from_bool( self->it->isEnd() ); +} + +/*----------------------Iterator instance definitions ----------------------------*/ +static PyMethodDef BPy_Iterator_methods[] = { + {"getExactTypeName", ( PyCFunction ) Iterator_getExactTypeName, METH_NOARGS, Iterator_getExactTypeName___doc__}, + {"increment", ( PyCFunction ) Iterator_increment, METH_NOARGS, Iterator_increment___doc__}, + {"decrement", ( PyCFunction ) Iterator_decrement, METH_NOARGS, Iterator_decrement___doc__}, + {"isBegin", ( PyCFunction ) Iterator_isBegin, METH_NOARGS, Iterator_isBegin___doc__}, + {"isEnd", ( PyCFunction ) Iterator_isEnd, METH_NOARGS, Iterator_isEnd___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_Iterator type definition ------------------------------*/ + +PyTypeObject Iterator_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "Iterator", /* tp_name */ + sizeof(BPy_Iterator), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)Iterator___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)Iterator___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + Iterator___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_Iterator_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + diff --git a/source/blender/freestyle/intern/python/BPy_Iterator.h b/source/blender/freestyle/intern/python/BPy_Iterator.h new file mode 100644 index 00000000000..0bdb52ef9a5 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_Iterator.h @@ -0,0 +1,35 @@ +#ifndef FREESTYLE_PYTHON_ITERATOR_H +#define FREESTYLE_PYTHON_ITERATOR_H + +#include <Python.h> + +#include "../system/Iterator.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +extern PyTypeObject Iterator_Type; + +#define BPy_Iterator_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &Iterator_Type) ) + +/*---------------------------Python BPy_Iterator structure definition----------*/ +typedef struct { + PyObject_HEAD + Iterator *it; +} BPy_Iterator; + +/*---------------------------Python BPy_Iterator visible prototypes-----------*/ + +int Iterator_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_ITERATOR_H */ diff --git a/source/blender/freestyle/intern/python/BPy_MediumType.cpp b/source/blender/freestyle/intern/python/BPy_MediumType.cpp new file mode 100644 index 00000000000..111fb756ba2 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_MediumType.cpp @@ -0,0 +1,99 @@ +#include "BPy_MediumType.h" + +#include "BPy_Convert.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +/*-----------------------BPy_MediumType type definition ------------------------------*/ + +static char MediumType___doc__[] = +"Class hierarchy: int > :class:`MediumType`\n" +"\n" +"The different blending modes available to similate the interaction\n" +"media-medium:\n" +"\n" +"* Stroke.DRY_MEDIUM: To simulate a dry medium such as Pencil or Charcoal.\n" +"* Stroke.HUMID_MEDIUM: To simulate ink painting (color substraction blending).\n" +"* Stroke.OPAQUE_MEDIUM: To simulate an opaque medium (oil, spray...).\n"; + +PyTypeObject MediumType_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "MediumType", /* tp_name */ + sizeof(PyLongObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + MediumType___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &PyLong_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/*-----------------------BPy_IntegrationType instance definitions -------------------------*/ + +PyLongObject _BPy_MediumType_DRY_MEDIUM = { + PyVarObject_HEAD_INIT(&MediumType_Type, 1) + { Stroke::DRY_MEDIUM } +}; +PyLongObject _BPy_MediumType_HUMID_MEDIUM = { + PyVarObject_HEAD_INIT(&MediumType_Type, 1) + { Stroke::HUMID_MEDIUM } +}; +PyLongObject _BPy_MediumType_OPAQUE_MEDIUM = { + PyVarObject_HEAD_INIT(&MediumType_Type, 1) + { Stroke::OPAQUE_MEDIUM } +}; + +//-------------------MODULE INITIALIZATION-------------------------------- + +int MediumType_Init( PyObject *module ) +{ + if( module == NULL ) + return -1; + + if( PyType_Ready( &MediumType_Type ) < 0 ) + return -1; + Py_INCREF( &MediumType_Type ); + PyModule_AddObject(module, "MediumType", (PyObject *)&MediumType_Type); + + return 0; +} + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + diff --git a/source/blender/freestyle/intern/python/BPy_MediumType.h b/source/blender/freestyle/intern/python/BPy_MediumType.h new file mode 100644 index 00000000000..3bc50477295 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_MediumType.h @@ -0,0 +1,42 @@ +#ifndef FREESTYLE_PYTHON_MEDIUMTYPE_H +#define FREESTYLE_PYTHON_MEDIUMTYPE_H + +#include <Python.h> + +#include "../stroke/Stroke.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +extern PyTypeObject MediumType_Type; + +#define BPy_MediumType_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &MediumType_Type) ) + +/*---------------------------Python BPy_MediumType structure definition----------*/ +typedef struct { + PyLongObject i; +} BPy_MediumType; + +/*---------------------------Python BPy_MediumType visible prototypes-----------*/ + +int MediumType_Init( PyObject *module ); + +// internal constants +extern PyLongObject _BPy_MediumType_DRY_MEDIUM; +extern PyLongObject _BPy_MediumType_HUMID_MEDIUM; +extern PyLongObject _BPy_MediumType_OPAQUE_MEDIUM; +// public constants +#define BPy_MediumType_DRY_MEDIUM ((PyObject *)&_BPy_MediumType_DRY_MEDIUM) +#define BPy_MediumType_HUMID_MEDIUM ((PyObject *)&_BPy_MediumType_HUMID_MEDIUM) +#define BPy_MediumType_OPAQUE_MEDIUM ((PyObject *)&_BPy_MediumType_OPAQUE_MEDIUM) + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_MEDIUMTYPE_H */ diff --git a/source/blender/freestyle/intern/python/BPy_Nature.cpp b/source/blender/freestyle/intern/python/BPy_Nature.cpp new file mode 100644 index 00000000000..35be367b348 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_Nature.cpp @@ -0,0 +1,305 @@ +#include "BPy_Nature.h" + +#include "BPy_Convert.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +static PyObject *BPy_Nature___and__(PyObject *a, PyObject *b); +static PyObject *BPy_Nature___xor__(PyObject *a, PyObject *b); +static PyObject *BPy_Nature___or__(PyObject *a, PyObject *b); +static int BPy_Nature_bool(PyObject *v); + +/*-----------------------BPy_Nature number method definitions --------------------*/ + +PyNumberMethods nature_as_number = { + 0, /* binaryfunc nb_add */ + 0, /* binaryfunc nb_subtract */ + 0, /* binaryfunc nb_multiply */ + 0, /* binaryfunc nb_remainder */ + 0, /* binaryfunc nb_divmod */ + 0, /* ternaryfunc nb_power */ + 0, /* unaryfunc nb_negative */ + 0, /* unaryfunc nb_positive */ + 0, /* unaryfunc nb_absolute */ + (inquiry)BPy_Nature_bool, /* inquiry nb_bool */ + 0, /* unaryfunc nb_invert */ + 0, /* binaryfunc nb_lshift */ + 0, /* binaryfunc nb_rshift */ + (binaryfunc)BPy_Nature___and__, /* binaryfunc nb_and */ + (binaryfunc)BPy_Nature___xor__, /* binaryfunc nb_xor */ + (binaryfunc)BPy_Nature___or__, /* binaryfunc nb_or */ + 0, /* unaryfunc nb_int */ + 0, /* void *nb_reserved */ + 0, /* unaryfunc nb_float */ + 0, /* binaryfunc nb_inplace_add */ + 0, /* binaryfunc nb_inplace_subtract */ + 0, /* binaryfunc nb_inplace_multiply */ + 0, /* binaryfunc nb_inplace_remainder */ + 0, /* ternaryfunc nb_inplace_power */ + 0, /* binaryfunc nb_inplace_lshift */ + 0, /* binaryfunc nb_inplace_rshift */ + 0, /* binaryfunc nb_inplace_and */ + 0, /* binaryfunc nb_inplace_xor */ + 0, /* binaryfunc nb_inplace_or */ + 0, /* binaryfunc nb_floor_divide */ + 0, /* binaryfunc nb_true_divide */ + 0, /* binaryfunc nb_inplace_floor_divide */ + 0, /* binaryfunc nb_inplace_true_divide */ + 0, /* unaryfunc nb_index */ +}; + +/*-----------------------BPy_Nature docstring ------------------------------------*/ + +static char Nature___doc__[] = +"Class hierarchy: int > :class:`Nature`\n" +"\n" +"Different possible natures of 0D and 1D elements of the ViewMap.\n" +"\n" +"Vertex natures:\n" +"\n" +"* Nature.POINT: True for any 0D element.\n" +"* Nature.S_VERTEX: True for SVertex.\n" +"* Nature.VIEW_VERTEX: True for ViewVertex.\n" +"* Nature.NON_T_VERTEX: True for NonTVertex.\n" +"* Nature.T_VERTEX: True for TVertex.\n" +"* Nature.CUSP: True for CUSP.\n" +"\n" +"Edge natures:\n" +"\n" +"* Nature.NO_FEATURE: True for non feature edges (always false for 1D\n" +" elements of the ViewMap).\n" +"* Nature.SILHOUETTE: True for silhouettes.\n" +"* Nature.BORDER: True for borders.\n" +"* Nature.CREASE: True for creases.\n" +"* Nature.RIDGE: True for ridges.\n" +"* Nature.VALLEY: True for valleys.\n" +"* Nature.SUGGESTIVE_CONTOUR: True for suggestive contours.\n" +"* Nature.MATERIAL_BOUNDARY: True for edges at material boundaries.\n"; + +/*-----------------------BPy_Nature type definition ------------------------------*/ + +PyTypeObject Nature_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "Nature", /* tp_name */ + sizeof(PyLongObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + &nature_as_number, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + Nature___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &PyLong_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/*-----------------------BPy_Nature instance definitions ----------------------------------*/ + +static PyLongObject _Nature_POINT = { + PyVarObject_HEAD_INIT(&Nature_Type, 1) + { Nature::POINT } +}; +static PyLongObject _Nature_S_VERTEX = { + PyVarObject_HEAD_INIT(&Nature_Type, 1) + { Nature::S_VERTEX } +}; +static PyLongObject _Nature_VIEW_VERTEX = { + PyVarObject_HEAD_INIT(&Nature_Type, 1) + { Nature::VIEW_VERTEX } +}; +static PyLongObject _Nature_NON_T_VERTEX = { + PyVarObject_HEAD_INIT(&Nature_Type, 1) + { Nature::NON_T_VERTEX } +}; +static PyLongObject _Nature_T_VERTEX = { + PyVarObject_HEAD_INIT(&Nature_Type, 1) + { Nature::T_VERTEX } +}; +static PyLongObject _Nature_CUSP = { + PyVarObject_HEAD_INIT(&Nature_Type, 1) + { Nature::CUSP } +}; +static PyLongObject _Nature_NO_FEATURE = { + PyVarObject_HEAD_INIT(&Nature_Type, 1) + { Nature::NO_FEATURE } +}; +static PyLongObject _Nature_SILHOUETTE = { + PyVarObject_HEAD_INIT(&Nature_Type, 1) + { Nature::SILHOUETTE } +}; +static PyLongObject _Nature_BORDER = { + PyVarObject_HEAD_INIT(&Nature_Type, 1) + { Nature::BORDER } +}; +static PyLongObject _Nature_CREASE = { + PyVarObject_HEAD_INIT(&Nature_Type, 1) + { Nature::CREASE } +}; +static PyLongObject _Nature_RIDGE = { + PyVarObject_HEAD_INIT(&Nature_Type, 1) + { Nature::RIDGE } +}; +static PyLongObject _Nature_VALLEY = { + PyVarObject_HEAD_INIT(&Nature_Type, 1) + { Nature::VALLEY } +}; +static PyLongObject _Nature_SUGGESTIVE_CONTOUR = { + PyVarObject_HEAD_INIT(&Nature_Type, 1) + { Nature::SUGGESTIVE_CONTOUR } +}; +static PyLongObject _Nature_MATERIAL_BOUNDARY = { + PyVarObject_HEAD_INIT(&Nature_Type, 1) + { Nature::MATERIAL_BOUNDARY } +}; + +#define BPy_Nature_POINT ((PyObject *)&_Nature_POINT) +#define BPy_Nature_S_VERTEX ((PyObject *)&_Nature_S_VERTEX) +#define BPy_Nature_VIEW_VERTEX ((PyObject *)&_Nature_VIEW_VERTEX) +#define BPy_Nature_NON_T_VERTEX ((PyObject *)&_Nature_NON_T_VERTEX) +#define BPy_Nature_T_VERTEX ((PyObject *)&_Nature_T_VERTEX) +#define BPy_Nature_CUSP ((PyObject *)&_Nature_CUSP) +#define BPy_Nature_NO_FEATURE ((PyObject *)&_Nature_NO_FEATURE) +#define BPy_Nature_SILHOUETTE ((PyObject *)&_Nature_SILHOUETTE) +#define BPy_Nature_BORDER ((PyObject *)&_Nature_BORDER) +#define BPy_Nature_CREASE ((PyObject *)&_Nature_CREASE) +#define BPy_Nature_RIDGE ((PyObject *)&_Nature_RIDGE) +#define BPy_Nature_VALLEY ((PyObject *)&_Nature_VALLEY) +#define BPy_Nature_SUGGESTIVE_CONTOUR ((PyObject *)&_Nature_SUGGESTIVE_CONTOUR) +#define BPy_Nature_MATERIAL_BOUNDARY ((PyObject *)&_Nature_MATERIAL_BOUNDARY) + +//-------------------MODULE INITIALIZATION-------------------------------- +int Nature_Init( PyObject *module ) +{ + if( module == NULL ) + return -1; + + if( PyType_Ready( &Nature_Type ) < 0 ) + return -1; + Py_INCREF( &Nature_Type ); + PyModule_AddObject(module, "Nature", (PyObject *)&Nature_Type); + + // VertexNature + PyDict_SetItemString( Nature_Type.tp_dict, "POINT", BPy_Nature_POINT); + PyDict_SetItemString( Nature_Type.tp_dict, "S_VERTEX", BPy_Nature_S_VERTEX); + PyDict_SetItemString( Nature_Type.tp_dict, "VIEW_VERTEX", BPy_Nature_VIEW_VERTEX ); + PyDict_SetItemString( Nature_Type.tp_dict, "NON_T_VERTEX", BPy_Nature_NON_T_VERTEX ); + PyDict_SetItemString( Nature_Type.tp_dict, "T_VERTEX", BPy_Nature_T_VERTEX ); + PyDict_SetItemString( Nature_Type.tp_dict, "CUSP", BPy_Nature_CUSP ); + + // EdgeNature + PyDict_SetItemString( Nature_Type.tp_dict, "NO_FEATURE", BPy_Nature_NO_FEATURE ); + PyDict_SetItemString( Nature_Type.tp_dict, "SILHOUETTE", BPy_Nature_SILHOUETTE ); + PyDict_SetItemString( Nature_Type.tp_dict, "BORDER", BPy_Nature_BORDER ); + PyDict_SetItemString( Nature_Type.tp_dict, "CREASE", BPy_Nature_CREASE ); + PyDict_SetItemString( Nature_Type.tp_dict, "RIDGE", BPy_Nature_RIDGE ); + PyDict_SetItemString( Nature_Type.tp_dict, "VALLEY", BPy_Nature_VALLEY ); + PyDict_SetItemString( Nature_Type.tp_dict, "SUGGESTIVE_CONTOUR", BPy_Nature_SUGGESTIVE_CONTOUR ); + PyDict_SetItemString( Nature_Type.tp_dict, "MATERIAL_BOUNDARY", BPy_Nature_MATERIAL_BOUNDARY ); + + return 0; +} + +static PyObject * +BPy_Nature_bitwise(PyObject *a, int op, PyObject *b) +{ + BPy_Nature *result; + + if (!BPy_Nature_Check(a) || !BPy_Nature_Check(b)) { + PyErr_SetString(PyExc_TypeError, "operands must be a Nature object"); + return NULL; + } + if (Py_SIZE(a) != 1) { + stringstream msg; + msg << "operand 1: unexpected Nature byte length: " << Py_SIZE(a); + PyErr_SetString(PyExc_TypeError, msg.str().c_str()); + return NULL; + } + if (Py_SIZE(b) != 1) { + stringstream msg; + msg << "operand 2: unexpected Nature byte length: " << Py_SIZE(b); + PyErr_SetString(PyExc_TypeError, msg.str().c_str()); + return NULL; + } + result = PyObject_NewVar(BPy_Nature, &Nature_Type, 1); + if (!result) + return NULL; + if (Py_SIZE(result) != 1) { + stringstream msg; + msg << "unexpected Nature byte length: " << Py_SIZE(result); + PyErr_SetString(PyExc_TypeError, msg.str().c_str()); + return NULL; + } + switch (op) { + case '&': + result->i.ob_digit[0] = (((PyLongObject *)a)->ob_digit[0]) & (((PyLongObject *)b)->ob_digit)[0]; + break; + case '^': + result->i.ob_digit[0] = (((PyLongObject *)a)->ob_digit[0]) ^ (((PyLongObject *)b)->ob_digit)[0]; + break; + case '|': + result->i.ob_digit[0] = (((PyLongObject *)a)->ob_digit[0]) | (((PyLongObject *)b)->ob_digit)[0]; + break; + } + return (PyObject *)result; +} + +static PyObject * +BPy_Nature___and__(PyObject *a, PyObject *b) +{ + return BPy_Nature_bitwise(a, '&', b); +} + +static PyObject * +BPy_Nature___xor__(PyObject *a, PyObject *b) +{ + return BPy_Nature_bitwise(a, '^', b); +} + +static PyObject * +BPy_Nature___or__(PyObject *a, PyObject *b) +{ + return BPy_Nature_bitwise(a, '|', b); +} + +static int +BPy_Nature_bool(PyObject *v) +{ + return ((PyLongObject *)v)->ob_digit[0] != 0; +} + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + diff --git a/source/blender/freestyle/intern/python/BPy_Nature.h b/source/blender/freestyle/intern/python/BPy_Nature.h new file mode 100644 index 00000000000..8c38415242e --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_Nature.h @@ -0,0 +1,33 @@ +#ifndef FREESTYLE_PYTHON_NATURE_H +#define FREESTYLE_PYTHON_NATURE_H + +#include <Python.h> + +#include "../winged_edge/Nature.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +extern PyTypeObject Nature_Type; + +#define BPy_Nature_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &Nature_Type) ) + +/*---------------------------Python BPy_Nature structure definition----------*/ +typedef struct { + PyLongObject i; +} BPy_Nature; + +/*---------------------------Python BPy_Nature visible prototypes-----------*/ + +int Nature_Init( PyObject *module ); + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_NATURE_H */ diff --git a/source/blender/freestyle/intern/python/BPy_Operators.cpp b/source/blender/freestyle/intern/python/BPy_Operators.cpp new file mode 100644 index 00000000000..7d660054335 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_Operators.cpp @@ -0,0 +1,682 @@ +#include "BPy_Operators.h" + +#include "BPy_BinaryPredicate1D.h" +#include "BPy_UnaryPredicate0D.h" +#include "BPy_UnaryPredicate1D.h" +#include "UnaryFunction0D/BPy_UnaryFunction0DDouble.h" +#include "UnaryFunction1D/BPy_UnaryFunction1DVoid.h" +#include "Iterator/BPy_ViewEdgeIterator.h" +#include "Iterator/BPy_ChainingIterator.h" +#include "BPy_StrokeShader.h" +#include "BPy_Convert.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- +int Operators_Init( PyObject *module ) +{ + if( module == NULL ) + return -1; + + if( PyType_Ready( &Operators_Type ) < 0 ) + return -1; + + Py_INCREF( &Operators_Type ); + PyModule_AddObject(module, "Operators", (PyObject *)&Operators_Type); + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char Operators___doc__[] = +"Class defining the operators used in a style module. There are five\n" +"types of operators: Selection, chaining, splitting, sorting and\n" +"creation. All these operators are user controlled through functors,\n" +"predicates and shaders that are taken as arguments.\n"; + +static void Operators___dealloc__(BPy_Operators* self) +{ + Py_TYPE(self)->tp_free((PyObject*)self); +} + +static char Operators_select___doc__[] = +".. staticmethod:: select(pred)\n" +"\n" +" Selects the ViewEdges of the ViewMap verifying a specified\n" +" condition.\n" +"\n" +" :arg pred: The predicate expressing this condition.\n" +" :type pred: UnaryPredicate1D\n"; + +static PyObject * Operators_select(BPy_Operators* self, PyObject *args) +{ + PyObject *obj = 0; + + if ( !PyArg_ParseTuple(args, "O!", &UnaryPredicate1D_Type, &obj) ) + return NULL; + if ( !((BPy_UnaryPredicate1D *) obj)->up1D ) { + PyErr_SetString(PyExc_TypeError, "Operators.select(): 1st argument: invalid UnaryPredicate1D object"); + return NULL; + } + + if (Operators::select(*( ((BPy_UnaryPredicate1D *) obj)->up1D )) < 0) { + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, "Operators.select() failed"); + return NULL; + } + + Py_RETURN_NONE; +} + +static char Operators_chain___doc__[] = +".. staticmethod:: chain(it, pred, modifier)\n" +"\n" +" Builds a set of chains from the current set of ViewEdges. Each\n" +" ViewEdge of the current list starts a new chain. The chaining\n" +" operator then iterates over the ViewEdges of the ViewMap using the\n" +" user specified iterator. This operator only iterates using the\n" +" increment operator and is therefore unidirectional.\n" +"\n" +" :arg it: The iterator on the ViewEdges of the ViewMap. It contains\n" +" the chaining rule.\n" +" :type it: :class:`ViewEdgeIterator`\n" +" :arg pred: The predicate on the ViewEdge that expresses the\n" +" stopping condition.\n" +" :type pred: :class:`UnaryPredicate1D`\n" +" :arg modifier: A function that takes a ViewEdge as argument and\n" +" that is used to modify the processed ViewEdge state (the\n" +" timestamp incrementation is a typical illustration of such a\n" +" modifier).\n" +" :type modifier: :class:`UnaryFunction1DVoid`\n" +"\n" +".. staticmethod:: chain(it, pred)\n" +"\n" +" Builds a set of chains from the current set of ViewEdges. Each\n" +" ViewEdge of the current list starts a new chain. The chaining\n" +" operator then iterates over the ViewEdges of the ViewMap using the\n" +" user specified iterator. This operator only iterates using the\n" +" increment operator and is therefore unidirectional. This chaining\n" +" operator is different from the previous one because it doesn't take\n" +" any modifier as argument. Indeed, the time stamp (insuring that a\n" +" ViewEdge is processed one time) is automatically managed in this\n" +" case.\n" +"\n" +" :arg it: The iterator on the ViewEdges of the ViewMap. It contains\n" +" the chaining rule. \n" +" :type it: :class:`ViewEdgeIterator`\n" +" :arg pred: The predicate on the ViewEdge that expresses the\n" +" stopping condition.\n" +" :type pred: :class:`UnaryPredicate1D`\n"; + +// CHANGE: first parameter is a chaining iterator, not just a view + +static PyObject * Operators_chain(BPy_Operators* self, PyObject *args) +{ + PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0; + + if ( !PyArg_ParseTuple(args, "O!O!|O!", &ChainingIterator_Type, &obj1, + &UnaryPredicate1D_Type, &obj2, + &UnaryFunction1DVoid_Type, &obj3) ) + return NULL; + if ( !((BPy_ChainingIterator *) obj1)->c_it ) { + PyErr_SetString(PyExc_TypeError, "Operators.chain(): 1st argument: invalid ChainingIterator object"); + return NULL; + } + if ( !((BPy_UnaryPredicate1D *) obj2)->up1D ) { + PyErr_SetString(PyExc_TypeError, "Operators.chain(): 2nd argument: invalid UnaryPredicate1D object"); + return NULL; + } + + if( !obj3 ) { + + if (Operators::chain( *( ((BPy_ChainingIterator *) obj1)->c_it ), + *( ((BPy_UnaryPredicate1D *) obj2)->up1D ) ) < 0) { + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, "Operators.chain() failed"); + return NULL; + } + + } else { + + if ( !((BPy_UnaryFunction1DVoid *) obj3)->uf1D_void ) { + PyErr_SetString(PyExc_TypeError, "Operators.chain(): 3rd argument: invalid UnaryFunction1DVoid object"); + return NULL; + } + if (Operators::chain( *( ((BPy_ChainingIterator *) obj1)->c_it ), + *( ((BPy_UnaryPredicate1D *) obj2)->up1D ), + *( ((BPy_UnaryFunction1DVoid *) obj3)->uf1D_void ) ) < 0) { + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, "Operators.chain() failed"); + return NULL; + } + + } + + Py_RETURN_NONE; +} + +static char Operators_bidirectionalChain___doc__[] = +".. staticmethod:: bidirectionalChain(it, pred)\n" +"\n" +" Builds a set of chains from the current set of ViewEdges. Each\n" +" ViewEdge of the current list potentially starts a new chain. The\n" +" chaining operator then iterates over the ViewEdges of the ViewMap\n" +" using the user specified iterator. This operator iterates both using\n" +" the increment and decrement operators and is therefore bidirectional.\n" +" This operator works with a ChainingIterator which contains the\n" +" chaining rules. It is this last one which can be told to chain only\n" +" edges that belong to the selection or not to process twice a ViewEdge\n" +" during the chaining. Each time a ViewEdge is added to a chain, its\n" +" chaining time stamp is incremented. This allows you to keep track of\n" +" the number of chains to which a ViewEdge belongs to.\n" +"\n" +" :arg it: The ChainingIterator on the ViewEdges of the ViewMap. It\n" +" contains the chaining rule.\n" +" :type it: :class:`ChainingIterator`\n" +" :arg pred: The predicate on the ViewEdge that expresses the\n" +" stopping condition.\n" +" :type pred: :class:`UnaryPredicate1D`\n" +"\n" +".. staticmethod:: bidirectionalChain(it)\n" +"\n" +" The only difference with the above bidirectional chaining algorithm\n" +" is that we don't need to pass a stopping criterion. This might be\n" +" desirable when the stopping criterion is already contained in the\n" +" iterator definition. Builds a set of chains from the current set of\n" +" ViewEdges. Each ViewEdge of the current list potentially starts a new\n" +" chain. The chaining operator then iterates over the ViewEdges of the\n" +" ViewMap using the user specified iterator. This operator iterates\n" +" both using the increment and decrement operators and is therefore\n" +" bidirectional. This operator works with a ChainingIterator which\n" +" contains the chaining rules. It is this last one which can be told to\n" +" chain only edges that belong to the selection or not to process twice\n" +" a ViewEdge during the chaining. Each time a ViewEdge is added to a\n" +" chain, its chaining time stamp is incremented. This allows you to\n" +" keep track of the number of chains to which a ViewEdge belongs to.\n" +"\n" +" :arg it: The ChainingIterator on the ViewEdges of the ViewMap. It\n" +" contains the chaining rule.\n" +" :type it: :class:`ChainingIterator`\n"; + +static PyObject * Operators_bidirectionalChain(BPy_Operators* self, PyObject *args) +{ + PyObject *obj1 = 0, *obj2 = 0; + + if( !PyArg_ParseTuple(args, "O!|O!", &ChainingIterator_Type, &obj1, &UnaryPredicate1D_Type, &obj2) ) + return NULL; + if ( !((BPy_ChainingIterator *) obj1)->c_it ) { + PyErr_SetString(PyExc_TypeError, "Operators.bidirectionalChain(): 1st argument: invalid ChainingIterator object"); + return NULL; + } + + if( !obj2 ) { + + if (Operators::bidirectionalChain( *( ((BPy_ChainingIterator *) obj1)->c_it ) ) < 0) { + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, "Operators.bidirectionalChain() failed"); + return NULL; + } + + } else { + + if ( !((BPy_UnaryPredicate1D *) obj2)->up1D ) { + PyErr_SetString(PyExc_TypeError, "Operators.bidirectionalChain(): 2nd argument: invalid UnaryPredicate1D object"); + return NULL; + } + if (Operators::bidirectionalChain( *( ((BPy_ChainingIterator *) obj1)->c_it ), + *( ((BPy_UnaryPredicate1D *) obj2)->up1D ) ) < 0) { + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, "Operators.bidirectionalChain() failed"); + return NULL; + } + + } + + Py_RETURN_NONE; +} + +static char Operators_sequentialSplit___doc__[] = +".. staticmethod:: sequentialSplit(startingPred, stoppingPred, sampling=0.0)\n" +"\n" +" Splits each chain of the current set of chains in a sequential way.\n" +" The points of each chain are processed (with a specified sampling)\n" +" sequentially. Each time a user specified starting condition is\n" +" verified, a new chain begins and ends as soon as a user-defined\n" +" stopping predicate is verified. This allows chains overlapping rather\n" +" than chains partitioning. The first point of the initial chain is the\n" +" first point of one of the resulting chains. The splitting ends when\n" +" no more chain can start.\n" +"\n" +" :arg startingPred: The predicate on a point that expresses the\n" +" starting condition.\n" +" :type startingPred: :class:`UnaryPredicate0D`\n" +" :arg stoppingPred: The predicate on a point that expresses the\n" +" stopping condition.\n" +" :type stoppingPred: :class:`UnaryPredicate0D`\n" +" :arg sampling: The resolution used to sample the chain for the\n" +" predicates evaluation. (The chain is not actually resampled;\n" +" a virtual point only progresses along the curve using this\n" +" resolution.)\n" +" :type sampling: float\n" +"\n" +".. staticmethod:: sequentialSplit(pred, sampling=0.0)\n" +"\n" +" Splits each chain of the current set of chains in a sequential way.\n" +" The points of each chain are processed (with a specified sampling)\n" +" sequentially and each time a user specified condition is verified,\n" +" the chain is split into two chains. The resulting set of chains is a\n" +" partition of the initial chain\n" +"\n" +" :arg pred: The predicate on a point that expresses the splitting\n" +" condition.\n" +" :type pred: :class:`UnaryPredicate0D`\n" +" :arg sampling: The resolution used to sample the chain for the\n" +" predicate evaluation. (The chain is not actually resampled; a\n" +" virtual point only progresses along the curve using this\n" +" resolution.)\n" +" :type sampling: float\n"; + +static PyObject * Operators_sequentialSplit(BPy_Operators* self, PyObject *args) +{ + PyObject *obj1 = 0, *obj2 = 0; + float f = 0.0; + + if( !PyArg_ParseTuple(args, "O!|Of", &UnaryPredicate0D_Type, &obj1, &obj2, &f) ) + return NULL; + if ( !((BPy_UnaryPredicate0D *) obj1)->up0D ) { + PyErr_SetString(PyExc_TypeError, "Operators.sequentialSplit(): 1st argument: invalid UnaryPredicate0D object"); + return NULL; + } + + if( obj2 && BPy_UnaryPredicate0D_Check(obj2) ) { + + if ( !((BPy_UnaryPredicate0D *) obj2)->up0D ) { + PyErr_SetString(PyExc_TypeError, "Operators.sequentialSplit(): 2nd argument: invalid UnaryPredicate0D object"); + return NULL; + } + if (Operators::sequentialSplit( *( ((BPy_UnaryPredicate0D *) obj1)->up0D ), + *( ((BPy_UnaryPredicate0D *) obj2)->up0D ), + f ) < 0) { + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, "Operators.sequentialSplit() failed"); + return NULL; + } + + } else { + + if ( obj2 ) { + if ( !PyFloat_Check(obj2) ) { + PyErr_SetString(PyExc_TypeError, "Operators.sequentialSplit(): invalid 2nd argument"); + return NULL; + } + f = PyFloat_AsDouble(obj2); + } + if (Operators::sequentialSplit( *( ((BPy_UnaryPredicate0D *) obj1)->up0D ), f ) < 0) { + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, "Operators.sequentialSplit() failed"); + return NULL; + } + + } + + Py_RETURN_NONE; +} + +static char Operators_recursiveSplit___doc__[] = +".. staticmethod:: recursiveSplit(func, pred, sampling=0.0)\n" +"\n" +" Splits the current set of chains in a recursive way. We process the\n" +" points of each chain (with a specified sampling) to find the point\n" +" minimizing a specified function. The chain is split in two at this\n" +" point and the two new chains are processed in the same way. The\n" +" recursivity level is controlled through a predicate 1D that expresses\n" +" a stopping condition on the chain that is about to be processed.\n" +"\n" +" :arg func: The Unary Function evaluated at each point of the chain.\n" +" The splitting point is the point minimizing this function.\n" +" :type func: :class:`UnaryFunction0DDouble`\n" +" :arg pred: The Unary Predicate expressing the recursivity stopping\n" +" condition. This predicate is evaluated for each curve before it\n" +" actually gets split. If pred(chain) is true, the curve won't be\n" +" split anymore.\n" +" :type pred: :class:`UnaryPredicate1D`\n" +" :arg sampling: The resolution used to sample the chain for the\n" +" predicates evaluation. (The chain is not actually resampled, a\n" +" virtual point only progresses along the curve using this\n" +" resolution.)\n" +" :type sampling: float\n" +"\n" +".. staticmethod:: recursiveSplit(func, pred0d, pred, sampling=0.0)\n" +"\n" +" Splits the current set of chains in a recursive way. We process the\n" +" points of each chain (with a specified sampling) to find the point\n" +" minimizing a specified function. The chain is split in two at this\n" +" point and the two new chains are processed in the same way. The user\n" +" can specify a 0D predicate to make a first selection on the points\n" +" that can potentially be split. A point that doesn't verify the 0D\n" +" predicate won't be candidate in realizing the min. The recursivity\n" +" level is controlled through a predicate 1D that expresses a stopping\n" +" condition on the chain that is about to be processed.\n" +"\n" +" :arg func: The Unary Function evaluated at each point of the chain.\n" +" The splitting point is the point minimizing this function.\n" +" :type func: :class:`UnaryFunction0DDouble`\n" +" :arg pred0d: The Unary Predicate 0D used to select the candidate\n" +" points where the split can occur. For example, it is very likely\n" +" that would rather have your chain splitting around its middle\n" +" point than around one of its extremities. A 0D predicate working\n" +" on the curvilinear abscissa allows to add this kind of constraints.\n" +" :type pred0d: :class:`UnaryPredicate0D`\n" +" :arg pred: The Unary Predicate expressing the recursivity stopping\n" +" condition. This predicate is evaluated for each curve before it\n" +" actually gets split. If pred(chain) is true, the curve won't be\n" +" split anymore.\n" +" :type pred: :class:`UnaryPredicate1D`\n" +" :arg sampling: The resolution used to sample the chain for the\n" +" predicates evaluation. (The chain is not actually resampled; a\n" +" virtual point only progresses along the curve using this\n" +" resolution.)\n" +" :type sampling: float\n"; + +static PyObject * Operators_recursiveSplit(BPy_Operators* self, PyObject *args) +{ + PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0; + float f = 0.0; + + if ( !PyArg_ParseTuple(args, "O!O|Of", &UnaryFunction0DDouble_Type, &obj1, &obj2, &obj3, &f) ) + return NULL; + if ( !((BPy_UnaryFunction0DDouble *) obj1)->uf0D_double ) { + PyErr_SetString(PyExc_TypeError, "Operators.recursiveSplit(): 1st argument: invalid UnaryFunction0DDouble object"); + return NULL; + } + + if ( BPy_UnaryPredicate1D_Check(obj2) ) { + + if ( !((BPy_UnaryPredicate1D *) obj2)->up1D ) { + PyErr_SetString(PyExc_TypeError, "Operators.recursiveSplit(): 2nd argument: invalid UnaryPredicate1D object"); + return NULL; + } + if ( obj3 ) { + if ( !PyFloat_Check(obj3) ) { + PyErr_SetString(PyExc_TypeError, "Operators.recursiveSplit(): invalid 3rd argument"); + return NULL; + } + f = PyFloat_AsDouble(obj3); + } + if (Operators::recursiveSplit( *( ((BPy_UnaryFunction0DDouble *) obj1)->uf0D_double ), + *( ((BPy_UnaryPredicate1D *) obj2)->up1D ), + f ) < 0) { + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, "Operators.recursiveSplit() failed"); + return NULL; + } + + } else { + + if ( !BPy_UnaryPredicate0D_Check(obj2) || !((BPy_UnaryPredicate0D *) obj2)->up0D ) { + PyErr_SetString(PyExc_TypeError, "Operators.recursiveSplit(): invalid 2nd argument"); + return NULL; + } + if ( !BPy_UnaryPredicate1D_Check(obj3) || !((BPy_UnaryPredicate1D *) obj3)->up1D ) { + PyErr_SetString(PyExc_TypeError, "Operators.recursiveSplit(): invalid 3rd argument"); + return NULL; + } + if (Operators::recursiveSplit( *( ((BPy_UnaryFunction0DDouble *) obj1)->uf0D_double ), + *( ((BPy_UnaryPredicate0D *) obj2)->up0D ), + *( ((BPy_UnaryPredicate1D *) obj3)->up1D ), + f ) < 0) { + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, "Operators.recursiveSplit() failed"); + return NULL; + } + + } + + Py_RETURN_NONE; +} + +static char Operators_sort___doc__[] = +".. staticmethod:: sort(pred)\n" +"\n" +" Sorts the current set of chains (or viewedges) according to the\n" +" comparison predicate given as argument.\n" +"\n" +" :arg pred: The binary predicate used for the comparison.\n" +" :type pred: BinaryPredicate1D\n"; + +static PyObject * Operators_sort(BPy_Operators* self, PyObject *args) +{ + PyObject *obj = 0; + + if ( !PyArg_ParseTuple(args, "O!", &BinaryPredicate1D_Type, &obj) ) + return NULL; + if ( !((BPy_BinaryPredicate1D *) obj)->bp1D ) { + PyErr_SetString(PyExc_TypeError, "Operators.sort(): 1st argument: invalid BinaryPredicate1D object"); + return NULL; + } + + if (Operators::sort(*( ((BPy_BinaryPredicate1D *) obj)->bp1D )) < 0) { + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, "Operators.sort() failed"); + return NULL; + } + Py_RETURN_NONE; +} + +static char Operators_create___doc__[] = +".. staticmethod:: create(pred, shaders)\n" +"\n" +" Creates and shades the strokes from the current set of chains. A\n" +" predicate can be specified to make a selection pass on the chains.\n" +"\n" +" :arg pred: The predicate that a chain must verify in order to be\n" +" transform as a stroke.\n" +" :type pred: :class:`UnaryPredicate1D`\n" +" :arg shaders: The list of shaders used to shade the strokes.\n" +" :type shaders: List of StrokeShader objects\n"; + +static PyObject * Operators_create(BPy_Operators* self, PyObject *args) +{ + PyObject *obj1 = 0, *obj2 = 0; + + if ( !PyArg_ParseTuple(args, "O!O!", &UnaryPredicate1D_Type, &obj1, &PyList_Type, &obj2) ) + return NULL; + if ( !((BPy_UnaryPredicate1D *) obj1)->up1D ) { + PyErr_SetString(PyExc_TypeError, "Operators.create(): 1st argument: invalid UnaryPredicate1D object"); + return NULL; + } + + vector<StrokeShader *> shaders; + for( int i = 0; i < PyList_Size(obj2); i++) { + PyObject *py_ss = PyList_GetItem(obj2,i); + + if ( !BPy_StrokeShader_Check(py_ss) ) { + PyErr_SetString(PyExc_TypeError, "Operators.create() 2nd argument must be a list of StrokeShader objects"); + return NULL; + } + shaders.push_back( ((BPy_StrokeShader *) py_ss)->ss ); + } + + if (Operators::create( *( ((BPy_UnaryPredicate1D *) obj1)->up1D ), shaders) < 0) { + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, "Operators.create() failed"); + return NULL; + } + + Py_RETURN_NONE; +} + +static char Operators_getViewEdgeFromIndex___doc__[] = +".. staticmethod:: getViewEdgeFromIndex()\n" +"\n" +" Returns the ViewEdge at the index in the current set of ViewEdges.\n" +"\n" +" :arg i: index (0 <= i < Operators.getViewEdgesSize()).\n" +" :type i: int\n" +" :return: The ViewEdge object.\n" +" :rtype: :class:`ViewEdge`\n"; + +static PyObject * Operators_getViewEdgeFromIndex(BPy_Operators* self, PyObject *args) { + unsigned int i; + + if (!PyArg_ParseTuple(args, "I", &i)) + return NULL; + if (i >= Operators::getViewEdgesSize()) { + PyErr_SetString(PyExc_IndexError, "index out of range"); + return NULL; + } + return BPy_ViewEdge_from_ViewEdge(*(Operators::getViewEdgeFromIndex(i))); +} + +static char Operators_getChainFromIndex___doc__[] = +".. staticmethod:: getChainFromIndex()\n" +"\n" +" Returns the Chain at the index in the current set of Chains.\n" +"\n" +" :arg i: index (0 <= i < Operators.getChainsSize()).\n" +" :type i: int\n" +" :return: The Chain object.\n" +" :rtype: :class:`Chain`\n"; + +static PyObject * Operators_getChainFromIndex(BPy_Operators* self, PyObject *args) { + unsigned int i; + + if (!PyArg_ParseTuple(args, "I", &i)) + return NULL; + if (i >= Operators::getChainsSize()) { + PyErr_SetString(PyExc_IndexError, "index out of range"); + return NULL; + } + return BPy_Chain_from_Chain(*(Operators::getChainFromIndex(i))); +} + +static char Operators_getStrokeFromIndex___doc__[] = +".. staticmethod:: getStrokeFromIndex()\n" +"\n" +" Returns the Stroke at the index in the current set of Strokes.\n" +"\n" +" :arg i: index (0 <= i < Operators.getStrokesSize()).\n" +" :type i: int\n" +" :return: The Stroke object.\n" +" :rtype: :class:`Stroke`\n"; + +static PyObject * Operators_getStrokeFromIndex(BPy_Operators* self, PyObject *args) { + unsigned int i; + + if (!PyArg_ParseTuple(args, "I", &i)) + return NULL; + if (i >= Operators::getStrokesSize()) { + PyErr_SetString(PyExc_IndexError, "index out of range"); + return NULL; + } + return BPy_Stroke_from_Stroke(*(Operators::getStrokeFromIndex(i))); +} + +static char Operators_getViewEdgesSize___doc__[] = +".. staticmethod:: getViewEdgesSize()\n" +"\n" +" Returns the number of ViewEdges.\n" +"\n" +" :return: The number of ViewEdges.\n" +" :rtype: int\n"; + +static PyObject * Operators_getViewEdgesSize( BPy_Operators* self) { + return PyLong_FromLong( Operators::getViewEdgesSize() ); +} + +static char Operators_getChainsSize___doc__[] = +".. staticmethod:: getChainsSize()\n" +"\n" +" Returns the number of Chains.\n" +"\n" +" :return: The number of Chains.\n" +" :rtype: int\n"; + +static PyObject * Operators_getChainsSize( BPy_Operators* self ) { + return PyLong_FromLong( Operators::getChainsSize() ); +} + +static char Operators_getStrokesSize___doc__[] = +".. staticmethod:: getStrokesSize()\n" +"\n" +" Returns the number of Strokes.\n" +"\n" +" :return: The number of Strokes.\n" +" :rtype: int\n"; + +static PyObject * Operators_getStrokesSize( BPy_Operators* self) { + return PyLong_FromLong( Operators::getStrokesSize() ); +} + +/*----------------------Operators instance definitions ----------------------------*/ +static PyMethodDef BPy_Operators_methods[] = { + {"select", ( PyCFunction ) Operators_select, METH_VARARGS | METH_STATIC, Operators_select___doc__}, + {"chain", ( PyCFunction ) Operators_chain, METH_VARARGS | METH_STATIC, Operators_chain___doc__}, + {"bidirectionalChain", ( PyCFunction ) Operators_bidirectionalChain, METH_VARARGS | METH_STATIC, Operators_bidirectionalChain___doc__}, + {"sequentialSplit", ( PyCFunction ) Operators_sequentialSplit, METH_VARARGS | METH_STATIC, Operators_sequentialSplit___doc__}, + {"recursiveSplit", ( PyCFunction ) Operators_recursiveSplit, METH_VARARGS | METH_STATIC, Operators_recursiveSplit___doc__}, + {"sort", ( PyCFunction ) Operators_sort, METH_VARARGS | METH_STATIC, Operators_sort___doc__}, + {"create", ( PyCFunction ) Operators_create, METH_VARARGS | METH_STATIC, Operators_create___doc__}, + {"getViewEdgeFromIndex", ( PyCFunction ) Operators_getViewEdgeFromIndex, METH_VARARGS | METH_STATIC, Operators_getViewEdgeFromIndex___doc__}, + {"getChainFromIndex", ( PyCFunction ) Operators_getChainFromIndex, METH_VARARGS | METH_STATIC, Operators_getChainFromIndex___doc__}, + {"getStrokeFromIndex", ( PyCFunction ) Operators_getStrokeFromIndex, METH_VARARGS | METH_STATIC, Operators_getStrokeFromIndex___doc__}, + {"getViewEdgesSize", ( PyCFunction ) Operators_getViewEdgesSize, METH_NOARGS | METH_STATIC, Operators_getViewEdgesSize___doc__}, + {"getChainsSize", ( PyCFunction ) Operators_getChainsSize, METH_NOARGS | METH_STATIC, Operators_getChainsSize___doc__}, + {"getStrokesSize", ( PyCFunction ) Operators_getStrokesSize, METH_NOARGS | METH_STATIC, Operators_getStrokesSize___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_Operators type definition ------------------------------*/ + +PyTypeObject Operators_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "Operators", /* tp_name */ + sizeof(BPy_Operators), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)Operators___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + Operators___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_Operators_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + diff --git a/source/blender/freestyle/intern/python/BPy_Operators.h b/source/blender/freestyle/intern/python/BPy_Operators.h new file mode 100644 index 00000000000..5e01d6bb1fe --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_Operators.h @@ -0,0 +1,34 @@ +#ifndef FREESTYLE_PYTHON_OPERATORS_H +#define FREESTYLE_PYTHON_OPERATORS_H + +#include <Python.h> + +#include "../stroke/Operators.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +extern PyTypeObject Operators_Type; + +#define BPy_Operators_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &Operators_Type) ) + +/*---------------------------Python BPy_Operators structure definition----------*/ +typedef struct { + PyObject_HEAD +} BPy_Operators; + +/*---------------------------Python BPy_Operators visible prototypes-----------*/ + +int Operators_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_OPERATORS_H */ diff --git a/source/blender/freestyle/intern/python/BPy_SShape.cpp b/source/blender/freestyle/intern/python/BPy_SShape.cpp new file mode 100644 index 00000000000..65951182f10 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_SShape.cpp @@ -0,0 +1,330 @@ +#include "BPy_SShape.h" + +#include "BPy_Convert.h" +#include "BPy_BBox.h" +#include "BPy_Id.h" +#include "Interface0D/BPy_SVertex.h" +#include "Interface1D/BPy_FEdge.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- +int SShape_Init( PyObject *module ) +{ + if( module == NULL ) + return -1; + + if( PyType_Ready( &SShape_Type ) < 0 ) + return -1; + + Py_INCREF( &SShape_Type ); + PyModule_AddObject(module, "SShape", (PyObject *)&SShape_Type); + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char SShape___doc__[] = +"Class to define a feature shape. It is the gathering of feature\n" +"elements from an identified input shape.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(iBrother)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg iBrother: An SShape object.\n" +" :type iBrother: :class:`SShape`\n"; + +static int SShape___init__(BPy_SShape *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj = NULL; + + if (! PyArg_ParseTuple(args, "|O!", &SShape_Type, &obj) ) + return -1; + + if( !obj ) { + self->ss = new SShape(); + + } else { + self->ss = new SShape(*( ((BPy_SShape *) obj)->ss )); + } + self->borrowed = 0; + + return 0; +} + +static void SShape___dealloc__(BPy_SShape *self) +{ + if( self->ss && !self->borrowed ) + delete self->ss; + Py_TYPE(self)->tp_free((PyObject*)self); +} + +static PyObject * SShape___repr__(BPy_SShape *self) +{ + return PyUnicode_FromFormat("SShape - address: %p", self->ss ); +} + +static char SShape_AddEdge___doc__[] = +".. method:: AddEdge(iEdge)\n" +"\n" +" Adds an FEdge to the list of FEdges.\n" +"\n" +" :arg iEdge: An FEdge object.\n" +" :type iEdge: :class:`FEdge`\n"; + +static PyObject * SShape_AddEdge( BPy_SShape *self , PyObject *args) { + PyObject *py_fe = 0; + + if(!( PyArg_ParseTuple(args, "O!", &FEdge_Type, &py_fe) )) + return NULL; + + self->ss->AddEdge( ((BPy_FEdge *) py_fe)->fe ); + + Py_RETURN_NONE; +} + +static char SShape_AddNewVertex___doc__[] = +".. method:: AddNewVertex(iv)\n" +"\n" +" Adds an SVertex to the list of SVertex of this Shape. The SShape\n" +" attribute of the SVertex is also set to this SShape.\n" +"\n" +" :arg iv: An SVertex object.\n" +" :type iv: :class:`SVertex`\n"; + +static PyObject * SShape_AddNewVertex( BPy_SShape *self , PyObject *args) { + PyObject *py_sv = 0; + + if(!( PyArg_ParseTuple(args, "O!", &SVertex_Type, &py_sv) )) + return NULL; + + self->ss->AddNewVertex( ((BPy_SVertex *) py_sv)->sv ); + + Py_RETURN_NONE; +} + +static char SShape_setBBox___doc__[] = +".. method:: setBBox(iBBox)\n" +"\n" +" Sets the bounding box of the SShape.\n" +"\n" +" :arg iBBox: The bounding box of the SShape.\n" +" :type iBBox: :class:`BBox`\n"; + +static PyObject * SShape_setBBox( BPy_SShape *self , PyObject *args) { + PyObject *py_bb = 0; + + if(!( PyArg_ParseTuple(args, "O!", &BBox_Type, &py_bb) )) + return NULL; + + self->ss->setBBox(*( ((BPy_BBox*) py_bb)->bb )); + + Py_RETURN_NONE; +} + +static char SShape_ComputeBBox___doc__[] = +".. method:: ComputeBBox()\n" +"\n" +" Compute the bbox of the SShape.\n"; + +static PyObject * SShape_ComputeBBox( BPy_SShape *self ) { + self->ss->ComputeBBox(); + + Py_RETURN_NONE; +} + +static char SShape_bbox___doc__[] = +".. method:: bbox()\n" +"\n" +" Returns the bounding box of the SShape.\n" +"\n" +" :return: the bounding box of the SShape.\n" +" :rtype: :class:`BBox`\n"; + +static PyObject * SShape_bbox( BPy_SShape *self ) { + BBox<Vec3r> bb( self->ss->bbox() ); + return BPy_BBox_from_BBox( bb ); +} + +static char SShape_getVertexList___doc__[] = +".. method:: getVertexList()\n" +"\n" +" Returns the list of vertices of the SShape.\n" +"\n" +" :return: The list of vertices objects.\n" +" :rtype: List of :class:`SVertex` objects\n"; + +static PyObject * SShape_getVertexList( BPy_SShape *self ) { + PyObject *py_vertices = PyList_New(0); + + vector< SVertex * > vertices = self->ss->getVertexList(); + vector< SVertex * >::iterator it; + + for( it = vertices.begin(); it != vertices.end(); it++ ) { + PyList_Append( py_vertices, BPy_SVertex_from_SVertex(*( *it )) ); + } + + return py_vertices; +} + +static char SShape_getEdgeList___doc__[] = +".. method:: getEdgeList()\n" +"\n" +" Returns the list of edges of the SShape.\n" +"\n" +" :return: The list of edges of the SShape.\n" +" :rtype: List of :class:`FEdge` objects\n"; + +static PyObject * SShape_getEdgeList( BPy_SShape *self ) { + PyObject *py_edges = PyList_New(0); + + vector< FEdge * > edges = self->ss->getEdgeList(); + vector< FEdge * >::iterator it; + + for( it = edges.begin(); it != edges.end(); it++ ) { + PyList_Append( py_edges, Any_BPy_FEdge_from_FEdge(*( *it )) ); + } + + return py_edges; +} + +static char SShape_getId___doc__[] = +".. method:: getId()\n" +"\n" +" Returns the Id of the SShape.\n" +"\n" +" :return: The Id of the SShape.\n" +" :rtype: :class:`Id`\n"; + +static PyObject * SShape_getId( BPy_SShape *self ) { + Id id( self->ss->getId() ); + return BPy_Id_from_Id( id ); +} + +static char SShape_setId___doc__[] = +".. method:: setId(id)\n" +"\n" +" Sets the Id of the SShape.\n" +"\n" +" :arg id: The Id of the SShape.\n" +" :type id: :class:`Id`\n"; + +static PyObject * SShape_setId( BPy_SShape *self , PyObject *args) { + PyObject *py_id; + + if(!( PyArg_ParseTuple(args, "O!", &Id_Type, &py_id) )) + return NULL; + + self->ss->setId(*( ((BPy_Id *) py_id)->id )); + + Py_RETURN_NONE; +} + +static char SShape_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the SShape.\n" +"\n" +" :return: The name string.\n" +" :rtype: str\n"; + +static PyObject * SShape_getName( BPy_SShape *self ) { + return PyUnicode_FromString( self->ss->getName().c_str() ); +} + +static char SShape_setName___doc__[] = +".. method:: setName(name)\n" +"\n" +" Sets the name of the SShape.\n" +"\n" +" :arg name: A name string.\n" +" :type name: str\n"; + +static PyObject * SShape_setName( BPy_SShape *self , PyObject *args) { + char *s; + + if(!( PyArg_ParseTuple(args, "s", &s) )) + return NULL; + + self->ss->setName(s); + + Py_RETURN_NONE; +} + +// const Material & material (unsigned i) const +// const vector< Material > & materials () const +// void SetMaterials (const vector< Material > &iMaterials) + +/*----------------------SShape instance definitions ----------------------------*/ +static PyMethodDef BPy_SShape_methods[] = { + {"AddEdge", ( PyCFunction ) SShape_AddEdge, METH_VARARGS, SShape_AddEdge___doc__}, + {"AddNewVertex", ( PyCFunction ) SShape_AddNewVertex, METH_VARARGS, SShape_AddNewVertex___doc__}, + {"setBBox", ( PyCFunction ) SShape_setBBox, METH_VARARGS, SShape_setBBox___doc__}, + {"ComputeBBox", ( PyCFunction ) SShape_ComputeBBox, METH_NOARGS, SShape_ComputeBBox___doc__}, + {"bbox", ( PyCFunction ) SShape_bbox, METH_NOARGS, SShape_bbox___doc__}, + {"getVertexList", ( PyCFunction ) SShape_getVertexList, METH_NOARGS, SShape_getVertexList___doc__}, + {"getEdgeList", ( PyCFunction ) SShape_getEdgeList, METH_NOARGS, SShape_getEdgeList___doc__}, + {"getId", ( PyCFunction ) SShape_getId, METH_NOARGS, SShape_getId___doc__}, + {"setId", ( PyCFunction ) SShape_setId, METH_VARARGS, SShape_setId___doc__}, + {"getName", ( PyCFunction ) SShape_getName, METH_NOARGS, SShape_getName___doc__}, + {"setName", ( PyCFunction ) SShape_setName, METH_VARARGS, SShape_setName___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_SShape type definition ------------------------------*/ + +PyTypeObject SShape_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "SShape", /* tp_name */ + sizeof(BPy_SShape), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)SShape___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)SShape___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + SShape___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_SShape_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)SShape___init__, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/BPy_SShape.h b/source/blender/freestyle/intern/python/BPy_SShape.h new file mode 100644 index 00000000000..e8d631f0538 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_SShape.h @@ -0,0 +1,35 @@ +#ifndef FREESTYLE_PYTHON_SSHAPE_H +#define FREESTYLE_PYTHON_SSHAPE_H + +#include <Python.h> + +#include "../view_map/Silhouette.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +extern PyTypeObject SShape_Type; + +#define BPy_SShape_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &SShape_Type) ) + +/*---------------------------Python BPy_SShape structure definition----------*/ +typedef struct { + PyObject_HEAD + SShape *ss; + int borrowed; /* non-zero if *ss is a borrowed object */ +} BPy_SShape; + +/*---------------------------Python BPy_SShape visible prototypes-----------*/ + +int SShape_Init( PyObject *module ); + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_SSHAPE_H */ diff --git a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp new file mode 100644 index 00000000000..e68cc3fd28b --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp @@ -0,0 +1,658 @@ +#include "BPy_StrokeAttribute.h" + +#include "BPy_Convert.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- +int StrokeAttribute_Init( PyObject *module ) +{ + if( module == NULL ) + return -1; + + if( PyType_Ready( &StrokeAttribute_Type ) < 0 ) + return -1; + Py_INCREF( &StrokeAttribute_Type ); + PyModule_AddObject(module, "StrokeAttribute", (PyObject *)&StrokeAttribute_Type); + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char StrokeAttribute___doc__[] = +"Class to define a set of attributes associated with a :class:`StrokeVertex`.\n" +"The attribute set stores the color, alpha and thickness values for a Stroke\n" +"Vertex.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(iBrother)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg iBrother: A StrokeAttribute object.\n" +" :type iBrother: :class:`StrokeAttribute`\n" +"\n" +".. method:: __init__(iRColor, iGColor, iBColor, iAlpha, iRThickness, iLThickness)\n" +"\n" +" Builds a stroke vertex attribute from a set of parameters.\n" +"\n" +" :arg iRColor: Red component of a stroke color.\n" +" :type iRColor: float\n" +" :arg iGColor: Green component of a stroke color.\n" +" :type iGColor: float\n" +" :arg iBColor: Blue component of a stroke color.\n" +" :type iBColor: float\n" +" :arg iAlpha: Alpha component of a stroke color.\n" +" :type iAlpha: float\n" +" :arg iRThickness: Stroke thickness on the right.\n" +" :type iRThickness: float\n" +" :arg iLThickness: Stroke thickness on the left.\n" +" :type iLThickness: float\n" +"\n" +".. method:: __init__(a1, a2, t)\n" +"\n" +" Interpolation constructor. Builds a StrokeAttribute from two\n" +" StrokeAttribute objects and an interpolation parameter.\n" +"\n" +" :arg a1: The first StrokeAttribute object.\n" +" :type a1: :class:`StrokeAttribute`\n" +" :arg a2: The second StrokeAttribute object.\n" +" :type a2: :class:`StrokeAttribute`\n" +" :arg t: The interpolation parameter.\n" +" :type t: float\n"; + +static int StrokeAttribute___init__(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds) +{ + + PyObject *obj1 = 0, *obj2 = 0 , *obj3 = 0, *obj4 = 0, *obj5 = 0 , *obj6 = 0; + + if (! PyArg_ParseTuple(args, "|OOOOOO", &obj1, &obj2, &obj3, &obj4, &obj5, &obj6) ) + return -1; + + if( !obj1 || !obj2 || !obj3 ){ + + self->sa = new StrokeAttribute(); + + } else if( BPy_StrokeAttribute_Check(obj1) && + BPy_StrokeAttribute_Check(obj2) && + PyFloat_Check(obj3) ) { + + self->sa = new StrokeAttribute( *( ((BPy_StrokeAttribute *) obj1)->sa ), + *( ((BPy_StrokeAttribute *) obj2)->sa ), + PyFloat_AsDouble( obj3 ) ); + + } else if( obj4 && obj5 && obj6 ) { + + self->sa = new StrokeAttribute( PyFloat_AsDouble( obj1 ), + PyFloat_AsDouble( obj2 ), + PyFloat_AsDouble( obj3 ), + PyFloat_AsDouble( obj4 ), + PyFloat_AsDouble( obj5 ), + PyFloat_AsDouble( obj6 ) ); + + } else { + PyErr_SetString(PyExc_TypeError, "invalid arguments"); + return -1; + } + + self->borrowed = 0; + + return 0; + +} + +static void StrokeAttribute___dealloc__(BPy_StrokeAttribute* self) +{ + if( self->sa && !self->borrowed ) + delete self->sa; + Py_TYPE(self)->tp_free((PyObject*)self); +} + +static PyObject * StrokeAttribute___repr__(BPy_StrokeAttribute* self) +{ + stringstream repr("StrokeAttribute:"); + repr << " r: " << self->sa->getColorR() + << " g: " << self->sa->getColorG() + << " b: " << self->sa->getColorB() + << " a: " << self->sa->getAlpha() + << " - R: " << self->sa->getThicknessR() + << " L: " << self->sa->getThicknessL(); + + return PyUnicode_FromString( repr.str().c_str() ); +} + + +static char StrokeAttribute_getColorR___doc__[] = +".. method:: getColorR()\n" +"\n" +" Returns the red component of the stroke color.\n" +"\n" +" :return: Red component of the stroke color.\n" +" :rtype: float\n"; + +static PyObject *StrokeAttribute_getColorR( BPy_StrokeAttribute *self ) { + return PyFloat_FromDouble( self->sa->getColorR() ); +} + +static char StrokeAttribute_getColorG___doc__[] = +".. method:: getColorG()\n" +"\n" +" Returns the green component of the stroke color.\n" +"\n" +" :return: Green component of the stroke color.\n" +" :rtype: float\n"; + +static PyObject *StrokeAttribute_getColorG( BPy_StrokeAttribute *self ) { + return PyFloat_FromDouble( self->sa->getColorG() ); +} + +static char StrokeAttribute_getColorB___doc__[] = +".. method:: getColorB()\n" +"\n" +" Returns the blue component of the stroke color.\n" +"\n" +" :return: Blue component of the stroke color.\n" +" :rtype: float\n"; + +static PyObject *StrokeAttribute_getColorB( BPy_StrokeAttribute *self ) { + return PyFloat_FromDouble( self->sa->getColorB() ); +} + +static char StrokeAttribute_getColorRGB___doc__[] = +".. method:: getColorRGB()\n" +"\n" +" Returns the RGB components of the stroke color.\n" +"\n" +" :return: RGB components of the stroke color.\n" +" :rtype: :class:`mathutils.Vector`\n"; + +static PyObject *StrokeAttribute_getColorRGB( BPy_StrokeAttribute *self ) { + Vec3f v( self->sa->getColorRGB() ); + return Vector_from_Vec3f( v ); +} + +static char StrokeAttribute_getAlpha___doc__[] = +".. method:: getAlpha()\n" +"\n" +" Returns the alpha component of the stroke color.\n" +"\n" +" :return: Alpha component of the stroke color.\n" +" :rtype: float\n"; + +static PyObject *StrokeAttribute_getAlpha( BPy_StrokeAttribute *self ) { + return PyFloat_FromDouble( self->sa->getAlpha() ); +} + +static char StrokeAttribute_getThicknessR___doc__[] = +".. method:: getThicknessR()\n" +"\n" +" Returns the thickness on the right of the vertex when following\n" +" the stroke.\n" +"\n" +" :return: The thickness on the right of the vertex.\n" +" :rtype: float\n"; + +static PyObject *StrokeAttribute_getThicknessR( BPy_StrokeAttribute *self ) { + return PyFloat_FromDouble( self->sa->getThicknessR() ); +} + +static char StrokeAttribute_getThicknessL___doc__[] = +".. method:: getThicknessL()\n" +"\n" +" Returns the thickness on the left of the vertex when following\n" +" the stroke.\n" +"\n" +" :return: The thickness on the left of the vertex.\n" +" :rtype: float\n"; + +static PyObject *StrokeAttribute_getThicknessL( BPy_StrokeAttribute *self ) { + return PyFloat_FromDouble( self->sa->getThicknessL() ); +} + +static char StrokeAttribute_getThicknessRL___doc__[] = +".. method:: getThicknessRL()\n" +"\n" +" Returns the thickness on the right and on the left of the vertex\n" +" when following the stroke.\n" +"\n" +" :return: A two-dimensional vector. The first value is the\n" +" thickness on the right of the vertex when following the stroke,\n" +" and the second one is the thickness on the left.\n" +" :rtype: :class:`mathutils.Vector`\n"; + +static PyObject *StrokeAttribute_getThicknessRL( BPy_StrokeAttribute *self ) { + Vec2f v( self->sa->getThicknessRL() ); + return Vector_from_Vec2f( v ); +} + +static char StrokeAttribute_isVisible___doc__[] = +".. method:: isVisible()\n" +"\n" +" Returns true if the StrokeVertex is visible, false otherwise.\n" +"\n" +" :return: True if the StrokeVertex is visible, false otherwise.\n" +" :rtype: bool\n"; + +static PyObject *StrokeAttribute_isVisible( BPy_StrokeAttribute *self ) { + return PyBool_from_bool( self->sa->isVisible() ); +} + +static char StrokeAttribute_getAttributeReal___doc__[] = +".. method:: getAttributeReal(iName)\n" +"\n" +" Returns an attribute of float type.\n" +"\n" +" :arg iName: The name of the attribute.\n" +" :type iName: str\n" +" :return: The attribute value.\n" +" :rtype: float\n"; + +static PyObject *StrokeAttribute_getAttributeReal( BPy_StrokeAttribute *self, PyObject *args ) { + char *attr; + + if(!( PyArg_ParseTuple(args, "s", &attr) )) + return NULL; + + double a = self->sa->getAttributeReal( attr ); + return PyFloat_FromDouble( a ); +} + +static char StrokeAttribute_getAttributeVec2f___doc__[] = +".. method:: getAttributeVec2f(iName)\n" +"\n" +" Returns an attribute of two-dimensional vector type.\n" +"\n" +" :arg iName: The name of the attribute.\n" +" :type iName: str\n" +" :return: The attribute value.\n" +" :rtype: :class:`mathutils.Vector`\n"; + +static PyObject *StrokeAttribute_getAttributeVec2f( BPy_StrokeAttribute *self, PyObject *args ) { + char *attr; + + if(!( PyArg_ParseTuple(args, "s", &attr) )) + return NULL; + + Vec2f a = self->sa->getAttributeVec2f( attr ); + return Vector_from_Vec2f( a ); +} + +static char StrokeAttribute_getAttributeVec3f___doc__[] = +".. method:: getAttributeVec3f(iName)\n" +"\n" +" Returns an attribute of three-dimensional vector type.\n" +"\n" +" :arg iName: The name of the attribute.\n" +" :type iName: str\n" +" :return: The attribute value.\n" +" :rtype: :class:`mathutils.Vector`\n"; + +static PyObject *StrokeAttribute_getAttributeVec3f( BPy_StrokeAttribute *self, PyObject *args ) { + char *attr; + + if(!( PyArg_ParseTuple(args, "s", &attr) )) + return NULL; + + Vec3f a = self->sa->getAttributeVec3f( attr ); + return Vector_from_Vec3f( a ); +} + +static char StrokeAttribute_isAttributeAvailableReal___doc__[] = +".. method:: isAttributeAvailableReal(iName)\n" +"\n" +" Checks whether the attribute iName of float type is available.\n" +"\n" +" :arg iName: The name of the attribute.\n" +" :type iName: str\n" +" :return: True if the attribute is availbale.\n" +" :rtype: bool\n"; + +static PyObject *StrokeAttribute_isAttributeAvailableReal( BPy_StrokeAttribute *self, PyObject *args ) { + char *attr; + + if(!( PyArg_ParseTuple(args, "s", &attr) )) + return NULL; + + return PyBool_from_bool( self->sa->isAttributeAvailableReal( attr ) ); +} + +static char StrokeAttribute_isAttributeAvailableVec2f___doc__[] = +".. method:: isAttributeAvailableVec2f(iName)\n" +"\n" +" Checks whether the attribute iName of two-dimensional vector type\n" +" is available.\n" +"\n" +" :arg iName: The name of the attribute.\n" +" :type iName: str\n" +" :return: True if the attribute is availbale.\n" +" :rtype: bool\n"; + +static PyObject *StrokeAttribute_isAttributeAvailableVec2f( BPy_StrokeAttribute *self, PyObject *args ) { + char *attr; + + if(!( PyArg_ParseTuple(args, "s", &attr) )) + return NULL; + + return PyBool_from_bool( self->sa->isAttributeAvailableVec2f( attr ) ); +} + +static char StrokeAttribute_isAttributeAvailableVec3f___doc__[] = +".. method:: isAttributeAvailableVec3f(iName)\n" +"\n" +" Checks whether the attribute iName of three-dimensional vector\n" +" type is available.\n" +"\n" +" :arg iName: The name of the attribute.\n" +" :type iName: str\n" +" :return: True if the attribute is availbale.\n" +" :rtype: bool\n"; + +static PyObject *StrokeAttribute_isAttributeAvailableVec3f( BPy_StrokeAttribute *self, PyObject *args ) { + char *attr; + + if(!( PyArg_ParseTuple(args, "s", &attr) )) + return NULL; + + return PyBool_from_bool( self->sa->isAttributeAvailableVec3f( attr ) ); +} + + +static char StrokeAttribute_setColor___doc__[] = +".. method:: setColor(r, g, b)\n" +"\n" +" Sets the stroke color.\n" +"\n" +" :arg r: Red component of the stroke color.\n" +" :type r: float\n" +" :arg g: Green component of the stroke color.\n" +" :type g: float\n" +" :arg b: Blue component of the stroke color.\n" +" :type b: float\n" +"\n" +".. method:: setColor(iRGB)\n" +"\n" +" Sets the stroke color.\n" +"\n" +" :arg iRGB: The new RGB values.\n" +" :type iRGB: :class:`mathutils.Vector`, list or tuple of 3 real numbers\n"; + +static PyObject * StrokeAttribute_setColor( BPy_StrokeAttribute *self, PyObject *args ) { + PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0 ; + + if(!( PyArg_ParseTuple(args, "O|OO", &obj1, &obj2, &obj3) )) + return NULL; + + if( obj1 && !obj2 && !obj3 ){ + + Vec3f *v = Vec3f_ptr_from_PyObject(obj1); + if( !v ) { + PyErr_SetString(PyExc_TypeError, "argument 1 must be a 3D vector (either a list of 3 elements or Vector)"); + return NULL; + } + self->sa->setColor( *v ); + delete v; + + } else if( obj1 && obj2 && obj3 ){ + + self->sa->setColor( PyFloat_AsDouble(obj1), + PyFloat_AsDouble(obj2), + PyFloat_AsDouble(obj3) ); + + } else { + PyErr_SetString(PyExc_TypeError, "invalid arguments"); + return NULL; + } + + Py_RETURN_NONE; +} + +static char StrokeAttribute_setAlpha___doc__[] = +".. method:: setAlpha(alpha)\n" +"\n" +" Sets the alpha component of the stroke color.\n" +"\n" +" :arg alpha: The new alpha value.\n" +" :type alpha: float\n"; + +static PyObject * StrokeAttribute_setAlpha( BPy_StrokeAttribute *self, PyObject *args ){ + float f = 0; + + if(!( PyArg_ParseTuple(args, "f", &f) )) + return NULL; + + self->sa->setAlpha( f ); + Py_RETURN_NONE; +} + +static char StrokeAttribute_setThickness___doc__[] = +".. method:: setThickness(tr, tl)\n" +"\n" +" Sets the stroke thickness.\n" +"\n" +" :arg tr: The thickness on the right of the vertex when following\n" +" the stroke.\n" +" :type tr: float\n" +" :arg tl: The thickness on the left of the vertex when following\n" +" the stroke.\n" +" :type tl: float\n" +"\n" +".. method:: setThickness(tRL)\n" +"\n" +" Sets the stroke thickness.\n" +"\n" +" :arg tRL: The thickness on the right and on the left of the vertex\n" +" when following the stroke.\n" +" :type tRL: :class:`mathutils.Vector`, list or tuple of 2 real numbers\n"; + +static PyObject * StrokeAttribute_setThickness( BPy_StrokeAttribute *self, PyObject *args ) { + PyObject *obj1 = 0, *obj2 = 0; + + if(!( PyArg_ParseTuple(args, "O|O", &obj1, &obj2) )) + return NULL; + + if( obj1 && !obj2 ){ + + Vec2f *v = Vec2f_ptr_from_PyObject(obj1); + if( !v ) { + PyErr_SetString(PyExc_TypeError, "argument 1 must be a 2D vector (either a list of 2 elements or Vector)"); + return NULL; + } + self->sa->setThickness( *v ); + delete v; + + } else if( obj1 && obj2 ){ + + self->sa->setThickness( PyFloat_AsDouble(obj1), + PyFloat_AsDouble(obj2) ); + + } else { + PyErr_SetString(PyExc_TypeError, "invalid arguments"); + return NULL; + } + + Py_RETURN_NONE; +} + +static char StrokeAttribute_setVisible___doc__[] = +".. method:: setVisible(iVisible)\n" +"\n" +" Sets the visibility flag. True means the StrokeVertex is visible.\n" +"\n" +" :arg iVisible: True if the StrokeVertex is visible.\n" +" :type iVisible: bool\n"; + +static PyObject * StrokeAttribute_setVisible( BPy_StrokeAttribute *self, PyObject *args ) { + PyObject *py_b; + + if(!( PyArg_ParseTuple(args, "O", &py_b) )) + return NULL; + + self->sa->setVisible( bool_from_PyBool(py_b) ); + + Py_RETURN_NONE; +} + +static char StrokeAttribute_setAttributeReal___doc__[] = +".. method:: setAttributeReal(iName, att)\n" +"\n" +" Adds a user-defined attribute of float type. If there is no\n" +" attribute of the given name, it is added. Otherwise, the new value\n" +" replaces the old one.\n" +"\n" +" :arg iName: The name of the attribute.\n" +" :type iName: str\n" +" :arg att: The attribute value.\n" +" :type att: float\n"; + +static PyObject * StrokeAttribute_setAttributeReal( BPy_StrokeAttribute *self, PyObject *args ) { + char *s = 0; + double d = 0; + + if(!( PyArg_ParseTuple(args, "sd", &s, &d) )) + return NULL; + + self->sa->setAttributeReal( s, d ); + Py_RETURN_NONE; +} + +static char StrokeAttribute_setAttributeVec2f___doc__[] = +".. method:: setAttributeVec2f(iName, att)\n" +"\n" +" Adds a user-defined attribute of two-dimensional vector type. If\n" +" there is no attribute of the given name, it is added. Otherwise,\n" +" the new value replaces the old one.\n" +"\n" +" :arg iName: The name of the attribute.\n" +" :type iName: str\n" +" :arg att: The attribute value.\n" +" :type att: :class:`mathutils.Vector`, list or tuple of 2 real numbers\n"; + +static PyObject * StrokeAttribute_setAttributeVec2f( BPy_StrokeAttribute *self, PyObject *args ) { + char *s; + PyObject *obj = 0; + + if(!( PyArg_ParseTuple(args, "sO", &s, &obj) )) + return NULL; + Vec2f *v = Vec2f_ptr_from_PyObject(obj); + if( !v ) { + PyErr_SetString(PyExc_TypeError, "argument 2 must be a 2D vector (either a list of 2 elements or Vector)"); + return NULL; + } + self->sa->setAttributeVec2f( s, *v ); + delete v; + + Py_RETURN_NONE; +} + +static char StrokeAttribute_setAttributeVec3f___doc__[] = +".. method:: setAttributeVec3f(iName, att)\n" +"\n" +" Adds a user-defined attribute of three-dimensional vector type.\n" +" If there is no attribute of the given name, it is added.\n" +" Otherwise, the new value replaces the old one.\n" +"\n" +" :arg iName: The name of the attribute.\n" +" :type iName: str\n" +" :arg att: The attribute value.\n" +" :type att: :class:`mathutils.Vector`, list or tuple of 3 real numbers\n"; + +static PyObject * StrokeAttribute_setAttributeVec3f( BPy_StrokeAttribute *self, PyObject *args ) { + char *s; + PyObject *obj = 0; + + if(!( PyArg_ParseTuple(args, "sO", &s, &obj) )) + return NULL; + Vec3f *v = Vec3f_ptr_from_PyObject(obj); + if( !v ) { + PyErr_SetString(PyExc_TypeError, "argument 2 must be a 3D vector (either a list of 3 elements or Vector)"); + return NULL; + } + self->sa->setAttributeVec3f( s, *v ); + delete v; + + Py_RETURN_NONE; +} + +/*----------------------StrokeAttribute instance definitions ----------------------------*/ +static PyMethodDef BPy_StrokeAttribute_methods[] = { + {"getColorR", ( PyCFunction ) StrokeAttribute_getColorR, METH_NOARGS, StrokeAttribute_getColorR___doc__}, + {"getColorG", ( PyCFunction ) StrokeAttribute_getColorG, METH_NOARGS, StrokeAttribute_getColorG___doc__}, + {"getColorB", ( PyCFunction ) StrokeAttribute_getColorB, METH_NOARGS, StrokeAttribute_getColorB___doc__}, + {"getColorRGB", ( PyCFunction ) StrokeAttribute_getColorRGB, METH_NOARGS, StrokeAttribute_getColorRGB___doc__}, + {"getAlpha", ( PyCFunction ) StrokeAttribute_getAlpha, METH_NOARGS, StrokeAttribute_getAlpha___doc__}, + {"getThicknessR", ( PyCFunction ) StrokeAttribute_getThicknessR, METH_NOARGS, StrokeAttribute_getThicknessR___doc__}, + {"getThicknessL", ( PyCFunction ) StrokeAttribute_getThicknessL, METH_NOARGS, StrokeAttribute_getThicknessL___doc__}, + {"getThicknessRL", ( PyCFunction ) StrokeAttribute_getThicknessRL, METH_NOARGS, StrokeAttribute_getThicknessRL___doc__}, + {"isVisible", ( PyCFunction ) StrokeAttribute_isVisible, METH_NOARGS, StrokeAttribute_isVisible___doc__}, + {"getAttributeReal", ( PyCFunction ) StrokeAttribute_getAttributeReal, METH_VARARGS, StrokeAttribute_getAttributeReal___doc__}, + {"getAttributeVec2f", ( PyCFunction ) StrokeAttribute_getAttributeVec2f, METH_VARARGS, StrokeAttribute_getAttributeVec2f___doc__}, + {"getAttributeVec3f", ( PyCFunction ) StrokeAttribute_getAttributeVec3f, METH_VARARGS, StrokeAttribute_getAttributeVec3f___doc__}, + {"isAttributeAvailableReal", ( PyCFunction ) StrokeAttribute_isAttributeAvailableReal, METH_VARARGS, StrokeAttribute_isAttributeAvailableReal___doc__}, + {"isAttributeAvailableVec2f", ( PyCFunction ) StrokeAttribute_isAttributeAvailableVec2f, METH_VARARGS, StrokeAttribute_isAttributeAvailableVec2f___doc__}, + {"isAttributeAvailableVec3f", ( PyCFunction ) StrokeAttribute_isAttributeAvailableVec3f, METH_VARARGS, StrokeAttribute_isAttributeAvailableVec3f___doc__}, + {"setColor", ( PyCFunction ) StrokeAttribute_setColor, METH_VARARGS, StrokeAttribute_setColor___doc__}, + {"setAlpha", ( PyCFunction ) StrokeAttribute_setAlpha, METH_VARARGS, StrokeAttribute_setAlpha___doc__}, + {"setThickness", ( PyCFunction ) StrokeAttribute_setThickness, METH_VARARGS, StrokeAttribute_setThickness___doc__}, + {"setVisible", ( PyCFunction ) StrokeAttribute_setVisible, METH_VARARGS, StrokeAttribute_setVisible___doc__}, + {"setAttributeReal", ( PyCFunction ) StrokeAttribute_setAttributeReal, METH_VARARGS, StrokeAttribute_setAttributeReal___doc__}, + {"setAttributeVec2f", ( PyCFunction ) StrokeAttribute_setAttributeVec2f, METH_VARARGS, StrokeAttribute_setAttributeVec2f___doc__}, + {"setAttributeVec3f", ( PyCFunction ) StrokeAttribute_setAttributeVec3f, METH_VARARGS, StrokeAttribute_setAttributeVec3f___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_StrokeAttribute type definition ------------------------------*/ + +PyTypeObject StrokeAttribute_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "StrokeAttribute", /* tp_name */ + sizeof(BPy_StrokeAttribute), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)StrokeAttribute___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)StrokeAttribute___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + StrokeAttribute___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_StrokeAttribute_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)StrokeAttribute___init__, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + diff --git a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h new file mode 100644 index 00000000000..51e18c0a96f --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h @@ -0,0 +1,35 @@ +#ifndef FREESTYLE_PYTHON_STROKEATTRIBUTE_H +#define FREESTYLE_PYTHON_STROKEATTRIBUTE_H + +#include <Python.h> + +#include "../stroke/Stroke.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +extern PyTypeObject StrokeAttribute_Type; + +#define BPy_StrokeAttribute_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &StrokeAttribute_Type) ) + +/*---------------------------Python BPy_StrokeAttribute structure definition----------*/ +typedef struct { + PyObject_HEAD + StrokeAttribute *sa; + int borrowed; /* non-zero if *sa is a borrowed reference */ +} BPy_StrokeAttribute; + +/*---------------------------Python BPy_StrokeAttribute visible prototypes-----------*/ + +int StrokeAttribute_Init( PyObject *module ); + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_STROKEATTRIBUTE_H */ diff --git a/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp b/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp new file mode 100644 index 00000000000..202e33c3231 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp @@ -0,0 +1,297 @@ +#include "BPy_StrokeShader.h" + +#include "BPy_Convert.h" +#include "Interface1D/BPy_Stroke.h" + +#include "StrokeShader/BPy_BackboneStretcherShader.h" +#include "StrokeShader/BPy_BezierCurveShader.h" +#include "StrokeShader/BPy_CalligraphicShader.h" +#include "StrokeShader/BPy_ColorNoiseShader.h" +#include "StrokeShader/BPy_ColorVariationPatternShader.h" +#include "StrokeShader/BPy_ConstantColorShader.h" +#include "StrokeShader/BPy_ConstantThicknessShader.h" +#include "StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h" +#include "StrokeShader/BPy_fstreamShader.h" +#include "StrokeShader/BPy_GuidingLinesShader.h" +#include "StrokeShader/BPy_IncreasingColorShader.h" +#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" +#include "StrokeShader/BPy_TextureAssignerShader.h" +#include "StrokeShader/BPy_ThicknessNoiseShader.h" +#include "StrokeShader/BPy_ThicknessVariationPatternShader.h" +#include "StrokeShader/BPy_TipRemoverShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- +int StrokeShader_Init( PyObject *module ) +{ + if( module == NULL ) + return -1; + + if( PyType_Ready( &StrokeShader_Type ) < 0 ) + return -1; + Py_INCREF( &StrokeShader_Type ); + PyModule_AddObject(module, "StrokeShader", (PyObject *)&StrokeShader_Type); + + if( PyType_Ready( &BackboneStretcherShader_Type ) < 0 ) + return -1; + Py_INCREF( &BackboneStretcherShader_Type ); + PyModule_AddObject(module, "BackboneStretcherShader", (PyObject *)&BackboneStretcherShader_Type); + + if( PyType_Ready( &BezierCurveShader_Type ) < 0 ) + return -1; + Py_INCREF( &BezierCurveShader_Type ); + PyModule_AddObject(module, "BezierCurveShader", (PyObject *)&BezierCurveShader_Type); + + if( PyType_Ready( &CalligraphicShader_Type ) < 0 ) + return -1; + Py_INCREF( &CalligraphicShader_Type ); + PyModule_AddObject(module, "CalligraphicShader", (PyObject *)&CalligraphicShader_Type); + + if( PyType_Ready( &ColorNoiseShader_Type ) < 0 ) + return -1; + Py_INCREF( &ColorNoiseShader_Type ); + PyModule_AddObject(module, "ColorNoiseShader", (PyObject *)&ColorNoiseShader_Type); + + if( PyType_Ready( &ColorVariationPatternShader_Type ) < 0 ) + return -1; + Py_INCREF( &ColorVariationPatternShader_Type ); + PyModule_AddObject(module, "ColorVariationPatternShader", (PyObject *)&ColorVariationPatternShader_Type); + + if( PyType_Ready( &ConstantColorShader_Type ) < 0 ) + return -1; + Py_INCREF( &ConstantColorShader_Type ); + PyModule_AddObject(module, "ConstantColorShader", (PyObject *)&ConstantColorShader_Type); + + if( PyType_Ready( &ConstantThicknessShader_Type ) < 0 ) + return -1; + Py_INCREF( &ConstantThicknessShader_Type ); + PyModule_AddObject(module, "ConstantThicknessShader", (PyObject *)&ConstantThicknessShader_Type); + + if( PyType_Ready( &ConstrainedIncreasingThicknessShader_Type ) < 0 ) + return -1; + Py_INCREF( &ConstrainedIncreasingThicknessShader_Type ); + PyModule_AddObject(module, "ConstrainedIncreasingThicknessShader", (PyObject *)&ConstrainedIncreasingThicknessShader_Type); + + if( PyType_Ready( &fstreamShader_Type ) < 0 ) + return -1; + Py_INCREF( &fstreamShader_Type ); + PyModule_AddObject(module, "fstreamShader", (PyObject *)&fstreamShader_Type); + + if( PyType_Ready( &GuidingLinesShader_Type ) < 0 ) + return -1; + Py_INCREF( &GuidingLinesShader_Type ); + PyModule_AddObject(module, "GuidingLinesShader", (PyObject *)&GuidingLinesShader_Type); + + if( PyType_Ready( &IncreasingColorShader_Type ) < 0 ) + return -1; + Py_INCREF( &IncreasingColorShader_Type ); + PyModule_AddObject(module, "IncreasingColorShader", (PyObject *)&IncreasingColorShader_Type); + + if( PyType_Ready( &IncreasingThicknessShader_Type ) < 0 ) + return -1; + Py_INCREF( &IncreasingThicknessShader_Type ); + PyModule_AddObject(module, "IncreasingThicknessShader", (PyObject *)&IncreasingThicknessShader_Type); + + if( PyType_Ready( &PolygonalizationShader_Type ) < 0 ) + return -1; + Py_INCREF( &PolygonalizationShader_Type ); + PyModule_AddObject(module, "PolygonalizationShader", (PyObject *)&PolygonalizationShader_Type); + + if( PyType_Ready( &SamplingShader_Type ) < 0 ) + return -1; + Py_INCREF( &SamplingShader_Type ); + PyModule_AddObject(module, "SamplingShader", (PyObject *)&SamplingShader_Type); + + if( PyType_Ready( &SmoothingShader_Type ) < 0 ) + return -1; + Py_INCREF( &SmoothingShader_Type ); + PyModule_AddObject(module, "SmoothingShader", (PyObject *)&SmoothingShader_Type); + + if( PyType_Ready( &SpatialNoiseShader_Type ) < 0 ) + return -1; + Py_INCREF( &SpatialNoiseShader_Type ); + PyModule_AddObject(module, "SpatialNoiseShader", (PyObject *)&SpatialNoiseShader_Type); + + if( PyType_Ready( &streamShader_Type ) < 0 ) + return -1; + Py_INCREF( &streamShader_Type ); + PyModule_AddObject(module, "streamShader", (PyObject *)&streamShader_Type); + + if( PyType_Ready( &StrokeTextureShader_Type ) < 0 ) + return -1; + Py_INCREF( &StrokeTextureShader_Type ); + PyModule_AddObject(module, "StrokeTextureShader", (PyObject *)&StrokeTextureShader_Type); + + if( PyType_Ready( &TextureAssignerShader_Type ) < 0 ) + return -1; + Py_INCREF( &TextureAssignerShader_Type ); + PyModule_AddObject(module, "TextureAssignerShader", (PyObject *)&TextureAssignerShader_Type); + + if( PyType_Ready( &ThicknessNoiseShader_Type ) < 0 ) + return -1; + Py_INCREF( &ThicknessNoiseShader_Type ); + PyModule_AddObject(module, "ThicknessNoiseShader", (PyObject *)&ThicknessNoiseShader_Type); + + if( PyType_Ready( &ThicknessVariationPatternShader_Type ) < 0 ) + return -1; + Py_INCREF( &ThicknessVariationPatternShader_Type ); + PyModule_AddObject(module, "ThicknessVariationPatternShader", (PyObject *)&ThicknessVariationPatternShader_Type); + + if( PyType_Ready( &TipRemoverShader_Type ) < 0 ) + return -1; + Py_INCREF( &TipRemoverShader_Type ); + PyModule_AddObject(module, "TipRemoverShader", (PyObject *)&TipRemoverShader_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char StrokeShader___doc__[] = +"Base class for stroke shaders. Any stroke shader must inherit from\n" +"this class and overload the shade() method. A StrokeShader is\n" +"designed to modify stroke attributes such as thickness, color,\n" +"geometry, texture, blending mode, and so on. The basic way for this\n" +"operation is to iterate over the stroke vertices of the :class:`Stroke`\n" +"and to modify the :class:`StrokeAttribute` of each vertex. Here is a\n" +"code example of such an iteration::\n" +"\n" +" it = ioStroke.strokeVerticesBegin()\n" +" while it.isEnd() == 0:\n" +" att = it.getObject().attribute()\n" +" ## perform here any attribute modification\n" +" it.increment()\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n"; + +static int StrokeShader___init__(BPy_StrokeShader *self, PyObject *args, PyObject *kwds) +{ + if ( !PyArg_ParseTuple(args, "") ) + return -1; + self->ss = new StrokeShader(); + self->ss->py_ss = (PyObject *) self; + return 0; +} + +static void StrokeShader___dealloc__(BPy_StrokeShader* self) +{ + if (self->ss) + delete self->ss; + Py_TYPE(self)->tp_free((PyObject*)self); +} + + +static PyObject * StrokeShader___repr__(BPy_StrokeShader* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->ss->getName().c_str(), self->ss ); +} + +static char StrokeShader_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of this stroke shader.\n" +"\n" +" :return: The name of this stroke shader.\n" +" :rtype: str\n"; + +static PyObject * StrokeShader_getName( BPy_StrokeShader *self, PyObject *args) +{ + return PyUnicode_FromString( self->ss->getName().c_str() ); +} + +static char StrokeShader_shade___doc__[] = +".. method:: shade(s)\n" +"\n" +" The shading method. Must be overloaded by inherited classes.\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static PyObject *StrokeShader_shade( BPy_StrokeShader *self , PyObject *args) { + PyObject *py_s = 0; + + if(!( PyArg_ParseTuple(args, "O!", &Stroke_Type, &py_s) )) + return NULL; + + if( typeid(*(self->ss)) == typeid(StrokeShader) ) { + PyErr_SetString(PyExc_TypeError, "shade method not properly overridden"); + return NULL; + } + if (self->ss->shade(*( ((BPy_Stroke *) py_s)->s )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->ss->getName() + " shade method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + Py_RETURN_NONE; +} + +/*----------------------StrokeShader instance definitions ----------------------------*/ +static PyMethodDef BPy_StrokeShader_methods[] = { + {"getName", ( PyCFunction ) StrokeShader_getName, METH_NOARGS, StrokeShader_getName___doc__}, + {"shade", ( PyCFunction ) StrokeShader_shade, METH_VARARGS, StrokeShader_shade___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_StrokeShader type definition ------------------------------*/ + +PyTypeObject StrokeShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "StrokeShader", /* tp_name */ + sizeof(BPy_StrokeShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)StrokeShader___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)StrokeShader___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + StrokeShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_StrokeShader_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)StrokeShader___init__, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/BPy_StrokeShader.h b/source/blender/freestyle/intern/python/BPy_StrokeShader.h new file mode 100644 index 00000000000..baa31a3100e --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_StrokeShader.h @@ -0,0 +1,40 @@ +#ifndef FREESTYLE_PYTHON_STROKESHADER_H +#define FREESTYLE_PYTHON_STROKESHADER_H + +#include <Python.h> + +#include "../system/FreestyleConfig.h" + +using namespace std; + +#include "../stroke/StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +extern PyTypeObject StrokeShader_Type; + +#define BPy_StrokeShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &StrokeShader_Type) ) + +/*---------------------------Python BPy_StrokeShader structure definition----------*/ +typedef struct { + PyObject_HEAD + StrokeShader *ss; +} BPy_StrokeShader; + +/*---------------------------Python BPy_StrokeShader visible prototypes-----------*/ + +int StrokeShader_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_STROKESHADER_H */ diff --git a/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.cpp new file mode 100644 index 00000000000..9cb855f32ae --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.cpp @@ -0,0 +1,126 @@ +#include "BPy_UnaryFunction0D.h" + +#include "UnaryFunction0D/BPy_UnaryFunction0DDouble.h" +#include "UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.h" +#include "UnaryFunction0D/BPy_UnaryFunction0DFloat.h" +#include "UnaryFunction0D/BPy_UnaryFunction0DId.h" +#include "UnaryFunction0D/BPy_UnaryFunction0DMaterial.h" +#include "UnaryFunction0D/BPy_UnaryFunction0DUnsigned.h" +#include "UnaryFunction0D/BPy_UnaryFunction0DVec2f.h" +#include "UnaryFunction0D/BPy_UnaryFunction0DVec3f.h" +#include "UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h" +#include "UnaryFunction0D/BPy_UnaryFunction0DViewShape.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- +int UnaryFunction0D_Init( PyObject *module ) +{ + if( module == NULL ) + return -1; + + if( PyType_Ready( &UnaryFunction0D_Type ) < 0 ) + return -1; + Py_INCREF( &UnaryFunction0D_Type ); + PyModule_AddObject(module, "UnaryFunction0D", (PyObject *)&UnaryFunction0D_Type); + + UnaryFunction0DDouble_Init( module ); + UnaryFunction0DEdgeNature_Init( module ); + UnaryFunction0DFloat_Init( module ); + UnaryFunction0DId_Init( module ); + UnaryFunction0DMaterial_Init( module ); + UnaryFunction0DUnsigned_Init( module ); + UnaryFunction0DVec2f_Init( module ); + UnaryFunction0DVec3f_Init( module ); + UnaryFunction0DVectorViewShape_Init( module ); + UnaryFunction0DViewShape_Init( module ); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char UnaryFunction0D___doc__[] = +"Base class for Unary Functions (functors) working on\n" +":class:`Interface0DIterator`. A unary function will be used by\n" +"invoking __call__() on an Interface0DIterator. In Python, several\n" +"different subclasses of UnaryFunction0D are used depending on the\n" +"types of functors' return values. For example, you would inherit from\n" +"a :class:`UnaryFunction0DDouble` if you wish to define a function that\n" +"returns a double value. Available UnaryFunction0D subclasses are:\n" +"\n" +"* :class:`UnaryFunction0DDouble`\n" +"* :class:`UnaryFunction0DEdgeNature`\n" +"* :class:`UnaryFunction0DFloat`\n" +"* :class:`UnaryFunction0DId`\n" +"* :class:`UnaryFunction0DMaterial`\n" +"* :class:`UnaryFunction0DUnsigned`\n" +"* :class:`UnaryFunction0DVec2f`\n" +"* :class:`UnaryFunction0DVec3f`\n" +"* :class:`UnaryFunction0DVectorViewShape`\n" +"* :class:`UnaryFunction0DViewShape`\n"; + +static void UnaryFunction0D___dealloc__(BPy_UnaryFunction0D* self) +{ + Py_TYPE(self)->tp_free((PyObject*)self); +} + + +static PyObject * UnaryFunction0D___repr__(BPy_UnaryFunction0D* self) +{ + return PyUnicode_FromString("UnaryFunction0D"); +} + +/*-----------------------BPy_UnaryFunction0D type definition ------------------------------*/ + +PyTypeObject UnaryFunction0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "UnaryFunction0D", /* tp_name */ + sizeof(BPy_UnaryFunction0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)UnaryFunction0D___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)UnaryFunction0D___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + UnaryFunction0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h b/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h new file mode 100644 index 00000000000..6d61c336662 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h @@ -0,0 +1,34 @@ +#ifndef FREESTYLE_PYTHON_UNARYFUNCTION0D_H +#define FREESTYLE_PYTHON_UNARYFUNCTION0D_H + +#include <Python.h> + +#include "../view_map/Functions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +extern PyTypeObject UnaryFunction0D_Type; + +#define BPy_UnaryFunction0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &UnaryFunction0D_Type) ) + +/*---------------------------Python BPy_UnaryFunction0D structure definition----------*/ +typedef struct { + PyObject_HEAD + PyObject *py_uf0D; +} BPy_UnaryFunction0D; + +/*---------------------------Python BPy_UnaryFunction0D visible prototypes-----------*/ + +int UnaryFunction0D_Init( PyObject *module ); + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_UNARYFUNCTION0D_H */ diff --git a/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp new file mode 100644 index 00000000000..f4de9edb962 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp @@ -0,0 +1,117 @@ +#include "BPy_UnaryFunction1D.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" +#include "UnaryFunction1D/BPy_UnaryFunction1DVoid.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- +int UnaryFunction1D_Init( PyObject *module ) +{ + if( module == NULL ) + return -1; + + if( PyType_Ready( &UnaryFunction1D_Type ) < 0 ) + return -1; + Py_INCREF( &UnaryFunction1D_Type ); + PyModule_AddObject(module, "UnaryFunction1D", (PyObject *)&UnaryFunction1D_Type); + + UnaryFunction1DDouble_Init( module ); + UnaryFunction1DEdgeNature_Init( module ); + UnaryFunction1DFloat_Init( module ); + UnaryFunction1DUnsigned_Init( module ); + UnaryFunction1DVec2f_Init( module ); + UnaryFunction1DVec3f_Init( module ); + UnaryFunction1DVectorViewShape_Init( module ); + UnaryFunction1DVoid_Init( module ); + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char UnaryFunction1D___doc__[] = +"Base class for Unary Functions (functors) working on\n" +":class:`Interface1D`. A unary function will be used by invoking\n" +"__call__() on an Interface1D. In Python, several different subclasses\n" +"of UnaryFunction1D are used depending on the types of functors' return\n" +"values. For example, you would inherit from a\n" +":class:`UnaryFunction1DDouble` if you wish to define a function that\n" +"returns a double value. Available UnaryFunction1D subclasses are:\n" +"\n" +"* :class:`UnaryFunction1DDouble`\n" +"* :class:`UnaryFunction1DEdgeNature`\n" +"* :class:`UnaryFunction1DFloat`\n" +"* :class:`UnaryFunction1DUnsigned`\n" +"* :class:`UnaryFunction1DVec2f`\n" +"* :class:`UnaryFunction1DVec3f`\n" +"* :class:`UnaryFunction1DVectorViewShape`\n" +"* :class:`UnaryFunction1DVoid`\n"; + +static void UnaryFunction1D___dealloc__(BPy_UnaryFunction1D* self) +{ + Py_TYPE(self)->tp_free((PyObject*)self); +} + +static PyObject * UnaryFunction1D___repr__(BPy_UnaryFunction1D* self) +{ + return PyUnicode_FromString("UnaryFunction1D"); +} + +/*-----------------------BPy_UnaryFunction1D type definition ------------------------------*/ + +PyTypeObject UnaryFunction1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "UnaryFunction1D", /* tp_name */ + sizeof(BPy_UnaryFunction1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)UnaryFunction1D___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)UnaryFunction1D___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + UnaryFunction1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h b/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h new file mode 100644 index 00000000000..cb9df18ab75 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h @@ -0,0 +1,34 @@ +#ifndef FREESTYLE_PYTHON_UNARYFUNCTION1D_H +#define FREESTYLE_PYTHON_UNARYFUNCTION1D_H + +#include <Python.h> + +#include "../view_map/Functions1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +extern PyTypeObject UnaryFunction1D_Type; + +#define BPy_UnaryFunction1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &UnaryFunction1D_Type) ) + +/*---------------------------Python BPy_UnaryFunction1D structure definition----------*/ +typedef struct { + PyObject_HEAD + PyObject *py_uf1D; +} BPy_UnaryFunction1D; + +/*---------------------------Python BPy_UnaryFunction1D visible prototypes-----------*/ + +int UnaryFunction1D_Init( PyObject *module ); + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_UNARYFUNCTION1D_H */ diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp new file mode 100644 index 00000000000..81f39ef7ab7 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp @@ -0,0 +1,184 @@ +#include "BPy_UnaryPredicate0D.h" + +#include "BPy_Convert.h" +#include "Iterator/BPy_Interface0DIterator.h" +#include "UnaryPredicate0D/BPy_FalseUP0D.h" +#include "UnaryPredicate0D/BPy_TrueUP0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- +int UnaryPredicate0D_Init( PyObject *module ) +{ + if( module == NULL ) + return -1; + + if( PyType_Ready( &UnaryPredicate0D_Type ) < 0 ) + return -1; + Py_INCREF( &UnaryPredicate0D_Type ); + PyModule_AddObject(module, "UnaryPredicate0D", (PyObject *)&UnaryPredicate0D_Type); + + if( PyType_Ready( &FalseUP0D_Type ) < 0 ) + return -1; + Py_INCREF( &FalseUP0D_Type ); + PyModule_AddObject(module, "FalseUP0D", (PyObject *)&FalseUP0D_Type); + + if( PyType_Ready( &TrueUP0D_Type ) < 0 ) + return -1; + Py_INCREF( &TrueUP0D_Type ); + PyModule_AddObject(module, "TrueUP0D", (PyObject *)&TrueUP0D_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char UnaryPredicate0D___doc__[] = +"Base class for unary predicates that work on\n" +":class:`Interface0DIterator`. A UnaryPredicate0D is a functor that\n" +"evaluates a condition on an Interface0DIterator and returns true or\n" +"false depending on whether this condition is satisfied or not. The\n" +"UnaryPredicate0D is used by invoking its __call__() method. Any\n" +"inherited class must overload the __call__() method.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Must be overload by inherited classes.\n" +"\n" +" :arg it: The Interface0DIterator pointing onto the Interface0D at\n" +" which we wish to evaluate the predicate.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: True if the condition is satisfied, false otherwise.\n" +" :rtype: bool\n"; + +static int UnaryPredicate0D___init__(BPy_UnaryPredicate0D *self, PyObject *args, PyObject *kwds) +{ + if ( !PyArg_ParseTuple(args, "") ) + return -1; + self->up0D = new UnaryPredicate0D(); + self->up0D->py_up0D = (PyObject *) self; + return 0; +} + +static void UnaryPredicate0D___dealloc__(BPy_UnaryPredicate0D* self) +{ + if (self->up0D) + delete self->up0D; + Py_TYPE(self)->tp_free((PyObject*)self); +} + +static PyObject * UnaryPredicate0D___repr__(BPy_UnaryPredicate0D* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->up0D->getName().c_str(), self->up0D ); +} + +static char UnaryPredicate0D_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the UnaryPredicate0D.\n" +"\n" +" :return: The name of the UnaryPredicate0D.\n" +" :rtype: str\n"; + +static PyObject * UnaryPredicate0D_getName( BPy_UnaryPredicate0D *self ) +{ + return PyUnicode_FromString( self->up0D->getName().c_str() ); +} + +static PyObject * UnaryPredicate0D___call__( BPy_UnaryPredicate0D *self, PyObject *args, PyObject *kwds) +{ + PyObject *py_if0D_it; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } + if( !PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &py_if0D_it) ) + return NULL; + + Interface0DIterator *if0D_it = ((BPy_Interface0DIterator *) py_if0D_it)->if0D_it; + + if( !if0D_it ) { + string msg(self->up0D->getName() + " has no Interface0DIterator"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + return NULL; + } + if( typeid(*(self->up0D)) == typeid(UnaryPredicate0D) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); + return NULL; + } + if (self->up0D->operator()(*if0D_it) < 0) { + if (!PyErr_Occurred()) { + string msg(self->up0D->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return PyBool_from_bool( self->up0D->result ); +} + +/*----------------------UnaryPredicate0D instance definitions ----------------------------*/ +static PyMethodDef BPy_UnaryPredicate0D_methods[] = { + {"getName", ( PyCFunction ) UnaryPredicate0D_getName, METH_NOARGS, UnaryPredicate0D_getName___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_UnaryPredicate0D type definition ------------------------------*/ + +PyTypeObject UnaryPredicate0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "UnaryPredicate0D", /* tp_name */ + sizeof(BPy_UnaryPredicate0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)UnaryPredicate0D___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)UnaryPredicate0D___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)UnaryPredicate0D___call__, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + UnaryPredicate0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_UnaryPredicate0D_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)UnaryPredicate0D___init__, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + + diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.h b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.h new file mode 100644 index 00000000000..9f9bb0c1003 --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.h @@ -0,0 +1,34 @@ +#ifndef FREESTYLE_PYTHON_UNARYPREDICATE0D_H +#define FREESTYLE_PYTHON_UNARYPREDICATE0D_H + +#include <Python.h> + +#include "../stroke/Predicates0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +extern PyTypeObject UnaryPredicate0D_Type; + +#define BPy_UnaryPredicate0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &UnaryPredicate0D_Type) ) + +/*---------------------------Python BPy_UnaryPredicate0D structure definition----------*/ +typedef struct { + PyObject_HEAD + UnaryPredicate0D *up0D; +} BPy_UnaryPredicate0D; + +/*---------------------------Python BPy_UnaryPredicate0D visible prototypes-----------*/ + +int UnaryPredicate0D_Init( PyObject *module ); + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_UNARYPREDICATE0D_H */ diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp new file mode 100644 index 00000000000..095963fb3af --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp @@ -0,0 +1,230 @@ +#include "BPy_UnaryPredicate1D.h" + +#include "BPy_Convert.h" +#include "BPy_Interface1D.h" + +#include "UnaryPredicate1D/BPy_ContourUP1D.h" +#include "UnaryPredicate1D/BPy_DensityLowerThanUP1D.h" +#include "UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h" +#include "UnaryPredicate1D/BPy_EqualToTimeStampUP1D.h" +#include "UnaryPredicate1D/BPy_ExternalContourUP1D.h" +#include "UnaryPredicate1D/BPy_FalseUP1D.h" +#include "UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h" +#include "UnaryPredicate1D/BPy_ShapeUP1D.h" +#include "UnaryPredicate1D/BPy_TrueUP1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- +int UnaryPredicate1D_Init( PyObject *module ) +{ + if( module == NULL ) + return -1; + + if( PyType_Ready( &UnaryPredicate1D_Type ) < 0 ) + return -1; + Py_INCREF( &UnaryPredicate1D_Type ); + PyModule_AddObject(module, "UnaryPredicate1D", (PyObject *)&UnaryPredicate1D_Type); + + if( PyType_Ready( &ContourUP1D_Type ) < 0 ) + return -1; + Py_INCREF( &ContourUP1D_Type ); + PyModule_AddObject(module, "ContourUP1D", (PyObject *)&ContourUP1D_Type); + + if( PyType_Ready( &DensityLowerThanUP1D_Type ) < 0 ) + return -1; + Py_INCREF( &DensityLowerThanUP1D_Type ); + PyModule_AddObject(module, "DensityLowerThanUP1D", (PyObject *)&DensityLowerThanUP1D_Type); + + if( PyType_Ready( &EqualToChainingTimeStampUP1D_Type ) < 0 ) + return -1; + Py_INCREF( &EqualToChainingTimeStampUP1D_Type ); + PyModule_AddObject(module, "EqualToChainingTimeStampUP1D", (PyObject *)&EqualToChainingTimeStampUP1D_Type); + + if( PyType_Ready( &EqualToTimeStampUP1D_Type ) < 0 ) + return -1; + Py_INCREF( &EqualToTimeStampUP1D_Type ); + PyModule_AddObject(module, "EqualToTimeStampUP1D", (PyObject *)&EqualToTimeStampUP1D_Type); + + if( PyType_Ready( &ExternalContourUP1D_Type ) < 0 ) + return -1; + Py_INCREF( &ExternalContourUP1D_Type ); + PyModule_AddObject(module, "ExternalContourUP1D", (PyObject *)&ExternalContourUP1D_Type); + + if( PyType_Ready( &FalseUP1D_Type ) < 0 ) + return -1; + Py_INCREF( &FalseUP1D_Type ); + PyModule_AddObject(module, "FalseUP1D", (PyObject *)&FalseUP1D_Type); + + if( PyType_Ready( &QuantitativeInvisibilityUP1D_Type ) < 0 ) + return -1; + Py_INCREF( &QuantitativeInvisibilityUP1D_Type ); + PyModule_AddObject(module, "QuantitativeInvisibilityUP1D", (PyObject *)&QuantitativeInvisibilityUP1D_Type); + + if( PyType_Ready( &ShapeUP1D_Type ) < 0 ) + return -1; + Py_INCREF( &ShapeUP1D_Type ); + PyModule_AddObject(module, "ShapeUP1D", (PyObject *)&ShapeUP1D_Type); + + if( PyType_Ready( &TrueUP1D_Type ) < 0 ) + return -1; + Py_INCREF( &TrueUP1D_Type ); + PyModule_AddObject(module, "TrueUP1D", (PyObject *)&TrueUP1D_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char UnaryPredicate1D___doc__[] = +"Base class for unary predicates that work on :class:`Interface1D`. A\n" +"UnaryPredicate1D is a functor that evaluates a condition on a\n" +"Interface1D and returns true or false depending on whether this\n" +"condition is satisfied or not. The UnaryPredicate1D is used by\n" +"invoking its __call__() method. Any inherited class must overload the\n" +"__call__() method.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Must be overload by inherited classes.\n" +"\n" +" :arg inter: The Interface1D on which we wish to evaluate the predicate.\n" +" :type inter: :class:`Interface1D`\n" +" :return: True if the condition is satisfied, false otherwise.\n" +" :rtype: bool\n"; + +static int UnaryPredicate1D___init__(BPy_UnaryPredicate1D *self, PyObject *args, PyObject *kwds) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->up1D = new UnaryPredicate1D(); + self->up1D->py_up1D = (PyObject *) self; + return 0; +} + +static void UnaryPredicate1D___dealloc__(BPy_UnaryPredicate1D* self) +{ + if (self->up1D) + delete self->up1D; + Py_TYPE(self)->tp_free((PyObject*)self); +} + +static PyObject * UnaryPredicate1D___repr__(BPy_UnaryPredicate1D* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->up1D->getName().c_str(), self->up1D ); +} + +static char UnaryPredicate1D_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the string of the name of the UnaryPredicate1D.\n" +"\n" +" Reimplemented in TrueUP1D, FalseUP1D, QuantitativeInvisibilityUP1D,\n" +" ContourUP1D, ExternalContourUP1D, EqualToTimeStampUP1D,\n" +" EqualToChainingTimeStampUP1D, ShapeUP1D, and DensityLowerThanUP1D.\n" +"\n" +" :return: \n" +" :rtype: str\n"; + +static PyObject * UnaryPredicate1D_getName( BPy_UnaryPredicate1D *self, PyObject *args) +{ + return PyUnicode_FromString( self->up1D->getName().c_str() ); +} + +static PyObject * UnaryPredicate1D___call__( BPy_UnaryPredicate1D *self, PyObject *args, PyObject *kwds) +{ + PyObject *py_if1D; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } + if( !PyArg_ParseTuple(args, "O!", &Interface1D_Type, &py_if1D) ) + return NULL; + + Interface1D *if1D = ((BPy_Interface1D *) py_if1D)->if1D; + + if( !if1D ) { + string msg(self->up1D->getName() + " has no Interface0DIterator"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + return NULL; + } + if( typeid(*(self->up1D)) == typeid(UnaryPredicate1D) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); + return NULL; + } + if( self->up1D->operator()(*if1D) < 0 ) { + if (!PyErr_Occurred()) { + string msg(self->up1D->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return PyBool_from_bool( self->up1D->result ); +} + +/*----------------------UnaryPredicate1D instance definitions ----------------------------*/ +static PyMethodDef BPy_UnaryPredicate1D_methods[] = { + {"getName", ( PyCFunction ) UnaryPredicate1D_getName, METH_NOARGS, UnaryPredicate1D_getName___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_UnaryPredicate1D type definition ------------------------------*/ + +PyTypeObject UnaryPredicate1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "UnaryPredicate1D", /* tp_name */ + sizeof(BPy_UnaryPredicate1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)UnaryPredicate1D___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)UnaryPredicate1D___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)UnaryPredicate1D___call__, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + UnaryPredicate1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_UnaryPredicate1D_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)UnaryPredicate1D___init__, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + + diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.h b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.h new file mode 100644 index 00000000000..75953e7977b --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.h @@ -0,0 +1,34 @@ +#ifndef FREESTYLE_PYTHON_UNARYPREDICATE1D_H +#define FREESTYLE_PYTHON_UNARYPREDICATE1D_H + +#include <Python.h> + +#include "../stroke/Predicates1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +extern PyTypeObject UnaryPredicate1D_Type; + +#define BPy_UnaryPredicate1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &UnaryPredicate1D_Type) ) + +/*---------------------------Python BPy_UnaryPredicate1D structure definition----------*/ +typedef struct { + PyObject_HEAD + UnaryPredicate1D *up1D; +} BPy_UnaryPredicate1D; + +/*---------------------------Python BPy_UnaryPredicate1D visible prototypes-----------*/ + +int UnaryPredicate1D_Init( PyObject *module ); + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_UNARYPREDICATE1D_H */ diff --git a/source/blender/freestyle/intern/python/BPy_ViewMap.cpp b/source/blender/freestyle/intern/python/BPy_ViewMap.cpp new file mode 100644 index 00000000000..c9667103e5a --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_ViewMap.cpp @@ -0,0 +1,195 @@ +#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 + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- +int ViewMap_Init( PyObject *module ) +{ + if( module == NULL ) + return -1; + + if( PyType_Ready( &ViewMap_Type ) < 0 ) + return -1; + + Py_INCREF( &ViewMap_Type ); + PyModule_AddObject(module, "ViewMap", (PyObject *)&ViewMap_Type); + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ViewMap___doc__[] = +"Class defining the ViewMap.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n"; + +static int ViewMap___init__(BPy_ViewMap *self, PyObject *args, PyObject *kwds) +{ + self->vm = new ViewMap(); + return 0; +} + +static void ViewMap___dealloc__(BPy_ViewMap *self) +{ + if( self->vm ) + delete self->vm; + Py_TYPE(self)->tp_free((PyObject*)self); +} + +static PyObject * ViewMap___repr__(BPy_ViewMap *self) +{ + return PyUnicode_FromFormat("ViewMap - address: %p", self->vm ); +} + +static char ViewMap_getClosestViewEdge___doc__[] = +".. method:: getClosestViewEdge(x, y)\n" +"\n" +" Gets the ViewEdge nearest to the 2D point specified as arguments.\n" +"\n" +" :arg x: X coordinate of a 2D point.\n" +" :type x: float\n" +" :arg y: Y coordinate of a 2D point.\n" +" :type y: float\n" +" :return: The ViewEdge nearest to the specified 2D point.\n" +" :rtype: :class:`ViewEdge`\n"; + +static PyObject * ViewMap_getClosestViewEdge( BPy_ViewMap *self , PyObject *args) { + double x, y; + + if(!( PyArg_ParseTuple(args, "dd", &x, &y) )) + return NULL; + + ViewEdge *ve = const_cast<ViewEdge *>( self->vm->getClosestViewEdge(x,y) ); + if( ve ) + return BPy_ViewEdge_from_ViewEdge(*ve); + + Py_RETURN_NONE; +} + +static char ViewMap_getClosestFEdge___doc__[] = +".. method:: getClosestFEdge(x, y)\n" +"\n" +" Gets the FEdge nearest to the 2D point specified as arguments.\n" +"\n" +" :arg x: X coordinate of a 2D point.\n" +" :type x: float\n" +" :arg y: Y coordinate of a 2D point.\n" +" :type y: float\n" +" :return: The FEdge nearest to the specified 2D point.\n" +" :rtype: :class:`FEdge`\n"; + +static PyObject * ViewMap_getClosestFEdge( BPy_ViewMap *self , PyObject *args) { + double x, y; + + if(!( PyArg_ParseTuple(args, "dd", &x, &y) )) + return NULL; + + FEdge *fe = const_cast<FEdge *>( self->vm->getClosestFEdge(x,y) ); + if( fe ) + return Any_BPy_FEdge_from_FEdge(*fe); + + Py_RETURN_NONE; +} + +static char ViewMap_getScene3dBBox___doc__[] = +".. method:: getScene3dBBox()\n" +"\n" +" Returns the scene 3D bounding box.\n" +"\n" +" :return: The scene 3D bounding box.\n" +" :rtype: :class:`BBox`\n"; + +static PyObject * ViewMap_getScene3dBBox( BPy_ViewMap *self , PyObject *args) { + BBox<Vec3r> bb( self->vm->getScene3dBBox() ); + return BPy_BBox_from_BBox( bb ); +} + +static char ViewMap_setScene3dBBox___doc__[] = +".. method:: setScene3dBBox(bbox)\n" +"\n" +" Sets the scene 3D bounding box.\n" +"\n" +" :arg bbox: The scene 3D bounding box.\n" +" :type bbox: :class:`BBox`\n"; + +static PyObject * ViewMap_setScene3dBBox( BPy_ViewMap *self , PyObject *args) { + PyObject *py_bb = 0; + + if(!( PyArg_ParseTuple(args, "O!", &BBox_Type, &py_bb) )) + return NULL; + + self->vm->setScene3dBBox(*( ((BPy_BBox *) py_bb)->bb )); + + Py_RETURN_NONE; +} + +// static ViewMap *getInstance (); + +/*---------------------- BPy_ViewShape instance definitions ----------------------------*/ +static PyMethodDef BPy_ViewMap_methods[] = { + {"getClosestViewEdge", ( PyCFunction ) ViewMap_getClosestViewEdge, METH_VARARGS, ViewMap_getClosestViewEdge___doc__}, + {"getClosestFEdge", ( PyCFunction ) ViewMap_getClosestFEdge, METH_VARARGS, ViewMap_getClosestFEdge___doc__}, + {"getScene3dBBox", ( PyCFunction ) ViewMap_getScene3dBBox, METH_NOARGS, ViewMap_getScene3dBBox___doc__}, + {"setScene3dBBox", ( PyCFunction ) ViewMap_setScene3dBBox, METH_VARARGS, ViewMap_setScene3dBBox___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_ViewMap type definition ------------------------------*/ + +PyTypeObject ViewMap_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ViewMap", /* tp_name */ + sizeof(BPy_ViewMap), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)ViewMap___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)ViewMap___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ViewMap___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_ViewMap_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ViewMap___init__, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/BPy_ViewMap.h b/source/blender/freestyle/intern/python/BPy_ViewMap.h new file mode 100644 index 00000000000..943aeb718fc --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_ViewMap.h @@ -0,0 +1,34 @@ +#ifndef FREESTYLE_PYTHON_VIEWMAP_H +#define FREESTYLE_PYTHON_VIEWMAP_H + +#include <Python.h> + +#include "../view_map/ViewMap.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +extern PyTypeObject ViewMap_Type; + +#define BPy_ViewMap_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ViewMap_Type) ) + +/*---------------------------Python BPy_ViewMap structure definition----------*/ +typedef struct { + PyObject_HEAD + ViewMap *vm; +} BPy_ViewMap; + +/*---------------------------Python BPy_ViewMap visible prototypes-----------*/ + +int ViewMap_Init( PyObject *module ); + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_VIEWMAP_H */ diff --git a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp new file mode 100644 index 00000000000..eebfa88773c --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp @@ -0,0 +1,353 @@ +#include "BPy_ViewShape.h" + +#include "BPy_Convert.h" +#include "Interface0D/BPy_ViewVertex.h" +#include "Interface1D/BPy_ViewEdge.h" +#include "BPy_SShape.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- +int ViewShape_Init( PyObject *module ) +{ + if( module == NULL ) + return -1; + + if( PyType_Ready( &ViewShape_Type ) < 0 ) + return -1; + + Py_INCREF( &ViewShape_Type ); + PyModule_AddObject(module, "ViewShape", (PyObject *)&ViewShape_Type); + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ViewShape___doc__[] = +"Class gathering the elements of the ViewMap (i.e., :class:`ViewVertex`\n" +"and :class:`ViewEdge`) that are issued from the same input shape.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(iBrother)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg iBrother: A ViewShape object.\n" +" :type iBrother: :class:`ViewShape`\n" +"\n" +".. method:: __init__(iSShape)\n" +"\n" +" Builds a ViewShape from an SShape.\n" +"\n" +" :arg iSShape: An SShape object.\n" +" :type iSShape: :class:`SShape`\n"; + +static int ViewShape___init__(BPy_ViewShape *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj; + + if (! PyArg_ParseTuple(args, "|O", &obj) ) + return -1; + + if( !obj ) { + self->vs = new ViewShape(); + + } else if( BPy_SShape_Check(obj) ) { + self->vs = new ViewShape( ((BPy_SShape *) obj)->ss ); + + } else if( BPy_ViewShape_Check(obj) ) { + self->vs = new ViewShape(*( ((BPy_ViewShape *) obj)->vs )); + + } else { + PyErr_SetString(PyExc_TypeError, "invalid argument"); + return -1; + } + self->borrowed = 0; + + return 0; +} + +static void ViewShape___dealloc__(BPy_ViewShape *self) +{ + if( self->vs && !self->borrowed ) + delete self->vs; + Py_TYPE(self)->tp_free((PyObject*)self); +} + +static PyObject * ViewShape___repr__(BPy_ViewShape *self) +{ + return PyUnicode_FromFormat("ViewShape - address: %p", self->vs ); +} + +static char ViewShape_sshape___doc__[] = +".. method:: sshape()\n" +"\n" +" Returns the SShape on top of which this ViewShape is built.\n" +"\n" +" :return: The SShape on top of which this ViewShape is built.\n" +" :rtype: :class:`SShape`\n"; + +static PyObject * ViewShape_sshape( BPy_ViewShape *self ) { + return BPy_SShape_from_SShape( *(self->vs->sshape()) ); +} + +static char ViewShape_vertices___doc__[] = +".. method:: vertices()\n" +"\n" +" Returns the list of ViewVertex objects contained in this ViewShape.\n" +"\n" +" :return: The list of ViewVertex objects.\n" +" :rtype: List of :class:`ViewVertex` objects\n"; + +static PyObject * ViewShape_vertices( BPy_ViewShape *self ) { + PyObject *py_vertices = PyList_New(0); + + vector< ViewVertex * > vertices = self->vs->vertices(); + vector< ViewVertex * >::iterator it; + + for( it = vertices.begin(); it != vertices.end(); it++ ) { + PyList_Append( py_vertices, Any_BPy_ViewVertex_from_ViewVertex(*( *it )) ); + } + + return py_vertices; +} + +static char ViewShape_edges___doc__[] = +".. method:: edges()\n" +"\n" +" Returns the list of ViewEdge objects contained in this ViewShape.\n" +"\n" +" :return: The list of ViewEdge objects.\n" +" :rtype: List of :class:`ViewEdge` objects\n"; + +static PyObject * ViewShape_edges( BPy_ViewShape *self ) { + PyObject *py_edges = PyList_New(0); + + vector< ViewEdge * > edges = self->vs->edges(); + vector< ViewEdge * >::iterator it; + + for( it = edges.begin(); it != edges.end(); it++ ) { + PyList_Append( py_edges, BPy_ViewEdge_from_ViewEdge(*( *it )) ); + } + + return py_edges; +} + +static char ViewShape_getId___doc__[] = +".. method:: getId()\n" +"\n" +" Returns the ViewShape id.\n" +"\n" +" :return: An Id object.\n" +" :rtype: :class:`Id`\n"; + +static PyObject * ViewShape_getId( BPy_ViewShape *self ) { + Id id( self->vs->getId() ); + return BPy_Id_from_Id( id ); +} + +static char ViewShape_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the ViewShape.\n" +"\n" +" :return: The name string.\n" +" :rtype: str\n"; + +static PyObject * ViewShape_getName( BPy_ViewShape *self ) { + return PyUnicode_FromString( self->vs->getName().c_str() ); +} + +static char ViewShape_setSShape___doc__[] = +".. method:: setSShape(iSShape)\n" +"\n" +" Sets the SShape on top of which the ViewShape is built.\n" +"\n" +" :arg iSShape: An SShape object.\n" +" :type iSShape: :class:`SShape`\n"; + +static PyObject * ViewShape_setSShape( BPy_ViewShape *self , PyObject *args) { + PyObject *py_ss = 0; + + if(!( PyArg_ParseTuple(args, "O!", &SShape_Type, &py_ss) )) + return NULL; + + self->vs->setSShape( ((BPy_SShape *) py_ss)->ss ); + + Py_RETURN_NONE; +} + +static char ViewShape_setVertices___doc__[] = +".. method:: setVertices(iVertices)\n" +"\n" +" Sets the list of ViewVertex objects contained in this ViewShape.\n" +"\n" +" :arg iVertices: The list of ViewVertex objects.\n" +" :type iVertices: List of :class:`ViewVertex` objects\n"; + +static PyObject * ViewShape_setVertices( BPy_ViewShape *self , PyObject *args) { + PyObject *list = 0; + PyObject *tmp; + + if(!( PyArg_ParseTuple(args, "O!", &PyList_Type, &list) )) + return NULL; + + vector< ViewVertex *> v; + + for( int i=0; i < PyList_Size(list); i++ ) { + tmp = PyList_GetItem(list, i); + if( BPy_ViewVertex_Check(tmp) ) + v.push_back( ((BPy_ViewVertex *) tmp)->vv ); + else { + PyErr_SetString(PyExc_TypeError, "argument must be list of ViewVertex objects"); + return NULL; + } + } + + self->vs->setVertices( v ); + + Py_RETURN_NONE; +} + +static char ViewShape_setEdges___doc__[] = +".. method:: setEdges(iEdges)\n" +"\n" +" Sets the list of ViewEdge objects contained in this ViewShape.\n" +"\n" +" :arg iEdges: The list of ViewEdge objects.\n" +" :type iEdges: List of :class:`ViewEdge` objects.\n"; + +static PyObject * ViewShape_setEdges( BPy_ViewShape *self , PyObject *args) { + PyObject *list = 0; + PyObject *tmp; + + if(!( PyArg_ParseTuple(args, "O!", &PyList_Type, &list) )) + return NULL; + + vector<ViewEdge *> v; + + for( int i=0; i < PyList_Size(list); i++ ) { + tmp = PyList_GetItem(list, i); + if( BPy_ViewEdge_Check(tmp) ) + v.push_back( ((BPy_ViewEdge *) tmp)->ve ); + else { + PyErr_SetString(PyExc_TypeError, "argument must be list of ViewEdge objects"); + return NULL; + } + } + + self->vs->setEdges( v ); + + Py_RETURN_NONE; +} + +static char ViewShape_AddEdge___doc__[] = +".. method:: AddEdge(iEdge)\n" +"\n" +" Adds a ViewEdge to the list of ViewEdge objects.\n" +"\n" +" :arg iEdge: A ViewEdge object.\n" +" :type iEdge: :class:`ViewEdge`\n"; + +static PyObject * ViewShape_AddEdge( BPy_ViewShape *self , PyObject *args) { + PyObject *py_ve = 0; + + if(!( PyArg_ParseTuple(args, "O!", &ViewEdge_Type, &py_ve) )) + return NULL; + + self->vs->AddEdge( ((BPy_ViewEdge *) py_ve)->ve ); + + Py_RETURN_NONE; +} + +static char ViewShape_AddVertex___doc__[] = +".. method:: AddVertex(iVertex)\n" +"\n" +" Adds a ViewVertex to the list of the ViewVertex objects.\n" +"\n" +" :arg iVertex: A ViewVertex object.\n" +" :type iVertex: :class:`ViewVertex`\n"; + +static PyObject * ViewShape_AddVertex( BPy_ViewShape *self , PyObject *args) { + PyObject *py_vv = 0; + + if(!( PyArg_ParseTuple(args, "O!", &ViewVertex_Type, &py_vv) )) + return NULL; + + self->vs->AddVertex( ((BPy_ViewVertex *) py_vv)->vv ); + + Py_RETURN_NONE; +} + +// virtual ViewShape * duplicate () + +/*---------------------- BPy_ViewShape instance definitions ----------------------------*/ +static PyMethodDef BPy_ViewShape_methods[] = { + {"sshape", ( PyCFunction ) ViewShape_sshape, METH_NOARGS, ViewShape_sshape___doc__}, + {"vertices", ( PyCFunction ) ViewShape_vertices, METH_NOARGS, ViewShape_vertices___doc__}, + {"edges", ( PyCFunction ) ViewShape_edges, METH_NOARGS, ViewShape_edges___doc__}, + {"getId", ( PyCFunction ) ViewShape_getId, METH_NOARGS, ViewShape_getId___doc__}, + {"getName", ( PyCFunction ) ViewShape_getName, METH_NOARGS, ViewShape_getName___doc__}, + {"setSShape", ( PyCFunction ) ViewShape_setSShape, METH_VARARGS, ViewShape_setSShape___doc__}, + {"setVertices", ( PyCFunction ) ViewShape_setVertices, METH_VARARGS, ViewShape_setVertices___doc__}, + {"setEdges", ( PyCFunction ) ViewShape_setEdges, METH_VARARGS, ViewShape_setEdges___doc__}, + {"AddEdge", ( PyCFunction ) ViewShape_AddEdge, METH_VARARGS, ViewShape_AddEdge___doc__}, + {"AddVertex", ( PyCFunction ) ViewShape_AddVertex, METH_VARARGS, ViewShape_AddVertex___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_ViewShape type definition ------------------------------*/ + +PyTypeObject ViewShape_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ViewShape", /* tp_name */ + sizeof(BPy_ViewShape), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)ViewShape___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)ViewShape___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ViewShape___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_ViewShape_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ViewShape___init__, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/BPy_ViewShape.h b/source/blender/freestyle/intern/python/BPy_ViewShape.h new file mode 100644 index 00000000000..1850ec8f13a --- /dev/null +++ b/source/blender/freestyle/intern/python/BPy_ViewShape.h @@ -0,0 +1,35 @@ +#ifndef FREESTYLE_PYTHON_VIEWSHAPE_H +#define FREESTYLE_PYTHON_VIEWSHAPE_H + +#include <Python.h> + +#include "../view_map/ViewMap.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +extern PyTypeObject ViewShape_Type; + +#define BPy_ViewShape_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ViewShape_Type) ) + +/*---------------------------Python BPy_ViewShape structure definition----------*/ +typedef struct { + PyObject_HEAD + ViewShape *vs; + int borrowed; /* non-zero if *vs a borrowed object */ +} BPy_ViewShape; + +/*---------------------------Python BPy_ViewShape visible prototypes-----------*/ + +int ViewShape_Init( PyObject *module ); + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_VIEWSHAPE_H */ diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.cpp new file mode 100644 index 00000000000..ad2885fb95a --- /dev/null +++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.cpp @@ -0,0 +1,79 @@ +#include "BPy_FalseBP1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char FalseBP1D___doc__[] = +"Class hierarchy: :class:`BinaryPredicate1D` > :class:`FalseBP1D`\n" +"\n" +".. method:: __call__(inter1, inter2)\n" +"\n" +" Always returns false.\n" +"\n" +" :arg inter1: The first Interface1D object.\n" +" :type inter1: :class:`Interface1D`\n" +" :arg inter2: The second Interface1D object.\n" +" :type inter2: :class:`Interface1D`\n" +" :return: False.\n" +" :rtype: bool\n"; + +static int FalseBP1D___init__( BPy_FalseBP1D* self, PyObject *args ) +{ + if(!( PyArg_ParseTuple(args, "") )) + return -1; + self->py_bp1D.bp1D = new Predicates1D::FalseBP1D(); + return 0; +} + +/*-----------------------BPy_FalseBP1D type definition ------------------------------*/ +PyTypeObject FalseBP1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "FalseBP1D", /* tp_name */ + sizeof(BPy_FalseBP1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + FalseBP1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &BinaryPredicate1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)FalseBP1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.h b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.h new file mode 100644 index 00000000000..a8d4aad88aa --- /dev/null +++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.h @@ -0,0 +1,29 @@ +#ifndef FREESTYLE_PYTHON_FALSEBP1D_H +#define FREESTYLE_PYTHON_FALSEBP1D_H + +#include "../BPy_BinaryPredicate1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject FalseBP1D_Type; + +#define BPy_FalseBP1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &FalseBP1D_Type) ) + +/*---------------------------Python BPy_FalseBP1D structure definition----------*/ +typedef struct { + BPy_BinaryPredicate1D py_bp1D; +} BPy_FalseBP1D; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_FALSEBP1D_H */ diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.cpp new file mode 100644 index 00000000000..1a59091c453 --- /dev/null +++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.cpp @@ -0,0 +1,81 @@ +#include "BPy_Length2DBP1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char Length2DBP1D___doc__[] = +"Class hierarchy: :class:`BinaryPredicate1D` > :class:`Length2DBP1D`\n" +"\n" +".. method:: __call__(inter1, inter2)\n" +"\n" +" Returns true if the 2D length of inter1 is less than the 2D length\n" +" of inter2.\n" +"\n" +" :arg inter1: The first Interface1D object.\n" +" :type inter1: :class:`Interface1D`\n" +" :arg inter2: The second Interface1D object.\n" +" :type inter2: :class:`Interface1D`\n" +" :return: True or false.\n" +" :rtype: bool\n"; + +static int Length2DBP1D___init__( BPy_Length2DBP1D* self, PyObject *args ) +{ + if(!( PyArg_ParseTuple(args, "") )) + return -1; + self->py_bp1D.bp1D = new Predicates1D::Length2DBP1D(); + return 0; +} + +/*-----------------------BPy_Length2DBP1D type definition ------------------------------*/ + +PyTypeObject Length2DBP1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "Length2DBP1D", /* tp_name */ + sizeof(BPy_Length2DBP1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + Length2DBP1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &BinaryPredicate1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Length2DBP1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.h b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.h new file mode 100644 index 00000000000..d5bce5b150d --- /dev/null +++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.h @@ -0,0 +1,29 @@ +#ifndef FREESTYLE_PYTHON_LENGTH2DBP1D_H +#define FREESTYLE_PYTHON_LENGTH2DBP1D_H + +#include "../BPy_BinaryPredicate1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject Length2DBP1D_Type; + +#define BPy_Length2DBP1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &Length2DBP1D_Type) ) + +/*---------------------------Python BPy_Length2DBP1D structure definition----------*/ +typedef struct { + BPy_BinaryPredicate1D py_bp1D; +} BPy_Length2DBP1D; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_LENGTH2DBP1D_H */ diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.cpp new file mode 100644 index 00000000000..2b479a49fc0 --- /dev/null +++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.cpp @@ -0,0 +1,80 @@ +#include "BPy_SameShapeIdBP1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char SameShapeIdBP1D___doc__[] = +"Class hierarchy: :class:`BinaryPredicate1D` > :class:`SameShapeIdBP1D`\n" +"\n" +".. method:: __call__(inter1, inter2)\n" +"\n" +" Returns true if inter1 and inter2 belong to the same shape.\n" +"\n" +" :arg inter1: The first Interface1D object.\n" +" :type inter1: :class:`Interface1D`\n" +" :arg inter2: The second Interface1D object.\n" +" :type inter2: :class:`Interface1D`\n" +" :return: True or false.\n" +" :rtype: bool\n"; + +static int SameShapeIdBP1D___init__( BPy_SameShapeIdBP1D* self, PyObject *args ) +{ + if(!( PyArg_ParseTuple(args, "") )) + return -1; + self->py_bp1D.bp1D = new Predicates1D::SameShapeIdBP1D(); + return 0; +} + +/*-----------------------BPy_SameShapeIdBP1D type definition ------------------------------*/ + +PyTypeObject SameShapeIdBP1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "SameShapeIdBP1D", /* tp_name */ + sizeof(BPy_SameShapeIdBP1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + SameShapeIdBP1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &BinaryPredicate1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)SameShapeIdBP1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.h b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.h new file mode 100644 index 00000000000..71065d4ceeb --- /dev/null +++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.h @@ -0,0 +1,29 @@ +#ifndef FREESTYLE_PYTHON_SAMESHAPEIDBP1D_H +#define FREESTYLE_PYTHON_SAMESHAPEIDBP1D_H + +#include "../BPy_BinaryPredicate1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject SameShapeIdBP1D_Type; + +#define BPy_SameShapeIdBP1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &SameShapeIdBP1D_Type) ) + +/*---------------------------Python BPy_SameShapeIdBP1D structure definition----------*/ +typedef struct { + BPy_BinaryPredicate1D py_bp1D; +} BPy_SameShapeIdBP1D; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_SAMESHAPEIDBP1D_H */ diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.cpp new file mode 100644 index 00000000000..090a8232794 --- /dev/null +++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.cpp @@ -0,0 +1,80 @@ +#include "BPy_TrueBP1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char TrueBP1D___doc__[] = +"Class hierarchy: :class:`BinaryPredicate1D` > :class:`TrueBP1D`\n" +"\n" +".. method:: __call__(inter1, inter2)\n" +"\n" +" Always returns true.\n" +"\n" +" :arg inter1: The first Interface1D object.\n" +" :type inter1: :class:`Interface1D`\n" +" :arg inter2: The second Interface1D object.\n" +" :type inter2: :class:`Interface1D`\n" +" :return: True.\n" +" :rtype: bool\n"; + +static int TrueBP1D___init__( BPy_TrueBP1D* self, PyObject *args ) +{ + if(!( PyArg_ParseTuple(args, "") )) + return -1; + self->py_bp1D.bp1D = new Predicates1D::TrueBP1D(); + return 0; +} + +/*-----------------------BPy_TrueBP1D type definition ------------------------------*/ + +PyTypeObject TrueBP1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "TrueBP1D", /* tp_name */ + sizeof(BPy_TrueBP1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + TrueBP1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &BinaryPredicate1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)TrueBP1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.h b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.h new file mode 100644 index 00000000000..7d809e1fe65 --- /dev/null +++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.h @@ -0,0 +1,29 @@ +#ifndef FREESTYLE_PYTHON_TRUEBP1D_H +#define FREESTYLE_PYTHON_TRUEBP1D_H + +#include "../BPy_BinaryPredicate1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject TrueBP1D_Type; + +#define BPy_TrueBP1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &TrueBP1D_Type) ) + +/*---------------------------Python BPy_TrueBP1D structure definition----------*/ +typedef struct { + BPy_BinaryPredicate1D py_bp1D; +} BPy_TrueBP1D; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_TRUEBP1D_H */ diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp new file mode 100644 index 00000000000..f5ba9d58d72 --- /dev/null +++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp @@ -0,0 +1,92 @@ +#include "BPy_ViewMapGradientNormBP1D.h" + +#include "../BPy_Convert.h" +#include "../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +//ViewMapGradientNormBP1D(int level, IntegrationType iType=MEAN, float sampling=2.0) + +static char ViewMapGradientNormBP1D___doc__[] = +"Class hierarchy: :class:`BinaryPredicate1D` > :class:`ViewMapGradientNormBP1D`\n" +"\n" +".. method:: __call__(inter1, inter2)\n" +"\n" +" Returns true if the evaluation of the Gradient norm Function is\n" +" higher for inter1 than for inter2.\n" +"\n" +" :arg inter1: The first Interface1D object.\n" +" :type inter1: :class:`Interface1D`\n" +" :arg inter2: The second Interface1D object.\n" +" :type inter2: :class:`Interface1D`\n" +" :return: True or false.\n" +" :rtype: bool\n"; + +static int ViewMapGradientNormBP1D___init__( BPy_ViewMapGradientNormBP1D* self, PyObject *args ) +{ + int i; + PyObject *obj; + float f = 2.0; + + if(!( PyArg_ParseTuple(args, "i|O!f", &i, &IntegrationType_Type, &obj, &f) )) + return -1; + + IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + self->py_bp1D.bp1D = new Predicates1D::ViewMapGradientNormBP1D(i,t,f); + return 0; +} + +/*-----------------------BPy_ViewMapGradientNormBP1D type definition ------------------------------*/ + +PyTypeObject ViewMapGradientNormBP1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ViewMapGradientNormBP1D", /* tp_name */ + sizeof(BPy_ViewMapGradientNormBP1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ViewMapGradientNormBP1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &BinaryPredicate1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ViewMapGradientNormBP1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.h b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.h new file mode 100644 index 00000000000..23d27e118a9 --- /dev/null +++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.h @@ -0,0 +1,29 @@ +#ifndef FREESTYLE_PYTHON_VIEWMAPGRADIENTNORMBP1D_H +#define FREESTYLE_PYTHON_VIEWMAPGRADIENTNORMBP1D_H + +#include "../BPy_BinaryPredicate1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ViewMapGradientNormBP1D_Type; + +#define BPy_ViewMapGradientNormBP1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ViewMapGradientNormBP1D_Type) ) + +/*---------------------------Python BPy_ViewMapGradientNormBP1D structure definition----------*/ +typedef struct { + BPy_BinaryPredicate1D py_bp1D; +} BPy_ViewMapGradientNormBP1D; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_VIEWMAPGRADIENTNORMBP1D_H */ diff --git a/source/blender/freestyle/intern/python/Director.cpp b/source/blender/freestyle/intern/python/Director.cpp new file mode 100644 index 00000000000..1948da2b6b0 --- /dev/null +++ b/source/blender/freestyle/intern/python/Director.cpp @@ -0,0 +1,304 @@ +#include "Director.h" + +#include "BPy_Convert.h" + +#include "BPy_BinaryPredicate0D.h" +#include "BPy_BinaryPredicate1D.h" +#include "BPy_FrsMaterial.h" +#include "BPy_Id.h" +#include "BPy_UnaryFunction0D.h" +#include "BPy_UnaryFunction1D.h" +#include "BPy_UnaryPredicate0D.h" +#include "BPy_UnaryPredicate1D.h" +#include "BPy_StrokeShader.h" +#include "Iterator/BPy_ChainingIterator.h" +#include "Iterator/BPy_Interface0DIterator.h" +#include "Interface1D/BPy_Stroke.h" +#include "Interface1D/BPy_ViewEdge.h" +#include "BPy_ViewShape.h" + +#include "UnaryFunction0D/BPy_UnaryFunction0DDouble.h" +#include "UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.h" +#include "UnaryFunction0D/BPy_UnaryFunction0DFloat.h" +#include "UnaryFunction0D/BPy_UnaryFunction0DId.h" +#include "UnaryFunction0D/BPy_UnaryFunction0DMaterial.h" +#include "UnaryFunction0D/BPy_UnaryFunction0DUnsigned.h" +#include "UnaryFunction0D/BPy_UnaryFunction0DVec2f.h" +#include "UnaryFunction0D/BPy_UnaryFunction0DVec3f.h" +#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__ +int Director_BPy_BinaryPredicate0D___call__( BinaryPredicate0D *bp0D, Interface0D& i1, Interface0D& i2 ) { + if (!bp0D->py_bp0D) { // internal error + PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_bp0D) not initialized"); + return -1; + } + PyObject *arg1 = Any_BPy_Interface0D_from_Interface0D(i1); + PyObject *arg2 = Any_BPy_Interface0D_from_Interface0D(i2); + if (!arg1 || !arg2) { + Py_XDECREF(arg1); + Py_XDECREF(arg2); + return -1; + } + PyObject *result = PyObject_CallMethod( bp0D->py_bp0D, "__call__", "OO", arg1, arg2 ); + Py_DECREF(arg1); + Py_DECREF(arg2); + if (!result) + return -1; + int ret = PyObject_IsTrue(result); + Py_DECREF(result); + if (ret < 0) + return -1; + bp0D->result = ret; + return 0; +} + + +// BinaryPredicate1D: __call__ +int Director_BPy_BinaryPredicate1D___call__( BinaryPredicate1D *bp1D, Interface1D& i1, Interface1D& i2 ) { + if (!bp1D->py_bp1D) { // internal error + PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_bp1D) not initialized"); + return -1; + } + PyObject *arg1 = Any_BPy_Interface1D_from_Interface1D(i1); + PyObject *arg2 = Any_BPy_Interface1D_from_Interface1D(i2); + if (!arg1 || !arg2) { + Py_XDECREF(arg1); + Py_XDECREF(arg2); + return -1; + } + PyObject *result = PyObject_CallMethod( bp1D->py_bp1D, "__call__", "OO", arg1, arg2 ); + Py_DECREF(arg1); + Py_DECREF(arg2); + if (!result) + return -1; + int ret = PyObject_IsTrue(result); + Py_DECREF(result); + if (ret < 0) + return -1; + bp1D->result = ret; + return 0; +} + + +// UnaryPredicate0D: __call__ +int Director_BPy_UnaryPredicate0D___call__( UnaryPredicate0D *up0D, Interface0DIterator& if0D_it ) { + if (!up0D->py_up0D) { // internal error + PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_up0D) not initialized"); + return -1; + } + PyObject *arg = BPy_Interface0DIterator_from_Interface0DIterator(if0D_it, 0); + if (!arg) + return -1; + PyObject *result = PyObject_CallMethod( up0D->py_up0D, "__call__", "O", arg ); + Py_DECREF(arg); + if (!result) + return -1; + int ret = PyObject_IsTrue(result); + Py_DECREF(result); + if (ret < 0) + return -1; + up0D->result = ret; + return 0; +} + + +// UnaryPredicate1D: __call__ +int Director_BPy_UnaryPredicate1D___call__( UnaryPredicate1D *up1D, Interface1D& if1D ) { + if (!up1D->py_up1D) { // internal error + PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_up1D) not initialized"); + return -1; + } + PyObject *arg = Any_BPy_Interface1D_from_Interface1D(if1D); + if (!arg) + return -1; + PyObject *result = PyObject_CallMethod( up1D->py_up1D, "__call__", "O", arg ); + Py_DECREF(arg); + if (!result) + return -1; + int ret = PyObject_IsTrue(result); + Py_DECREF(result); + if (ret < 0) + return -1; + up1D->result = ret; + return 0; +} + + +// StrokeShader: shade +int Director_BPy_StrokeShader_shade( StrokeShader *ss, Stroke& s ) { + if (!ss->py_ss) { // internal error + PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_ss) not initialized"); + return -1; + } + PyObject *arg = BPy_Stroke_from_Stroke(s); + if (!arg) + return -1; + PyObject *result = PyObject_CallMethod( ss->py_ss, "shade", "O", arg ); + Py_DECREF(arg); + if (!result) + return -1; + Py_DECREF(result); + return 0; +} + +// ChainingIterator: init, traverse +int Director_BPy_ChainingIterator_init( ChainingIterator *c_it ) { + if (!c_it->py_c_it) { // internal error + PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_c_it) not initialized"); + return -1; + } + PyObject *result = PyObject_CallMethod( c_it->py_c_it, "init", ""); + if (!result) + return -1; + Py_DECREF(result); + return 0; +} + +int Director_BPy_ChainingIterator_traverse( ChainingIterator *c_it, AdjacencyIterator& a_it ) { + if (!c_it->py_c_it) { // internal error + PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_c_it) not initialized"); + return -1; + } + PyObject *arg = BPy_AdjacencyIterator_from_AdjacencyIterator(a_it); + if (!arg) + return -1; + PyObject *result = PyObject_CallMethod( c_it->py_c_it, "traverse", "O", arg ); + Py_DECREF(arg); + if (!result) + return -1; + if (BPy_ViewEdge_Check(result)) { + c_it->result = ((BPy_ViewEdge *) result)->ve; + } else if (result == Py_None) { + c_it->result = NULL; + } else { + PyErr_SetString(PyExc_RuntimeError, "traverse method returned a wrong value"); + Py_DECREF(result); + return -1; + } + Py_DECREF(result); + return 0; +} + + +// BPy_UnaryFunction{0D,1D}: __call__ +int Director_BPy_UnaryFunction0D___call__( void *uf0D, PyObject *obj, Interface0DIterator& if0D_it) { + + if (!obj) { // internal error + PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_uf0D) not initialized"); + return -1; + } + PyObject *arg = BPy_Interface0DIterator_from_Interface0DIterator(if0D_it, 0); + if (!arg) + return -1; + PyObject *result = PyObject_CallMethod( obj, "__call__", "O", arg ); + Py_DECREF(arg); + if (!result) + return -1; + + if( BPy_UnaryFunction0DDouble_Check(obj) ) { + ((UnaryFunction0D<double> *) uf0D)->result = PyFloat_AsDouble(result); + + } else if ( BPy_UnaryFunction0DEdgeNature_Check(obj) ) { + ((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) ) { + ((UnaryFunction0D<Id> *) uf0D)->result = *( ((BPy_Id *) result)->id ); + + } else if ( BPy_UnaryFunction0DMaterial_Check(obj) ) { + ((UnaryFunction0D<FrsMaterial> *) uf0D)->result = *( ((BPy_FrsMaterial *) result)->m ); + + } else if ( BPy_UnaryFunction0DUnsigned_Check(obj) ) { + ((UnaryFunction0D<unsigned> *) uf0D)->result = PyLong_AsLong(result); + + } else if ( BPy_UnaryFunction0DVec2f_Check(obj) ) { + Vec2f *v = Vec2f_ptr_from_Vector( result ); + ((UnaryFunction0D<Vec2f> *) uf0D)->result = *v; + delete v; + + } else if ( BPy_UnaryFunction0DVec3f_Check(obj) ) { + Vec3f *v = Vec3f_ptr_from_Vector( result ); + ((UnaryFunction0D<Vec3f> *) uf0D)->result = *v; + delete v; + + } else if ( BPy_UnaryFunction0DVectorViewShape_Check(obj) ) { + vector<ViewShape*> vec; + for( int i = 0; i < PyList_Size(result); i++) { + ViewShape *b = ( (BPy_ViewShape *) PyList_GetItem(result, i) )->vs; + vec.push_back( b ); + } + + ((UnaryFunction0D< vector<ViewShape*> > *) uf0D)->result = vec; + + } else if ( BPy_UnaryFunction0DViewShape_Check(obj) ) { + ((UnaryFunction0D<ViewShape*> *) uf0D)->result = ((BPy_ViewShape *) result)->vs; + + } + + Py_DECREF(result); + return 0; +} + +int Director_BPy_UnaryFunction1D___call__( void *uf1D, PyObject *obj, Interface1D& if1D) { + + if (!obj) { // internal error + PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_uf1D) not initialized"); + return -1; + } + PyObject *arg = Any_BPy_Interface1D_from_Interface1D(if1D); + if (!arg) + return -1; + PyObject *result = PyObject_CallMethod( obj, "__call__", "O", arg ); + Py_DECREF(arg); + if (!result) + return -1; + + 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 = PyLong_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; + + } + + Py_DECREF(result); + return 0; +} diff --git a/source/blender/freestyle/intern/python/Director.h b/source/blender/freestyle/intern/python/Director.h new file mode 100644 index 00000000000..667d4a65942 --- /dev/null +++ b/source/blender/freestyle/intern/python/Director.h @@ -0,0 +1,49 @@ +#ifndef FREESTYLE_PYTHON_DIRECTOR +# define FREESTYLE_PYTHON_DIRECTOR + +class UnaryPredicate0D; +class UnaryPredicate1D; +class BinaryPredicate0D; +class BinaryPredicate1D; +class ChainingIterator; +class AdjacencyIterator; +class Interface0D; +class Interface1D; +class Interface0DIterator; +class Stroke; +class StrokeShader; + +#ifdef __cplusplus +extern "C" { +#endif + +#include <Python.h> + +#ifdef __cplusplus +} +#endif + +// BinaryPredicate0D: __call__ +int Director_BPy_BinaryPredicate0D___call__( BinaryPredicate0D *bp0D, Interface0D& i1, Interface0D& i2 ); + +// BinaryPredicate1D: __call__ +int Director_BPy_BinaryPredicate1D___call__( BinaryPredicate1D *bp1D, Interface1D& i1, Interface1D& i2 ); + +// UnaryFunction{0D,1D}: __call__ +int Director_BPy_UnaryFunction0D___call__( void *uf0D, PyObject *obj, Interface0DIterator& if0D_it); +int Director_BPy_UnaryFunction1D___call__( void *uf1D, PyObject *obj, Interface1D& if1D); + +// UnaryPredicate0D: __call__ +int Director_BPy_UnaryPredicate0D___call__( UnaryPredicate0D *up0D, Interface0DIterator& if0D_it ); + +// UnaryPredicate1D: __call__ +int Director_BPy_UnaryPredicate1D___call__( UnaryPredicate1D *up1D, Interface1D& if1D ); + +// StrokeShader: shade +int Director_BPy_StrokeShader_shade( StrokeShader *ss, Stroke& s ); + +// ChainingIterator: init, traverse +int Director_BPy_ChainingIterator_init( ChainingIterator *c_it ); +int Director_BPy_ChainingIterator_traverse( ChainingIterator *c_it, AdjacencyIterator& a_it ); + +#endif // FREESTYLE_PYTHON_DIRECTOR diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp new file mode 100644 index 00000000000..e213edd5c79 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp @@ -0,0 +1,278 @@ +#include "BPy_CurvePoint.h" + +#include "../BPy_Convert.h" +#include "../Interface0D/BPy_SVertex.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char CurvePoint___doc__[] = +"Class hierarchy: :class:`Interface0D` > :class:`CurvePoint`\n" +"\n" +"Class to represent a point of a curve. A CurvePoint can be any point\n" +"of a 1D curve (it doesn't have to be a vertex of the curve). Any\n" +":class:`Interface1D` is built upon ViewEdges, themselves built upon\n" +"FEdges. Therefore, a curve is basically a polyline made of a list of\n" +":class:`SVertex` objects. Thus, a CurvePoint is built by linearly\n" +"interpolating two :class:`SVertex` instances. CurvePoint can be used\n" +"as virtual points while querying 0D information along a curve at a\n" +"given resolution.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Defult constructor.\n" +"\n" +".. method:: __init__(iBrother)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg iBrother: A CurvePoint object.\n" +" :type iBrother: :class:`CurvePoint`\n" +"\n" +".. method:: __init__(iA, iB, t2d)\n" +"\n" +" Builds a CurvePoint from two SVertex and an interpolation parameter.\n" +"\n" +" :arg iA: The first SVertex.\n" +" :type iA: :class:`SVertex`\n" +" :arg iB: The second SVertex.\n" +" :type iB: :class:`SVertex`\n" +" :arg t2d: A 2D interpolation parameter used to linearly interpolate\n" +" iA and iB.\n" +" :type t2d: float\n" +"\n" +".. method:: __init__(iA, iB, t2d)\n" +"\n" +" Builds a CurvePoint from two CurvePoint and an interpolation\n" +" parameter.\n" +"\n" +" :arg iA: The first CurvePoint.\n" +" :type iA: :class:`CurvePoint`\n" +" :arg iB: The second CurvePoint.\n" +" :type iB: :class:`CurvePoint`\n" +" :arg t2d: The 2D interpolation parameter used to linearly\n" +" interpolate iA and iB.\n" +" :type t2d: float\n"; + +static int CurvePoint___init__(BPy_CurvePoint *self, PyObject *args, PyObject *kwds) +{ + + PyObject *obj1 = 0, *obj2 = 0 , *obj3 = 0; + + if (! PyArg_ParseTuple(args, "|OOO!", &obj1, &obj2, &PyFloat_Type, &obj3) ) + return -1; + + if( !obj1 ){ + self->cp = new CurvePoint(); + + } else if( !obj2 && BPy_CurvePoint_Check(obj1) ) { + self->cp = new CurvePoint( *(((BPy_CurvePoint *) obj1)->cp) ); + + } else if( obj3 && BPy_SVertex_Check(obj1) && BPy_SVertex_Check(obj2) ) { + self->cp = new CurvePoint( ((BPy_SVertex *) obj1)->sv, + ((BPy_SVertex *) obj2)->sv, + PyFloat_AsDouble( obj3 ) ); + + } else if( obj3 && BPy_CurvePoint_Check(obj1) && BPy_CurvePoint_Check(obj2) ) { + CurvePoint *cp1 = ((BPy_CurvePoint *) obj1)->cp; + CurvePoint *cp2 = ((BPy_CurvePoint *) obj2)->cp; + if( !cp1 || cp1->A() == 0 || cp1->B() == 0 ) { + PyErr_SetString(PyExc_TypeError, "argument 1 is an invalid CurvePoint object"); + return -1; + } + if( !cp2 || cp2->A() == 0 || cp2->B() == 0 ) { + PyErr_SetString(PyExc_TypeError, "argument 2 is an invalid CurvePoint object"); + return -1; + } + self->cp = new CurvePoint( cp1, cp2, PyFloat_AsDouble( obj3 ) ); + + } else { + PyErr_SetString(PyExc_TypeError, "invalid argument(s)"); + return -1; + } + + self->py_if0D.if0D = self->cp; + self->py_if0D.borrowed = 0; + + return 0; +} + +static char CurvePoint_A___doc__[] = +".. method:: A()\n" +"\n" +" Returns the first SVertex upon which the CurvePoint is built.\n" +"\n" +" :return: The first SVertex.\n" +" :rtype: :class:`SVertex`\n"; + +static PyObject * CurvePoint_A( BPy_CurvePoint *self ) { + SVertex *A = self->cp->A(); + if( A ) + return BPy_SVertex_from_SVertex( *A ); + + Py_RETURN_NONE; +} + +static char CurvePoint_B___doc__[] = +".. method:: B()\n" +"\n" +" Returns the second SVertex upon which the CurvePoint is built.\n" +"\n" +" :return: The second SVertex.\n" +" :rtype: :class:`SVertex`\n"; + +static PyObject * CurvePoint_B( BPy_CurvePoint *self ) { + SVertex *B = self->cp->B(); + if( B ) + return BPy_SVertex_from_SVertex( *B ); + + Py_RETURN_NONE; +} + +static char CurvePoint_t2d___doc__[] = +".. method:: t2d()\n" +"\n" +" Returns the 2D interpolation parameter.\n" +"\n" +" :return: The 2D interpolation parameter.\n" +" :rtype: float\n"; + +static PyObject * CurvePoint_t2d( BPy_CurvePoint *self ) { + return PyFloat_FromDouble( self->cp->t2d() ); +} + +static char CurvePoint_setA___doc__[] = +".. method:: setA(iA)\n" +"\n" +" Sets the first SVertex upon which to build the CurvePoint.\n" +"\n" +" :arg iA: The first SVertex.\n" +" :type iA: :class:`SVertex`\n"; + +static PyObject *CurvePoint_setA( BPy_CurvePoint *self , PyObject *args) { + PyObject *py_sv; + + if(!( PyArg_ParseTuple(args, "O!", &SVertex_Type, &py_sv) )) + return NULL; + + self->cp->setA( ((BPy_SVertex *) py_sv)->sv ); + + Py_RETURN_NONE; +} + +static char CurvePoint_setB___doc__[] = +".. method:: setB(iB)\n" +"\n" +" Sets the first SVertex upon which to build the CurvePoint.\n" +"\n" +" :arg iB: The second SVertex.\n" +" :type iB: :class:`SVertex`\n"; + +static PyObject *CurvePoint_setB( BPy_CurvePoint *self , PyObject *args) { + PyObject *py_sv; + + if(!( PyArg_ParseTuple(args, "O!", &SVertex_Type, &py_sv) )) + return NULL; + + self->cp->setB( ((BPy_SVertex *) py_sv)->sv ); + + Py_RETURN_NONE; +} + +static char CurvePoint_setT2d___doc__[] = +".. method:: setT2d(t)\n" +"\n" +" Sets the 2D interpolation parameter to use.\n" +"\n" +" :arg t: The 2D interpolation parameter.\n" +" :type t: float\n"; + +static PyObject *CurvePoint_setT2d( BPy_CurvePoint *self , PyObject *args) { + float t; + + if(!( PyArg_ParseTuple(args, "f", &t) )) + return NULL; + + self->cp->setT2d( t ); + + Py_RETURN_NONE; +} + +static char CurvePoint_curvatureFredo___doc__[] = +".. method:: curvatureFredo()\n" +"\n" +" Returns the angle in radians.\n" +"\n" +" :return: The angle in radians.\n" +" :rtype: float\n"; + +static PyObject *CurvePoint_curvatureFredo( BPy_CurvePoint *self , PyObject *args) { + return PyFloat_FromDouble( self->cp->curvatureFredo() ); +} + +///bool operator== (const CurvePoint &b) + +/*----------------------CurvePoint instance definitions ----------------------------*/ +static PyMethodDef BPy_CurvePoint_methods[] = { + {"A", ( PyCFunction ) CurvePoint_A, METH_NOARGS, CurvePoint_A___doc__}, + {"B", ( PyCFunction ) CurvePoint_B, METH_NOARGS, CurvePoint_B___doc__}, + {"t2d", ( PyCFunction ) CurvePoint_t2d, METH_NOARGS, CurvePoint_t2d___doc__}, + {"setA", ( PyCFunction ) CurvePoint_setA, METH_VARARGS, CurvePoint_setA___doc__}, + {"setB", ( PyCFunction ) CurvePoint_setB, METH_VARARGS, CurvePoint_setB___doc__}, + {"setT2d", ( PyCFunction ) CurvePoint_setT2d, METH_VARARGS, CurvePoint_setT2d___doc__}, + {"curvatureFredo", ( PyCFunction ) CurvePoint_curvatureFredo, METH_NOARGS, CurvePoint_curvatureFredo___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_CurvePoint type definition ------------------------------*/ +PyTypeObject CurvePoint_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "CurvePoint", /* tp_name */ + sizeof(BPy_CurvePoint), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + CurvePoint___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_CurvePoint_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &Interface0D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)CurvePoint___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.h b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.h new file mode 100644 index 00000000000..b4c22645503 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_CURVEPOINT_H +#define FREESTYLE_PYTHON_CURVEPOINT_H + +#include "../BPy_Interface0D.h" +#include "../../stroke/Curve.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject CurvePoint_Type; + +#define BPy_CurvePoint_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &CurvePoint_Type) ) + +/*---------------------------Python BPy_CurvePoint structure definition----------*/ +typedef struct { + BPy_Interface0D py_if0D; + CurvePoint *cp; +} BPy_CurvePoint; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_CURVEPOINT_H */ diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp new file mode 100644 index 00000000000..8f036233b63 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp @@ -0,0 +1,303 @@ +#include "BPy_SVertex.h" + +#include "../BPy_Convert.h" +#include "../BPy_Id.h" +#include "../Interface1D/BPy_FEdge.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +static char SVertex___doc__[] = +"Class hierarchy: :class:`Interface0D` > :class:`SVertex`\n" +"\n" +"Class to define a vertex of the embedding.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(iBrother)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg iBrother: A SVertex object.\n" +" :type iBrother: :class:`SVertex`\n" +"\n" +".. method:: __init__(iPoint3D, id)\n" +"\n" +" Builds a SVertex from 3D coordinates and an Id.\n" +"\n" +" :arg iPoint3D: A three-dimensional vector.\n" +" :type iPoint3D: :class:`mathutils.Vector`\n" +" :arg id: An Id object.\n" +" :type id: :class:`Id`\n"; + +//------------------------INSTANCE METHODS ---------------------------------- + +static int SVertex___init__(BPy_SVertex *self, PyObject *args, PyObject *kwds) +{ + PyObject *py_point = 0; + BPy_Id *py_id = 0; + + + if (! PyArg_ParseTuple(args, "|OO!", &py_point, &Id_Type, &py_id) ) + return -1; + + if( !py_point ) { + self->sv = new SVertex(); + + } else if( !py_id && BPy_SVertex_Check(py_point) ) { + self->sv = new SVertex( *(((BPy_SVertex *)py_point)->sv) ); + + } else if( py_point && py_id ) { + Vec3r *v = Vec3r_ptr_from_PyObject(py_point); + if( !v ) { + PyErr_SetString(PyExc_TypeError, "argument 1 must be a 3D vector (either a list of 3 elements or Vector)"); + return -1; + } + self->sv = new SVertex( *v, *(py_id->id) ); + delete v; + + } else { + PyErr_SetString(PyExc_TypeError, "invalid argument(s)"); + return -1; + } + + self->py_if0D.if0D = self->sv; + self->py_if0D.borrowed = 0; + + return 0; +} + +static char SVertex_normals___doc__[] = +".. method:: normals()\n" +"\n" +" Returns the normals for this Vertex as a list. In a smooth surface,\n" +" a vertex has exactly one normal. In a sharp surface, a vertex can\n" +" have any number of normals.\n" +"\n" +" :return: A list of normals.\n" +" :rtype: List of :class:`mathutils.Vector` objects\n"; + +static PyObject * SVertex_normals( BPy_SVertex *self ) { + PyObject *py_normals; + set< Vec3r > normals; + + py_normals = PyList_New(0); + normals = self->sv->normals(); + + for( set< Vec3r >::iterator set_iterator = normals.begin(); set_iterator != normals.end(); set_iterator++ ) { + Vec3r v( *set_iterator ); + PyList_Append( py_normals, Vector_from_Vec3r(v) ); + } + + return py_normals; +} + +static char SVertex_normalsSize___doc__[] = +".. method:: normalsSize()\n" +"\n" +" Returns the number of different normals for this vertex.\n" +"\n" +" :return: The number of normals.\n" +" :rtype: int\n"; + +static PyObject * SVertex_normalsSize( BPy_SVertex *self ) { + return PyLong_FromLong( self->sv->normalsSize() ); +} + +static char SVertex_viewvertex___doc__[] = +".. method:: viewvertex()\n" +"\n" +" If this SVertex is also a ViewVertex, this method returns the\n" +" ViewVertex. None is returned otherwise.\n" +"\n" +" :return: The ViewVertex object.\n" +" :rtype: :class:`ViewVertex`\n"; + +static PyObject * SVertex_viewvertex( BPy_SVertex *self ) { + ViewVertex *vv = self->sv->viewvertex(); + if( vv ) + return Any_BPy_ViewVertex_from_ViewVertex( *vv ); + + Py_RETURN_NONE; +} + +static char SVertex_setPoint3D___doc__[] = +".. method:: setPoint3D(p)\n" +"\n" +" Sets the 3D coordinates of the SVertex.\n" +"\n" +" :arg p: A three-dimensional vector.\n" +" :type p: :class:`mathutils.Vector`, list or tuple of 3 real numbers\n"; + +static PyObject *SVertex_setPoint3D( BPy_SVertex *self , PyObject *args) { + PyObject *py_point; + + if(!( PyArg_ParseTuple(args, "O", &py_point) )) + return NULL; + Vec3r *v = Vec3r_ptr_from_PyObject(py_point); + if( !v ) { + PyErr_SetString(PyExc_TypeError, "argument 1 must be a 3D vector (either a list of 3 elements or Vector)"); + return NULL; + } + self->sv->setPoint3D( *v ); + delete v; + + Py_RETURN_NONE; +} + +static char SVertex_setPoint2D___doc__[] = +".. method:: setPoint2D(p)\n" +"\n" +" Sets the 2D projected coordinates of the SVertex.\n" +"\n" +" :arg p: A three-dimensional vector.\n" +" :type p: :class:`mathutils.Vector`, list or tuple of 3 real numbers\n"; + +static PyObject *SVertex_setPoint2D( BPy_SVertex *self , PyObject *args) { + PyObject *py_point; + + if(!( PyArg_ParseTuple(args, "O", &py_point) )) + return NULL; + Vec3r *v = Vec3r_ptr_from_PyObject(py_point); + if( !v ) { + PyErr_SetString(PyExc_TypeError, "argument 1 must be a 3D vector (either a list of 3 elements or Vector)"); + return NULL; + } + self->sv->setPoint2D( *v ); + delete v; + + Py_RETURN_NONE; +} + +static char SVertex_AddNormal___doc__[] = +".. method:: AddNormal(n)\n" +"\n" +" Adds a normal to the SVertex's set of normals. If the same normal\n" +" is already in the set, nothing changes.\n" +"\n" +" :arg n: A three-dimensional vector.\n" +" :type n: :class:`mathutils.Vector`, list or tuple of 3 real numbers\n"; + +static PyObject *SVertex_AddNormal( BPy_SVertex *self , PyObject *args) { + PyObject *py_normal; + + if(!( PyArg_ParseTuple(args, "O", &py_normal) )) + return NULL; + Vec3r *n = Vec3r_ptr_from_PyObject(py_normal); + if( !n ) { + PyErr_SetString(PyExc_TypeError, "argument 1 must be a 3D vector (either a list of 3 elements or Vector)"); + return NULL; + } + self->sv->AddNormal( *n ); + delete n; + + Py_RETURN_NONE; +} + +static char SVertex_setId___doc__[] = +".. method:: setId(id)\n" +"\n" +" Sets the identifier of the SVertex.\n" +"\n" +" :arg id: The identifier.\n" +" :type id: :class:`Id`\n"; + +static PyObject *SVertex_setId( BPy_SVertex *self , PyObject *args) { + BPy_Id *py_id; + + if( !PyArg_ParseTuple(args, "O!", &Id_Type, &py_id) ) + return NULL; + + self->sv->setId( *(py_id->id) ); + + Py_RETURN_NONE; +} + +static char SVertex_AddFEdge___doc__[] = +".. method:: AddFEdge(fe)\n" +"\n" +" Add an FEdge to the list of edges emanating from this SVertex.\n" +"\n" +" :arg fe: An FEdge.\n" +" :type fe: :class:`FEdge`\n"; + +static PyObject *SVertex_AddFEdge( BPy_SVertex *self , PyObject *args) { + PyObject *py_fe; + + if(!( PyArg_ParseTuple(args, "O!", &FEdge_Type, &py_fe) )) + return NULL; + + self->sv->AddFEdge( ((BPy_FEdge *) py_fe)->fe ); + + Py_RETURN_NONE; +} + +// virtual bool operator== (const SVertex &iBrother) +// ViewVertex * viewvertex () + +/*----------------------SVertex instance definitions ----------------------------*/ +static PyMethodDef BPy_SVertex_methods[] = { + {"normals", ( PyCFunction ) SVertex_normals, METH_NOARGS, SVertex_normals___doc__}, + {"normalsSize", ( PyCFunction ) SVertex_normalsSize, METH_NOARGS, SVertex_normalsSize___doc__}, + {"viewvertex", ( PyCFunction ) SVertex_viewvertex, METH_NOARGS, SVertex_viewvertex___doc__}, + {"setPoint3D", ( PyCFunction ) SVertex_setPoint3D, METH_VARARGS, SVertex_setPoint3D___doc__}, + {"setPoint2D", ( PyCFunction ) SVertex_setPoint2D, METH_VARARGS, SVertex_setPoint2D___doc__}, + {"AddNormal", ( PyCFunction ) SVertex_AddNormal, METH_VARARGS, SVertex_AddNormal___doc__}, + {"setId", ( PyCFunction ) SVertex_setId, METH_VARARGS, SVertex_setId___doc__}, + {"AddFEdge", ( PyCFunction ) SVertex_AddFEdge, METH_VARARGS, SVertex_AddFEdge___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_SVertex type definition ------------------------------*/ +PyTypeObject SVertex_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "SVertex", /* tp_name */ + sizeof(BPy_SVertex), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + SVertex___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_SVertex_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &Interface0D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)SVertex___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.h b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.h new file mode 100644 index 00000000000..7d310f2b7dc --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.h @@ -0,0 +1,32 @@ +#ifndef FREESTYLE_PYTHON_SVERTEX_H +#define FREESTYLE_PYTHON_SVERTEX_H + +#include "../../view_map/Silhouette.h" +#include "../BPy_Interface0D.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject SVertex_Type; + +#define BPy_SVertex_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &SVertex_Type) ) + +/*---------------------------Python BPy_SVertex structure definition----------*/ +typedef struct { + BPy_Interface0D py_if0D; + SVertex *sv; +} BPy_SVertex; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_SVERTEX_H */ diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp new file mode 100644 index 00000000000..c1fe6875ea7 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp @@ -0,0 +1,195 @@ +#include "BPy_ViewVertex.h" + +#include "../BPy_Convert.h" +#include "../Interface1D/BPy_ViewEdge.h" +#include "../BPy_Nature.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ViewVertex___doc__[] = +"Class hierarchy: :class:`Interface0D` > :class:`ViewVertex`\n" +"\n" +"Class to define a view vertex. A view vertex is a feature vertex\n" +"corresponding to a point of the image graph, where the characteristics\n" +"of an edge (e.g., nature and visibility) might change. A\n" +":class:`ViewVertex` can be of two kinds: A :class:`TVertex` when it\n" +"corresponds to the intersection between two ViewEdges or a\n" +":class:`NonTVertex` when it corresponds to a vertex of the initial\n" +"input mesh (it is the case for vertices such as corners for example).\n" +"Thus, this class can be specialized into two classes, the\n" +":class:`TVertex` class and the :class:`NonTVertex` class.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(iBrother)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg iBrother: A ViewVertex object.\n" +" :type iBrother: :class:`ViewVertex`\n"; + +static int ViewVertex___init__( BPy_ViewVertex *self, PyObject *args, PyObject *kwds ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->vv = 0; // ViewVertex is abstract + self->py_if0D.if0D = self->vv; + self->py_if0D.borrowed = 0; + return 0; +} + +static char ViewVertex_setNature___doc__[] = +".. method:: setNature(iNature)\n" +"\n" +" Sets the nature of the vertex.\n" +"\n" +" :arg iNature: A Nature object.\n" +" :type iNature: :class:`Nature`\n"; + +static PyObject * ViewVertex_setNature( BPy_ViewVertex *self, PyObject *args ) { + PyObject *py_n; + + if( !self->vv ) + Py_RETURN_NONE; + + if(!( PyArg_ParseTuple(args, "O!", &Nature_Type, &py_n) )) + return NULL; + + PyObject *i = (PyObject *) &( ((BPy_Nature *) py_n)->i ); + ((ViewVertex *) self->py_if0D.if0D)->setNature( PyLong_AsLong(i) ); + + Py_RETURN_NONE; +} + +static char ViewVertex_edgesBegin___doc__[] = +".. method:: edgesBegin()\n" +"\n" +" Returns an iterator over the ViewEdges that goes to or comes from\n" +" this ViewVertex pointing to the first ViewEdge of the list. The\n" +" orientedViewEdgeIterator allows to iterate in CCW order over these\n" +" ViewEdges and to get the orientation for each ViewEdge\n" +" (incoming/outgoing).\n" +"\n" +" :return: An orientedViewEdgeIterator pointing to the first ViewEdge.\n" +" :rtype: :class:`orientedViewEdgeIterator`\n"; + +static PyObject * ViewVertex_edgesBegin( BPy_ViewVertex *self ) { + if( !self->vv ) + Py_RETURN_NONE; + + ViewVertexInternal::orientedViewEdgeIterator ove_it( self->vv->edgesBegin() ); + return BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ove_it, 0 ); +} + +static char ViewVertex_edgesEnd___doc__[] = +".. method:: edgesEnd()\n" +"\n" +" Returns an orientedViewEdgeIterator over the ViewEdges around this\n" +" ViewVertex, pointing after the last ViewEdge.\n" +"\n" +" :return: An orientedViewEdgeIterator pointing after the last ViewEdge.\n" +" :rtype: :class:`orientedViewEdgeIterator`\n"; + +static PyObject * ViewVertex_edgesEnd( BPy_ViewVertex *self ) { +#if 0 + if( !self->vv ) + Py_RETURN_NONE; + + ViewVertexInternal::orientedViewEdgeIterator ove_it( self->vv->edgesEnd() ); + return BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ove_it, 1 ); +#else + PyErr_SetString(PyExc_NotImplementedError, "edgesEnd method currently disabled"); + return NULL; +#endif +} + +static char ViewVertex_edgesIterator___doc__[] = +".. method:: edgesIterator(iEdge)\n" +"\n" +" Returns an orientedViewEdgeIterator pointing to the ViewEdge given\n" +" as argument.\n" +"\n" +" :arg iEdge: A ViewEdge object.\n" +" :type iEdge: :class:`ViewEdge`\n" +" :return: An orientedViewEdgeIterator pointing to the given ViewEdge.\n" +" :rtype: :class:`orientedViewEdgeIterator`\n"; + +static PyObject * ViewVertex_edgesIterator( BPy_ViewVertex *self, PyObject *args ) { + PyObject *py_ve; + + if( !self->vv ) + Py_RETURN_NONE; + + if(!( PyArg_ParseTuple(args, "O!", &ViewEdge_Type, &py_ve) )) + return NULL; + + ViewEdge *ve = ((BPy_ViewEdge *) py_ve)->ve; + ViewVertexInternal::orientedViewEdgeIterator ove_it( self->vv->edgesIterator( ve ) ); + return BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ove_it, 0 ); +} + +/*----------------------ViewVertex instance definitions ----------------------------*/ +static PyMethodDef BPy_ViewVertex_methods[] = { + {"setNature", ( PyCFunction ) ViewVertex_setNature, METH_VARARGS, ViewVertex_setNature___doc__}, + {"edgesBegin", ( PyCFunction ) ViewVertex_edgesBegin, METH_NOARGS, ViewVertex_edgesBegin___doc__}, + {"edgesEnd", ( PyCFunction ) ViewVertex_edgesEnd, METH_NOARGS, ViewVertex_edgesEnd___doc__}, + {"edgesIterator", ( PyCFunction ) ViewVertex_edgesIterator, METH_VARARGS, ViewVertex_edgesIterator___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_ViewVertex type definition ------------------------------*/ +PyTypeObject ViewVertex_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ViewVertex", /* tp_name */ + sizeof(BPy_ViewVertex), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ViewVertex___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_ViewVertex_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &Interface0D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ViewVertex___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.h b/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.h new file mode 100644 index 00000000000..26c06b50d71 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_VIEWVERTEX_H +#define FREESTYLE_PYTHON_VIEWVERTEX_H + +#include "../../view_map/ViewMap.h" +#include "../BPy_Interface0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ViewVertex_Type; + +#define BPy_ViewVertex_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ViewVertex_Type) ) + +/*---------------------------Python BPy_ViewVertex structure definition----------*/ +typedef struct { + BPy_Interface0D py_if0D; + ViewVertex *vv; +} BPy_ViewVertex; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_VIEWVERTEX_H */ diff --git a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp new file mode 100644 index 00000000000..80b9defd95e --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp @@ -0,0 +1,400 @@ +#include "BPy_StrokeVertex.h" + +#include "../../BPy_Convert.h" +#include "../../BPy_StrokeAttribute.h" +#include "../../Interface0D/BPy_SVertex.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char StrokeVertex___doc__[] = +"Class hierarchy: :class:`Interface0D` > :class:`CurvePoint` > :class:`StrokeVertex`\n" +"\n" +"Class to define a stroke vertex.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(iBrother)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg iBrother: A StrokeVertex object.\n" +" :type iBrother: :class:`StrokeVertex`\n" +"\n" +".. method:: __init__(iA, iB, t3)\n" +"\n" +" Builds a stroke vertex from 2 stroke vertices and an interpolation\n" +" parameter.\n" +"\n" +" :arg iA: The first StrokeVertex.\n" +" :type iA: :class:`StrokeVertex`\n" +" :arg iB: The second StrokeVertex.\n" +" :type iB: :class:`StrokeVertex`\n" +" :arg t3: An interpolation parameter.\n" +" :type t3: float\n" +"\n" +".. method:: __init__(iPoint)\n" +"\n" +" Builds a stroke vertex from a CurvePoint\n" +"\n" +" :arg iPoint: A CurvePoint object.\n" +" :type iPoint: :class:`CurvePoint`\n" +"\n" +".. method:: __init__(iSVertex)\n" +"\n" +" Builds a stroke vertex from a SVertex\n" +"\n" +" :arg iSVertex: An SVertex object.\n" +" :type iSVertex: :class:`SVertex`\n" +"\n" +".. method:: __init__(iSVertex, iAttribute)\n" +"\n" +" Builds a stroke vertex from an SVertex and a StrokeAttribute object.\n" +"\n" +" :arg iSVertex: An SVertex object.\n" +" :type iSVertex: :class:`SVertex`\n" +" :arg iAttribute: A StrokeAttribute object.\n" +" :type iAttribute: :class:`StrokeAttribute`\n"; + +static int StrokeVertex___init__(BPy_StrokeVertex *self, PyObject *args, PyObject *kwds) +{ + + PyObject *obj1 = 0, *obj2 = 0 , *obj3 = 0; + + if (! PyArg_ParseTuple(args, "|OOO!", &obj1, &obj2, &PyFloat_Type, &obj3) ) + return -1; + + if( !obj1 ){ + self->sv = new StrokeVertex(); + + } else if( !obj2 && BPy_StrokeVertex_Check(obj1) && ((BPy_StrokeVertex *) obj1)->sv ) { + self->sv = new StrokeVertex( *(((BPy_StrokeVertex *) obj1)->sv) ); + + } else if( !obj2 && BPy_CurvePoint_Check(obj1) && ((BPy_CurvePoint *) obj1)->cp ) { + self->sv = new StrokeVertex( ((BPy_CurvePoint *) obj1)->cp ); + + } else if( !obj2 && BPy_SVertex_Check(obj1) && ((BPy_SVertex *) obj1)->sv ) { + self->sv = new StrokeVertex( ((BPy_SVertex *) obj1)->sv ); + + } else if( obj3 && BPy_StrokeVertex_Check(obj1) && BPy_StrokeVertex_Check(obj2) ) { + StrokeVertex *sv1 = ((BPy_StrokeVertex *) obj1)->sv; + StrokeVertex *sv2 = ((BPy_StrokeVertex *) obj2)->sv; + if( !sv1 || ( sv1->A() == 0 && sv1->B() == 0 ) ) { + PyErr_SetString(PyExc_TypeError, "argument 1 is an invalid StrokeVertex object"); + return -1; + } + if( !sv2 || ( sv2->A() == 0 && sv2->B() == 0 ) ) { + PyErr_SetString(PyExc_TypeError, "argument 2 is an invalid StrokeVertex object"); + return -1; + } + self->sv = new StrokeVertex( sv1, sv2, PyFloat_AsDouble( obj3 ) ); + + } else { + PyErr_SetString(PyExc_TypeError, "invalid argument(s)"); + return -1; + } + + self->py_cp.cp = self->sv; + self->py_cp.py_if0D.if0D = self->sv; + self->py_cp.py_if0D.borrowed = 0; + + return 0; +} + +static char StrokeVertex_x___doc__[] = +".. method:: x()\n" +"\n" +" Returns the 2D point X coordinate.\n" +"\n" +" :return: The X coordinate.\n" +" :rtype: float\n"; + +static PyObject * StrokeVertex_x( BPy_StrokeVertex *self ) { + return PyFloat_FromDouble( self->sv->x() ); +} + +static char StrokeVertex_y___doc__[] = +".. method:: y()\n" +"\n" +" Returns the 2D point Y coordinate.\n" +"\n" +" :return: The Y coordinate.\n" +" :rtype: float\n"; + +static PyObject * StrokeVertex_y( BPy_StrokeVertex *self ) { + return PyFloat_FromDouble( self->sv->y() ); +} + +static char StrokeVertex_getPoint___doc__[] = +".. method:: getPoint()\n" +"\n" +" Returns the 2D point coordinates as a two-dimensional vector.\n" +"\n" +" :return: The 2D coordinates.\n" +" :rtype: :class:`mathutils.Vector`\n"; + +static PyObject * StrokeVertex_getPoint( BPy_StrokeVertex *self ) { + Vec2f v( self->sv->getPoint() ); + return Vector_from_Vec2f( v ); +} + +static char StrokeVertex_attribute___doc__[] = +".. method:: attribute()\n" +"\n" +" Returns the StrokeAttribute for this StrokeVertex.\n" +"\n" +" :return: The StrokeAttribute object.\n" +" :rtype: :class:`StrokeAttribute`\n"; + +static PyObject * StrokeVertex_attribute( BPy_StrokeVertex *self ) { + return BPy_StrokeAttribute_from_StrokeAttribute( self->sv->attribute() ); +} + +static char StrokeVertex_curvilinearAbscissa___doc__[] = +".. method:: curvilinearAbscissa()\n" +"\n" +" Returns the curvilinear abscissa.\n" +"\n" +" :return: The curvilinear abscissa.\n" +" :rtype: float\n"; + +static PyObject * StrokeVertex_curvilinearAbscissa( BPy_StrokeVertex *self ) { + return PyFloat_FromDouble( self->sv->curvilinearAbscissa() ); +} + +static char StrokeVertex_strokeLength___doc__[] = +".. method:: strokeLength()\n" +"\n" +" Returns the length of the Stroke to which this StrokeVertex belongs\n" +"\n" +" :return: The stroke length.\n" +" :rtype: float\n"; + +static PyObject * StrokeVertex_strokeLength( BPy_StrokeVertex *self ) { + return PyFloat_FromDouble( self->sv->strokeLength() ); +} + +static char StrokeVertex_u___doc__[] = +".. method:: u()\n" +"\n" +" Returns the curvilinear abscissa of this StrokeVertex in the Stroke\n" +"\n" +" :return: The curvilinear abscissa.\n" +" :rtype: float\n"; + +static PyObject * StrokeVertex_u( BPy_StrokeVertex *self ) { + return PyFloat_FromDouble( self->sv->u() ); +} + +static char StrokeVertex_setX___doc__[] = +".. method:: setX(x)\n" +"\n" +" Sets the 2D point X coordinate.\n" +"\n" +" :arg x: The X coordinate.\n" +" :type x: float\n"; + +static PyObject *StrokeVertex_setX( BPy_StrokeVertex *self , PyObject *args) { + double r; + + if(!( PyArg_ParseTuple(args, "d", &r) )) + return NULL; + + self->sv->setX( r ); + + Py_RETURN_NONE; +} + +static char StrokeVertex_setY___doc__[] = +".. method:: setY(y)\n" +"\n" +" Sets the 2D point Y coordinate.\n" +"\n" +" :arg y: The Y coordinate.\n" +" :type y: float\n"; + +static PyObject *StrokeVertex_setY( BPy_StrokeVertex *self , PyObject *args) { + double r; + + if(!( PyArg_ParseTuple(args, "d", &r) )) + return NULL; + + self->sv->setY( r ); + + Py_RETURN_NONE; +} + +static char StrokeVertex_setPoint___doc__[] = +".. method:: setPoint(x, y)\n" +"\n" +" Sets the 2D point X and Y coordinates.\n" +"\n" +" :arg x: The X coordinate.\n" +" :type x: float\n" +" :arg y: The Y coordinate.\n" +" :type y: float\n" +"\n" +".. method:: setPoint(p)\n" +"\n" +" Sets the 2D point X and Y coordinates.\n" +"\n" +" :arg p: A two-dimensional vector.\n" +" :type p: :class:`mathutils.Vector`, list or tuple of 2 real numbers\n"; + +static PyObject *StrokeVertex_setPoint( BPy_StrokeVertex *self , PyObject *args) { + PyObject *obj1 = 0, *obj2 = 0; + + if(!( PyArg_ParseTuple(args, "O|O", &obj1, &obj2) )) + return NULL; + + if( obj1 && !obj2 ){ + Vec2f *v = Vec2f_ptr_from_PyObject(obj1); + if( !v ) { + PyErr_SetString(PyExc_TypeError, "argument 1 must be a 2D vector (either a list of 2 elements or Vector)"); + return NULL; + } + self->sv->setPoint( *v ); + delete v; + } else if( PyFloat_Check(obj1) && obj2 && PyFloat_Check(obj2) ){ + self->sv->setPoint( PyFloat_AsDouble(obj1), PyFloat_AsDouble(obj2) ); + } else { + PyErr_SetString(PyExc_TypeError, "invalid arguments"); + return NULL; + } + + Py_RETURN_NONE; +} + +static char StrokeVertex_setAttribute___doc__[] = +".. method:: setAttribute(iAttribute)\n" +"\n" +" Sets the attribute.\n" +"\n" +" :arg iAttribute: A StrokeAttribute object.\n" +" :type iAttribute: :class:`StrokeAttribute`\n"; + +static PyObject *StrokeVertex_setAttribute( BPy_StrokeVertex *self , PyObject *args) { + PyObject *py_sa; + + if(!( PyArg_ParseTuple(args, "O!", &StrokeAttribute_Type, &py_sa) )) + return NULL; + + self->sv->setAttribute(*( ((BPy_StrokeAttribute *) py_sa)->sa )); + + Py_RETURN_NONE; +} + +static char StrokeVertex_setCurvilinearAbscissa___doc__[] = +".. method:: setCurvilinearAbscissa(iAbscissa)\n" +"\n" +" Sets the curvilinear abscissa of this StrokeVertex in the Stroke\n" +"\n" +" :arg iAbscissa: The curvilinear abscissa.\n" +" :type iAbscissa: float\n"; + +static PyObject *StrokeVertex_setCurvilinearAbscissa( BPy_StrokeVertex *self , PyObject *args) { + double r; + + if(!( PyArg_ParseTuple(args, "d", &r) )) + return NULL; + + self->sv->setCurvilinearAbscissa( r ); + + Py_RETURN_NONE; +} + +static char StrokeVertex_setStrokeLength___doc__[] = +".. method:: setStrokeLength(iLength)\n" +"\n" +" Sets the stroke length (it is only a value retained by the\n" +" StrokeVertex, and it won't change the real stroke length).\n" +"\n" +" :arg iLength: The stroke length.\n" +" :type iLength: float\n"; + +static PyObject *StrokeVertex_setStrokeLength( BPy_StrokeVertex *self , PyObject *args) { + double r; + + if(!( PyArg_ParseTuple(args, "d", &r) )) + return NULL; + + self->sv->setStrokeLength( r ); + + Py_RETURN_NONE; +} + +// real operator[] (const int i) const +// real & operator[] (const int i) + +/*----------------------StrokeVertex instance definitions ----------------------------*/ +static PyMethodDef BPy_StrokeVertex_methods[] = { + {"x", ( PyCFunction ) StrokeVertex_x, METH_NOARGS, StrokeVertex_x___doc__}, + {"y", ( PyCFunction ) StrokeVertex_y, METH_NOARGS, StrokeVertex_y___doc__}, + {"getPoint", ( PyCFunction ) StrokeVertex_getPoint, METH_NOARGS, StrokeVertex_getPoint___doc__}, + {"attribute", ( PyCFunction ) StrokeVertex_attribute, METH_NOARGS, StrokeVertex_attribute___doc__}, + {"curvilinearAbscissa", ( PyCFunction ) StrokeVertex_curvilinearAbscissa, METH_NOARGS, StrokeVertex_curvilinearAbscissa___doc__}, + {"strokeLength", ( PyCFunction ) StrokeVertex_strokeLength, METH_NOARGS, StrokeVertex_strokeLength___doc__}, + {"u", ( PyCFunction ) StrokeVertex_u, METH_NOARGS, StrokeVertex_u___doc__}, + {"setX", ( PyCFunction ) StrokeVertex_setX, METH_VARARGS, StrokeVertex_setX___doc__}, + {"setY", ( PyCFunction ) StrokeVertex_setY, METH_VARARGS, StrokeVertex_setY___doc__}, + {"setPoint", ( PyCFunction ) StrokeVertex_setPoint, METH_VARARGS, StrokeVertex_setPoint___doc__}, + {"setAttribute", ( PyCFunction ) StrokeVertex_setAttribute, METH_VARARGS, StrokeVertex_setAttribute___doc__}, + {"setCurvilinearAbscissa", ( PyCFunction ) StrokeVertex_setCurvilinearAbscissa, METH_VARARGS, StrokeVertex_setCurvilinearAbscissa___doc__}, + {"setStrokeLength", ( PyCFunction ) StrokeVertex_setStrokeLength, METH_VARARGS, StrokeVertex_setStrokeLength___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_StrokeVertex type definition ------------------------------*/ +PyTypeObject StrokeVertex_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "StrokeVertex", /* tp_name */ + sizeof(BPy_StrokeVertex), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + StrokeVertex___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_StrokeVertex_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &CurvePoint_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)StrokeVertex___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.h b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.h new file mode 100644 index 00000000000..2a84e2480f0 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_STROKEVERTEX_H +#define FREESTYLE_PYTHON_STROKEVERTEX_H + +#include "../BPy_CurvePoint.h" +#include "../../../stroke/Stroke.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject StrokeVertex_Type; + +#define BPy_StrokeVertex_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &StrokeVertex_Type) ) + +/*---------------------------Python BPy_StrokeVertex structure definition----------*/ +typedef struct { + BPy_CurvePoint py_cp; + StrokeVertex *sv; +} BPy_StrokeVertex; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_STROKEVERTEX_H */ diff --git a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp new file mode 100644 index 00000000000..ebb2920353d --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp @@ -0,0 +1,153 @@ +#include "BPy_NonTVertex.h" + +#include "../../BPy_Convert.h" +#include "../BPy_SVertex.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char NonTVertex___doc__[] = +"Class hierarchy: :class:`Interface0D` > :class:`ViewVertex` > :class:`NonTVertex`\n" +"\n" +"View vertex for corners, cusps, etc. associated to a single SVertex.\n" +"Can be associated to 2 or more view edges.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(iBrother)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg iBrother: A NonTVertex object.\n" +" :type iBrother: :class:`NonTVertex`\n" +"\n" +".. method:: __init__(iSVertex)\n" +"\n" +" Builds a NonTVertex from a SVertex.\n" +"\n" +" :arg iSVertex: An SVertex object.\n" +" :type iSVertex: :class:`SVertex`\n"; + +static int NonTVertex___init__(BPy_NonTVertex *self, PyObject *args, PyObject *kwds) +{ + + PyObject *obj = 0; + + if (! PyArg_ParseTuple(args, "|O!", &SVertex_Type, &obj) ) + return -1; + + if( !obj ){ + self->ntv = new NonTVertex(); + + } else if( ((BPy_SVertex *) obj)->sv ) { + self->ntv = new NonTVertex( ((BPy_SVertex *) obj)->sv ); + + } else { + PyErr_SetString(PyExc_TypeError, "invalid argument"); + return -1; + } + + self->py_vv.vv = self->ntv; + self->py_vv.py_if0D.if0D = self->ntv; + self->py_vv.py_if0D.borrowed = 0; + + return 0; +} + +static char NonTVertex_svertex___doc__[] = +".. method:: svertex()\n" +"\n" +" Returns the SVertex on top of which this NonTVertex is built.\n" +"\n" +" :return: The SVertex on top of which this NonTVertex is built.\n" +" :rtype: :class:`SVertex`\n"; + +static PyObject * NonTVertex_svertex( BPy_NonTVertex *self ) { + SVertex *v = self->ntv->svertex(); + if( v ){ + return BPy_SVertex_from_SVertex( *v ); + } + + Py_RETURN_NONE; +} + +static char NonTVertex_setSVertex___doc__[] = +".. method:: setSVertex(iSVertex)\n" +"\n" +" Sets the SVertex on top of which this NonTVertex is built.\n" +"\n" +" :arg iSVertex: The SVertex on top of which this NonTVertex is built.\n" +" :type iSVertex: :class:`SVertex`\n"; + +static PyObject * NonTVertex_setSVertex( BPy_NonTVertex *self, PyObject *args) { + PyObject *py_sv; + + if(!( PyArg_ParseTuple(args, "O!", &SVertex_Type, &py_sv) )) + return NULL; + + self->ntv->setSVertex( ((BPy_SVertex *) py_sv)->sv ); + + Py_RETURN_NONE; +} + +/*----------------------NonTVertex instance definitions ----------------------------*/ +static PyMethodDef BPy_NonTVertex_methods[] = { + {"svertex", ( PyCFunction ) NonTVertex_svertex, METH_NOARGS, NonTVertex_svertex___doc__}, + {"setSVertex", ( PyCFunction ) NonTVertex_setSVertex, METH_VARARGS, NonTVertex_setSVertex___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_NonTVertex type definition ------------------------------*/ +PyTypeObject NonTVertex_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "NonTVertex", /* tp_name */ + sizeof(BPy_NonTVertex), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + NonTVertex___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_NonTVertex_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &ViewVertex_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)NonTVertex___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.h b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.h new file mode 100644 index 00000000000..071194d2d42 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_NONTVERTEX_H +#define FREESTYLE_PYTHON_NONTVERTEX_H + +#include "../BPy_ViewVertex.h" +#include "../../../view_map/ViewMap.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject NonTVertex_Type; + +#define BPy_NonTVertex_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &NonTVertex_Type) ) + +/*---------------------------Python BPy_NonTVertex structure definition----------*/ +typedef struct { + BPy_ViewVertex py_vv; + NonTVertex *ntv; +} BPy_NonTVertex; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_NONTVERTEX_H */ diff --git a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp new file mode 100644 index 00000000000..14add743a37 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp @@ -0,0 +1,249 @@ +#include "BPy_TVertex.h" + +#include "../../BPy_Convert.h" +#include "../BPy_SVertex.h" +#include "../../BPy_Id.h" +#include "../../Interface1D/BPy_FEdge.h" +#include "../../Interface1D/BPy_ViewEdge.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char TVertex___doc__[] = +"Class hierarchy: :class:`Interface0D` > :class:`ViewVertex` > :class:`TVertex`\n" +"\n" +"Class to define a T vertex, i.e. an intersection between two edges.\n" +"It points towards two SVertex and four ViewEdges. Among the\n" +"ViewEdges, two are front and the other two are back. Basically a\n" +"front edge hides part of a back edge. So, among the back edges, one\n" +"is of invisibility N and the other of invisibility N+1.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(iBrother)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg iBrother: A TVertex object.\n" +" :type iBrother: :class:`TVertex`\n"; + +static int TVertex___init__(BPy_TVertex *self, PyObject *args, PyObject *kwds) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->tv = new TVertex(); + self->py_vv.vv = self->tv; + self->py_vv.py_if0D.if0D = self->tv; + self->py_vv.py_if0D.borrowed = 0; + + return 0; +} + +static char TVertex_frontSVertex___doc__[] = +".. method:: frontSVertex()\n" +"\n" +" Returns the SVertex that is closer to the viewpoint.\n" +"\n" +" :return: The SVertex that is closer to the viewpoint.\n" +" :rtype: :class:`SVertex`\n"; + +static PyObject * TVertex_frontSVertex( BPy_TVertex *self ) { + SVertex *v = self->tv->frontSVertex(); + if( v ){ + return BPy_SVertex_from_SVertex( *v ); + } + + Py_RETURN_NONE; +} + +static char TVertex_backSVertex___doc__[] = +".. method:: backSVertex()\n" +"\n" +" Returns the SVertex that is further away from the viewpoint.\n" +"\n" +" :return: The SVertex that is further away from the viewpoint.\n" +" :rtype: :class:`SVertex`\n"; + +static PyObject * TVertex_backSVertex( BPy_TVertex *self ) { + SVertex *v = self->tv->backSVertex(); + if( v ){ + return BPy_SVertex_from_SVertex( *v ); + } + + Py_RETURN_NONE; +} + +static char TVertex_setFrontSVertex___doc__[] = +".. method:: setFrontSVertex(iFrontSVertex)\n" +"\n" +" Sets the SVertex that is closer to the viewpoint.\n" +"\n" +" :arg iFrontSVertex: An SVertex object.\n" +" :type iFrontSVertex: :class:`SVertex`\n"; + +static PyObject * TVertex_setFrontSVertex( BPy_TVertex *self, PyObject *args) { + PyObject *py_sv; + + if(!( PyArg_ParseTuple(args, "O!", &SVertex_Type, &py_sv) )) + return NULL; + + self->tv->setFrontSVertex( ((BPy_SVertex *) py_sv)->sv ); + + Py_RETURN_NONE; +} + +static char TVertex_setBackSVertex___doc__[] = +".. method:: setBackSVertex(iBackSVertex)\n" +"\n" +" Sets the SVertex that is further away from the viewpoint.\n" +"\n" +" :arg iBackSVertex: An SVertex object.\n" +" :type iBackSVertex: :class:`SVertex`\n"; + +static PyObject * TVertex_setBackSVertex( BPy_TVertex *self, PyObject *args) { + PyObject *py_sv; + + if(!( PyArg_ParseTuple(args, "O", &SVertex_Type, &py_sv) )) + return NULL; + + self->tv->setBackSVertex( ((BPy_SVertex *) py_sv)->sv ); + + Py_RETURN_NONE; +} + +static char TVertex_setId___doc__[] = +".. method:: setId(iId)\n" +"\n" +" Sets the Id.\n" +"\n" +" :arg iId: An Id object.\n" +" :type iId: :class:`Id`\n"; + +static PyObject * TVertex_setId( BPy_TVertex *self, PyObject *args) { + PyObject *py_id; + + if(!( PyArg_ParseTuple(args, "O!", &Id_Type, &py_id) )) + return NULL; + + if( ((BPy_Id *) py_id)->id ) + self->tv->setId(*( ((BPy_Id *) py_id)->id )); + + Py_RETURN_NONE; +} + +static char TVertex_getSVertex___doc__[] = +".. method:: getSVertex(iFEdge)\n" +"\n" +" Returns the SVertex (among the 2) belonging to the given FEdge.\n" +"\n" +" :arg iFEdge: An FEdge object.\n" +" :type iFEdge: :class:`FEdge`\n" +" :return: The SVertex belonging to the given FEdge.\n" +" :rtype: :class:`SVertex`\n"; + +static PyObject * TVertex_getSVertex( BPy_TVertex *self, PyObject *args) { + PyObject *py_fe; + + if(!( PyArg_ParseTuple(args, "O!", &FEdge_Type, &py_fe) )) + return NULL; + + SVertex *sv = self->tv->getSVertex( ((BPy_FEdge *) py_fe)->fe ); + if( sv ){ + return BPy_SVertex_from_SVertex( *sv ); + } + + Py_RETURN_NONE; +} + +static char TVertex_mate___doc__[] = +".. method:: mate(iEdgeA)\n" +"\n" +" Returns the mate edge of the ViewEdge given as argument. If the\n" +" ViewEdge is frontEdgeA, frontEdgeB is returned. If the ViewEdge is\n" +" frontEdgeB, frontEdgeA is returned. Same for back edges.\n" +"\n" +" :arg iEdgeA: A ViewEdge object.\n" +" :type iEdgeA: :class:`ViewEdge`\n" +" :return: The mate edge of the given ViewEdge.\n" +" :rtype: :class:`ViewEdge`\n"; + +static PyObject * TVertex_mate( BPy_TVertex *self, PyObject *args) { + PyObject *py_ve; + + if(!( PyArg_ParseTuple(args, "O!", &ViewEdge_Type, &py_ve) )) + return NULL; + + ViewEdge *ve = self->tv->mate( ((BPy_ViewEdge *) py_ve)->ve ); + if( ve ){ + return BPy_ViewEdge_from_ViewEdge( *ve ); + } + + Py_RETURN_NONE; +} + +/*----------------------TVertex instance definitions ----------------------------*/ +static PyMethodDef BPy_TVertex_methods[] = { + {"frontSVertex", ( PyCFunction ) TVertex_frontSVertex, METH_NOARGS, TVertex_frontSVertex___doc__}, + {"backSVertex", ( PyCFunction ) TVertex_backSVertex, METH_NOARGS, TVertex_backSVertex___doc__}, + {"setFrontSVertex", ( PyCFunction ) TVertex_setFrontSVertex, METH_VARARGS, TVertex_setFrontSVertex___doc__}, + {"setBackSVertex", ( PyCFunction ) TVertex_setBackSVertex, METH_VARARGS, TVertex_setBackSVertex___doc__}, + {"setId", ( PyCFunction ) TVertex_setId, METH_VARARGS, TVertex_setId___doc__}, + {"getSVertex", ( PyCFunction ) TVertex_getSVertex, METH_VARARGS, TVertex_getSVertex___doc__}, + {"mate", ( PyCFunction ) TVertex_mate, METH_VARARGS, TVertex_mate___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_TVertex type definition ------------------------------*/ +PyTypeObject TVertex_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "TVertex", /* tp_name */ + sizeof(BPy_TVertex), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + TVertex___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_TVertex_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &ViewVertex_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)TVertex___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.h b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.h new file mode 100644 index 00000000000..12fe5c0cb43 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_TVERTEX_H +#define FREESTYLE_PYTHON_TVERTEX_H + +#include "../BPy_ViewVertex.h" +#include "../../../view_map/ViewMap.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject TVertex_Type; + +#define BPy_TVertex_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &TVertex_Type) ) + +/*---------------------------Python BPy_TVertex structure definition----------*/ +typedef struct { + BPy_ViewVertex py_vv; + TVertex *tv; +} BPy_TVertex; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_TVERTEX_H */ diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp new file mode 100644 index 00000000000..a7b710f796b --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp @@ -0,0 +1,416 @@ +#include "BPy_FEdge.h" + +#include "../BPy_Convert.h" +#include "../BPy_Id.h" +#include "../Interface0D/BPy_SVertex.h" +#include "../Interface1D/BPy_ViewEdge.h" +#include "../BPy_Nature.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char FEdge___doc__[] = +"Class hierarchy: :class:`Interface1D` > :class:`FEdge`\n" +"\n" +"Base Class for feature edges. This FEdge can represent a silhouette,\n" +"a crease, a ridge/valley, a border or a suggestive contour. For\n" +"silhouettes, the FEdge is oriented so that the visible face lies on\n" +"the left of the edge. For borders, the FEdge is oriented so that the\n" +"face lies on the left of the edge. An FEdge can represent an initial\n" +"edge of the mesh or runs accross a face of the initial mesh depending\n" +"on the smoothness or sharpness of the mesh. This class is specialized\n" +"into a smooth and a sharp version since their properties slightly vary\n" +"from one to the other.\n" +"\n" +".. method:: FEdge()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: FEdge(iBrother)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg iBrother: An FEdge object.\n" +" :type iBrother: :class:`FEdge`\n" +"\n" +".. method:: FEdge(vA, vB)\n" +"\n" +" Builds an FEdge going from vA to vB.\n" +"\n" +" :arg vA: The first SVertex.\n" +" :type vA: :class:`SVertex`\n" +" :arg vB: The second SVertex.\n" +" :type vB: :class:`SVertex`\n"; + +static int FEdge___init__(BPy_FEdge *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj1 = 0, *obj2 = 0; + + if (! PyArg_ParseTuple(args, "|OO", &obj1, &obj2) ) + return -1; + + if( !obj1 ){ + self->fe = new FEdge(); + + } else if( !obj2 && BPy_FEdge_Check(obj1) ) { + self->fe = new FEdge(*( ((BPy_FEdge *) obj1)->fe )); + + } else if( obj2 && BPy_SVertex_Check(obj1) && BPy_SVertex_Check(obj2) ) { + self->fe = new FEdge( ((BPy_SVertex *) obj1)->sv, ((BPy_SVertex *) obj2)->sv ); + + } else { + PyErr_SetString(PyExc_TypeError, "invalid argument(s)"); + return -1; + } + + self->py_if1D.if1D = self->fe; + self->py_if1D.borrowed = 0; + + return 0; +} + +static char FEdge_vertexA___doc__[] = +".. method:: vertexA()\n" +"\n" +" Returns the first SVertex.\n" +"\n" +" :return: The first SVertex.\n" +" :rtype: :class:`SVertex`\n"; + +static PyObject * FEdge_vertexA( BPy_FEdge *self ) { + SVertex *A = self->fe->vertexA(); + if( A ){ + return BPy_SVertex_from_SVertex( *A ); + } + + Py_RETURN_NONE; +} + +static char FEdge_vertexB___doc__[] = +".. method:: vertexB()\n" +"\n" +" Returns the second SVertex.\n" +"\n" +" :return: The second SVertex.\n" +" :rtype: :class:`SVertex`\n"; + +static PyObject * FEdge_vertexB( BPy_FEdge *self ) { + SVertex *B = self->fe->vertexB(); + if( B ){ + return BPy_SVertex_from_SVertex( *B ); + } + + Py_RETURN_NONE; +} + + +static PyObject * FEdge___getitem__( BPy_FEdge *self, PyObject *args ) { + int i; + + if(!( PyArg_ParseTuple(args, "i", &i) )) + return NULL; + if(!(i == 0 || i == 1)) { + PyErr_SetString(PyExc_IndexError, "index must be either 0 or 1"); + return NULL; + } + + SVertex *v = self->fe->operator[](i); + if( v ) + return BPy_SVertex_from_SVertex( *v ); + + Py_RETURN_NONE; +} + +static char FEdge_nextEdge___doc__[] = +".. method:: nextEdge()\n" +"\n" +" Returns the FEdge following this one in the ViewEdge. If this FEdge\n" +" is the last of the ViewEdge, None is returned.\n" +"\n" +" :return: The edge following this one in the ViewEdge.\n" +" :rtype: :class:`FEdge`\n"; + +static PyObject * FEdge_nextEdge( BPy_FEdge *self ) { + FEdge *fe = self->fe->nextEdge(); + if( fe ) + return Any_BPy_FEdge_from_FEdge( *fe ); + + Py_RETURN_NONE; +} + +static char FEdge_previousEdge___doc__[] = +".. method:: previousEdge()\n" +"\n" +" Returns the FEdge preceding this one in the ViewEdge. If this FEdge\n" +" is the first one of the ViewEdge, None is returned.\n" +"\n" +" :return: The edge preceding this one in the ViewEdge.\n" +" :rtype: :class:`FEdge`\n"; + +static PyObject * FEdge_previousEdge( BPy_FEdge *self ) { + FEdge *fe = self->fe->previousEdge(); + if( fe ) + return Any_BPy_FEdge_from_FEdge( *fe ); + + Py_RETURN_NONE; +} + +static char FEdge_viewedge___doc__[] = +".. method:: viewedge()\n" +"\n" +" Returns the ViewEdge to which this FEdge belongs to.\n" +"\n" +" :return: The ViewEdge to which this FEdge belongs to.\n" +" :rtype: :class:`ViewEdge`\n"; + +static PyObject * FEdge_viewedge( BPy_FEdge *self ) { + ViewEdge *ve = self->fe->viewedge(); + if( ve ) + return BPy_ViewEdge_from_ViewEdge( *ve ); + + Py_RETURN_NONE; +} + +static char FEdge_isSmooth___doc__[] = +".. method:: isSmooth()\n" +"\n" +" Returns true if this FEdge is a smooth FEdge.\n" +"\n" +" :return: True if this FEdge is a smooth FEdge.\n" +" :rtype: bool\n"; + +static PyObject * FEdge_isSmooth( BPy_FEdge *self ) { + return PyBool_from_bool( self->fe->isSmooth() ); +} + +static char FEdge_setVertexA___doc__[] = +".. method:: setVertexA(vA)\n" +"\n" +" Sets the first SVertex.\n" +"\n" +" :arg vA: An SVertex object.\n" +" :type vA: :class:`SVertex`\n"; + +static PyObject *FEdge_setVertexA( BPy_FEdge *self , PyObject *args) { + PyObject *py_sv; + + if(!( PyArg_ParseTuple(args, "O!", &SVertex_Type, &py_sv) )) + return NULL; + + self->fe->setVertexA( ((BPy_SVertex *) py_sv)->sv ); + + Py_RETURN_NONE; +} + +static char FEdge_setVertexB___doc__[] = +".. method:: setVertexB(vB)\n" +"\n" +" Sets the second SVertex.\n" +"\n" +" :arg vB: An SVertex object.\n" +" :type vB: :class:`SVertex`\n"; + +static PyObject *FEdge_setVertexB( BPy_FEdge *self , PyObject *args) { + PyObject *py_sv; + + if(!( PyArg_ParseTuple(args, "O", &py_sv) && BPy_SVertex_Check(py_sv) )) { + cout << "ERROR: FEdge_setVertexB" << endl; + Py_RETURN_NONE; + } + + self->fe->setVertexB( ((BPy_SVertex *) py_sv)->sv ); + + Py_RETURN_NONE; +} + +static char FEdge_setId___doc__[] = +".. method:: setId(id)\n" +"\n" +" Sets the Id of this FEdge.\n" +"\n" +" :arg id: An Id object.\n" +" :type id: :class:`Id`\n"; + +static PyObject *FEdge_setId( BPy_FEdge *self , PyObject *args) { + PyObject *py_id; + + if(!( PyArg_ParseTuple(args, "O!", &Id_Type, &py_id) )) + return NULL; + + self->fe->setId(*( ((BPy_Id *) py_id)->id )); + + Py_RETURN_NONE; +} + +static char FEdge_setNextEdge___doc__[] = +".. method:: setNextEdge(iEdge)\n" +"\n" +" Sets the pointer to the next FEdge.\n" +"\n" +" :arg iEdge: An FEdge object.\n" +" :type iEdge: :class:`FEdge`\n"; + +static PyObject *FEdge_setNextEdge( BPy_FEdge *self , PyObject *args) { + PyObject *py_fe; + + if(!( PyArg_ParseTuple(args, "O!", &FEdge_Type, &py_fe) )) + return NULL; + + self->fe->setNextEdge( ((BPy_FEdge *) py_fe)->fe ); + + Py_RETURN_NONE; +} + +static char FEdge_setPreviousEdge___doc__[] = +".. method:: setPreviousEdge(iEdge)\n" +"\n" +" Sets the pointer to the previous FEdge.\n" +"\n" +" :arg iEdge: An FEdge object.\n" +" :type iEdge: :class:`FEdge`\n"; + +static PyObject *FEdge_setPreviousEdge( BPy_FEdge *self , PyObject *args) { + PyObject *py_fe; + + if(!( PyArg_ParseTuple(args, "O!", &FEdge_Type, &py_fe) )) + return NULL; + + self->fe->setPreviousEdge( ((BPy_FEdge *) py_fe)->fe ); + + Py_RETURN_NONE; +} + +static char FEdge_setNature___doc__[] = +".. method:: setNature(iNature)\n" +"\n" +" Sets the nature of this FEdge.\n" +"\n" +" :arg iNature: A Nature object.\n" +" :type iNature: :class:`Nature`\n"; + +static PyObject * FEdge_setNature( BPy_FEdge *self, PyObject *args ) { + PyObject *py_n; + + if(!( PyArg_ParseTuple(args, "O!", &Nature_Type, &py_n) )) + return NULL; + + PyObject *i = (PyObject *) &( ((BPy_Nature *) py_n)->i ); + self->fe->setNature( PyLong_AsLong(i) ); + + Py_RETURN_NONE; +} + +static char FEdge_setViewEdge___doc__[] = +".. method:: setViewEdge(iViewEdge)\n" +"\n" +" Sets the ViewEdge to which this FEdge belongs to.\n" +"\n" +" :arg iViewEdge: A ViewEdge object.\n" +" :type iViewEdge: :class:`ViewEdge`\n"; + +static PyObject * FEdge_setViewEdge( BPy_FEdge *self, PyObject *args ) { + PyObject *py_ve; + + if(!( PyArg_ParseTuple(args, "O!", &ViewEdge_Type, &py_ve) )) + return NULL; + + ViewEdge *ve = ((BPy_ViewEdge *) py_ve)->ve; + self->fe->setViewEdge( ve ); + + Py_RETURN_NONE; +} + +static char FEdge_setSmooth___doc__[] = +".. method:: setSmooth(iFlag)\n" +"\n" +" Sets the flag telling whether this FEdge is smooth or sharp. True\n" +" for Smooth, false for Sharp.\n" +"\n" +" :arg iFlag: True for Smooth, false for Sharp.\n" +" :type iFlag: bool\n"; + +static PyObject *FEdge_setSmooth( BPy_FEdge *self , PyObject *args) { + PyObject *py_b; + + if(!( PyArg_ParseTuple(args, "O", &py_b) )) + return NULL; + + self->fe->setSmooth( bool_from_PyBool(py_b) ); + + Py_RETURN_NONE; +} + +/*----------------------FEdge instance definitions ----------------------------*/ + +static PyMethodDef BPy_FEdge_methods[] = { + {"vertexA", ( PyCFunction ) FEdge_vertexA, METH_NOARGS, FEdge_vertexA___doc__}, + {"vertexB", ( PyCFunction ) FEdge_vertexB, METH_NOARGS, FEdge_vertexB___doc__}, + {"__getitem__", ( PyCFunction ) FEdge___getitem__, METH_VARARGS, "(int i) Returns the first SVertex if i=0, the seccond SVertex if i=1."}, + {"nextEdge", ( PyCFunction ) FEdge_nextEdge, METH_NOARGS, FEdge_nextEdge___doc__}, + {"previousEdge", ( PyCFunction ) FEdge_previousEdge, METH_NOARGS, FEdge_previousEdge___doc__}, + {"viewedge", ( PyCFunction ) FEdge_viewedge, METH_NOARGS, FEdge_viewedge___doc__}, + {"isSmooth", ( PyCFunction ) FEdge_isSmooth, METH_NOARGS, FEdge_isSmooth___doc__}, + {"setVertexA", ( PyCFunction ) FEdge_setVertexA, METH_VARARGS, FEdge_setVertexA___doc__}, + {"setVertexB", ( PyCFunction ) FEdge_setVertexB, METH_VARARGS, FEdge_setVertexB___doc__}, + {"setId", ( PyCFunction ) FEdge_setId, METH_VARARGS, FEdge_setId___doc__}, + {"setNextEdge", ( PyCFunction ) FEdge_setNextEdge, METH_VARARGS, FEdge_setNextEdge___doc__}, + {"setPreviousEdge", ( PyCFunction ) FEdge_setPreviousEdge, METH_VARARGS, FEdge_setPreviousEdge___doc__}, + {"setSmooth", ( PyCFunction ) FEdge_setSmooth, METH_VARARGS, FEdge_setSmooth___doc__}, + {"setViewEdge", ( PyCFunction ) FEdge_setViewEdge, METH_VARARGS, FEdge_setViewEdge___doc__}, + {"setNature", ( PyCFunction ) FEdge_setNature, METH_VARARGS, FEdge_setNature___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_FEdge type definition ------------------------------*/ + +PyTypeObject FEdge_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "FEdge", /* tp_name */ + sizeof(BPy_FEdge), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + FEdge___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_FEdge_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &Interface1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)FEdge___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.h b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.h new file mode 100644 index 00000000000..9d13145aaf2 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_FEDGE_H +#define FREESTYLE_PYTHON_FEDGE_H + +#include "../BPy_Interface1D.h" +#include "../../view_map/Silhouette.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject FEdge_Type; + +#define BPy_FEdge_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &FEdge_Type) ) + +/*---------------------------Python BPy_FEdge structure definition----------*/ +typedef struct { + BPy_Interface1D py_if1D; + FEdge *fe; +} BPy_FEdge; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_FEDGE_H */ diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp new file mode 100644 index 00000000000..5b20db3a267 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp @@ -0,0 +1,202 @@ +#include "BPy_FrsCurve.h" + +#include "../BPy_Convert.h" +#include "../BPy_Id.h" +#include "../Interface0D/BPy_CurvePoint.h" +#include "../Interface0D/BPy_SVertex.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char FrsCurve___doc__[] = +"Class hierarchy: :class:`Interface1D` > :class:`Curve`\n" +"\n" +"Base class for curves made of CurvePoints. :class:`SVertex` is the\n" +"type of the initial curve vertices. A :class:`Chain` is a\n" +"specialization of a Curve.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default Constructor.\n" +"\n" +".. method:: __init__(iBrother)\n" +"\n" +" Copy Constructor.\n" +"\n" +" :arg iBrother: A Curve object.\n" +" :type iBrother: :class:`Curve`\n" +"\n" +".. method:: __init__(iId)\n" +"\n" +" Builds a Curve from its Id.\n" +"\n" +" :arg iId: An Id object.\n" +" :type iId: :class:`Id`\n"; + +static int FrsCurve___init__(BPy_FrsCurve *self, PyObject *args, PyObject *kwds) +{ + + PyObject *obj = 0; + + if (! PyArg_ParseTuple(args, "|O", &obj) ) + return -1; + + if( !obj ){ + self->c = new Curve(); + + } else if( BPy_FrsCurve_Check(obj) ) { + self->c = new Curve(*( ((BPy_FrsCurve *) obj)->c )); + + } else if( BPy_Id_Check(obj) ) { + self->c = new Curve(*( ((BPy_Id *) obj)->id )); + + } else { + PyErr_SetString(PyExc_TypeError, "invalid argument"); + return -1; + } + + self->py_if1D.if1D = self->c; + self->py_if1D.borrowed = 0; + + return 0; +} + +static char FrsCurve_push_vertex_back___doc__[] = +".. method:: push_vertex_back(iVertex)\n" +"\n" +" Adds a single vertex at the end of the Curve.\n" +"\n" +" :arg iVertex: A vertex object.\n" +" :type iVertex: :class:`SVertex` or :class:`CurvePoint`\n"; + +static PyObject * FrsCurve_push_vertex_back( BPy_FrsCurve *self, PyObject *args ) { + PyObject *obj; + + if(!( PyArg_ParseTuple(args, "O", &obj) )) + return NULL; + + if( BPy_CurvePoint_Check(obj) ) { + self->c->push_vertex_back( ((BPy_CurvePoint *) obj)->cp ); + } else if( BPy_SVertex_Check(obj) ) { + self->c->push_vertex_back( ((BPy_SVertex *) obj)->sv ); + } else { + PyErr_SetString(PyExc_TypeError, "invalid argument"); + return NULL; + } + + Py_RETURN_NONE; +} + +static char FrsCurve_push_vertex_front___doc__[] = +".. method:: push_vertex_front(iVertex)\n" +"\n" +" Adds a single vertex at the front of the Curve.\n" +"\n" +" :arg iVertex: A vertex object.\n" +" :type iVertex: :class:`SVertex` or :class:`CurvePoint`\n"; + +static PyObject * FrsCurve_push_vertex_front( BPy_FrsCurve *self, PyObject *args ) { + PyObject *obj; + + if(!( PyArg_ParseTuple(args, "O", &obj) )) + return NULL; + + if( BPy_CurvePoint_Check(obj) ) { + self->c->push_vertex_front( ((BPy_CurvePoint *) obj)->cp ); + } else if( BPy_SVertex_Check(obj) ) { + self->c->push_vertex_front( ((BPy_SVertex *) obj)->sv ); + } else { + PyErr_SetString(PyExc_TypeError, "invalid argument"); + return NULL; + } + + Py_RETURN_NONE; +} + +static char FrsCurve_empty___doc__[] = +".. method:: empty()\n" +"\n" +" Returns true if the Curve doesn't have any Vertex yet.\n" +"\n" +" :return: True if the Curve has no vertices.\n" +" :rtype: bool\n"; + +static PyObject * FrsCurve_empty( BPy_FrsCurve *self ) { + return PyBool_from_bool( self->c->empty() ); +} + +static char FrsCurve_nSegments___doc__[] = +".. method:: nSegments()\n" +"\n" +" Returns the number of segments in the polyline constituing the\n" +" Curve.\n" +"\n" +" :return: The number of segments.\n" +" :rtype: int\n"; + +static PyObject * FrsCurve_nSegments( BPy_FrsCurve *self ) { + return PyLong_FromLong( self->c->nSegments() ); +} + +/*----------------------FrsCurve instance definitions ----------------------------*/ +static PyMethodDef BPy_FrsCurve_methods[] = { + {"push_vertex_back", ( PyCFunction ) FrsCurve_push_vertex_back, METH_VARARGS, FrsCurve_push_vertex_back___doc__}, + {"push_vertex_front", ( PyCFunction ) FrsCurve_push_vertex_front, METH_VARARGS, FrsCurve_push_vertex_front___doc__}, + {"empty", ( PyCFunction ) FrsCurve_empty, METH_NOARGS, FrsCurve_empty___doc__}, + {"nSegments", ( PyCFunction ) FrsCurve_nSegments, METH_NOARGS, FrsCurve_nSegments___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_FrsCurve type definition ------------------------------*/ + +PyTypeObject FrsCurve_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "Curve", /* tp_name */ + sizeof(BPy_FrsCurve), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + FrsCurve___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_FrsCurve_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &Interface1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)FrsCurve___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.h b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.h new file mode 100644 index 00000000000..0829cf0ebf5 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_FRSCURVE_H +#define FREESTYLE_PYTHON_FRSCURVE_H + +#include "../BPy_Interface1D.h" +#include "../../stroke/Curve.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject FrsCurve_Type; + +#define BPy_FrsCurve_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &FrsCurve_Type) ) + +/*---------------------------Python BPy_FrsCurve structure definition----------*/ +typedef struct { + BPy_Interface1D py_if1D; + Curve *c; +} BPy_FrsCurve; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_FRSCURVE_H */ diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp new file mode 100644 index 00000000000..7edfde7e8f6 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp @@ -0,0 +1,492 @@ +#include "BPy_Stroke.h" + +#include "../BPy_Convert.h" +#include "../BPy_Id.h" +#include "../Interface0D/BPy_SVertex.h" +#include "../Interface0D/CurvePoint/BPy_StrokeVertex.h" +#include "../Iterator/BPy_StrokeVertexIterator.h" +#include "../BPy_MediumType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +// Stroke () +// 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 + +static char Stroke___doc__[] = +"Class hierarchy: :class:`Interface1D` > :class:`Stroke`\n" +"\n" +"Class to define a stroke. A stroke is made of a set of 2D vertices\n" +"(:class:`StrokeVertex`), regularly spaced out. This set of vertices\n" +"defines the stroke's backbone geometry. Each of these stroke vertices\n" +"defines the stroke's shape and appearance at this vertex position.\n" +"\n" +".. method:: Stroke()\n" +"\n" +" Default constructor\n" +"\n" +".. method:: Stroke(iBrother)\n" +"\n" +" Copy constructor\n" +"\n" +" :arg iBrother: \n" +" :type iBrother: :class:`Stroke`\n" +"\n" +".. method:: Stroke(iBegin, iEnd)\n" +"\n" +" Builds a stroke from a set of StrokeVertex. This constructor is\n" +" templated by an iterator type. This iterator type must allow the\n" +" vertices parsing using the ++ operator.\n" +"\n" +" :arg iBegin: The iterator pointing to the first vertex.\n" +" :type iBegin: InputVertexIterator\n" +" :arg iEnd: The iterator pointing to the end of the vertex list.\n" +" :type iEnd: InputVertexIterator\n"; + +static int Stroke___init__(BPy_Stroke *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj1 = NULL, *obj2 = NULL; + + if (! PyArg_ParseTuple(args, "|OO", &obj1, &obj2) ) + return -1; + + if( !obj1 ){ + self->s = new Stroke(); + + } else if ( !obj2 && BPy_Stroke_Check(obj1) ) { + self->s = new Stroke(*( ((BPy_Stroke *)obj1)->s )); + + } else if ( obj2 ) { + PyErr_SetString(PyExc_TypeError, + "Stroke(InputVertexIterator iBegin, InputVertexIterator iEnd) not implemented"); + return -1; + } else { + PyErr_SetString(PyExc_TypeError, "invalid argument(s)"); + return -1; + } + + self->py_if1D.if1D = self->s; + self->py_if1D.borrowed = 0; + + return 0; +} + +static PyObject * Stroke___iter__( PyObject *self ) { + StrokeInternal::StrokeVertexIterator sv_it( ((BPy_Stroke *)self)->s->strokeVerticesBegin() ); + return BPy_StrokeVertexIterator_from_StrokeVertexIterator( sv_it, 0 ); +} + +static Py_ssize_t Stroke_length( BPy_Stroke *self ) { + return self->s->strokeVerticesSize(); +} + +static PyObject * Stroke_item( BPy_Stroke *self, Py_ssize_t i ) { + if (i < 0 || i >= (Py_ssize_t)self->s->strokeVerticesSize()) { + PyErr_SetString(PyExc_IndexError, "subscript index out of range"); + return NULL; + } + return BPy_StrokeVertex_from_StrokeVertex( self->s->strokeVerticeAt(i) ); +} + +static PyObject * Stroke___getitem__( BPy_Stroke *self, PyObject *item ) { + long i; + + if (!PyLong_Check(item)) { + PyErr_SetString(PyExc_TypeError, "subscript indices must be integers"); + return NULL; + } + i = PyLong_AsLong(item); + if (i == -1 && PyErr_Occurred()) + return NULL; + if (i < 0) { + i += self->s->strokeVerticesSize(); + } + return Stroke_item(self, i); +} + +static char Stroke_ComputeSampling___doc__[] = +".. method:: ComputeSampling(iNVertices)\n" +"\n" +" Compute the sampling needed to get iNVertices vertices. If the\n" +" specified number of vertices is less than the actual number of\n" +" vertices, the actual sampling value is returned. (To remove Vertices,\n" +" use the RemoveVertex() method of this class.)\n" +"\n" +" :arg iNVertices: The number of stroke vertices we eventually want\n" +" in our Stroke.\n" +" :type iNVertices: int\n" +" :return: The sampling that must be used in the Resample(float)\n" +" method.\n" +" :rtype: float\n"; + +static PyObject * Stroke_ComputeSampling( BPy_Stroke *self, PyObject *args ) { + int i; + + if(!( PyArg_ParseTuple(args, "i", &i) )) + return NULL; + + return PyFloat_FromDouble( self->s->ComputeSampling( i ) ); +} + +static char Stroke_Resample___doc__[] = +".. method:: Resample(iNPoints)\n" +"\n" +" Resamples the stroke so that it eventually has iNPoints. That means\n" +" it is going to add iNPoints-vertices_size, if vertices_size is the\n" +" number of points we already have. If vertices_size >= iNPoints, no\n" +" resampling is done.\n" +"\n" +" :arg iNPoints: The number of vertices we eventually want in our stroke.\n" +" :type iNPoints: int\n" +"\n" +".. method:: Resample(iSampling)\n" +"\n" +" Resamples the stroke with a given sampling. If the sampling is\n" +" smaller than the actual sampling value, no resampling is done.\n" +"\n" +" :arg iSampling: The new sampling value.\n" +" :type iSampling: float\n"; + +static PyObject * Stroke_Resample( BPy_Stroke *self, PyObject *args ) { + PyObject *obj; + + if(!( PyArg_ParseTuple(args, "O", &obj) )) + return NULL; + + if( PyLong_Check(obj) ) + self->s->Resample( (int) PyLong_AsLong(obj) ); + else if( PyFloat_Check(obj) ) + self->s->Resample( (float) PyFloat_AsDouble(obj) ); + else { + PyErr_SetString(PyExc_TypeError, "invalid argument"); + return NULL; + } + + Py_RETURN_NONE; +} + +static char Stroke_InsertVertex___doc__[] = +".. method:: InsertVertex(iVertex, next)\n" +"\n" +" Inserts the stroke vertex iVertex in the stroke before next. The\n" +" length, curvilinear abscissa are updated consequently.\n" +"\n" +" :arg iVertex: The StrokeVertex to insert in the Stroke.\n" +" :type iVertex: :class:`StrokeVertex`\n" +" :arg next: A StrokeVertexIterator pointing to the StrokeVertex\n" +" before which iVertex must be inserted.\n" +" :type next: :class:`StrokeVertexIterator`\n"; + +static PyObject * Stroke_InsertVertex( BPy_Stroke *self, PyObject *args ) { + PyObject *py_sv = 0, *py_sv_it = 0; + + if(!( PyArg_ParseTuple(args, "O!O!", &StrokeVertex_Type, &py_sv, &StrokeVertexIterator_Type, &py_sv_it) )) + return NULL; + + StrokeVertex *sv = ((BPy_StrokeVertex *) py_sv)->sv; + StrokeInternal::StrokeVertexIterator sv_it(*( ((BPy_StrokeVertexIterator *) py_sv_it)->sv_it )); + self->s->InsertVertex( sv, sv_it ); + + Py_RETURN_NONE; +} + +static char Stroke_RemoveVertex___doc__[] = +".. method:: RemoveVertex(iVertex)\n" +"\n" +" Removes the stroke vertex iVertex from the stroke. The length and\n" +" curvilinear abscissa are updated consequently.\n" +"\n" +" :arg iVertex: \n" +" :type iVertex: :class:`StrokeVertex`\n"; + +static PyObject * Stroke_RemoveVertex( BPy_Stroke *self, PyObject *args ) { + PyObject *py_sv; + + if(!( PyArg_ParseTuple(args, "O!", &StrokeVertex_Type, &py_sv) )) + return NULL; + + if( ((BPy_StrokeVertex *) py_sv)->sv ) + self->s->RemoveVertex( ((BPy_StrokeVertex *) py_sv)->sv ); + else { + PyErr_SetString(PyExc_TypeError, "invalid argument"); + return NULL; + } + + Py_RETURN_NONE; +} + +static char Stroke_getMediumType___doc__[] = +".. method:: getMediumType()\n" +"\n" +" Returns the MediumType used for this Stroke.\n" +"\n" +" :return: the MediumType used for this Stroke.\n" +" :rtype: :class:`MediumType`\n"; + +static PyObject * Stroke_getMediumType( BPy_Stroke *self ) { + return BPy_MediumType_from_MediumType( self->s->getMediumType() ); +} + +static char Stroke_getTextureId___doc__[] = +".. method:: getTextureId()\n" +"\n" +" Returns the ID of the texture used to simulate th marks system for\n" +" this Stroke\n" +"\n" +" :return: The texture ID.\n" +" :rtype: int\n"; + +static PyObject * Stroke_getTextureId( BPy_Stroke *self ) { + return PyLong_FromLong( self->s->getTextureId() ); +} + +static char Stroke_hasTips___doc__[] = +".. method:: hasTips()\n" +"\n" +" Returns true if this Stroke uses a texture with tips, false\n" +" otherwise.\n" +"\n" +" :return: True if this Stroke uses a texture with tips.\n" +" :rtype: bool\n"; + +static PyObject * Stroke_hasTips( BPy_Stroke *self ) { + return PyBool_from_bool( self->s->hasTips() ); +} + +static char Stroke_setId___doc__[] = +".. method:: setId(id)\n" +"\n" +" Sets the Id of the Stroke.\n" +"\n" +" :arg id: the Id of the Stroke.\n" +" :type id: :class:`Id`\n"; + +static PyObject *Stroke_setId( BPy_Stroke *self , PyObject *args) { + PyObject *py_id; + + if(!( PyArg_ParseTuple(args, "O!", &Id_Type, &py_id) )) + return NULL; + + self->s->setId(*( ((BPy_Id *) py_id)->id )); + + Py_RETURN_NONE; +} + +static char Stroke_setLength___doc__[] = +".. method:: setLength(iLength)\n" +"\n" +" Sets the 2D length of the Stroke.\n" +"\n" +" :arg iLength: The 2D length of the Stroke.\n" +" :type iLength: float\n"; + +static PyObject *Stroke_setLength( BPy_Stroke *self , PyObject *args) { + float f; + + if(!( PyArg_ParseTuple(args, "f", &f) )) + return NULL; + + self->s->setLength( f ); + + Py_RETURN_NONE; +} + +static char Stroke_setMediumType___doc__[] = +".. method:: setMediumType(iType)\n" +"\n" +" Sets the medium type that must be used for this Stroke.\n" +"\n" +" :arg iType: A MediumType object.\n" +" :type iType: :class:`MediumType`\n"; + +static PyObject *Stroke_setMediumType( BPy_Stroke *self , PyObject *args) { + PyObject *py_mt; + + if(!( PyArg_ParseTuple(args, "O!", &MediumType_Type, &py_mt) )) + return NULL; + + self->s->setMediumType( MediumType_from_BPy_MediumType(py_mt) ); + + Py_RETURN_NONE; +} + +static char Stroke_setTextureId___doc__[] = +".. method:: setTextureId(iId)\n" +"\n" +" Sets the texture ID to be used to simulate the marks system for this\n" +" Stroke.\n" +"\n" +" :arg iId: A texture ID.\n" +" :type iId: int\n"; + +static PyObject *Stroke_setTextureId( BPy_Stroke *self , PyObject *args) { + unsigned int i; + + if(!( PyArg_ParseTuple(args, "I", &i) )) + return NULL; + + self->s->setTextureId( i ); + + Py_RETURN_NONE; +} + +static char Stroke_setTips___doc__[] = +".. method:: setTips(iTips)\n" +"\n" +" Sets the flag telling whether this stroke is using a texture with\n" +" tips or not.\n" +"\n" +" :arg iTips: True if this stroke uses a texture with tips.\n" +" :type iTips: bool\n"; + +static PyObject *Stroke_setTips( BPy_Stroke *self , PyObject *args) { + PyObject *py_b; + + if(!( PyArg_ParseTuple(args, "O", &py_b) )) + return NULL; + + self->s->setTips( bool_from_PyBool(py_b) ); + + Py_RETURN_NONE; +} + +static char Stroke_strokeVerticesBegin___doc__[] = +".. method:: strokeVerticesBegin(t=0.0)\n" +"\n" +" Returns a StrokeVertexIterator pointing on the first StrokeVertex of\n" +" the Stroke. O ne can specify a sampling value to resample the Stroke\n" +" on the fly if needed.\n" +"\n" +" :arg t: The resampling value with which we want our Stroke to be\n" +" resampled. If 0 is specified, no resampling is done.\n" +" :type t: float\n" +" :return: A StrokeVertexIterator pointing on the first StrokeVertex.\n" +" :rtype: :class:`StrokeVertexIterator`\n"; + +static PyObject * Stroke_strokeVerticesBegin( BPy_Stroke *self , PyObject *args) { + float f = 0; + + if(!( PyArg_ParseTuple(args, "|f", &f) )) + return NULL; + + StrokeInternal::StrokeVertexIterator sv_it( self->s->strokeVerticesBegin(f) ); + return BPy_StrokeVertexIterator_from_StrokeVertexIterator( sv_it, 0 ); +} + +static char Stroke_strokeVerticesEnd___doc__[] = +".. method:: strokeVerticesEnd()\n" +"\n" +" Returns a StrokeVertexIterator pointing after the last StrokeVertex\n" +" of the Stroke.\n" +"\n" +" :return: A StrokeVertexIterator pointing after the last StrokeVertex.\n" +" :rtype: :class:`StrokeVertexIterator`\n"; + +static PyObject * Stroke_strokeVerticesEnd( BPy_Stroke *self ) { + StrokeInternal::StrokeVertexIterator sv_it( self->s->strokeVerticesEnd() ); + return BPy_StrokeVertexIterator_from_StrokeVertexIterator( sv_it, 1 ); +} + +static char Stroke_strokeVerticesSize___doc__[] = +".. method:: strokeVerticesSize()\n" +"\n" +" Returns the number of StrokeVertex constituing the Stroke.\n" +"\n" +" :return: The number of stroke vertices.\n" +" :rtype: int\n"; + +static PyObject * Stroke_strokeVerticesSize( BPy_Stroke *self ) { + return PyLong_FromLong( self->s->strokeVerticesSize() ); +} + +/*----------------------Stroke instance definitions ----------------------------*/ + +static PyMethodDef BPy_Stroke_methods[] = { + {"__getitem__", ( PyCFunction ) Stroke___getitem__, METH_O, "(int i) Returns the i-th StrokeVertex constituting the Stroke."}, + {"ComputeSampling", ( PyCFunction ) Stroke_ComputeSampling, METH_VARARGS, Stroke_ComputeSampling___doc__}, + {"Resample", ( PyCFunction ) Stroke_Resample, METH_VARARGS, Stroke_Resample___doc__}, + {"RemoveVertex", ( PyCFunction ) Stroke_RemoveVertex, METH_VARARGS, Stroke_RemoveVertex___doc__}, + {"InsertVertex", ( PyCFunction ) Stroke_InsertVertex, METH_VARARGS, Stroke_InsertVertex___doc__}, + {"getMediumType", ( PyCFunction ) Stroke_getMediumType, METH_NOARGS, Stroke_getMediumType___doc__}, + {"getTextureId", ( PyCFunction ) Stroke_getTextureId, METH_NOARGS, Stroke_getTextureId___doc__}, + {"hasTips", ( PyCFunction ) Stroke_hasTips, METH_NOARGS, Stroke_hasTips___doc__}, + {"setId", ( PyCFunction ) Stroke_setId, METH_VARARGS, Stroke_setId___doc__}, + {"setLength", ( PyCFunction ) Stroke_setLength, METH_VARARGS, Stroke_setLength___doc__}, + {"setMediumType", ( PyCFunction ) Stroke_setMediumType, METH_VARARGS, Stroke_setMediumType___doc__}, + {"setTextureId", ( PyCFunction ) Stroke_setTextureId, METH_VARARGS, Stroke_setTextureId___doc__}, + {"setTips", ( PyCFunction ) Stroke_setTips, METH_VARARGS, Stroke_setTips___doc__}, + {"strokeVerticesBegin", ( PyCFunction ) Stroke_strokeVerticesBegin, METH_VARARGS, Stroke_strokeVerticesBegin___doc__}, + {"strokeVerticesEnd", ( PyCFunction ) Stroke_strokeVerticesEnd, METH_NOARGS, Stroke_strokeVerticesEnd___doc__}, + {"strokeVerticesSize", ( PyCFunction ) Stroke_strokeVerticesSize, METH_NOARGS, Stroke_strokeVerticesSize___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_Stroke type definition ------------------------------*/ + +static PySequenceMethods Stroke_as_sequence = { + (lenfunc)Stroke_length, /* sq_length */ + NULL, /* sq_concat */ + NULL, /* sq_repeat */ + (ssizeargfunc)Stroke_item, /* sq_item */ + NULL, /* sq_slice */ + NULL, /* sq_ass_item */ + NULL, /* sq_ass_slice */ + NULL, /* sq_contains */ + NULL, /* sq_inplace_concat */ + NULL, /* sq_inplace_repeat */ +}; + +PyTypeObject Stroke_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "Stroke", /* tp_name */ + sizeof(BPy_Stroke), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + &Stroke_as_sequence, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + Stroke___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + (getiterfunc)Stroke___iter__, /* tp_iter */ + 0, /* tp_iternext */ + BPy_Stroke_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &Interface1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Stroke___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.h b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.h new file mode 100644 index 00000000000..52c6d214b85 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_STROKE_H +#define FREESTYLE_PYTHON_STROKE_H + +#include "../BPy_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/Interface1D/BPy_ViewEdge.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp new file mode 100644 index 00000000000..e35ea82ace2 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp @@ -0,0 +1,463 @@ +#include "BPy_ViewEdge.h" + +#include "../BPy_Convert.h" +#include "../BPy_Id.h" +#include "../Interface0D/BPy_ViewVertex.h" +#include "../Interface1D/BPy_FEdge.h" +#include "../Interface1D/BPy_ViewEdge.h" +#include "../BPy_Nature.h" +#include "../BPy_ViewShape.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ViewEdge___doc__[] = +"Class hierarchy: :class:`Interface1D` > :class:`ViewEdge`\n" +"\n" +"Class defining a ViewEdge. A ViewEdge in an edge of the image graph.\n" +"it connnects two :class:`ViewVertex` objects. It is made by connecting\n" +"a set of FEdges.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(iBrother)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg iBrother: A ViewEdge object.\n" +" :type iBrother: :class:`ViewEdge`\n"; + +static int ViewEdge___init__(BPy_ViewEdge *self, PyObject *args, PyObject *kwds) +{ + if ( !PyArg_ParseTuple(args, "") ) + return -1; + self->ve = new ViewEdge(); + self->py_if1D.if1D = self->ve; + self->py_if1D.borrowed = 0; + + return 0; +} + +static char ViewEdge_A___doc__[] = +".. method:: A()\n" +"\n" +" Returns the first ViewVertex.\n" +"\n" +" :return: The first ViewVertex.\n" +" :rtype: :class:`ViewVertex`\n"; + +static PyObject * ViewEdge_A( BPy_ViewEdge *self ) { + ViewVertex *v = self->ve->A(); + if( v ){ + return Any_BPy_ViewVertex_from_ViewVertex( *v ); + } + + Py_RETURN_NONE; +} + +static char ViewEdge_B___doc__[] = +".. method:: B()\n" +"\n" +" Returns the second ViewVertex.\n" +"\n" +" :return: The second ViewVertex.\n" +" :rtype: :class:`ViewVertex`\n"; + +static PyObject * ViewEdge_B( BPy_ViewEdge *self ) { + ViewVertex *v = self->ve->B(); + if( v ){ + return Any_BPy_ViewVertex_from_ViewVertex( *v ); + } + + Py_RETURN_NONE; +} + +static char ViewEdge_fedgeA___doc__[] = +".. method:: fedgeA()\n" +"\n" +" Returns the first FEdge that constitutes this ViewEdge.\n" +"\n" +" :return: The first FEdge constituting this ViewEdge.\n" +" :rtype: :class:`FEdge`\n"; + +static PyObject * ViewEdge_fedgeA( BPy_ViewEdge *self ) { + FEdge *A = self->ve->fedgeA(); + if( A ){ + return Any_BPy_FEdge_from_FEdge( *A ); + } + + Py_RETURN_NONE; +} + +static char ViewEdge_fedgeB___doc__[] = +".. method:: fedgeB()\n" +"\n" +" Returns the last FEdge that constitutes this ViewEdge.\n" +"\n" +" :return: The last FEdge constituting this ViewEdge.\n" +" :rtype: :class:`FEdge`\n"; + +static PyObject * ViewEdge_fedgeB( BPy_ViewEdge *self ) { + FEdge *B = self->ve->fedgeB(); + if( B ){ + return Any_BPy_FEdge_from_FEdge( *B ); + } + + Py_RETURN_NONE; +} + +static char ViewEdge_viewShape___doc__[] = +".. method:: viewShape()\n" +"\n" +" Returns the ViewShape to which this ViewEdge belongs to.\n" +"\n" +" :return: The ViewShape to which this ViewEdge belongs to.\n" +" :rtype: :class:`ViewShape`\n"; + +static PyObject * ViewEdge_viewShape( BPy_ViewEdge *self ) { + ViewShape *vs = self->ve->viewShape(); + if( vs ){ + return BPy_ViewShape_from_ViewShape( *vs ); + } + + Py_RETURN_NONE; +} + +static char ViewEdge_aShape___doc__[] = +".. method:: aShape()\n" +"\n" +" Returns the shape that is occluded by the ViewShape to which this\n" +" ViewEdge belongs to. If no object is occluded, None is returned.\n" +"\n" +" :return: The occluded ViewShape.\n" +" :rtype: :class:`ViewShape`\n"; + +static PyObject * ViewEdge_aShape( BPy_ViewEdge *self ) { + ViewShape *vs = self->ve->aShape(); + if( vs ){ + return BPy_ViewShape_from_ViewShape( *vs ); + } + + Py_RETURN_NONE; +} + +static char ViewEdge_isClosed___doc__[] = +".. method:: isClosed()\n" +"\n" +" Tells whether this ViewEdge forms a closed loop or not.\n" +"\n" +" :return: True if this ViewEdge forms a closed loop.\n" +" :rtype: bool\n"; + +static PyObject * ViewEdge_isClosed( BPy_ViewEdge *self ) { + return PyBool_from_bool( self->ve->isClosed() ); +} + +static char ViewEdge_getChainingTimeStamp___doc__[] = +".. method:: getChainingTimeStamp()\n" +"\n" +" Returns the time stamp of this ViewEdge.\n" +"\n" +" :return: The time stamp.\n" +" :rtype: int\n"; + +static PyObject * ViewEdge_getChainingTimeStamp( BPy_ViewEdge *self ) { + return PyLong_FromLong( self->ve->getChainingTimeStamp() ); +} + +static char ViewEdge_setChainingTimeStamp___doc__[] = +".. method:: setChainingTimeStamp(ts)\n" +"\n" +" Sets the time stamp value.\n" +"\n" +" :arg ts: The time stamp.\n" +" :type ts: int\n"; + +static PyObject * ViewEdge_setChainingTimeStamp( BPy_ViewEdge *self, PyObject *args) { + int timestamp = 0 ; + + if( !PyArg_ParseTuple(args, "i", ×tamp) ) + return NULL; + + self->ve->setChainingTimeStamp( timestamp ); + + Py_RETURN_NONE; +} + +static char ViewEdge_setA___doc__[] = +".. method:: setA(iA)\n" +"\n" +" Sets the first ViewVertex of the ViewEdge.\n" +"\n" +" :arg iA: The first ViewVertex of the ViewEdge.\n" +" :type iA: :class:`ViewVertex`\n"; + +static PyObject *ViewEdge_setA( BPy_ViewEdge *self , PyObject *args) { + PyObject *py_vv; + + if(!( PyArg_ParseTuple(args, "O!", &ViewVertex_Type, &py_vv) )) + return NULL; + + self->ve->setA( ((BPy_ViewVertex *) py_vv)->vv ); + + Py_RETURN_NONE; +} + +static char ViewEdge_setB___doc__[] = +".. method:: setB(iB)\n" +"\n" +" Sets the last ViewVertex of the ViewEdge.\n" +"\n" +" :arg iB: The last ViewVertex of the ViewEdge.\n" +" :type iB: :class:`ViewVertex`\n"; + +static PyObject *ViewEdge_setB( BPy_ViewEdge *self , PyObject *args) { + PyObject *py_vv; + + if(!( PyArg_ParseTuple(args, "O!", &ViewVertex_Type, &py_vv) )) + return NULL; + + self->ve->setB( ((BPy_ViewVertex *) py_vv)->vv ); + + Py_RETURN_NONE; +} + +static char ViewEdge_setNature___doc__[] = +".. method:: setNature(iNature)\n" +"\n" +" Sets the nature of the ViewEdge.\n" +"\n" +" :arg iNature: The nature of the ViewEdge.\n" +" :type iNature: :class:`Nature`\n"; + +static PyObject * ViewEdge_setNature( BPy_ViewEdge *self, PyObject *args ) { + PyObject *py_n; + + if(!( PyArg_ParseTuple(args, "O!", &Nature_Type, &py_n) )) + return NULL; + + PyObject *i = (PyObject *) &( ((BPy_Nature *) py_n)->i ); + self->ve->setNature( PyLong_AsLong(i) ); + + Py_RETURN_NONE; +} + +static char ViewEdge_setFEdgeA___doc__[] = +".. method:: setFEdgeA(iFEdge)\n" +"\n" +" Sets the first FEdge of the ViewEdge.\n" +"\n" +" :arg iFEdge: The first FEdge of the ViewEdge.\n" +" :type iFEdge: :class:`FEdge`\n"; + +static PyObject * ViewEdge_setFEdgeA( BPy_ViewEdge *self, PyObject *args ) { + PyObject *py_fe; + + if(!( PyArg_ParseTuple(args, "O!", &FEdge_Type, &py_fe) )) + return NULL; + + self->ve->setFEdgeA( ((BPy_FEdge *) py_fe)->fe ); + + Py_RETURN_NONE; +} + +static char ViewEdge_setFEdgeB___doc__[] = +".. method:: setFEdgeB(iFEdge)\n" +"\n" +" Sets the last FEdge of the ViewEdge.\n" +"\n" +" :arg iFEdge: The last FEdge of the ViewEdge.\n" +" :type iFEdge: :class:`FEdge`\n"; + +static PyObject * ViewEdge_setFEdgeB( BPy_ViewEdge *self, PyObject *args ) { + PyObject *py_fe; + + if(!( PyArg_ParseTuple(args, "O!", &FEdge_Type, &py_fe) )) + return NULL; + + self->ve->setFEdgeB( ((BPy_FEdge *) py_fe)->fe ); + + Py_RETURN_NONE; +} + +static char ViewEdge_setShape___doc__[] = +".. method:: setShape(iVShape)\n" +"\n" +" Sets the ViewShape to which this ViewEdge belongs to.\n" +"\n" +" :arg iVShape: The ViewShape to which this ViewEdge belongs to.\n" +" :type iVShape: :class:`ViewShape`\n"; + +static PyObject * ViewEdge_setShape( BPy_ViewEdge *self, PyObject *args ) { + PyObject *py_vs; + + if(!( PyArg_ParseTuple(args, "O", &ViewShape_Type, &py_vs) )) + return NULL; + + self->ve->setShape( ((BPy_ViewShape *) py_vs)->vs ); + + Py_RETURN_NONE; +} + +static char ViewEdge_setId___doc__[] = +".. method:: setId(id)\n" +"\n" +" Sets the ViewEdge id.\n" +"\n" +" :arg id: An Id object.\n" +" :type id: :class:`Id`\n"; + +static PyObject * ViewEdge_setId( BPy_ViewEdge *self, PyObject *args ) { + PyObject *py_id; + + if(!( PyArg_ParseTuple(args, "O!", &Id_Type, &py_id) )) + return NULL; + + Id id(*( ((BPy_Id *) py_id)->id )); + self->ve->setId( id ); + + Py_RETURN_NONE; +} + +static char ViewEdge_UpdateFEdges___doc__[] = +".. method:: UpdateFEdges()\n" +"\n" +" Sets Viewedge to this for all embedded fedges.\n"; + +static PyObject * ViewEdge_UpdateFEdges( BPy_ViewEdge *self ) { + self->ve->UpdateFEdges(); + + Py_RETURN_NONE; +} + +static char ViewEdge_setaShape___doc__[] = +".. method:: setaShape(iShape)\n" +"\n" +" Sets the occluded ViewShape.\n" +"\n" +" :arg iShape: A ViewShape object.\n" +" :type iShape: :class:`ViewShape`\n"; + +static PyObject * ViewEdge_setaShape( BPy_ViewEdge *self, PyObject *args ) { + PyObject *py_vs; + + if(!( PyArg_ParseTuple(args, "O!", &ViewShape_Type, &py_vs) )) + return NULL; + + ViewShape *vs = ((BPy_ViewShape *) py_vs)->vs; + self->ve->setaShape( vs ); + + Py_RETURN_NONE; +} + +static char ViewEdge_setQI___doc__[] = +".. method:: setQI(qi)\n" +"\n" +" Sets the quantitative invisibility value of the ViewEdge.\n" +"\n" +" :arg qi: The quantitative invisibility.\n" +" :type qi: int\n"; + +static PyObject * ViewEdge_setQI( BPy_ViewEdge *self, PyObject *args ) { + int qi; + + if(!( PyArg_ParseTuple(args, "i", &qi) )) + return NULL; + + self->ve->setQI( qi ); + + Py_RETURN_NONE; +} + +static char ViewEdge_qi___doc__[] = +".. method:: getChainingTimeStamp()\n" +"\n" +" Returns the quantitative invisibility value of the ViewEdge.\n" +"\n" +" :return: The quantitative invisibility.\n" +" :rtype: int\n"; + +static PyObject * ViewEdge_qi( BPy_ViewEdge *self ) { + return PyLong_FromLong( self->ve->qi() ); +} + +/*----------------------ViewEdge instance definitions ----------------------------*/ +static PyMethodDef BPy_ViewEdge_methods[] = { + {"A", ( PyCFunction ) ViewEdge_A, METH_NOARGS, ViewEdge_A___doc__}, + {"B", ( PyCFunction ) ViewEdge_B, METH_NOARGS, ViewEdge_B___doc__}, + {"fedgeA", ( PyCFunction ) ViewEdge_fedgeA, METH_NOARGS, ViewEdge_fedgeA___doc__}, + {"fedgeB", ( PyCFunction ) ViewEdge_fedgeB, METH_NOARGS, ViewEdge_fedgeB___doc__}, + {"viewShape", ( PyCFunction ) ViewEdge_viewShape, METH_NOARGS, ViewEdge_viewShape___doc__}, + {"aShape", ( PyCFunction ) ViewEdge_aShape, METH_NOARGS, ViewEdge_aShape___doc__}, + {"isClosed", ( PyCFunction ) ViewEdge_isClosed, METH_NOARGS, ViewEdge_isClosed___doc__}, + {"getChainingTimeStamp", ( PyCFunction ) ViewEdge_getChainingTimeStamp, METH_NOARGS, ViewEdge_getChainingTimeStamp___doc__}, + {"setChainingTimeStamp", ( PyCFunction ) ViewEdge_setChainingTimeStamp, METH_VARARGS, ViewEdge_setChainingTimeStamp___doc__}, + {"setA", ( PyCFunction ) ViewEdge_setA, METH_VARARGS, ViewEdge_setA___doc__}, + {"setB", ( PyCFunction ) ViewEdge_setB, METH_VARARGS, ViewEdge_setB___doc__}, + {"setNature", ( PyCFunction ) ViewEdge_setNature, METH_VARARGS, ViewEdge_setNature___doc__}, + {"setFEdgeA", ( PyCFunction ) ViewEdge_setFEdgeA, METH_VARARGS, ViewEdge_setFEdgeA___doc__}, + {"setFEdgeB", ( PyCFunction ) ViewEdge_setFEdgeB, METH_VARARGS, ViewEdge_setFEdgeB___doc__}, + {"setShape", ( PyCFunction ) ViewEdge_setShape, METH_VARARGS, ViewEdge_setShape___doc__}, + {"setId", ( PyCFunction ) ViewEdge_setId, METH_VARARGS, ViewEdge_setId___doc__}, + {"UpdateFEdges", ( PyCFunction ) ViewEdge_UpdateFEdges, METH_NOARGS, ViewEdge_UpdateFEdges___doc__}, + {"setaShape", ( PyCFunction ) ViewEdge_setaShape, METH_VARARGS, ViewEdge_setaShape___doc__}, + {"setQI", ( PyCFunction ) ViewEdge_setQI, METH_VARARGS, ViewEdge_setQI___doc__}, + {"qi", ( PyCFunction ) ViewEdge_qi, METH_NOARGS, ViewEdge_qi___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_ViewEdge type definition ------------------------------*/ + +PyTypeObject ViewEdge_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ViewEdge", /* tp_name */ + sizeof(BPy_ViewEdge), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ViewEdge___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_ViewEdge_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &Interface1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ViewEdge___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.h b/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.h new file mode 100644 index 00000000000..ead377377e8 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.h @@ -0,0 +1,32 @@ +#ifndef FREESTYLE_PYTHON_VIEWEDGE_H +#define FREESTYLE_PYTHON_VIEWEDGE_H + +#include "../../view_map/ViewMap.h" + +#include "../BPy_Interface1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ViewEdge_Type; + +#define BPy_ViewEdge_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ViewEdge_Type) ) + +/*---------------------------Python BPy_ViewEdge structure definition----------*/ +typedef struct { + BPy_Interface1D py_if1D; + ViewEdge *ve; +} BPy_ViewEdge; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_VIEWEDGE_H */ diff --git a/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp b/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp new file mode 100644 index 00000000000..c85134f71d5 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp @@ -0,0 +1,171 @@ +#include "BPy_Chain.h" + +#include "../../BPy_Convert.h" +#include "../../BPy_Id.h" +#include "../BPy_ViewEdge.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char Chain___doc__[] = +"Class hierarchy: :class:`Interface1D` > :class:`Curve` > :class:`Chain`\n" +"\n" +"Class to represent a 1D elements issued from the chaining process. A\n" +"Chain is the last step before the :class:`Stroke` and is used in the\n" +"Splitting and Creation processes.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Defult constructor.\n" +"\n" +".. method:: __init__(iBrother)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg iBrother: A Chain object.\n" +" :type iBrother: :class:`Chain`\n" +"\n" +".. method:: __init__(id)\n" +"\n" +" Builds a chain from its Id.\n" +"\n" +" :arg id: An Id object.\n" +" :type id: :class:`Id`\n"; + +int Chain___init__(BPy_Chain *self, PyObject *args, PyObject *kwds) +{ + + PyObject *obj = 0; + + if (! PyArg_ParseTuple(args, "|O", &obj) ) + return -1; + + if( !obj ){ + self->c = new Chain(); + + } else if( BPy_Chain_Check(obj) ) { + self->c = new Chain(*( ((BPy_Chain *) obj)->c )); + + } else if( BPy_Id_Check(obj) ) { + self->c = new Chain(*( ((BPy_Id *) obj)->id )); + + } else { + PyErr_SetString(PyExc_TypeError, "invalid argument"); + return -1; + } + + self->py_c.c = self->c; + self->py_c.py_if1D.if1D = self->c; + self->py_c.py_if1D.borrowed = 0; + + return 0; +} + +static char Chain_push_viewedge_back___doc__[] = +".. method:: push_viewedge_back(iViewEdge, orientation)\n" +"\n" +" Adds a ViewEdge at the end of the Chain.\n" +"\n" +" :arg iViewEdge: The ViewEdge that must be added.\n" +" :type iViewEdge: :class:`ViewEdge`\n" +" :arg orientation: The orientation with which the ViewEdge must be\n" +" processed.\n" +" :type orientation: bool\n"; + +PyObject * Chain_push_viewedge_back( BPy_Chain *self, PyObject *args ) { + PyObject *obj1 = 0, *obj2 = 0; + + if(!( PyArg_ParseTuple(args, "O!O", &ViewEdge_Type, &obj1, &obj2) )) + return NULL; + + ViewEdge *ve = ((BPy_ViewEdge *) obj1)->ve; + bool orientation = bool_from_PyBool( obj2 ); + self->c->push_viewedge_back( ve, orientation); + + Py_RETURN_NONE; +} + +static char Chain_push_viewedge_front___doc__[] = +".. method:: push_viewedge_front(iViewEdge, orientation)\n" +"\n" +" Adds a ViewEdge at the beginning of the Chain.\n" +"\n" +" :arg iViewEdge: The ViewEdge that must be added.\n" +" :type iViewEdge: :class:`ViewEdge`\n" +" :arg orientation: The orientation with which the ViewEdge must be\n" +" processed.\n" +" :type orientation: bool\n"; + +PyObject * Chain_push_viewedge_front( BPy_Chain *self, PyObject *args ) { + PyObject *obj1 = 0, *obj2 = 0; + + if(!( PyArg_ParseTuple(args, "O!O", &ViewEdge_Type, &obj1, &obj2) )) + return NULL; + + ViewEdge *ve = ((BPy_ViewEdge *) obj1)->ve; + bool orientation = bool_from_PyBool( obj2 ); + self->c->push_viewedge_front(ve, orientation); + + Py_RETURN_NONE; +} + +/*----------------------Chain instance definitions ----------------------------*/ +static PyMethodDef BPy_Chain_methods[] = { + {"push_viewedge_back", ( PyCFunction ) Chain_push_viewedge_back, METH_VARARGS, Chain_push_viewedge_back___doc__}, + {"push_viewedge_front", ( PyCFunction ) Chain_push_viewedge_front, METH_VARARGS, Chain_push_viewedge_front___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_Chain type definition ------------------------------*/ + +PyTypeObject Chain_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "Chain", /* tp_name */ + sizeof(BPy_Chain), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + Chain___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_Chain_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &FrsCurve_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Chain___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.h b/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.h new file mode 100644 index 00000000000..19f325ef513 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_CHAIN_H +#define FREESTYLE_PYTHON_CHAIN_H + +#include "../BPy_FrsCurve.h" +#include "../../../stroke/Chain.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject Chain_Type; + +#define BPy_Chain_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &Chain_Type) ) + +/*---------------------------Python BPy_Chain structure definition----------*/ +typedef struct { + BPy_FrsCurve py_c; + Chain *c; +} BPy_Chain; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_CHAIN_H */ diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp new file mode 100644 index 00000000000..ec49167b0c1 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp @@ -0,0 +1,305 @@ +#include "BPy_FEdgeSharp.h" + +#include "../../BPy_Convert.h" +#include "../../Interface0D/BPy_SVertex.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char FEdgeSharp___doc__[] = +"Class hierarchy: :class:`Interface1D` > :class:`FEdge` > :class:`FEdgeSharp`\n" +"\n" +"Class defining a sharp FEdge. A Sharp FEdge corresponds to an initial\n" +"edge of the input mesh. It can be a silhouette, a crease or a border.\n" +"If it is a crease edge, then it is borded by two faces of the mesh.\n" +"Face a lies on its right whereas Face b lies on its left. If it is a\n" +"border edge, then it doesn't have any face on its right, and thus Face\n" +"a is None.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(iBrother)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg iBrother: An FEdgeSharp object.\n" +" :type iBrother: :class:`FEdgeSharp`\n" +"\n" +".. method:: __init__(vA, vB)\n" +"\n" +" Builds an FEdgeSharp going from vA to vB.\n" +"\n" +" :arg vA: The first SVertex object.\n" +" :type vA: :class:`SVertex`\n" +" :arg vB: The second SVertex object.\n" +" :type vB: :class:`SVertex`\n"; + +static int FEdgeSharp___init__(BPy_FEdgeSharp *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj1 = 0, *obj2 = 0; + + if (! PyArg_ParseTuple(args, "|OO", &obj1, &obj2) ) + return -1; + + if( !obj1 ){ + self->fes = new FEdgeSharp(); + + } else if( !obj2 && BPy_FEdgeSharp_Check(obj1) ) { + self->fes = new FEdgeSharp(*( ((BPy_FEdgeSharp *) obj1)->fes )); + + } else if( obj2 && BPy_SVertex_Check(obj1) && BPy_SVertex_Check(obj2) ) { + self->fes = new FEdgeSharp( ((BPy_SVertex *) obj1)->sv, ((BPy_SVertex *) obj2)->sv ); + + } else { + PyErr_SetString(PyExc_TypeError, "invalid argument(s)"); + return -1; + } + + self->py_fe.fe = self->fes; + self->py_fe.py_if1D.if1D = self->fes; + self->py_fe.py_if1D.borrowed = 0; + + return 0; +} + +static char FEdgeSharp_normalA___doc__[] = +".. method:: normalA()\n" +"\n" +" Returns the normal to the face lying on the right of the FEdge. If\n" +" this FEdge is a border, it has no Face on its right and therefore, no\n" +" normal.\n" +"\n" +" :return: The normal to the face lying on the right of the FEdge.\n" +" :rtype: :class:`mathutils.Vector`\n"; + +static PyObject * FEdgeSharp_normalA( BPy_FEdgeSharp *self ) { + Vec3r v( self->fes->normalA() ); + return Vector_from_Vec3r( v ); +} + +static char FEdgeSharp_normalB___doc__[] = +".. method:: normalB()\n" +"\n" +" Returns the normal to the face lying on the left of the FEdge.\n" +"\n" +" :return: The normal to the face lying on the left of the FEdge.\n" +" :rtype: :class:`mathutils.Vector`\n"; + +static PyObject * FEdgeSharp_normalB( BPy_FEdgeSharp *self ) { + Vec3r v( self->fes->normalB() ); + return Vector_from_Vec3r( v ); +} + +static char FEdgeSharp_aMaterialIndex___doc__[] = +".. method:: aMaterialIndex()\n" +"\n" +" Returns the index of the material of the face lying on the right of\n" +" the FEdge. If this FEdge is a border, it has no Face on its right and\n" +" therefore, no material.\n" +"\n" +" :return: The index of the material of the face lying on the right of\n" +" the FEdge.\n" +" :rtype: int\n"; + +static PyObject * FEdgeSharp_aMaterialIndex( BPy_FEdgeSharp *self ) { + return PyLong_FromLong( self->fes->aFrsMaterialIndex() ); +} + +static char FEdgeSharp_bMaterialIndex___doc__[] = +".. method:: bMaterialIndex()\n" +"\n" +" Returns the index of the material of the face lying on the left of\n" +" the FEdge.\n" +"\n" +" :return: The index of the material of the face lying on the left of\n" +" the FEdge.\n" +" :rtype: int\n"; + +static PyObject * FEdgeSharp_bMaterialIndex( BPy_FEdgeSharp *self ) { + return PyLong_FromLong( self->fes->bFrsMaterialIndex() ); +} + +static char FEdgeSharp_aMaterial___doc__[] = +".. method:: aMaterial()\n" +"\n" +" Returns the material of the face lying on the right of the FEdge. If\n" +" this FEdge is a border, it has no Face on its right and therefore, no\n" +" material.\n" +"\n" +" :return: The material of the face lying on the right of the FEdge.\n" +" :rtype: :class:`Material`\n"; + +static PyObject * FEdgeSharp_aMaterial( BPy_FEdgeSharp *self ) { + FrsMaterial m( self->fes->aFrsMaterial() ); + return BPy_FrsMaterial_from_FrsMaterial(m); +} + +static char FEdgeSharp_bMaterial___doc__[] = +".. method:: bMaterial()\n" +"\n" +" Returns the material of the face lying on the left of the FEdge.\n" +"\n" +" :return: The material of the face lying on the left of the FEdge.\n" +" :rtype: :class:`Material`\n"; + +static PyObject * FEdgeSharp_bMaterial( BPy_FEdgeSharp *self ) { + FrsMaterial m( self->fes->aFrsMaterial() ); + return BPy_FrsMaterial_from_FrsMaterial(m); +} + +static char FEdgeSharp_setNormalA___doc__[] = +".. method:: setNormalA(iNormal)\n" +"\n" +" Sets the normal to the face lying on the right of the FEdge.\n" +"\n" +" :arg iNormal: A three-dimensional vector.\n" +" :type iNormal: :class:`mathutils.Vector`, list or tuple of 3 real numbers\n"; + +static PyObject * FEdgeSharp_setNormalA( BPy_FEdgeSharp *self, PyObject *args ) { + PyObject *obj = 0; + + if(!( PyArg_ParseTuple(args, "O", &obj) )) + return NULL; + Vec3r *v = Vec3r_ptr_from_PyObject(obj); + if( !v ) { + PyErr_SetString(PyExc_TypeError, "argument 1 must be a 3D vector (either a list of 3 elements or Vector)"); + return NULL; + } + self->fes->setNormalA( *v ); + delete v; + + Py_RETURN_NONE; +} + +static char FEdgeSharp_setNormalB___doc__[] = +".. method:: setNormalB(iNormal)\n" +"\n" +" Sets the normal to the face lying on the left of the FEdge.\n" +"\n" +" :arg iNormal: A three-dimensional vector.\n" +" :type iNormal: :class:`mathutils.Vector`, list or tuple of 3 real numbers\n"; + +static PyObject * FEdgeSharp_setNormalB( BPy_FEdgeSharp *self, PyObject *args ) { + PyObject *obj = 0; + + if(!( PyArg_ParseTuple(args, "O", &obj) )) + return NULL; + Vec3r *v = Vec3r_ptr_from_PyObject(obj); + if( !v ) { + PyErr_SetString(PyExc_TypeError, "argument 1 must be a 3D vector (either a list of 3 elements or Vector)"); + return NULL; + } + self->fes->setNormalB( *v ); + delete v; + + Py_RETURN_NONE; +} + +static char FEdgeSharp_setaMaterialIndex___doc__[] = +".. method:: setaMaterialIndex(i)\n" +"\n" +" Sets the index of the material lying on the right of the FEdge.\n" +"\n" +" :arg i: A material index.\n" +" :type i: int\n"; + +static PyObject * FEdgeSharp_setaMaterialIndex( BPy_FEdgeSharp *self, PyObject *args ) { + unsigned int i; + + if(!( PyArg_ParseTuple(args, "I", &i) )) + return NULL; + + self->fes->setaFrsMaterialIndex( i ); + + Py_RETURN_NONE; +} + +static char FEdgeSharp_setbMaterialIndex___doc__[] = +".. method:: setbMaterialIndex(i)\n" +"\n" +" Sets the index of the material lying on the left of the FEdge.\n" +"\n" +" :arg i: A material index.\n" +" :type i: int\n"; + +static PyObject * FEdgeSharp_setbMaterialIndex( BPy_FEdgeSharp *self, PyObject *args ) { + unsigned int i; + + if(!( PyArg_ParseTuple(args, "I", &i) )) + return NULL; + + self->fes->setbFrsMaterialIndex( i ); + + Py_RETURN_NONE; +} + +/*----------------------FEdgeSharp instance definitions ----------------------------*/ +static PyMethodDef BPy_FEdgeSharp_methods[] = { + {"normalA", ( PyCFunction ) FEdgeSharp_normalA, METH_NOARGS, FEdgeSharp_normalA___doc__}, + {"normalB", ( PyCFunction ) FEdgeSharp_normalB, METH_NOARGS, FEdgeSharp_normalB___doc__}, + {"aMaterialIndex", ( PyCFunction ) FEdgeSharp_aMaterialIndex, METH_NOARGS, FEdgeSharp_aMaterialIndex___doc__}, + {"bMaterialIndex", ( PyCFunction ) FEdgeSharp_bMaterialIndex, METH_NOARGS, FEdgeSharp_bMaterialIndex___doc__}, + {"aMaterial", ( PyCFunction ) FEdgeSharp_aMaterial, METH_NOARGS, FEdgeSharp_aMaterial___doc__}, + {"bMaterial", ( PyCFunction ) FEdgeSharp_bMaterial, METH_NOARGS, FEdgeSharp_bMaterial___doc__}, + {"setNormalA", ( PyCFunction ) FEdgeSharp_setNormalA, METH_VARARGS, FEdgeSharp_setNormalA___doc__}, + {"setNormalB", ( PyCFunction ) FEdgeSharp_setNormalB, METH_VARARGS, FEdgeSharp_setNormalB___doc__}, + {"setaMaterialIndex", ( PyCFunction ) FEdgeSharp_setaMaterialIndex, METH_VARARGS, FEdgeSharp_setaMaterialIndex___doc__}, + {"setbMaterialIndex", ( PyCFunction ) FEdgeSharp_setbMaterialIndex, METH_VARARGS, FEdgeSharp_setbMaterialIndex___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_FEdgeSharp type definition ------------------------------*/ + +PyTypeObject FEdgeSharp_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "FEdgeSharp", /* tp_name */ + sizeof(BPy_FEdgeSharp), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + FEdgeSharp___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_FEdgeSharp_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &FEdge_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)FEdgeSharp___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.h b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.h new file mode 100644 index 00000000000..84b01e27c21 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_FEDGESHARP_H +#define FREESTYLE_PYTHON_FEDGESHARP_H + +#include "../BPy_FEdge.h" +#include "../../../view_map/Silhouette.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject FEdgeSharp_Type; + +#define BPy_FEdgeSharp_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &FEdgeSharp_Type) ) + +/*---------------------------Python BPy_FEdgeSharp structure definition----------*/ +typedef struct { + BPy_FEdge py_fe; + FEdgeSharp *fes; +} BPy_FEdgeSharp; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_FEDGESHARP_H */ diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp new file mode 100644 index 00000000000..df945b1e6a8 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp @@ -0,0 +1,207 @@ +#include "BPy_FEdgeSmooth.h" + +#include "../../BPy_Convert.h" +#include "../../Interface0D/BPy_SVertex.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char FEdgeSmooth___doc__[] = +"Class hierarchy: :class:`Interface1D` > :class:`FEdge` > :class:`FEdgeSmooth`\n" +"\n" +"Class defining a smooth edge. This kind of edge typically runs across\n" +"a face of the input mesh. It can be a silhouette, a ridge or valley,\n" +"a suggestive contour.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(iBrother)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg iBrother: An FEdgeSmooth object.\n" +" :type iBrother: :class:`FEdgeSmooth`\n" +"\n" +".. method:: __init__(vA, vB)\n" +"\n" +" Builds an FEdgeSmooth going from vA to vB.\n" +"\n" +" :arg vA: The first SVertex object.\n" +" :type vA: :class:`SVertex`\n" +" :arg vB: The second SVertex object.\n" +" :type vB: :class:`SVertex`\n"; + +static int FEdgeSmooth___init__(BPy_FEdgeSmooth *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj1 = 0, *obj2 = 0; + + if (! PyArg_ParseTuple(args, "|OO", &obj1, &obj2) ) + return -1; + + if( !obj1 ){ + self->fes = new FEdgeSmooth(); + + } else if( !obj2 && BPy_FEdgeSmooth_Check(obj1) ) { + self->fes = new FEdgeSmooth(*( ((BPy_FEdgeSmooth *) obj1)->fes )); + + } else if( obj2 && BPy_SVertex_Check(obj1) && BPy_SVertex_Check(obj2) ) { + self->fes = new FEdgeSmooth( ((BPy_SVertex *) obj1)->sv, ((BPy_SVertex *) obj2)->sv ); + + } else { + PyErr_SetString(PyExc_TypeError, "invalid argument(s)"); + return -1; + } + + self->py_fe.fe = self->fes; + self->py_fe.py_if1D.if1D = self->fes; + self->py_fe.py_if1D.borrowed = 0; + + return 0; +} + +static char FEdgeSmooth_normal___doc__[] = +".. method:: normal()\n" +"\n" +" Returns the normal to the Face it is running accross.\n" +"\n" +" :return: The normal to the Face it is running accross.\n" +" :rtype: :class:`mathutils.Vector`\n"; + +static PyObject * FEdgeSmooth_normal( BPy_FEdgeSmooth *self ) { + Vec3r v( self->fes->normal() ); + return Vector_from_Vec3r( v ); +} + +static char FEdgeSmooth_materialIndex___doc__[] = +".. method:: materialIndex()\n" +"\n" +" Returns the index of the material of the face it is running accross.\n" +"\n" +" :return: The index of the material of the face it is running accross.\n" +" :rtype: int\n"; + +static PyObject * FEdgeSmooth_materialIndex( BPy_FEdgeSmooth *self ) { + return PyLong_FromLong( self->fes->frs_materialIndex() ); +} + +static char FEdgeSmooth_material___doc__[] = +".. method:: material()\n" +"\n" +" Returns the material of the face it is running accross.\n" +"\n" +" :return: The material of the face it is running accross.\n" +" :rtype: :class:`Material`\n"; + +static PyObject * FEdgeSmooth_material( BPy_FEdgeSmooth *self ) { + FrsMaterial m( self->fes->frs_material() ); + return BPy_FrsMaterial_from_FrsMaterial(m); +} + +static char FEdgeSmooth_setNormal___doc__[] = +".. method:: setNormal(iNormal)\n" +"\n" +" Sets the normal to the Face it is running accross.\n" +"\n" +" :arg iNormal: A three-dimensional vector.\n" +" :type iNormal: :class:`mathutils.Vector`, list or tuple of 3 real numbers\n"; + +static PyObject * FEdgeSmooth_setNormal( BPy_FEdgeSmooth *self, PyObject *args ) { + PyObject *obj = 0; + + if(!( PyArg_ParseTuple(args, "O", &obj) )) + return NULL; + Vec3r *v = Vec3r_ptr_from_PyObject(obj); + if( !v ) { + PyErr_SetString(PyExc_TypeError, "argument 1 must be a 3D vector (either a list of 3 elements or Vector)"); + return NULL; + } + self->fes->setNormal( *v ); + delete v; + + Py_RETURN_NONE; +} + +static char FEdgeSmooth_setMaterialIndex___doc__[] = +".. method:: setMaterialIndex(i)\n" +"\n" +" Sets the index of the material of the face it is running accross.\n" +"\n" +" :arg i: The index of the material of the face it is running accross.\n" +" :type i: int\n"; + +static PyObject * FEdgeSmooth_setMaterialIndex( BPy_FEdgeSmooth *self, PyObject *args ) { + unsigned int i; + + if(!( PyArg_ParseTuple(args, "I", &i) )) + return NULL; + + self->fes->setFrsMaterialIndex( i ); + + Py_RETURN_NONE; +} + +/*----------------------FEdgeSmooth instance definitions ----------------------------*/ +static PyMethodDef BPy_FEdgeSmooth_methods[] = { + {"normal", ( PyCFunction ) FEdgeSmooth_normal, METH_NOARGS, FEdgeSmooth_normal___doc__}, + {"materialIndex", ( PyCFunction ) FEdgeSmooth_materialIndex, METH_NOARGS, FEdgeSmooth_materialIndex___doc__}, + {"material", ( PyCFunction ) FEdgeSmooth_material, METH_NOARGS, FEdgeSmooth_material___doc__}, + {"setNormal", ( PyCFunction ) FEdgeSmooth_setNormal, METH_VARARGS, FEdgeSmooth_setNormal___doc__}, + {"setMaterialIndex", ( PyCFunction ) FEdgeSmooth_setMaterialIndex, METH_VARARGS, FEdgeSmooth_setMaterialIndex___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_FEdgeSmooth type definition ------------------------------*/ + +PyTypeObject FEdgeSmooth_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "FEdgeSmooth", /* tp_name */ + sizeof(BPy_FEdgeSmooth), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + FEdgeSmooth___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_FEdgeSmooth_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &FEdge_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)FEdgeSmooth___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.h b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.h new file mode 100644 index 00000000000..d7b44bb1da7 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_FEDGESMOOTH_H +#define FREESTYLE_PYTHON_FEDGESMOOTH_H + +#include "../BPy_FEdge.h" +#include "../../../view_map/Silhouette.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject FEdgeSmooth_Type; + +#define BPy_FEdgeSmooth_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &FEdgeSmooth_Type) ) + +/*---------------------------Python BPy_FEdgeSmooth structure definition----------*/ +typedef struct { + BPy_FEdge py_fe; + FEdgeSmooth *fes; +} BPy_FEdgeSmooth; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_FEDGESMOOTH_H */ diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp new file mode 100644 index 00000000000..1f4b041cce8 --- /dev/null +++ b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp @@ -0,0 +1,167 @@ +#include "BPy_AdjacencyIterator.h" + +#include "../BPy_Convert.h" +#include "../Interface0D/BPy_ViewVertex.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char AdjacencyIterator___doc__[] = +"Class hierarchy: :class:`Iterator` > :class:`AdjacencyIterator`\n" +"\n" +"Class for representing adjacency iterators used in the chaining\n" +"process. An AdjacencyIterator is created in the increment() and\n" +"decrement() methods of a :class:`ChainingIterator` and passed to the\n" +"traverse() method of the ChainingIterator.\n" +"\n" +".. method:: __init__(iVertex, iRestrictToSelection=True, iRestrictToUnvisited=True)\n" +"\n" +" Builds a AdjacencyIterator object.\n" +"\n" +" :arg iVertex: The vertex which is the next crossing.\n" +" :type iVertex: :class:`ViewVertex`\n" +" :arg iRestrictToSelection: Indicates whether to force the chaining\n" +" to stay within the set of selected ViewEdges or not.\n" +" :type iRestrictToSelection: bool\n" +" :arg iRestrictToUnvisited: Indicates whether a ViewEdge that has\n" +" already been chained must be ignored ot not.\n" +" :type iRestrictToUnvisited: bool\n" +"\n" +".. method:: __init__(it)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg it: An AdjacencyIterator object.\n" +" :type it: :class:`AdjacencyIterator`\n"; + +static int AdjacencyIterator___init__(BPy_AdjacencyIterator *self, PyObject *args ) +{ + PyObject *obj1 = 0, *obj2 = 0 , *obj3 = 0; + + if (! PyArg_ParseTuple(args, "|OOO", &obj1, &obj2, &obj3) ) + return -1; + + if( !obj1 && !obj2 && !obj3 ){ + self->a_it = new AdjacencyIterator(); + + } else if( BPy_AdjacencyIterator_Check(obj1) ) { + self->a_it = new AdjacencyIterator(*( ((BPy_AdjacencyIterator *) obj1)->a_it )); + + } else if( BPy_ViewVertex_Check(obj1) ) { + bool restrictToSelection = ( obj2 ) ? bool_from_PyBool(obj2) : true; + bool restrictToUnvisited = ( obj3 ) ? bool_from_PyBool(obj3) : true; + + self->a_it = new AdjacencyIterator( ((BPy_ViewVertex *) obj1)->vv, restrictToSelection, restrictToUnvisited ); + + } else { + PyErr_SetString(PyExc_TypeError, "invalid argument(s)"); + return -1; + } + + self->py_it.it = self->a_it; + + return 0; + +} + +static PyObject * AdjacencyIterator_iternext(BPy_AdjacencyIterator *self) { + if (self->a_it->isEnd()) { + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + ViewEdge *ve = self->a_it->operator*(); + self->a_it->increment(); + return BPy_ViewEdge_from_ViewEdge( *ve ); +} + +static char AdjacencyIterator_isIncoming___doc__[] = +".. method:: isIncoming()\n" +"\n" +" Returns true if the current ViewEdge is coming towards the\n" +" iteration vertex. False otherwise.\n" +"\n" +" :return: True if the current ViewEdge is coming towards the\n" +" iteration vertex\n" +" :rtype: bool\n"; + +static PyObject * AdjacencyIterator_isIncoming(BPy_AdjacencyIterator *self) { + return PyBool_from_bool(self->a_it->isIncoming()); +} + +static char AdjacencyIterator_getObject___doc__[] = +".. method:: getObject()\n" +"\n" +" Returns the pointed ViewEdge.\n" +"\n" +" :return: The pointed ViewEdge.\n" +" :rtype: :class:`ViewEdge`\n"; + +static PyObject * AdjacencyIterator_getObject(BPy_AdjacencyIterator *self) { + + ViewEdge *ve = self->a_it->operator*(); + if( ve ) + return BPy_ViewEdge_from_ViewEdge( *ve ); + + Py_RETURN_NONE; +} + +/*----------------------AdjacencyIterator instance definitions ----------------------------*/ +static PyMethodDef BPy_AdjacencyIterator_methods[] = { + {"isIncoming", ( PyCFunction ) AdjacencyIterator_isIncoming, METH_NOARGS, AdjacencyIterator_isIncoming___doc__}, + {"getObject", ( PyCFunction ) AdjacencyIterator_getObject, METH_NOARGS, AdjacencyIterator_getObject___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_AdjacencyIterator type definition ------------------------------*/ + +PyTypeObject AdjacencyIterator_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "AdjacencyIterator", /* tp_name */ + sizeof(BPy_AdjacencyIterator), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + AdjacencyIterator___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + PyObject_SelfIter, /* tp_iter */ + (iternextfunc)AdjacencyIterator_iternext, /* tp_iternext */ + BPy_AdjacencyIterator_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &Iterator_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)AdjacencyIterator___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.h new file mode 100644 index 00000000000..733a9f2fcab --- /dev/null +++ b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.h @@ -0,0 +1,32 @@ +#ifndef FREESTYLE_PYTHON_ADJACENCYITERATOR_H +#define FREESTYLE_PYTHON_ADJACENCYITERATOR_H + +#include "../../stroke/ChainingIterators.h" +#include "../BPy_Iterator.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject AdjacencyIterator_Type; + +#define BPy_AdjacencyIterator_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &AdjacencyIterator_Type) ) + +/*---------------------------Python BPy_AdjacencyIterator structure definition----------*/ +typedef struct { + BPy_Iterator py_it; + AdjacencyIterator *a_it; +} BPy_AdjacencyIterator; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_ADJACENCYITERATOR_H */ diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp new file mode 100644 index 00000000000..aa6d10ddb5f --- /dev/null +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp @@ -0,0 +1,205 @@ +#include "BPy_ChainPredicateIterator.h" + +#include "../BPy_Convert.h" +#include "../BPy_BinaryPredicate1D.h" +#include "../Interface1D/BPy_ViewEdge.h" +#include "../BPy_UnaryPredicate1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ChainPredicateIterator___doc__[] = +"Class hierarchy: :class:`Iterator` > :class:`ViewEdgeIterator` > :class:`ChainingIterator` > :class:`ChainPredicateIterator`\n" +"\n" +"A \"generic\" user-controlled ViewEdge iterator. This iterator is in\n" +"particular built from a unary predicate and a binary predicate.\n" +"First, the unary predicate is evaluated for all potential next\n" +"ViewEdges in order to only keep the ones respecting a certain\n" +"constraint. Then, the binary predicate is evaluated on the current\n" +"ViewEdge together with each ViewEdge of the previous selection. The\n" +"first ViewEdge respecting both the unary predicate and the binary\n" +"predicate is kept as the next one. If none of the potential next\n" +"ViewEdge respects these two predicates, None is returned.\n" +"\n" +".. method:: __init__(iRestrictToSelection=True, iRestrictToUnvisited=True, begin=None, orientation=True)\n" +"\n" +" Builds a ChainPredicateIterator from a starting ViewEdge and its\n" +" orientation.\n" +"\n" +" :arg iRestrictToSelection: Indicates whether to force the chaining\n" +" to stay within the set of selected ViewEdges or not.\n" +" :type iRestrictToSelection: bool\n" +" :arg iRestrictToUnvisited: Indicates whether a ViewEdge that has\n" +" already been chained must be ignored ot not.\n" +" :type iRestrictToUnvisited: bool\n" +" :arg begin: The ViewEdge from where to start the iteration.\n" +" :type begin: :class:`ViewEdge` or None\n" +" :arg orientation: If true, we'll look for the next ViewEdge among\n" +" the ViewEdges that surround the ending ViewVertex of begin. If\n" +" false, we'll search over the ViewEdges surrounding the ending\n" +" ViewVertex of begin. \n" +" :type orientation: bool\n" +"\n" +".. method:: __init__(upred, bpred, iRestrictToSelection=True, iRestrictToUnvisited=True, begin=None, orientation=True)\n" +"\n" +" Builds a ChainPredicateIterator from a unary predicate, a binary\n" +" predicate, a starting ViewEdge and its orientation.\n" +"\n" +" :arg upred: The unary predicate that the next ViewEdge must satisfy.\n" +" :type upred: :class:`UnaryPredicate1D`\n" +" :arg bpred: The binary predicate that the next ViewEdge must\n" +" satisfy together with the actual pointed ViewEdge.\n" +" :type bpred: :class:`BinaryPredicate1D`\n" +" :arg iRestrictToSelection: Indicates whether to force the chaining\n" +" to stay within the set of selected ViewEdges or not.\n" +" :type iRestrictToSelection: bool\n" +" :arg iRestrictToUnvisited: Indicates whether a ViewEdge that has\n" +" already been chained must be ignored ot not.\n" +" :type iRestrictToUnvisited: bool\n" +" :arg begin: The ViewEdge from where to start the iteration.\n" +" :type begin: :class:`ViewEdge` or None\n" +" :arg orientation: If true, we'll look for the next ViewEdge among\n" +" the ViewEdges that surround the ending ViewVertex of begin. If\n" +" false, we'll search over the ViewEdges surrounding the ending\n" +" ViewVertex of begin.\n" +" :type orientation: bool\n" +"\n" +".. method:: __init__(brother)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg brother: A ChainPredicateIterator object.\n" +" :type brother: :class:`ChainPredicateIterator`\n"; + +static int ChainPredicateIterator___init__(BPy_ChainPredicateIterator *self, PyObject *args ) +{ + PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0, *obj4 = 0, *obj5 = 0, *obj6 = 0; + + if (!( PyArg_ParseTuple(args, "|OOOOOO", &obj1, &obj2, &obj3, &obj4, &obj5, &obj6) )) + return -1; + + if( obj1 && BPy_ChainPredicateIterator_Check(obj1) ) { + self->cp_it = new ChainPredicateIterator(*( ((BPy_ChainPredicateIterator *) obj1)->cp_it )); + self->upred = NULL; + self->bpred = NULL; + + } else if( obj1 && BPy_UnaryPredicate1D_Check(obj1) && + obj2 && BPy_BinaryPredicate1D_Check(obj2) ) { + + if (!((BPy_UnaryPredicate1D *) obj1)->up1D) { + PyErr_SetString(PyExc_TypeError, "1st argument: invalid UnaryPredicate1D object"); + return -1; + } + if (!((BPy_BinaryPredicate1D *) obj2)->bp1D) { + PyErr_SetString(PyExc_TypeError, "2nd argument: invalid BinaryPredicate1D object"); + return -1; + } + UnaryPredicate1D *up1D = ((BPy_UnaryPredicate1D *) obj1)->up1D; + BinaryPredicate1D *bp1D = ((BPy_BinaryPredicate1D *) obj2)->bp1D; + bool restrictToSelection = ( obj3 ) ? bool_from_PyBool(obj3) : true; + bool restrictToUnvisited = ( obj4 ) ? bool_from_PyBool(obj4) : true; + ViewEdge *begin; + if ( !obj5 || obj5 == Py_None ) + begin = NULL; + else if ( BPy_ViewEdge_Check(obj5) ) + begin = ((BPy_ViewEdge *) obj5)->ve; + else { + PyErr_SetString(PyExc_TypeError, "5th argument must be either a ViewEdge object or None"); + return -1; + } + bool orientation = ( obj6 ) ? bool_from_PyBool(obj6) : true; + + self->cp_it = new ChainPredicateIterator( *up1D, *bp1D, restrictToSelection, restrictToUnvisited, begin, orientation); + self->upred = obj1; + self->bpred = obj2; + Py_INCREF( self->upred ); + Py_INCREF( self->bpred ); + + } else { + bool restrictToSelection = ( obj1 ) ? bool_from_PyBool(obj1) : true; + bool restrictToUnvisited = ( obj2 ) ? bool_from_PyBool(obj2) : true; + ViewEdge *begin; + if ( !obj3 || obj3 == Py_None ) + begin = NULL; + else if ( BPy_ViewEdge_Check(obj3) ) + begin = ((BPy_ViewEdge *) obj3)->ve; + else { + PyErr_SetString(PyExc_TypeError, "3rd argument must be either a ViewEdge object or None"); + return -1; + } + bool orientation = ( obj4 ) ? bool_from_PyBool(obj4) : true; + + self->cp_it = new ChainPredicateIterator( restrictToSelection, restrictToUnvisited, begin, orientation); + self->upred = NULL; + self->bpred = NULL; + } + + self->py_c_it.c_it = self->cp_it; + self->py_c_it.py_ve_it.ve_it = self->cp_it; + self->py_c_it.py_ve_it.py_it.it = self->cp_it; + + + return 0; + +} + +static void ChainPredicateIterator___dealloc__(BPy_ChainPredicateIterator *self) +{ + Py_XDECREF( self->upred ); + Py_XDECREF( self->bpred ); + ChainingIterator_Type.tp_dealloc((PyObject *)self); +} + +/*-----------------------BPy_ChainPredicateIterator type definition ------------------------------*/ + +PyTypeObject ChainPredicateIterator_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ChainPredicateIterator", /* tp_name */ + sizeof(BPy_ChainPredicateIterator), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)ChainPredicateIterator___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ChainPredicateIterator___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &ChainingIterator_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ChainPredicateIterator___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.h new file mode 100644 index 00000000000..5a31ac407d5 --- /dev/null +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.h @@ -0,0 +1,35 @@ +#ifndef FREESTYLE_PYTHON_CHAINPREDICATEITERATOR_H +#define FREESTYLE_PYTHON_CHAINPREDICATEITERATOR_H + + +#include "../../stroke/ChainingIterators.h" + +#include "BPy_ChainingIterator.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ChainPredicateIterator_Type; + +#define BPy_ChainPredicateIterator_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ChainPredicateIterator_Type) ) + +/*---------------------------Python BPy_ChainPredicateIterator structure definition----------*/ +typedef struct { + BPy_ChainingIterator py_c_it; + ChainPredicateIterator *cp_it; + PyObject *upred; + PyObject *bpred; +} BPy_ChainPredicateIterator; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_CHAINPREDICATEITERATOR_H */ diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp new file mode 100644 index 00000000000..caf43a800c5 --- /dev/null +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp @@ -0,0 +1,131 @@ +#include "BPy_ChainSilhouetteIterator.h" + +#include "../BPy_Convert.h" +#include "../Interface1D/BPy_ViewEdge.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +// ChainSilhouetteIterator (bool iRestrictToSelection=true, ViewEdge *begin=NULL, bool orientation=true) +// ChainSilhouetteIterator (const ChainSilhouetteIterator &brother) + +static char ChainSilhouetteIterator___doc__[] = +"Class hierarchy: :class:`Iterator` > :class:`ViewEdgeIterator` > :class:`ChainingIterator` > :class:`ChainSilhouetteIterator`\n" +"\n" +"A ViewEdge Iterator used to follow ViewEdges the most naturally. For\n" +"example, it will follow visible ViewEdges of same nature. As soon, as\n" +"the nature or the visibility changes, the iteration stops (by setting\n" +"the pointed ViewEdge to 0). In the case of an iteration over a set of\n" +"ViewEdge that are both Silhouette and Crease, there will be a\n" +"precedence of the silhouette over the crease criterion.\n" +"\n" +".. method:: __init__(iRestrictToSelection=True, begin=None, orientation=True)\n" +"\n" +" Builds a ChainSilhouetteIterator from the first ViewEdge used for\n" +" iteration and its orientation.\n" +"\n" +" :arg iRestrictToSelection: Indicates whether to force the chaining\n" +" to stay within the set of selected ViewEdges or not.\n" +" :type iRestrictToSelection: bool\n" +" :arg begin: The ViewEdge from where to start the iteration.\n" +" :type begin: :class:`ViewEdge` or None\n" +" :arg orientation: If true, we'll look for the next ViewEdge among\n" +" the ViewEdges that surround the ending ViewVertex of begin. If\n" +" false, we'll search over the ViewEdges surrounding the ending\n" +" ViewVertex of begin.\n" +" :type orientation: bool\n" +"\n" +".. method:: __init__(brother)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg brother: A ChainSilhouetteIterator object.\n" +" :type brother: :class:`ChainSilhouetteIterator`\n"; + +static int ChainSilhouetteIterator___init__(BPy_ChainSilhouetteIterator *self, PyObject *args ) +{ + PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0; + + if (!( PyArg_ParseTuple(args, "|OOO", &obj1, &obj2, &obj3) )) + return -1; + + if( obj1 && BPy_ChainSilhouetteIterator_Check(obj1) ) { + self->cs_it = new ChainSilhouetteIterator(*( ((BPy_ChainSilhouetteIterator *) obj1)->cs_it )); + + } else { + bool restrictToSelection = ( obj1 ) ? bool_from_PyBool(obj1) : true; + ViewEdge *begin; + if ( !obj2 || obj2 == Py_None ) + begin = NULL; + else if ( BPy_ViewEdge_Check(obj2) ) + begin = ((BPy_ViewEdge *) obj2)->ve; + else { + PyErr_SetString(PyExc_TypeError, "2nd argument must be either a ViewEdge object or None"); + return -1; + } + bool orientation = ( obj3 ) ? bool_from_PyBool(obj3) : true; + + self->cs_it = new ChainSilhouetteIterator( restrictToSelection, begin, orientation); + } + + self->py_c_it.c_it = self->cs_it; + self->py_c_it.py_ve_it.ve_it = self->cs_it; + self->py_c_it.py_ve_it.py_it.it = self->cs_it; + + return 0; + +} + +/*-----------------------BPy_ChainSilhouetteIterator type definition ------------------------------*/ + +PyTypeObject ChainSilhouetteIterator_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ChainSilhouetteIterator", /* tp_name */ + sizeof(BPy_ChainSilhouetteIterator), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ChainSilhouetteIterator___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &ChainingIterator_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ChainSilhouetteIterator___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.h new file mode 100644 index 00000000000..912d397d279 --- /dev/null +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.h @@ -0,0 +1,33 @@ +#ifndef FREESTYLE_PYTHON_CHAINSILHOUETTEITERATOR_H +#define FREESTYLE_PYTHON_CHAINSILHOUETTEITERATOR_H + + +#include "../../stroke/ChainingIterators.h" + +#include "BPy_ChainingIterator.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ChainSilhouetteIterator_Type; + +#define BPy_ChainSilhouetteIterator_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ChainSilhouetteIterator_Type) ) + +/*---------------------------Python BPy_ChainSilhouetteIterator structure definition----------*/ +typedef struct { + BPy_ChainingIterator py_c_it; + ChainSilhouetteIterator *cs_it; +} BPy_ChainSilhouetteIterator; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_CHAINSILHOUETTEITERATOR_H */ diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp new file mode 100644 index 00000000000..ddb957c900e --- /dev/null +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp @@ -0,0 +1,236 @@ +#include "BPy_ChainingIterator.h" + +#include "../BPy_Convert.h" +#include "../Interface0D/BPy_ViewVertex.h" +#include "../Interface1D/BPy_ViewEdge.h" +#include "BPy_AdjacencyIterator.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ChainingIterator___doc__[] = +"Class hierarchy: :class:`Iterator` > :class:`ViewEdgeIterator` > :class:`ChainingIterator`\n" +"\n" +"Base class for chaining iterators. This class is designed to be\n" +"overloaded in order to describe chaining rules. It makes the\n" +"description of chaining rules easier. The two main methods that need\n" +"to overloaded are traverse() and init(). traverse() tells which\n" +":class:`ViewEdge` to follow, among the adjacent ones. If you specify\n" +"restriction rules (such as \"Chain only ViewEdges of the selection\"),\n" +"they will be included in the adjacency iterator (i.e, the adjacent\n" +"iterator will only stop on \"valid\" edges).\n" +"\n" +".. method:: __init__(iRestrictToSelection=True, iRestrictToUnvisited=True, begin=None, orientation=True)\n" +"\n" +" Builds a Chaining Iterator from the first ViewEdge used for\n" +" iteration and its orientation.\n" +"\n" +" :arg iRestrictToSelection: Indicates whether to force the chaining\n" +" to stay within the set of selected ViewEdges or not.\n" +" :type iRestrictToSelection: bool\n" +" :arg iRestrictToUnvisited: Indicates whether a ViewEdge that has\n" +" already been chained must be ignored ot not.\n" +" :type iRestrictToUnvisited: bool\n" +" :arg begin: The ViewEdge from which to start the chain.\n" +" :type begin: :class:`ViewEdge` or None\n" +" :arg orientation: The direction to follow to explore the graph. If\n" +" true, the direction indicated by the first ViewEdge is used.\n" +" :type orientation: bool\n" +"\n" +".. method:: __init__(brother)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg brother: \n" +" :type brother: ChainingIterator\n"; + +static int ChainingIterator___init__(BPy_ChainingIterator *self, PyObject *args ) +{ + PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0, *obj4 = 0; + + if (!( PyArg_ParseTuple(args, "|OOOO", &obj1, &obj2, &obj3, &obj4) )) + return -1; + + if( obj1 && BPy_ChainingIterator_Check(obj1) ) { + self->c_it = new ChainingIterator(*( ((BPy_ChainingIterator *) obj1)->c_it )); + + } else { + bool restrictToSelection = ( obj1 ) ? bool_from_PyBool(obj1) : true; + bool restrictToUnvisited = ( obj2 ) ? bool_from_PyBool(obj2) : true; + ViewEdge *begin; + if ( !obj3 || obj3 == Py_None ) + begin = NULL; + else if ( BPy_ViewEdge_Check(obj3) ) + begin = ((BPy_ViewEdge *) obj3)->ve; + else { + PyErr_SetString(PyExc_TypeError, "3rd argument must be either a ViewEdge object or None"); + return -1; + } + bool orientation = ( obj4 ) ? bool_from_PyBool(obj4) : true; + + self->c_it = new ChainingIterator( restrictToSelection, restrictToUnvisited, begin, orientation); + } + + self->py_ve_it.ve_it = self->c_it; + self->py_ve_it.py_it.it = self->c_it; + + self->c_it->py_c_it = (PyObject *) self; + + return 0; +} + +static char ChainingIterator_init___doc__[] = +".. method:: init()\n" +"\n" +" Initializes the iterator context. This method is called each\n" +" time a new chain is started. It can be used to reset some\n" +" history information that you might want to keep.\n"; + +static PyObject *ChainingIterator_init( BPy_ChainingIterator *self ) { + if( typeid(*(self->c_it)) == typeid(ChainingIterator) ) { + PyErr_SetString(PyExc_TypeError, "init() method not properly overridden"); + return NULL; + } + self->c_it->init(); + + Py_RETURN_NONE; +} + +static char ChainingIterator_traverse___doc__[] = +".. method:: traverse(it)\n" +"\n" +" This method iterates over the potential next ViewEdges and returns\n" +" the one that will be followed next. Returns the next ViewEdge to\n" +" follow or None when the end of the chain is reached.\n" +"\n" +" :arg it: The iterator over the ViewEdges adjacent to the end vertex\n" +" of the current ViewEdge. The adjacency iterator reflects the\n" +" restriction rules by only iterating over the valid ViewEdges.\n" +" :type it: :class:`AdjacencyIterator`\n" +" :return: Returns the next ViewEdge to follow, or None if chaining ends.\n" +" :rtype: :class:`ViewEdge` or None\n"; + +static PyObject *ChainingIterator_traverse( BPy_ChainingIterator *self, PyObject *args ) { + PyObject *py_a_it; + + if(!( PyArg_ParseTuple(args, "O!", &AdjacencyIterator_Type, &py_a_it) )) + return NULL; + + if( typeid(*(self->c_it)) == typeid(ChainingIterator) ) { + PyErr_SetString(PyExc_TypeError, "traverse() method not properly overridden"); + return NULL; + } + if( ((BPy_AdjacencyIterator *) py_a_it)->a_it ) + self->c_it->traverse(*( ((BPy_AdjacencyIterator *) py_a_it)->a_it )); + + Py_RETURN_NONE; +} + +static char ChainingIterator_getVertex___doc__[] = +".. method:: getVertex()\n" +"\n" +" Returns the vertex which is the next crossing.\n" +"\n" +" :return: The vertex which is the next crossing.\n" +" :rtype: :class:`ViewVertex`\n"; + +static PyObject *ChainingIterator_getVertex( BPy_ChainingIterator *self ) { + ViewVertex *v = self->c_it->getVertex(); + if( v ) + return Any_BPy_ViewVertex_from_ViewVertex( *v ); + + Py_RETURN_NONE; +} + +static char ChainingIterator_isIncrementing___doc__[] = +".. method:: isIncrementing()\n" +"\n" +" Returns true if the current iteration is an incrementation.\n" +"\n" +" :return: True if the current iteration is an incrementation.\n" +" :rtype: bool\n"; + +static PyObject *ChainingIterator_isIncrementing( BPy_ChainingIterator *self ) { + return PyBool_from_bool( self->c_it->isIncrementing() ); +} + +static char ChainingIterator_getObject___doc__[] = +".. method:: getObject()\n" +"\n" +" Returns the pointed ViewEdge.\n" +"\n" +" :return: The pointed ViewEdge.\n" +" :rtype: :class:`ViewEdge`\n"; + +static PyObject * ChainingIterator_getObject( BPy_ChainingIterator *self) { + + ViewEdge *ve = self->c_it->operator*(); + if( ve ) + return BPy_ViewEdge_from_ViewEdge( *ve ); + + Py_RETURN_NONE; +} + +/*----------------------ChainingIterator instance definitions ----------------------------*/ +static PyMethodDef BPy_ChainingIterator_methods[] = { + {"init", ( PyCFunction ) ChainingIterator_init, METH_NOARGS, ChainingIterator_init___doc__}, + {"traverse", ( PyCFunction ) ChainingIterator_traverse, METH_VARARGS, ChainingIterator_traverse___doc__}, + {"getVertex", ( PyCFunction ) ChainingIterator_getVertex, METH_NOARGS, ChainingIterator_getVertex___doc__}, + {"isIncrementing", ( PyCFunction ) ChainingIterator_isIncrementing, METH_NOARGS, ChainingIterator_isIncrementing___doc__}, + {"getObject", ( PyCFunction ) ChainingIterator_getObject, METH_NOARGS, ChainingIterator_getObject___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_ChainingIterator type definition ------------------------------*/ + +PyTypeObject ChainingIterator_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ChainingIterator", /* tp_name */ + sizeof(BPy_ChainingIterator), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ChainingIterator___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_ChainingIterator_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &ViewEdgeIterator_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ChainingIterator___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.h new file mode 100644 index 00000000000..2a00aa8072f --- /dev/null +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.h @@ -0,0 +1,33 @@ +#ifndef FREESTYLE_PYTHON_CHAININGITERATOR_H +#define FREESTYLE_PYTHON_CHAININGITERATOR_H + + +#include "../../stroke/ChainingIterators.h" + +#include "BPy_ViewEdgeIterator.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ChainingIterator_Type; + +#define BPy_ChainingIterator_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ChainingIterator_Type) ) + +/*---------------------------Python BPy_ChainingIterator structure definition----------*/ +typedef struct { + BPy_ViewEdgeIterator py_ve_it; + ChainingIterator *c_it; +} BPy_ChainingIterator; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_CHAININGITERATOR_H */ diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp new file mode 100644 index 00000000000..d1a8fbef6b9 --- /dev/null +++ b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp @@ -0,0 +1,171 @@ +#include "BPy_CurvePointIterator.h" + +#include "../BPy_Convert.h" +#include "BPy_Interface0DIterator.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char CurvePointIterator___doc__[] = +"Class hierarchy: :class:`Iterator` > :class:`CurvePointIterator`\n" +"\n" +"Class representing an iterator on a curve. Allows an iterating\n" +"outside initial vertices. A CurvePoint is instanciated and returned\n" +"by getObject().\n" +"\n" +".. method:: __init__(step=0.0)\n" +"\n" +" Builds a CurvePointIterator object.\n" +"\n" +" :arg step: A resampling resolution with which the curve is resampled.\n" +" If zero, no resampling is done (i.e., the iterator iterates over\n" +" initial vertices).\n" +" :type step: float\n" +"\n" +".. method:: __init__(brother)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg brother: A CurvePointIterator object.\n" +" :type brother: :class:`CurvePointIterator`\n"; + +static int CurvePointIterator___init__(BPy_CurvePointIterator *self, PyObject *args ) +{ + PyObject *obj = 0; + + if (! PyArg_ParseTuple(args, "|O", &obj) ) + return -1; + + if( !obj ){ + self->cp_it = new CurveInternal::CurvePointIterator(); + + } else if( BPy_CurvePointIterator_Check(obj) ) { + self->cp_it = new CurveInternal::CurvePointIterator(*( ((BPy_CurvePointIterator *) obj)->cp_it )); + + } else if( PyFloat_Check(obj) ) { + self->cp_it = new CurveInternal::CurvePointIterator( PyFloat_AsDouble(obj) ); + + } else { + PyErr_SetString(PyExc_TypeError, "invalid argument"); + return -1; + } + + self->py_it.it = self->cp_it; + + return 0; +} + +static char CurvePointIterator_t___doc__[] = +".. method:: t()\n" +"\n" +" Returns the curvilinear abscissa.\n" +"\n" +" :return: The curvilinear abscissa.\n" +" :rtype: float\n"; + +PyObject * CurvePointIterator_t( BPy_CurvePointIterator *self ) { + return PyFloat_FromDouble( self->cp_it->t() ); +} + +static char CurvePointIterator_u___doc__[] = +".. method:: u()\n" +"\n" +" Returns the point parameter in the curve (0<=u<=1).\n" +"\n" +" :return: The point parameter.\n" +" :rtype: float\n"; + +static PyObject * CurvePointIterator_u( BPy_CurvePointIterator *self ) { + return PyFloat_FromDouble( self->cp_it->u() ); +} + +static char CurvePointIterator_castToInterface0DIterator___doc__[] = +".. method:: castToInterface0DIterator()\n" +"\n" +" Returns an Interface0DIterator converted from this\n" +" CurvePointIterator. Useful for any call to a function of the\n" +" UnaryFunction0D type.\n" +"\n" +" :return: An Interface0DIterator object converted from the\n" +" iterator.\n" +" :rtype: :class:`Interface0DIterator`\n"; + +static PyObject * CurvePointIterator_castToInterface0DIterator( BPy_CurvePointIterator *self ) { + Interface0DIterator it( self->cp_it->castToInterface0DIterator() ); + return BPy_Interface0DIterator_from_Interface0DIterator( it, 0 ); +} + +static char CurvePointIterator_getObject___doc__[] = +".. method:: getObject()\n" +"\n" +" Returns a CurvePoint pointed by the iterator.\n" +"\n" +" :return: \n" +" :rtype: :class:`CurvePoint`\n"; + +static PyObject * CurvePointIterator_getObject(BPy_CurvePointIterator *self) { + return BPy_CurvePoint_from_CurvePoint( self->cp_it->operator*() ); +} + +/*----------------------CurvePointIterator instance definitions ----------------------------*/ +static PyMethodDef BPy_CurvePointIterator_methods[] = { + {"t", ( PyCFunction ) CurvePointIterator_t, METH_NOARGS, CurvePointIterator_t___doc__}, + {"u", ( PyCFunction ) CurvePointIterator_u, METH_NOARGS, CurvePointIterator_u___doc__}, + {"castToInterface0DIterator", ( PyCFunction ) CurvePointIterator_castToInterface0DIterator, METH_NOARGS, CurvePointIterator_castToInterface0DIterator___doc__}, + {"getObject", ( PyCFunction ) CurvePointIterator_getObject, METH_NOARGS, CurvePointIterator_getObject___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_CurvePointIterator type definition ------------------------------*/ + +PyTypeObject CurvePointIterator_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "CurvePointIterator", /* tp_name */ + sizeof(BPy_CurvePointIterator), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + CurvePointIterator___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_CurvePointIterator_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &Iterator_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)CurvePointIterator___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.h new file mode 100644 index 00000000000..ad04c7208bb --- /dev/null +++ b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.h @@ -0,0 +1,32 @@ +#ifndef FREESTYLE_PYTHON_CURVEPOINTITERATOR_H +#define FREESTYLE_PYTHON_CURVEPOINTITERATOR_H + +#include "../../stroke/CurveIterators.h" + +#include "../BPy_Iterator.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject CurvePointIterator_Type; + +#define BPy_CurvePointIterator_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &CurvePointIterator_Type) ) + +/*---------------------------Python BPy_CurvePointIterator structure definition----------*/ +typedef struct { + BPy_Iterator py_it; + CurveInternal::CurvePointIterator *cp_it; +} BPy_CurvePointIterator; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_CURVEPOINTITERATOR_H */ diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp new file mode 100644 index 00000000000..6643913c32a --- /dev/null +++ b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp @@ -0,0 +1,151 @@ +#include "BPy_Interface0DIterator.h" + +#include "../BPy_Convert.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char Interface0DIterator___doc__[] = +"Class hierarchy: :class:`Iterator` > :class:`Interface0DIterator`\n" +"\n" +"Class defining an iterator over Interface0D elements. An instance of\n" +"this iterator is always obtained from a 1D element.\n" +"\n" +".. method:: __init__(it)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n"; + +static int Interface0DIterator___init__(BPy_Interface0DIterator *self, PyObject *args ) +{ + PyObject *obj = 0; + + if (!( PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj) )) + return -1; + + self->if0D_it = new Interface0DIterator(*( ((BPy_Interface0DIterator *) obj)->if0D_it )); + self->py_it.it = self->if0D_it; + self->reversed = 0; + + return 0; +} + +static PyObject * Interface0DIterator_iternext( BPy_Interface0DIterator *self ) { + Interface0D *if0D; + if (self->reversed) { + if (self->if0D_it->isBegin()) { + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + self->if0D_it->decrement(); + if0D = self->if0D_it->operator->(); + } else { + if (self->if0D_it->isEnd()) { + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + if0D = self->if0D_it->operator->(); + self->if0D_it->increment(); + } + return Any_BPy_Interface0D_from_Interface0D( *if0D ); +} + +static char Interface0DIterator_t___doc__[] = +".. method:: t()\n" +"\n" +" Returns the curvilinear abscissa.\n" +"\n" +" :return: The curvilinear abscissa.\n" +" :rtype: float\n"; + +static PyObject * Interface0DIterator_t( BPy_Interface0DIterator *self ) { + return PyFloat_FromDouble( self->if0D_it->t() ); +} + +static char Interface0DIterator_u___doc__[] = +".. method:: u()\n" +"\n" +" Returns the point parameter in the curve 0<=u<=1.\n" +"\n" +" :return: The point parameter.\n" +" :rtype: float\n"; + +static PyObject * Interface0DIterator_u( BPy_Interface0DIterator *self ) { + return PyFloat_FromDouble( self->if0D_it->u() ); +} + +static char Interface0DIterator_getObject___doc__[] = +".. method:: getObject()\n" +"\n" +" Returns the pointed Interface0D.\n" +"\n" +" :return: The pointed Interface0D.\n" +" :rtype: :class:`Interface0D`\n"; + +static PyObject * Interface0DIterator_getObject(BPy_Interface0DIterator *self) { + return Any_BPy_Interface0D_from_Interface0D( self->if0D_it->operator*() ); +} + +/*----------------------Interface0DIterator instance definitions ----------------------------*/ +static PyMethodDef BPy_Interface0DIterator_methods[] = { + {"t", ( PyCFunction ) Interface0DIterator_t, METH_NOARGS, Interface0DIterator_t___doc__}, + {"u", ( PyCFunction ) Interface0DIterator_u, METH_NOARGS, Interface0DIterator_u___doc__}, + {"getObject", ( PyCFunction ) Interface0DIterator_getObject, METH_NOARGS, Interface0DIterator_getObject___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_Interface0DIterator type definition ------------------------------*/ + +PyTypeObject Interface0DIterator_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "Interface0DIterator", /* tp_name */ + sizeof(BPy_Interface0DIterator), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + Interface0DIterator___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + PyObject_SelfIter, /* tp_iter */ + (iternextfunc)Interface0DIterator_iternext, /* tp_iternext */ + BPy_Interface0DIterator_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &Iterator_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Interface0DIterator___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.h new file mode 100644 index 00000000000..1972763b2eb --- /dev/null +++ b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.h @@ -0,0 +1,33 @@ +#ifndef FREESTYLE_PYTHON_INTERFACE0DITERATOR_H +#define FREESTYLE_PYTHON_INTERFACE0DITERATOR_H + +#include "../../view_map/Interface0D.h" +#include "../BPy_Iterator.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject Interface0DIterator_Type; + +#define BPy_Interface0DIterator_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &Interface0DIterator_Type) ) + +/*---------------------------Python BPy_Interface0DIterator structure definition----------*/ +typedef struct { + BPy_Iterator py_it; + Interface0DIterator *if0D_it; + int reversed; +} BPy_Interface0DIterator; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_INTERFACE0DITERATOR_H */ diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp new file mode 100644 index 00000000000..ef40d994e27 --- /dev/null +++ b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp @@ -0,0 +1,181 @@ +#include "BPy_SVertexIterator.h" + +#include "../BPy_Convert.h" +#include "../Interface0D/BPy_SVertex.h" +#include "../Interface1D/BPy_FEdge.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char SVertexIterator___doc__[] = +"Class hierarchy: :class:`Iterator` > :class:`SVertexIterator`\n" +"\n" +"Class representing an iterator over :class:`SVertex` of a\n" +":class:`ViewEdge`. An instance of an SVertexIterator can be obtained\n" +"from a ViewEdge by calling verticesBegin() or verticesEnd().\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(it)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg it: An SVertexIterator object.\n" +" :type it: :class:`SVertexIterator`\n" +"\n" +".. method:: __init__(v, begin, prev, next, t)\n" +"\n" +" Builds an SVertexIterator that starts iteration from an SVertex\n" +" object v.\n" +"\n" +" :arg v: The SVertex from which the iterator starts iteration.\n" +" :type v: :class:`SVertex`\n" +" :arg begin: The first vertex of a view edge.\n" +" :type begin: :class:`SVertex`\n" +" :arg prev: The previous FEdge coming to v.\n" +" :type prev: :class:`FEdge`\n" +" :arg next: The next FEdge going out from v.\n" +" :type next: :class:`FEdge`\n" +" :arg t: The curvilinear abscissa at v.\n" +" :type t: float\n"; + +static int SVertexIterator___init__(BPy_SVertexIterator *self, PyObject *args ) +{ + PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0, *obj4 = 0; + float f = 0; + + if (! PyArg_ParseTuple(args, "|OOOOf", &obj1, &obj2, &obj3, &obj4, f) ) + return -1; + + if( !obj1 ){ + self->sv_it = new ViewEdgeInternal::SVertexIterator(); + + } else if( BPy_SVertexIterator_Check(obj1) ) { + self->sv_it = new ViewEdgeInternal::SVertexIterator(*( ((BPy_SVertexIterator *) obj1)->sv_it )); + + } else if( obj1 && BPy_SVertex_Check(obj1) && + obj2 && BPy_SVertex_Check(obj2) && + obj3 && BPy_FEdge_Check(obj3) && + obj4 && BPy_FEdge_Check(obj4) ) { + + self->sv_it = new ViewEdgeInternal::SVertexIterator( + ((BPy_SVertex *) obj1)->sv, + ((BPy_SVertex *) obj2)->sv, + ((BPy_FEdge *) obj3)->fe, + ((BPy_FEdge *) obj4)->fe, + f ); + + } else { + PyErr_SetString(PyExc_TypeError, "invalid argument(s)"); + return -1; + } + + self->py_it.it = self->sv_it; + + return 0; +} + +static char SVertexIterator_t___doc__[] = +".. method:: t()\n" +"\n" +" Returns the curvilinear abscissa.\n" +"\n" +" :return: The curvilinear abscissa.\n" +" :rtype: float\n"; + +static PyObject * SVertexIterator_t( BPy_SVertexIterator *self ) { + return PyFloat_FromDouble( self->sv_it->t() ); +} + +static char SVertexIterator_u___doc__[] = +".. method:: u()\n" +"\n" +" Returns the point parameter (0<=u<=1).\n" +"\n" +" :return: The point parameter.\n" +" :rtype: float\n"; + +static PyObject * SVertexIterator_u( BPy_SVertexIterator *self ) { + return PyFloat_FromDouble( self->sv_it->u() ); +} + +static char SVertexIterator_getObject___doc__[] = +".. method:: getObject()\n" +"\n" +" Returns the pointed SVertex.\n" +"\n" +" :return: the pointed SVertex.\n" +" :rtype: :class:`SVertex`\n"; + +static PyObject * SVertexIterator_getObject( BPy_SVertexIterator *self) { + SVertex *sv = self->sv_it->operator->(); + + if( sv ) + return BPy_SVertex_from_SVertex( *sv ); + + Py_RETURN_NONE; +} + +/*----------------------SVertexIterator instance definitions ----------------------------*/ +static PyMethodDef BPy_SVertexIterator_methods[] = { + {"t", ( PyCFunction ) SVertexIterator_t, METH_NOARGS, SVertexIterator_t___doc__}, + {"u", ( PyCFunction ) SVertexIterator_u, METH_NOARGS, SVertexIterator_u___doc__}, + {"getObject", ( PyCFunction ) SVertexIterator_getObject, METH_NOARGS, SVertexIterator_getObject___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_SVertexIterator type definition ------------------------------*/ + +PyTypeObject SVertexIterator_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "SVertexIterator", /* tp_name */ + sizeof(BPy_SVertexIterator), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + SVertexIterator___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_SVertexIterator_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &Iterator_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)SVertexIterator___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.h new file mode 100644 index 00000000000..b40f4d36420 --- /dev/null +++ b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.h @@ -0,0 +1,33 @@ +#ifndef FREESTYLE_PYTHON_SVERTEXITERATOR_H +#define FREESTYLE_PYTHON_SVERTEXITERATOR_H + +#include "../../view_map/ViewMapIterators.h" + +#include "../BPy_Iterator.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject SVertexIterator_Type; + +#define BPy_SVertexIterator_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &SVertexIterator_Type) ) + +/*---------------------------Python BPy_SVertexIterator structure definition----------*/ +typedef struct { + BPy_Iterator py_it; + ViewEdgeInternal::SVertexIterator *sv_it; +} BPy_SVertexIterator; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_SVERTEXITERATOR_H */ diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp new file mode 100644 index 00000000000..a9b2c4d774a --- /dev/null +++ b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp @@ -0,0 +1,197 @@ +#include "BPy_StrokeVertexIterator.h" + +#include "../BPy_Convert.h" +#include "BPy_Interface0DIterator.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char StrokeVertexIterator___doc__[] = +"Class hierarchy: :class:`Iterator` > :class:`StrokeVertexIterator`\n" +"\n" +"Class defining an iterator designed to iterate over the\n" +":class:`StrokeVertex` of a :class:`Stroke`. An instance of a\n" +"StrokeVertexIterator can only be obtained from a Stroke by calling\n" +"strokeVerticesBegin() or strokeVerticesEnd(). It is iterating over\n" +"the same vertices as an :class:`Interface0DIterator`. The difference\n" +"resides in the object access. Indeed, an Interface0DIterator allows\n" +"only an access to an Interface0D whereas we could need to access the\n" +"specialized StrokeVertex type. In this case, one should use a\n" +"StrokeVertexIterator. The castToInterface0DIterator() method is\n" +"useful to get an Interface0DIterator from a StrokeVertexIterator in\n" +"order to call any functions of the UnaryFunction0D type.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(it)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg it: A StrokeVertexIterator object.\n" +" :type it: :class:`StrokeVertexIterator`\n"; + +static int StrokeVertexIterator___init__(BPy_StrokeVertexIterator *self, PyObject *args ) +{ + PyObject *obj = 0; + + if (! PyArg_ParseTuple(args, "|O", &obj) ) + return -1; + + if( !obj ){ + self->sv_it = new StrokeInternal::StrokeVertexIterator(); + + } else if( BPy_StrokeVertexIterator_Check(obj) ) { + self->sv_it = new StrokeInternal::StrokeVertexIterator(*( ((BPy_StrokeVertexIterator *) obj)->sv_it )); + + } else { + PyErr_SetString(PyExc_TypeError, "invalid argument"); + return -1; + } + + self->py_it.it = self->sv_it; + self->reversed = 0; + + return 0; +} + +static PyObject * StrokeVertexIterator_iternext( BPy_StrokeVertexIterator *self ) { + StrokeVertex *sv; + if (self->reversed) { + if (self->sv_it->isBegin()) { + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + self->sv_it->decrement(); + sv = self->sv_it->operator->(); + } else { + if (self->sv_it->isEnd()) { + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + sv = self->sv_it->operator->(); + self->sv_it->increment(); + } + return BPy_StrokeVertex_from_StrokeVertex( *sv ); +} + +static char StrokeVertexIterator_t___doc__[] = +".. method:: t()\n" +"\n" +" Returns the curvilinear abscissa of the current point.\n" +"\n" +" :return: The curvilinear abscissa of the current point.\n" +" :rtype: float\n"; + +static PyObject * StrokeVertexIterator_t( BPy_StrokeVertexIterator *self ) { + return PyFloat_FromDouble( self->sv_it->t() ); +} + +static char StrokeVertexIterator_u___doc__[] = +".. method:: u()\n" +"\n" +" Returns the point parameter in the stroke (0<=u<=1).\n" +"\n" +" :return: The point parameter in the stroke\n" +" :rtype: float\n"; + +static PyObject * StrokeVertexIterator_u( BPy_StrokeVertexIterator *self ) { + return PyFloat_FromDouble( self->sv_it->u() ); +} + +static char StrokeVertexIterator_castToInterface0DIterator___doc__[] = +".. method:: castToInterface0DIterator()\n" +"\n" +" Returns an Interface0DIterator converted from this\n" +" StrokeVertexIterator. Useful for any call to a function of the\n" +" UnaryFunction0D type.\n" +"\n" +" :return: An Interface0DIterator converted from the StrokeVertexIterator.\n" +" :rtype: :class:`Interface0DIterator`\n"; + +static PyObject * StrokeVertexIterator_castToInterface0DIterator( BPy_StrokeVertexIterator *self ) { + Interface0DIterator it( self->sv_it->castToInterface0DIterator() ); + return BPy_Interface0DIterator_from_Interface0DIterator( it, 0 ); +} + +static char StrokeVertexIterator_getObject___doc__[] = +".. method:: getObject()\n" +"\n" +" Returns the pointed StrokeVertex.\n" +"\n" +" :return: The pointed StrokeVertex.\n" +" :rtype: :class:`StrokeVertex`\n"; + +static PyObject * StrokeVertexIterator_getObject( BPy_StrokeVertexIterator *self) { + if (!self->reversed && self->sv_it->isEnd()) + Py_RETURN_NONE; + StrokeVertex *sv = self->sv_it->operator->(); + if( sv ) + return BPy_StrokeVertex_from_StrokeVertex( *sv ); + + Py_RETURN_NONE; +} + +/*----------------------StrokeVertexIterator instance definitions ----------------------------*/ +static PyMethodDef BPy_StrokeVertexIterator_methods[] = { + {"t", ( PyCFunction ) StrokeVertexIterator_t, METH_NOARGS, StrokeVertexIterator_t___doc__}, + {"u", ( PyCFunction ) StrokeVertexIterator_u, METH_NOARGS, StrokeVertexIterator_u___doc__}, + {"castToInterface0DIterator", ( PyCFunction ) StrokeVertexIterator_castToInterface0DIterator, METH_NOARGS, StrokeVertexIterator_castToInterface0DIterator___doc__}, + {"getObject", ( PyCFunction ) StrokeVertexIterator_getObject, METH_NOARGS, StrokeVertexIterator_getObject___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_StrokeVertexIterator type definition ------------------------------*/ + +PyTypeObject StrokeVertexIterator_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "StrokeVertexIterator", /* tp_name */ + sizeof(BPy_StrokeVertexIterator), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + StrokeVertexIterator___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + PyObject_SelfIter, /* tp_iter */ + (iternextfunc)StrokeVertexIterator_iternext, /* tp_iternext */ + BPy_StrokeVertexIterator_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &Iterator_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)StrokeVertexIterator___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.h new file mode 100644 index 00000000000..0c4b6e4bb6c --- /dev/null +++ b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.h @@ -0,0 +1,33 @@ +#ifndef FREESTYLE_PYTHON_STROKEVERTEXITERATOR_H +#define FREESTYLE_PYTHON_STROKEVERTEXITERATOR_H + +#include "../../stroke/StrokeIterators.h" + +#include "../BPy_Iterator.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject StrokeVertexIterator_Type; + +#define BPy_StrokeVertexIterator_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &StrokeVertexIterator_Type) ) + +/*---------------------------Python BPy_StrokeVertexIterator structure definition----------*/ +typedef struct { + BPy_Iterator py_it; + StrokeInternal::StrokeVertexIterator *sv_it; + int reversed; +} BPy_StrokeVertexIterator; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_STROKEVERTEXITERATOR_H */ diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp new file mode 100644 index 00000000000..660e00b7089 --- /dev/null +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp @@ -0,0 +1,266 @@ +#include "BPy_ViewEdgeIterator.h" + +#include "../BPy_Convert.h" +#include "../Interface1D/BPy_ViewEdge.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ViewEdgeIterator___doc__[] = +"Class hierarchy: :class:`Iterator` > :class:`ViewEdgeIterator`\n" +"\n" +"Base class for iterators over ViewEdges of the :class:`ViewMap` Graph.\n" +"Basically the increment() operator of this class should be able to\n" +"take the decision of \"where\" (on which ViewEdge) to go when pointing\n" +"on a given ViewEdge.\n" +"\n" +".. method:: __init__(begin=None, orientation=True)\n" +"\n" +" Builds a ViewEdgeIterator from a starting ViewEdge and its\n" +" orientation.\n" +"\n" +" :arg begin: The ViewEdge from where to start the iteration.\n" +" :type begin: :class:`ViewEdge` or None\n" +" :arg orientation: If true, we'll look for the next ViewEdge among\n" +" the ViewEdges that surround the ending ViewVertex of begin. If\n" +" false, we'll search over the ViewEdges surrounding the ending\n" +" ViewVertex of begin.\n" +" :type orientation: bool\n" +"\n" +".. method:: __init__(it)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg it: A ViewEdgeIterator object.\n" +" :type it: :class:`ViewEdgeIterator`\n"; + +static int ViewEdgeIterator___init__(BPy_ViewEdgeIterator *self, PyObject *args ) +{ + PyObject *obj1 = 0, *obj2 = 0; + + if (!( PyArg_ParseTuple(args, "O|O", &obj1, &obj2) )) + return -1; + + if( obj1 && BPy_ViewEdgeIterator_Check(obj1) ) { + self->ve_it = new ViewEdgeInternal::ViewEdgeIterator(*( ((BPy_ViewEdgeIterator *) obj1)->ve_it )); + + } else { + ViewEdge *begin; + if ( !obj1 || obj1 == Py_None ) + begin = NULL; + else if ( BPy_ViewEdge_Check(obj1) ) + begin = ((BPy_ViewEdge *) obj1)->ve; + else { + PyErr_SetString(PyExc_TypeError, "1st argument must be either a ViewEdge object or None"); + return -1; + } + bool orientation = ( obj2 ) ? bool_from_PyBool(obj2) : true; + + self->ve_it = new ViewEdgeInternal::ViewEdgeIterator( begin, orientation); + + } + + self->py_it.it = self->ve_it; + + return 0; +} + +static char ViewEdgeIterator_getCurrentEdge___doc__[] = +".. method:: getCurrentEdge()\n" +"\n" +" Returns the current pointed ViewEdge.\n" +"\n" +" :return: The current pointed ViewEdge.\n" +" :rtype: :class:`ViewEdge`\n"; + +static PyObject *ViewEdgeIterator_getCurrentEdge( BPy_ViewEdgeIterator *self ) { + ViewEdge *ve = self->ve_it->getCurrentEdge(); + if( ve ) + return BPy_ViewEdge_from_ViewEdge( *ve ); + + Py_RETURN_NONE; +} + +static char ViewEdgeIterator_setCurrentEdge___doc__[] = +".. method:: setCurrentEdge(edge)\n" +"\n" +" Sets the current pointed ViewEdge.\n" +"\n" +" :arg edge: The current pointed ViewEdge.\n" +" :type edge: :class:`ViewEdge`\n"; + +static PyObject *ViewEdgeIterator_setCurrentEdge( BPy_ViewEdgeIterator *self, PyObject *args ) { + PyObject *py_ve; + + if(!( PyArg_ParseTuple(args, "O!", &ViewEdge_Type, &py_ve) )) + return NULL; + + self->ve_it->setCurrentEdge( ((BPy_ViewEdge *) py_ve)->ve ); + + Py_RETURN_NONE; +} + +static char ViewEdgeIterator_getBegin___doc__[] = +".. method:: getBegin()\n" +"\n" +" Returns the first ViewEdge used for the iteration.\n" +"\n" +" :return: The first ViewEdge used for the iteration.\n" +" :rtype: :class:`ViewEdge`\n"; + +static PyObject *ViewEdgeIterator_getBegin( BPy_ViewEdgeIterator *self ) { + ViewEdge *ve = self->ve_it->getBegin(); + if( ve ) + return BPy_ViewEdge_from_ViewEdge( *ve ); + + Py_RETURN_NONE; +} + +static char ViewEdgeIterator_setBegin___doc__[] = +".. method:: setBegin(begin)\n" +"\n" +" Sets the first ViewEdge used for the iteration.\n" +"\n" +" :arg begin: The first ViewEdge used for the iteration.\n" +" :type begin: :class:`ViewEdge`\n"; + +static PyObject *ViewEdgeIterator_setBegin( BPy_ViewEdgeIterator *self, PyObject *args ) { + PyObject *py_ve; + + if(!( PyArg_ParseTuple(args, "O!", &ViewEdge_Type, &py_ve) )) + return NULL; + + self->ve_it->setBegin( ((BPy_ViewEdge *) py_ve)->ve ); + + Py_RETURN_NONE; +} + +static char ViewEdgeIterator_getOrientation___doc__[] = +".. method:: getOrientation()\n" +"\n" +" Returns the orientation of the pointed ViewEdge in the iteration.\n" +"\n" +" :return: The orientation of the pointed ViewEdge in the iteration.\n" +" :rtype: bool\n"; + +static PyObject *ViewEdgeIterator_getOrientation( BPy_ViewEdgeIterator *self ) { + return PyBool_from_bool( self->ve_it->getOrientation() ); +} + +static char ViewEdgeIterator_setOrientation___doc__[] = +".. method:: setOrientation(orientation)\n" +"\n" +" Sets the orientation of the pointed ViewEdge in the iteration.\n" +"\n" +" :arg orientation: If true, we'll look for the next ViewEdge among\n" +" the ViewEdges that surround the ending ViewVertex of begin. If\n" +" false, we'll search over the ViewEdges surrounding the ending\n" +" ViewVertex of begin.\n" +" :type orientation: bool\n"; + +static PyObject *ViewEdgeIterator_setOrientation( BPy_ViewEdgeIterator *self, PyObject *args ) { + PyObject *py_b; + + if(!( PyArg_ParseTuple(args, "O", &py_b) )) + return NULL; + + self->ve_it->setOrientation( bool_from_PyBool(py_b) ); + + Py_RETURN_NONE; +} + +static char ViewEdgeIterator_changeOrientation___doc__[] = +".. method:: changeOrientation()\n" +"\n" +" Changes the current orientation.\n"; + +static PyObject *ViewEdgeIterator_changeOrientation( BPy_ViewEdgeIterator *self ) { + self->ve_it->changeOrientation(); + + Py_RETURN_NONE; +} + +static char ViewEdgeIterator_getObject___doc__[] = +".. method:: getObject()\n" +"\n" +" Returns the pointed ViewEdge.\n" +"\n" +" :return: The pointed ViewEdge.\n" +" :rtype: :class:`ViewEdge`\n"; + +static PyObject * ViewEdgeIterator_getObject( BPy_ViewEdgeIterator *self) { + + ViewEdge *ve = self->ve_it->operator*(); + if( ve ) + return BPy_ViewEdge_from_ViewEdge( *ve ); + + Py_RETURN_NONE; +} + +/*----------------------ViewEdgeIterator instance definitions ----------------------------*/ +static PyMethodDef BPy_ViewEdgeIterator_methods[] = { + {"getCurrentEdge", ( PyCFunction ) ViewEdgeIterator_getCurrentEdge, METH_NOARGS, ViewEdgeIterator_getCurrentEdge___doc__}, + {"setCurrentEdge", ( PyCFunction ) ViewEdgeIterator_setCurrentEdge, METH_VARARGS, ViewEdgeIterator_setCurrentEdge___doc__}, + {"getBegin", ( PyCFunction ) ViewEdgeIterator_getBegin, METH_NOARGS, ViewEdgeIterator_getBegin___doc__}, + {"setBegin", ( PyCFunction ) ViewEdgeIterator_setBegin, METH_VARARGS, ViewEdgeIterator_setBegin___doc__}, + {"getOrientation", ( PyCFunction ) ViewEdgeIterator_getOrientation, METH_NOARGS, ViewEdgeIterator_getOrientation___doc__}, + {"setOrientation", ( PyCFunction ) ViewEdgeIterator_setOrientation, METH_VARARGS, ViewEdgeIterator_setOrientation___doc__}, + {"changeOrientation", ( PyCFunction ) ViewEdgeIterator_changeOrientation, METH_NOARGS, ViewEdgeIterator_changeOrientation___doc__}, + {"getObject", ( PyCFunction ) ViewEdgeIterator_getObject, METH_NOARGS, ViewEdgeIterator_getObject___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_ViewEdgeIterator type definition ------------------------------*/ + +PyTypeObject ViewEdgeIterator_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ViewEdgeIterator", /* tp_name */ + sizeof(BPy_ViewEdgeIterator), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ViewEdgeIterator___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_ViewEdgeIterator_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &Iterator_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ViewEdgeIterator___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.h new file mode 100644 index 00000000000..dce90efc8cf --- /dev/null +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.h @@ -0,0 +1,33 @@ +#ifndef FREESTYLE_PYTHON_VIEWEDGEITERATOR_H +#define FREESTYLE_PYTHON_VIEWEDGEITERATOR_H + + +#include "../../view_map/ViewMapIterators.h" + +#include "../BPy_Iterator.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ViewEdgeIterator_Type; + +#define BPy_ViewEdgeIterator_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ViewEdgeIterator_Type) ) + +/*---------------------------Python BPy_ViewEdgeIterator structure definition----------*/ +typedef struct { + BPy_Iterator py_it; + ViewEdgeInternal::ViewEdgeIterator *ve_it; +} BPy_ViewEdgeIterator; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_VIEWEDGEITERATOR_H */ diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp new file mode 100644 index 00000000000..46eb7055217 --- /dev/null +++ b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp @@ -0,0 +1,140 @@ +#include "BPy_orientedViewEdgeIterator.h" + +#include "../BPy_Convert.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char orientedViewEdgeIterator___doc__[] = +"Class hierarchy: :class:`Iterator` > :class:`orientedViewEdgeIterator`\n" +"\n" +"Class representing an iterator over oriented ViewEdges around a\n" +":class:`ViewVertex`. This iterator allows a CCW iteration (in the image\n" +"plane). An instance of an orientedViewEdgeIterator can only be\n" +"obtained from a ViewVertex by calling edgesBegin() or edgesEnd().\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(iBrother)\n" +"\n" +" Copy constructor.\n" +"\n" +" :arg iBrother: An orientedViewEdgeIterator object.\n" +" :type iBrother: :class:`orientedViewEdgeIterator`\n"; + +static int orientedViewEdgeIterator___init__(BPy_orientedViewEdgeIterator *self, PyObject *args ) +{ + PyObject *obj = 0; + + if (!( PyArg_ParseTuple(args, "|O", &obj) )) + return -1; + + if( !obj ) + self->ove_it = new ViewVertexInternal::orientedViewEdgeIterator(); + else if( BPy_orientedViewEdgeIterator_Check(obj) ) + self->ove_it = new ViewVertexInternal::orientedViewEdgeIterator(*( ((BPy_orientedViewEdgeIterator *) obj)->ove_it )); + else { + PyErr_SetString(PyExc_TypeError, "invalid argument"); + return -1; + } + + self->py_it.it = self->ove_it; + self->reversed = 0; + + return 0; +} + +static PyObject * orientedViewEdgeIterator_iternext( BPy_orientedViewEdgeIterator *self ) { + ViewVertex::directedViewEdge *dve; + if (self->reversed) { + if (self->ove_it->isBegin()) { + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + self->ove_it->decrement(); + dve = self->ove_it->operator->(); + } else { + if (self->ove_it->isEnd()) { + PyErr_SetNone(PyExc_StopIteration); + return NULL; + } + dve = self->ove_it->operator->(); + self->ove_it->increment(); + } + return BPy_directedViewEdge_from_directedViewEdge( *dve ); +} + +static char orientedViewEdgeIterator_getObject___doc__[] = +".. method:: getObject()\n" +"\n" +" Returns the pointed oriented ViewEdge.\n" +"\n" +" :return: A tuple of the pointed ViewEdge and a boolean value. If\n" +" the boolean value is true, the ViewEdge is incoming.\n" +" :rtype: (:class:`directedViewEdge`, bool)\n"; + +static PyObject * orientedViewEdgeIterator_getObject( BPy_orientedViewEdgeIterator *self) { + return BPy_directedViewEdge_from_directedViewEdge( self->ove_it->operator*() ); +} + +/*----------------------orientedViewEdgeIterator instance definitions ----------------------------*/ +static PyMethodDef BPy_orientedViewEdgeIterator_methods[] = { + {"getObject", ( PyCFunction ) orientedViewEdgeIterator_getObject, METH_NOARGS, orientedViewEdgeIterator_getObject___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_orientedViewEdgeIterator type definition ------------------------------*/ + +PyTypeObject orientedViewEdgeIterator_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "orientedViewEdgeIterator", /* tp_name */ + sizeof(BPy_orientedViewEdgeIterator), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + orientedViewEdgeIterator___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + PyObject_SelfIter, /* tp_iter */ + (iternextfunc)orientedViewEdgeIterator_iternext, /* tp_iternext */ + BPy_orientedViewEdgeIterator_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &Iterator_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)orientedViewEdgeIterator___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.h b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.h new file mode 100644 index 00000000000..cd9edf1e224 --- /dev/null +++ b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.h @@ -0,0 +1,34 @@ +#ifndef FREESTYLE_PYTHON_ORIENTEDVIEWEDGEITERATOR_H +#define FREESTYLE_PYTHON_ORIENTEDVIEWEDGEITERATOR_H + +#include "../../stroke/Stroke.h" +#include "../../view_map/ViewMapIterators.h" + +#include "../BPy_Iterator.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject orientedViewEdgeIterator_Type; + +#define BPy_orientedViewEdgeIterator_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &orientedViewEdgeIterator_Type) ) + +/*---------------------------Python BPy_orientedViewEdgeIterator structure definition----------*/ +typedef struct { + BPy_Iterator py_it; + ViewVertexInternal::orientedViewEdgeIterator *ove_it; + int reversed; +} BPy_orientedViewEdgeIterator; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_ORIENTEDVIEWEDGEITERATOR_H */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp new file mode 100644 index 00000000000..cdab4b38b95 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp @@ -0,0 +1,91 @@ +#include "BPy_BackboneStretcherShader.h" + +#include "../../stroke/BasicStrokeShaders.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char BackboneStretcherShader___doc__[] = +"Class hierarchy: :class:`StrokeShader` > :class:`BackboneStretcherShader`\n" +"\n" +"[Geometry shader]\n" +"\n" +".. method:: __init__(iAmount=2.0)\n" +"\n" +" Builds a BackboneStretcherShader object.\n" +"\n" +" :arg iAmount: The stretching amount value.\n" +" :type iAmount: float\n" +"\n" +".. method:: shade(s)\n" +"\n" +" Stretches the stroke at its two extremities and following the\n" +" respective directions: v(1)v(0) and v(n-1)v(n).\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static int BackboneStretcherShader___init__( BPy_BackboneStretcherShader* self, PyObject *args) +{ + float f = 2.0; + + if(!( PyArg_ParseTuple(args, "|f", &f) )) + return -1; + + self->py_ss.ss = new StrokeShaders::BackboneStretcherShader(f); + return 0; +} + +/*-----------------------BPy_BackboneStretcherShader type definition ------------------------------*/ + +PyTypeObject BackboneStretcherShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "BackboneStretcherShader", /* tp_name */ + sizeof(BPy_BackboneStretcherShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + BackboneStretcherShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &StrokeShader_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)BackboneStretcherShader___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.h new file mode 100644 index 00000000000..35a74c0bda2 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_BACKBONESTRETCHERSHADER_H +#define FREESTYLE_PYTHON_BACKBONESTRETCHERSHADER_H + +#include "../BPy_StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject BackboneStretcherShader_Type; + +#define BPy_BackboneStretcherShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &BackboneStretcherShader_Type) ) + +/*---------------------------Python BPy_BackboneStretcherShader structure definition----------*/ +typedef struct { + BPy_StrokeShader py_ss; +} BPy_BackboneStretcherShader; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_BACKBONESTRETCHERSHADER_H */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.cpp new file mode 100644 index 00000000000..f3d3bfafd08 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.cpp @@ -0,0 +1,93 @@ +#include "BPy_BezierCurveShader.h" + +#include "../../stroke/BasicStrokeShaders.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char BezierCurveShader___doc__[] = +"Class hierarchy: :class:`StrokeShader` > :class:`BezierCurveShader`\n" +"\n" +"[Geometry shader]\n" +"\n" +".. method:: __init__(error=4.0)\n" +"\n" +" Builds a BezierCurveShader object.\n" +"\n" +" :arg error: The error we're allowing for the approximation. This\n" +" error is the max distance allowed between the new curve and the\n" +" original geometry.\n" +" :type error: float\n" +"\n" +".. method:: shade(s)\n" +"\n" +" Transforms the stroke backbone geometry so that it corresponds to a\n" +" Bezier Curve approximation of the original backbone geometry.\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static int BezierCurveShader___init__( BPy_BezierCurveShader* self, PyObject *args) +{ + float f = 4.0; + + if(!( PyArg_ParseTuple(args, "|f", &f) )) + return -1; + + self->py_ss.ss = new StrokeShaders::BezierCurveShader(f); + return 0; +} + +/*-----------------------BPy_BezierCurveShader type definition ------------------------------*/ + +PyTypeObject BezierCurveShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "BezierCurveShader", /* tp_name */ + sizeof(BPy_BezierCurveShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + BezierCurveShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &StrokeShader_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)BezierCurveShader___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.h new file mode 100644 index 00000000000..b94ef88acea --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_BEZIERCURVESHADER_H +#define FREESTYLE_PYTHON_BEZIERCURVESHADER_H + +#include "../BPy_StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject BezierCurveShader_Type; + +#define BPy_BezierCurveShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &BezierCurveShader_Type) ) + +/*---------------------------Python BPy_BezierCurveShader structure definition----------*/ +typedef struct { + BPy_StrokeShader py_ss; +} BPy_BezierCurveShader; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_BEZIERCURVESHADER_H */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp new file mode 100644 index 00000000000..05f8d1299de --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp @@ -0,0 +1,113 @@ +#include "BPy_CalligraphicShader.h" + +#include "../../stroke/AdvancedStrokeShaders.h" +#include "../BPy_Convert.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char CalligraphicShader___doc__[] = +"Class hierarchy: :class:`StrokeShader` > :class:`CalligraphicShader`\n" +"\n" +"[Thickness Shader]\n" +"\n" +".. method:: __init__(iMinThickness, iMaxThickness, iOrientation, iClamp)\n" +"\n" +" Builds a CalligraphicShader object.\n" +"\n" +" :arg iMinThickness: The minimum thickness in the direction\n" +" perpandicular to the main direction.\n" +" :type iMinThickness: float\n" +" :arg iMaxThickness: The maximum thickness in the main direction.\n" +" :type iMaxThickness: float\n" +" :arg iOrientation: The 2D vector giving the main direction.\n" +" :type iOrientation: :class:`mathutils.Vector`\n" +" :arg iClamp: If true, the strokes are drawn in black when the stroke\n" +" direction is between -90 and 90 degrees with respect to the main\n" +" direction and drawn in white otherwise. If false, the strokes\n" +" are always drawn in black.\n" +" :type iClamp: bool\n" +"\n" +".. method:: shade(s)\n" +"\n" +" Assigns thicknesses to the stroke vertices so that the stroke looks\n" +" like made with a calligraphic tool, i.e. the stroke will be the\n" +" thickest in a main direction, and the thinest in the direction\n" +" perpendicular to this one, and an interpolation inbetween.\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static int CalligraphicShader___init__( BPy_CalligraphicShader* self, PyObject *args) +{ + double d1, d2; + PyObject *obj3 = 0, *obj4 = 0; + + + if(!( PyArg_ParseTuple(args, "ddOO", &d1, &d2, &obj3, &obj4) )) + return -1; + Vec2f *v = Vec2f_ptr_from_PyObject(obj3); + if( !v ) { + PyErr_SetString(PyExc_TypeError, "argument 3 must be a 2D vector (either a list of 2 elements or Vector)"); + return -1; + } + self->py_ss.ss = new CalligraphicShader(d1, d2, *v, bool_from_PyBool(obj4) ); + delete v; + + return 0; + +} + +/*-----------------------BPy_CalligraphicShader type definition ------------------------------*/ + +PyTypeObject CalligraphicShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "CalligraphicShader", /* tp_name */ + sizeof(BPy_CalligraphicShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + CalligraphicShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &StrokeShader_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)CalligraphicShader___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h new file mode 100644 index 00000000000..c573b0184ad --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_CALLIGRAPHICSHADER_H +#define FREESTYLE_PYTHON_CALLIGRAPHICSHADER_H + +#include "../BPy_StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject CalligraphicShader_Type; + +#define BPy_CalligraphicShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &CalligraphicShader_Type) + +/*---------------------------Python BPy_CalligraphicShader structure definition----------*/ +typedef struct { + BPy_StrokeShader py_ss; +} BPy_CalligraphicShader; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_CALLIGRAPHICSHADER_H */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.cpp new file mode 100644 index 00000000000..d005e8ccfe8 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.cpp @@ -0,0 +1,92 @@ +#include "BPy_ColorNoiseShader.h" + +#include "../../stroke/BasicStrokeShaders.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ColorNoiseShader___doc__[] = +"Class hierarchy: :class:`StrokeShader` > :class:`ColorNoiseShader`\n" +"\n" +"[Color shader]\n" +"\n" +".. method:: __init__(iAmplitude, iPeriod)\n" +"\n" +" Builds a ColorNoiseShader object.\n" +"\n" +" :arg iAmplitude: The amplitude of the noise signal.\n" +" :type iAmplitude: float\n" +" :arg iPeriod: The period of the noise signal.\n" +" :type iPeriod: float\n" +"\n" +".. method:: shade(s)\n" +"\n" +" Shader to add noise to the stroke colors.\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static int ColorNoiseShader___init__( BPy_ColorNoiseShader* self, PyObject *args) +{ + float f1, f2; + + if(!( PyArg_ParseTuple(args, "ff", &f1, &f2) )) + return -1; + + self->py_ss.ss = new StrokeShaders::ColorNoiseShader(f1, f2); + return 0; +} + +/*-----------------------BPy_ColorNoiseShader type definition ------------------------------*/ + +PyTypeObject ColorNoiseShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ColorNoiseShader", /* tp_name */ + sizeof(BPy_ColorNoiseShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ColorNoiseShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &StrokeShader_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ColorNoiseShader___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.h new file mode 100644 index 00000000000..694b847565e --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_COLORNOISESHADER_H +#define FREESTYLE_PYTHON_COLORNOISESHADER_H + +#include "../BPy_StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ColorNoiseShader_Type; + +#define BPy_ColorNoiseShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ColorNoiseShader_Type) ) + +/*---------------------------Python BPy_ColorNoiseShader structure definition----------*/ +typedef struct { + BPy_StrokeShader py_ss; +} BPy_ColorNoiseShader; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_COLORNOISESHADER_H */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorVariationPatternShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorVariationPatternShader.cpp new file mode 100644 index 00000000000..2d48df78da1 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorVariationPatternShader.cpp @@ -0,0 +1,98 @@ +#include "BPy_ColorVariationPatternShader.h" + +#include "../../stroke/BasicStrokeShaders.h" +#include "../BPy_Convert.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ColorVariationPatternShader___doc__[] = +"Class hierarchy: :class:`StrokeShader` > :class:`ColorVariationPatternShader`\n" +"\n" +"[Color shader]\n" +"\n" +".. method:: __init__(pattern_name, stretch=True)\n" +"\n" +" Builds a ColorVariationPatternShader object.\n" +"\n" +" :arg pattern_name: The file name of the texture file to use as\n" +" pattern.\n" +" :type pattern_name: str\n" +" :arg stretch: Tells whether the texture must be strecthed or\n" +" repeted to fit the stroke.\n" +" :type stretch: bool\n" +"\n" +".. method:: shade(s)\n" +"\n" +" Applies a pattern to vary the original color. The new color is the\n" +" result of the multiplication of the pattern and the original color.\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static int ColorVariationPatternShader___init__( BPy_ColorVariationPatternShader* self, PyObject *args) +{ + const char *s; + PyObject *obj = 0; + + if(!( PyArg_ParseTuple(args, "s|O", &s, &obj) )) + return -1; + + bool b = (obj) ? bool_from_PyBool(obj) : true; + self->py_ss.ss = new StrokeShaders::ColorVariationPatternShader(s,b); + return 0; +} + +/*-----------------------BPy_ColorVariationPatternShader type definition ------------------------------*/ + +PyTypeObject ColorVariationPatternShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ColorVariationPatternShader", /* tp_name */ + sizeof(BPy_ColorVariationPatternShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ColorVariationPatternShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &StrokeShader_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ColorVariationPatternShader___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorVariationPatternShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorVariationPatternShader.h new file mode 100644 index 00000000000..b1898ebfecf --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorVariationPatternShader.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_COLORVARIATIONPATTERNSHADER_H +#define FREESTYLE_PYTHON_COLORVARIATIONPATTERNSHADER_H + +#include "../BPy_StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ColorVariationPatternShader_Type; + +#define BPy_ColorVariationPatternShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ColorVariationPatternShader_Type) ) + +/*---------------------------Python BPy_ColorVariationPatternShader structure definition----------*/ +typedef struct { + BPy_StrokeShader py_ss; +} BPy_ColorVariationPatternShader; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_COLORVARIATIONPATTERNSHADER_H */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.cpp new file mode 100644 index 00000000000..d0f4c365a80 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.cpp @@ -0,0 +1,96 @@ +#include "BPy_ConstantColorShader.h" + +#include "../../stroke/BasicStrokeShaders.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ConstantColorShader___doc__[] = +"Class hierarchy: :class:`StrokeShader` > :class:`ConstantColorShader`\n" +"\n" +"[Color shader]\n" +"\n" +".. method:: __init__(iR, iG, iB, iAlpha=1.0)\n" +"\n" +" Builds a ConstantColorShader object.\n" +"\n" +" :arg iR: The red component.\n" +" :type iR: float\n" +" :arg iG: The green component.\n" +" :type iG: float\n" +" :arg iB: The blue component.\n" +" :type iB: float\n" +" :arg iAlpha: The alpha value.\n" +" :type iAlpha: float\n" +"\n" +".. method:: shade(s)\n" +"\n" +" Assigns a constant color to every vertex of the Stroke.\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static int ConstantColorShader___init__( BPy_ConstantColorShader* self, PyObject *args) +{ + float f1, f2, f3, f4 = 1.0; + + if(!( PyArg_ParseTuple(args, "fff|f", &f1, &f2, &f3, &f4) )) + return -1; + + self->py_ss.ss = new StrokeShaders::ConstantColorShader(f1, f2, f3, f4); + return 0; +} + +/*-----------------------BPy_ConstantColorShader type definition ------------------------------*/ + +PyTypeObject ConstantColorShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ConstantColorShader", /* tp_name */ + sizeof(BPy_ConstantColorShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ConstantColorShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &StrokeShader_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ConstantColorShader___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.h new file mode 100644 index 00000000000..30a09d852fd --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_CONSTANTCOLORSHADER_H +#define FREESTYLE_PYTHON_CONSTANTCOLORSHADER_H + +#include "../BPy_StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ConstantColorShader_Type; + +#define BPy_ConstantColorShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ConstantColorShader_Type) ) + +/*---------------------------Python BPy_ConstantColorShader structure definition----------*/ +typedef struct { + BPy_StrokeShader py_ss; +} BPy_ConstantColorShader; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_CONSTANTCOLORSHADER_H */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp new file mode 100644 index 00000000000..60d3e696675 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp @@ -0,0 +1,90 @@ +#include "BPy_ConstantThicknessShader.h" + +#include "../../stroke/BasicStrokeShaders.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ConstantThicknessShader___doc__[] = +"Class hierarchy: :class:`StrokeShader` > :class:`ConstantThicknessShader`\n" +"\n" +"[Thickness shader]\n" +"\n" +".. method:: __init__(thickness)\n" +"\n" +" Builds a ConstantThicknessShader object.\n" +"\n" +" :arg thickness: The thickness that must be assigned to the stroke.\n" +" :type thickness: float\n" +"\n" +".. method:: shade(s)\n" +"\n" +" Assigns an absolute constant thickness to every vertex of the Stroke.\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static int ConstantThicknessShader___init__( BPy_ConstantThicknessShader* self, PyObject *args) +{ + float f; + + if(!( PyArg_ParseTuple(args, "f", &f) )) + return -1; + + self->py_ss.ss = new StrokeShaders::ConstantThicknessShader(f); + return 0; +} + +/*-----------------------BPy_ConstantThicknessShader type definition ------------------------------*/ + +PyTypeObject ConstantThicknessShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ConstantThicknessShader", /* tp_name */ + sizeof(BPy_ConstantThicknessShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ConstantThicknessShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &StrokeShader_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ConstantThicknessShader___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.h new file mode 100644 index 00000000000..bb7f3c0f622 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_CONSTANTTHICKNESSSHADER_H +#define FREESTYLE_PYTHON_CONSTANTTHICKNESSSHADER_H + +#include "../BPy_StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ConstantThicknessShader_Type; + +#define BPy_ConstantThicknessShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ConstantThicknessShader_Type) ) + +/*---------------------------Python BPy_ConstantThicknessShader structure definition----------*/ +typedef struct { + BPy_StrokeShader py_ss; +} BPy_ConstantThicknessShader; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_CONSTANTTHICKNESSSHADER_H */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp new file mode 100644 index 00000000000..3892ccca37b --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp @@ -0,0 +1,96 @@ +#include "BPy_ConstrainedIncreasingThicknessShader.h" + +#include "../../stroke/BasicStrokeShaders.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ConstrainedIncreasingThicknessShader___doc__[] = +"Class hierarchy: :class:`StrokeShader` > :class:`ConstrainedIncreasingThicknessShader`\n" +"\n" +"[Thickness shader]\n" +"\n" +".. method:: __init__(iThicknessMin, iThicknessMax, iRatio)\n" +"\n" +" Builds a ConstrainedIncreasingThicknessShader object.\n" +"\n" +" :arg iThicknessMin: The minimum thickness.\n" +" :type iThicknessMin: float\n" +" :arg iThicknessMax: The maximum thickness.\n" +" :type iThicknessMax: float\n" +" :arg iRatio: The thickness/length ratio that we don't want to exceed. \n" +" :type iRatio: float\n" +"\n" +".. method:: shade(s)\n" +"\n" +" Same as the :class:`IncreasingThicknessShader`, but here we allow\n" +" the user to control the thickness/length ratio so that we don't get\n" +" fat short lines.\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static int ConstrainedIncreasingThicknessShader___init__( BPy_ConstrainedIncreasingThicknessShader* self, PyObject *args) +{ + float f1, f2, f3; + + if(!( PyArg_ParseTuple(args, "fff", &f1, &f2, &f3) )) + return -1; + + self->py_ss.ss = new StrokeShaders::ConstrainedIncreasingThicknessShader(f1, f2, f3); + return 0; +} + +/*-----------------------BPy_ConstrainedIncreasingThicknessShader type definition ------------------------------*/ + +PyTypeObject ConstrainedIncreasingThicknessShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ConstrainedIncreasingThicknessShader", /* tp_name */ + sizeof(BPy_ConstrainedIncreasingThicknessShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ConstrainedIncreasingThicknessShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &StrokeShader_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ConstrainedIncreasingThicknessShader___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h new file mode 100644 index 00000000000..38a8aa2bfe0 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_CONSTRAINEDINCREASINGTHICKNESSSHADER_H +#define FREESTYLE_PYTHON_CONSTRAINEDINCREASINGTHICKNESSSHADER_H + +#include "../BPy_StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ConstrainedIncreasingThicknessShader_Type; + +#define BPy_ConstrainedIncreasingThicknessShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ConstrainedIncreasingThicknessShader_Type) ) + +/*---------------------------Python BPy_ConstrainedIncreasingThicknessShader structure definition----------*/ +typedef struct { + BPy_StrokeShader py_ss; +} BPy_ConstrainedIncreasingThicknessShader; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_CONSTRAINEDINCREASINGTHICKNESSSHADER_H */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.cpp new file mode 100644 index 00000000000..79af155b728 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.cpp @@ -0,0 +1,98 @@ +#include "BPy_GuidingLinesShader.h" + +#include "../../stroke/BasicStrokeShaders.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GuidingLinesShader___doc__[] = +"Class hierarchy: :class:`StrokeShader` > :class:`GuidingLinesShader`\n" +"\n" +"[Geometry shader]\n" +"\n" +".. method:: __init__(iOffset)\n" +"\n" +" Builds a GuidingLinesShader object.\n" +"\n" +" :arg iOffset: The line that replaces the stroke is initially in the\n" +" middle of the initial stroke bounding box. iOffset is the value\n" +" of the displacement which is applied to this line along its\n" +" normal.\n" +" :type iOffset: float\n" +"\n" +".. method:: shade(s)\n" +"\n" +" Shader to modify the Stroke geometry so that it corresponds to its\n" +" main direction line. This shader must be used together with the\n" +" splitting operator using the curvature criterion. Indeed, the\n" +" precision of the approximation will depend on the size of the\n" +" stroke's pieces. The bigger the pieces are, the rougher the\n" +" approximation is.\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static int GuidingLinesShader___init__( BPy_GuidingLinesShader* self, PyObject *args) +{ + float f; + + if(!( PyArg_ParseTuple(args, "f", &f) )) + return -1; + + self->py_ss.ss = new StrokeShaders::GuidingLinesShader(f); + return 0; +} + +/*-----------------------BPy_GuidingLinesShader type definition ------------------------------*/ + +PyTypeObject GuidingLinesShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GuidingLinesShader", /* tp_name */ + sizeof(BPy_GuidingLinesShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GuidingLinesShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &StrokeShader_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GuidingLinesShader___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.h new file mode 100644 index 00000000000..e25704c33ba --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_GUIDINGLINESSHADER_H +#define FREESTYLE_PYTHON_GUIDINGLINESSHADER_H + +#include "../BPy_StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GuidingLinesShader_Type; + +#define BPy_GuidingLinesShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GuidingLinesShader_Type) ) + +/*---------------------------Python BPy_GuidingLinesShader structure definition----------*/ +typedef struct { + BPy_StrokeShader py_ss; +} BPy_GuidingLinesShader; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_GUIDINGLINESSHADER_H */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp new file mode 100644 index 00000000000..063e5cd587d --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp @@ -0,0 +1,106 @@ +#include "BPy_IncreasingColorShader.h" + +#include "../../stroke/BasicStrokeShaders.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char IncreasingColorShader___doc__[] = +"Class hierarchy: :class:`StrokeShader` > :class:`IncreasingColorShader`\n" +"\n" +"[Color shader]\n" +"\n" +".. method:: __init__(iRm, iGm, iBm, iAlpham, iRM, iGM, iBM, iAlphaM)\n" +"\n" +" Builds an IncreasingColorShader object.\n" +"\n" +" :arg iRm: The first color red component.\n" +" :type iRm: float\n" +" :arg iGm: The first color green component.\n" +" :type iGm: float\n" +" :arg iBm: The first color blue component.\n" +" :type iBm: float\n" +" :arg iAlpham: The first color alpha value.\n" +" :type iAlpham: float\n" +" :arg iRM: The second color red component.\n" +" :type iRM: float\n" +" :arg iGM: The second color green component.\n" +" :type iGM: float\n" +" :arg iBM: The second color blue component.\n" +" :type iBM: float\n" +" :arg iAlphaM: The second color alpha value.\n" +" :type iAlphaM: float\n" +"\n" +".. method:: shade(s)\n" +"\n" +" Assigns a varying color to the stroke. The user specifies two\n" +" colors A and B. The stroke color will change linearly from A to B\n" +" between the first and the last vertex.\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static int IncreasingColorShader___init__( BPy_IncreasingColorShader* self, PyObject *args) +{ + float f1, f2, f3, f4, f5, f6, f7, f8; + + if(!( PyArg_ParseTuple(args, "ffffffff", &f1, &f2, &f3, &f4, &f5, &f6, &f7, &f8) )) + return -1; + + self->py_ss.ss = new StrokeShaders::IncreasingColorShader(f1, f2, f3, f4, f5, f6, f7, f8); + return 0; +} + +/*-----------------------BPy_IncreasingColorShader type definition ------------------------------*/ + +PyTypeObject IncreasingColorShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "IncreasingColorShader", /* tp_name */ + sizeof(BPy_IncreasingColorShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + IncreasingColorShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &StrokeShader_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)IncreasingColorShader___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.h new file mode 100644 index 00000000000..9bc82e98098 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_INCREASINGCOLORSHADER_H +#define FREESTYLE_PYTHON_INCREASINGCOLORSHADER_H + +#include "../BPy_StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject IncreasingColorShader_Type; + +#define BPy_IncreasingColorShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &IncreasingColorShader_Type) ) + +/*---------------------------Python BPy_IncreasingColorShader structure definition----------*/ +typedef struct { + BPy_StrokeShader py_ss; +} BPy_IncreasingColorShader; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_INCREASINGCOLORSHADER_H */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp new file mode 100644 index 00000000000..398587df23e --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp @@ -0,0 +1,96 @@ +#include "BPy_IncreasingThicknessShader.h" + +#include "../../stroke/BasicStrokeShaders.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char IncreasingThicknessShader___doc__[] = +"Class hierarchy: :class:`StrokeShader` > :class:`IncreasingThicknessShader`\n" +"\n" +"[Thickness shader]\n" +"\n" +".. method:: __init__(iThicknessA, iThicknessB)\n" +"\n" +" Builds an IncreasingThicknessShader object.\n" +"\n" +" :arg iThicknessA: The first thickness value.\n" +" :type iThicknessA: float\n" +" :arg iThicknessB: The second thickness value.\n" +" :type iThicknessB: float\n" +"\n" +".. method:: shade(s)\n" +"\n" +" Assigns thicknesses values such as the thickness increases from a\n" +" thickness value A to a thickness value B between the first vertex\n" +" to the midpoint vertex and then decreases from B to a A between\n" +" this midpoint vertex and the last vertex. The thickness is\n" +" linearly interpolated from A to B.\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static int IncreasingThicknessShader___init__( BPy_IncreasingThicknessShader* self, PyObject *args) +{ + float f1, f2; + + if(!( PyArg_ParseTuple(args, "ff", &f1, &f2) )) + return -1; + + self->py_ss.ss = new StrokeShaders::IncreasingThicknessShader(f1, f2); + return 0; +} + +/*-----------------------BPy_IncreasingThicknessShader type definition ------------------------------*/ + +PyTypeObject IncreasingThicknessShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "IncreasingThicknessShader", /* tp_name */ + sizeof(BPy_IncreasingThicknessShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + IncreasingThicknessShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &StrokeShader_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)IncreasingThicknessShader___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.h new file mode 100644 index 00000000000..33d883b1860 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_INCREASINGTHICKNESSSHADER_H +#define FREESTYLE_PYTHON_INCREASINGTHICKNESSSHADER_H + +#include "../BPy_StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject IncreasingThicknessShader_Type; + +#define BPy_IncreasingThicknessShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &IncreasingThicknessShader_Type) ) + +/*---------------------------Python BPy_IncreasingThicknessShader structure definition----------*/ +typedef struct { + BPy_StrokeShader py_ss; +} BPy_IncreasingThicknessShader; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_INCREASINGTHICKNESSSHADER_H */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp new file mode 100644 index 00000000000..2ea4bf14941 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp @@ -0,0 +1,97 @@ +#include "BPy_PolygonalizationShader.h" + +#include "../../stroke/BasicStrokeShaders.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char PolygonalizationShader___doc__[] = +"Class hierarchy: :class:`StrokeShader` > :class:`PolygonalizationShader`\n" +"\n" +"[Geometry shader]\n" +"\n" +".. method:: __init__(iError)\n" +"\n" +" Builds a PolygonalizationShader object.\n" +"\n" +" :arg iError: The error we want our polygonal approximation to have\n" +" with respect to the original geometry. The smaller, the closer\n" +" the new stroke is to the orinal one. This error corresponds to\n" +" the maximum distance between the new stroke and the old one.\n" +" :type iError: float\n" +"\n" +".. method:: shade(s)\n" +"\n" +" Modifies the Stroke geometry so that it looks more \"polygonal\".\n" +" The basic idea is to start from the minimal stroke approximation\n" +" consisting in a line joining the first vertex to the last one and\n" +" to subdivide using the original stroke vertices until a certain\n" +" error is reached.\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static int PolygonalizationShader___init__( BPy_PolygonalizationShader* self, PyObject *args) +{ + float f; + + if(!( PyArg_ParseTuple(args, "f", &f) )) + return -1; + + self->py_ss.ss = new StrokeShaders::PolygonalizationShader(f); + return 0; +} + +/*-----------------------BPy_PolygonalizationShader type definition ------------------------------*/ + +PyTypeObject PolygonalizationShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "PolygonalizationShader", /* tp_name */ + sizeof(BPy_PolygonalizationShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + PolygonalizationShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &StrokeShader_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)PolygonalizationShader___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.h new file mode 100644 index 00000000000..85bcc00e869 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_POLYGONALIZATIONSHADER_H +#define FREESTYLE_PYTHON_POLYGONALIZATIONSHADER_H + +#include "../BPy_StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject PolygonalizationShader_Type; + +#define BPy_PolygonalizationShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &PolygonalizationShader_Type) ) + +/*---------------------------Python BPy_PolygonalizationShader structure definition----------*/ +typedef struct { + BPy_StrokeShader py_ss; +} BPy_PolygonalizationShader; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_POLYGONALIZATIONSHADER_H */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.cpp new file mode 100644 index 00000000000..08b1e64f7a5 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.cpp @@ -0,0 +1,90 @@ +#include "BPy_SamplingShader.h" + +#include "../../stroke/BasicStrokeShaders.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char SamplingShader___doc__[] = +"Class hierarchy: :class:`StrokeShader` > :class:`SamplingShader`\n" +"\n" +"[Geometry shader]\n" +"\n" +".. method:: __init__(sampling)\n" +"\n" +" Builds a SamplingShader object.\n" +"\n" +" :arg sampling: The sampling to use for the stroke resampling.\n" +" :type sampling: float\n" +"\n" +".. method:: shade(s)\n" +"\n" +" Resamples the stroke.\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static int SamplingShader___init__( BPy_SamplingShader* self, PyObject *args) +{ + float f; + + if(!( PyArg_ParseTuple(args, "f", &f) )) + return -1; + + self->py_ss.ss = new StrokeShaders::SamplingShader(f); + return 0; +} + +/*-----------------------BPy_SamplingShader type definition ------------------------------*/ + +PyTypeObject SamplingShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "SamplingShader", /* tp_name */ + sizeof(BPy_SamplingShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + SamplingShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &StrokeShader_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)SamplingShader___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.h new file mode 100644 index 00000000000..dfc6efb3319 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_SAMPLINGSHADER_H +#define FREESTYLE_PYTHON_SAMPLINGSHADER_H + +#include "../BPy_StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject SamplingShader_Type; + +#define BPy_SamplingShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &SamplingShader_Type) ) + +/*---------------------------Python BPy_SamplingShader structure definition----------*/ +typedef struct { + BPy_StrokeShader py_ss; +} BPy_SamplingShader; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_SAMPLINGSHADER_H */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp new file mode 100644 index 00000000000..6f62865f99a --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp @@ -0,0 +1,108 @@ +#include "BPy_SmoothingShader.h" + +#include "../../stroke/AdvancedStrokeShaders.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char SmoothingShader___doc__[] = +"Class hierarchy: :class:`StrokeShader` > :class:`SmoothingShader`\n" +"\n" +"[Geometry shader]\n" +"\n" +".. method:: __init__(iNbIteration, iFactorPoint, ifactorCurvature, iFactorCurvatureDifference, iAnisoPoint, iAnisNormal, iAnisoCurvature, icarricatureFactor)\n" +"\n" +" Builds a SmoothingShader object.\n" +"\n" +" :arg iNbIteration: The number of iterations (400).\n" +" :type iNbIteration: int\n" +" :arg iFactorPoint: 0.0\n" +" :type iFactorPoint: float\n" +" :arg ifactorCurvature: 0.0\n" +" :type ifactorCurvature: float\n" +" :arg iFactorCurvatureDifference: 0.2\n" +" :type iFactorCurvatureDifference: float\n" +" :arg iAnisoPoint: \n" +" :type iAnisoPoint: float\n" +" :arg iAnisNormal: 0.0\n" +" :type iAnisNormal: float\n" +" :arg iAnisoCurvature: 0.0\n" +" :type iAnisoCurvature: float\n" +" :arg icarricatureFactor: 1.0\n" +" :type icarricatureFactor: float\n" +"\n" +".. method:: shade(s)\n" +"\n" +" Smoothes the stroke by moving the vertices to make the stroke\n" +" smoother. Uses curvature flow to converge towards a curve of\n" +" constant curvature. The diffusion method we use is anisotropic to\n" +" prevent the diffusion accross corners.\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static 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) )) + return -1; + + self->py_ss.ss = new SmoothingShader(i1, d2, d3, d4, d5, d6, d7, d8); + return 0; +} + +/*-----------------------BPy_SmoothingShader type definition ------------------------------*/ + +PyTypeObject SmoothingShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "SmoothingShader", /* tp_name */ + sizeof(BPy_SmoothingShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + SmoothingShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &StrokeShader_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)SmoothingShader___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.h new file mode 100644 index 00000000000..18d6ca3cc30 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.h @@ -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 */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp new file mode 100644 index 00000000000..245212c3950 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp @@ -0,0 +1,102 @@ +#include "BPy_SpatialNoiseShader.h" + +#include "../../stroke/AdvancedStrokeShaders.h" +#include "../BPy_Convert.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char SpatialNoiseShader___doc__[] = +"Class hierarchy: :class:`StrokeShader` > :class:`SpatialNoiseShader`\n" +"\n" +"[Geometry shader]\n" +"\n" +".. method:: __init__(iAmount, ixScale, nbOctave, smooth, pureRandom)\n" +"\n" +" Builds a SpatialNoiseShader object.\n" +"\n" +" :arg iAmount: The amplitude of the noise.\n" +" :type iAmount: float\n" +" :arg ixScale: The noise frequency.\n" +" :type ixScale: float\n" +" :arg nbOctave: The number of octaves\n" +" :type nbOctave: int\n" +" :arg smooth: True if you want the noise to be smooth.\n" +" :type smooth: bool\n" +" :arg pureRandom: True if you don't want any coherence.\n" +" :type pureRandom: bool\n" +"\n" +".. method:: shade(s)\n" +"\n" +" Spatial Noise stroke shader. Moves the vertices to make the stroke\n" +" more noisy.\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static int SpatialNoiseShader___init__( BPy_SpatialNoiseShader* self, PyObject *args) +{ + float f1, f2; + int i3; + PyObject *obj4 = 0, *obj5 = 0; + + if(!( PyArg_ParseTuple(args, "ffiOO", &f1, &f2, &i3, &obj4, &obj5) )) + return -1; + + self->py_ss.ss = new SpatialNoiseShader(f1, f2, i3, bool_from_PyBool(obj4), bool_from_PyBool(obj5) ); + return 0; +} + +/*-----------------------BPy_SpatialNoiseShader type definition ------------------------------*/ + +PyTypeObject SpatialNoiseShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "SpatialNoiseShader", /* tp_name */ + sizeof(BPy_SpatialNoiseShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + SpatialNoiseShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &StrokeShader_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)SpatialNoiseShader___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.h new file mode 100644 index 00000000000..46e1c12385d --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_SPATIALNOISESHADER_H +#define FREESTYLE_PYTHON_SPATIALNOISESHADER_H + +#include "../BPy_StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject SpatialNoiseShader_Type; + +#define BPy_SpatialNoiseShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &SpatialNoiseShader_Type) ) + +/*---------------------------Python BPy_SpatialNoiseShader structure definition----------*/ +typedef struct { + BPy_StrokeShader py_ss; +} BPy_SpatialNoiseShader; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_SPATIALNOISESHADER_H */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureShader.cpp new file mode 100644 index 00000000000..a6e2d9f71e0 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureShader.cpp @@ -0,0 +1,117 @@ +#include "BPy_StrokeTextureShader.h" + +#include "../../stroke/BasicStrokeShaders.h" +#include "../BPy_Convert.h" +#include "../BPy_MediumType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char StrokeTextureShader___doc__[] = +"Class hierarchy: :class:`StrokeShader` > :class:`StrokeTextureShader`\n" +"\n" +"[Texture shader]\n" +"\n" +".. method:: __init__(textureFile, mediumType=MediumType.OPAQUE_MEDIUM, iTips=False)\n" +"\n" +" Builds a StrokeTextureShader object.\n" +"\n" +" :arg textureFile: \n" +" :type textureFile: str\n" +" :arg mediumType: The medium type and therefore, the blending mode\n" +" that must be used for the rendering of this stroke.\n" +" :type mediumType: :class:`MediumType`\n" +" :arg iTips: Tells whether the texture includes tips or not. If it\n" +" is the case, the texture image must respect the following format.\n" +" :type iTips: bool\n" +"\n" +" The format of a texture image including tips::\n" +"\n" +" ___________\n" +" | |\n" +" | A |\n" +" |___________|\n" +" | | |\n" +" | B | C |\n" +" |_____|_____|\n" +"\n" +" * A : The stroke's corpus texture.\n" +" * B : The stroke's left extremity texture.\n" +" * C : The stroke's right extremity texture.\n" +"\n" +".. method:: shade(s)\n" +"\n" +" Assigns a texture and a blending mode to the stroke in order to\n" +" simulate its marks system.\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static int StrokeTextureShader___init__( BPy_StrokeTextureShader* self, PyObject *args) +{ + const char *s1; + PyObject *obj2 = 0, *obj3 = 0; + + if(!( PyArg_ParseTuple(args, "s|O!O", &s1, &MediumType_Type, &obj2, &obj3) )) + return -1; + + Stroke::MediumType mt = (obj2) ? MediumType_from_BPy_MediumType(obj2) : Stroke::OPAQUE_MEDIUM; + bool b = (obj3) ? bool_from_PyBool(obj3) : true; + + self->py_ss.ss = new StrokeShaders::StrokeTextureShader(s1,mt,b); + return 0; +} + +/*-----------------------BPy_StrokeTextureShader type definition ------------------------------*/ + +PyTypeObject StrokeTextureShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "StrokeTextureShader", /* tp_name */ + sizeof(BPy_StrokeTextureShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + StrokeTextureShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &StrokeShader_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)StrokeTextureShader___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureShader.h new file mode 100644 index 00000000000..c65506f2f14 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureShader.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_STROKETEXTURESHADER_H +#define FREESTYLE_PYTHON_STROKETEXTURESHADER_H + +#include "../BPy_StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject StrokeTextureShader_Type; + +#define BPy_StrokeTextureShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &StrokeTextureShader_Type) ) + +/*---------------------------Python BPy_StrokeTextureShader structure definition----------*/ +typedef struct { + BPy_StrokeShader py_ss; +} BPy_StrokeTextureShader; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_STROKETEXTURESHADER_H */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_TextureAssignerShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_TextureAssignerShader.cpp new file mode 100644 index 00000000000..7fbb3462fb4 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_TextureAssignerShader.cpp @@ -0,0 +1,106 @@ +#include "BPy_TextureAssignerShader.h" + +#include "../../stroke/BasicStrokeShaders.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char TextureAssignerShader___doc__[] = +"Class hierarchy: :class:`StrokeShader` > :class:`TextureAssignerShader`\n" +"\n" +"[Texture shader]\n" +"\n" +".. method:: __init__(id)\n" +"\n" +" Builds a TextureAssignerShader object.\n" +"\n" +" :arg id: The preset number to use.\n" +" :type id: int\n" +"\n" +".. method:: shade(s)\n" +"\n" +" Assigns a texture to the stroke in order to simulate its marks\n" +" system. This shader takes as input an integer value telling which\n" +" texture and blending mode to use among a set of predefined\n" +" textures. Here are the different presets:\n" +"\n" +" * 0: `/brushes/charcoalAlpha.bmp`, `MediumType.HUMID_MEDIUM`\n" +" * 1: `/brushes/washbrushAlpha.bmp`, `MediumType.HUMID_MEDIUM`\n" +" * 2: `/brushes/oil.bmp`, `MediumType.HUMID_MEDIUM`\n" +" * 3: `/brushes/oilnoblend.bmp`, `MediumType.HUMID_MEDIUM`\n" +" * 4: `/brushes/charcoalAlpha.bmp`, `MediumType.DRY_MEDIUM`\n" +" * 5: `/brushes/washbrushAlpha.bmp`, `MediumType.DRY_MEDIUM`\n" +" * 6: `/brushes/opaqueDryBrushAlpha.bmp`, `MediumType.OPAQUE_MEDIUM`\n" +" * 7: `/brushes/opaqueBrushAlpha.bmp`, `MediumType.OPAQUE_MEDIUM`\n" +"\n" +" Any other value will lead to the following preset:\n" +"\n" +" * Default: `/brushes/smoothAlpha.bmp`, `MediumType.OPAQUE_MEDIUM`\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static int TextureAssignerShader___init__( BPy_TextureAssignerShader* self, PyObject *args) +{ + int i; + + if(!( PyArg_ParseTuple(args, "i", &i) )) + return -1; + + self->py_ss.ss = new StrokeShaders::TextureAssignerShader(i); + return 0; +} + +/*-----------------------BPy_TextureAssignerShader type definition ------------------------------*/ + +PyTypeObject TextureAssignerShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "TextureAssignerShader", /* tp_name */ + sizeof(BPy_TextureAssignerShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + TextureAssignerShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &StrokeShader_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)TextureAssignerShader___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_TextureAssignerShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_TextureAssignerShader.h new file mode 100644 index 00000000000..9cffc1c1662 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_TextureAssignerShader.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_TEXTUREASSIGNERSHADER_H +#define FREESTYLE_PYTHON_TEXTUREASSIGNERSHADER_H + +#include "../BPy_StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject TextureAssignerShader_Type; + +#define BPy_TextureAssignerShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &TextureAssignerShader_Type) ) + +/*---------------------------Python BPy_TextureAssignerShader structure definition----------*/ +typedef struct { + BPy_StrokeShader py_ss; +} BPy_TextureAssignerShader; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_TEXTUREASSIGNERSHADER_H */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.cpp new file mode 100644 index 00000000000..c0cf2176b52 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.cpp @@ -0,0 +1,92 @@ +#include "BPy_ThicknessNoiseShader.h" + +#include "../../stroke/BasicStrokeShaders.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ThicknessNoiseShader___doc__[] = +"Class hierarchy: :class:`StrokeShader` > :class:`ThicknessNoiseShader`\n" +"\n" +"[Thickness shader]\n" +"\n" +".. method:: __init__(iAmplitude, iPeriod)\n" +"\n" +" Builds a ThicknessNoiseShader object.\n" +"\n" +" :arg iAmplitude: The amplitude of the noise signal.\n" +" :type iAmplitude: float\n" +" :arg iPeriod: The period of the noise signal.\n" +" :type iPeriod: float\n" +"\n" +".. method:: shade(s)\n" +"\n" +" Adds some noise to the stroke thickness.\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static int ThicknessNoiseShader___init__( BPy_ThicknessNoiseShader* self, PyObject *args) +{ + float f1, f2; + + if(!( PyArg_ParseTuple(args, "ff", &f1, &f2) )) + return -1; + + self->py_ss.ss = new StrokeShaders::ThicknessNoiseShader(f1, f2); + return 0; +} + +/*-----------------------BPy_ThicknessNoiseShader type definition ------------------------------*/ + +PyTypeObject ThicknessNoiseShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ThicknessNoiseShader", /* tp_name */ + sizeof(BPy_ThicknessNoiseShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ThicknessNoiseShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &StrokeShader_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ThicknessNoiseShader___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.h new file mode 100644 index 00000000000..c3ef101683e --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_THICKNESSNOISESHADER_H +#define FREESTYLE_PYTHON_THICKNESSNOISESHADER_H + +#include "../BPy_StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ThicknessNoiseShader_Type; + +#define BPy_ThicknessNoiseShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ThicknessNoiseShader_Type) ) + +/*---------------------------Python BPy_ThicknessNoiseShader structure definition----------*/ +typedef struct { + BPy_StrokeShader py_ss; +} BPy_ThicknessNoiseShader; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_THICKNESSNOISESHADER_H */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessVariationPatternShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessVariationPatternShader.cpp new file mode 100644 index 00000000000..afcfd68fcec --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessVariationPatternShader.cpp @@ -0,0 +1,103 @@ +#include "BPy_ThicknessVariationPatternShader.h" + +#include "../../stroke/BasicStrokeShaders.h" +#include "../BPy_Convert.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ThicknessVariationPatternShader___doc__[] = +"Class hierarchy: :class:`StrokeShader` > :class:`ThicknessVariationPatternShader`\n" +"\n" +"[Thickness shader]\n" +"\n" +".. method:: __init__(pattern_name, iMinThickness, iMaxThickness, stretch)\n" +"\n" +" Builds a ThicknessVariationPatternShader object.\n" +"\n" +" :arg pattern_name: The texture file name.\n" +" :type pattern_name: str\n" +" :arg iMinThickness: The minimum thickness we don't want to exceed.\n" +" :type iMinThickness: float\n" +" :arg iMaxThickness: The maximum thickness we don't want to exceed.\n" +" :type iMaxThickness: float\n" +" :arg stretch: Tells whether the pattern texture must be stretched\n" +" or repeted to fit the stroke.\n" +" :type stretch: bool\n" +"\n" +".. method:: shade(s)\n" +"\n" +" Applies a pattern (texture) to vary thickness. The new thicknesses\n" +" are the result of the multiplication of the pattern and the\n" +" original thickness.\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static int ThicknessVariationPatternShader___init__( BPy_ThicknessVariationPatternShader* self, PyObject *args) +{ + const char *s1; + float f2 = 1.0, f3 = 5.0; + PyObject *obj4 = 0; + + if(!( PyArg_ParseTuple(args, "s|ffO", &s1, &f2, &f3, &obj4) )) + return -1; + + bool b = (obj4) ? bool_from_PyBool(obj4) : true; + self->py_ss.ss = new StrokeShaders::ThicknessVariationPatternShader(s1, f2, f3, b); + return 0; +} + +/*-----------------------BPy_ThicknessVariationPatternShader type definition ------------------------------*/ + +PyTypeObject ThicknessVariationPatternShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ThicknessVariationPatternShader", /* tp_name */ + sizeof(BPy_ThicknessVariationPatternShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ThicknessVariationPatternShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &StrokeShader_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ThicknessVariationPatternShader___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessVariationPatternShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessVariationPatternShader.h new file mode 100644 index 00000000000..302c9e005ae --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessVariationPatternShader.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_THICKNESSVARIATIONPATTERNSHADER_H +#define FREESTYLE_PYTHON_THICKNESSVARIATIONPATTERNSHADER_H + +#include "../BPy_StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ThicknessVariationPatternShader_Type; + +#define BPy_ThicknessVariationPatternShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ThicknessVariationPatternShader_Type) ) + +/*---------------------------Python BPy_ThicknessVariationPatternShader structure definition----------*/ +typedef struct { + BPy_StrokeShader py_ss; +} BPy_ThicknessVariationPatternShader; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_THICKNESSVARIATIONPATTERNSHADER_H */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.cpp new file mode 100644 index 00000000000..8241a03892c --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.cpp @@ -0,0 +1,91 @@ +#include "BPy_TipRemoverShader.h" + +#include "../../stroke/BasicStrokeShaders.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char TipRemoverShader___doc__[] = +"Class hierarchy: :class:`StrokeShader` > :class:`TipRemoverShader`\n" +"\n" +"[Geometry shader]\n" +"\n" +".. method:: __init__(tipLength)\n" +"\n" +" Builds a TipRemoverShader object.\n" +"\n" +" :arg tipLength: The length of the piece of stroke we want to remove\n" +" at each extremity.\n" +" :type tipLength: float\n" +"\n" +".. method:: shade(s)\n" +"\n" +" Removes the stroke's extremities.\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static int TipRemoverShader___init__( BPy_TipRemoverShader* self, PyObject *args) +{ + double d; + + if(!( PyArg_ParseTuple(args, "d", &d) )) + return -1; + + self->py_ss.ss = new StrokeShaders::TipRemoverShader(d); + return 0; +} + +/*-----------------------BPy_TipRemoverShader type definition ------------------------------*/ + +PyTypeObject TipRemoverShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "TipRemoverShader", /* tp_name */ + sizeof(BPy_TipRemoverShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + TipRemoverShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &StrokeShader_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)TipRemoverShader___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.h new file mode 100644 index 00000000000..a1b2e3988bc --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_TIPREMOVERSHADER_H +#define FREESTYLE_PYTHON_TIPREMOVERSHADER_H + +#include "../BPy_StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject TipRemoverShader_Type; + +#define BPy_TipRemoverShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &TipRemoverShader_Type) ) + +/*---------------------------Python BPy_TipRemoverShader structure definition----------*/ +typedef struct { + BPy_StrokeShader py_ss; +} BPy_TipRemoverShader; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_TIPREMOVERSHADER_H */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_fstreamShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_fstreamShader.cpp new file mode 100644 index 00000000000..2d9828c232c --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_fstreamShader.cpp @@ -0,0 +1,90 @@ +#include "BPy_fstreamShader.h" + +#include "../../stroke/AdvancedStrokeShaders.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char fstreamShader___doc__[] = +"Class hierarchy: :class:`StrokeShader` > :class:`fstreamShader`\n" +"\n" +"[Output shader]\n" +"\n" +".. method:: __init__(iFileName)\n" +"\n" +" Builds a fstreamShader object.\n" +"\n" +" :arg iFileName: The output file name.\n" +" :type iFileName: str\n" +"\n" +".. method:: shade(s)\n" +"\n" +" Streams the Stroke in a file.\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static int fstreamShader___init__( BPy_fstreamShader* self, PyObject *args) +{ + const char *s; + + if(!( PyArg_ParseTuple(args, "s", &s) )) + return -1; + + self->py_ss.ss = new StrokeShaders::fstreamShader(s); + return 0; +} + +/*-----------------------BPy_fstreamShader type definition ------------------------------*/ + +PyTypeObject fstreamShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "fstreamShader", /* tp_name */ + sizeof(BPy_fstreamShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + fstreamShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &StrokeShader_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)fstreamShader___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_fstreamShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_fstreamShader.h new file mode 100644 index 00000000000..843d50505db --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_fstreamShader.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_FSTREAMSHADER_H +#define FREESTYLE_PYTHON_FSTREAMSHADER_H + +#include "../BPy_StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject fstreamShader_Type; + +#define BPy_fstreamShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &fstreamShader_Type) ) + +/*---------------------------Python BPy_fstreamShader structure definition----------*/ +typedef struct { + BPy_StrokeShader py_ss; +} BPy_fstreamShader; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_FSTREAMSHADER_H */ diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_streamShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_streamShader.cpp new file mode 100644 index 00000000000..722c51c440e --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_streamShader.cpp @@ -0,0 +1,84 @@ +#include "BPy_streamShader.h" + +#include "../../stroke/BasicStrokeShaders.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char streamShader___doc__[] = +"Class hierarchy: :class:`StrokeShader` > :class:`streamShader`\n" +"\n" +"[Output shader]\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a streamShader object.\n" +"\n" +".. method:: shade(s)\n" +"\n" +" Streams the Stroke into stdout.\n" +"\n" +" :arg s: A Stroke object.\n" +" :type s: :class:`Stroke`\n"; + +static int streamShader___init__( BPy_streamShader* self, PyObject *args) +{ + if(!( PyArg_ParseTuple(args, "") )) + return -1; + self->py_ss.ss = new StrokeShaders::streamShader(); + return 0; +} + +/*-----------------------BPy_streamShader type definition ------------------------------*/ + +PyTypeObject streamShader_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "streamShader", /* tp_name */ + sizeof(BPy_streamShader), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + streamShader___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &StrokeShader_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)streamShader___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_streamShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_streamShader.h new file mode 100644 index 00000000000..38056d5fa59 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_streamShader.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_STREAMSHADER_H +#define FREESTYLE_PYTHON_STREAMSHADER_H + +#include "../BPy_StrokeShader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject streamShader_Type; + +#define BPy_streamShader_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &streamShader_Type) ) + +/*---------------------------Python BPy_streamShader structure definition----------*/ +typedef struct { + BPy_StrokeShader py_ss; +} BPy_streamShader; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +#endif /* FREESTYLE_PYTHON_STREAMSHADER_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp new file mode 100644 index 00000000000..b61b9baf033 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp @@ -0,0 +1,215 @@ +#include "BPy_UnaryFunction0DDouble.h" + +#include "../BPy_Convert.h" +#include "../Iterator/BPy_Interface0DIterator.h" + +#include "UnaryFunction0D_double/BPy_Curvature2DAngleF0D.h" +#include "UnaryFunction0D_double/BPy_DensityF0D.h" +#include "UnaryFunction0D_double/BPy_GetProjectedXF0D.h" +#include "UnaryFunction0D_double/BPy_GetProjectedYF0D.h" +#include "UnaryFunction0D_double/BPy_GetProjectedZF0D.h" +#include "UnaryFunction0D_double/BPy_GetXF0D.h" +#include "UnaryFunction0D_double/BPy_GetYF0D.h" +#include "UnaryFunction0D_double/BPy_GetZF0D.h" +#include "UnaryFunction0D_double/BPy_LocalAverageDepthF0D.h" +#include "UnaryFunction0D_double/BPy_ZDiscontinuityF0D.h" + +#include "../Director.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- + +int UnaryFunction0DDouble_Init( PyObject *module ) { + + if( module == NULL ) + return -1; + + if( PyType_Ready( &UnaryFunction0DDouble_Type ) < 0 ) + return -1; + Py_INCREF( &UnaryFunction0DDouble_Type ); + PyModule_AddObject(module, "UnaryFunction0DDouble", (PyObject *)&UnaryFunction0DDouble_Type); + + if( PyType_Ready( &DensityF0D_Type ) < 0 ) + return -1; + Py_INCREF( &DensityF0D_Type ); + PyModule_AddObject(module, "DensityF0D", (PyObject *)&DensityF0D_Type); + + if( PyType_Ready( &LocalAverageDepthF0D_Type ) < 0 ) + return -1; + Py_INCREF( &LocalAverageDepthF0D_Type ); + PyModule_AddObject(module, "LocalAverageDepthF0D", (PyObject *)&LocalAverageDepthF0D_Type); + + if( PyType_Ready( &Curvature2DAngleF0D_Type ) < 0 ) + return -1; + Py_INCREF( &Curvature2DAngleF0D_Type ); + PyModule_AddObject(module, "Curvature2DAngleF0D", (PyObject *)&Curvature2DAngleF0D_Type); + + if( PyType_Ready( &GetProjectedXF0D_Type ) < 0 ) + return -1; + Py_INCREF( &GetProjectedXF0D_Type ); + PyModule_AddObject(module, "GetProjectedXF0D", (PyObject *)&GetProjectedXF0D_Type); + + if( PyType_Ready( &GetProjectedYF0D_Type ) < 0 ) + return -1; + Py_INCREF( &GetProjectedYF0D_Type ); + PyModule_AddObject(module, "GetProjectedYF0D", (PyObject *)&GetProjectedYF0D_Type); + + if( PyType_Ready( &GetProjectedZF0D_Type ) < 0 ) + return -1; + Py_INCREF( &GetProjectedZF0D_Type ); + PyModule_AddObject(module, "GetProjectedZF0D", (PyObject *)&GetProjectedZF0D_Type); + + if( PyType_Ready( &GetXF0D_Type ) < 0 ) + return -1; + Py_INCREF( &GetXF0D_Type ); + PyModule_AddObject(module, "GetXF0D", (PyObject *)&GetXF0D_Type); + + if( PyType_Ready( &GetYF0D_Type ) < 0 ) + return -1; + Py_INCREF( &GetYF0D_Type ); + PyModule_AddObject(module, "GetYF0D", (PyObject *)&GetYF0D_Type); + + if( PyType_Ready( &GetZF0D_Type ) < 0 ) + return -1; + Py_INCREF( &GetZF0D_Type ); + PyModule_AddObject(module, "GetZF0D", (PyObject *)&GetZF0D_Type); + + if( PyType_Ready( &ZDiscontinuityF0D_Type ) < 0 ) + return -1; + Py_INCREF( &ZDiscontinuityF0D_Type ); + PyModule_AddObject(module, "ZDiscontinuityF0D", (PyObject *)&ZDiscontinuityF0D_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char UnaryFunction0DDouble___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DDouble`\n" +"\n" +"Base class for unary functions (functors) that work on\n" +":class:`Interface0DIterator` and return a float value.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n"; + +static int UnaryFunction0DDouble___init__(BPy_UnaryFunction0DDouble* self, PyObject *args, PyObject *kwds) +{ + if ( !PyArg_ParseTuple(args, "") ) + return -1; + self->uf0D_double = new UnaryFunction0D<double>(); + self->uf0D_double->py_uf0D = (PyObject *)self; + return 0; +} + +static void UnaryFunction0DDouble___dealloc__(BPy_UnaryFunction0DDouble* self) +{ + if (self->uf0D_double) + delete self->uf0D_double; + UnaryFunction0D_Type.tp_dealloc((PyObject*)self); +} + +static PyObject * UnaryFunction0DDouble___repr__(BPy_UnaryFunction0DDouble* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->uf0D_double->getName().c_str(), self->uf0D_double ); +} + +static char UnaryFunction0DDouble_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the unary 0D predicate.\n" +"\n" +" :return: The name of the unary 0D predicate.\n" +" :rtype: str\n"; + +static PyObject * UnaryFunction0DDouble_getName( BPy_UnaryFunction0DDouble *self ) +{ + return PyUnicode_FromString( self->uf0D_double->getName().c_str() ); +} + +static PyObject * UnaryFunction0DDouble___call__( BPy_UnaryFunction0DDouble *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } + if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) + return NULL; + + if( typeid(*(self->uf0D_double)) == typeid(UnaryFunction0D<double>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); + return NULL; + } + if (self->uf0D_double->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it)) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf0D_double->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return PyFloat_FromDouble( self->uf0D_double->result ); + +} + +/*----------------------UnaryFunction0DDouble instance definitions ----------------------------*/ +static PyMethodDef BPy_UnaryFunction0DDouble_methods[] = { + {"getName", ( PyCFunction ) UnaryFunction0DDouble_getName, METH_NOARGS, UnaryFunction0DDouble_getName___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_UnaryFunction0DDouble type definition ------------------------------*/ + +PyTypeObject UnaryFunction0DDouble_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "UnaryFunction0DDouble", /* tp_name */ + sizeof(BPy_UnaryFunction0DDouble), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)UnaryFunction0DDouble___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)UnaryFunction0DDouble___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)UnaryFunction0DDouble___call__, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + UnaryFunction0DDouble___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_UnaryFunction0DDouble_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)UnaryFunction0DDouble___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.h new file mode 100644 index 00000000000..dbeb70cc082 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.h @@ -0,0 +1,34 @@ +#ifndef FREESTYLE_PYTHON_UNARYFUNCTION0DDOUBLE_H +#define FREESTYLE_PYTHON_UNARYFUNCTION0DDOUBLE_H + +#include "../BPy_UnaryFunction0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject UnaryFunction0DDouble_Type; + +#define BPy_UnaryFunction0DDouble_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &UnaryFunction0DDouble_Type) ) + +/*---------------------------Python BPy_UnaryFunction0DDouble structure definition----------*/ +typedef struct { + BPy_UnaryFunction0D py_uf0D; + UnaryFunction0D<double> *uf0D_double; +} BPy_UnaryFunction0DDouble; + +/*---------------------------Python BPy_UnaryFunction0DDouble visible prototypes-----------*/ +int UnaryFunction0DDouble_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_UNARYFUNCTION0DDOUBLE_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp new file mode 100644 index 00000000000..a5ecd46b3bd --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp @@ -0,0 +1,159 @@ +#include "BPy_UnaryFunction0DEdgeNature.h" + +#include "../BPy_Convert.h" +#include "../Iterator/BPy_Interface0DIterator.h" + +#include "UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- + +int UnaryFunction0DEdgeNature_Init( PyObject *module ) { + + if( module == NULL ) + return -1; + + if( PyType_Ready( &UnaryFunction0DEdgeNature_Type ) < 0 ) + return -1; + Py_INCREF( &UnaryFunction0DEdgeNature_Type ); + PyModule_AddObject(module, "UnaryFunction0DEdgeNature", (PyObject *)&UnaryFunction0DEdgeNature_Type); + + if( PyType_Ready( &CurveNatureF0D_Type ) < 0 ) + return -1; + Py_INCREF( &CurveNatureF0D_Type ); + PyModule_AddObject(module, "CurveNatureF0D", (PyObject *)&CurveNatureF0D_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char UnaryFunction0DEdgeNature___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DEdgeNature`\n" +"\n" +"Base class for unary functions (functors) that work on\n" +":class:`Interface0DIterator` and return a :class:`Nature` object.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n"; + +static int UnaryFunction0DEdgeNature___init__(BPy_UnaryFunction0DEdgeNature* self, PyObject *args, PyObject *kwds) +{ + if ( !PyArg_ParseTuple(args, "") ) + return -1; + self->uf0D_edgenature = new UnaryFunction0D<Nature::EdgeNature>(); + self->uf0D_edgenature->py_uf0D = (PyObject *)self; + return 0; +} + +static void UnaryFunction0DEdgeNature___dealloc__(BPy_UnaryFunction0DEdgeNature* self) +{ + if (self->uf0D_edgenature) + delete self->uf0D_edgenature; + UnaryFunction0D_Type.tp_dealloc((PyObject*)self); +} + +static PyObject * UnaryFunction0DEdgeNature___repr__(BPy_UnaryFunction0DEdgeNature* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->uf0D_edgenature->getName().c_str(), self->uf0D_edgenature ); +} + +static char UnaryFunction0DEdgeNature_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the unary 0D predicate.\n" +"\n" +" :return: The name of the unary 0D predicate.\n" +" :rtype: str\n"; + +static PyObject * UnaryFunction0DEdgeNature_getName( BPy_UnaryFunction0DEdgeNature *self ) +{ + return PyUnicode_FromString( self->uf0D_edgenature->getName().c_str() ); +} + +static PyObject * UnaryFunction0DEdgeNature___call__( BPy_UnaryFunction0DEdgeNature *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } + if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) + return NULL; + + if( typeid(*(self->uf0D_edgenature)) == typeid(UnaryFunction0D<Nature::EdgeNature>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); + return NULL; + } + if (self->uf0D_edgenature->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf0D_edgenature->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return BPy_Nature_from_Nature( self->uf0D_edgenature->result ); + +} + +/*----------------------UnaryFunction0DEdgeNature instance definitions ----------------------------*/ +static PyMethodDef BPy_UnaryFunction0DEdgeNature_methods[] = { + {"getName", ( PyCFunction ) UnaryFunction0DEdgeNature_getName, METH_NOARGS, UnaryFunction0DEdgeNature_getName___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_UnaryFunction0DEdgeNature type definition ------------------------------*/ + +PyTypeObject UnaryFunction0DEdgeNature_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "UnaryFunction0DEdgeNature", /* tp_name */ + sizeof(BPy_UnaryFunction0DEdgeNature), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)UnaryFunction0DEdgeNature___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)UnaryFunction0DEdgeNature___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)UnaryFunction0DEdgeNature___call__, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + UnaryFunction0DEdgeNature___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_UnaryFunction0DEdgeNature_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)UnaryFunction0DEdgeNature___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.h new file mode 100644 index 00000000000..d6959cae57f --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.h @@ -0,0 +1,36 @@ +#ifndef FREESTYLE_PYTHON_UNARYFUNCTION0DEDGENATURE_H +#define FREESTYLE_PYTHON_UNARYFUNCTION0DEDGENATURE_H + +#include "../BPy_UnaryFunction0D.h" + +#include "../../winged_edge/Nature.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject UnaryFunction0DEdgeNature_Type; + +#define BPy_UnaryFunction0DEdgeNature_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &UnaryFunction0DEdgeNature_Type) ) + +/*---------------------------Python BPy_UnaryFunction0DEdgeNature structure definition----------*/ +typedef struct { + BPy_UnaryFunction0D py_uf0D; + UnaryFunction0D<Nature::EdgeNature> *uf0D_edgenature; +} BPy_UnaryFunction0DEdgeNature; + +/*---------------------------Python BPy_UnaryFunction0DEdgeNature visible prototypes-----------*/ +int UnaryFunction0DEdgeNature_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_UNARYFUNCTION0DEDGENATURE_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp new file mode 100644 index 00000000000..72ca2acf3b7 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp @@ -0,0 +1,189 @@ +#include "BPy_UnaryFunction0DFloat.h" + +#include "../BPy_Convert.h" +#include "../Iterator/BPy_Interface0DIterator.h" + +#include "UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.h" +#include "UnaryFunction0D_float/BPy_GetParameterF0D.h" +#include "UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.h" +#include "UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h" +#include "UnaryFunction0D_float/BPy_ReadMapPixelF0D.h" +#include "UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- + +int UnaryFunction0DFloat_Init( PyObject *module ) { + + if( module == NULL ) + return -1; + + if( PyType_Ready( &UnaryFunction0DFloat_Type ) < 0 ) + return -1; + Py_INCREF( &UnaryFunction0DFloat_Type ); + PyModule_AddObject(module, "UnaryFunction0DFloat", (PyObject *)&UnaryFunction0DFloat_Type); + + if( PyType_Ready( &GetCurvilinearAbscissaF0D_Type ) < 0 ) + return -1; + Py_INCREF( &GetCurvilinearAbscissaF0D_Type ); + PyModule_AddObject(module, "GetCurvilinearAbscissaF0D", (PyObject *)&GetCurvilinearAbscissaF0D_Type); + + if( PyType_Ready( &GetParameterF0D_Type ) < 0 ) + return -1; + Py_INCREF( &GetParameterF0D_Type ); + PyModule_AddObject(module, "GetParameterF0D", (PyObject *)&GetParameterF0D_Type); + + if( PyType_Ready( &GetViewMapGradientNormF0D_Type ) < 0 ) + return -1; + Py_INCREF( &GetViewMapGradientNormF0D_Type ); + PyModule_AddObject(module, "GetViewMapGradientNormF0D", (PyObject *)&GetViewMapGradientNormF0D_Type); + + if( PyType_Ready( &ReadCompleteViewMapPixelF0D_Type ) < 0 ) + return -1; + Py_INCREF( &ReadCompleteViewMapPixelF0D_Type ); + PyModule_AddObject(module, "ReadCompleteViewMapPixelF0D", (PyObject *)&ReadCompleteViewMapPixelF0D_Type); + + if( PyType_Ready( &ReadMapPixelF0D_Type ) < 0 ) + return -1; + Py_INCREF( &ReadMapPixelF0D_Type ); + PyModule_AddObject(module, "ReadMapPixelF0D", (PyObject *)&ReadMapPixelF0D_Type); + + if( PyType_Ready( &ReadSteerableViewMapPixelF0D_Type ) < 0 ) + return -1; + Py_INCREF( &ReadSteerableViewMapPixelF0D_Type ); + PyModule_AddObject(module, "ReadSteerableViewMapPixelF0D", (PyObject *)&ReadSteerableViewMapPixelF0D_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char UnaryFunction0DFloat___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DFloat`\n" +"\n" +"Base class for unary functions (functors) that work on\n" +":class:`Interface0DIterator` and return a float value.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n"; + +static int UnaryFunction0DFloat___init__(BPy_UnaryFunction0DFloat* self, PyObject *args, PyObject *kwds) +{ + if ( !PyArg_ParseTuple(args, "") ) + return -1; + self->uf0D_float = new UnaryFunction0D<float>(); + self->uf0D_float->py_uf0D = (PyObject *)self; + return 0; +} + +static void UnaryFunction0DFloat___dealloc__(BPy_UnaryFunction0DFloat* self) +{ + if (self->uf0D_float) + delete self->uf0D_float; + UnaryFunction0D_Type.tp_dealloc((PyObject*)self); +} + +static PyObject * UnaryFunction0DFloat___repr__(BPy_UnaryFunction0DFloat* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->uf0D_float->getName().c_str(), self->uf0D_float ); +} + +static char UnaryFunction0DFloat_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the unary 0D predicate.\n" +"\n" +" :return: The name of the unary 0D predicate.\n" +" :rtype: str\n"; + +static PyObject * UnaryFunction0DFloat_getName( BPy_UnaryFunction0DFloat *self ) +{ + return PyUnicode_FromString( self->uf0D_float->getName().c_str() ); +} + +static PyObject * UnaryFunction0DFloat___call__( BPy_UnaryFunction0DFloat *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } + if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) + return NULL; + + if( typeid(*(self->uf0D_float)) == typeid(UnaryFunction0D<float>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); + return NULL; + } + if (self->uf0D_float->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf0D_float->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return PyFloat_FromDouble( self->uf0D_float->result ); + +} + +/*----------------------UnaryFunction0DFloat instance definitions ----------------------------*/ +static PyMethodDef BPy_UnaryFunction0DFloat_methods[] = { + {"getName", ( PyCFunction ) UnaryFunction0DFloat_getName, METH_NOARGS, UnaryFunction0DFloat_getName___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_UnaryFunction0DFloat type definition ------------------------------*/ + +PyTypeObject UnaryFunction0DFloat_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "UnaryFunction0DFloat", /* tp_name */ + sizeof(BPy_UnaryFunction0DFloat), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)UnaryFunction0DFloat___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)UnaryFunction0DFloat___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)UnaryFunction0DFloat___call__, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + UnaryFunction0DFloat___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_UnaryFunction0DFloat_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)UnaryFunction0DFloat___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.h new file mode 100644 index 00000000000..fbf207d48c7 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.h @@ -0,0 +1,34 @@ +#ifndef FREESTYLE_PYTHON_UNARYFUNCTION0DFLOAT_H +#define FREESTYLE_PYTHON_UNARYFUNCTION0DFLOAT_H + +#include "../BPy_UnaryFunction0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject UnaryFunction0DFloat_Type; + +#define BPy_UnaryFunction0DFloat_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &UnaryFunction0DFloat_Type) ) + +/*---------------------------Python BPy_UnaryFunction0DFloat structure definition----------*/ +typedef struct { + BPy_UnaryFunction0D py_uf0D; + UnaryFunction0D<float> *uf0D_float; +} BPy_UnaryFunction0DFloat; + +/*---------------------------Python BPy_UnaryFunction0DFloat visible prototypes-----------*/ +int UnaryFunction0DFloat_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_UNARYFUNCTION0DFLOAT_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp new file mode 100644 index 00000000000..3c4ccdbcbf1 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp @@ -0,0 +1,158 @@ +#include "BPy_UnaryFunction0DId.h" + +#include "../BPy_Convert.h" +#include "../Iterator/BPy_Interface0DIterator.h" + +#include "UnaryFunction0D_Id/BPy_ShapeIdF0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- + +int UnaryFunction0DId_Init( PyObject *module ) { + + if( module == NULL ) + return -1; + + if( PyType_Ready( &UnaryFunction0DId_Type ) < 0 ) + return -1; + Py_INCREF( &UnaryFunction0DId_Type ); + PyModule_AddObject(module, "UnaryFunction0DId", (PyObject *)&UnaryFunction0DId_Type); + + if( PyType_Ready( &ShapeIdF0D_Type ) < 0 ) + return -1; + Py_INCREF( &ShapeIdF0D_Type ); + PyModule_AddObject(module, "ShapeIdF0D", (PyObject *)&ShapeIdF0D_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char UnaryFunction0DId___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DId`\n" +"\n" +"Base class for unary functions (functors) that work on\n" +":class:`Interface0DIterator` and return an :class:`Id` object.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n"; + +static int UnaryFunction0DId___init__(BPy_UnaryFunction0DId* self, PyObject *args, PyObject *kwds) +{ + if ( !PyArg_ParseTuple(args, "") ) + return -1; + self->uf0D_id = new UnaryFunction0D<Id>(); + self->uf0D_id->py_uf0D = (PyObject *)self; + return 0; +} + +static void UnaryFunction0DId___dealloc__(BPy_UnaryFunction0DId* self) +{ + if (self->uf0D_id) + delete self->uf0D_id; + UnaryFunction0D_Type.tp_dealloc((PyObject*)self); +} + +static PyObject * UnaryFunction0DId___repr__(BPy_UnaryFunction0DId* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->uf0D_id->getName().c_str(), self->uf0D_id ); +} + +static char UnaryFunction0DId_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the unary 0D predicate.\n" +"\n" +" :return: The name of the unary 0D predicate.\n" +" :rtype: str\n"; + +static PyObject * UnaryFunction0DId_getName( BPy_UnaryFunction0DId *self ) +{ + return PyUnicode_FromString( self->uf0D_id->getName().c_str() ); +} + +static PyObject * UnaryFunction0DId___call__( BPy_UnaryFunction0DId *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } + if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) + return NULL; + + if( typeid(*(self->uf0D_id)) == typeid(UnaryFunction0D<Id>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); + return NULL; + } + if (self->uf0D_id->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf0D_id->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return BPy_Id_from_Id( self->uf0D_id->result ); +} + +/*----------------------UnaryFunction0DId instance definitions ----------------------------*/ +static PyMethodDef BPy_UnaryFunction0DId_methods[] = { + {"getName", ( PyCFunction ) UnaryFunction0DId_getName, METH_NOARGS, UnaryFunction0DId_getName___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_UnaryFunction0DId type definition ------------------------------*/ + +PyTypeObject UnaryFunction0DId_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "UnaryFunction0DId", /* tp_name */ + sizeof(BPy_UnaryFunction0DId), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)UnaryFunction0DId___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)UnaryFunction0DId___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)UnaryFunction0DId___call__, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + UnaryFunction0DId___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_UnaryFunction0DId_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)UnaryFunction0DId___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.h new file mode 100644 index 00000000000..159e24e2674 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.h @@ -0,0 +1,36 @@ +#ifndef FREESTYLE_PYTHON_UNARYFUNCTION0DID_H +#define FREESTYLE_PYTHON_UNARYFUNCTION0DID_H + +#include "../BPy_UnaryFunction0D.h" + +#include "../../system/Id.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject UnaryFunction0DId_Type; + +#define BPy_UnaryFunction0DId_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &UnaryFunction0DId_Type) ) + +/*---------------------------Python BPy_UnaryFunction0DId structure definition----------*/ +typedef struct { + BPy_UnaryFunction0D py_uf0D; + UnaryFunction0D<Id> *uf0D_id; +} BPy_UnaryFunction0DId; + +/*---------------------------Python BPy_UnaryFunction0DId visible prototypes-----------*/ +int UnaryFunction0DId_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_UNARYFUNCTION0DID_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp new file mode 100644 index 00000000000..d61453172b9 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp @@ -0,0 +1,160 @@ +#include "BPy_UnaryFunction0DMaterial.h" + +#include "../BPy_Convert.h" +#include "../Iterator/BPy_Interface0DIterator.h" + +#include "UnaryFunction0D_Material/BPy_MaterialF0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- + +int UnaryFunction0DMaterial_Init( PyObject *module ) { + + if( module == NULL ) + return -1; + + if( PyType_Ready( &UnaryFunction0DMaterial_Type ) < 0 ) + return -1; + Py_INCREF( &UnaryFunction0DMaterial_Type ); + PyModule_AddObject(module, "UnaryFunction0DMaterial", (PyObject *)&UnaryFunction0DMaterial_Type); + + if( PyType_Ready( &MaterialF0D_Type ) < 0 ) + return -1; + Py_INCREF( &MaterialF0D_Type ); + PyModule_AddObject(module, "MaterialF0D", (PyObject *)&MaterialF0D_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char UnaryFunction0DMaterial___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DMaterial`\n" +"\n" +"Base class for unary functions (functors) that work on\n" +":class:`Interface0DIterator` and return a :class:`Material` object.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n"; + +static int UnaryFunction0DMaterial___init__(BPy_UnaryFunction0DMaterial* self, PyObject *args, PyObject *kwds) +{ + if ( !PyArg_ParseTuple(args, "") ) + return -1; + self->uf0D_material = new UnaryFunction0D<FrsMaterial>(); + self->uf0D_material->py_uf0D = (PyObject *)self; + return 0; +} + +static void UnaryFunction0DMaterial___dealloc__(BPy_UnaryFunction0DMaterial* self) +{ + if (self->uf0D_material) + delete self->uf0D_material; + UnaryFunction0D_Type.tp_dealloc((PyObject*)self); +} + + +static PyObject * UnaryFunction0DMaterial___repr__(BPy_UnaryFunction0DMaterial* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->uf0D_material->getName().c_str(), self->uf0D_material ); +} + +static char UnaryFunction0DMaterial_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the unary 0D predicate.\n" +"\n" +" :return: The name of the unary 0D predicate.\n" +" :rtype: str\n"; + +static PyObject * UnaryFunction0DMaterial_getName( BPy_UnaryFunction0DMaterial *self ) +{ + return PyUnicode_FromString( self->uf0D_material->getName().c_str() ); +} + +static PyObject * UnaryFunction0DMaterial___call__( BPy_UnaryFunction0DMaterial *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } + if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) + return NULL; + + if( typeid(*(self->uf0D_material)) == typeid(UnaryFunction0D<FrsMaterial>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); + return NULL; + } + if (self->uf0D_material->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf0D_material->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return BPy_FrsMaterial_from_FrsMaterial( self->uf0D_material->result ); + +} + +/*----------------------UnaryFunction0DMaterial instance definitions ----------------------------*/ +static PyMethodDef BPy_UnaryFunction0DMaterial_methods[] = { + {"getName", ( PyCFunction ) UnaryFunction0DMaterial_getName, METH_NOARGS, UnaryFunction0DMaterial_getName___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_UnaryFunction0DMaterial type definition ------------------------------*/ + +PyTypeObject UnaryFunction0DMaterial_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "UnaryFunction0DMaterial", /* tp_name */ + sizeof(BPy_UnaryFunction0DMaterial), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)UnaryFunction0DMaterial___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)UnaryFunction0DMaterial___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)UnaryFunction0DMaterial___call__, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + UnaryFunction0DMaterial___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_UnaryFunction0DMaterial_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)UnaryFunction0DMaterial___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.h new file mode 100644 index 00000000000..02fb2b99ccd --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.h @@ -0,0 +1,36 @@ +#ifndef FREESTYLE_PYTHON_UNARYFUNCTION0DMATERIAL_H +#define FREESTYLE_PYTHON_UNARYFUNCTION0DMATERIAL_H + +#include "../BPy_UnaryFunction0D.h" + +#include "../../scene_graph/FrsMaterial.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject UnaryFunction0DMaterial_Type; + +#define BPy_UnaryFunction0DMaterial_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &UnaryFunction0DMaterial_Type) ) + +/*---------------------------Python BPy_UnaryFunction0DMaterial structure definition----------*/ +typedef struct { + BPy_UnaryFunction0D py_uf0D; + UnaryFunction0D<FrsMaterial> *uf0D_material; +} BPy_UnaryFunction0DMaterial; + +/*---------------------------Python BPy_UnaryFunction0DMaterial visible prototypes-----------*/ +int UnaryFunction0DMaterial_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_UNARYFUNCTION0DMATERIAL_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp new file mode 100644 index 00000000000..37f6a2ab342 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp @@ -0,0 +1,159 @@ +#include "BPy_UnaryFunction0DUnsigned.h" + +#include "../BPy_Convert.h" +#include "../Iterator/BPy_Interface0DIterator.h" + +#include "UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- + +int UnaryFunction0DUnsigned_Init( PyObject *module ) { + + if( module == NULL ) + return -1; + + if( PyType_Ready( &UnaryFunction0DUnsigned_Type ) < 0 ) + return -1; + Py_INCREF( &UnaryFunction0DUnsigned_Type ); + PyModule_AddObject(module, "UnaryFunction0DUnsigned", (PyObject *)&UnaryFunction0DUnsigned_Type); + + if( PyType_Ready( &QuantitativeInvisibilityF0D_Type ) < 0 ) + return -1; + Py_INCREF( &QuantitativeInvisibilityF0D_Type ); + PyModule_AddObject(module, "QuantitativeInvisibilityF0D", (PyObject *)&QuantitativeInvisibilityF0D_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char UnaryFunction0DUnsigned___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DUnsigned`\n" +"\n" +"Base class for unary functions (functors) that work on\n" +":class:`Interface0DIterator` and return an int value.\n" +"\n" +".. method:: __init__()\n" +"\n" + " Default constructor.\n"; + +static int UnaryFunction0DUnsigned___init__(BPy_UnaryFunction0DUnsigned* self, PyObject *args, PyObject *kwds) +{ + if ( !PyArg_ParseTuple(args, "") ) + return -1; + self->uf0D_unsigned = new UnaryFunction0D<unsigned int>(); + self->uf0D_unsigned->py_uf0D = (PyObject *)self; + return 0; +} + +static void UnaryFunction0DUnsigned___dealloc__(BPy_UnaryFunction0DUnsigned* self) +{ + if (self->uf0D_unsigned) + delete self->uf0D_unsigned; + UnaryFunction0D_Type.tp_dealloc((PyObject*)self); +} + +static PyObject * UnaryFunction0DUnsigned___repr__(BPy_UnaryFunction0DUnsigned* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->uf0D_unsigned->getName().c_str(), self->uf0D_unsigned ); +} + +static char UnaryFunction0DUnsigned_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the unary 0D predicate.\n" +"\n" +" :return: The name of the unary 0D predicate.\n" +" :rtype: str\n"; + +static PyObject * UnaryFunction0DUnsigned_getName( BPy_UnaryFunction0DUnsigned *self ) +{ + return PyUnicode_FromString( self->uf0D_unsigned->getName().c_str() ); +} + +static PyObject * UnaryFunction0DUnsigned___call__( BPy_UnaryFunction0DUnsigned *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } + if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) + return NULL; + + if( typeid(*(self->uf0D_unsigned)) == typeid(UnaryFunction0D<unsigned int>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); + return NULL; + } + if (self->uf0D_unsigned->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf0D_unsigned->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return PyLong_FromLong( self->uf0D_unsigned->result ); + +} + +/*----------------------UnaryFunction0DUnsigned instance definitions ----------------------------*/ +static PyMethodDef BPy_UnaryFunction0DUnsigned_methods[] = { + {"getName", ( PyCFunction ) UnaryFunction0DUnsigned_getName, METH_NOARGS, UnaryFunction0DUnsigned_getName___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_UnaryFunction0DUnsigned type definition ------------------------------*/ + +PyTypeObject UnaryFunction0DUnsigned_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "UnaryFunction0DUnsigned", /* tp_name */ + sizeof(BPy_UnaryFunction0DUnsigned), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)UnaryFunction0DUnsigned___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)UnaryFunction0DUnsigned___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)UnaryFunction0DUnsigned___call__, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + UnaryFunction0DUnsigned___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_UnaryFunction0DUnsigned_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)UnaryFunction0DUnsigned___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.h new file mode 100644 index 00000000000..4776ce30918 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.h @@ -0,0 +1,34 @@ +#ifndef FREESTYLE_PYTHON_UNARYFUNCTION0DUNSIGNED_H +#define FREESTYLE_PYTHON_UNARYFUNCTION0DUNSIGNED_H + +#include "../BPy_UnaryFunction0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject UnaryFunction0DUnsigned_Type; + +#define BPy_UnaryFunction0DUnsigned_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &UnaryFunction0DUnsigned_Type) ) + +/*---------------------------Python BPy_UnaryFunction0DUnsigned structure definition----------*/ +typedef struct { + BPy_UnaryFunction0D py_uf0D; + UnaryFunction0D<unsigned int> *uf0D_unsigned; +} BPy_UnaryFunction0DUnsigned; + +/*---------------------------Python BPy_UnaryFunction0DUnsigned visible prototypes-----------*/ +int UnaryFunction0DUnsigned_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_UNARYFUNCTION0DUNSIGNED_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp new file mode 100644 index 00000000000..9c9e2e85568 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp @@ -0,0 +1,165 @@ +#include "BPy_UnaryFunction0DVec2f.h" + +#include "../BPy_Convert.h" +#include "../Iterator/BPy_Interface0DIterator.h" + +#include "UnaryFunction0D_Vec2f/BPy_Normal2DF0D.h" +#include "UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- + +int UnaryFunction0DVec2f_Init( PyObject *module ) { + + if( module == NULL ) + return -1; + + if( PyType_Ready( &UnaryFunction0DVec2f_Type ) < 0 ) + return -1; + Py_INCREF( &UnaryFunction0DVec2f_Type ); + PyModule_AddObject(module, "UnaryFunction0DVec2f", (PyObject *)&UnaryFunction0DVec2f_Type); + + if( PyType_Ready( &Normal2DF0D_Type ) < 0 ) + return -1; + Py_INCREF( &Normal2DF0D_Type ); + PyModule_AddObject(module, "Normal2DF0D", (PyObject *)&Normal2DF0D_Type); + + if( PyType_Ready( &VertexOrientation2DF0D_Type ) < 0 ) + return -1; + Py_INCREF( &VertexOrientation2DF0D_Type ); + PyModule_AddObject(module, "VertexOrientation2DF0D", (PyObject *)&VertexOrientation2DF0D_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char UnaryFunction0DVec2f___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DVec2f`\n" +"\n" +"Base class for unary functions (functors) that work on\n" +":class:`Interface0DIterator` and return a 2D vector.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n"; + +static int UnaryFunction0DVec2f___init__(BPy_UnaryFunction0DVec2f* self, PyObject *args, PyObject *kwds) +{ + if ( !PyArg_ParseTuple(args, "") ) + return -1; + self->uf0D_vec2f = new UnaryFunction0D<Vec2f>(); + self->uf0D_vec2f->py_uf0D = (PyObject *)self; + return 0; +} + +static void UnaryFunction0DVec2f___dealloc__(BPy_UnaryFunction0DVec2f* self) +{ + if (self->uf0D_vec2f) + delete self->uf0D_vec2f; + UnaryFunction0D_Type.tp_dealloc((PyObject*)self); +} + +static PyObject * UnaryFunction0DVec2f___repr__(BPy_UnaryFunction0DVec2f* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->uf0D_vec2f->getName().c_str(), self->uf0D_vec2f ); +} + +static char UnaryFunction0DVec2f_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the unary 0D predicate.\n" +"\n" +" :return: The name of the unary 0D predicate.\n" +" :rtype: str\n"; + +static PyObject * UnaryFunction0DVec2f_getName( BPy_UnaryFunction0DVec2f *self ) +{ + return PyUnicode_FromString( self->uf0D_vec2f->getName().c_str() ); +} + +static PyObject * UnaryFunction0DVec2f___call__( BPy_UnaryFunction0DVec2f *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } + if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) + return NULL; + + if( typeid(*(self->uf0D_vec2f)) == typeid(UnaryFunction0D<Vec2f>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); + return NULL; + } + if (self->uf0D_vec2f->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf0D_vec2f->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return Vector_from_Vec2f( self->uf0D_vec2f->result ); + +} + +/*----------------------UnaryFunction0DVec2f instance definitions ----------------------------*/ +static PyMethodDef BPy_UnaryFunction0DVec2f_methods[] = { + {"getName", ( PyCFunction ) UnaryFunction0DVec2f_getName, METH_NOARGS, UnaryFunction0DVec2f_getName___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_UnaryFunction0DVec2f type definition ------------------------------*/ + +PyTypeObject UnaryFunction0DVec2f_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "UnaryFunction0DVec2f", /* tp_name */ + sizeof(BPy_UnaryFunction0DVec2f), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)UnaryFunction0DVec2f___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)UnaryFunction0DVec2f___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)UnaryFunction0DVec2f___call__, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + UnaryFunction0DVec2f___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_UnaryFunction0DVec2f_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)UnaryFunction0DVec2f___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.h new file mode 100644 index 00000000000..6628d629a41 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.h @@ -0,0 +1,37 @@ +#ifndef FREESTYLE_PYTHON_UNARYFUNCTION0DVEC2F_H +#define FREESTYLE_PYTHON_UNARYFUNCTION0DVEC2F_H + +#include "../BPy_UnaryFunction0D.h" + +#include "../../geometry/Geom.h" +using namespace Geometry; + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject UnaryFunction0DVec2f_Type; + +#define BPy_UnaryFunction0DVec2f_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &UnaryFunction0DVec2f_Type) ) + +/*---------------------------Python BPy_UnaryFunction0DVec2f structure definition----------*/ +typedef struct { + BPy_UnaryFunction0D py_uf0D; + UnaryFunction0D<Vec2f> *uf0D_vec2f; +} BPy_UnaryFunction0DVec2f; + +/*---------------------------Python BPy_UnaryFunction0DVec2f visible prototypes-----------*/ +int UnaryFunction0DVec2f_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_UNARYFUNCTION0DVEC2F_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp new file mode 100644 index 00000000000..13f8dd69fa1 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp @@ -0,0 +1,159 @@ +#include "BPy_UnaryFunction0DVec3f.h" + +#include "../BPy_Convert.h" +#include "../Iterator/BPy_Interface0DIterator.h" + +#include "UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- + +int UnaryFunction0DVec3f_Init( PyObject *module ) { + + if( module == NULL ) + return -1; + + if( PyType_Ready( &UnaryFunction0DVec3f_Type ) < 0 ) + return -1; + Py_INCREF( &UnaryFunction0DVec3f_Type ); + PyModule_AddObject(module, "UnaryFunction0DVec3f", (PyObject *)&UnaryFunction0DVec3f_Type); + + if( PyType_Ready( &VertexOrientation3DF0D_Type ) < 0 ) + return -1; + Py_INCREF( &VertexOrientation3DF0D_Type ); + PyModule_AddObject(module, "VertexOrientation3DF0D", (PyObject *)&VertexOrientation3DF0D_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char UnaryFunction0DVec3f___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DVec3f`\n" +"\n" +"Base class for unary functions (functors) that work on\n" +":class:`Interface0DIterator` and return a 3D vector.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n"; + +static int UnaryFunction0DVec3f___init__(BPy_UnaryFunction0DVec3f* self, PyObject *args, PyObject *kwds) +{ + if ( !PyArg_ParseTuple(args, "") ) + return -1; + self->uf0D_vec3f = new UnaryFunction0D<Vec3f>(); + self->uf0D_vec3f->py_uf0D = (PyObject *)self; + return 0; +} + +static void UnaryFunction0DVec3f___dealloc__(BPy_UnaryFunction0DVec3f* self) +{ + if (self->uf0D_vec3f) + delete self->uf0D_vec3f; + UnaryFunction0D_Type.tp_dealloc((PyObject*)self); +} + +static PyObject * UnaryFunction0DVec3f___repr__(BPy_UnaryFunction0DVec3f* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->uf0D_vec3f->getName().c_str(), self->uf0D_vec3f ); +} + +static char UnaryFunction0DVec3f_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the unary 0D predicate.\n" +"\n" +" :return: The name of the unary 0D predicate.\n" +" :rtype: str\n"; + +static PyObject * UnaryFunction0DVec3f_getName( BPy_UnaryFunction0DVec3f *self ) +{ + return PyUnicode_FromString( self->uf0D_vec3f->getName().c_str() ); +} + +static PyObject * UnaryFunction0DVec3f___call__( BPy_UnaryFunction0DVec3f *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } + if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) + return NULL; + + if( typeid(*(self->uf0D_vec3f)) == typeid(UnaryFunction0D<Vec3f>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); + return NULL; + } + if (self->uf0D_vec3f->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf0D_vec3f->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return Vector_from_Vec3f( self->uf0D_vec3f->result ); + +} + +/*----------------------UnaryFunction0DVec3f instance definitions ----------------------------*/ +static PyMethodDef BPy_UnaryFunction0DVec3f_methods[] = { + {"getName", ( PyCFunction ) UnaryFunction0DVec3f_getName, METH_NOARGS, UnaryFunction0DVec3f_getName___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_UnaryFunction0DVec3f type definition ------------------------------*/ + +PyTypeObject UnaryFunction0DVec3f_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "UnaryFunction0DVec3f", /* tp_name */ + sizeof(BPy_UnaryFunction0DVec3f), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)UnaryFunction0DVec3f___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)UnaryFunction0DVec3f___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)UnaryFunction0DVec3f___call__, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + UnaryFunction0DVec3f___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_UnaryFunction0DVec3f_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)UnaryFunction0DVec3f___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.h new file mode 100644 index 00000000000..47ec89fb179 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.h @@ -0,0 +1,37 @@ +#ifndef FREESTYLE_PYTHON_UNARYFUNCTION0DVEC3F_H +#define FREESTYLE_PYTHON_UNARYFUNCTION0DVEC3F_H + +#include "../BPy_UnaryFunction0D.h" + +#include "../../geometry/Geom.h" +using namespace Geometry; + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject UnaryFunction0DVec3f_Type; + +#define BPy_UnaryFunction0DVec3f_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &UnaryFunction0DVec3f_Type) ) + +/*---------------------------Python BPy_UnaryFunction0DVec3f structure definition----------*/ +typedef struct { + BPy_UnaryFunction0D py_uf0D; + UnaryFunction0D<Vec3f> *uf0D_vec3f; +} BPy_UnaryFunction0DVec3f; + +/*---------------------------Python BPy_UnaryFunction0DVec3f visible prototypes-----------*/ +int UnaryFunction0DVec3f_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_UNARYFUNCTION0DVEC3F_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp new file mode 100644 index 00000000000..40564b018d6 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp @@ -0,0 +1,172 @@ +#include "BPy_UnaryFunction0DVectorViewShape.h" + +#include "../BPy_Convert.h" +#include "../Iterator/BPy_Interface0DIterator.h" + +#include "UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- + +int UnaryFunction0DVectorViewShape_Init( PyObject *module ) { + + if( module == NULL ) + return -1; + + if( PyType_Ready( &UnaryFunction0DVectorViewShape_Type ) < 0 ) + return -1; + Py_INCREF( &UnaryFunction0DVectorViewShape_Type ); + PyModule_AddObject(module, "UnaryFunction0DVectorViewShape", (PyObject *)&UnaryFunction0DVectorViewShape_Type); + + if( PyType_Ready( &GetOccludersF0D_Type ) < 0 ) + return -1; + Py_INCREF( &GetOccludersF0D_Type ); + PyModule_AddObject(module, "GetOccludersF0D", (PyObject *)&GetOccludersF0D_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char UnaryFunction0DVectorViewShape___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DVectorViewShape`\n" +"\n" +"Base class for unary functions (functors) that work on\n" +":class:`Interface0DIterator` and return a list of :class:`ViewShape`\n" +"objects.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n"; + +static int UnaryFunction0DVectorViewShape___init__(BPy_UnaryFunction0DVectorViewShape* self, PyObject *args, PyObject *kwds) +{ + if ( !PyArg_ParseTuple(args, "") ) + return -1; + self->uf0D_vectorviewshape = new UnaryFunction0D< std::vector<ViewShape*> >(); + self->uf0D_vectorviewshape->py_uf0D = (PyObject *)self; + return 0; +} + +static void UnaryFunction0DVectorViewShape___dealloc__(BPy_UnaryFunction0DVectorViewShape* self) +{ + if (self->uf0D_vectorviewshape) + delete self->uf0D_vectorviewshape; + UnaryFunction0D_Type.tp_dealloc((PyObject*)self); +} + +static PyObject * UnaryFunction0DVectorViewShape___repr__(BPy_UnaryFunction0DVectorViewShape* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->uf0D_vectorviewshape->getName().c_str(), self->uf0D_vectorviewshape ); +} + +static char UnaryFunction0DVectorViewShape_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the unary 0D predicate.\n" +"\n" +" :return: The name of the unary 0D predicate.\n" +" :rtype: str\n"; + +static PyObject * UnaryFunction0DVectorViewShape_getName( BPy_UnaryFunction0DVectorViewShape *self ) +{ + return PyUnicode_FromString( self->uf0D_vectorviewshape->getName().c_str() ); +} + +static PyObject * UnaryFunction0DVectorViewShape___call__( BPy_UnaryFunction0DVectorViewShape *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } + if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) + return NULL; + + if( typeid(*(self->uf0D_vectorviewshape)) == typeid(UnaryFunction0D< std::vector<ViewShape*> >) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); + return NULL; + } + if (self->uf0D_vectorviewshape->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf0D_vectorviewshape->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + PyObject *list = PyList_New(0); + PyObject *item; + for( unsigned int i = 0; i < self->uf0D_vectorviewshape->result.size(); i++) { + ViewShape *v = self->uf0D_vectorviewshape->result[i]; + if (v) { + item = BPy_ViewShape_from_ViewShape(*v); + } else { + item = Py_None; + Py_INCREF(item); + } + PyList_Append(list, item); + } + + return list; +} + +/*----------------------UnaryFunction0DVectorViewShape instance definitions ----------------------------*/ +static PyMethodDef BPy_UnaryFunction0DVectorViewShape_methods[] = { + {"getName", ( PyCFunction ) UnaryFunction0DVectorViewShape_getName, METH_NOARGS, UnaryFunction0DVectorViewShape_getName___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_UnaryFunction0DVectorViewShape type definition ------------------------------*/ + +PyTypeObject UnaryFunction0DVectorViewShape_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "UnaryFunction0DVectorViewShape", /* tp_name */ + sizeof(BPy_UnaryFunction0DVectorViewShape), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)UnaryFunction0DVectorViewShape___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)UnaryFunction0DVectorViewShape___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)UnaryFunction0DVectorViewShape___call__, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + UnaryFunction0DVectorViewShape___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_UnaryFunction0DVectorViewShape_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)UnaryFunction0DVectorViewShape___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h new file mode 100644 index 00000000000..77f96e96f20 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h @@ -0,0 +1,37 @@ +#ifndef FREESTYLE_PYTHON_UNARYFUNCTION0DVECTORVIEWSHAPE_H +#define FREESTYLE_PYTHON_UNARYFUNCTION0DVECTORVIEWSHAPE_H + +#include "../BPy_UnaryFunction0D.h" + +#include <vector> +#include "../../view_map/ViewMap.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject UnaryFunction0DVectorViewShape_Type; + +#define BPy_UnaryFunction0DVectorViewShape_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &UnaryFunction0DVectorViewShape_Type) ) + +/*---------------------------Python BPy_UnaryFunction0DVectorViewShape structure definition----------*/ +typedef struct { + BPy_UnaryFunction0D py_uf0D; + UnaryFunction0D< std::vector<ViewShape*> > *uf0D_vectorviewshape; +} BPy_UnaryFunction0DVectorViewShape; + +/*---------------------------Python BPy_UnaryFunction0DVectorViewShape visible prototypes-----------*/ +int UnaryFunction0DVectorViewShape_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_UNARYFUNCTION0DVECTORVIEWSHAPE_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp new file mode 100644 index 00000000000..5f3f18453ba --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp @@ -0,0 +1,165 @@ +#include "BPy_UnaryFunction0DViewShape.h" + +#include "../BPy_Convert.h" +#include "../Iterator/BPy_Interface0DIterator.h" + +#include "UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.h" +#include "UnaryFunction0D_ViewShape/BPy_GetShapeF0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- + +int UnaryFunction0DViewShape_Init( PyObject *module ) { + + if( module == NULL ) + return -1; + + if( PyType_Ready( &UnaryFunction0DViewShape_Type ) < 0 ) + return -1; + Py_INCREF( &UnaryFunction0DViewShape_Type ); + PyModule_AddObject(module, "UnaryFunction0DViewShape", (PyObject *)&UnaryFunction0DViewShape_Type); + + if( PyType_Ready( &GetOccludeeF0D_Type ) < 0 ) + return -1; + Py_INCREF( &GetOccludeeF0D_Type ); + PyModule_AddObject(module, "GetOccludeeF0D", (PyObject *)&GetOccludeeF0D_Type); + + if( PyType_Ready( &GetShapeF0D_Type ) < 0 ) + return -1; + Py_INCREF( &GetShapeF0D_Type ); + PyModule_AddObject(module, "GetShapeF0D", (PyObject *)&GetShapeF0D_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char UnaryFunction0DViewShape___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DViewShape`\n" +"\n" +"Base class for unary functions (functors) that work on\n" +":class:`Interface0DIterator` and return a :class:`ViewShape` object.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n"; + +static int UnaryFunction0DViewShape___init__(BPy_UnaryFunction0DViewShape* self, PyObject *args, PyObject *kwds) +{ + if ( !PyArg_ParseTuple(args, "") ) + return -1; + self->uf0D_viewshape = new UnaryFunction0D<ViewShape*>(); + self->uf0D_viewshape->py_uf0D = (PyObject *)self; + return 0; +} + +static void UnaryFunction0DViewShape___dealloc__(BPy_UnaryFunction0DViewShape* self) +{ + if (self->uf0D_viewshape) + delete self->uf0D_viewshape; + UnaryFunction0D_Type.tp_dealloc((PyObject*)self); +} + +static PyObject * UnaryFunction0DViewShape___repr__(BPy_UnaryFunction0DViewShape* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->uf0D_viewshape->getName().c_str(), self->uf0D_viewshape ); +} + +static char UnaryFunction0DViewShape_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the unary 0D predicate.\n" +"\n" +" :return: The name of the unary 0D predicate.\n" +" :rtype: str\n"; + +static PyObject * UnaryFunction0DViewShape_getName( BPy_UnaryFunction0DViewShape *self ) +{ + return PyUnicode_FromString( self->uf0D_viewshape->getName().c_str() ); +} + +static PyObject * UnaryFunction0DViewShape___call__( BPy_UnaryFunction0DViewShape *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } + if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj)) + return NULL; + + if( typeid(*(self->uf0D_viewshape)) == typeid(UnaryFunction0D<ViewShape*>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); + return NULL; + } + if (self->uf0D_viewshape->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf0D_viewshape->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return BPy_ViewShape_from_ViewShape( *(self->uf0D_viewshape->result) ); + +} + +/*----------------------UnaryFunction0DViewShape instance definitions ----------------------------*/ +static PyMethodDef BPy_UnaryFunction0DViewShape_methods[] = { + {"getName", ( PyCFunction ) UnaryFunction0DViewShape_getName, METH_NOARGS, UnaryFunction0DViewShape_getName___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_UnaryFunction0DViewShape type definition ------------------------------*/ + +PyTypeObject UnaryFunction0DViewShape_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "UnaryFunction0DViewShape", /* tp_name */ + sizeof(BPy_UnaryFunction0DViewShape), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)UnaryFunction0DViewShape___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)UnaryFunction0DViewShape___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)UnaryFunction0DViewShape___call__, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + UnaryFunction0DViewShape___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_UnaryFunction0DViewShape_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)UnaryFunction0DViewShape___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.h new file mode 100644 index 00000000000..68c888eb36b --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.h @@ -0,0 +1,36 @@ +#ifndef FREESTYLE_PYTHON_UNARYFUNCTION0DVIEWSHAPE_H +#define FREESTYLE_PYTHON_UNARYFUNCTION0DVIEWSHAPE_H + +#include "../BPy_UnaryFunction0D.h" + +#include "../../view_map/ViewMap.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject UnaryFunction0DViewShape_Type; + +#define BPy_UnaryFunction0DViewShape_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &UnaryFunction0DViewShape_Type) ) + +/*---------------------------Python BPy_UnaryFunction0DViewShape structure definition----------*/ +typedef struct { + BPy_UnaryFunction0D py_uf0D; + UnaryFunction0D<ViewShape*> *uf0D_viewshape; +} BPy_UnaryFunction0DViewShape; + +/*---------------------------Python BPy_UnaryFunction0DViewShape visible prototypes-----------*/ +int UnaryFunction0DViewShape_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_UNARYFUNCTION0DVIEWSHAPE_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.cpp new file mode 100644 index 00000000000..49e8310380a --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.cpp @@ -0,0 +1,92 @@ +#include "BPy_ShapeIdF0D.h" + +#include "../../../view_map/Functions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ShapeIdF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DId` > :class:`ShapeIdF0D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a ShapeIdF0D object.\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns the :class:`Id` of the Shape the :class:`Interface0D`\n" +" pointed by the Interface0DIterator belongs to. This evaluation can\n" +" be ambiguous (in the case of a :class:`TVertex` for example). This\n" +" functor tries to remove this ambiguity using the context offered by\n" +" the 1D element to which the Interface0DIterator belongs to.\n" +" However, there still can be problematic cases, and the user willing\n" +" to deal with this cases in a specific way should implement its own\n" +" getShapeIdF0D functor.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: The Id of the Shape the pointed Interface0D belongs to.\n" +" :rtype: :class:`Id`\n"; + +static int ShapeIdF0D___init__( BPy_ShapeIdF0D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf0D_id.uf0D_id = new Functions0D::ShapeIdF0D(); + self->py_uf0D_id.uf0D_id->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_ShapeIdF0D type definition ------------------------------*/ + +PyTypeObject ShapeIdF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ShapeIdF0D", /* tp_name */ + sizeof(BPy_ShapeIdF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ShapeIdF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DId_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ShapeIdF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.h new file mode 100644 index 00000000000..11995bb4e88 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_SHAPEIDF0D_H +#define FREESTYLE_PYTHON_SHAPEIDF0D_H + +#include "../BPy_UnaryFunction0DId.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ShapeIdF0D_Type; + +#define BPy_ShapeIdF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ShapeIdF0D_Type) ) + +/*---------------------------Python BPy_ShapeIdF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DId py_uf0D_id; +} BPy_ShapeIdF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_SHAPEIDF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.cpp new file mode 100644 index 00000000000..85ea137134a --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.cpp @@ -0,0 +1,96 @@ +#include "BPy_MaterialF0D.h" + +#include "../../../view_map/Functions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char MaterialF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DMaterial` > :class:`MaterialF0D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a MaterialF0D object.\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns the material of the object evaluated at the\n" +" :class:`Interface0D` pointed by the Interface0DIterator. This\n" +" evaluation can be ambiguous (in the case of a :class:`TVertex` for\n" +" example. This functor tries to remove this ambiguity using the\n" +" context offered by the 1D element to which the Interface0DIterator\n" +" belongs to and by arbitrary chosing the material of the face that\n" +" lies on its left when following the 1D element if there are two\n" +" different materials on each side of the point. However, there\n" +" still can be problematic cases, and the user willing to deal with\n" +" this cases in a specific way should implement its own getMaterial\n" +" functor.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: The material of the object evaluated at the pointed\n" +" Interface0D.\n" +" :rtype: :class:`Material`\n"; + +static int MaterialF0D___init__( BPy_MaterialF0D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf0D_material.uf0D_material = new Functions0D::MaterialF0D(); + self->py_uf0D_material.uf0D_material->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_MaterialF0D type definition ------------------------------*/ + +PyTypeObject MaterialF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "MaterialF0D", /* tp_name */ + sizeof(BPy_MaterialF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + MaterialF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DMaterial_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)MaterialF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.h new file mode 100644 index 00000000000..1ae30484ba5 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_MATERIALF0D_H +#define FREESTYLE_PYTHON_MATERIALF0D_H + +#include "../BPy_UnaryFunction0DMaterial.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject MaterialF0D_Type; + +#define BPy_MaterialF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &MaterialF0D_Type) ) + +/*---------------------------Python BPy_MaterialF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DMaterial py_uf0D_material; +} BPy_MaterialF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_MATERIALF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.cpp new file mode 100644 index 00000000000..0d2023313ca --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.cpp @@ -0,0 +1,87 @@ +#include "BPy_CurveNatureF0D.h" + +#include "../../../view_map/Functions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char CurveNatureF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DEdgeNature` > :class:`CurveNatureF0D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a CurveNatureF0D object.\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns the :class:`Nature` of the 1D element the Interface0D pointed\n" +" by the Interface0DIterator belongs to.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: The nature of the 1D element to which the pointed Interface0D\n" +" belongs.\n" +" :rtype: :class:`Nature`\n"; + +static int CurveNatureF0D___init__( BPy_CurveNatureF0D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf0D_edgenature.uf0D_edgenature = new Functions0D::CurveNatureF0D(); + self->py_uf0D_edgenature.uf0D_edgenature->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_CurveNatureF0D type definition ------------------------------*/ + +PyTypeObject CurveNatureF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "CurveNatureF0D", /* tp_name */ + sizeof(BPy_CurveNatureF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + CurveNatureF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DEdgeNature_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)CurveNatureF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.h new file mode 100644 index 00000000000..63b3050c474 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_CURVENATUREF0D_H +#define FREESTYLE_PYTHON_CURVENATUREF0D_H + +#include "../BPy_UnaryFunction0DEdgeNature.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject CurveNatureF0D_Type; + +#define BPy_CurveNatureF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &CurveNatureF0D_Type) ) + +/*---------------------------Python BPy_CurveNatureF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DEdgeNature py_uf0D_edgenature; +} BPy_CurveNatureF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_CURVENATUREF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.cpp new file mode 100644 index 00000000000..fdec2c324c6 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.cpp @@ -0,0 +1,89 @@ +#include "BPy_Normal2DF0D.h" + +#include "../../../view_map/Functions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char Normal2DF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DVec2f` > :class:`Normal2DF0D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a Normal2DF0D object.\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns a two-dimensional vector giving the normalized 2D normal to\n" +" the 1D element to which the :class:`Interface0D` pointed by the\n" +" Interface0DIterator belongs. The normal is evaluated at the pointed\n" +" Interface0D.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: The 2D normal of the 1D element evaluated at the pointed\n" +" Interface0D.\n" +" :rtype: :class:`mathutils.Vector`\n"; + +static int Normal2DF0D___init__( BPy_Normal2DF0D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf0D_vec2f.uf0D_vec2f = new Functions0D::Normal2DF0D(); + self->py_uf0D_vec2f.uf0D_vec2f->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_Normal2DF0D type definition ------------------------------*/ + +PyTypeObject Normal2DF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "Normal2DF0D", /* tp_name */ + sizeof(BPy_Normal2DF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + Normal2DF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DVec2f_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Normal2DF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.h new file mode 100644 index 00000000000..0b3be2df428 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_NORMAL2DF0D_H +#define FREESTYLE_PYTHON_NORMAL2DF0D_H + +#include "../BPy_UnaryFunction0DVec2f.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject Normal2DF0D_Type; + +#define BPy_Normal2DF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &Normal2DF0D_Type) ) + +/*---------------------------Python BPy_Normal2DF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DVec2f py_uf0D_vec2f; +} BPy_Normal2DF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_NORMAL2DF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.cpp new file mode 100644 index 00000000000..f362293e179 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.cpp @@ -0,0 +1,89 @@ +#include "BPy_VertexOrientation2DF0D.h" + +#include "../../../view_map/Functions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char VertexOrientation2DF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DVec2f` > :class:`VertexOrientation2DF0D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a VertexOrientation2DF0D object.\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns a two-dimensional vector giving the 2D oriented tangent to\n" +" the 1D element to which the :class:`Interface0D` pointed by the\n" +" Interface0DIterator belongs. The 2D oriented tangent is evaluated\n" +" at the pointed Interface0D.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: The 2D oriented tangent to the 1D element evaluated at the\n" +" pointed Interface0D.\n" +" :rtype: :class:`mathutils.Vector`\n"; + +static int VertexOrientation2DF0D___init__( BPy_VertexOrientation2DF0D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf0D_vec2f.uf0D_vec2f = new Functions0D::VertexOrientation2DF0D(); + self->py_uf0D_vec2f.uf0D_vec2f->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_VertexOrientation2DF0D type definition ------------------------------*/ + +PyTypeObject VertexOrientation2DF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "VertexOrientation2DF0D", /* tp_name */ + sizeof(BPy_VertexOrientation2DF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + VertexOrientation2DF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DVec2f_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)VertexOrientation2DF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.h new file mode 100644 index 00000000000..1cce9b592ba --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_VERTEXORIENTATION2DF0D_H +#define FREESTYLE_PYTHON_VERTEXORIENTATION2DF0D_H + +#include "../BPy_UnaryFunction0DVec2f.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject VertexOrientation2DF0D_Type; + +#define BPy_VertexOrientation2DF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &VertexOrientation2DF0D_Type) ) + +/*---------------------------Python BPy_VertexOrientation2DF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DVec2f py_uf0D_vec2f; +} BPy_VertexOrientation2DF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_VERTEXORIENTATION2DF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.cpp new file mode 100644 index 00000000000..8cb3e88efe3 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.cpp @@ -0,0 +1,89 @@ +#include "BPy_VertexOrientation3DF0D.h" + +#include "../../../view_map/Functions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char VertexOrientation3DF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DVec3f` > :class:`VertexOrientation3DF0D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a VertexOrientation3DF0D object.\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns a three-dimensional vector giving the 3D oriented tangent\n" +" to the 1D element to which the :class:`Interface0D` pointed by the\n" +" Interface0DIterator belongs. The 3D oriented tangent is evaluated\n" +" at the pointed Interface0D.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: The 3D oriented tangent to the 1D element evaluated at the\n" +" pointed Interface0D.\n" +" :rtype: :class:`mathutils.Vector`\n"; + +static int VertexOrientation3DF0D___init__( BPy_VertexOrientation3DF0D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf0D_vec3f.uf0D_vec3f = new Functions0D::VertexOrientation3DF0D(); + self->py_uf0D_vec3f.uf0D_vec3f->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_VertexOrientation3DF0D type definition ------------------------------*/ + +PyTypeObject VertexOrientation3DF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "VertexOrientation3DF0D", /* tp_name */ + sizeof(BPy_VertexOrientation3DF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + VertexOrientation3DF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DVec3f_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)VertexOrientation3DF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.h new file mode 100644 index 00000000000..80cac529f0b --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_VERTEXORIENTATION3DF0D_H +#define FREESTYLE_PYTHON_VERTEXORIENTATION3DF0D_H + +#include "../BPy_UnaryFunction0DVec3f.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject VertexOrientation3DF0D_Type; + +#define BPy_VertexOrientation3DF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &VertexOrientation3DF0D_Type) ) + +/*---------------------------Python BPy_VertexOrientation3DF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DVec3f py_uf0D_vec3f; +} BPy_VertexOrientation3DF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_VERTEXORIENTATION3DF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.cpp new file mode 100644 index 00000000000..8bfd2bb2638 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.cpp @@ -0,0 +1,86 @@ +#include "BPy_GetOccludeeF0D.h" + +#include "../../../view_map/Functions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetOccludeeF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DViewShape` > :class:`GetOccludeeF0D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a GetOccludeeF0D object.\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns the :class:`ViewShape` that the Interface0D pointed by the\n" +" Interface0DIterator occludes.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: The ViewShape occluded by the pointed Interface0D.\n" +" :rtype: :class:`ViewShape`\n"; + +static int GetOccludeeF0D___init__( BPy_GetOccludeeF0D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf0D_viewshape.uf0D_viewshape = new Functions0D::GetOccludeeF0D(); + self->py_uf0D_viewshape.uf0D_viewshape->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_GetOccludeeF0D type definition ------------------------------*/ + +PyTypeObject GetOccludeeF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetOccludeeF0D", /* tp_name */ + sizeof(BPy_GetOccludeeF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetOccludeeF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DViewShape_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetOccludeeF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.h new file mode 100644 index 00000000000..fd4f7d92bbb --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETOCCLUDEEF0D_H +#define FREESTYLE_PYTHON_GETOCCLUDEEF0D_H + +#include "../BPy_UnaryFunction0DViewShape.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetOccludeeF0D_Type; + +#define BPy_GetOccludeeF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetOccludeeF0D_Type) ) + +/*---------------------------Python BPy_GetOccludeeF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DViewShape py_uf0D_viewshape; +} BPy_GetOccludeeF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETOCCLUDEEF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.cpp new file mode 100644 index 00000000000..3cc931edec5 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.cpp @@ -0,0 +1,86 @@ +#include "BPy_GetShapeF0D.h" + +#include "../../../view_map/Functions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetShapeF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DViewShape` > :class:`GetShapeF0D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a GetShapeF0D.cpp object.\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns the :class:`ViewShape` containing the Interface0D pointed\n" +" by the Interface0DIterator.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: The ViewShape containing the pointed Interface0D.\n" +" :rtype: :class:`ViewShape`\n"; + +static int GetShapeF0D___init__( BPy_GetShapeF0D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf0D_viewshape.uf0D_viewshape = new Functions0D::GetShapeF0D(); + self->py_uf0D_viewshape.uf0D_viewshape->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_GetShapeF0D type definition ------------------------------*/ + +PyTypeObject GetShapeF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetShapeF0D", /* tp_name */ + sizeof(BPy_GetShapeF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetShapeF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DViewShape_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetShapeF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.h new file mode 100644 index 00000000000..040c753968d --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETSHAPEF0D_H +#define FREESTYLE_PYTHON_GETSHAPEF0D_H + +#include "../BPy_UnaryFunction0DViewShape.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetShapeF0D_Type; + +#define BPy_GetShapeF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetShapeF0D_Type) ) + +/*---------------------------Python BPy_GetShapeF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DViewShape py_uf0D_viewshape; +} BPy_GetShapeF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETSHAPEF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.cpp new file mode 100644 index 00000000000..e28b1ca138a --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.cpp @@ -0,0 +1,89 @@ +#include "BPy_Curvature2DAngleF0D.h" + +#include "../../../view_map/Functions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char Curvature2DAngleF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DDouble` > :class:`Curvature2DAngleF0D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a Curvature2DAngleF0D object.\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns a real value giving the 2D curvature (as an angle) of the\n" +" 1D element to which the :class:`Interface0D` pointed by the\n" +" Interface0DIterator belongs. The 2D curvature is evaluated at the\n" +" Interface0D.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: The 2D curvature of the 1D element evaluated at the\n" +" pointed Interface0D.\n" +" :rtype: float\n"; + +static int Curvature2DAngleF0D___init__( BPy_Curvature2DAngleF0D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf0D_double.uf0D_double = new Functions0D::Curvature2DAngleF0D(); + self->py_uf0D_double.uf0D_double->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_Curvature2DAngleF0D type definition ------------------------------*/ + +PyTypeObject Curvature2DAngleF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "Curvature2DAngleF0D", /* tp_name */ + sizeof(BPy_Curvature2DAngleF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + Curvature2DAngleF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Curvature2DAngleF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.h new file mode 100644 index 00000000000..810ba04db8a --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_CURVATURE2DANGLEF0D_H +#define FREESTYLE_PYTHON_CURVATURE2DANGLEF0D_H + +#include "../BPy_UnaryFunction0DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject Curvature2DAngleF0D_Type; + +#define BPy_Curvature2DAngleF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &Curvature2DAngleF0D_Type) ) + +/*---------------------------Python BPy_Curvature2DAngleF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DDouble py_uf0D_double; +} BPy_Curvature2DAngleF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_CURVATURE2DANGLEF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.cpp new file mode 100644 index 00000000000..64c2d453552 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.cpp @@ -0,0 +1,96 @@ +#include "BPy_DensityF0D.h" + +#include "../../../stroke/AdvancedFunctions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char DensityF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DDouble` > :class:`DensityF0D`\n" +"\n" +".. method:: __init__(sigma=2.0)\n" +"\n" +" Builds a DensityF0D object.\n" +"\n" +" :arg sigma: The gaussian sigma value ndicating the X value for\n" +" which the gaussian function is 0.5. It leads to the window size\n" +" value (the larger, the smoother).\n" +" :type sigma: float\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns the density of the (result) image evaluated at the\n" +" :class:`Interface0D` pointed by the Interface0DIterator. This\n" +" density is evaluated using a pixels square window around the\n" +" evaluation point and integrating these values using a gaussian.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: The density of the image evaluated at the pointed\n" +" Interface0D.\n" +" :rtype: float\n"; + +static int DensityF0D___init__( BPy_DensityF0D* self, PyObject *args) +{ + double d = 2; + + if( !PyArg_ParseTuple(args, "|d", &d) ) + return -1; + self->py_uf0D_double.uf0D_double = new Functions0D::DensityF0D(d); + self->py_uf0D_double.uf0D_double->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_DensityF0D type definition ------------------------------*/ + +PyTypeObject DensityF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "DensityF0D", /* tp_name */ + sizeof(BPy_DensityF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + DensityF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)DensityF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.h new file mode 100644 index 00000000000..17ea95a771c --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_DENSITYF0D_H +#define FREESTYLE_PYTHON_DENSITYF0D_H + +#include "../BPy_UnaryFunction0DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject DensityF0D_Type; + +#define BPy_DensityF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &DensityF0D_Type) ) + +/*---------------------------Python BPy_DensityF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DDouble py_uf0D_double; +} BPy_DensityF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_DENSITYF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.cpp new file mode 100644 index 00000000000..e539ca10dc8 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.cpp @@ -0,0 +1,86 @@ +#include "BPy_GetProjectedXF0D.h" + +#include "../../../view_map/Functions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetProjectedXF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DDouble` > :class:`GetProjectedXF0D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a GetProjectedXF0D object.\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns the X 3D projected coordinate of the :class:`Interface0D`\n" +" pointed by the Interface0DIterator.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: The X 3D projected coordinate of the pointed Interface0D.\n" +" :rtype: float\n"; + +static int GetProjectedXF0D___init__( BPy_GetProjectedXF0D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf0D_double.uf0D_double = new Functions0D::GetProjectedXF0D(); + self->py_uf0D_double.uf0D_double->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_GetProjectedXF0D type definition ------------------------------*/ + +PyTypeObject GetProjectedXF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetProjectedXF0D", /* tp_name */ + sizeof(BPy_GetProjectedXF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetProjectedXF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetProjectedXF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.h new file mode 100644 index 00000000000..da73623cbf0 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETPROJECTEDXF0D_H +#define FREESTYLE_PYTHON_GETPROJECTEDXF0D_H + +#include "../BPy_UnaryFunction0DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetProjectedXF0D_Type; + +#define BPy_GetProjectedXF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetProjectedXF0D_Type) ) + +/*---------------------------Python BPy_GetProjectedXF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DDouble py_uf0D_double; +} BPy_GetProjectedXF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETPROJECTEDXF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.cpp new file mode 100644 index 00000000000..4e1fbbd699c --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.cpp @@ -0,0 +1,86 @@ +#include "BPy_GetProjectedYF0D.h" + +#include "../../../view_map/Functions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetProjectedYF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DDouble` > :class:`GetProjectedYF0D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a GetProjectedYF0D object.\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns the Y 3D projected coordinate of the :class:`Interface0D`\n" +" pointed by the Interface0DIterator.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: The Y 3D projected coordinate of the pointed Interface0D.\n" +" :rtype: float\n"; + +static int GetProjectedYF0D___init__( BPy_GetProjectedYF0D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf0D_double.uf0D_double = new Functions0D::GetProjectedYF0D(); + self->py_uf0D_double.uf0D_double->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_GetProjectedYF0D type definition ------------------------------*/ + +PyTypeObject GetProjectedYF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetProjectedYF0D", /* tp_name */ + sizeof(BPy_GetProjectedYF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetProjectedYF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetProjectedYF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.h new file mode 100644 index 00000000000..3a26e093747 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETPROJECTEDYF0D_H +#define FREESTYLE_PYTHON_GETPROJECTEDYF0D_H + +#include "../BPy_UnaryFunction0DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetProjectedYF0D_Type; + +#define BPy_GetProjectedYF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetProjectedYF0D_Type) ) + +/*---------------------------Python BPy_GetProjectedYF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DDouble py_uf0D_double; +} BPy_GetProjectedYF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETPROJECTEDYF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.cpp new file mode 100644 index 00000000000..73a68b8f6a8 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.cpp @@ -0,0 +1,86 @@ +#include "BPy_GetProjectedZF0D.h" + +#include "../../../view_map/Functions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetProjectedZF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DDouble` > :class:`GetProjectedZF0D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a GetProjectedZF0D object.\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns the Z 3D projected coordinate of the :class:`Interface0D`\n" +" pointed by the Interface0DIterator.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: The Z 3D projected coordinate of the pointed Interface0D.\n" +" :rtype: float\n"; + +static int GetProjectedZF0D___init__( BPy_GetProjectedZF0D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf0D_double.uf0D_double = new Functions0D::GetProjectedZF0D(); + self->py_uf0D_double.uf0D_double->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_GetProjectedZF0D type definition ------------------------------*/ + +PyTypeObject GetProjectedZF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetProjectedZF0D", /* tp_name */ + sizeof(BPy_GetProjectedZF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetProjectedZF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetProjectedZF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.h new file mode 100644 index 00000000000..aa41b70c660 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETPROJECTEDZF0D_H +#define FREESTYLE_PYTHON_GETPROJECTEDZF0D_H + +#include "../BPy_UnaryFunction0DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetProjectedZF0D_Type; + +#define BPy_GetProjectedZF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetProjectedZF0D_Type) ) + +/*---------------------------Python BPy_GetProjectedZF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DDouble py_uf0D_double; +} BPy_GetProjectedZF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETPROJECTEDZF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.cpp new file mode 100644 index 00000000000..099977e35eb --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.cpp @@ -0,0 +1,86 @@ +#include "BPy_GetXF0D.h" + +#include "../../../view_map/Functions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetXF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DDouble` > :class:`GetXF0D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a GetXF0D object.\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns the X 3D coordinate of the :class:`Interface0D` pointed by\n" +" the Interface0DIterator.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: The X 3D coordinate of the pointed Interface0D.\n" +" :rtype: float\n"; + +static int GetXF0D___init__( BPy_GetXF0D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf0D_double.uf0D_double = new Functions0D::GetXF0D(); + self->py_uf0D_double.uf0D_double->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_GetXF0D type definition ------------------------------*/ + +PyTypeObject GetXF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetXF0D", /* tp_name */ + sizeof(BPy_GetXF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetXF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetXF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.h new file mode 100644 index 00000000000..69e9a892f4a --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETXF0D_H +#define FREESTYLE_PYTHON_GETXF0D_H + +#include "../BPy_UnaryFunction0DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetXF0D_Type; + +#define BPy_GetXF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetXF0D_Type) ) + +/*---------------------------Python BPy_GetXF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DDouble py_uf0D_double; +} BPy_GetXF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETXF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.cpp new file mode 100644 index 00000000000..7640dafef6f --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.cpp @@ -0,0 +1,86 @@ +#include "BPy_GetYF0D.h" + +#include "../../../view_map/Functions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetYF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DDouble` > :class:`GetYF0D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a GetYF0D object.\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns the Y 3D coordinate of the :class:`Interface0D` pointed by\n" +" the Interface0DIterator.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: The Y 3D coordinate of the pointed Interface0D.\n" +" :rtype: float\n"; + +static int GetYF0D___init__( BPy_GetYF0D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf0D_double.uf0D_double = new Functions0D::GetYF0D(); + self->py_uf0D_double.uf0D_double->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_GetYF0D type definition ------------------------------*/ + +PyTypeObject GetYF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetYF0D", /* tp_name */ + sizeof(BPy_GetYF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetYF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetYF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.h new file mode 100644 index 00000000000..0601f38585f --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETYF0D_H +#define FREESTYLE_PYTHON_GETYF0D_H + +#include "../BPy_UnaryFunction0DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetYF0D_Type; + +#define BPy_GetYF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetYF0D_Type) ) + +/*---------------------------Python BPy_GetYF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DDouble py_uf0D_double; +} BPy_GetYF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETYF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.cpp new file mode 100644 index 00000000000..01932c2b4ed --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.cpp @@ -0,0 +1,86 @@ +#include "BPy_GetZF0D.h" + +#include "../../../view_map/Functions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetZF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DDouble` > :class:`GetZF0D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a GetZF0D object.\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns the Z 3D coordinate of the :class:`Interface0D` pointed by\n" +" the Interface0DIterator.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: The Z 3D coordinate of the pointed Interface0D.\n" +" :rtype: float\n"; + +static int GetZF0D___init__( BPy_GetZF0D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf0D_double.uf0D_double = new Functions0D::GetZF0D(); + self->py_uf0D_double.uf0D_double->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_GetZF0D type definition ------------------------------*/ + +PyTypeObject GetZF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetZF0D", /* tp_name */ + sizeof(BPy_GetZF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetZF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetZF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.h new file mode 100644 index 00000000000..eac52426600 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETZF0D_H +#define FREESTYLE_PYTHON_GETZF0D_H + +#include "../BPy_UnaryFunction0DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetZF0D_Type; + +#define BPy_GetZF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetZF0D_Type) ) + +/*---------------------------Python BPy_GetZF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DDouble py_uf0D_double; +} BPy_GetZF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETZF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.cpp new file mode 100644 index 00000000000..f268fdf7003 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.cpp @@ -0,0 +1,92 @@ +#include "BPy_LocalAverageDepthF0D.h" + +#include "../../../stroke/AdvancedFunctions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char LocalAverageDepthF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DDouble` > :class:`LocalAverageDepthF0D`\n" +"\n" +".. method:: __init__(maskSize=5.0)\n" +"\n" +" Builds a LocalAverageDepthF0D object.\n" +"\n" +" :arg maskSize: The size of the mask.\n" +" :type maskSize: float\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns the average depth around the :class:`Interface0D` pointed\n" +" by the Interface0DIterator. The result is obtained by querying the\n" +" depth buffer on a window around that point.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: The average depth around the pointed Interface0D.\n" +" :rtype: float\n"; + +static int LocalAverageDepthF0D___init__( BPy_LocalAverageDepthF0D* self, PyObject *args) +{ + double d = 5.0; + + if( !PyArg_ParseTuple(args, "|d", &d) ) + return -1; + self->py_uf0D_double.uf0D_double = new Functions0D::LocalAverageDepthF0D(d); + self->py_uf0D_double.uf0D_double->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_LocalAverageDepthF0D type definition ------------------------------*/ + +PyTypeObject LocalAverageDepthF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "LocalAverageDepthF0D", /* tp_name */ + sizeof(BPy_LocalAverageDepthF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + LocalAverageDepthF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)LocalAverageDepthF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.h new file mode 100644 index 00000000000..7385e1d24c1 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_LOCALAVERAGEDEPTHF0D_H +#define FREESTYLE_PYTHON_LOCALAVERAGEDEPTHF0D_H + +#include "../BPy_UnaryFunction0DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject LocalAverageDepthF0D_Type; + +#define BPy_LocalAverageDepthF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &LocalAverageDepthF0D_Type) ) + +/*---------------------------Python BPy_LocalAverageDepthF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DDouble py_uf0D_double; +} BPy_LocalAverageDepthF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_LOCALAVERAGEDEPTHF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.cpp new file mode 100644 index 00000000000..20e2ab31bda --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.cpp @@ -0,0 +1,91 @@ +#include "BPy_ZDiscontinuityF0D.h" + +#include "../../../view_map/Functions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ZDiscontinuityF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DDouble` > :class:`ZDiscontinuityF0D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a ZDiscontinuityF0D object.\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns a real value giving the distance between the\n" +" :class:`Interface0D` pointed by the Interface0DIterator and the\n" +" shape that lies behind (occludee). This distance is evaluated in\n" +" the camera space and normalized between 0 and 1. Therefore, if no\n" +" oject is occluded by the shape to which the Interface0D belongs to,\n" +" 1 is returned.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: The normalized distance between the pointed Interface0D\n" +" and the occludee.\n" +" :rtype: float\n"; + +static int ZDiscontinuityF0D___init__( BPy_ZDiscontinuityF0D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf0D_double.uf0D_double = new Functions0D::ZDiscontinuityF0D(); + self->py_uf0D_double.uf0D_double->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_ZDiscontinuityF0D type definition ------------------------------*/ + +PyTypeObject ZDiscontinuityF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ZDiscontinuityF0D", /* tp_name */ + sizeof(BPy_ZDiscontinuityF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ZDiscontinuityF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ZDiscontinuityF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.h new file mode 100644 index 00000000000..a26ba4fdbd6 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_ZDISCONTINUITYF0D_H +#define FREESTYLE_PYTHON_ZDISCONTINUITYF0D_H + +#include "../BPy_UnaryFunction0DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ZDiscontinuityF0D_Type; + +#define BPy_ZDiscontinuityF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ZDiscontinuityF0D_Type) ) + +/*---------------------------Python BPy_ZDiscontinuityF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DDouble py_uf0D_double; +} BPy_ZDiscontinuityF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_ZDISCONTINUITYF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.cpp new file mode 100644 index 00000000000..4aaceb3559a --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.cpp @@ -0,0 +1,87 @@ +#include "BPy_GetCurvilinearAbscissaF0D.h" + +#include "../../../view_map/Functions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetCurvilinearAbscissaF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DFloat` > :class:`GetCurvilinearAbscissaF0D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a GetCurvilinearAbscissaF0D object.\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns the curvilinear abscissa of the :class:`Interface0D`\n" +" pointed by the Interface0DIterator in the context of its 1D\n" +" element.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: The curvilinear abscissa of the pointed Interface0D.\n" +" :rtype: float\n"; + +static int GetCurvilinearAbscissaF0D___init__( BPy_GetCurvilinearAbscissaF0D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf0D_float.uf0D_float = new Functions0D::GetCurvilinearAbscissaF0D(); + self->py_uf0D_float.uf0D_float->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_GetCurvilinearAbscissaF0D type definition ------------------------------*/ + +PyTypeObject GetCurvilinearAbscissaF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetCurvilinearAbscissaF0D", /* tp_name */ + sizeof(BPy_GetCurvilinearAbscissaF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetCurvilinearAbscissaF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DFloat_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetCurvilinearAbscissaF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.h new file mode 100644 index 00000000000..0cb56fcec70 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETCURVILINEARABSCISSAF0D_H +#define FREESTYLE_PYTHON_GETCURVILINEARABSCISSAF0D_H + +#include "../BPy_UnaryFunction0DFloat.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetCurvilinearAbscissaF0D_Type; + +#define BPy_GetCurvilinearAbscissaF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetCurvilinearAbscissaF0D_Type) ) + +/*---------------------------Python BPy_GetCurvilinearAbscissaF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DFloat py_uf0D_float; +} BPy_GetCurvilinearAbscissaF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETCURVILINEARABSCISSAF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.cpp new file mode 100644 index 00000000000..aeea47deffc --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.cpp @@ -0,0 +1,86 @@ +#include "BPy_GetParameterF0D.h" + +#include "../../../view_map/Functions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetParameterF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DFloat` > :class:`GetParameterF0D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a GetParameterF0D object.\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns the parameter of the :class:`Interface0D` pointed by the\n" +" Interface0DIterator in the context of its 1D element.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: The parameter of an Interface0D.\n" +" :rtype: float\n"; + +static int GetParameterF0D___init__( BPy_GetParameterF0D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf0D_float.uf0D_float = new Functions0D::GetParameterF0D(); + self->py_uf0D_float.uf0D_float->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_GetParameterF0D type definition ------------------------------*/ + +PyTypeObject GetParameterF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetParameterF0D", /* tp_name */ + sizeof(BPy_GetParameterF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetParameterF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DFloat_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetParameterF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.h new file mode 100644 index 00000000000..4817e5cec86 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETPARAMETERF0D_H +#define FREESTYLE_PYTHON_GETPARAMETERF0D_H + +#include "../BPy_UnaryFunction0DFloat.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetParameterF0D_Type; + +#define BPy_GetParameterF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetParameterF0D_Type) ) + +/*---------------------------Python BPy_GetParameterF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DFloat py_uf0D_float; +} BPy_GetParameterF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETPARAMETERF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.cpp new file mode 100644 index 00000000000..bac65716ba9 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.cpp @@ -0,0 +1,93 @@ +#include "BPy_GetViewMapGradientNormF0D.h" + +#include "../../../stroke/AdvancedFunctions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetViewMapGradientNormF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DFloat` > :class:`GetViewMapGradientNormF0D`\n" +"\n" +".. method:: __init__(level)\n" +"\n" +" Builds a GetViewMapGradientNormF0D object.\n" +"\n" +" :arg level: The level of the pyramid from which the pixel must be\n" +" read.\n" +" :type level: int\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns the norm of the gradient of the global viewmap density\n" +" image.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: The norm of the gradient of the global viewmap density\n" +" image.\n" +" :rtype: float\n"; + +static int GetViewMapGradientNormF0D___init__( BPy_GetViewMapGradientNormF0D* self, PyObject *args) +{ + int i; + + if( !PyArg_ParseTuple(args, "i", &i) ) + return -1; + self->py_uf0D_float.uf0D_float = new Functions0D::GetViewMapGradientNormF0D(i); + self->py_uf0D_float.uf0D_float->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_GetViewMapGradientNormF0D type definition ------------------------------*/ + +PyTypeObject GetViewMapGradientNormF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetViewMapGradientNormF0D", /* tp_name */ + sizeof(BPy_GetViewMapGradientNormF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetViewMapGradientNormF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DFloat_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetViewMapGradientNormF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.h new file mode 100644 index 00000000000..c072ba7f408 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETVIEWMAPGRADIENTNORMF0D_H +#define FREESTYLE_PYTHON_GETVIEWMAPGRADIENTNORMF0D_H + +#include "../BPy_UnaryFunction0DFloat.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetViewMapGradientNormF0D_Type; + +#define BPy_GetViewMapGradientNormF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetViewMapGradientNormF0D_Type) ) + +/*---------------------------Python BPy_GetViewMapGradientNormF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DFloat py_uf0D_float; +} BPy_GetViewMapGradientNormF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETVIEWMAPGRADIENTNORMF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.cpp new file mode 100644 index 00000000000..6a40266cf7b --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.cpp @@ -0,0 +1,91 @@ +#include "BPy_ReadCompleteViewMapPixelF0D.h" + +#include "../../../stroke/AdvancedFunctions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ReadCompleteViewMapPixelF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DFloat` > :class:`ReadCompleteViewMapPixelF0D`\n" +"\n" +".. method:: __init__(level)\n" +"\n" +" Builds a ReadCompleteViewMapPixelF0D object.\n" +"\n" +" :arg level: The level of the pyramid from which the pixel must be\n" +" read.\n" +" :type level: int\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Reads a pixel in one of the level of the complete viewmap.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: A pixel in one of the level of the complete viewmap.\n" +" :rtype: float\n"; + +static int ReadCompleteViewMapPixelF0D___init__( BPy_ReadCompleteViewMapPixelF0D* self, PyObject *args) +{ + int i; + + if( !PyArg_ParseTuple(args, "i", &i) ) + return -1; + self->py_uf0D_float.uf0D_float = new Functions0D::ReadCompleteViewMapPixelF0D(i); + self->py_uf0D_float.uf0D_float->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_ReadCompleteViewMapPixelF0D type definition ------------------------------*/ + +PyTypeObject ReadCompleteViewMapPixelF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ReadCompleteViewMapPixelF0D", /* tp_name */ + sizeof(BPy_ReadCompleteViewMapPixelF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ReadCompleteViewMapPixelF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DFloat_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ReadCompleteViewMapPixelF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h new file mode 100644 index 00000000000..6a10e6c06a4 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_READCOMPLETEVIEWMAPPIXELF0D_H +#define FREESTYLE_PYTHON_READCOMPLETEVIEWMAPPIXELF0D_H + +#include "../BPy_UnaryFunction0DFloat.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ReadCompleteViewMapPixelF0D_Type; + +#define BPy_ReadCompleteViewMapPixelF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ReadCompleteViewMapPixelF0D_Type) ) + +/*---------------------------Python BPy_ReadCompleteViewMapPixelF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DFloat py_uf0D_float; +} BPy_ReadCompleteViewMapPixelF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_READCOMPLETEVIEWMAPPIXELF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.cpp new file mode 100644 index 00000000000..74cf688507e --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.cpp @@ -0,0 +1,94 @@ +#include "BPy_ReadMapPixelF0D.h" + +#include "../../../stroke/AdvancedFunctions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ReadMapPixelF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DFloat` > :class:`ReadMapPixelF0D`\n" +"\n" +".. method:: __init__(iMapName, level)\n" +"\n" +" Builds a ReadMapPixelF0D object.\n" +"\n" +" :arg iMapName: The name of the map to be read.\n" +" :type iMapName: str\n" +" :arg level: The level of the pyramid from which the pixel must be\n" +" read.\n" +" :type level: int\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Reads a pixel in a map.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: A pixel in a map.\n" +" :rtype: float\n"; + +static int ReadMapPixelF0D___init__( BPy_ReadMapPixelF0D* self, PyObject *args) +{ + const char *s; + int i; + + if( !PyArg_ParseTuple(args, "si", &s, &i) ) + return -1; + self->py_uf0D_float.uf0D_float = new Functions0D::ReadMapPixelF0D(s,i); + self->py_uf0D_float.uf0D_float->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_ReadMapPixelF0D type definition ------------------------------*/ + +PyTypeObject ReadMapPixelF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ReadMapPixelF0D", /* tp_name */ + sizeof(BPy_ReadMapPixelF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ReadMapPixelF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DFloat_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ReadMapPixelF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.h new file mode 100644 index 00000000000..9aed0cd82bf --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_READMAPPIXELF0D_H +#define FREESTYLE_PYTHON_READMAPPIXELF0D_H + +#include "../BPy_UnaryFunction0DFloat.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ReadMapPixelF0D_Type; + +#define BPy_ReadMapPixelF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ReadMapPixelF0D_Type) ) + +/*---------------------------Python BPy_ReadMapPixelF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DFloat py_uf0D_float; +} BPy_ReadMapPixelF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_READMAPPIXELF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.cpp new file mode 100644 index 00000000000..db0145e3e2a --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.cpp @@ -0,0 +1,95 @@ +#include "BPy_ReadSteerableViewMapPixelF0D.h" + +#include "../../../stroke/AdvancedFunctions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ReadSteerableViewMapPixelF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DFloat` > :class:`ReadSteerableViewMapPixelF0D`\n" +"\n" +".. method:: __init__(nOrientation, level)\n" +"\n" +" Builds a ReadSteerableViewMapPixelF0D object.\n" +"\n" +" :arg nOrientation: The integer belonging to [0, 4] indicating the\n" +" orientation (E, NE, N, NW) we are interested in.\n" +" :type nOrientation: int\n" +" :arg level: The level of the pyramid from which the pixel must be\n" +" read.\n" +" :type level: int\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Reads a pixel in one of the level of one of the steerable viewmaps.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: A pixel in one of the level of one of the steerable viewmaps.\n" +" :rtype: float\n"; + +static int ReadSteerableViewMapPixelF0D___init__( BPy_ReadSteerableViewMapPixelF0D* self, PyObject *args) +{ + unsigned int u; + int i; + + if( !PyArg_ParseTuple(args, "Ii", &u, &i) ) + return -1; + self->py_uf0D_float.uf0D_float = new Functions0D::ReadSteerableViewMapPixelF0D(u,i); + self->py_uf0D_float.uf0D_float->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_ReadSteerableViewMapPixelF0D type definition ------------------------------*/ + +PyTypeObject ReadSteerableViewMapPixelF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ReadSteerableViewMapPixelF0D", /* tp_name */ + sizeof(BPy_ReadSteerableViewMapPixelF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ReadSteerableViewMapPixelF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DFloat_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ReadSteerableViewMapPixelF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h new file mode 100644 index 00000000000..a881a10f72d --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_READSTEERABLEVIEWMAPPIXELF0D_H +#define FREESTYLE_PYTHON_READSTEERABLEVIEWMAPPIXELF0D_H + +#include "../BPy_UnaryFunction0DFloat.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ReadSteerableViewMapPixelF0D_Type; + +#define BPy_ReadSteerableViewMapPixelF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ReadSteerableViewMapPixelF0D_Type) ) + +/*---------------------------Python BPy_ReadSteerableViewMapPixelF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DFloat py_uf0D_float; +} BPy_ReadSteerableViewMapPixelF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_READSTEERABLEVIEWMAPPIXELF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.cpp new file mode 100644 index 00000000000..e993a99c1d8 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.cpp @@ -0,0 +1,92 @@ +#include "BPy_QuantitativeInvisibilityF0D.h" + +#include "../../../view_map/Functions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char QuantitativeInvisibilityF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DUnsigned` > :class:`QuantitativeInvisibilityF0D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a QuantitativeInvisibilityF0D object.\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns the quantitative invisibility of the :class:`Interface0D`\n" +" pointed by the Interface0DIterator. This evaluation can be\n" +" ambiguous (in the case of a :class:`TVertex` for example). This\n" +" functor tries to remove this ambiguity using the context offered by\n" +" the 1D element to which the Interface0D belongs to. However, there\n" +" still can be problematic cases, and the user willing to deal with\n" +" this cases in a specific way should implement its own getQIF0D\n" +" functor.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: The quantitative invisibility of the pointed Interface0D.\n" +" :rtype: int\n"; + +static int QuantitativeInvisibilityF0D___init__( BPy_QuantitativeInvisibilityF0D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf0D_unsigned.uf0D_unsigned = new Functions0D::QuantitativeInvisibilityF0D(); + self->py_uf0D_unsigned.uf0D_unsigned->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_QuantitativeInvisibilityF0D type definition ------------------------------*/ + +PyTypeObject QuantitativeInvisibilityF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "QuantitativeInvisibilityF0D", /* tp_name */ + sizeof(BPy_QuantitativeInvisibilityF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + QuantitativeInvisibilityF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DUnsigned_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)QuantitativeInvisibilityF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h new file mode 100644 index 00000000000..39b73343608 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_QUANTITATIVEINVISIBILITYF0D_H +#define FREESTYLE_PYTHON_QUANTITATIVEINVISIBILITYF0D_H + +#include "../BPy_UnaryFunction0DUnsigned.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject QuantitativeInvisibilityF0D_Type; + +#define BPy_QuantitativeInvisibilityF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &QuantitativeInvisibilityF0D_Type) ) + +/*---------------------------Python BPy_QuantitativeInvisibilityF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DUnsigned py_uf0D_unsigned; +} BPy_QuantitativeInvisibilityF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_QUANTITATIVEINVISIBILITYF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.cpp new file mode 100644 index 00000000000..50686ce92f9 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.cpp @@ -0,0 +1,87 @@ +#include "BPy_GetOccludersF0D.h" + +#include "../../../view_map/Functions0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetOccludersF0D___doc__[] = +"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DVectorViewShape` > :class:`GetOccludersF0D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a GetOccludersF0D object.\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Returns a list of :class:`ViewShape` objects occluding the\n" +" :class:`Interface0D` pointed by the Interface0DIterator.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: A list of ViewShape objects occluding the pointed\n" +" Interface0D.\n" +" :rtype: list of :class:`ViewShape` objects\n"; + +static int GetOccludersF0D___init__( BPy_GetOccludersF0D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf0D_vectorviewshape.uf0D_vectorviewshape = new Functions0D::GetOccludersF0D(); + self->py_uf0D_vectorviewshape.uf0D_vectorviewshape->py_uf0D = (PyObject *)self; + return 0; +} + +/*-----------------------BPy_GetOccludersF0D type definition ------------------------------*/ + +PyTypeObject GetOccludersF0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetOccludersF0D", /* tp_name */ + sizeof(BPy_GetOccludersF0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetOccludersF0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction0DVectorViewShape_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetOccludersF0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.h new file mode 100644 index 00000000000..0e92158a2e7 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETOCCLUDERSF0D_H +#define FREESTYLE_PYTHON_GETOCCLUDERSF0D_H + +#include "../BPy_UnaryFunction0DVectorViewShape.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetOccludersF0D_Type; + +#define BPy_GetOccludersF0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetOccludersF0D_Type) ) + +/*---------------------------Python BPy_GetOccludersF0D structure definition----------*/ +typedef struct { + BPy_UnaryFunction0DVectorViewShape py_uf0D_vectorviewshape; +} BPy_GetOccludersF0D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETOCCLUDERSF0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp new file mode 100644 index 00000000000..07fb48dd9a8 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp @@ -0,0 +1,289 @@ +#include "BPy_UnaryFunction1DDouble.h" + +#include "../BPy_Convert.h" +#include "../BPy_Interface1D.h" +#include "../BPy_IntegrationType.h" + +#include "UnaryFunction1D_double/BPy_Curvature2DAngleF1D.h" +#include "UnaryFunction1D_double/BPy_DensityF1D.h" +#include "UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h" +#include "UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h" +#include "UnaryFunction1D_double/BPy_GetProjectedXF1D.h" +#include "UnaryFunction1D_double/BPy_GetProjectedYF1D.h" +#include "UnaryFunction1D_double/BPy_GetProjectedZF1D.h" +#include "UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h" +#include "UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.h" +#include "UnaryFunction1D_double/BPy_GetXF1D.h" +#include "UnaryFunction1D_double/BPy_GetYF1D.h" +#include "UnaryFunction1D_double/BPy_GetZF1D.h" +#include "UnaryFunction1D_double/BPy_LocalAverageDepthF1D.h" +#include "UnaryFunction1D_double/BPy_ZDiscontinuityF1D.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- + +int UnaryFunction1DDouble_Init( PyObject *module ) { + + if( module == NULL ) + return -1; + + if( PyType_Ready( &UnaryFunction1DDouble_Type ) < 0 ) + return -1; + Py_INCREF( &UnaryFunction1DDouble_Type ); + PyModule_AddObject(module, "UnaryFunction1DDouble", (PyObject *)&UnaryFunction1DDouble_Type); + + if( PyType_Ready( &DensityF1D_Type ) < 0 ) + return -1; + Py_INCREF( &DensityF1D_Type ); + PyModule_AddObject(module, "DensityF1D", (PyObject *)&DensityF1D_Type); + + if( PyType_Ready( &Curvature2DAngleF1D_Type ) < 0 ) + return -1; + Py_INCREF( &Curvature2DAngleF1D_Type ); + PyModule_AddObject(module, "Curvature2DAngleF1D", (PyObject *)&Curvature2DAngleF1D_Type); + + if( PyType_Ready( &GetCompleteViewMapDensityF1D_Type ) < 0 ) + return -1; + Py_INCREF( &GetCompleteViewMapDensityF1D_Type ); + PyModule_AddObject(module, "GetCompleteViewMapDensityF1D", (PyObject *)&GetCompleteViewMapDensityF1D_Type); + + if( PyType_Ready( &GetDirectionalViewMapDensityF1D_Type ) < 0 ) + return -1; + Py_INCREF( &GetDirectionalViewMapDensityF1D_Type ); + PyModule_AddObject(module, "GetDirectionalViewMapDensityF1D", (PyObject *)&GetDirectionalViewMapDensityF1D_Type); + + if( PyType_Ready( &GetProjectedXF1D_Type ) < 0 ) + return -1; + Py_INCREF( &GetProjectedXF1D_Type ); + PyModule_AddObject(module, "GetProjectedXF1D", (PyObject *)&GetProjectedXF1D_Type); + + if( PyType_Ready( &GetProjectedYF1D_Type ) < 0 ) + return -1; + Py_INCREF( &GetProjectedYF1D_Type ); + PyModule_AddObject(module, "GetProjectedYF1D", (PyObject *)&GetProjectedYF1D_Type); + + if( PyType_Ready( &GetProjectedZF1D_Type ) < 0 ) + return -1; + Py_INCREF( &GetProjectedZF1D_Type ); + PyModule_AddObject(module, "GetProjectedZF1D", (PyObject *)&GetProjectedZF1D_Type); + + if( PyType_Ready( &GetSteerableViewMapDensityF1D_Type ) < 0 ) + return -1; + Py_INCREF( &GetSteerableViewMapDensityF1D_Type ); + PyModule_AddObject(module, "GetSteerableViewMapDensityF1D", (PyObject *)&GetSteerableViewMapDensityF1D_Type); + + if( PyType_Ready( &GetViewMapGradientNormF1D_Type ) < 0 ) + return -1; + Py_INCREF( &GetViewMapGradientNormF1D_Type ); + PyModule_AddObject(module, "GetViewMapGradientNormF1D", (PyObject *)&GetViewMapGradientNormF1D_Type); + + if( PyType_Ready( &GetXF1D_Type ) < 0 ) + return -1; + Py_INCREF( &GetXF1D_Type ); + PyModule_AddObject(module, "GetXF1D", (PyObject *)&GetXF1D_Type); + + if( PyType_Ready( &GetYF1D_Type ) < 0 ) + return -1; + Py_INCREF( &GetYF1D_Type ); + PyModule_AddObject(module, "GetYF1D", (PyObject *)&GetYF1D_Type); + + if( PyType_Ready( &GetZF1D_Type ) < 0 ) + return -1; + Py_INCREF( &GetZF1D_Type ); + PyModule_AddObject(module, "GetZF1D", (PyObject *)&GetZF1D_Type); + + if( PyType_Ready( &LocalAverageDepthF1D_Type ) < 0 ) + return -1; + Py_INCREF( &LocalAverageDepthF1D_Type ); + PyModule_AddObject(module, "LocalAverageDepthF1D", (PyObject *)&LocalAverageDepthF1D_Type); + + if( PyType_Ready( &ZDiscontinuityF1D_Type ) < 0 ) + return -1; + Py_INCREF( &ZDiscontinuityF1D_Type ); + PyModule_AddObject(module, "ZDiscontinuityF1D", (PyObject *)&ZDiscontinuityF1D_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char UnaryFunction1DDouble___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble`\n" +"\n" +"Base class for unary functions (functors) that work on\n" +":class:`Interface1D` and return a float value.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(integration)\n" +"\n" +" Builds a unary 1D function using the integration method given as\n" +" argument.\n" +"\n" +" :arg integration: An integration method.\n" +" :type integration: :class:`IntegrationType`\n"; + +static int UnaryFunction1DDouble___init__(BPy_UnaryFunction1DDouble* self, PyObject *args) +{ + PyObject *obj = 0; + + if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + return -1; + + if( !obj ) + self->uf1D_double = new UnaryFunction1D<double>(); + else { + self->uf1D_double = new UnaryFunction1D<double>( IntegrationType_from_BPy_IntegrationType(obj) ); + } + + self->uf1D_double->py_uf1D = (PyObject *)self; + + return 0; +} + +static void UnaryFunction1DDouble___dealloc__(BPy_UnaryFunction1DDouble* self) +{ + if (self->uf1D_double) + delete self->uf1D_double; + UnaryFunction1D_Type.tp_dealloc((PyObject*)self); +} + +static PyObject * UnaryFunction1DDouble___repr__(BPy_UnaryFunction1DDouble* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_double->getName().c_str(), self->uf1D_double ); +} + +static char UnaryFunction1DDouble_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the unary 1D function.\n" +"\n" +" :return: The name of the unary 1D function.\n" +" :rtype: str\n"; + +static PyObject * UnaryFunction1DDouble_getName( BPy_UnaryFunction1DDouble *self ) +{ + return PyUnicode_FromString( self->uf1D_double->getName().c_str() ); +} + +static PyObject * UnaryFunction1DDouble___call__( BPy_UnaryFunction1DDouble *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } + if( !PyArg_ParseTuple(args, "O!", &Interface1D_Type, &obj) ) + return NULL; + + if( typeid(*(self->uf1D_double)) == typeid(UnaryFunction1D<double>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); + return NULL; + } + if (self->uf1D_double->operator()(*( ((BPy_Interface1D *) obj)->if1D )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf1D_double->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return PyFloat_FromDouble( self->uf1D_double->result ); + +} + +static char UnaryFunction1DDouble_setIntegrationType___doc__[] = +".. method:: setIntegrationType(integration)\n" +"\n" +" Sets the integration method.\n" +"\n" +" :arg integration: An integration method.\n" +" :type integration: :class:`IntegrationType`\n"; + +static PyObject * UnaryFunction1DDouble_setIntegrationType(BPy_UnaryFunction1DDouble* self, PyObject *args) +{ + PyObject *obj; + + if( !PyArg_ParseTuple(args, "O!", &IntegrationType_Type, &obj) ) + return NULL; + + self->uf1D_double->setIntegrationType( IntegrationType_from_BPy_IntegrationType(obj) ); + Py_RETURN_NONE; +} + +static char UnaryFunction1DDouble_getIntegrationType___doc__[] = +".. method:: getIntegrationType(integration)\n" +"\n" +" Returns the integration method.\n" +"\n" +" :return: The integration method.\n" +" :rtype: :class:`IntegrationType`\n"; + +static PyObject * UnaryFunction1DDouble_getIntegrationType(BPy_UnaryFunction1DDouble* self) { + return BPy_IntegrationType_from_IntegrationType( self->uf1D_double->getIntegrationType() ); +} + +/*----------------------UnaryFunction1DDouble instance definitions ----------------------------*/ +static PyMethodDef BPy_UnaryFunction1DDouble_methods[] = { + {"getName", ( PyCFunction ) UnaryFunction1DDouble_getName, METH_NOARGS, UnaryFunction1DDouble_getName___doc__}, + {"setIntegrationType", ( PyCFunction ) UnaryFunction1DDouble_setIntegrationType, METH_VARARGS, UnaryFunction1DDouble_setIntegrationType___doc__}, + {"getIntegrationType", ( PyCFunction ) UnaryFunction1DDouble_getIntegrationType, METH_NOARGS, UnaryFunction1DDouble_getIntegrationType___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_UnaryFunction1DDouble type definition ------------------------------*/ + +PyTypeObject UnaryFunction1DDouble_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "UnaryFunction1DDouble", /* tp_name */ + sizeof(BPy_UnaryFunction1DDouble), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)UnaryFunction1DDouble___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)UnaryFunction1DDouble___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)UnaryFunction1DDouble___call__, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + UnaryFunction1DDouble___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_UnaryFunction1DDouble_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)UnaryFunction1DDouble___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.h new file mode 100644 index 00000000000..9a9170cfe17 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.h @@ -0,0 +1,34 @@ +#ifndef FREESTYLE_PYTHON_UNARYFUNCTION1DDOUBLE_H +#define FREESTYLE_PYTHON_UNARYFUNCTION1DDOUBLE_H + +#include "../BPy_UnaryFunction1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject UnaryFunction1DDouble_Type; + +#define BPy_UnaryFunction1DDouble_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &UnaryFunction1DDouble_Type) ) + +/*---------------------------Python BPy_UnaryFunction1DDouble structure definition----------*/ +typedef struct { + BPy_UnaryFunction1D py_uf1D; + UnaryFunction1D<double> *uf1D_double; +} BPy_UnaryFunction1DDouble; + +/*---------------------------Python BPy_UnaryFunction1DDouble visible prototypes-----------*/ +int UnaryFunction1DDouble_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_UNARYFUNCTION1DDOUBLE_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp new file mode 100644 index 00000000000..4f6a672857a --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp @@ -0,0 +1,210 @@ +#include "BPy_UnaryFunction1DEdgeNature.h" + +#include "../BPy_Convert.h" +#include "../BPy_Interface1D.h" +#include "../BPy_IntegrationType.h" + +#include "UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- + +int UnaryFunction1DEdgeNature_Init( PyObject *module ) { + + if( module == NULL ) + return -1; + + if( PyType_Ready( &UnaryFunction1DEdgeNature_Type ) < 0 ) + return -1; + Py_INCREF( &UnaryFunction1DEdgeNature_Type ); + PyModule_AddObject(module, "UnaryFunction1DEdgeNature", (PyObject *)&UnaryFunction1DEdgeNature_Type); + + if( PyType_Ready( &CurveNatureF1D_Type ) < 0 ) + return -1; + Py_INCREF( &CurveNatureF1D_Type ); + PyModule_AddObject(module, "CurveNatureF1D", (PyObject *)&CurveNatureF1D_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char UnaryFunction1DEdgeNature___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DEdgeNature`\n" +"\n" +"Base class for unary functions (functors) that work on\n" +":class:`Interface1D` and return a :class:`Nature` object.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(integration)\n" +"\n" +" Builds a unary 1D function using the integration method given as\n" +" argument.\n" +"\n" +" :arg integration: An integration method.\n" +" :type integration: :class:`IntegrationType`\n"; + +static int UnaryFunction1DEdgeNature___init__(BPy_UnaryFunction1DEdgeNature* self, PyObject *args) +{ + PyObject *obj = 0; + + if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + return -1; + + if( !obj ) + self->uf1D_edgenature = new UnaryFunction1D<Nature::EdgeNature>(); + else { + self->uf1D_edgenature = new UnaryFunction1D<Nature::EdgeNature>( IntegrationType_from_BPy_IntegrationType(obj) ); + } + + self->uf1D_edgenature->py_uf1D = (PyObject *)self; + + return 0; +} + +static void UnaryFunction1DEdgeNature___dealloc__(BPy_UnaryFunction1DEdgeNature* self) +{ + if (self->uf1D_edgenature) + delete self->uf1D_edgenature; + UnaryFunction1D_Type.tp_dealloc((PyObject*)self); +} + +static PyObject * UnaryFunction1DEdgeNature___repr__(BPy_UnaryFunction1DEdgeNature* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_edgenature->getName().c_str(), self->uf1D_edgenature ); +} + +static char UnaryFunction1DEdgeNature_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the unary 1D function.\n" +"\n" +" :return: The name of the unary 1D function.\n" +" :rtype: str\n"; + +static PyObject * UnaryFunction1DEdgeNature_getName( BPy_UnaryFunction1DEdgeNature *self ) +{ + return PyUnicode_FromString( self->uf1D_edgenature->getName().c_str() ); +} + +static PyObject * UnaryFunction1DEdgeNature___call__( BPy_UnaryFunction1DEdgeNature *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } + if( !PyArg_ParseTuple(args, "O!", &Interface1D_Type, &obj) ) + return NULL; + + if( typeid(*(self->uf1D_edgenature)) == typeid(UnaryFunction1D<Nature::EdgeNature>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); + return NULL; + } + if (self->uf1D_edgenature->operator()(*( ((BPy_Interface1D *) obj)->if1D )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf1D_edgenature->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return BPy_Nature_from_Nature( self->uf1D_edgenature->result ); + +} + +static char UnaryFunction1DEdgeNature_setIntegrationType___doc__[] = +".. method:: setIntegrationType(integration)\n" +"\n" +" Sets the integration method.\n" +"\n" +" :arg integration: An integration method.\n" +" :type integration: :class:`IntegrationType`\n"; + +static PyObject * UnaryFunction1DEdgeNature_setIntegrationType(BPy_UnaryFunction1DEdgeNature* self, PyObject *args) +{ + PyObject *obj; + + if( !PyArg_ParseTuple(args, "O!", &IntegrationType_Type, &obj) ) + return NULL; + + self->uf1D_edgenature->setIntegrationType( IntegrationType_from_BPy_IntegrationType(obj) ); + Py_RETURN_NONE; +} + +static char UnaryFunction1DEdgeNature_getIntegrationType___doc__[] = +".. method:: getIntegrationType(integration)\n" +"\n" +" Returns the integration method.\n" +"\n" +" :return: The integration method.\n" +" :rtype: :class:`IntegrationType`\n"; + +static PyObject * UnaryFunction1DEdgeNature_getIntegrationType(BPy_UnaryFunction1DEdgeNature* self) { + return BPy_IntegrationType_from_IntegrationType( self->uf1D_edgenature->getIntegrationType() ); +} + +/*----------------------UnaryFunction1DEdgeNature instance definitions ----------------------------*/ +static PyMethodDef BPy_UnaryFunction1DEdgeNature_methods[] = { + {"getName", ( PyCFunction ) UnaryFunction1DEdgeNature_getName, METH_NOARGS, UnaryFunction1DEdgeNature_getName___doc__}, + {"setIntegrationType", ( PyCFunction ) UnaryFunction1DEdgeNature_setIntegrationType, METH_VARARGS, UnaryFunction1DEdgeNature_setIntegrationType___doc__}, + {"getIntegrationType", ( PyCFunction ) UnaryFunction1DEdgeNature_getIntegrationType, METH_NOARGS, UnaryFunction1DEdgeNature_getIntegrationType___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_UnaryFunction1DEdgeNature type definition ------------------------------*/ + +PyTypeObject UnaryFunction1DEdgeNature_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "UnaryFunction1DEdgeNature", /* tp_name */ + sizeof(BPy_UnaryFunction1DEdgeNature), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)UnaryFunction1DEdgeNature___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)UnaryFunction1DEdgeNature___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)UnaryFunction1DEdgeNature___call__, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + UnaryFunction1DEdgeNature___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_UnaryFunction1DEdgeNature_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)UnaryFunction1DEdgeNature___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.h new file mode 100644 index 00000000000..05e3e522c4b --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.h @@ -0,0 +1,36 @@ +#ifndef FREESTYLE_PYTHON_UNARYFUNCTION1DEDGENATURE_H +#define FREESTYLE_PYTHON_UNARYFUNCTION1DEDGENATURE_H + +#include "../BPy_UnaryFunction1D.h" + +#include "../../winged_edge/Nature.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject UnaryFunction1DEdgeNature_Type; + +#define BPy_UnaryFunction1DEdgeNature_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &UnaryFunction1DEdgeNature_Type) ) + +/*---------------------------Python BPy_UnaryFunction1DEdgeNature structure definition----------*/ +typedef struct { + BPy_UnaryFunction1D py_uf1D; + UnaryFunction1D<Nature::EdgeNature> *uf1D_edgenature; +} BPy_UnaryFunction1DEdgeNature; + +/*---------------------------Python BPy_UnaryFunction1DEdgeNature visible prototypes-----------*/ +int UnaryFunction1DEdgeNature_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_UNARYFUNCTION1DEDGENATURE_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp new file mode 100644 index 00000000000..9f16ed9ce36 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp @@ -0,0 +1,203 @@ +#include "BPy_UnaryFunction1DFloat.h" + +#include "../BPy_Convert.h" +#include "../BPy_Interface1D.h" +#include "../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- + +int UnaryFunction1DFloat_Init( PyObject *module ) { + + if( module == NULL ) + return -1; + + if( PyType_Ready( &UnaryFunction1DFloat_Type ) < 0 ) + return -1; + Py_INCREF( &UnaryFunction1DFloat_Type ); + PyModule_AddObject(module, "UnaryFunction1DFloat", (PyObject *)&UnaryFunction1DFloat_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char UnaryFunction1DFloat___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DFloat`\n" +"\n" +"Base class for unary functions (functors) that work on\n" +":class:`Interface1D` and return a float value.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(integration)\n" +"\n" +" Builds a unary 1D function using the integration method given as\n" +" argument.\n" +"\n" +" :arg integration: An integration method.\n" +" :type integration: :class:`IntegrationType`\n"; + +static int UnaryFunction1DFloat___init__(BPy_UnaryFunction1DFloat* self, PyObject *args) +{ + PyObject *obj = 0; + + if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + return -1; + + if( !obj ) + self->uf1D_float = new UnaryFunction1D<float>(); + else { + self->uf1D_float = new UnaryFunction1D<float>( IntegrationType_from_BPy_IntegrationType(obj) ); + } + + self->uf1D_float->py_uf1D = (PyObject *)self; + + return 0; +} + +static void UnaryFunction1DFloat___dealloc__(BPy_UnaryFunction1DFloat* self) +{ + if (self->uf1D_float) + delete self->uf1D_float; + UnaryFunction1D_Type.tp_dealloc((PyObject*)self); +} + +static PyObject * UnaryFunction1DFloat___repr__(BPy_UnaryFunction1DFloat* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_float->getName().c_str(), self->uf1D_float ); +} + +static char UnaryFunction1DFloat_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the unary 1D function.\n" +"\n" +" :return: The name of the unary 1D function.\n" +" :rtype: str\n"; + +static PyObject * UnaryFunction1DFloat_getName( BPy_UnaryFunction1DFloat *self ) +{ + return PyUnicode_FromString( self->uf1D_float->getName().c_str() ); +} + +static PyObject * UnaryFunction1DFloat___call__( BPy_UnaryFunction1DFloat *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } + if( !PyArg_ParseTuple(args, "O!", &Interface1D_Type, &obj) ) + return NULL; + + if( typeid(*(self->uf1D_float)) == typeid(UnaryFunction1D<float>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); + return NULL; + } + if (self->uf1D_float->operator()(*( ((BPy_Interface1D *) obj)->if1D )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf1D_float->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return PyFloat_FromDouble( self->uf1D_float->result ); + +} + +static char UnaryFunction1DFloat_setIntegrationType___doc__[] = +".. method:: setIntegrationType(integration)\n" +"\n" +" Sets the integration method.\n" +"\n" +" :arg integration: An integration method.\n" +" :type integration: :class:`IntegrationType`\n"; + +static PyObject * UnaryFunction1DFloat_setIntegrationType(BPy_UnaryFunction1DFloat* self, PyObject *args) +{ + PyObject *obj; + + if( !PyArg_ParseTuple(args, "O!", &IntegrationType_Type, &obj) ) + return NULL; + + self->uf1D_float->setIntegrationType( IntegrationType_from_BPy_IntegrationType(obj) ); + Py_RETURN_NONE; +} + +static char UnaryFunction1DFloat_getIntegrationType___doc__[] = +".. method:: getIntegrationType(integration)\n" +"\n" +" Returns the integration method.\n" +"\n" +" :return: The integration method.\n" +" :rtype: :class:`IntegrationType`\n"; + +static PyObject * UnaryFunction1DFloat_getIntegrationType(BPy_UnaryFunction1DFloat* self) { + return BPy_IntegrationType_from_IntegrationType( self->uf1D_float->getIntegrationType() ); +} + +/*----------------------UnaryFunction1DFloat instance definitions ----------------------------*/ +static PyMethodDef BPy_UnaryFunction1DFloat_methods[] = { + {"getName", ( PyCFunction ) UnaryFunction1DFloat_getName, METH_NOARGS, UnaryFunction1DFloat_getName___doc__}, + {"setIntegrationType", ( PyCFunction ) UnaryFunction1DFloat_setIntegrationType, METH_VARARGS, UnaryFunction1DFloat_setIntegrationType___doc__}, + {"getIntegrationType", ( PyCFunction ) UnaryFunction1DFloat_getIntegrationType, METH_NOARGS, UnaryFunction1DFloat_getIntegrationType___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_UnaryFunction1DFloat type definition ------------------------------*/ + +PyTypeObject UnaryFunction1DFloat_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "UnaryFunction1DFloat", /* tp_name */ + sizeof(BPy_UnaryFunction1DFloat), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)UnaryFunction1DFloat___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)UnaryFunction1DFloat___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)UnaryFunction1DFloat___call__, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + UnaryFunction1DFloat___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_UnaryFunction1DFloat_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)UnaryFunction1DFloat___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.h new file mode 100644 index 00000000000..529b382372e --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.h @@ -0,0 +1,34 @@ +#ifndef FREESTYLE_PYTHON_UNARYFUNCTION1DFLOAT_H +#define FREESTYLE_PYTHON_UNARYFUNCTION1DFLOAT_H + +#include "../BPy_UnaryFunction1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject UnaryFunction1DFloat_Type; + +#define BPy_UnaryFunction1DFloat_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &UnaryFunction1DFloat_Type) ) + +/*---------------------------Python BPy_UnaryFunction1DFloat structure definition----------*/ +typedef struct { + BPy_UnaryFunction1D py_uf1D; + UnaryFunction1D<float> *uf1D_float; +} BPy_UnaryFunction1DFloat; + +/*---------------------------Python BPy_UnaryFunction1DFloat visible prototypes-----------*/ +int UnaryFunction1DFloat_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_UNARYFUNCTION1DFLOAT_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp new file mode 100644 index 00000000000..98615728c63 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp @@ -0,0 +1,210 @@ +#include "BPy_UnaryFunction1DUnsigned.h" + +#include "../BPy_Convert.h" +#include "../BPy_Interface1D.h" +#include "../BPy_IntegrationType.h" + +#include "UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- + +int UnaryFunction1DUnsigned_Init( PyObject *module ) { + + if( module == NULL ) + return -1; + + if( PyType_Ready( &UnaryFunction1DUnsigned_Type ) < 0 ) + return -1; + Py_INCREF( &UnaryFunction1DUnsigned_Type ); + PyModule_AddObject(module, "UnaryFunction1DUnsigned", (PyObject *)&UnaryFunction1DUnsigned_Type); + + if( PyType_Ready( &QuantitativeInvisibilityF1D_Type ) < 0 ) + return -1; + Py_INCREF( &QuantitativeInvisibilityF1D_Type ); + PyModule_AddObject(module, "QuantitativeInvisibilityF1D", (PyObject *)&QuantitativeInvisibilityF1D_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char UnaryFunction1DUnsigned___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DUnsigned`\n" +"\n" +"Base class for unary functions (functors) that work on\n" +":class:`Interface1D` and return an int value.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(integration)\n" +"\n" +" Builds a unary 1D function using the integration method given as\n" +" argument.\n" +"\n" +" :arg integration: An integration method.\n" +" :type integration: :class:`IntegrationType`\n"; + +static int UnaryFunction1DUnsigned___init__(BPy_UnaryFunction1DUnsigned* self, PyObject *args) +{ + PyObject *obj = 0; + + if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + return -1; + + if( !obj ) + self->uf1D_unsigned = new UnaryFunction1D<unsigned int>(); + else { + self->uf1D_unsigned = new UnaryFunction1D<unsigned int>( IntegrationType_from_BPy_IntegrationType(obj) ); + } + + self->uf1D_unsigned->py_uf1D = (PyObject *)self; + + return 0; +} + +static void UnaryFunction1DUnsigned___dealloc__(BPy_UnaryFunction1DUnsigned* self) +{ + if (self->uf1D_unsigned) + delete self->uf1D_unsigned; + UnaryFunction1D_Type.tp_dealloc((PyObject*)self); +} + +static PyObject * UnaryFunction1DUnsigned___repr__(BPy_UnaryFunction1DUnsigned* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_unsigned->getName().c_str(), self->uf1D_unsigned ); +} + +static char UnaryFunction1DUnsigned_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the unary 1D function.\n" +"\n" +" :return: The name of the unary 1D function.\n" +" :rtype: str\n"; + +static PyObject * UnaryFunction1DUnsigned_getName( BPy_UnaryFunction1DUnsigned *self ) +{ + return PyUnicode_FromString( self->uf1D_unsigned->getName().c_str() ); +} + +static PyObject * UnaryFunction1DUnsigned___call__( BPy_UnaryFunction1DUnsigned *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } + if( !PyArg_ParseTuple(args, "O!", &Interface1D_Type, &obj) ) + return NULL; + + if( typeid(*(self->uf1D_unsigned)) == typeid(UnaryFunction1D<unsigned int>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); + return NULL; + } + if (self->uf1D_unsigned->operator()(*( ((BPy_Interface1D *) obj)->if1D )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf1D_unsigned->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return PyLong_FromLong( self->uf1D_unsigned->result ); + +} + +static char UnaryFunction1DUnsigned_setIntegrationType___doc__[] = +".. method:: setIntegrationType(integration)\n" +"\n" +" Sets the integration method.\n" +"\n" +" :arg integration: An integration method.\n" +" :type integration: :class:`IntegrationType`\n"; + +static PyObject * UnaryFunction1DUnsigned_setIntegrationType(BPy_UnaryFunction1DUnsigned* self, PyObject *args) +{ + PyObject *obj; + + if( !PyArg_ParseTuple(args, "O!", &IntegrationType_Type, &obj) ) + return NULL; + + self->uf1D_unsigned->setIntegrationType( IntegrationType_from_BPy_IntegrationType(obj) ); + Py_RETURN_NONE; +} + +static char UnaryFunction1DUnsigned_getIntegrationType___doc__[] = +".. method:: getIntegrationType(integration)\n" +"\n" +" Returns the integration method.\n" +"\n" +" :return: The integration method.\n" +" :rtype: :class:`IntegrationType`\n"; + +static PyObject * UnaryFunction1DUnsigned_getIntegrationType(BPy_UnaryFunction1DUnsigned* self) { + return BPy_IntegrationType_from_IntegrationType( self->uf1D_unsigned->getIntegrationType() ); +} + +/*----------------------UnaryFunction1DUnsigned instance definitions ----------------------------*/ +static PyMethodDef BPy_UnaryFunction1DUnsigned_methods[] = { + {"getName", ( PyCFunction ) UnaryFunction1DUnsigned_getName, METH_NOARGS, UnaryFunction1DUnsigned_getName___doc__}, + {"setIntegrationType", ( PyCFunction ) UnaryFunction1DUnsigned_setIntegrationType, METH_VARARGS, UnaryFunction1DUnsigned_setIntegrationType___doc__}, + {"getIntegrationType", ( PyCFunction ) UnaryFunction1DUnsigned_getIntegrationType, METH_NOARGS, UnaryFunction1DUnsigned_getIntegrationType___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_UnaryFunction1DUnsigned type definition ------------------------------*/ + +PyTypeObject UnaryFunction1DUnsigned_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "UnaryFunction1DUnsigned", /* tp_name */ + sizeof(BPy_UnaryFunction1DUnsigned), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)UnaryFunction1DUnsigned___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)UnaryFunction1DUnsigned___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)UnaryFunction1DUnsigned___call__, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + UnaryFunction1DUnsigned___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_UnaryFunction1DUnsigned_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)UnaryFunction1DUnsigned___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.h new file mode 100644 index 00000000000..c70cc6257a7 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.h @@ -0,0 +1,34 @@ +#ifndef FREESTYLE_PYTHON_UNARYFUNCTION1DUNSIGNED_H +#define FREESTYLE_PYTHON_UNARYFUNCTION1DUNSIGNED_H + +#include "../BPy_UnaryFunction1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject UnaryFunction1DUnsigned_Type; + +#define BPy_UnaryFunction1DUnsigned_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &UnaryFunction1DUnsigned_Type) ) + +/*---------------------------Python BPy_UnaryFunction1DUnsigned structure definition----------*/ +typedef struct { + BPy_UnaryFunction1D py_uf1D; + UnaryFunction1D<unsigned int> *uf1D_unsigned; +} BPy_UnaryFunction1DUnsigned; + +/*---------------------------Python BPy_UnaryFunction1DUnsigned visible prototypes-----------*/ +int UnaryFunction1DUnsigned_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_UNARYFUNCTION1DUNSIGNED_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp new file mode 100644 index 00000000000..9f2c52c6f44 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp @@ -0,0 +1,216 @@ +#include "BPy_UnaryFunction1DVec2f.h" + +#include "../BPy_Convert.h" +#include "../BPy_Interface1D.h" +#include "../BPy_IntegrationType.h" + +#include "UnaryFunction1D_Vec2f/BPy_Normal2DF1D.h" +#include "UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- + +int UnaryFunction1DVec2f_Init( PyObject *module ) { + + if( module == NULL ) + return -1; + + if( PyType_Ready( &UnaryFunction1DVec2f_Type ) < 0 ) + return -1; + Py_INCREF( &UnaryFunction1DVec2f_Type ); + PyModule_AddObject(module, "UnaryFunction1DVec2f", (PyObject *)&UnaryFunction1DVec2f_Type); + + if( PyType_Ready( &Normal2DF1D_Type ) < 0 ) + return -1; + Py_INCREF( &Normal2DF1D_Type ); + PyModule_AddObject(module, "Normal2DF1D", (PyObject *)&Normal2DF1D_Type); + + if( PyType_Ready( &Orientation2DF1D_Type ) < 0 ) + return -1; + Py_INCREF( &Orientation2DF1D_Type ); + PyModule_AddObject(module, "Orientation2DF1D", (PyObject *)&Orientation2DF1D_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char UnaryFunction1DVec2f___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DVec2f`\n" +"\n" +"Base class for unary functions (functors) that work on\n" +":class:`Interface1D` and return a 2D vector.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(integration)\n" +"\n" +" Builds a unary 1D function using the integration method given as\n" +" argument.\n" +"\n" +" :arg integration: An integration method.\n" +" :type integration: :class:`IntegrationType`\n"; + +static int UnaryFunction1DVec2f___init__(BPy_UnaryFunction1DVec2f* self, PyObject *args) +{ + PyObject *obj = 0; + + if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + return -1; + + if( !obj ) + self->uf1D_vec2f = new UnaryFunction1D<Vec2f>(); + else { + self->uf1D_vec2f = new UnaryFunction1D<Vec2f>( IntegrationType_from_BPy_IntegrationType(obj) ); + } + + self->uf1D_vec2f->py_uf1D = (PyObject *)self; + + return 0; +} + +static void UnaryFunction1DVec2f___dealloc__(BPy_UnaryFunction1DVec2f* self) +{ + if (self->uf1D_vec2f) + delete self->uf1D_vec2f; + UnaryFunction1D_Type.tp_dealloc((PyObject*)self); +} + +static PyObject * UnaryFunction1DVec2f___repr__(BPy_UnaryFunction1DVec2f* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_vec2f->getName().c_str(), self->uf1D_vec2f ); +} + +static char UnaryFunction1DVec2f_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the unary 1D function.\n" +"\n" +" :return: The name of the unary 1D function.\n" +" :rtype: str\n"; + +static PyObject * UnaryFunction1DVec2f_getName( BPy_UnaryFunction1DVec2f *self ) +{ + return PyUnicode_FromString( self->uf1D_vec2f->getName().c_str() ); +} + +static PyObject * UnaryFunction1DVec2f___call__( BPy_UnaryFunction1DVec2f *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } + if( !PyArg_ParseTuple(args, "O!", &Interface1D_Type, &obj) ) + return NULL; + + if( typeid(*(self->uf1D_vec2f)) == typeid(UnaryFunction1D<Vec2f>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); + return NULL; + } + if (self->uf1D_vec2f->operator()(*( ((BPy_Interface1D *) obj)->if1D )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf1D_vec2f->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return Vector_from_Vec2f( self->uf1D_vec2f->result ); + +} + +static char UnaryFunction1DVec2f_setIntegrationType___doc__[] = +".. method:: setIntegrationType(integration)\n" +"\n" +" Sets the integration method.\n" +"\n" +" :arg integration: An integration method.\n" +" :type integration: :class:`IntegrationType`\n"; + +static PyObject * UnaryFunction1DVec2f_setIntegrationType(BPy_UnaryFunction1DVec2f* self, PyObject *args) +{ + PyObject *obj; + + if( !PyArg_ParseTuple(args, "O!", &IntegrationType_Type, &obj) ) + return NULL; + + self->uf1D_vec2f->setIntegrationType( IntegrationType_from_BPy_IntegrationType(obj) ); + Py_RETURN_NONE; +} + +static char UnaryFunction1DVec2f_getIntegrationType___doc__[] = +".. method:: getIntegrationType(integration)\n" +"\n" +" Returns the integration method.\n" +"\n" +" :return: The integration method.\n" +" :rtype: :class:`IntegrationType`\n"; + +static PyObject * UnaryFunction1DVec2f_getIntegrationType(BPy_UnaryFunction1DVec2f* self) { + return BPy_IntegrationType_from_IntegrationType( self->uf1D_vec2f->getIntegrationType() ); +} + +/*----------------------UnaryFunction1DVec2f instance definitions ----------------------------*/ +static PyMethodDef BPy_UnaryFunction1DVec2f_methods[] = { + {"getName", ( PyCFunction ) UnaryFunction1DVec2f_getName, METH_NOARGS, UnaryFunction1DVec2f_getName___doc__}, + {"setIntegrationType", ( PyCFunction ) UnaryFunction1DVec2f_setIntegrationType, METH_VARARGS, UnaryFunction1DVec2f_setIntegrationType___doc__}, + {"getIntegrationType", ( PyCFunction ) UnaryFunction1DVec2f_getIntegrationType, METH_NOARGS, UnaryFunction1DVec2f_getIntegrationType___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_UnaryFunction1DVec2f type definition ------------------------------*/ + +PyTypeObject UnaryFunction1DVec2f_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "UnaryFunction1DVec2f", /* tp_name */ + sizeof(BPy_UnaryFunction1DVec2f), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)UnaryFunction1DVec2f___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)UnaryFunction1DVec2f___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)UnaryFunction1DVec2f___call__, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + UnaryFunction1DVec2f___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_UnaryFunction1DVec2f_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)UnaryFunction1DVec2f___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.h new file mode 100644 index 00000000000..64a616e211a --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.h @@ -0,0 +1,37 @@ +#ifndef FREESTYLE_PYTHON_UNARYFUNCTION1DVEC2F_H +#define FREESTYLE_PYTHON_UNARYFUNCTION1DVEC2F_H + +#include "../BPy_UnaryFunction1D.h" + +#include "../../geometry/Geom.h" +using namespace Geometry; + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject UnaryFunction1DVec2f_Type; + +#define BPy_UnaryFunction1DVec2f_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &UnaryFunction1DVec2f_Type) ) + +/*---------------------------Python BPy_UnaryFunction1DVec2f structure definition----------*/ +typedef struct { + BPy_UnaryFunction1D py_uf1D; + UnaryFunction1D<Vec2f> *uf1D_vec2f; +} BPy_UnaryFunction1DVec2f; + +/*---------------------------Python BPy_UnaryFunction1DVec2f visible prototypes-----------*/ +int UnaryFunction1DVec2f_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_UNARYFUNCTION1DVEC2F_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp new file mode 100644 index 00000000000..67a7955f0d5 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp @@ -0,0 +1,210 @@ +#include "BPy_UnaryFunction1DVec3f.h" + +#include "../BPy_Convert.h" +#include "../BPy_Interface1D.h" +#include "../BPy_IntegrationType.h" + +#include "UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- + +int UnaryFunction1DVec3f_Init( PyObject *module ) { + + if( module == NULL ) + return -1; + + if( PyType_Ready( &UnaryFunction1DVec3f_Type ) < 0 ) + return -1; + Py_INCREF( &UnaryFunction1DVec3f_Type ); + PyModule_AddObject(module, "UnaryFunction1DVec3f", (PyObject *)&UnaryFunction1DVec3f_Type); + + if( PyType_Ready( &Orientation3DF1D_Type ) < 0 ) + return -1; + Py_INCREF( &Orientation3DF1D_Type ); + PyModule_AddObject(module, "Orientation3DF1D", (PyObject *)&Orientation3DF1D_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char UnaryFunction1DVec3f___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DVec3f`\n" +"\n" +"Base class for unary functions (functors) that work on\n" +":class:`Interface1D` and return a 3D vector.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(integration)\n" +"\n" +" Builds a unary 1D function using the integration method given as\n" +" argument.\n" +"\n" +" :arg integration: An integration method.\n" +" :type integration: :class:`IntegrationType`\n"; + +int UnaryFunction1DVec3f___init__(BPy_UnaryFunction1DVec3f* self, PyObject *args) +{ + PyObject *obj = 0; + + if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + return -1; + + if( !obj ) + self->uf1D_vec3f = new UnaryFunction1D<Vec3f>(); + else { + self->uf1D_vec3f = new UnaryFunction1D<Vec3f>( IntegrationType_from_BPy_IntegrationType(obj) ); + } + + self->uf1D_vec3f->py_uf1D = (PyObject *)self; + + return 0; +} +void UnaryFunction1DVec3f___dealloc__(BPy_UnaryFunction1DVec3f* self) +{ + if (self->uf1D_vec3f) + delete self->uf1D_vec3f; + UnaryFunction1D_Type.tp_dealloc((PyObject*)self); +} + + +PyObject * UnaryFunction1DVec3f___repr__(BPy_UnaryFunction1DVec3f* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_vec3f->getName().c_str(), self->uf1D_vec3f ); +} + +static char UnaryFunction1DVec3f_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the unary 1D function.\n" +"\n" +" :return: The name of the unary 1D function.\n" +" :rtype: str\n"; + +PyObject * UnaryFunction1DVec3f_getName( BPy_UnaryFunction1DVec3f *self ) +{ + return PyUnicode_FromString( self->uf1D_vec3f->getName().c_str() ); +} + +PyObject * UnaryFunction1DVec3f___call__( BPy_UnaryFunction1DVec3f *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } + if( !PyArg_ParseTuple(args, "O!", &Interface1D_Type, &obj) ) + return NULL; + + if( typeid(*(self->uf1D_vec3f)) == typeid(UnaryFunction1D<Vec3f>) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); + return NULL; + } + if (self->uf1D_vec3f->operator()(*( ((BPy_Interface1D *) obj)->if1D )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf1D_vec3f->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + return Vector_from_Vec3f( self->uf1D_vec3f->result ); + +} + +static char UnaryFunction1DVec3f_setIntegrationType___doc__[] = +".. method:: setIntegrationType(integration)\n" +"\n" +" Sets the integration method.\n" +"\n" +" :arg integration: An integration method.\n" +" :type integration: :class:`IntegrationType`\n"; + +PyObject * UnaryFunction1DVec3f_setIntegrationType(BPy_UnaryFunction1DVec3f* self, PyObject *args) +{ + PyObject *obj; + + if( !PyArg_ParseTuple(args, "O!", &IntegrationType_Type, &obj) ) + return NULL; + + self->uf1D_vec3f->setIntegrationType( IntegrationType_from_BPy_IntegrationType(obj) ); + Py_RETURN_NONE; +} + +static char UnaryFunction1DVec3f_getIntegrationType___doc__[] = +".. method:: getIntegrationType(integration)\n" +"\n" +" Returns the integration method.\n" +"\n" +" :return: The integration method.\n" +" :rtype: :class:`IntegrationType`\n"; + +PyObject * UnaryFunction1DVec3f_getIntegrationType(BPy_UnaryFunction1DVec3f* self) { + return BPy_IntegrationType_from_IntegrationType( self->uf1D_vec3f->getIntegrationType() ); +} + +/*----------------------UnaryFunction1DVec3f instance definitions ----------------------------*/ +static PyMethodDef BPy_UnaryFunction1DVec3f_methods[] = { + {"getName", ( PyCFunction ) UnaryFunction1DVec3f_getName, METH_NOARGS, UnaryFunction1DVec3f_getName___doc__}, + {"setIntegrationType", ( PyCFunction ) UnaryFunction1DVec3f_setIntegrationType, METH_VARARGS, UnaryFunction1DVec3f_setIntegrationType___doc__}, + {"getIntegrationType", ( PyCFunction ) UnaryFunction1DVec3f_getIntegrationType, METH_NOARGS, UnaryFunction1DVec3f_getIntegrationType___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_UnaryFunction1DVec3f type definition ------------------------------*/ + +PyTypeObject UnaryFunction1DVec3f_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "UnaryFunction1DVec3f", /* tp_name */ + sizeof(BPy_UnaryFunction1DVec3f), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)UnaryFunction1DVec3f___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)UnaryFunction1DVec3f___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)UnaryFunction1DVec3f___call__, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + UnaryFunction1DVec3f___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_UnaryFunction1DVec3f_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)UnaryFunction1DVec3f___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.h new file mode 100644 index 00000000000..7730271fc09 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.h @@ -0,0 +1,37 @@ +#ifndef FREESTYLE_PYTHON_UNARYFUNCTION1DVEC3F_H +#define FREESTYLE_PYTHON_UNARYFUNCTION1DVEC3F_H + +#include "../BPy_UnaryFunction1D.h" + +#include "../../geometry/Geom.h" +using namespace Geometry; + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject UnaryFunction1DVec3f_Type; + +#define BPy_UnaryFunction1DVec3f_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &UnaryFunction1DVec3f_Type) ) + +/*---------------------------Python BPy_UnaryFunction1DVec3f structure definition----------*/ +typedef struct { + BPy_UnaryFunction1D py_uf1D; + UnaryFunction1D<Vec3f> *uf1D_vec3f; +} BPy_UnaryFunction1DVec3f; + +/*---------------------------Python BPy_UnaryFunction1DVec3f visible prototypes-----------*/ +int UnaryFunction1DVec3f_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_UNARYFUNCTION1DVEC3F_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp new file mode 100644 index 00000000000..5555f401cbf --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp @@ -0,0 +1,235 @@ +#include "BPy_UnaryFunction1DVectorViewShape.h" + +#include "../BPy_Convert.h" +#include "../BPy_Interface1D.h" +#include "../BPy_IntegrationType.h" + +#include "UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.h" +#include "UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.h" +#include "UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- + +int UnaryFunction1DVectorViewShape_Init( PyObject *module ) { + + if( module == NULL ) + return -1; + + if( PyType_Ready( &UnaryFunction1DVectorViewShape_Type ) < 0 ) + return -1; + Py_INCREF( &UnaryFunction1DVectorViewShape_Type ); + PyModule_AddObject(module, "UnaryFunction1DVectorViewShape", (PyObject *)&UnaryFunction1DVectorViewShape_Type); + + if( PyType_Ready( &GetOccludeeF1D_Type ) < 0 ) + return -1; + Py_INCREF( &GetOccludeeF1D_Type ); + PyModule_AddObject(module, "GetOccludeeF1D", (PyObject *)&GetOccludeeF1D_Type); + + if( PyType_Ready( &GetOccludersF1D_Type ) < 0 ) + return -1; + Py_INCREF( &GetOccludersF1D_Type ); + PyModule_AddObject(module, "GetOccludersF1D", (PyObject *)&GetOccludersF1D_Type); + + if( PyType_Ready( &GetShapeF1D_Type ) < 0 ) + return -1; + Py_INCREF( &GetShapeF1D_Type ); + PyModule_AddObject(module, "GetShapeF1D", (PyObject *)&GetShapeF1D_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char UnaryFunction1DVectorViewShape___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DVectorViewShape`\n" +"\n" +"Base class for unary functions (functors) that work on\n" +":class:`Interface1D` and return a list of :class:`ViewShape`\n" +"objects.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(integration)\n" +"\n" +" Builds a unary 1D function using the integration method given as\n" +" argument.\n" +"\n" +" :arg integration: An integration method.\n" +" :type integration: :class:`IntegrationType`\n"; + +static int UnaryFunction1DVectorViewShape___init__(BPy_UnaryFunction1DVectorViewShape* self, PyObject *args) +{ + PyObject *obj = 0; + + if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + return -1; + + if( !obj ) + self->uf1D_vectorviewshape = new UnaryFunction1D< std::vector<ViewShape*> >(); + else { + self->uf1D_vectorviewshape = new UnaryFunction1D< std::vector<ViewShape*> >( IntegrationType_from_BPy_IntegrationType(obj) ); + } + + self->uf1D_vectorviewshape->py_uf1D = (PyObject *)self; + + return 0; +} + +static void UnaryFunction1DVectorViewShape___dealloc__(BPy_UnaryFunction1DVectorViewShape* self) +{ + if (self->uf1D_vectorviewshape) + delete self->uf1D_vectorviewshape; + UnaryFunction1D_Type.tp_dealloc((PyObject*)self); +} + +static PyObject * UnaryFunction1DVectorViewShape___repr__(BPy_UnaryFunction1DVectorViewShape* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_vectorviewshape->getName().c_str(), self->uf1D_vectorviewshape ); +} + +static char UnaryFunction1DVectorViewShape_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the unary 1D function.\n" +"\n" +" :return: The name of the unary 1D function.\n" +" :rtype: str\n"; + +static PyObject * UnaryFunction1DVectorViewShape_getName( BPy_UnaryFunction1DVectorViewShape *self ) +{ + return PyUnicode_FromString( self->uf1D_vectorviewshape->getName().c_str() ); +} + +static PyObject * UnaryFunction1DVectorViewShape___call__( BPy_UnaryFunction1DVectorViewShape *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } + if( !PyArg_ParseTuple(args, "O!", &Interface1D_Type, &obj) ) + return NULL; + + if( typeid(*(self->uf1D_vectorviewshape)) == typeid(UnaryFunction1D< std::vector<ViewShape*> >) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); + return NULL; + } + if (self->uf1D_vectorviewshape->operator()(*( ((BPy_Interface1D *) obj)->if1D )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf1D_vectorviewshape->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + PyObject *list = PyList_New(0); + PyObject *item; + for( unsigned int i = 0; i < self->uf1D_vectorviewshape->result.size(); i++) { + ViewShape *v = self->uf1D_vectorviewshape->result[i]; + if (v) { + item = BPy_ViewShape_from_ViewShape(*v); + } else { + item = Py_None; + Py_INCREF(item); + } + PyList_Append(list, item); + } + + return list; +} + +static char UnaryFunction1DVectorViewShape_setIntegrationType___doc__[] = +".. method:: setIntegrationType(integration)\n" +"\n" +" Sets the integration method.\n" +"\n" +" :arg integration: An integration method.\n" +" :type integration: :class:`IntegrationType`\n"; + +static PyObject * UnaryFunction1DVectorViewShape_setIntegrationType(BPy_UnaryFunction1DVectorViewShape* self, PyObject *args) +{ + PyObject *obj; + + if( !PyArg_ParseTuple(args, "O!", &IntegrationType_Type, &obj) ) + return NULL; + + self->uf1D_vectorviewshape->setIntegrationType( IntegrationType_from_BPy_IntegrationType(obj) ); + Py_RETURN_NONE; +} + +static char UnaryFunction1DVectorViewShape_getIntegrationType___doc__[] = +".. method:: getIntegrationType(integration)\n" +"\n" +" Returns the integration method.\n" +"\n" +" :return: The integration method.\n" +" :rtype: :class:`IntegrationType`\n"; + +static PyObject * UnaryFunction1DVectorViewShape_getIntegrationType(BPy_UnaryFunction1DVectorViewShape* self) { + return BPy_IntegrationType_from_IntegrationType( self->uf1D_vectorviewshape->getIntegrationType() ); +} + +/*----------------------UnaryFunction1DVectorViewShape instance definitions ----------------------------*/ +static PyMethodDef BPy_UnaryFunction1DVectorViewShape_methods[] = { + {"getName", ( PyCFunction ) UnaryFunction1DVectorViewShape_getName, METH_NOARGS, UnaryFunction1DVectorViewShape_getName___doc__}, + {"setIntegrationType", ( PyCFunction ) UnaryFunction1DVectorViewShape_setIntegrationType, METH_VARARGS, UnaryFunction1DVectorViewShape_setIntegrationType___doc__}, + {"getIntegrationType", ( PyCFunction ) UnaryFunction1DVectorViewShape_getIntegrationType, METH_NOARGS, UnaryFunction1DVectorViewShape_getIntegrationType___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_UnaryFunction1DVectorViewShape type definition ------------------------------*/ + +PyTypeObject UnaryFunction1DVectorViewShape_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "UnaryFunction1DVectorViewShape", /* tp_name */ + sizeof(BPy_UnaryFunction1DVectorViewShape), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)UnaryFunction1DVectorViewShape___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)UnaryFunction1DVectorViewShape___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)UnaryFunction1DVectorViewShape___call__, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + UnaryFunction1DVectorViewShape___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_UnaryFunction1DVectorViewShape_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)UnaryFunction1DVectorViewShape___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h new file mode 100644 index 00000000000..e2321a6107f --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h @@ -0,0 +1,37 @@ +#ifndef FREESTYLE_PYTHON_UNARYFUNCTION1DVECTORVIEWSHAPE_H +#define FREESTYLE_PYTHON_UNARYFUNCTION1DVECTORVIEWSHAPE_H + +#include "../BPy_UnaryFunction1D.h" + +#include <vector> +#include "../../view_map/ViewMap.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject UnaryFunction1DVectorViewShape_Type; + +#define BPy_UnaryFunction1DVectorViewShape_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &UnaryFunction1DVectorViewShape_Type) ) + +/*---------------------------Python BPy_UnaryFunction1DVectorViewShape structure definition----------*/ +typedef struct { + BPy_UnaryFunction1D py_uf1D; + UnaryFunction1D< std::vector<ViewShape*> > *uf1D_vectorviewshape; +} BPy_UnaryFunction1DVectorViewShape; + +/*---------------------------Python BPy_UnaryFunction1DVectorViewShape visible prototypes-----------*/ +int UnaryFunction1DVectorViewShape_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_UNARYFUNCTION1DVECTORVIEWSHAPE_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp new file mode 100644 index 00000000000..f18421d8754 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp @@ -0,0 +1,222 @@ +#include "BPy_UnaryFunction1DVoid.h" + +#include "../BPy_Convert.h" +#include "../BPy_Interface1D.h" +#include "../BPy_IntegrationType.h" + +#include "UnaryFunction1D_void/BPy_ChainingTimeStampF1D.h" +#include "UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h" +#include "UnaryFunction1D_void/BPy_TimeStampF1D.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------MODULE INITIALIZATION-------------------------------- + +int UnaryFunction1DVoid_Init( PyObject *module ) { + + if( module == NULL ) + return -1; + + if( PyType_Ready( &UnaryFunction1DVoid_Type ) < 0 ) + return -1; + Py_INCREF( &UnaryFunction1DVoid_Type ); + PyModule_AddObject(module, "UnaryFunction1DVoid", (PyObject *)&UnaryFunction1DVoid_Type); + + if( PyType_Ready( &ChainingTimeStampF1D_Type ) < 0 ) + return -1; + Py_INCREF( &ChainingTimeStampF1D_Type ); + PyModule_AddObject(module, "ChainingTimeStampF1D", (PyObject *)&ChainingTimeStampF1D_Type); + + if( PyType_Ready( &IncrementChainingTimeStampF1D_Type ) < 0 ) + return -1; + Py_INCREF( &IncrementChainingTimeStampF1D_Type ); + PyModule_AddObject(module, "IncrementChainingTimeStampF1D", (PyObject *)&IncrementChainingTimeStampF1D_Type); + + if( PyType_Ready( &TimeStampF1D_Type ) < 0 ) + return -1; + Py_INCREF( &TimeStampF1D_Type ); + PyModule_AddObject(module, "TimeStampF1D", (PyObject *)&TimeStampF1D_Type); + + return 0; +} + +//------------------------INSTANCE METHODS ---------------------------------- + +static char UnaryFunction1DVoid___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DVoid`\n" +"\n" +"Base class for unary functions (functors) working on\n" +":class:`Interface1D`.\n" +"\n" +".. method:: __init__()\n" +"\n" +" Default constructor.\n" +"\n" +".. method:: __init__(integration)\n" +"\n" +" Builds a unary 1D function using the integration method given as\n" +" argument.\n" +"\n" +" :arg integration: An integration method.\n" +" :type integration: :class:`IntegrationType`\n"; + +static int UnaryFunction1DVoid___init__(BPy_UnaryFunction1DVoid* self, PyObject *args) +{ + PyObject *obj = 0; + + if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + return -1; + + if( !obj ) + self->uf1D_void = new UnaryFunction1D_void(); + else { + self->uf1D_void = new UnaryFunction1D_void( IntegrationType_from_BPy_IntegrationType(obj) ); + } + + self->uf1D_void->py_uf1D = (PyObject *)self; + + return 0; +} + +static void UnaryFunction1DVoid___dealloc__(BPy_UnaryFunction1DVoid* self) +{ + if (self->uf1D_void) + delete self->uf1D_void; + UnaryFunction1D_Type.tp_dealloc((PyObject*)self); +} + +static PyObject * UnaryFunction1DVoid___repr__(BPy_UnaryFunction1DVoid* self) +{ + return PyUnicode_FromFormat("type: %s - address: %p", self->uf1D_void->getName().c_str(), self->uf1D_void ); +} + +static char UnaryFunction1DVoid_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the unary 1D function.\n" +"\n" +" :return: The name of the unary 1D function.\n" +" :rtype: str\n"; + +static PyObject * UnaryFunction1DVoid_getName( BPy_UnaryFunction1DVoid *self ) +{ + return PyUnicode_FromString( self->uf1D_void->getName().c_str() ); +} + +static PyObject * UnaryFunction1DVoid___call__( BPy_UnaryFunction1DVoid *self, PyObject *args, PyObject *kwds) +{ + PyObject *obj; + + if( kwds != NULL ) { + PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported"); + return NULL; + } + if( !PyArg_ParseTuple(args, "O!", &Interface1D_Type, &obj) ) + return NULL; + + if( typeid(*(self->uf1D_void)) == typeid(UnaryFunction1D_void) ) { + PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden"); + return NULL; + } + if (self->uf1D_void->operator()(*( ((BPy_Interface1D *) obj)->if1D )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf1D_void->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } + Py_RETURN_NONE; +} + +static char UnaryFunction1DVoid_setIntegrationType___doc__[] = +".. method:: setIntegrationType(integration)\n" +"\n" +" Sets the integration method.\n" +"\n" +" :arg integration: An integration method.\n" +" :type integration: :class:`IntegrationType`\n"; + +static PyObject * UnaryFunction1DVoid_setIntegrationType(BPy_UnaryFunction1DVoid* self, PyObject *args) +{ + PyObject *obj; + + if( !PyArg_ParseTuple(args, "O!", &IntegrationType_Type, &obj) ) + return NULL; + + self->uf1D_void->setIntegrationType( IntegrationType_from_BPy_IntegrationType(obj) ); + Py_RETURN_NONE; +} + +static char UnaryFunction1DVoid_getIntegrationType___doc__[] = +".. method:: getIntegrationType(integration)\n" +"\n" +" Returns the integration method.\n" +"\n" +" :return: The integration method.\n" +" :rtype: :class:`IntegrationType`\n"; + +static PyObject * UnaryFunction1DVoid_getIntegrationType(BPy_UnaryFunction1DVoid* self) { + return BPy_IntegrationType_from_IntegrationType( self->uf1D_void->getIntegrationType() ); +} + +/*----------------------UnaryFunction1DVoid instance definitions ----------------------------*/ +static PyMethodDef BPy_UnaryFunction1DVoid_methods[] = { + {"getName", ( PyCFunction ) UnaryFunction1DVoid_getName, METH_NOARGS, UnaryFunction1DVoid_getName___doc__}, + {"setIntegrationType", ( PyCFunction ) UnaryFunction1DVoid_setIntegrationType, METH_VARARGS, UnaryFunction1DVoid_setIntegrationType___doc__}, + {"getIntegrationType", ( PyCFunction ) UnaryFunction1DVoid_getIntegrationType, METH_NOARGS, UnaryFunction1DVoid_getIntegrationType___doc__}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_UnaryFunction1DVoid type definition ------------------------------*/ + +PyTypeObject UnaryFunction1DVoid_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "UnaryFunction1DVoid", /* tp_name */ + sizeof(BPy_UnaryFunction1DVoid), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)UnaryFunction1DVoid___dealloc__, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + (reprfunc)UnaryFunction1DVoid___repr__, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + (ternaryfunc)UnaryFunction1DVoid___call__, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + UnaryFunction1DVoid___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + BPy_UnaryFunction1DVoid_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)UnaryFunction1DVoid___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.h new file mode 100644 index 00000000000..af907aeec84 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.h @@ -0,0 +1,34 @@ +#ifndef FREESTYLE_PYTHON_UNARYFUNCTION1DVOID_H +#define FREESTYLE_PYTHON_UNARYFUNCTION1DVOID_H + +#include "../BPy_UnaryFunction1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject UnaryFunction1DVoid_Type; + +#define BPy_UnaryFunction1DVoid_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &UnaryFunction1DVoid_Type) ) + +/*---------------------------Python BPy_UnaryFunction1DVoid structure definition----------*/ +typedef struct { + BPy_UnaryFunction1D py_uf1D; + UnaryFunction1D_void *uf1D_void; +} BPy_UnaryFunction1DVoid; + +/*---------------------------Python BPy_UnaryFunction1DVoid visible prototypes-----------*/ +int UnaryFunction1DVoid_Init( PyObject *module ); + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_UNARYFUNCTION1DVOID_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.cpp new file mode 100644 index 00000000000..a31d96ad1a4 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.cpp @@ -0,0 +1,99 @@ +#include "BPy_CurveNatureF1D.h" + +#include "../../../view_map/Functions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char CurveNatureF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DEdgeNature` > :class:`CurveNatureF1D`\n" +"\n" +".. method:: __init__(iType=IntegrationType.MEAN)\n" +"\n" +" Builds a CurveNatureF1D object.\n" +"\n" +" :arg iType: The integration method used to compute a single value\n" +" from a set of values.\n" +" :type iType: :class:`IntegrationType`\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns the nature of the Interface1D (silhouette, ridge, crease,\n" +" and so on). Except if the Interface1D is a :class:`ViewEdge`, this\n" +" result might be ambiguous. Indeed, the Interface1D might result\n" +" from the gathering of several 1D elements, each one being of a\n" +" different nature. An integration method, such as the MEAN, might\n" +" give, in this case, irrelevant results.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: The nature of the Interface1D.\n" +" :rtype: :class:`Nature`\n"; + +static int CurveNatureF1D___init__( BPy_CurveNatureF1D* self, PyObject *args) +{ + PyObject *obj = 0; + + if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + return -1; + + IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + self->py_uf1D_edgenature.uf1D_edgenature = new Functions1D::CurveNatureF1D(t); + return 0; +} + +/*-----------------------BPy_CurveNatureF1D type definition ------------------------------*/ + +PyTypeObject CurveNatureF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "CurveNatureF1D", /* tp_name */ + sizeof(BPy_CurveNatureF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + CurveNatureF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DEdgeNature_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)CurveNatureF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.h new file mode 100644 index 00000000000..852f8937954 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_CURVENATUREF1D_H +#define FREESTYLE_PYTHON_CURVENATUREF1D_H + +#include "../BPy_UnaryFunction1DEdgeNature.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject CurveNatureF1D_Type; + +#define BPy_CurveNatureF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &CurveNatureF1D_Type) ) + +/*---------------------------Python BPy_CurveNatureF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DEdgeNature py_uf1D_edgenature; +} BPy_CurveNatureF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_CURVENATUREF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp new file mode 100644 index 00000000000..92ba5b05e75 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp @@ -0,0 +1,94 @@ +#include "BPy_Normal2DF1D.h" + +#include "../../../view_map/Functions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char Normal2DF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DVec2f` > :class:`Normal2DF1D`\n" +"\n" +".. method:: __init__(iType=IntegrationType.MEAN)\n" +"\n" +" Builds a Normal2DF1D object.\n" +"\n" +" :arg iType: The integration method used to compute a single value\n" +" from a set of values.\n" +" :type iType: :class:`IntegrationType`\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns the 2D normal for the Interface1D.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: The 2D normal for the Interface1D.\n" +" :rtype: :class:`mathutils.Vector`\n"; + +static int Normal2DF1D___init__( BPy_Normal2DF1D* self, PyObject *args) +{ + PyObject *obj = 0; + + if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + return -1; + + IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + self->py_uf1D_vec2f.uf1D_vec2f = new Functions1D::Normal2DF1D(t); + return 0; +} + +/*-----------------------BPy_Normal2DF1D type definition ------------------------------*/ + +PyTypeObject Normal2DF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "Normal2DF1D", /* tp_name */ + sizeof(BPy_Normal2DF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + Normal2DF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DVec2f_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Normal2DF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.h new file mode 100644 index 00000000000..32078558d0c --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_NORMAL2DF1D_H +#define FREESTYLE_PYTHON_NORMAL2DF1D_H + +#include "../BPy_UnaryFunction1DVec2f.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject Normal2DF1D_Type; + +#define BPy_Normal2DF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &Normal2DF1D_Type) ) + +/*---------------------------Python BPy_Normal2DF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DVec2f py_uf1D_vec2f; +} BPy_Normal2DF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_NORMAL2DF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp new file mode 100644 index 00000000000..a1b87b9cf17 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp @@ -0,0 +1,96 @@ +#include "BPy_Orientation2DF1D.h" + +#include "../../../view_map/Functions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char Orientation2DF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DVec2f` > :class:`Orientation2DF1D`\n" +"\n" +".. method:: __init__(iType=IntegrationType.MEAN)\n" +"\n" +" Builds an Orientation2DF1D object.\n" +"\n" +" :arg iType: The integration method used to compute a single value\n" +" from a set of values.\n" +" :type iType: :class:`IntegrationType`\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns the 2D orientation of the Interface1D.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: The 2D orientation of the Interface1D.\n" +" :rtype: :class:`mathutils.Vector`\n"; + +static int Orientation2DF1D___init__( BPy_Orientation2DF1D* self, PyObject *args) +{ + PyObject *obj = 0; + + if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + return -1; + + IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + self->py_uf1D_vec2f.uf1D_vec2f = new Functions1D::Orientation2DF1D(t); + return 0; + +} + + +/*-----------------------BPy_Orientation2DF1D type definition ------------------------------*/ + +PyTypeObject Orientation2DF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "Orientation2DF1D", /* tp_name */ + sizeof(BPy_Orientation2DF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + Orientation2DF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DVec2f_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Orientation2DF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.h new file mode 100644 index 00000000000..189ab04db4f --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_ORIENTATION2DF1D_H +#define FREESTYLE_PYTHON_ORIENTATION2DF1D_H + +#include "../BPy_UnaryFunction1DVec2f.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject Orientation2DF1D_Type; + +#define BPy_Orientation2DF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &Orientation2DF1D_Type) ) + +/*---------------------------Python BPy_Orientation2DF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DVec2f py_uf1D_vec2f; +} BPy_Orientation2DF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_ORIENTATION2DF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.cpp new file mode 100644 index 00000000000..a55c1f7a542 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.cpp @@ -0,0 +1,94 @@ +#include "BPy_Orientation3DF1D.h" + +#include "../../../view_map/Functions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char Orientation3DF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DVec3f` > :class:`Orientation3DF1D`\n" +"\n" +".. method:: __init__(iType=IntegrationType.MEAN)\n" +"\n" +" Builds an Orientation3DF1D object.\n" +"\n" +" :arg iType: The integration method used to compute a single value\n" +" from a set of values.\n" +" :type iType: :class:`IntegrationType`\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns the 3D orientation of the Interface1D.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: The 3D orientation of the Interface1D.\n" +" :rtype: :class:`mathutils.Vector`\n"; + +static int Orientation3DF1D___init__( BPy_Orientation3DF1D* self, PyObject *args) +{ + PyObject *obj = 0; + + if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + return -1; + + IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + self->py_uf1D_vec3f.uf1D_vec3f = new Functions1D::Orientation3DF1D(t); + return 0; +} + +/*-----------------------BPy_Orientation3DF1D type definition ------------------------------*/ + +PyTypeObject Orientation3DF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "Orientation3DF1D", /* tp_name */ + sizeof(BPy_Orientation3DF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + Orientation3DF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DVec3f_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Orientation3DF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.h new file mode 100644 index 00000000000..b69baf106f4 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_ORIENTATION3DF1D_H +#define FREESTYLE_PYTHON_ORIENTATION3DF1D_H + +#include "../BPy_UnaryFunction1DVec3f.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject Orientation3DF1D_Type; + +#define BPy_Orientation3DF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &Orientation3DF1D_Type) ) + +/*---------------------------Python BPy_Orientation3DF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DVec3f py_uf1D_vec3f; +} BPy_Orientation3DF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_ORIENTATION3DF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.cpp new file mode 100644 index 00000000000..aec76c2888c --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.cpp @@ -0,0 +1,94 @@ +#include "BPy_Curvature2DAngleF1D.h" + +#include "../../../view_map/Functions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char Curvature2DAngleF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`Curvature2DAngleF1D`\n" +"\n" +".. method:: __init__(iType=IntegrationType.MEAN)\n" +"\n" +" Builds a Curvature2DAngleF1D object.\n" +"\n" +" :arg iType: The integration method used to compute a single value\n" +" from a set of values.\n" +" :type iType: :class:`IntegrationType`\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns the 2D curvature as an angle for an Interface1D.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: The 2D curvature as an angle.\n" +" :rtype: float\n"; + +static int Curvature2DAngleF1D___init__( BPy_Curvature2DAngleF1D* self, PyObject *args) +{ + PyObject *obj = 0; + + if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + return -1; + + IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + self->py_uf1D_double.uf1D_double = new Functions1D::Curvature2DAngleF1D(t); + return 0; + +} +/*-----------------------BPy_Curvature2DAngleF1D type definition ------------------------------*/ + +PyTypeObject Curvature2DAngleF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "Curvature2DAngleF1D", /* tp_name */ + sizeof(BPy_Curvature2DAngleF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + Curvature2DAngleF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Curvature2DAngleF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.h new file mode 100644 index 00000000000..1603a7dc4ea --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_CURVATURE2DANGLEF1D_H +#define FREESTYLE_PYTHON_CURVATURE2DANGLEF1D_H + +#include "../BPy_UnaryFunction1DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject Curvature2DAngleF1D_Type; + +#define BPy_Curvature2DAngleF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &Curvature2DAngleF1D_Type) ) + +/*---------------------------Python BPy_Curvature2DAngleF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DDouble py_uf1D_double; +} BPy_Curvature2DAngleF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_CURVATURE2DANGLEF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp new file mode 100644 index 00000000000..360f98fa361 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp @@ -0,0 +1,109 @@ +#include "BPy_DensityF1D.h" + +#include "../../../stroke/AdvancedFunctions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char DensityF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`DensityF1D`\n" +"\n" +".. method:: __init__(sigma=2.0, iType=IntegrationType.MEAN, sampling=2.0)\n" +"\n" +" Builds a DensityF1D object.\n" +"\n" +" :arg sigma: The sigma used in DensityF0D and determining the window size\n" +" used in each density query.\n" +" :type sigma: float\n" +" :arg iType: The integration method used to compute a single value\n" +" from a set of values.\n" +" :type iType: :class:`IntegrationType`\n" +" :arg sampling: The resolution used to sample the chain: the\n" +" corresponding 0D function is evaluated at each sample point and\n" +" the result is obtained by combining the resulting values into a\n" +" single one, following the method specified by iType.\n" +" :type sampling: float\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns the density evaluated for an Interface1D. The density is\n" +" evaluated for a set of points along the Interface1D (using the\n" +" :class:`DensityF0D` functor) with a user-defined sampling and then\n" +" integrated into a single value using a user-defined integration\n" +" method.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: The density evaluated for an Interface1D.\n" +" :rtype: float\n"; + +static int DensityF1D___init__( BPy_DensityF1D* self, PyObject *args) +{ + PyObject *obj = 0; + double d = 2.0; + float f = 2.0; + + if( !PyArg_ParseTuple(args, "|dO!f", &d, &IntegrationType_Type, &obj, &f) ) + return -1; + + IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + self->py_uf1D_double.uf1D_double = new Functions1D::DensityF1D(d,t,f); + return 0; + +} + +/*-----------------------BPy_DensityF1D type definition ------------------------------*/ + +PyTypeObject DensityF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "DensityF1D", /* tp_name */ + sizeof(BPy_DensityF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + DensityF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)DensityF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.h new file mode 100644 index 00000000000..36426536b36 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_DENSITYF1D_H +#define FREESTYLE_PYTHON_DENSITYF1D_H + +#include "../BPy_UnaryFunction1DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject DensityF1D_Type; + +#define BPy_DensityF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &DensityF1D_Type) ) + +/*---------------------------Python BPy_DensityF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DDouble py_uf1D_double; +} BPy_DensityF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_DENSITYF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp new file mode 100644 index 00000000000..b30d26c8516 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp @@ -0,0 +1,110 @@ +#include "BPy_GetCompleteViewMapDensityF1D.h" + +#include "../../../stroke/AdvancedFunctions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetCompleteViewMapDensityF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`GetCompleteViewMapDensityF1D`\n" +"\n" +".. method:: __init__(level, iType=IntegrationType.MEAN, sampling=2.0)\n" +"\n" +" Builds a GetCompleteViewMapDensityF1D object.\n" +"\n" +" :arg level: The level of the pyramid from which the pixel must be\n" +" read.\n" +" :type level: int\n" +" :arg iType: The integration method used to compute a single value\n" +" from a set of values.\n" +" :type iType: :class:`IntegrationType`\n" +" :arg sampling: The resolution used to sample the chain: the\n" +" corresponding 0D function is evaluated at each sample point and\n" +" the result is obtained by combining the resulting values into a\n" +" single one, following the method specified by iType.\n" +" :type sampling: float\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns the density evaluated for an Interface1D in the complete\n" +" viewmap image. The density is evaluated for a set of points along\n" +" the Interface1D (using the :class:`ReadCompleteViewMapPixelF0D`\n" +" functor) and then integrated into a single value using a\n" +" user-defined integration method.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: The density evaluated for the Interface1D in the complete\n" +" viewmap image.\n" +" :rtype: float\n"; + +static int GetCompleteViewMapDensityF1D___init__( BPy_GetCompleteViewMapDensityF1D* self, PyObject *args) +{ + PyObject *obj = 0; + unsigned i; + float f = 2.0; + + if( !PyArg_ParseTuple(args, "i|O!f", &i, &IntegrationType_Type, &obj, &f) ) + return -1; + + IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + self->py_uf1D_double.uf1D_double = new Functions1D::GetCompleteViewMapDensityF1D(i,t,f); + return 0; + +} + +/*-----------------------BPy_GetCompleteViewMapDensityF1D type definition ------------------------------*/ + +PyTypeObject GetCompleteViewMapDensityF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetCompleteViewMapDensityF1D", /* tp_name */ + sizeof(BPy_GetCompleteViewMapDensityF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetCompleteViewMapDensityF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetCompleteViewMapDensityF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h new file mode 100644 index 00000000000..5963b820348 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETCOMPLETEVIEWMAPDENSITYF1D_H +#define FREESTYLE_PYTHON_GETCOMPLETEVIEWMAPDENSITYF1D_H + +#include "../BPy_UnaryFunction1DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetCompleteViewMapDensityF1D_Type; + +#define BPy_GetCompleteViewMapDensityF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetCompleteViewMapDensityF1D_Type) ) + +/*---------------------------Python BPy_GetCompleteViewMapDensityF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DDouble py_uf1D_double; +} BPy_GetCompleteViewMapDensityF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETCOMPLETEVIEWMAPDENSITYF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp new file mode 100644 index 00000000000..494297d3a3b --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp @@ -0,0 +1,114 @@ +#include "BPy_GetDirectionalViewMapDensityF1D.h" + +#include "../../../stroke/AdvancedFunctions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetDirectionalViewMapDensityF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`GetDirectionalViewMapDensityF1D`\n" +"\n" +".. method:: __init__(iOrientation, level, iType=IntegrationType.MEAN, sampling=2.0)\n" +"\n" +" Builds a GetDirectionalViewMapDensityF1D object.\n" +"\n" +" :arg iOrientation: The number of the directional map we must work\n" +" with.\n" +" :type iOrientation: int\n" +" :arg level: The level of the pyramid from which the pixel must be\n" +" read.\n" +" :type level: int\n" +" :arg iType: The integration method used to compute a single value\n" +" from a set of values.\n" +" :type iType: :class:`IntegrationType`\n" +" :arg sampling: The resolution used to sample the chain: the\n" +" corresponding 0D function is evaluated at each sample point and\n" +" the result is obtained by combining the resulting values into a\n" +" single one, following the method specified by iType.\n" +" :type sampling: float\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns the density evaluated for an Interface1D in of the\n" +" steerable viewmaps image. The direction telling which Directional\n" +" map to choose is explicitely specified by the user. The density is\n" +" evaluated for a set of points along the Interface1D (using the\n" +" :class:`ReadSteerableViewMapPixelF0D` functor) and then integrated\n" +" into a single value using a user-defined integration method.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: the density evaluated for an Interface1D in of the\n" +" steerable viewmaps image.\n" +" :rtype: float\n"; + +static int GetDirectionalViewMapDensityF1D___init__( BPy_GetDirectionalViewMapDensityF1D* self, PyObject *args) +{ + PyObject *obj = 0; + unsigned int u1, u2; + float f = 2.0; + + if( !PyArg_ParseTuple(args, "II|O!f", &u1, &u2, &IntegrationType_Type, &obj, &f) ) + return -1; + + IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + self->py_uf1D_double.uf1D_double = new Functions1D::GetDirectionalViewMapDensityF1D(u1, u2, t, f); + return 0; + +} + +/*-----------------------BPy_GetDirectionalViewMapDensityF1D type definition ------------------------------*/ + +PyTypeObject GetDirectionalViewMapDensityF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetDirectionalViewMapDensityF1D", /* tp_name */ + sizeof(BPy_GetDirectionalViewMapDensityF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetDirectionalViewMapDensityF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetDirectionalViewMapDensityF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h new file mode 100644 index 00000000000..0e2d7ec2718 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETDIRECTIONALVIEWMAPDENSITYF1D_H +#define FREESTYLE_PYTHON_GETDIRECTIONALVIEWMAPDENSITYF1D_H + +#include "../BPy_UnaryFunction1DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetDirectionalViewMapDensityF1D_Type; + +#define BPy_GetDirectionalViewMapDensityF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetDirectionalViewMapDensityF1D_Type) ) + +/*---------------------------Python BPy_GetDirectionalViewMapDensityF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DDouble py_uf1D_double; +} BPy_GetDirectionalViewMapDensityF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETDIRECTIONALVIEWMAPDENSITYF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.cpp new file mode 100644 index 00000000000..7b1e7193b85 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.cpp @@ -0,0 +1,95 @@ +#include "BPy_GetProjectedXF1D.h" + +#include "../../../view_map/Functions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetProjectedXF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`GetProjectedXF1D`\n" +"\n" +".. method:: __init__(iType=IntegrationType.MEAN)\n" +"\n" +" Builds a GetProjectedXF1D object.\n" +"\n" +" :arg iType: The integration method used to compute a single value\n" +" from a set of values. \n" +" :type iType: :class:`IntegrationType`\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns the projected X 3D coordinate of an Interface1D.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: The projected X 3D coordinate of an Interface1D.\n" +" :rtype: float\n"; + +static int GetProjectedXF1D___init__( BPy_GetProjectedXF1D* self, PyObject *args ) +{ + PyObject *obj = 0; + + if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + return -1; + + IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + self->py_uf1D_double.uf1D_double = new Functions1D::GetProjectedXF1D(t); + return 0; +} + + +/*-----------------------BPy_GetProjectedXF1D type definition ------------------------------*/ + +PyTypeObject GetProjectedXF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetProjectedXF1D", /* tp_name */ + sizeof(BPy_GetProjectedXF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetProjectedXF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetProjectedXF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.h new file mode 100644 index 00000000000..d799fb7b334 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETPROJECTEDXF1D_H +#define FREESTYLE_PYTHON_GETPROJECTEDXF1D_H + +#include "../BPy_UnaryFunction1DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetProjectedXF1D_Type; + +#define BPy_GetProjectedXF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetProjectedXF1D_Type) ) + +/*---------------------------Python BPy_GetProjectedXF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DDouble py_uf1D_double; +} BPy_GetProjectedXF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETPROJECTEDXF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.cpp new file mode 100644 index 00000000000..df09b32b5b9 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.cpp @@ -0,0 +1,94 @@ +#include "BPy_GetProjectedYF1D.h" + +#include "../../../view_map/Functions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetProjectedYF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`GetProjectedYF1D`\n" +"\n" +".. method:: __init__(iType=IntegrationType.MEAN)\n" +"\n" +" Builds a GetProjectedYF1D object.\n" +"\n" +" :arg iType: The integration method used to compute a single value\n" +" from a set of values. \n" +" :type iType: :class:`IntegrationType`\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns the projected Y 3D coordinate of an Interface1D.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: The projected Y 3D coordinate of an Interface1D.\n" +" :rtype: float\n"; + +static int GetProjectedYF1D___init__( BPy_GetProjectedYF1D* self, PyObject *args ) +{ + PyObject *obj = 0; + + if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + return -1; + + IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + self->py_uf1D_double.uf1D_double = new Functions1D::GetProjectedYF1D(t); + return 0; +} + +/*-----------------------BPy_GetProjectedYF1D type definition ------------------------------*/ + +PyTypeObject GetProjectedYF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetProjectedYF1D", /* tp_name */ + sizeof(BPy_GetProjectedYF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetProjectedYF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetProjectedYF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.h new file mode 100644 index 00000000000..1b7fe6c6b5f --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETPROJECTEDYF1D_H +#define FREESTYLE_PYTHON_GETPROJECTEDYF1D_H + +#include "../BPy_UnaryFunction1DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetProjectedYF1D_Type; + +#define BPy_GetProjectedYF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetProjectedYF1D_Type) ) + +/*---------------------------Python BPy_GetProjectedYF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DDouble py_uf1D_double; +} BPy_GetProjectedYF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETPROJECTEDYF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.cpp new file mode 100644 index 00000000000..acd03856b2c --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.cpp @@ -0,0 +1,94 @@ +#include "BPy_GetProjectedZF1D.h" + +#include "../../../view_map/Functions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetProjectedZF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`GetProjectedZF1D`\n" +"\n" +".. method:: __init__(iType=IntegrationType.MEAN)\n" +"\n" +" Builds a GetProjectedZF1D object.\n" +"\n" +" :arg iType: The integration method used to compute a single value\n" +" from a set of values. \n" +" :type iType: :class:`IntegrationType`\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns the projected Z 3D coordinate of an Interface1D.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: The projected Z 3D coordinate of an Interface1D.\n" +" :rtype: float\n"; + +static int GetProjectedZF1D___init__( BPy_GetProjectedZF1D* self, PyObject *args ) +{ + PyObject *obj = 0; + + if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + return -1; + + IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + self->py_uf1D_double.uf1D_double = new Functions1D::GetProjectedZF1D(t); + return 0; +} + +/*-----------------------BPy_GetProjectedZF1D type definition ------------------------------*/ + +PyTypeObject GetProjectedZF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetProjectedZF1D", /* tp_name */ + sizeof(BPy_GetProjectedZF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetProjectedZF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetProjectedZF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.h new file mode 100644 index 00000000000..a87ac6f8c5e --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETPROJECTEDZF1D_H +#define FREESTYLE_PYTHON_GETPROJECTEDZF1D_H + +#include "../BPy_UnaryFunction1DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetProjectedZF1D_Type; + +#define BPy_GetProjectedZF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetProjectedZF1D_Type) ) + +/*---------------------------Python BPy_GetProjectedZF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DDouble py_uf1D_double; +} BPy_GetProjectedZF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETPROJECTEDZF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp new file mode 100644 index 00000000000..cc3813030ac --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp @@ -0,0 +1,107 @@ +#include "BPy_GetSteerableViewMapDensityF1D.h" + +#include "../../../stroke/AdvancedFunctions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetSteerableViewMapDensityF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`GetSteerableViewMapDensityF1D`\n" +"\n" +".. method:: __init__(level, iType=IntegrationType.MEAN, sampling=2.0)\n" +"\n" +" Builds a GetSteerableViewMapDensityF1D object.\n" +"\n" +" :arg level: The level of the pyramid from which the pixel must be\n" +" read.\n" +" :type level: int\n" +" :arg iType: The integration method used to compute a single value\n" +" from a set of values.\n" +" :type iType: :class:`IntegrationType`\n" +" :arg sampling: The resolution used to sample the chain: the\n" +" corresponding 0D function is evaluated at each sample point and\n" +" the result is obtained by combining the resulting values into a\n" +" single one, following the method specified by iType.\n" +" :type sampling: float\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns the density of the ViewMap for a given Interface1D. The\n" +" density of each :class:`FEdge` is evaluated in the proper steerable\n" +" :class:`ViewMap` depending on its orientation.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: The density of the ViewMap for a given Interface1D.\n" +" :rtype: float\n"; + +static int GetSteerableViewMapDensityF1D___init__( BPy_GetSteerableViewMapDensityF1D* self, PyObject *args) +{ + PyObject *obj = 0; + int i; + float f = 2.0; + + if( !PyArg_ParseTuple(args, "i|O!f", &i, &IntegrationType_Type, &obj, &f) ) + return -1; + + IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + self->py_uf1D_double.uf1D_double = new Functions1D::GetSteerableViewMapDensityF1D(i,t,f); + return 0; + +} + +/*-----------------------BPy_GetSteerableViewMapDensityF1D type definition ------------------------------*/ + +PyTypeObject GetSteerableViewMapDensityF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetSteerableViewMapDensityF1D", /* tp_name */ + sizeof(BPy_GetSteerableViewMapDensityF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetSteerableViewMapDensityF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetSteerableViewMapDensityF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h new file mode 100644 index 00000000000..29880c7e9a7 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h @@ -0,0 +1,29 @@ +#ifndef FREESTYLE_PYTHON_GETSTEERABLEVIEWMAPDENSITYF1D_H +#define FREESTYLE_PYTHON_GETSTEERABLEVIEWMAPDENSITYF1D_H + +#include "../BPy_UnaryFunction1DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetSteerableViewMapDensityF1D_Type; + +#define BPy_GetSteerableViewMapDensityF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetSteerableViewMapDensityF1D_Type) ) +/*---------------------------Python BPy_GetSteerableViewMapDensityF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DDouble py_uf1D_double; +} BPy_GetSteerableViewMapDensityF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETSTEERABLEVIEWMAPDENSITYF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp new file mode 100644 index 00000000000..c3e12fd7792 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp @@ -0,0 +1,107 @@ +#include "BPy_GetViewMapGradientNormF1D.h" + +#include "../../../stroke/AdvancedFunctions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetViewMapGradientNormF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`GetViewMapGradientNormF1D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a GetViewMapGradientNormF1D object.\n" +"\n" +" :arg level: The level of the pyramid from which the pixel must be\n" +" read.\n" +" :type level: int\n" +" :arg iType: The integration method used to compute a single value\n" +" from a set of values.\n" +" :type iType: :class:`IntegrationType`\n" +" :arg sampling: The resolution used to sample the chain: the\n" +" corresponding 0D function is evaluated at each sample point and\n" +" the result is obtained by combining the resulting values into a\n" +" single one, following the method specified by iType.\n" +" :type sampling: float\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns the density of the ViewMap for a given Interface1D. The\n" +" density of each :class:`FEdge` is evaluated in the proper steerable\n" +" :class:`ViewMap` depending on its orientation.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: The density of the ViewMap for a given Interface1D.\n" +" :rtype: float\n"; + +static int GetViewMapGradientNormF1D___init__( BPy_GetViewMapGradientNormF1D* self, PyObject *args) +{ + PyObject *obj = 0; + int i; + float f = 2.0; + + if( !PyArg_ParseTuple(args, "i|O!f", &i, &IntegrationType_Type, &obj, &f) ) + return -1; + + IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + self->py_uf1D_double.uf1D_double = new Functions1D::GetViewMapGradientNormF1D(i,t,f); + return 0; + +} + +/*-----------------------BPy_GetViewMapGradientNormF1D type definition ------------------------------*/ + +PyTypeObject GetViewMapGradientNormF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetViewMapGradientNormF1D", /* tp_name */ + sizeof(BPy_GetViewMapGradientNormF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetViewMapGradientNormF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetViewMapGradientNormF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.h new file mode 100644 index 00000000000..4f07629870f --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETVIEWMAPGRADIENTNORMF1D_H +#define FREESTYLE_PYTHON_GETVIEWMAPGRADIENTNORMF1D_H + +#include "../BPy_UnaryFunction1DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetViewMapGradientNormF1D_Type; + +#define BPy_GetViewMapGradientNormF1D_Check(v) ( ((PyObject *) v)->ob_type == PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetViewMapGradientNormF1D_Type) ) + +/*---------------------------Python BPy_GetViewMapGradientNormF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DDouble py_uf1D_double; +} BPy_GetViewMapGradientNormF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETVIEWMAPGRADIENTNORMF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.cpp new file mode 100644 index 00000000000..a15c6f59a3b --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.cpp @@ -0,0 +1,95 @@ +#include "BPy_GetXF1D.h" + +#include "../../../view_map/Functions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetXF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`GetXF1D`\n" +"\n" +".. method:: __init__(iType)\n" +"\n" +" Builds a GetXF1D object.\n" +"\n" +" :arg iType: The integration method used to compute a single value\n" +" from a set of values.\n" +" :type iType: :class:`IntegrationType`\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns the X 3D coordinate of an Interface1D.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: The X 3D coordinate of the Interface1D.\n" +" :rtype: float\n"; + +static int GetXF1D___init__( BPy_GetXF1D* self, PyObject *args ) +{ + PyObject *obj = 0; + + if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + return -1; + + IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + self->py_uf1D_double.uf1D_double = new Functions1D::GetXF1D(t); + return 0; +} + + +/*-----------------------BPy_GetXF1D type definition ------------------------------*/ + +PyTypeObject GetXF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetXF1D", /* tp_name */ + sizeof(BPy_GetXF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetXF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetXF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.h new file mode 100644 index 00000000000..5eae107daae --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETXF1D_H +#define FREESTYLE_PYTHON_GETXF1D_H + +#include "../BPy_UnaryFunction1DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetXF1D_Type; + +#define BPy_GetXF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetXF1D_Type) ) + +/*---------------------------Python BPy_GetXF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DDouble py_uf1D_double; +} BPy_GetXF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETXF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.cpp new file mode 100644 index 00000000000..b8ee3d8be27 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.cpp @@ -0,0 +1,93 @@ +#include "BPy_GetYF1D.h" + +#include "../../../view_map/Functions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetYF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`GetYF1D`\n" +"\n" +".. method:: __init__(iType)\n" +"\n" +" Builds a GetYF1D object.\n" +"\n" +" :arg iType: The integration method used to compute a single value\n" +" from a set of values.\n" +" :type iType: :class:`IntegrationType`\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns the Y 3D coordinate of an Interface1D.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: The Y 3D coordinate of the Interface1D.\n" +" :rtype: float\n"; + +static int GetYF1D___init__( BPy_GetYF1D* self, PyObject *args ) +{ + PyObject *obj = 0; + + if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + return -1; + + IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + self->py_uf1D_double.uf1D_double = new Functions1D::GetYF1D(t); + return 0; +} +/*-----------------------BPy_GetYF1D type definition ------------------------------*/ + +PyTypeObject GetYF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetYF1D", /* tp_name */ + sizeof(BPy_GetYF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetYF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetYF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.h new file mode 100644 index 00000000000..5864c245776 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETYF1D_H +#define FREESTYLE_PYTHON_GETYF1D_H + +#include "../BPy_UnaryFunction1DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetYF1D_Type; + +#define BPy_GetYF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetYF1D_Type) ) + +/*---------------------------Python BPy_GetYF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DDouble py_uf1D_double; +} BPy_GetYF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETYF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.cpp new file mode 100644 index 00000000000..af275c906c4 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.cpp @@ -0,0 +1,94 @@ +#include "BPy_GetZF1D.h" + +#include "../../../view_map/Functions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetZF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`GetZF1D`\n" +"\n" +".. method:: __init__(iType)\n" +"\n" +" Builds a GetZF1D object.\n" +"\n" +" :arg iType: The integration method used to compute a single value\n" +" from a set of values.\n" +" :type iType: :class:`IntegrationType`\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns the Z 3D coordinate of an Interface1D.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: The Z 3D coordinate of the Interface1D.\n" +" :rtype: float\n"; + +static int GetZF1D___init__( BPy_GetZF1D* self, PyObject *args ) +{ + PyObject *obj = 0; + + if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + return -1; + + IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + self->py_uf1D_double.uf1D_double = new Functions1D::GetZF1D(t); + return 0; +} + +/*-----------------------BPy_GetZF1D type definition ------------------------------*/ + +PyTypeObject GetZF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetZF1D", /* tp_name */ + sizeof(BPy_GetZF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetZF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetZF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.h new file mode 100644 index 00000000000..4b91a567eef --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETZF1D_H +#define FREESTYLE_PYTHON_GETZF1D_H + +#include "../BPy_UnaryFunction1DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetZF1D_Type; + +#define BPy_GetZF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetZF1D_Type) ) + +/*---------------------------Python BPy_GetZF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DDouble py_uf1D_double; +} BPy_GetZF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETZF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp new file mode 100644 index 00000000000..a3b15e6b5f7 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp @@ -0,0 +1,101 @@ +#include "BPy_LocalAverageDepthF1D.h" + +#include "../../../stroke/AdvancedFunctions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char LocalAverageDepthF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`LocalAverageDepthF1D`\n" +"\n" +".. method:: __init__(sigma, iType=IntegrationType.MEAN)\n" +"\n" +" Builds a LocalAverageDepthF1D object.\n" +"\n" +" :arg sigma: The sigma used in DensityF0D and determining the window\n" +" size used in each density query.\n" +" :type sigma: float\n" +" :arg iType: The integration method used to compute a single value\n" +" from a set of values.\n" +" :type iType: :class:`IntegrationType`\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns the average depth evaluated for an Interface1D. The\n" +" average depth is evaluated for a set of points along the\n" +" Interface1D (using the :class:`LocalAverageDepthF0D` functor) with\n" +" a user-defined sampling and then integrated into a single value\n" +" using a user-defined integration method.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: The average depth evaluated for the Interface1D.\n" +" :rtype: float\n"; + +static int LocalAverageDepthF1D___init__( BPy_LocalAverageDepthF1D* self, PyObject *args) +{ + PyObject *obj = 0; + double d; + + if( !PyArg_ParseTuple(args, "d|O!", &d, &IntegrationType_Type, &obj) ) + return -1; + + IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + self->py_uf1D_double.uf1D_double = new Functions1D::LocalAverageDepthF1D(d,t); + return 0; +} +/*-----------------------BPy_LocalAverageDepthF1D type definition ------------------------------*/ + +PyTypeObject LocalAverageDepthF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "LocalAverageDepthF1D", /* tp_name */ + sizeof(BPy_LocalAverageDepthF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + LocalAverageDepthF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)LocalAverageDepthF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.h new file mode 100644 index 00000000000..627d10b6414 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_LOCALAVERAGEDEPTHF1D_H +#define FREESTYLE_PYTHON_LOCALAVERAGEDEPTHF1D_H + +#include "../BPy_UnaryFunction1DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject LocalAverageDepthF1D_Type; + +#define BPy_LocalAverageDepthF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &LocalAverageDepthF1D_Type) ) + +/*---------------------------Python BPy_LocalAverageDepthF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DDouble py_uf1D_double; +} BPy_LocalAverageDepthF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_LOCALAVERAGEDEPTHF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.cpp new file mode 100644 index 00000000000..32a5106b380 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.cpp @@ -0,0 +1,99 @@ +#include "BPy_ZDiscontinuityF1D.h" + +#include "../../../view_map/Functions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ZDiscontinuityF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :class:`ZDiscontinuityF1D`\n" +"\n" +".. method:: __init__(iType=IntegrationType.MEAN)\n" +"\n" +" Builds a ZDiscontinuityF1D object.\n" +"\n" +" :arg iType: The integration method used to compute a single value\n" +" from a set of values.\n" +" :type iType: :class:`IntegrationType`\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns a real value giving the distance between an Interface1D\n" +" and the shape that lies behind (occludee). This distance is\n" +" evaluated in the camera space and normalized between 0 and 1.\n" +" Therefore, if no oject is occluded by the shape to which the\n" +" Interface1D belongs to, 1 is returned.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: The normalized distance between the Interface1D and the occludee.\n" +" :rtype: float\n"; + +static int ZDiscontinuityF1D___init__( BPy_ZDiscontinuityF1D* self, PyObject *args ) +{ + PyObject *obj = 0; + + if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + return -1; + + IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + self->py_uf1D_double.uf1D_double = new Functions1D::ZDiscontinuityF1D(t); + return 0; +} + + +/*-----------------------BPy_ZDiscontinuityF1D type definition ------------------------------*/ + +PyTypeObject ZDiscontinuityF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ZDiscontinuityF1D", /* tp_name */ + sizeof(BPy_ZDiscontinuityF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ZDiscontinuityF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DDouble_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ZDiscontinuityF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.h new file mode 100644 index 00000000000..e6b4be556d7 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_ZDISCONTINUITYF1D_H +#define FREESTYLE_PYTHON_ZDISCONTINUITYF1D_H + +#include "../BPy_UnaryFunction1DDouble.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ZDiscontinuityF1D_Type; + +#define BPy_ZDiscontinuityF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ZDiscontinuityF1D_Type) ) + +/*---------------------------Python BPy_ZDiscontinuityF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DDouble py_uf1D_double; +} BPy_ZDiscontinuityF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_ZDISCONTINUITYF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp new file mode 100644 index 00000000000..a7379c4f769 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp @@ -0,0 +1,99 @@ +#include "BPy_QuantitativeInvisibilityF1D.h" + +#include "../../../view_map/Functions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char QuantitativeInvisibilityF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DUnsigned` > :class:`QuantitativeInvisibilityF1D`\n" +"\n" +".. method:: __init__(iType=IntegrationType.MEAN)\n" +"\n" +" Builds a QuantitativeInvisibilityF1D object.\n" +"\n" +" :arg iType: The integration method used to compute a single value\n" +" from a set of values.\n" +" :type iType: :class:`IntegrationType`\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns the Quantitative Invisibility of an Interface1D element.\n" +" If the Interface1D is a :class:`ViewEdge`, then there is no\n" +" ambiguity concerning the result. But, if the Interface1D results\n" +" of a chaining (chain, stroke), then it might be made of several 1D\n" +" elements of different Quantitative Invisibilities.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: The Quantitative Invisibility of the Interface1D.\n" +" :rtype: int\n"; + +static int QuantitativeInvisibilityF1D___init__( BPy_QuantitativeInvisibilityF1D* self, PyObject *args) +{ + PyObject *obj = 0; + + if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) + return -1; + + IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; + self->py_uf1D_unsigned.uf1D_unsigned = new Functions1D::QuantitativeInvisibilityF1D(t); + return 0; + +} + +/*-----------------------BPy_QuantitativeInvisibilityF1D type definition ------------------------------*/ + +PyTypeObject QuantitativeInvisibilityF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "QuantitativeInvisibilityF1D", /* tp_name */ + sizeof(BPy_QuantitativeInvisibilityF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + QuantitativeInvisibilityF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DUnsigned_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)QuantitativeInvisibilityF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h new file mode 100644 index 00000000000..5bcf5fcc0a2 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_QUANTITATIVEINVISIBILITYF1D_H +#define FREESTYLE_PYTHON_QUANTITATIVEINVISIBILITYF1D_H + +#include "../BPy_UnaryFunction1DUnsigned.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject QuantitativeInvisibilityF1D_Type; + +#define BPy_QuantitativeInvisibilityF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &QuantitativeInvisibilityF1D_Type) ) + +/*---------------------------Python BPy_QuantitativeInvisibilityF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DUnsigned py_uf1D_unsigned; +} BPy_QuantitativeInvisibilityF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_QUANTITATIVEINVISIBILITYF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.cpp new file mode 100644 index 00000000000..4bd03f8fe75 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.cpp @@ -0,0 +1,86 @@ +#include "BPy_GetOccludeeF1D.h" + +#include "../../../view_map/Functions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetOccludeeF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DVectorViewShape` > :class:`GetOccludeeF1D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a GetOccludeeF1D object.\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns a list of occluded shapes covered by this Interface1D.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: A list of occluded shapes covered by the Interface1D.\n" +" :rtype: list of :class:`ViewShape` objects\n"; + +static int GetOccludeeF1D___init__( BPy_GetOccludeeF1D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf1D_vectorviewshape.uf1D_vectorviewshape = new Functions1D::GetOccludeeF1D(); + return 0; +} + +/*-----------------------BPy_GetOccludeeF1D type definition ------------------------------*/ + +PyTypeObject GetOccludeeF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetOccludeeF1D", /* tp_name */ + sizeof(BPy_GetOccludeeF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetOccludeeF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DVectorViewShape_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetOccludeeF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.h new file mode 100644 index 00000000000..c8d5e99a6a7 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETOCCLUDEEF1D_H +#define FREESTYLE_PYTHON_GETOCCLUDEEF1D_H + +#include "../BPy_UnaryFunction1DVectorViewShape.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetOccludeeF1D_Type; + +#define BPy_GetOccludeeF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetOccludeeF1D_Type) ) + +/*---------------------------Python BPy_GetOccludeeF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DVectorViewShape py_uf1D_vectorviewshape; +} BPy_GetOccludeeF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETOCCLUDEEF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.cpp new file mode 100644 index 00000000000..d37102a8447 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.cpp @@ -0,0 +1,86 @@ +#include "BPy_GetOccludersF1D.h" + +#include "../../../view_map/Functions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetOccludersF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DVectorViewShape` > :class:`GetOccludersF1D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a GetOccludersF1D object.\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns a list of occluding shapes that cover this Interface1D.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: A list of occluding shapes that cover the Interface1D.\n" +" :rtype: list of :class:`ViewShape` objects\n"; + +static int GetOccludersF1D___init__( BPy_GetOccludersF1D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf1D_vectorviewshape.uf1D_vectorviewshape = new Functions1D::GetOccludersF1D(); + return 0; +} + +/*-----------------------BPy_GetOccludersF1D type definition ------------------------------*/ + +PyTypeObject GetOccludersF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetOccludersF1D", /* tp_name */ + sizeof(BPy_GetOccludersF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetOccludersF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DVectorViewShape_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetOccludersF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.h new file mode 100644 index 00000000000..ad39ad25c3d --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETOCCLUDERSF1D_H +#define FREESTYLE_PYTHON_GETOCCLUDERSF1D_H + +#include "../BPy_UnaryFunction1DVectorViewShape.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetOccludersF1D_Type; + +#define BPy_GetOccludersF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetOccludersF1D_Type) ) + +/*---------------------------Python BPy_GetOccludersF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DVectorViewShape py_uf1D_vectorviewshape; +} BPy_GetOccludersF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETOCCLUDERSF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.cpp new file mode 100644 index 00000000000..9b2007296f9 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.cpp @@ -0,0 +1,86 @@ +#include "BPy_GetShapeF1D.h" + +#include "../../../view_map/Functions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char GetShapeF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DVectorViewShape` > :class:`GetShapeF1D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a GetShapeF1D object.\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns a list of shapes covered by this Interface1D.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: A list of shapes covered by the Interface1D.\n" +" :rtype: list of :class:`ViewShape` objects\n"; + +static int GetShapeF1D___init__( BPy_GetShapeF1D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf1D_vectorviewshape.uf1D_vectorviewshape = new Functions1D::GetShapeF1D(); + return 0; +} + +/*-----------------------BPy_GetShapeF1D type definition ------------------------------*/ + +PyTypeObject GetShapeF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "GetShapeF1D", /* tp_name */ + sizeof(BPy_GetShapeF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + GetShapeF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DVectorViewShape_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)GetShapeF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.h new file mode 100644 index 00000000000..39d1268c03f --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_GETSHAPEF1D_H +#define FREESTYLE_PYTHON_GETSHAPEF1D_H + +#include "../BPy_UnaryFunction1DVectorViewShape.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject GetShapeF1D_Type; + +#define BPy_GetShapeF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &GetShapeF1D_Type) ) + +/*---------------------------Python BPy_GetShapeF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DVectorViewShape py_uf1D_vectorviewshape; +} BPy_GetShapeF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_GETSHAPEF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.cpp new file mode 100644 index 00000000000..be774a09d99 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.cpp @@ -0,0 +1,84 @@ +#include "BPy_ChainingTimeStampF1D.h" + +#include "../../../view_map/Functions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ChainingTimeStampF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DVoid` > :class:`ChainingTimeStampF1D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a ChainingTimeStampF1D object.\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Sets the chaining time stamp of the Interface1D.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n"; + +static int ChainingTimeStampF1D___init__( BPy_ChainingTimeStampF1D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf1D_void.uf1D_void = new Functions1D::ChainingTimeStampF1D(); + return 0; +} + +/*-----------------------BPy_ChainingTimeStampF1D type definition ------------------------------*/ + +PyTypeObject ChainingTimeStampF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ChainingTimeStampF1D", /* tp_name */ + sizeof(BPy_ChainingTimeStampF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ChainingTimeStampF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DVoid_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ChainingTimeStampF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.h new file mode 100644 index 00000000000..6855ddaf14b --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_CHAININGTIMESTAMPF1D_H +#define FREESTYLE_PYTHON_CHAININGTIMESTAMPF1D_H + +#include "../BPy_UnaryFunction1DVoid.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ChainingTimeStampF1D_Type; + +#define BPy_ChainingTimeStampF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ChainingTimeStampF1D_Type) ) + +/*---------------------------Python BPy_ChainingTimeStampF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DVoid py_uf1D_void; +} BPy_ChainingTimeStampF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_CHAININGTIMESTAMPF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp new file mode 100644 index 00000000000..2d1a1344c4b --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp @@ -0,0 +1,84 @@ +#include "BPy_IncrementChainingTimeStampF1D.h" + +#include "../../../view_map/Functions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char IncrementChainingTimeStampF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DVoid` > :class:`IncrementChainingTimeStampF1D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds an IncrementChainingTimeStampF1D object.\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Increments the chaining time stamp of the Interface1D.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n"; + +static int IncrementChainingTimeStampF1D___init__( BPy_IncrementChainingTimeStampF1D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf1D_void.uf1D_void = new Functions1D::IncrementChainingTimeStampF1D(); + return 0; +} + +/*-----------------------BPy_IncrementChainingTimeStampF1D type definition ------------------------------*/ + +PyTypeObject IncrementChainingTimeStampF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "IncrementChainingTimeStampF1D", /* tp_name */ + sizeof(BPy_IncrementChainingTimeStampF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + IncrementChainingTimeStampF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DVoid_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)IncrementChainingTimeStampF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h new file mode 100644 index 00000000000..a1d5714ab63 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_INCREMENTCHAININGTIMESTAMPF1D_H +#define FREESTYLE_PYTHON_INCREMENTCHAININGTIMESTAMPF1D_H + +#include "../BPy_UnaryFunction1DVoid.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject IncrementChainingTimeStampF1D_Type; + +#define BPy_IncrementChainingTimeStampF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &IncrementChainingTimeStampF1D_Type) ) + +/*---------------------------Python BPy_IncrementChainingTimeStampF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DVoid py_uf1D_void; +} BPy_IncrementChainingTimeStampF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_INCREMENTCHAININGTIMESTAMPF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.cpp new file mode 100644 index 00000000000..c5311501098 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.cpp @@ -0,0 +1,84 @@ +#include "BPy_TimeStampF1D.h" + +#include "../../../view_map/Functions1D.h" +#include "../../BPy_Convert.h" +#include "../../BPy_IntegrationType.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char TimeStampF1D___doc__[] = +"Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DVoid` > :class:`TimeStampF1D`\n" +"\n" +".. method:: __init__()\n" +"\n" +" Builds a TimeStampF1D object.\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns the time stamp of the Interface1D.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n"; + +static int TimeStampF1D___init__( BPy_TimeStampF1D* self, PyObject *args ) +{ + if( !PyArg_ParseTuple(args, "") ) + return -1; + self->py_uf1D_void.uf1D_void = new Functions1D::TimeStampF1D(); + return 0; +} + +/*-----------------------BPy_TimeStampF1D type definition ------------------------------*/ + +PyTypeObject TimeStampF1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "TimeStampF1D", /* tp_name */ + sizeof(BPy_TimeStampF1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + TimeStampF1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryFunction1DVoid_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)TimeStampF1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.h new file mode 100644 index 00000000000..d9bee247c09 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.h @@ -0,0 +1,30 @@ +#ifndef FREESTYLE_PYTHON_TIMESTAMPF1D_H +#define FREESTYLE_PYTHON_TIMESTAMPF1D_H + +#include "../BPy_UnaryFunction1DVoid.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject TimeStampF1D_Type; + +#define BPy_TimeStampF1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &TimeStampF1D_Type) ) + +/*---------------------------Python BPy_TimeStampF1D structure definition----------*/ +typedef struct { + BPy_UnaryFunction1DVoid py_uf1D_void; +} BPy_TimeStampF1D; + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_CHAININGTIMESTAMPF1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.cpp new file mode 100644 index 00000000000..afefa703d14 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.cpp @@ -0,0 +1,78 @@ +#include "BPy_FalseUP0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char FalseUP0D___doc__[] = +"Class hierarchy: :class:`UnaryPredicate0D` > :class:`FalseUP0D`\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Always returns false.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: False.\n" +" :rtype: bool\n"; + +static int FalseUP0D___init__( BPy_FalseUP0D* self, PyObject *args) +{ + if(!( PyArg_ParseTuple(args, "") )) + return -1; + self->py_up0D.up0D = new Predicates0D::FalseUP0D(); + return 0; +} + +/*-----------------------BPy_FalseUP0D type definition ------------------------------*/ + +PyTypeObject FalseUP0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "FalseUP0D", /* tp_name */ + sizeof(BPy_FalseUP0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + FalseUP0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryPredicate0D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)FalseUP0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.h b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.h new file mode 100644 index 00000000000..399941d442d --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.h @@ -0,0 +1,29 @@ +#ifndef FREESTYLE_PYTHON_FALSEUP0D_H +#define FREESTYLE_PYTHON_FALSEUP0D_H + +#include "../BPy_UnaryPredicate0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject FalseUP0D_Type; + +#define BPy_FalseUP0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &FalseUP0D_Type) ) + +/*---------------------------Python BPy_FalseUP0D structure definition----------*/ +typedef struct { + BPy_UnaryPredicate0D py_up0D; +} BPy_FalseUP0D; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_FALSEUP0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.cpp new file mode 100644 index 00000000000..2efc9ed6f74 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.cpp @@ -0,0 +1,78 @@ +#include "BPy_TrueUP0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char TrueUP0D___doc__[] = +"Class hierarchy: :class:`UnaryPredicate0D` > :class:`TrueUP0D`\n" +"\n" +".. method:: __call__(it)\n" +"\n" +" Always returns true.\n" +"\n" +" :arg it: An Interface0DIterator object.\n" +" :type it: :class:`Interface0DIterator`\n" +" :return: True.\n" +" :rtype: bool\n"; + +static int TrueUP0D___init__( BPy_TrueUP0D* self, PyObject *args ) +{ + if(!( PyArg_ParseTuple(args, "") )) + return -1; + self->py_up0D.up0D = new Predicates0D::TrueUP0D(); + return 0; +} + +/*-----------------------BPy_TrueUP0D type definition ------------------------------*/ + +PyTypeObject TrueUP0D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "TrueUP0D", /* tp_name */ + sizeof(BPy_TrueUP0D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + TrueUP0D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryPredicate0D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)TrueUP0D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.h b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.h new file mode 100644 index 00000000000..24976aaa5c9 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.h @@ -0,0 +1,29 @@ +#ifndef FREESTYLE_PYTHON_TRUEUP0D_H +#define FREESTYLE_PYTHON_TRUEUP0D_H + +#include "../BPy_UnaryPredicate0D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject TrueUP0D_Type; + +#define BPy_TrueUP0D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &TrueUP0D_Type) ) + +/*---------------------------Python BPy_TrueUP0D structure definition----------*/ +typedef struct { + BPy_UnaryPredicate0D py_up0D; +} BPy_TrueUP0D; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_TRUEUP0D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.cpp new file mode 100644 index 00000000000..dbbcc4255cf --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.cpp @@ -0,0 +1,79 @@ +#include "BPy_ContourUP1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ContourUP1D___doc__[] = +"Class hierarchy: :class:`UnaryPredicate1D` > :class:`ContourUP1D`\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns true if the Interface1D is a contour. An Interface1D is a\n" +" contour if it is borded by a different shape on each of its sides.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: True if the Interface1D is a contour, false otherwise.\n" +" :rtype: bool\n"; + +static int ContourUP1D___init__( BPy_ContourUP1D* self, PyObject *args ) +{ + if(!( PyArg_ParseTuple(args, "") )) + return -1; + self->py_up1D.up1D = new Predicates1D::ContourUP1D(); + return 0; +} + +/*-----------------------BPy_ContourUP1D type definition ------------------------------*/ + +PyTypeObject ContourUP1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ContourUP1D", /* tp_name */ + sizeof(BPy_ContourUP1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ContourUP1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryPredicate1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ContourUP1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.h new file mode 100644 index 00000000000..a24261a60de --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.h @@ -0,0 +1,29 @@ +#ifndef FREESTYLE_PYTHON_CONTOURUP1D_H +#define FREESTYLE_PYTHON_CONTOURUP1D_H + +#include "../BPy_UnaryPredicate1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ContourUP1D_Type; + +#define BPy_ContourUP1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ContourUP1D_Type) ) + +/*---------------------------Python BPy_ContourUP1D structure definition----------*/ +typedef struct { + BPy_UnaryPredicate1D py_up1D; +} BPy_ContourUP1D; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_CONTOURUP1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.cpp new file mode 100644 index 00000000000..c88f077c23b --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.cpp @@ -0,0 +1,95 @@ +#include "BPy_DensityLowerThanUP1D.h" + +#include "../../stroke/AdvancedPredicates1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char DensityLowerThanUP1D___doc__[] = +"Class hierarchy: :class:`UnaryPredicate1D` > :class:`DensityLowerThanUP1D`\n" +"\n" +".. method:: __init__(threshold, sigma=2.0)\n" +"\n" +" Builds a DensityLowerThanUP1D object.\n" +"\n" +" :arg threshold: The value of the threshold density. Any Interface1D\n" +" having a density lower than this threshold will match.\n" +" :type threshold: float\n" +" :arg sigma: The sigma value defining the density evaluation window\n" +" size used in the :class:`DensityF0D` functor.\n" +" :type sigma: float\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns true if the density evaluated for the Interface1D is less\n" +" than a user-defined density value.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: True if the density is lower than a threshold.\n" +" :rtype: bool\n"; + +static int DensityLowerThanUP1D___init__( BPy_DensityLowerThanUP1D* self, PyObject *args ) +{ + double d1, d2 = 2.0; + + if( !PyArg_ParseTuple(args, "d|d", &d1, &d2) ) + return -1; + + self->py_up1D.up1D = new Predicates1D::DensityLowerThanUP1D(d1,d2); + return 0; +} + +/*-----------------------BPy_DensityLowerThanUP1D type definition ------------------------------*/ + +PyTypeObject DensityLowerThanUP1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "DensityLowerThanUP1D", /* tp_name */ + sizeof(BPy_DensityLowerThanUP1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + DensityLowerThanUP1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryPredicate1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)DensityLowerThanUP1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.h new file mode 100644 index 00000000000..2862b060a0a --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.h @@ -0,0 +1,29 @@ +#ifndef FREESTYLE_PYTHON_DENSITYLOWERTHANUP1D_H +#define FREESTYLE_PYTHON_DENSITYLOWERTHANUP1D_H + +#include "../BPy_UnaryPredicate1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject DensityLowerThanUP1D_Type; + +#define BPy_DensityLowerThanUP1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &DensityLowerThanUP1D_Type) ) + +/*---------------------------Python BPy_DensityLowerThanUP1D structure definition----------*/ +typedef struct { + BPy_UnaryPredicate1D py_up1D; +} BPy_DensityLowerThanUP1D; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_DENSITYLOWERTHANUP1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp new file mode 100644 index 00000000000..2310f5792c5 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp @@ -0,0 +1,89 @@ +#include "BPy_EqualToChainingTimeStampUP1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char EqualToChainingTimeStampUP1D___doc__[] = +"Class hierarchy: :class:`UnaryPredicate1D` > :class:`EqualToChainingTimeStampUP1D`\n" +"\n" +".. method:: __init__(ts)\n" +"\n" +" Builds a EqualToChainingTimeStampUP1D object.\n" +"\n" +" :arg ts: A time stamp value.\n" +" :type ts: int\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns true if the Interface1D's time stamp is equal to a certain\n" +" user-defined value.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: True if the time stamp is equal to a user-defined value.\n" +" :rtype: bool\n"; + +static int EqualToChainingTimeStampUP1D___init__( BPy_EqualToChainingTimeStampUP1D* self, PyObject *args ) +{ + unsigned u; + + if( !PyArg_ParseTuple(args, "I", &u) ) + return -1; + + self->py_up1D.up1D = new Predicates1D::EqualToChainingTimeStampUP1D(u); + return 0; +} + +/*-----------------------BPy_EqualToChainingTimeStampUP1D type definition ------------------------------*/ + +PyTypeObject EqualToChainingTimeStampUP1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "EqualToChainingTimeStampUP1D", /* tp_name */ + sizeof(BPy_EqualToChainingTimeStampUP1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + EqualToChainingTimeStampUP1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryPredicate1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)EqualToChainingTimeStampUP1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h new file mode 100644 index 00000000000..39423423b8e --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h @@ -0,0 +1,29 @@ +#ifndef FREESTYLE_PYTHON_EQUALTOCHAININGTIMESTAMPUP1D_H +#define FREESTYLE_PYTHON_EQUALTOCHAININGTIMESTAMPUP1D_H + +#include "../BPy_UnaryPredicate1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject EqualToChainingTimeStampUP1D_Type; + +#define BPy_EqualToChainingTimeStampUP1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &EqualToChainingTimeStampUP1D_Type) ) + +/*---------------------------Python BPy_EqualToChainingTimeStampUP1D structure definition----------*/ +typedef struct { + BPy_UnaryPredicate1D py_up1D; +} BPy_EqualToChainingTimeStampUP1D; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_EQUALTOCHAININGTIMESTAMPUP1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.cpp new file mode 100644 index 00000000000..97415b2b28f --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.cpp @@ -0,0 +1,89 @@ +#include "BPy_EqualToTimeStampUP1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char EqualToTimeStampUP1D___doc__[] = +"Class hierarchy: :class:`UnaryPredicate1D` > :class:`EqualToTimeStampUP1D`\n" +"\n" +".. method:: __init__(ts)\n" +"\n" +" Builds a EqualToTimeStampUP1D object.\n" +"\n" +" :arg ts: A time stamp value.\n" +" :type ts: int\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns true if the Interface1D's time stamp is equal to a certain\n" +" user-defined value.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: True if the time stamp is equal to a user-defined value.\n" +" :rtype: bool\n"; + +static int EqualToTimeStampUP1D___init__( BPy_EqualToTimeStampUP1D* self, PyObject *args ) +{ + unsigned u; + + if( !PyArg_ParseTuple(args, "I", &u) ) + return -1; + + self->py_up1D.up1D = new Predicates1D::EqualToTimeStampUP1D(u); + return 0; +} + +/*-----------------------BPy_EqualToTimeStampUP1D type definition ------------------------------*/ + +PyTypeObject EqualToTimeStampUP1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "EqualToTimeStampUP1D", /* tp_name */ + sizeof(BPy_EqualToTimeStampUP1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + EqualToTimeStampUP1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryPredicate1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)EqualToTimeStampUP1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.h new file mode 100644 index 00000000000..538dc400dc2 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.h @@ -0,0 +1,29 @@ +#ifndef FREESTYLE_PYTHON_EQUALTOTIMESTAMPUP1D_H +#define FREESTYLE_PYTHON_EQUALTOTIMESTAMPUP1D_H + +#include "../BPy_UnaryPredicate1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject EqualToTimeStampUP1D_Type; + +#define BPy_EqualToTimeStampUP1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &EqualToTimeStampUP1D_Type) ) + +/*---------------------------Python BPy_EqualToTimeStampUP1D structure definition----------*/ +typedef struct { + BPy_UnaryPredicate1D py_up1D; +} BPy_EqualToTimeStampUP1D; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_EQUALTOTIMESTAMPUP1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.cpp new file mode 100644 index 00000000000..3c9156f3a89 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.cpp @@ -0,0 +1,81 @@ +#include "BPy_ExternalContourUP1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ExternalContourUP1D___doc__[] = +"Class hierarchy: :class:`UnaryPredicate1D` > :class:`ExternalContourUP1D`\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns true if the Interface1D is an external contour. An\n" +" Interface1D is an external contour if it is borded by no shape on\n" +" one of its sides.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: True if the Interface1D is an external contour, false\n" +" otherwise.\n" +" :rtype: bool\n"; + +static int ExternalContourUP1D___init__( BPy_ExternalContourUP1D* self, PyObject *args ) +{ + if(!( PyArg_ParseTuple(args, "") )) + return -1; + self->py_up1D.up1D = new Predicates1D::ExternalContourUP1D(); + return 0; +} + +/*-----------------------BPy_ExternalContourUP1D type definition ------------------------------*/ + +PyTypeObject ExternalContourUP1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ExternalContourUP1D", /* tp_name */ + sizeof(BPy_ExternalContourUP1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ExternalContourUP1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryPredicate1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ExternalContourUP1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.h new file mode 100644 index 00000000000..31300f04dfe --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.h @@ -0,0 +1,29 @@ +#ifndef FREESTYLE_PYTHON_EXTERNALCONTOURUP1D_H +#define FREESTYLE_PYTHON_EXTERNALCONTOURUP1D_H + +#include "../BPy_UnaryPredicate1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ExternalContourUP1D_Type; + +#define BPy_ExternalContourUP1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ExternalContourUP1D_Type) ) + +/*---------------------------Python BPy_ExternalContourUP1D structure definition----------*/ +typedef struct { + BPy_UnaryPredicate1D py_up1D; +} BPy_ExternalContourUP1D; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_EXTERNALCONTOURUP1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.cpp new file mode 100644 index 00000000000..ac878a7770b --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.cpp @@ -0,0 +1,78 @@ +#include "BPy_FalseUP1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char FalseUP1D___doc__[] = +"Class hierarchy: :class:`UnaryPredicate1D` > :class:`FalseUP1D`\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Always returns false.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: False.\n" +" :rtype: bool\n"; + +static int FalseUP1D___init__( BPy_FalseUP1D* self, PyObject *args ) +{ + if(!( PyArg_ParseTuple(args, "") )) + return -1; + self->py_up1D.up1D = new Predicates1D::FalseUP1D(); + return 0; +} + +/*-----------------------BPy_FalseUP1D type definition ------------------------------*/ + +PyTypeObject FalseUP1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "FalseUP1D", /* tp_name */ + sizeof(BPy_FalseUP1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + FalseUP1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryPredicate1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)FalseUP1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.h new file mode 100644 index 00000000000..273e4962db9 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.h @@ -0,0 +1,29 @@ +#ifndef FREESTYLE_PYTHON_FALSEUP1D_H +#define FREESTYLE_PYTHON_FALSEUP1D_H + +#include "../BPy_UnaryPredicate1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject FalseUP1D_Type; + +#define BPy_FalseUP1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &FalseUP1D_Type) ) + +/*---------------------------Python BPy_FalseUP1D structure definition----------*/ +typedef struct { + BPy_UnaryPredicate1D py_up1D; +} BPy_FalseUP1D; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_FALSEUP1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp new file mode 100644 index 00000000000..cabc4689a03 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp @@ -0,0 +1,92 @@ +#include "BPy_QuantitativeInvisibilityUP1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char QuantitativeInvisibilityUP1D___doc__[] = +"Class hierarchy: :class:`UnaryPredicate1D` > :class:`QuantitativeInvisibilityUP1D`\n" +"\n" +".. method:: __init__(qi=0)\n" +"\n" +" Builds a QuantitativeInvisibilityUP1D object.\n" +"\n" +" :arg qi: The Quantitative Invisibility you want the Interface1D to\n" +" have.\n" +" :type qi: int\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns true if the Quantitative Invisibility evaluated at an\n" +" Interface1D, using the :class:`QuantitativeInvisibilityF1D`\n" +" functor, equals a certain user-defined value.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: True if Quantitative Invisibility equals a user-defined\n" +" value.\n" +" :rtype: bool\n"; + +static int QuantitativeInvisibilityUP1D___init__( BPy_QuantitativeInvisibilityUP1D* self, PyObject *args ) +{ + int i = 0; + + if( !PyArg_ParseTuple(args, "|i", &i) ) + return -1; + + self->py_up1D.up1D = new Predicates1D::QuantitativeInvisibilityUP1D(i); + return 0; +} + +/*-----------------------BPy_QuantitativeInvisibilityUP1D type definition ------------------------------*/ + +PyTypeObject QuantitativeInvisibilityUP1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "QuantitativeInvisibilityUP1D", /* tp_name */ + sizeof(BPy_QuantitativeInvisibilityUP1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + QuantitativeInvisibilityUP1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryPredicate1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)QuantitativeInvisibilityUP1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h new file mode 100644 index 00000000000..f120ecb9778 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h @@ -0,0 +1,29 @@ +#ifndef FREESTYLE_PYTHON_QUANTITATIVEINVISIBILITYUP1D_H +#define FREESTYLE_PYTHON_QUANTITATIVEINVISIBILITYUP1D_H + +#include "../BPy_UnaryPredicate1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject QuantitativeInvisibilityUP1D_Type; + +#define BPy_QuantitativeInvisibilityUP1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &QuantitativeInvisibilityUP1D_Type) ) + +/*---------------------------Python BPy_QuantitativeInvisibilityUP1D structure definition----------*/ +typedef struct { + BPy_UnaryPredicate1D py_up1D; +} BPy_QuantitativeInvisibilityUP1D; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_QUANTITATIVEINVISIBILITYUP1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.cpp new file mode 100644 index 00000000000..9e6e57c8d94 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.cpp @@ -0,0 +1,92 @@ +#include "BPy_ShapeUP1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char ShapeUP1D___doc__[] = +"Class hierarchy: :class:`UnaryPredicate1D` > :class:`ShapeUP1D`\n" +"\n" +".. method:: __init__(idFirst, idSecond=0)\n" +"\n" +" Builds a ShapeUP1D object.\n" +"\n" +" :arg idFirst: The first Id component.\n" +" :type idFirst: int\n" +" :arg idSecond: The second Id component.\n" +" :type idSecond: int\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Returns true if the shape to which the Interface1D belongs to has\n" +" the same :class:`Id` as the one specified by the user.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: True if Interface1D belongs to the shape of the\n" +" user-specified Id.\n" +" :rtype: bool\n"; + +static int ShapeUP1D___init__( BPy_ShapeUP1D* self, PyObject *args ) +{ + unsigned u1, u2 = 0; + + if( !PyArg_ParseTuple(args, "I|I", &u1, &u2) ) + return -1; + + self->py_up1D.up1D = new Predicates1D::ShapeUP1D(u1,u2); + return 0; +} + +/*-----------------------BPy_ShapeUP1D type definition ------------------------------*/ + +PyTypeObject ShapeUP1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "ShapeUP1D", /* tp_name */ + sizeof(BPy_ShapeUP1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + ShapeUP1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryPredicate1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ShapeUP1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.h new file mode 100644 index 00000000000..ce6d0276edd --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.h @@ -0,0 +1,29 @@ +#ifndef FREESTYLE_PYTHON_SHAPEUP1D_H +#define FREESTYLE_PYTHON_SHAPEUP1D_H + +#include "../BPy_UnaryPredicate1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject ShapeUP1D_Type; + +#define BPy_ShapeUP1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &ShapeUP1D_Type) ) + +/*---------------------------Python BPy_ShapeUP1D structure definition----------*/ +typedef struct { + BPy_UnaryPredicate1D py_up1D; +} BPy_ShapeUP1D; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_SHAPEUP1D_H */ diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.cpp new file mode 100644 index 00000000000..01da1a44453 --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.cpp @@ -0,0 +1,78 @@ +#include "BPy_TrueUP1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +//------------------------INSTANCE METHODS ---------------------------------- + +static char TrueUP1D___doc__[] = +"Class hierarchy: :class:`UnaryPredicate1D` > :class:`TrueUP1D`\n" +"\n" +".. method:: __call__(inter)\n" +"\n" +" Always returns true.\n" +"\n" +" :arg inter: An Interface1D object.\n" +" :type inter: :class:`Interface1D`\n" +" :return: True.\n" +" :rtype: bool\n"; + +static int TrueUP1D___init__( BPy_TrueUP1D* self, PyObject *args ) +{ + if(!( PyArg_ParseTuple(args, "") )) + return -1; + self->py_up1D.up1D = new Predicates1D::TrueUP1D(); + return 0; +} + +/*-----------------------BPy_TrueUP1D type definition ------------------------------*/ + +PyTypeObject TrueUP1D_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "TrueUP1D", /* tp_name */ + sizeof(BPy_TrueUP1D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + TrueUP1D___doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + &UnaryPredicate1D_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)TrueUP1D___init__, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ +}; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.h new file mode 100644 index 00000000000..5a01ad42d2a --- /dev/null +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.h @@ -0,0 +1,29 @@ +#ifndef FREESTYLE_PYTHON_TRUEUP1D_H +#define FREESTYLE_PYTHON_TRUEUP1D_H + +#include "../BPy_UnaryPredicate1D.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject TrueUP1D_Type; + +#define BPy_TrueUP1D_Check(v) ( PyObject_IsInstance( (PyObject *) v, (PyObject *) &TrueUP1D_Type) ) + +/*---------------------------Python BPy_TrueUP1D structure definition----------*/ +typedef struct { + BPy_UnaryPredicate1D py_up1D; +} BPy_TrueUP1D; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_TRUEUP1D_H */ |