Files
test/source/blender/freestyle/intern/python/BPy_Convert.h

182 lines
6.6 KiB
C
Raw Normal View History

2013-02-23 18:32:28 +00:00
/*
* 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.
*/
/** \file
* \ingroup freestyle
2013-02-23 18:32:28 +00:00
*/
2013-02-23 18:50:33 +00:00
#ifndef __FREESTYLE_PYTHON_CONVERT_H__
#define __FREESTYLE_PYTHON_CONVERT_H__
extern "C" {
#include <Python.h>
}
#include <typeinfo>
#include "../geometry/Geom.h"
Attempt to fix a potential name conflict between Freestyle and the compositor. A crash in the Freestyle renderer was reported by Ton on IRC with a stack trace below. Note that #2 is in Freestyle, whereas #1 is in the compositor. The problem was observed in a debug build on OS X 10.7 (gcc 4.2, openmp disabled, no llvm). ---------------------------------------------------------------------- Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: 13 at address: 0x0000000000000000 [Switching to process 72386 thread 0xf303] 0x0000000100c129f3 in NodeBase::~NodeBase (this=0x10e501c80) at COM_NodeBase.cpp:43 43 delete (this->m_outputsockets.back()); Current language: auto; currently c++ (gdb) where #0 0x0000000100c129f3 in NodeBase::~NodeBase (this=0x10e501c80) at COM_NodeBase.cpp:43 #1 0x0000000100c29066 in Node::~Node (this=0x10e501c80) at COM_Node.h:49 #2 0x000000010089c273 in NodeShape::~NodeShape (this=0x10e501c80) at NodeShape.cpp:43 #3 0x000000010089910b in NodeGroup::destroy (this=0x10e501da0) at NodeGroup.cpp:61 #4 0x00000001008990cd in NodeGroup::destroy (this=0x10e5014b0) at NodeGroup.cpp:59 #5 0x00000001008990cd in NodeGroup::destroy (this=0x114e18da0) at NodeGroup.cpp:59 #6 0x00000001007e6602 in Controller::ClearRootNode (this=0x114e19640) at Controller.cpp:329 #7 0x00000001007ea52e in Controller::LoadMesh (this=0x114e19640, re=0x10aba4638, srl=0x1140f5258) at Controller.cpp:302 #8 0x00000001008030ad in prepare (re=0x10aba4638, srl=0x1140f5258) at FRS_freestyle.cpp:302 #9 0x000000010080457a in FRS_do_stroke_rendering (re=0x10aba4638, srl=0x1140f5258) at FRS_freestyle.cpp:600 #10 0x00000001006aeb9d in add_freestyle (re=0x10aba4638) at pipeline.c:1584 #11 0x00000001006aceb7 in do_render_3d (re=0x10aba4638) at pipeline.c:1094 #12 0x00000001006ae061 in do_render_fields_blur_3d (re=0x10aba4638) at pipeline.c:1367 #13 0x00000001006afa16 in do_render_composite_fields_blur_3d (re=0x10aba4638) at pipeline.c:1815 #14 0x00000001006b04e4 in do_render_all_options (re=0x10aba4638) at pipeline.c:2021 ---------------------------------------------------------------------- Apparently a name conflict between the two Blender modules is taking place. The present commit hence intends to address it by putting all the Freestyle C++ classes in the namespace 'Freestyle'. This revision will also prevent potential name conflicts with other Blender modules in the future. Special thanks to Lukas Toenne for the help with C++ namespace.
2013-04-09 00:46:49 +00:00
using namespace Freestyle;
using namespace Freestyle::Geometry;
// BBox
#include "../geometry/BBox.h"
// FEdge, FEdgeSharp, FEdgeSmooth, SShape, SVertex, FEdgeInternal::SVertexIterator
2018-06-17 17:05:14 +02:00
#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 "mathutils/mathutils.h"
#include "generic/python_utildefines.h"
//==============================
// C++ => Python
//==============================
2018-10-11 08:49:28 +11:00
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(const 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);
2018-10-11 08:49:28 +11:00
PyObject *BPy_IntegrationType_from_IntegrationType(IntegrationType i);
PyObject *BPy_FrsMaterial_from_FrsMaterial(const FrsMaterial &m);
2018-10-11 08:49:28 +11:00
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,
bool reversed);
PyObject *BPy_CurvePointIterator_from_CurvePointIterator(CurveInternal::CurvePointIterator &cp_it);
PyObject *BPy_StrokeVertexIterator_from_StrokeVertexIterator(
StrokeInternal::StrokeVertexIterator &sv_it, bool reversed);
PyObject *BPy_SVertexIterator_from_SVertexIterator(ViewEdgeInternal::SVertexIterator &sv_it);
PyObject *BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator(
ViewVertexInternal::orientedViewEdgeIterator &ove_it, bool 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++
//==============================
2013-02-23 18:50:33 +00:00
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);
bool Vec2f_ptr_from_PyObject(PyObject *obj, Vec2f &vec);
bool Vec3f_ptr_from_PyObject(PyObject *obj, Vec3f &vec);
bool Vec3r_ptr_from_PyObject(PyObject *obj, Vec3r &vec);
bool Vec2f_ptr_from_Vector(PyObject *obj, Vec2f &vec);
bool Vec3f_ptr_from_Vector(PyObject *obj, Vec3f &vec);
bool Vec3r_ptr_from_Vector(PyObject *obj, Vec3r &vec);
bool Vec3f_ptr_from_Color(PyObject *obj, Vec3f &vec);
bool Vec3r_ptr_from_Color(PyObject *obj, Vec3r &vec);
bool Vec2f_ptr_from_PyList(PyObject *obj, Vec2f &vec);
bool Vec3f_ptr_from_PyList(PyObject *obj, Vec3f &vec);
bool Vec3r_ptr_from_PyList(PyObject *obj, Vec3r &vec);
bool Vec2f_ptr_from_PyTuple(PyObject *obj, Vec2f &vec);
bool Vec3f_ptr_from_PyTuple(PyObject *obj, Vec3f &vec);
bool Vec3r_ptr_from_PyTuple(PyObject *obj, Vec3r &vec);
bool float_array_from_PyObject(PyObject *obj, float *v, int n);
int convert_v4(PyObject *obj, void *v);
int convert_v3(PyObject *obj, void *v);
int convert_v2(PyObject *obj, void *v);
///////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif
2013-02-23 18:50:33 +00:00
#endif /* __FREESTYLE_PYTHON_CONVERT_H__ */