itom 1.4.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 static PyObject *PyPointCloud_copy(PyPointCloud *self); 00101 00102 //------------------------------------------------------------------------------------------------- 00103 // helper methods 00104 //------------------------------------------------------------------------------------------------- 00105 static PyObject *PyPointCloud_XYZ_append(PyPointCloud *self, PyObject *xyzObj); 00106 static PyObject *PyPointCloud_XYZI_append(PyPointCloud *self, PyObject *xyziObj); 00107 static PyObject *PyPointCloud_XYZRGBA_append(PyPointCloud *self, PyObject *xyzObj, PyObject *rgbaObj); 00108 static PyObject *PyPointCloud_XYZNormal_append(PyPointCloud *self, PyObject *xyz_nxnynz_curvObj); 00109 static PyObject *PyPointCloud_XYZINormal_append(PyPointCloud *self, PyObject *xyz_i_nxnynz_curvObj); 00110 static PyObject *PyPointCloud_XYZRGBNormal_append(PyPointCloud *self, PyObject *xyz_i_nxnynz_curvObj, PyObject *rgbaObj); 00111 00112 static PyPointCloud* createEmptyPyPointCloud(); 00113 00114 //------------------------------------------------------------------------------------------------- 00115 // getter / setter 00116 //------------------------------------------------------------------------------------------------- 00117 static PyObject* PyPointCloud_GetType(PyPointCloud *self, void *closure); 00118 static PyObject* PyPointCloud_GetSize(PyPointCloud *self, void *closure); 00119 static PyObject* PyPointCloud_GetHeight(PyPointCloud *self, void *closure); 00120 static PyObject* PyPointCloud_GetWidth(PyPointCloud *self, void *closure); 00121 static PyObject* PyPointCloud_GetEmpty(PyPointCloud *self, void *closure); 00122 static PyObject* PyPointCloud_GetOrganized(PyPointCloud *self, void *closure); 00123 static PyObject* PyPointCloud_GetDense(PyPointCloud *self, void *closure); 00124 static int PyPointCloud_SetDense(PyPointCloud *self, PyObject *value, void *closure); 00125 static PyObject* PyPointCloud_GetFields(PyPointCloud *self, void *closure); 00126 00127 //------------------------------------------------------------------------------------------------- 00128 // sequence protocol 00129 //------------------------------------------------------------------------------------------------- 00130 static Py_ssize_t PyPointCloud_seqLength(PyPointCloud *self); 00131 static PyObject *PyPointCloud_seqConcat(PyPointCloud *self, PyObject *rhs); 00132 static PyObject *PyPointCloud_seqRepeat(PyPointCloud *self, Py_ssize_t size); 00133 static PyObject *PyPointCloud_seqItem(PyPointCloud *self, Py_ssize_t size); 00134 static int PyPointCloud_seqAssItem(PyPointCloud *self, Py_ssize_t size, PyObject *point); 00135 static PyObject *PyPointCloud_seqInplaceConcat(PyPointCloud *self, PyObject *rhs); 00136 static PyObject *PyPointCloud_seqInplaceRepeat(PyPointCloud *self, Py_ssize_t size); 00137 00138 //------------------------------------------------------------------------------------------------- 00139 // mapping protocol 00140 //------------------------------------------------------------------------------------------------- 00141 static Py_ssize_t PyPointCloud_mappingLength(PyPointCloud *self); 00142 static PyObject *PyPointCloud_mappingGetElem(PyPointCloud *self, PyObject *key); 00143 static int PyPointCloud_mappingSetElem(PyPointCloud *self, PyObject *key, PyObject *value); 00144 00145 //------------------------------------------------------------------------------------------------- 00146 // pickling 00147 //------------------------------------------------------------------------------------------------- 00148 static PyObject* PyPointCloud_Reduce(PyPointCloud *self, PyObject *args); 00149 static PyObject* PyPointCloud_SetState(PyPointCloud *self, PyObject *args); 00150 00151 //------------------------------------------------------------------------------------------------- 00152 // static methods 00153 //------------------------------------------------------------------------------------------------- 00154 static PyObject *PyPointCloud_fromXYZ(PyPointCloud *self, PyObject *args); 00155 static PyObject *PyPointCloud_fromXYZI(PyPointCloud *self, PyObject *args); 00156 static PyObject *PyPointCloud_fromDisparity(PyPointCloud *self, PyObject *args, PyObject *kwds); 00157 00158 //------------------------------------------------------------------------------------------------- 00159 // type structures 00160 //------------------------------------------------------------------------------------------------- 00161 //static PyMemberDef PyNpDataObject_members[]; 00162 static PyMethodDef PyPointCloud_methods[]; 00163 static PyTypeObject PyPointCloudType; 00164 static PyModuleDef PyPointCloudModule; 00165 static PyGetSetDef PyPointCloud_getseters[]; 00166 static PySequenceMethods PyPointCloud_sequenceProtocol; 00167 static PyMappingMethods PyPointCloud_mappingProtocol; 00168 00169 static void PyPointCloud_addTpDict(PyObject *tp_dict); 00170 00171 //-------------------------------------------------------------------------------------------------- 00172 // PCL Point 00173 //-------------------------------------------------------------------------------------------------- 00174 typedef struct 00175 { 00176 PyObject_HEAD 00177 ito::PCLPoint *point; 00178 PyObject* base; 00179 } 00180 PyPoint; 00181 00182 //------------------------------------------------------------------------------------------------- 00183 // constructor, deconstructor, alloc, dellaoc 00184 //------------------------------------------------------------------------------------------------- 00185 static void PyPoint_dealloc(PyPoint *self); 00186 static PyObject* PyPoint_new(PyTypeObject *type, PyObject *args, PyObject *kwds); 00187 static int PyPoint_init(PyPoint *self, PyObject *args, PyObject *kwds); 00188 00189 00190 //------------------------------------------------------------------------------------------------- 00191 // general members 00192 //------------------------------------------------------------------------------------------------- 00193 static PyObject *PyPoint_name(PyPoint *self); 00194 static PyObject *PyPoint_repr(PyPoint *self); 00195 00196 //------------------------------------------------------------------------------------------------- 00197 // getter / setter 00198 //------------------------------------------------------------------------------------------------- 00199 static PyObject* PyPoint_GetType(PyPoint *self, void *closure); 00200 00201 static PyObject* PyPoint_GetXYZ(PyPoint *self, void *closure); 00202 static int PyPoint_SetXYZ(PyPoint *self, PyObject *value, void *closure); 00203 00204 static PyObject* PyPoint_GetIntensity(PyPoint *self, void *closure); 00205 static int PyPoint_SetIntensity(PyPoint *self, PyObject *value, void *closure); 00206 00207 static PyObject* PyPoint_GetRgb(PyPoint *self, void *closure); 00208 static int PyPoint_SetRgb(PyPoint *self, PyObject *value, void *closure); 00209 00210 static PyObject* PyPoint_GetRgba(PyPoint *self, void *closure); 00211 static int PyPoint_SetRgba(PyPoint *self, PyObject *value, void *closure); 00212 00213 static PyObject* PyPoint_GetCurvature(PyPoint *self, void *closure); 00214 static int PyPoint_SetCurvature(PyPoint *self, PyObject *value, void *closure); 00215 00216 static PyObject* PyPoint_GetNormal(PyPoint *self, void *closure); 00217 static int PyPoint_SetNormal(PyPoint *self, PyObject *value, void *closure); 00218 00219 //------------------------------------------------------------------------------------------------- 00220 // mapping members 00221 //------------------------------------------------------------------------------------------------- 00222 static PyObject* PyPoint_mappingGetElem(PyPoint* self, PyObject* key); 00223 static int PyPoint_mappingSetElem(PyPoint* self, PyObject* key, PyObject* value); 00224 00225 //------------------------------------------------------------------------------------------------- 00226 // type structures 00227 //------------------------------------------------------------------------------------------------- 00228 //static PyMemberDef PyNpDataObject_members[]; 00229 static PyMethodDef PyPoint_methods[]; 00230 static PyTypeObject PyPointType; 00231 static PyModuleDef PyPointModule; 00232 static PyGetSetDef PyPoint_getseters[]; 00233 static PyMappingMethods PyPoint_mappingProtocol; 00234 00235 static void PyPoint_addTpDict(PyObject *tp_dict); 00236 00237 00238 00239 00240 00241 00242 //-------------------------------------------------------------------------------------------------- 00243 // PCL PolygonMesh 00244 //-------------------------------------------------------------------------------------------------- 00245 typedef struct 00246 { 00247 PyObject_HEAD 00248 ito::PCLPolygonMesh *polygonMesh; 00249 PyObject* base; 00250 } 00251 PyPolygonMesh; 00252 00253 #define PyPolygonMesh_Check(op) PyObject_TypeCheck(op, &PythonPCL::PyPolygonMeshType) 00254 00255 //------------------------------------------------------------------------------------------------- 00256 // constructor, deconstructor, alloc, dellaoc 00257 //------------------------------------------------------------------------------------------------- 00258 static void PyPolygonMesh_dealloc(PyPolygonMesh *self); 00259 static PyObject* PyPolygonMesh_new(PyTypeObject *type, PyObject *args, PyObject *kwds); 00260 static int PyPolygonMesh_init(PyPolygonMesh *self, PyObject *args, PyObject *kwds); 00261 00262 00263 //------------------------------------------------------------------------------------------------- 00264 // general members 00265 //------------------------------------------------------------------------------------------------- 00266 static PyObject *PyPolygonMesh_name(PyPolygonMesh *self); 00267 static PyObject *PyPolygonMesh_repr(PyPolygonMesh *self); 00268 static PyObject *PyPolygonMesh_data(PyPolygonMesh *self); 00269 00270 static PyObject *PyPolygonMesh_get(PyPolygonMesh *self, PyObject *args, PyObject *kwds); 00271 static PyObject* PyPolygonMesh_getCloud(PyPolygonMesh *self, PyObject *args); 00272 static PyObject* PyPolygonMesh_getPolygons(PyPolygonMesh *self, PyObject *args); 00273 00274 //------------------------------------------------------------------------------------------------- 00275 // pickling 00276 //------------------------------------------------------------------------------------------------- 00277 static PyObject* PyPolygonMesh_Reduce(PyPolygonMesh *self, PyObject *args); 00278 static PyObject* PyPolygonMesh_SetState(PyPolygonMesh *self, PyObject *args); 00279 00280 //------------------------------------------------------------------------------------------------- 00281 // mapping 00282 //------------------------------------------------------------------------------------------------- 00283 static PyObject* PyPolygonMesh_mappingGetElem(PyPolygonMesh* self, PyObject* key); 00284 static int PyPolygonMesh_mappingLength(PyPolygonMesh* self); 00285 00286 //------------------------------------------------------------------------------------------------- 00287 // static methods 00288 //------------------------------------------------------------------------------------------------- 00289 static PyObject* PyPolygonMesh_FromCloudAndPolygons(PyObject *self, PyObject *args, PyObject *kwds); 00290 00291 //------------------------------------------------------------------------------------------------- 00292 // getter / setter 00293 //------------------------------------------------------------------------------------------------- 00294 static PyObject* PyPolygonMesh_getNrOfPolygons(PyPolygonMesh *self, void *closure); 00295 00296 //------------------------------------------------------------------------------------------------- 00297 // type structures 00298 //------------------------------------------------------------------------------------------------- 00299 //static PyMemberDef PyNpDataObject_members[]; 00300 static PyMethodDef PyPolygonMesh_methods[]; 00301 static PyTypeObject PyPolygonMeshType; 00302 static PyModuleDef PyPolygonMeshModule; 00303 static PyGetSetDef PyPolygonMesh_getseters[]; 00304 static PyMappingMethods PyPolygonMesh_mappingProtocol; 00305 00306 static void PyPolygonMesh_addTpDict(PyObject *tp_dict); 00307 00308 static PyPolygonMesh* createEmptyPyPolygonMesh(); 00309 00310 private: 00311 static PyObject* parseObjAsFloat32Array(PyObject *obj, npy_intp mRequired, npy_intp &n, float32 **elemRows); 00312 static PyObject* parseObjAsUInt8Array(PyObject *obj, npy_intp mRequired, npy_intp &n, uint8_t **elemRows); 00313 00314 }; 00315 00316 }; //end namespace ito 00317 00318 00319 #endif //#if ITOM_POINTCLOUDLIBRARY > 0 00320 00321 #endif