itom 1.3.0
|
00001 /* ******************************************************************** 00002 itom software 00003 URL: http://www.uni-stuttgart.de/ito 00004 Copyright (C) 2013, Institut fuer Technische Optik (ITO), 00005 Universitaet Stuttgart, Germany 00006 00007 This file is part of itom. 00008 00009 itom is free software; you can redistribute it and/or modify it 00010 under the terms of the GNU Library General Public Licence as published by 00011 the Free Software Foundation; either version 2 of the Licence, or (at 00012 your option) any later version. 00013 00014 itom is distributed in the hope that it will be useful, but 00015 WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library 00017 General Public Licence for more details. 00018 00019 You should have received a copy of the GNU Library General Public License 00020 along with itom. If not, see <http://www.gnu.org/licenses/>. 00021 *********************************************************************** */ 00022 00023 #ifndef PYTHONPCL_H 00024 #define PYTHONPCL_H 00025 00026 00027 /* includes */ 00028 #ifndef Q_MOC_RUN 00029 #define PY_ARRAY_UNIQUE_SYMBOL itom_ARRAY_API //see numpy help ::array api :: Miscellaneous :: Importing the api (this line must bebefore include global.h) 00030 #define NO_IMPORT_ARRAY 00031 00032 #ifndef ITOM_NPDATAOBJECT 00033 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION //see comment in pythonNpDataObject.cpp 00034 #endif 00035 00036 //python 00037 // see http://vtk.org/gitweb?p=VTK.git;a=commitdiff;h=7f3f750596a105d48ea84ebfe1b1c4ca03e0bab3 00038 #if (defined _DEBUG) && (!defined linux) 00039 #undef _DEBUG 00040 #if (defined linux) | (defined CMAKE) 00041 #include "Python.h" 00042 #include "numpy/arrayobject.h" 00043 #else 00044 #include "Python.h" 00045 #include "../Lib/site-packages/numpy/core/include/numpy/arrayobject.h" //for numpy arrays 00046 #endif 00047 #define _DEBUG 00048 #else 00049 #ifdef linux 00050 #include "Python.h" 00051 #include "numpy/arrayobject.h" 00052 #else 00053 #include "Python.h" 00054 #include "../Lib/site-packages/numpy/core/include/numpy/arrayobject.h" //for numpy arrays 00055 #endif 00056 #endif 00057 #endif 00058 00059 #include "../global.h" 00060 00061 #if ITOM_POINTCLOUDLIBRARY > 0 00062 00063 #include "PointCloud/pclStructures.h" 00064 00065 00066 namespace ito 00067 { 00068 00069 class PythonPCL 00070 { 00071 public: 00072 typedef struct 00073 { 00074 PyObject_HEAD 00075 ito::PCLPointCloud *data; 00076 PyObject* base; 00077 } 00078 PyPointCloud; 00079 00080 #define PyPointCloud_Check(op) PyObject_TypeCheck(op, &PythonPCL::PyPointCloudType) 00081 00082 //------------------------------------------------------------------------------------------------- 00083 // constructor, deconstructor, alloc, dellaoc 00084 //------------------------------------------------------------------------------------------------- 00085 static void PyPointCloud_dealloc(PyPointCloud *self); 00086 static PyObject* PyPointCloud_new(PyTypeObject *type, PyObject *args, PyObject *kwds); 00087 static int PyPointCloud_init(PyPointCloud *self, PyObject *args, PyObject *kwds); 00088 00089 00090 //------------------------------------------------------------------------------------------------- 00091 // general members 00092 //------------------------------------------------------------------------------------------------- 00093 static PyObject *PyPointCloud_name(PyPointCloud *self); 00094 static PyObject *PyPointCloud_repr(PyPointCloud *self); 00095 static PyObject *PyPointCloud_append(PyPointCloud *self, PyObject *args, PyObject *kwds); 00096 static PyObject *PyPointCloud_clear(PyPointCloud *self); 00097 static PyObject *PyPointCloud_insert(PyPointCloud *self, PyObject *args); 00098 static PyObject *PyPointCloud_erase(PyPointCloud *self, PyObject *args); 00099 static PyObject *PyPointCloud_toDataObject(PyPointCloud *self); 00100 00101 //------------------------------------------------------------------------------------------------- 00102 // helper methods 00103 //------------------------------------------------------------------------------------------------- 00104 static PyObject *PyPointCloud_XYZ_append(PyPointCloud *self, PyObject *xyzObj); 00105 static PyObject *PyPointCloud_XYZI_append(PyPointCloud *self, PyObject *xyziObj); 00106 static PyObject *PyPointCloud_XYZRGBA_append(PyPointCloud *self, PyObject *xyzObj, PyObject *rgbaObj); 00107 static PyObject *PyPointCloud_XYZNormal_append(PyPointCloud *self, PyObject *xyz_nxnynz_curvObj); 00108 static PyObject *PyPointCloud_XYZINormal_append(PyPointCloud *self, PyObject *xyz_i_nxnynz_curvObj); 00109 static PyObject *PyPointCloud_XYZRGBNormal_append(PyPointCloud *self, PyObject *xyz_i_nxnynz_curvObj, PyObject *rgbaObj); 00110 00111 static PyPointCloud* createEmptyPyPointCloud(); 00112 00113 //------------------------------------------------------------------------------------------------- 00114 // getter / setter 00115 //------------------------------------------------------------------------------------------------- 00116 static PyObject* PyPointCloud_GetType(PyPointCloud *self, void *closure); 00117 static PyObject* PyPointCloud_GetSize(PyPointCloud *self, void *closure); 00118 static PyObject* PyPointCloud_GetHeight(PyPointCloud *self, void *closure); 00119 static PyObject* PyPointCloud_GetWidth(PyPointCloud *self, void *closure); 00120 static PyObject* PyPointCloud_GetEmpty(PyPointCloud *self, void *closure); 00121 static PyObject* PyPointCloud_GetOrganized(PyPointCloud *self, void *closure); 00122 static PyObject* PyPointCloud_GetDense(PyPointCloud *self, void *closure); 00123 static int PyPointCloud_SetDense(PyPointCloud *self, PyObject *value, void *closure); 00124 static PyObject* PyPointCloud_GetFields(PyPointCloud *self, void *closure); 00125 00126 //------------------------------------------------------------------------------------------------- 00127 // sequence protocol 00128 //------------------------------------------------------------------------------------------------- 00129 static Py_ssize_t PyPointCloud_seqLength(PyPointCloud *self); 00130 static PyObject *PyPointCloud_seqConcat(PyPointCloud *self, PyObject *rhs); 00131 static PyObject *PyPointCloud_seqRepeat(PyPointCloud *self, Py_ssize_t size); 00132 static PyObject *PyPointCloud_seqItem(PyPointCloud *self, Py_ssize_t size); 00133 static int PyPointCloud_seqAssItem(PyPointCloud *self, Py_ssize_t size, PyObject *point); 00134 static PyObject *PyPointCloud_seqInplaceConcat(PyPointCloud *self, PyObject *rhs); 00135 static PyObject *PyPointCloud_seqInplaceRepeat(PyPointCloud *self, Py_ssize_t size); 00136 00137 //------------------------------------------------------------------------------------------------- 00138 // mapping protocol 00139 //------------------------------------------------------------------------------------------------- 00140 static Py_ssize_t PyPointCloud_mappingLength(PyPointCloud *self); 00141 static PyObject *PyPointCloud_mappingGetElem(PyPointCloud *self, PyObject *key); 00142 static int PyPointCloud_mappingSetElem(PyPointCloud *self, PyObject *key, PyObject *value); 00143 00144 //------------------------------------------------------------------------------------------------- 00145 // pickling 00146 //------------------------------------------------------------------------------------------------- 00147 static PyObject* PyPointCloud_Reduce(PyPointCloud *self, PyObject *args); 00148 static PyObject* PyPointCloud_SetState(PyPointCloud *self, PyObject *args); 00149 00150 //------------------------------------------------------------------------------------------------- 00151 // static methods 00152 //------------------------------------------------------------------------------------------------- 00153 static PyObject *PyPointCloud_fromXYZ(PyPointCloud *self, PyObject *args); 00154 static PyObject *PyPointCloud_fromXYZI(PyPointCloud *self, PyObject *args); 00155 static PyObject *PyPointCloud_fromDisparity(PyPointCloud *self, PyObject *args, PyObject *kwds); 00156 00157 //------------------------------------------------------------------------------------------------- 00158 // type structures 00159 //------------------------------------------------------------------------------------------------- 00160 //static PyMemberDef PyNpDataObject_members[]; 00161 static PyMethodDef PyPointCloud_methods[]; 00162 static PyTypeObject PyPointCloudType; 00163 static PyModuleDef PyPointCloudModule; 00164 static PyGetSetDef PyPointCloud_getseters[]; 00165 static PySequenceMethods PyPointCloud_sequenceProtocol; 00166 static PyMappingMethods PyPointCloud_mappingProtocol; 00167 00168 static void PyPointCloud_addTpDict(PyObject *tp_dict); 00169 00170 //-------------------------------------------------------------------------------------------------- 00171 // PCL Point 00172 //-------------------------------------------------------------------------------------------------- 00173 typedef struct 00174 { 00175 PyObject_HEAD 00176 ito::PCLPoint *point; 00177 PyObject* base; 00178 } 00179 PyPoint; 00180 00181 //------------------------------------------------------------------------------------------------- 00182 // constructor, deconstructor, alloc, dellaoc 00183 //------------------------------------------------------------------------------------------------- 00184 static void PyPoint_dealloc(PyPoint *self); 00185 static PyObject* PyPoint_new(PyTypeObject *type, PyObject *args, PyObject *kwds); 00186 static int PyPoint_init(PyPoint *self, PyObject *args, PyObject *kwds); 00187 00188 00189 //------------------------------------------------------------------------------------------------- 00190 // general members 00191 //------------------------------------------------------------------------------------------------- 00192 static PyObject *PyPoint_name(PyPoint *self); 00193 static PyObject *PyPoint_repr(PyPoint *self); 00194 00195 //------------------------------------------------------------------------------------------------- 00196 // getter / setter 00197 //------------------------------------------------------------------------------------------------- 00198 static PyObject* PyPoint_GetType(PyPoint *self, void *closure); 00199 00200 static PyObject* PyPoint_GetXYZ(PyPoint *self, void *closure); 00201 static int PyPoint_SetXYZ(PyPoint *self, PyObject *value, void *closure); 00202 00203 static PyObject* PyPoint_GetIntensity(PyPoint *self, void *closure); 00204 static int PyPoint_SetIntensity(PyPoint *self, PyObject *value, void *closure); 00205 00206 static PyObject* PyPoint_GetRgb(PyPoint *self, void *closure); 00207 static int PyPoint_SetRgb(PyPoint *self, PyObject *value, void *closure); 00208 00209 static PyObject* PyPoint_GetRgba(PyPoint *self, void *closure); 00210 static int PyPoint_SetRgba(PyPoint *self, PyObject *value, void *closure); 00211 00212 static PyObject* PyPoint_GetCurvature(PyPoint *self, void *closure); 00213 static int PyPoint_SetCurvature(PyPoint *self, PyObject *value, void *closure); 00214 00215 static PyObject* PyPoint_GetNormal(PyPoint *self, void *closure); 00216 static int PyPoint_SetNormal(PyPoint *self, PyObject *value, void *closure); 00217 00218 //------------------------------------------------------------------------------------------------- 00219 // mapping members 00220 //------------------------------------------------------------------------------------------------- 00221 static PyObject* PyPoint_mappingGetElem(PyPoint* self, PyObject* key); 00222 static int PyPoint_mappingSetElem(PyPoint* self, PyObject* key, PyObject* value); 00223 00224 //------------------------------------------------------------------------------------------------- 00225 // type structures 00226 //------------------------------------------------------------------------------------------------- 00227 //static PyMemberDef PyNpDataObject_members[]; 00228 static PyMethodDef PyPoint_methods[]; 00229 static PyTypeObject PyPointType; 00230 static PyModuleDef PyPointModule; 00231 static PyGetSetDef PyPoint_getseters[]; 00232 static PyMappingMethods PyPoint_mappingProtocol; 00233 00234 static void PyPoint_addTpDict(PyObject *tp_dict); 00235 00236 00237 00238 00239 00240 00241 //-------------------------------------------------------------------------------------------------- 00242 // PCL PolygonMesh 00243 //-------------------------------------------------------------------------------------------------- 00244 typedef struct 00245 { 00246 PyObject_HEAD 00247 ito::PCLPolygonMesh *polygonMesh; 00248 PyObject* base; 00249 } 00250 PyPolygonMesh; 00251 00252 #define PyPolygonMesh_Check(op) PyObject_TypeCheck(op, &PythonPCL::PyPolygonMeshType) 00253 00254 //------------------------------------------------------------------------------------------------- 00255 // constructor, deconstructor, alloc, dellaoc 00256 //------------------------------------------------------------------------------------------------- 00257 static void PyPolygonMesh_dealloc(PyPolygonMesh *self); 00258 static PyObject* PyPolygonMesh_new(PyTypeObject *type, PyObject *args, PyObject *kwds); 00259 static int PyPolygonMesh_init(PyPolygonMesh *self, PyObject *args, PyObject *kwds); 00260 00261 00262 //------------------------------------------------------------------------------------------------- 00263 // general members 00264 //------------------------------------------------------------------------------------------------- 00265 static PyObject *PyPolygonMesh_name(PyPolygonMesh *self); 00266 static PyObject *PyPolygonMesh_repr(PyPolygonMesh *self); 00267 static PyObject *PyPolygonMesh_data(PyPolygonMesh *self); 00268 00269 static PyObject *PyPolygonMesh_get(PyPolygonMesh *self, PyObject *args, PyObject *kwds); 00270 static PyObject* PyPolygonMesh_getCloud(PyPolygonMesh *self, PyObject *args); 00271 static PyObject* PyPolygonMesh_getPolygons(PyPolygonMesh *self, PyObject *args); 00272 00273 //------------------------------------------------------------------------------------------------- 00274 // pickling 00275 //------------------------------------------------------------------------------------------------- 00276 static PyObject* PyPolygonMesh_Reduce(PyPolygonMesh *self, PyObject *args); 00277 static PyObject* PyPolygonMesh_SetState(PyPolygonMesh *self, PyObject *args); 00278 00279 //------------------------------------------------------------------------------------------------- 00280 // mapping 00281 //------------------------------------------------------------------------------------------------- 00282 static PyObject* PyPolygonMesh_mappingGetElem(PyPolygonMesh* self, PyObject* key); 00283 static int PyPolygonMesh_mappingLength(PyPolygonMesh* self); 00284 00285 //------------------------------------------------------------------------------------------------- 00286 // static methods 00287 //------------------------------------------------------------------------------------------------- 00288 static PyObject* PyPolygonMesh_FromCloudAndPolygons(PyObject *self, PyObject *args, PyObject *kwds); 00289 00290 //------------------------------------------------------------------------------------------------- 00291 // getter / setter 00292 //------------------------------------------------------------------------------------------------- 00293 static PyObject* PyPolygonMesh_getNrOfPolygons(PyPolygonMesh *self, void *closure); 00294 00295 //------------------------------------------------------------------------------------------------- 00296 // type structures 00297 //------------------------------------------------------------------------------------------------- 00298 //static PyMemberDef PyNpDataObject_members[]; 00299 static PyMethodDef PyPolygonMesh_methods[]; 00300 static PyTypeObject PyPolygonMeshType; 00301 static PyModuleDef PyPolygonMeshModule; 00302 static PyGetSetDef PyPolygonMesh_getseters[]; 00303 static PyMappingMethods PyPolygonMesh_mappingProtocol; 00304 00305 static void PyPolygonMesh_addTpDict(PyObject *tp_dict); 00306 00307 static PyPolygonMesh* createEmptyPyPolygonMesh(); 00308 00309 private: 00310 static PyObject* parseObjAsFloat32Array(PyObject *obj, npy_intp mRequired, npy_intp &n, float32 **elemRows); 00311 static PyObject* parseObjAsUInt8Array(PyObject *obj, npy_intp mRequired, npy_intp &n, uint8_t **elemRows); 00312 00313 }; 00314 00315 }; //end namespace ito 00316 00317 00318 #endif //#if ITOM_POINTCLOUDLIBRARY > 0 00319 00320 #endif