forked from tpaviot/pythonocc-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVisualization.i
More file actions
140 lines (127 loc) · 4.5 KB
/
Visualization.i
File metadata and controls
140 lines (127 loc) · 4.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
##Copyright 2008-2016 Thomas Paviot (tpaviot@gmail.com)
##
##This file is part of pythonOCC.
##
##pythonOCC is free software: you can redistribute it and/or modify
##it under the terms of the GNU Lesser General Public License as published by
##the Free Software Foundation, either version 3 of the License, or
##(at your option) any later version.
##
##pythonOCC 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 Lesser General Public License
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.
*/
%module Visualization;
%{
#include <Visualization.h>
#include <Tesselator.h>
#include <Standard.hxx>
%}
%include ../SWIG_files/common/ExceptionCatcher.i
%include ../SWIG_files/common/OccHandle.i
%include "python/std_string.i"
%include "std_vector.i"
%include "typemaps.i"
%wrap_handle(AIS_InteractiveContext)
%wrap_handle(V3d_View)
%wrap_handle(V3d_Viewer)
%template(vector_float) std::vector<float>;
%typemap(out) float [ANY] {
int i;
$result = PyList_New($1_dim0);
for (i = 0; i < $1_dim0; i++) {
PyObject *o = PyFloat_FromFloat((float) $1[i]);
PyList_SetItem($result,i,o);
}
}
%apply int& OUTPUT {int& v1, int& v2, int& v3}
%apply float& OUTPUT {float& x, float& y, float& z}
class Tesselator {
public:
%feature("autodoc", "1");
Tesselator(TopoDS_Shape aShape);
%feature("autodoc", "1");
~Tesselator();
%feature("kwargs") Compute;
void Compute(bool compute_edges=false, float mesh_quality=1.0, bool parallel=false);
void GetVertex(int ivert, float& x, float& y, float& z);
void GetNormal(int inorm, float& x, float& y, float& z);
void GetTriangleIndex(int triangleIdx, int& v1, int& v2, int& v3);
void GetEdgeVertex(int iEdge, int ivert, float& x, float& y, float& z);
float* VerticesList();
int ObjGetTriangleCount();
int ObjGetInvalidTriangleCount();
int ObjGetVertexCount();
int ObjGetNormalCount();
int ObjGetEdgeCount();
int ObjEdgeGetVertexCount(int iEdge);
std::string ExportShapeToX3DIndexedFaceSet();
std::string ExportShapeToThreejsJSONString(char *shape_function_name);
%feature("kwargs") ExportShapeToX3D;
void ExportShapeToX3D(char *filename, int diffR=1, int diffG=0, int diffB=0);
std::vector<float> GetVerticesPositionAsTuple();
std::vector<float> GetNormalsAsTuple();
};
class Display3d {
public:
%feature("autodoc", "1");
Display3d();
%feature("autodoc", "1");
~Display3d();
%feature("autodoc", "1");
void Init(const long handle);
%feature("autodoc", "1");
void SetAnaglyphMode(int mode);
%feature("autodoc", "1");
void ChangeRenderingParams(int Method,
int RaytracingDepth,
bool IsShadowEnabled,
bool IsReflectionEnabled,
bool IsAntialiasingEnabled,
bool IsTransparentShadowEnabled,
int StereoMode,
int AnaglyphFilter,
bool ToReverseStere);
%feature("autodoc", "1");
void EnableVBO();
%feature("autodoc", "1");
void DisableVBO();
%feature("autodoc", "1");
Handle_V3d_View& GetView();
%feature("autodoc", "1");
Handle_V3d_Viewer& GetViewer();
%feature("autodoc", "1");
Handle_AIS_InteractiveContext GetContext();
%feature("autodoc", "1");
void Test();
%feature("autodoc", "1");
bool InitOffscreen(int size_x, int size_y);
%feature("autodoc", "1");
bool SetSize(int size_x, int size_y);
%feature("autodoc", "1");
bool IsOffscreen();
};
%extend Display3d {
PyObject* GetImageData(int bufType = 0) {
const char * data;
size_t size = 0;
Graphic3d_BufferType theBufferType = (Graphic3d_BufferType)bufType;
if ($self->GetImageData(data, size, theBufferType)) {
return PyBytes_FromStringAndSize(data, (Py_ssize_t)size);
}
Py_RETURN_NONE;
}
PyObject* GetSize() {
int size_x;
int size_y;
if ($self->GetSize(size_x, size_y)) {
return Py_BuildValue("ii", size_x, size_y);
}
Py_RETURN_NONE;
}
};