itom
Loading...
Searching...
No Matches
pythonPCL.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2020, Institut für Technische Optik (ITO),
5 Universität Stuttgart, Germany
6
7 This file is part of itom.
8
9 itom is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Library General Public Licence as published by
11 the Free Software Foundation; either version 2 of the Licence, or (at
12 your option) any later version.
13
14 itom is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17 General Public Licence for more details.
18
19 You should have received a copy of the GNU Library General Public License
20 along with itom. If not, see <http://www.gnu.org/licenses/>.
21*********************************************************************** */
22
23#ifndef PYTHONPCL_H
24#define PYTHONPCL_H
25
26
27/* includes */
28#ifndef Q_MOC_RUN
29 #define PY_ARRAY_UNIQUE_SYMBOL itom_ARRAY_API //see numpy help ::array api :: Miscellaneous :: Importing the api (this line must before include global.h)
30 #define NO_IMPORT_ARRAY
31
32 #include "pythonWrapper.h"
33#endif
34
35#include "../global.h"
36
37#if ITOM_POINTCLOUDLIBRARY > 0
38
39#include "PointCloud/pclStructures.h"
40
41
42namespace ito
43{
44
45class PythonPCL
46{
47public:
48 typedef struct
49 {
50 PyObject_HEAD
52 PyObject* base;
53 }
54 PyPointCloud;
55
56 #define PyPointCloud_Check(op) PyObject_TypeCheck(op, &PythonPCL::PyPointCloudType)
57
58 //-------------------------------------------------------------------------------------------------
59 // constructor, deconstructor, alloc, dellaoc
60 //-------------------------------------------------------------------------------------------------
61 static void PyPointCloud_dealloc(PyPointCloud *self);
62 static PyObject* PyPointCloud_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
63 static int PyPointCloud_init(PyPointCloud *self, PyObject *args, PyObject *kwds);
64
65
66 //-------------------------------------------------------------------------------------------------
67 // general members
68 //-------------------------------------------------------------------------------------------------
69 static PyObject *PyPointCloud_name(PyPointCloud *self);
70 static PyObject *PyPointCloud_repr(PyPointCloud *self);
71 static PyObject *PyPointCloud_append(PyPointCloud *self, PyObject *args, PyObject *kwds);
72 static PyObject *PyPointCloud_clear(PyPointCloud *self);
73 static PyObject *PyPointCloud_insert(PyPointCloud *self, PyObject *args);
74 static PyObject *PyPointCloud_erase(PyPointCloud *self, PyObject *args);
75 static PyObject *PyPointCloud_toDataObject(PyPointCloud *self);
76 static PyObject *PyPointCloud_copy(PyPointCloud *self);
77 static PyObject *PyPointCloud_scaleXYZ(PyPointCloud *self, PyObject *args, PyObject *kwds);
78 static PyObject *PyPointCloud_moveXYZ(PyPointCloud *self, PyObject *args, PyObject *kwds);
79
80 //-------------------------------------------------------------------------------------------------
81 // helper methods
82 //-------------------------------------------------------------------------------------------------
83 static PyObject *PyPointCloud_XYZ_append(PyPointCloud *self, PyObject *xyzObj);
84 static PyObject *PyPointCloud_XYZI_append(PyPointCloud *self, PyObject *xyziObj);
85 static PyObject *PyPointCloud_XYZRGBA_append(PyPointCloud *self, PyObject *xyzObj, PyObject *rgbaObj);
86 static PyObject *PyPointCloud_XYZNormal_append(PyPointCloud *self, PyObject *xyz_nxnynz_curvObj);
87 static PyObject *PyPointCloud_XYZINormal_append(PyPointCloud *self, PyObject *xyz_i_nxnynz_curvObj);
88 static PyObject *PyPointCloud_XYZRGBNormal_append(PyPointCloud *self, PyObject *xyz_i_nxnynz_curvObj, PyObject *rgbaObj);
89
90 static PyPointCloud* createEmptyPyPointCloud();
91
92 //-------------------------------------------------------------------------------------------------
93 // getter / setter
94 //-------------------------------------------------------------------------------------------------
95 static PyObject* PyPointCloud_GetType(PyPointCloud *self, void *closure);
96 static PyObject* PyPointCloud_GetSize(PyPointCloud *self, void *closure);
97 static PyObject* PyPointCloud_GetHeight(PyPointCloud *self, void *closure);
98 static PyObject* PyPointCloud_GetWidth(PyPointCloud *self, void *closure);
99 static PyObject* PyPointCloud_GetEmpty(PyPointCloud *self, void *closure);
100 static PyObject* PyPointCloud_GetOrganized(PyPointCloud *self, void *closure);
101 static PyObject* PyPointCloud_GetDense(PyPointCloud *self, void *closure);
102 static int PyPointCloud_SetDense(PyPointCloud *self, PyObject *value, void *closure);
103 static PyObject* PyPointCloud_GetFields(PyPointCloud *self, void *closure);
104
105 //-------------------------------------------------------------------------------------------------
106 // sequence protocol
107 //-------------------------------------------------------------------------------------------------
108 static Py_ssize_t PyPointCloud_seqLength(PyPointCloud *self);
109 static PyObject *PyPointCloud_seqConcat(PyPointCloud *self, PyObject *rhs);
110 static PyObject *PyPointCloud_seqRepeat(PyPointCloud *self, Py_ssize_t size);
111 static PyObject *PyPointCloud_seqItem(PyPointCloud *self, Py_ssize_t size);
112 static int PyPointCloud_seqAssItem(PyPointCloud *self, Py_ssize_t size, PyObject *point);
113 static PyObject *PyPointCloud_seqInplaceConcat(PyPointCloud *self, PyObject *rhs);
114 static PyObject *PyPointCloud_seqInplaceRepeat(PyPointCloud *self, Py_ssize_t size);
115
116 //-------------------------------------------------------------------------------------------------
117 // mapping protocol
118 //-------------------------------------------------------------------------------------------------
119 static Py_ssize_t PyPointCloud_mappingLength(PyPointCloud *self);
120 static PyObject *PyPointCloud_mappingGetElem(PyPointCloud *self, PyObject *key);
121 static int PyPointCloud_mappingSetElem(PyPointCloud *self, PyObject *key, PyObject *value);
122
123 //-------------------------------------------------------------------------------------------------
124 // pickling
125 //-------------------------------------------------------------------------------------------------
126 static PyObject* PyPointCloud_Reduce(PyPointCloud *self, PyObject *args);
127 static PyObject* PyPointCloud_SetState(PyPointCloud *self, PyObject *args);
128
129 //-------------------------------------------------------------------------------------------------
130 // static methods
131 //-------------------------------------------------------------------------------------------------
132 static PyObject *PyPointCloud_fromXYZ(PyPointCloud *self, PyObject *args, PyObject *kwds);
133 static PyObject *PyPointCloud_fromXYZI(PyPointCloud *self, PyObject *args, PyObject *kwds);
134 static PyObject *PyPointCloud_fromXYZRGBA(PyPointCloud *self, PyObject *args, PyObject *kwds);
135 static PyObject *PyPointCloud_fromTopography(PyPointCloud *self, PyObject *args, PyObject *kwds);
136
137 //-------------------------------------------------------------------------------------------------
138 // type structures
139 //-------------------------------------------------------------------------------------------------
140 //static PyMemberDef PyNpDataObject_members[];
141 static PyMethodDef PyPointCloud_methods[];
142 static PyTypeObject PyPointCloudType;
143 static PyModuleDef PyPointCloudModule;
144 static PyGetSetDef PyPointCloud_getseters[];
145 static PySequenceMethods PyPointCloud_sequenceProtocol;
146 static PyMappingMethods PyPointCloud_mappingProtocol;
147
148 static void PyPointCloud_addTpDict(PyObject *tp_dict);
149
150 //--------------------------------------------------------------------------------------------------
151 // PCL Point
152 //--------------------------------------------------------------------------------------------------
153 typedef struct
154 {
155 PyObject_HEAD
156 ito::PCLPoint *point;
157 PyObject* base;
158 }
159 PyPoint;
160
161 //-------------------------------------------------------------------------------------------------
162 // constructor, deconstructor, alloc, dellaoc
163 //-------------------------------------------------------------------------------------------------
164 static void PyPoint_dealloc(PyPoint *self);
165 static PyObject* PyPoint_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
166 static int PyPoint_init(PyPoint *self, PyObject *args, PyObject *kwds);
167
168
169 //-------------------------------------------------------------------------------------------------
170 // general members
171 //-------------------------------------------------------------------------------------------------
172 static PyObject *PyPoint_name(PyPoint *self);
173 static PyObject *PyPoint_repr(PyPoint *self);
174
175 //-------------------------------------------------------------------------------------------------
176 // getter / setter
177 //-------------------------------------------------------------------------------------------------
178 static PyObject* PyPoint_GetType(PyPoint *self, void *closure);
179
180 static PyObject* PyPoint_GetXYZ(PyPoint *self, void *closure);
181 static int PyPoint_SetXYZ(PyPoint *self, PyObject *value, void *closure);
182
183 static PyObject* PyPoint_GetIntensity(PyPoint *self, void *closure);
184 static int PyPoint_SetIntensity(PyPoint *self, PyObject *value, void *closure);
185
186 static PyObject* PyPoint_GetRgb(PyPoint *self, void *closure);
187 static int PyPoint_SetRgb(PyPoint *self, PyObject *value, void *closure);
188
189 static PyObject* PyPoint_GetRgba(PyPoint *self, void *closure);
190 static int PyPoint_SetRgba(PyPoint *self, PyObject *value, void *closure);
191
192 static PyObject* PyPoint_GetCurvature(PyPoint *self, void *closure);
193 static int PyPoint_SetCurvature(PyPoint *self, PyObject *value, void *closure);
194
195 static PyObject* PyPoint_GetNormal(PyPoint *self, void *closure);
196 static int PyPoint_SetNormal(PyPoint *self, PyObject *value, void *closure);
197
198 //-------------------------------------------------------------------------------------------------
199 // mapping members
200 //-------------------------------------------------------------------------------------------------
201 static PyObject* PyPoint_mappingGetElem(PyPoint* self, PyObject* key);
202 static int PyPoint_mappingSetElem(PyPoint* self, PyObject* key, PyObject* value);
203
204 //-------------------------------------------------------------------------------------------------
205 // type structures
206 //-------------------------------------------------------------------------------------------------
207 //static PyMemberDef PyNpDataObject_members[];
208 static PyMethodDef PyPoint_methods[];
209 static PyTypeObject PyPointType;
210 static PyModuleDef PyPointModule;
211 static PyGetSetDef PyPoint_getseters[];
212 static PyMappingMethods PyPoint_mappingProtocol;
213
214 static void PyPoint_addTpDict(PyObject *tp_dict);
215
216
217
218
219
220
221 //--------------------------------------------------------------------------------------------------
222 // PCL PolygonMesh
223 //--------------------------------------------------------------------------------------------------
224 typedef struct
225 {
226 PyObject_HEAD
227 ito::PCLPolygonMesh *polygonMesh;
228 PyObject* base;
229 }
230 PyPolygonMesh;
231
232 #define PyPolygonMesh_Check(op) PyObject_TypeCheck(op, &PythonPCL::PyPolygonMeshType)
233
234 //-------------------------------------------------------------------------------------------------
235 // constructor, deconstructor, alloc, dellaoc
236 //-------------------------------------------------------------------------------------------------
237 static void PyPolygonMesh_dealloc(PyPolygonMesh *self);
238 static PyObject* PyPolygonMesh_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
239 static int PyPolygonMesh_init(PyPolygonMesh *self, PyObject *args, PyObject *kwds);
240
241
242 //-------------------------------------------------------------------------------------------------
243 // general members
244 //-------------------------------------------------------------------------------------------------
245 static PyObject *PyPolygonMesh_name(PyPolygonMesh *self);
246 static PyObject *PyPolygonMesh_repr(PyPolygonMesh *self);
247 static PyObject *PyPolygonMesh_data(PyPolygonMesh *self);
248
249 static PyObject *PyPolygonMesh_get(PyPolygonMesh *self, PyObject *args, PyObject *kwds);
250 static PyObject* PyPolygonMesh_getCloud(PyPolygonMesh *self, PyObject *args);
251 static PyObject* PyPolygonMesh_getPolygons(PyPolygonMesh *self, PyObject *args);
252
253 //-------------------------------------------------------------------------------------------------
254 // pickling
255 //-------------------------------------------------------------------------------------------------
256 static PyObject* PyPolygonMesh_Reduce(PyPolygonMesh *self, PyObject *args);
257 static PyObject* PyPolygonMesh_SetState(PyPolygonMesh *self, PyObject *args);
258
259 //-------------------------------------------------------------------------------------------------
260 // mapping
261 //-------------------------------------------------------------------------------------------------
262 static PyObject* PyPolygonMesh_mappingGetElem(PyPolygonMesh* self, PyObject* key);
263 static int PyPolygonMesh_mappingLength(PyPolygonMesh* self);
264
265 //-------------------------------------------------------------------------------------------------
266 // static methods
267 //-------------------------------------------------------------------------------------------------
268 static PyObject* PyPolygonMesh_FromCloudAndPolygons(PyObject *self, PyObject *args, PyObject *kwds);
269 static PyObject* PyPolygonMesh_FromOrganizedCloud(PyObject * self, PyObject *args, PyObject *kwds);
270 static PyObject* PyPolygonMesh_FromTopography(PyObject * self, PyObject *args, PyObject *kwds);
271
272 //-------------------------------------------------------------------------------------------------
273 // getter / setter
274 //-------------------------------------------------------------------------------------------------
275 static PyObject* PyPolygonMesh_getNrOfPolygons(PyPolygonMesh *self, void *closure);
276
277 //-------------------------------------------------------------------------------------------------
278 // type structures
279 //-------------------------------------------------------------------------------------------------
280 //static PyMemberDef PyNpDataObject_members[];
281 static PyMethodDef PyPolygonMesh_methods[];
282 static PyTypeObject PyPolygonMeshType;
283 static PyModuleDef PyPolygonMeshModule;
284 static PyGetSetDef PyPolygonMesh_getseters[];
285 static PyMappingMethods PyPolygonMesh_mappingProtocol;
286
287 static void PyPolygonMesh_addTpDict(PyObject *tp_dict);
288
289 static PyPolygonMesh* createEmptyPyPolygonMesh();
290
291private:
292 static PyObject* parseObjAsFloat32Array(PyObject *obj, npy_intp mRequired, npy_intp &n, float32 **elemRows);
293 static PyObject* parseObjAsUInt8Array(PyObject *obj, npy_intp mRequired, npy_intp &n, uint8_t **elemRows);
294
295 static void PythonPCL_SetString(PyObject *exception, const char *string);
296 static void PythonPCL_SetString(PyObject *exception, const std::string &string);
297
298};
299
300}; //end namespace ito
301
302
303#endif //#if ITOM_POINTCLOUDLIBRARY > 0
304
305#endif
generic class that covers one single point cloud of different possible types provided by the Point Cl...
Definition pclStructures.h:293
generic class that covers one single point of different possible types provided by the Point Cloud Li...
Definition pclStructures.h:74
generic class that covers a shared pointer to pcl::PolygonMesh that is a class for a polygonal mesh p...
Definition pclStructures.h:668
Definition apiFunctionsGraph.cpp:40