2013-02-23 18:32:28 +00:00
|
|
|
/*
|
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** \file source/blender/freestyle/intern/python/BPy_Freestyle.cpp
|
|
|
|
|
* \ingroup freestyle
|
|
|
|
|
*/
|
|
|
|
|
|
2008-07-23 07:56:08 +00:00
|
|
|
#include "BPy_Freestyle.h"
|
|
|
|
|
|
2008-07-24 08:29:48 +00:00
|
|
|
#include "BPy_BBox.h"
|
2008-07-23 07:56:08 +00:00
|
|
|
#include "BPy_BinaryPredicate0D.h"
|
|
|
|
|
#include "BPy_BinaryPredicate1D.h"
|
2009-07-26 11:19:37 +00:00
|
|
|
#include "BPy_ContextFunctions.h"
|
2010-07-28 00:43:45 +00:00
|
|
|
#include "BPy_Convert.h"
|
2008-08-01 02:25:21 +00:00
|
|
|
#include "BPy_FrsMaterial.h"
|
2008-08-01 02:15:25 +00:00
|
|
|
#include "BPy_FrsNoise.h"
|
2008-07-23 07:56:08 +00:00
|
|
|
#include "BPy_Id.h"
|
|
|
|
|
#include "BPy_IntegrationType.h"
|
|
|
|
|
#include "BPy_Interface0D.h"
|
|
|
|
|
#include "BPy_Interface1D.h"
|
2008-07-26 21:47:39 +00:00
|
|
|
#include "BPy_Iterator.h"
|
2008-07-23 07:56:08 +00:00
|
|
|
#include "BPy_MediumType.h"
|
|
|
|
|
#include "BPy_Nature.h"
|
2008-07-29 05:45:16 +00:00
|
|
|
#include "BPy_Operators.h"
|
2008-07-24 08:29:48 +00:00
|
|
|
#include "BPy_SShape.h"
|
2008-07-23 07:56:08 +00:00
|
|
|
#include "BPy_StrokeAttribute.h"
|
|
|
|
|
#include "BPy_StrokeShader.h"
|
|
|
|
|
#include "BPy_UnaryFunction0D.h"
|
|
|
|
|
#include "BPy_UnaryFunction1D.h"
|
|
|
|
|
#include "BPy_UnaryPredicate0D.h"
|
|
|
|
|
#include "BPy_UnaryPredicate1D.h"
|
2008-07-26 21:47:39 +00:00
|
|
|
#include "BPy_ViewMap.h"
|
2008-07-24 08:29:48 +00:00
|
|
|
#include "BPy_ViewShape.h"
|
|
|
|
|
|
soc-2008-mxcurioni: reimplemented the initialization/allocation for base classes. The Python object type tp_new slot is now set to PyType_GenericNew, instead of the former custom functions. As a note, by default, Python does not set this slot: it is therefore mandatory for the base classes. For children classes, only __init__ is needed.
To make our base classes subclasses, the Py_TPFLAGS_BASETYPE flag was added to the object type tp_flags slot.
Finally, I began to implement CurvePoint, descendant of Interface0D. This commit allowed me to verify that my SWIG replacement method works: interfaces are well taken into account by children. For a test, use the following code:
================================
import Blender
from Blender import Freestyle
from Blender.Freestyle import *
print Interface0D()
print CurvePoint()
================================
The __repr__ method is only implemented in Interface0D:
PyObject * Interface0D___repr__(BPy_Interface0D* self)
{
return PyString_FromFormat("type: %s - address: %p", self->if0D->getExactTypeName().c_str(), self->if0D );}
and the result is of the form:
type: Interface0D - address: 0x18e5ccc0
type: CurvePoint - address: 0x18e473f0
As you can see, the correct getExactTypeName of the class is called.
2008-07-15 05:33:12 +00:00
|
|
|
|
2008-07-12 04:02:08 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2010-04-17 23:47:47 +00:00
|
|
|
//------------------------ MODULE FUNCTIONS ----------------------------------
|
2008-07-12 04:02:08 +00:00
|
|
|
|
2010-04-17 23:47:47 +00:00
|
|
|
#include "FRS_freestyle.h"
|
2011-03-06 12:13:32 +00:00
|
|
|
#include "RNA_access.h"
|
2010-04-17 23:47:47 +00:00
|
|
|
#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";
|
|
|
|
|
|
2013-02-24 02:32:56 +00:00
|
|
|
static PyObject *Freestyle_getCurrentScene(PyObject *self)
|
2010-04-17 23:47:47 +00:00
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
2009-09-27 00:32:20 +00:00
|
|
|
|
2010-07-28 00:43:45 +00:00
|
|
|
#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;
|
2013-10-31 07:41:40 +00:00
|
|
|
if (!strcmp(type, "SOFT_LIGHT")) return MA_RAMP_SOFT;
|
|
|
|
|
if (!strcmp(type, "LINEAR_LIGHT")) return MA_RAMP_LINEAR;
|
2010-07-28 00:43:45 +00:00
|
|
|
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";
|
|
|
|
|
|
2013-02-24 02:32:56 +00:00
|
|
|
static PyObject *Freestyle_blendRamp(PyObject *self, PyObject *args)
|
2010-07-28 00:43:45 +00:00
|
|
|
{
|
|
|
|
|
PyObject *obj1, *obj2;
|
|
|
|
|
char *s;
|
|
|
|
|
int type;
|
|
|
|
|
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");
|
2013-11-03 14:25:37 +00:00
|
|
|
return NULL;
|
2010-07-28 00:43:45 +00:00
|
|
|
}
|
2013-11-03 14:25:37 +00:00
|
|
|
if (!float_array_from_PyObject(obj1, a, 3)) {
|
2013-03-07 23:17:23 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError,
|
|
|
|
|
"argument 2 must be a 3D vector (either a tuple/list of 3 elements or Vector)");
|
2013-11-03 14:25:37 +00:00
|
|
|
return NULL;
|
2010-07-28 00:43:45 +00:00
|
|
|
}
|
2013-11-03 14:25:37 +00:00
|
|
|
if (!float_array_from_PyObject(obj2, b, 3)) {
|
2013-03-07 23:17:23 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError,
|
|
|
|
|
"argument 4 must be a 3D vector (either a tuple/list of 3 elements or Vector)");
|
2013-11-03 14:25:37 +00:00
|
|
|
return NULL;
|
2010-07-28 00:43:45 +00:00
|
|
|
}
|
2011-11-26 13:11:55 +00:00
|
|
|
ramp_blend(type, a, fac, b);
|
2013-02-24 02:32:56 +00:00
|
|
|
return Vector_CreatePyObject(a, 3, Py_NEW, NULL);
|
2010-07-28 00:43:45 +00:00
|
|
|
}
|
|
|
|
|
|
2010-07-26 23:50:32 +00:00
|
|
|
#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"
|
2010-07-28 00:43:45 +00:00
|
|
|
" :rtype: :class:`mathutils.Vector`\n";
|
2010-07-26 23:50:32 +00:00
|
|
|
|
2013-02-24 02:32:56 +00:00
|
|
|
static PyObject *Freestyle_evaluateColorRamp(PyObject *self, PyObject *args)
|
2010-07-26 23:50:32 +00:00
|
|
|
{
|
|
|
|
|
BPy_StructRNA *py_srna;
|
|
|
|
|
ColorBand *coba;
|
|
|
|
|
float in, out[4];
|
|
|
|
|
|
2013-02-24 02:32:56 +00:00
|
|
|
if (!(PyArg_ParseTuple(args, "O!f", &pyrna_struct_Type, &py_srna, &in)))
|
2010-07-26 23:50:32 +00:00
|
|
|
return NULL;
|
2013-02-24 02:32:56 +00:00
|
|
|
if (!RNA_struct_is_a(py_srna->ptr.type, &RNA_ColorRamp)) {
|
2010-07-26 23:50:32 +00:00
|
|
|
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;
|
|
|
|
|
}
|
2013-02-24 02:32:56 +00:00
|
|
|
return Vector_CreatePyObject(out, 4, Py_NEW, NULL);
|
2010-07-26 23:50:32 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-31 20:57:39 +00:00
|
|
|
#include "DNA_color_types.h"
|
2010-07-26 23:50:32 +00:00
|
|
|
#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";
|
|
|
|
|
|
2013-02-24 02:32:56 +00:00
|
|
|
static PyObject *Freestyle_evaluateCurveMappingF(PyObject *self, PyObject *args)
|
2010-07-26 23:50:32 +00:00
|
|
|
{
|
|
|
|
|
BPy_StructRNA *py_srna;
|
|
|
|
|
CurveMapping *cumap;
|
|
|
|
|
int cur;
|
|
|
|
|
float value;
|
|
|
|
|
|
2013-02-24 02:32:56 +00:00
|
|
|
if (!(PyArg_ParseTuple(args, "O!if", &pyrna_struct_Type, &py_srna, &cur, &value)))
|
2010-07-26 23:50:32 +00:00
|
|
|
return NULL;
|
2013-02-24 02:32:56 +00:00
|
|
|
if (!RNA_struct_is_a(py_srna->ptr.type, &RNA_CurveMapping)) {
|
2010-07-26 23:50:32 +00:00
|
|
|
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;
|
2012-09-23 15:05:29 +00:00
|
|
|
curvemapping_initialize(cumap);
|
2011-01-31 20:57:39 +00:00
|
|
|
/* disable extrapolation if enabled */
|
|
|
|
|
if ((cumap->cm[cur].flag & CUMA_EXTEND_EXTRAPOLATE)) {
|
2013-02-24 02:32:56 +00:00
|
|
|
cumap->cm[cur].flag &= ~(CUMA_EXTEND_EXTRAPOLATE);
|
2011-01-31 20:57:39 +00:00
|
|
|
curvemapping_changed(cumap, 0);
|
|
|
|
|
}
|
2010-07-26 23:50:32 +00:00
|
|
|
return PyFloat_FromDouble(curvemapping_evaluateF(cumap, cur, value));
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-17 23:47:47 +00:00
|
|
|
/*-----------------------Freestyle module docstring----------------------------*/
|
2009-09-27 00:32:20 +00:00
|
|
|
|
2010-08-28 13:52:49 +00:00
|
|
|
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"
|
2013-02-23 03:07:19 +00:00
|
|
|
" - :class:`WithinImageBoundaryUP1D`\n"
|
2010-08-28 13:52:49 +00:00
|
|
|
"\n"
|
|
|
|
|
"- :class:`ViewMap`\n"
|
|
|
|
|
"- :class:`ViewShape`\n"
|
|
|
|
|
"- :class:`IntegrationType`\n"
|
|
|
|
|
"- :class:`MediumType`\n"
|
|
|
|
|
"- :class:`Nature`\n"
|
|
|
|
|
"\n";
|
2009-09-27 00:32:20 +00:00
|
|
|
|
|
|
|
|
/*-----------------------Freestyle module method def---------------------------*/
|
|
|
|
|
|
|
|
|
|
static PyMethodDef module_functions[] = {
|
2013-02-24 02:32:56 +00:00
|
|
|
{"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__},
|
2013-03-07 23:17:23 +00:00
|
|
|
{"evaluateCurveMappingF", (PyCFunction) Freestyle_evaluateCurveMappingF, METH_VARARGS,
|
|
|
|
|
Freestyle_evaluateCurveMappingF___doc__},
|
2008-07-12 04:02:08 +00:00
|
|
|
{NULL, NULL, 0, NULL}
|
|
|
|
|
};
|
|
|
|
|
|
2009-09-27 00:32:20 +00:00
|
|
|
/*-----------------------Freestyle module definition---------------------------*/
|
2008-07-12 04:02:08 +00:00
|
|
|
|
2009-09-27 00:32:20 +00:00
|
|
|
static PyModuleDef module_definition = {
|
|
|
|
|
PyModuleDef_HEAD_INIT,
|
2013-11-24 00:28:01 +00:00
|
|
|
"_freestyle",
|
2009-09-27 00:32:20 +00:00
|
|
|
module_docstring,
|
|
|
|
|
-1,
|
|
|
|
|
module_functions
|
2008-07-12 04:02:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//-------------------MODULE INITIALIZATION--------------------------------
|
2013-02-24 02:32:56 +00:00
|
|
|
PyObject *Freestyle_Init(void)
|
2008-07-12 04:02:08 +00:00
|
|
|
{
|
2008-07-15 01:07:19 +00:00
|
|
|
PyObject *module;
|
2008-07-12 04:02:08 +00:00
|
|
|
|
2008-07-15 01:07:19 +00:00
|
|
|
// initialize modules
|
2009-09-27 00:32:20 +00:00
|
|
|
module = PyModule_Create(&module_definition);
|
2013-02-24 02:32:56 +00:00
|
|
|
if (!module)
|
2009-09-27 00:32:20 +00:00
|
|
|
return NULL;
|
|
|
|
|
PyDict_SetItemString(PySys_GetObject("modules"), module_definition.m_name, module);
|
2014-04-11 16:35:46 +09:00
|
|
|
|
|
|
|
|
// update 'sys.path' for Freestyle Python API modules
|
|
|
|
|
const char * const path = BLI_get_folder(BLENDER_SYSTEM_SCRIPTS, "freestyle");
|
|
|
|
|
if (path) {
|
|
|
|
|
char modpath[FILE_MAX];
|
|
|
|
|
BLI_join_dirfile(modpath, sizeof(modpath), path, "modules");
|
|
|
|
|
PyObject *sys_path = PySys_GetObject("path"); /* borrow */
|
|
|
|
|
PyObject *py_modpath = PyUnicode_FromString(modpath);
|
|
|
|
|
PyList_Append(sys_path, py_modpath);
|
|
|
|
|
Py_DECREF(py_modpath);
|
|
|
|
|
#if 0
|
|
|
|
|
printf("Adding Python path: %s\n", modpath);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
printf("Freestyle: couldn't find 'scripts/freestyle/modules', Freestyle won't work properly.\n");
|
|
|
|
|
}
|
2008-07-23 07:56:08 +00:00
|
|
|
|
2008-07-15 01:07:19 +00:00
|
|
|
// attach its classes (adding the object types to the module)
|
2008-07-23 07:56:08 +00:00
|
|
|
|
|
|
|
|
// those classes have to be initialized before the others
|
2013-02-24 02:32:56 +00:00
|
|
|
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);
|
2008-07-26 21:47:39 +00:00
|
|
|
|
2008-07-15 01:07:19 +00:00
|
|
|
return module;
|
2008-07-12 04:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
2009-10-15 19:38:45 +00:00
|
|
|
#endif
|