0f9d97b62b4685a87e403c3c6db49e7d66b59bc9
[blender.git] / source / blender / freestyle / intern / python / BPy_Convert.h
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2010 Blender Foundation.
19  * All rights reserved.
20  *
21  * The Original Code is: all of this file.
22  *
23  * Contributor(s): none yet.
24  *
25  * ***** END GPL LICENSE BLOCK *****
26  */
27
28 /** \file source/blender/freestyle/intern/python/BPy_Convert.h
29  *  \ingroup freestyle
30  */
31
32 #ifndef FREESTYLE_PYTHON_CONVERT_H
33 #define FREESTYLE_PYTHON_CONVERT_H
34
35 #include <Python.h>
36 #include <typeinfo>
37
38 #include "../geometry/Geom.h"
39 using namespace Geometry;
40
41 // BBox
42 #include "../geometry/BBox.h"
43
44 // FEdge, FEdgeSharp, FEdgeSmooth, SShape, SVertex, FEdgeInternal::SVertexIterator
45 #include "../view_map/Silhouette.h" 
46
47 // Id
48 #include "../system/Id.h"
49
50 // Interface0D, Interface0DIteratorNested, Interface0DIterator
51 #include "../view_map/Interface0D.h"
52
53 // Interface1D
54 #include "../view_map/Interface1D.h"
55
56 // FrsMaterial
57 #include "../scene_graph/FrsMaterial.h"
58
59 // Nature::VertexNature, Nature::EdgeNature
60 #include "../winged_edge/Nature.h"
61
62 // Stroke, StrokeAttribute, StrokeVertex
63 #include "../stroke/Stroke.h"
64
65 // NonTVertex, TVertex, ViewEdge, ViewMap, ViewShape, ViewVertex
66 #include "../view_map/ViewMap.h"
67
68 // CurvePoint, Curve
69 #include "../stroke/Curve.h"
70
71 // Chain
72 #include "../stroke/Chain.h"
73
74 //====== ITERATORS
75
76 // AdjacencyIterator, ChainingIterator, ChainSilhouetteIterator, ChainPredicateIterator
77 #include "../stroke/ChainingIterators.h"
78
79 // ViewVertexInternal::orientedViewEdgeIterator
80 // ViewEdgeInternal::SVertexIterator
81 // ViewEdgeInternal::ViewEdgeIterator
82 #include "../view_map/ViewMapIterators.h"
83
84 // StrokeInternal::StrokeVertexIterator
85 #include "../stroke/StrokeIterators.h"
86
87 // CurveInternal::CurvePointIterator
88 #include "../stroke/CurveIterators.h"
89
90 #ifdef __cplusplus
91 extern "C" {
92 #endif
93
94 ///////////////////////////////////////////////////////////////////////////////////////////
95
96 #include "mathutils/mathutils.h"
97
98 //==============================
99 // C++ => Python
100 //==============================
101
102 PyObject * PyBool_from_bool( bool b );
103 PyObject * Vector_from_Vec2f( Vec2f& v );
104 PyObject * Vector_from_Vec3f( Vec3f& v );
105 PyObject * Vector_from_Vec3r( Vec3r& v );
106
107 PyObject * Any_BPy_Interface0D_from_Interface0D( Interface0D& if0D );
108 PyObject * Any_BPy_Interface1D_from_Interface1D( Interface1D& if1D );
109 PyObject * Any_BPy_FEdge_from_FEdge( FEdge& fe );
110 PyObject * Any_BPy_ViewVertex_from_ViewVertex( ViewVertex& vv );
111
112 PyObject * BPy_BBox_from_BBox(const BBox< Vec3r > &bb);
113 PyObject * BPy_CurvePoint_from_CurvePoint( CurvePoint& cp );
114 PyObject * BPy_directedViewEdge_from_directedViewEdge( ViewVertex::directedViewEdge& dve );
115 PyObject * BPy_FEdge_from_FEdge( FEdge& fe );
116 PyObject * BPy_FEdgeSharp_from_FEdgeSharp( FEdgeSharp& fes );
117 PyObject * BPy_FEdgeSmooth_from_FEdgeSmooth( FEdgeSmooth& fes );
118 PyObject * BPy_Id_from_Id( Id& id );
119 PyObject * BPy_Interface0D_from_Interface0D( Interface0D& if0D );
120 PyObject * BPy_Interface1D_from_Interface1D( Interface1D& if1D );
121 PyObject * BPy_IntegrationType_from_IntegrationType( IntegrationType i );
122 PyObject * BPy_FrsMaterial_from_FrsMaterial(const FrsMaterial& m);
123 PyObject * BPy_Nature_from_Nature( unsigned short n );
124 PyObject * BPy_MediumType_from_MediumType( Stroke::MediumType n );
125 PyObject * BPy_SShape_from_SShape( SShape& ss );
126 PyObject * BPy_Stroke_from_Stroke( Stroke& s );
127 PyObject * BPy_StrokeAttribute_from_StrokeAttribute( StrokeAttribute& sa );
128 PyObject * BPy_StrokeVertex_from_StrokeVertex( StrokeVertex& sv );
129 PyObject * BPy_SVertex_from_SVertex( SVertex& sv );
130 PyObject * BPy_ViewVertex_from_ViewVertex( ViewVertex& vv );
131 PyObject * BPy_NonTVertex_from_NonTVertex( NonTVertex& ntv );
132 PyObject * BPy_TVertex_from_TVertex( TVertex& tv );
133 PyObject * BPy_ViewEdge_from_ViewEdge( ViewEdge& ve );
134 PyObject * BPy_Chain_from_Chain( Chain& c );
135 PyObject * BPy_ViewShape_from_ViewShape( ViewShape& vs );
136
137 PyObject * BPy_AdjacencyIterator_from_AdjacencyIterator( AdjacencyIterator& a_it );
138 PyObject * BPy_Interface0DIterator_from_Interface0DIterator( Interface0DIterator& if0D_it, int reversed );
139 PyObject * BPy_CurvePointIterator_from_CurvePointIterator( CurveInternal::CurvePointIterator& cp_it );
140 PyObject * BPy_StrokeVertexIterator_from_StrokeVertexIterator( StrokeInternal::StrokeVertexIterator& sv_it, int reversed);
141 PyObject * BPy_SVertexIterator_from_SVertexIterator( ViewEdgeInternal::SVertexIterator& sv_it );
142 PyObject * BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator( ViewVertexInternal::orientedViewEdgeIterator& ove_it, int reversed );
143 PyObject * BPy_ViewEdgeIterator_from_ViewEdgeIterator( ViewEdgeInternal::ViewEdgeIterator& ve_it );
144 PyObject * BPy_ChainingIterator_from_ChainingIterator( ChainingIterator& c_it );
145 PyObject * BPy_ChainPredicateIterator_from_ChainPredicateIterator( ChainPredicateIterator& cp_it );
146 PyObject * BPy_ChainSilhouetteIterator_from_ChainSilhouetteIterator( ChainSilhouetteIterator& cs_it );
147
148 //==============================
149 // Python => C++
150 //==============================
151
152 bool bool_from_PyBool( PyObject *b );
153 IntegrationType IntegrationType_from_BPy_IntegrationType( PyObject* obj );
154 Stroke::MediumType MediumType_from_BPy_MediumType( PyObject* obj );
155 Nature::EdgeNature EdgeNature_from_BPy_Nature( PyObject* obj );
156 Vec2f * Vec2f_ptr_from_PyObject( PyObject* obj );
157 Vec3f * Vec3f_ptr_from_PyObject( PyObject* obj );
158 Vec3r * Vec3r_ptr_from_PyObject( PyObject* obj );
159 Vec2f * Vec2f_ptr_from_Vector( PyObject* obj );
160 Vec3f * Vec3f_ptr_from_Vector( PyObject* obj );
161 Vec3r * Vec3r_ptr_from_Vector( PyObject* obj );
162 Vec3f * Vec3f_ptr_from_Color( PyObject* obj );
163 Vec3r * Vec3r_ptr_from_Color( PyObject* obj );
164 Vec2f * Vec2f_ptr_from_PyList( PyObject* obj );
165 Vec3f * Vec3f_ptr_from_PyList( PyObject* obj );
166 Vec3r * Vec3r_ptr_from_PyList( PyObject* obj );
167 Vec2f * Vec2f_ptr_from_PyTuple( PyObject* obj );
168 Vec3f * Vec3f_ptr_from_PyTuple( PyObject* obj );
169 Vec3r * Vec3r_ptr_from_PyTuple( PyObject* obj );
170
171 int float_array_from_PyObject(PyObject *obj, float *v, int n);
172
173
174 ///////////////////////////////////////////////////////////////////////////////////////////
175
176 #ifdef __cplusplus
177 }
178 #endif
179
180
181 #endif /* FREESTYLE_PYTHON_CONVERT_H */