* Added a generic helper function for parsing PyObject arguments as N-dimensional...
[blender.git] / source / blender / freestyle / intern / python / BPy_Convert.h
1 #ifndef FREESTYLE_PYTHON_CONVERT_H
2 #define FREESTYLE_PYTHON_CONVERT_H
3
4 #include <Python.h>
5 #include <typeinfo>
6
7 #include "../geometry/Geom.h"
8 using namespace Geometry;
9
10 // BBox
11 #include "../geometry/BBox.h"
12
13 // FEdge, FEdgeSharp, FEdgeSmooth, SShape, SVertex, FEdgeInternal::SVertexIterator
14 #include "../view_map/Silhouette.h" 
15
16 // Id
17 #include "../system/Id.h"
18
19 // Interface0D, Interface0DIteratorNested, Interface0DIterator
20 #include "../view_map/Interface0D.h"
21
22 // Interface1D
23 #include "../view_map/Interface1D.h"
24
25 // FrsMaterial
26 #include "../scene_graph/FrsMaterial.h"
27
28 // Nature::VertexNature, Nature::EdgeNature
29 #include "../winged_edge/Nature.h"
30
31 // Stroke, StrokeAttribute, StrokeVertex
32 #include "../stroke/Stroke.h"
33
34 // NonTVertex, TVertex, ViewEdge, ViewMap, ViewShape, ViewVertex
35 #include "../view_map/ViewMap.h"
36
37 // CurvePoint, Curve
38 #include "../stroke/Curve.h"
39
40 // Chain
41 #include "../stroke/Chain.h"
42
43 //====== ITERATORS
44
45 // AdjacencyIterator, ChainingIterator, ChainSilhouetteIterator, ChainPredicateIterator
46 #include "../stroke/ChainingIterators.h"
47
48 // ViewVertexInternal::orientedViewEdgeIterator
49 // ViewEdgeInternal::SVertexIterator
50 // ViewEdgeInternal::ViewEdgeIterator
51 #include "../view_map/ViewMapIterators.h"
52
53 // StrokeInternal::StrokeVertexIterator
54 #include "../stroke/StrokeIterators.h"
55
56 // CurveInternal::CurvePointIterator
57 #include "../stroke/CurveIterators.h"
58
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62
63 ///////////////////////////////////////////////////////////////////////////////////////////
64
65 #include "mathutils/mathutils.h"
66
67 //==============================
68 // C++ => Python
69 //==============================
70
71 PyObject * PyBool_from_bool( bool b );
72 PyObject * Vector_from_Vec2f( Vec2f& v );
73 PyObject * Vector_from_Vec3f( Vec3f& v );
74 PyObject * Vector_from_Vec3r( Vec3r& v );
75
76 PyObject * Any_BPy_Interface0D_from_Interface0D( Interface0D& if0D );
77 PyObject * Any_BPy_Interface1D_from_Interface1D( Interface1D& if1D );
78 PyObject * Any_BPy_FEdge_from_FEdge( FEdge& fe );
79 PyObject * Any_BPy_ViewVertex_from_ViewVertex( ViewVertex& vv );
80
81 PyObject * BPy_BBox_from_BBox( BBox< Vec3r > &bb );
82 PyObject * BPy_CurvePoint_from_CurvePoint( CurvePoint& cp );
83 PyObject * BPy_directedViewEdge_from_directedViewEdge( ViewVertex::directedViewEdge& dve );
84 PyObject * BPy_FEdge_from_FEdge( FEdge& fe );
85 PyObject * BPy_FEdgeSharp_from_FEdgeSharp( FEdgeSharp& fes );
86 PyObject * BPy_FEdgeSmooth_from_FEdgeSmooth( FEdgeSmooth& fes );
87 PyObject * BPy_Id_from_Id( Id& id );
88 PyObject * BPy_Interface0D_from_Interface0D( Interface0D& if0D );
89 PyObject * BPy_Interface1D_from_Interface1D( Interface1D& if1D );
90 PyObject * BPy_IntegrationType_from_IntegrationType( IntegrationType i );
91 PyObject * BPy_FrsMaterial_from_FrsMaterial( FrsMaterial& m );
92 PyObject * BPy_Nature_from_Nature( unsigned short n );
93 PyObject * BPy_MediumType_from_MediumType( Stroke::MediumType n );
94 PyObject * BPy_SShape_from_SShape( SShape& ss );
95 PyObject * BPy_Stroke_from_Stroke( Stroke& s );
96 PyObject * BPy_StrokeAttribute_from_StrokeAttribute( StrokeAttribute& sa );
97 PyObject * BPy_StrokeVertex_from_StrokeVertex( StrokeVertex& sv );
98 PyObject * BPy_SVertex_from_SVertex( SVertex& sv );
99 PyObject * BPy_ViewVertex_from_ViewVertex( ViewVertex& vv );
100 PyObject * BPy_NonTVertex_from_NonTVertex( NonTVertex& ntv );
101 PyObject * BPy_TVertex_from_TVertex( TVertex& tv );
102 PyObject * BPy_ViewEdge_from_ViewEdge( ViewEdge& ve );
103 PyObject * BPy_Chain_from_Chain( Chain& c );
104 PyObject * BPy_ViewShape_from_ViewShape( ViewShape& vs );
105
106 PyObject * BPy_AdjacencyIterator_from_AdjacencyIterator( AdjacencyIterator& a_it );
107 PyObject * BPy_Interface0DIterator_from_Interface0DIterator( Interface0DIterator& if0D_it, int reversed );
108 PyObject * BPy_CurvePointIterator_from_CurvePointIterator( CurveInternal::CurvePointIterator& cp_it );
109 PyObject * BPy_StrokeVertexIterator_from_StrokeVertexIterator( StrokeInternal::StrokeVertexIterator& sv_it, int reversed);
110 PyObject * BPy_SVertexIterator_from_SVertexIterator( ViewEdgeInternal::SVertexIterator& sv_it );
111 PyObject * BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ViewVertexInternal::orientedViewEdgeIterator& ove_it, int reversed );
112 PyObject * BPy_ViewEdgeIterator_from_ViewEdgeIterator( ViewEdgeInternal::ViewEdgeIterator& ve_it );
113 PyObject * BPy_ChainingIterator_from_ChainingIterator( ChainingIterator& c_it );
114 PyObject * BPy_ChainPredicateIterator_from_ChainPredicateIterator( ChainPredicateIterator& cp_it );
115 PyObject * BPy_ChainSilhouetteIterator_from_ChainSilhouetteIterator( ChainSilhouetteIterator& cs_it );
116
117 //==============================
118 // Python => C++
119 //==============================
120
121 bool bool_from_PyBool( PyObject *b );
122 IntegrationType IntegrationType_from_BPy_IntegrationType( PyObject* obj );
123 Stroke::MediumType MediumType_from_BPy_MediumType( PyObject* obj );
124 Nature::EdgeNature EdgeNature_from_BPy_Nature( PyObject* obj );
125 Vec2f * Vec2f_ptr_from_PyObject( PyObject* obj );
126 Vec3f * Vec3f_ptr_from_PyObject( PyObject* obj );
127 Vec3r * Vec3r_ptr_from_PyObject( PyObject* obj );
128 Vec2f * Vec2f_ptr_from_Vector( PyObject* obj );
129 Vec3f * Vec3f_ptr_from_Vector( PyObject* obj );
130 Vec3r * Vec3r_ptr_from_Vector( PyObject* obj );
131 Vec3f * Vec3f_ptr_from_Color( PyObject* obj );
132 Vec3r * Vec3r_ptr_from_Color( PyObject* obj );
133 Vec2f * Vec2f_ptr_from_PyList( PyObject* obj );
134 Vec3f * Vec3f_ptr_from_PyList( PyObject* obj );
135 Vec3r * Vec3r_ptr_from_PyList( PyObject* obj );
136 Vec2f * Vec2f_ptr_from_PyTuple( PyObject* obj );
137 Vec3f * Vec3f_ptr_from_PyTuple( PyObject* obj );
138 Vec3r * Vec3r_ptr_from_PyTuple( PyObject* obj );
139
140 int float_array_from_PyObject(PyObject *obj, float *v, int n);
141
142
143 ///////////////////////////////////////////////////////////////////////////////////////////
144
145 #ifdef __cplusplus
146 }
147 #endif
148
149
150 #endif /* FREESTYLE_PYTHON_CONVERT_H */