itom 1.0.14
D:/git-itom/sources/itom/Qitom/python/pythonPCL.h
00001 /* ********************************************************************
00002     itom software
00003     URL: http://www.uni-stuttgart.de/ito
00004     Copyright (C) 2013, Institut für Technische Optik (ITO),
00005     Universität 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     //#define NPY_NO_DEPRECATED_API 0x00000007 //see comment in pythonNpDataObject.cpp
00033     //python
00034     // see http://vtk.org/gitweb?p=VTK.git;a=commitdiff;h=7f3f750596a105d48ea84ebfe1b1c4ca03e0bab3
00035     #ifdef _DEBUG
00036         #undef _DEBUG
00037         #if (defined linux) | (defined CMAKE)
00038             #include "Python.h"
00039             #include "numpy/arrayobject.h"
00040         #else
00041             #include "Python.h"
00042             #include "../Lib/site-packages/numpy/core/include/numpy/arrayobject.h" //for numpy arrays
00043         #endif
00044         #define _DEBUG
00045     #else
00046         #ifdef linux
00047             #include "Python.h"
00048             #include "numpy/arrayobject.h"
00049         #else
00050             #include "Python.h"
00051             #include "../Lib/site-packages/numpy/core/include/numpy/arrayobject.h" //for numpy arrays
00052         #endif
00053     #endif
00054 #endif
00055 
00056 #include "../global.h"
00057 
00058 #if ITOM_POINTCLOUDLIBRARY > 0
00059 
00060 #include "PointCloud/pclStructures.h"
00061 
00062 
00063 namespace ito
00064 {
00065 
00066 class PythonPCL
00067 {
00068 public:
00069     typedef struct
00070     {
00071         PyObject_HEAD
00072         ito::PCLPointCloud *data;
00073         PyObject* base;
00074     }
00075     PyPointCloud;
00076 
00077     #define PyPointCloud_Check(op) PyObject_TypeCheck(op, &PythonPCL::PyPointCloudType)
00078 
00079     //-------------------------------------------------------------------------------------------------
00080     // constructor, deconstructor, alloc, dellaoc
00081     //------------------------------------------------------------------------------------------------- 
00082     static void PyPointCloud_dealloc(PyPointCloud *self);
00083     static PyObject* PyPointCloud_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
00084     static int PyPointCloud_init(PyPointCloud *self, PyObject *args, PyObject *kwds);
00085 
00086        
00087     //-------------------------------------------------------------------------------------------------
00088     // general members
00089     //------------------------------------------------------------------------------------------------- 
00090     static PyObject *PyPointCloud_name(PyPointCloud *self);
00091     static PyObject *PyPointCloud_repr(PyPointCloud *self);
00092     static PyObject *PyPointCloud_append(PyPointCloud *self, PyObject *args, PyObject *kwds);
00093     static PyObject *PyPointCloud_clear(PyPointCloud *self);
00094     static PyObject *PyPointCloud_insert(PyPointCloud *self, PyObject *args);
00095     static PyObject *PyPointCloud_erase(PyPointCloud *self, PyObject *args);
00096     static PyObject *PyPointCloud_toDataObject(PyPointCloud *self);
00097 
00098     //-------------------------------------------------------------------------------------------------
00099     // helper methods
00100     //-------------------------------------------------------------------------------------------------
00101     static PyObject *PyPointCloud_XYZ_append(PyPointCloud *self, PyObject *xyzObj);
00102     static PyObject *PyPointCloud_XYZI_append(PyPointCloud *self, PyObject *xyziObj);
00103     static PyObject *PyPointCloud_XYZRGBA_append(PyPointCloud *self, PyObject *xyzObj, PyObject *rgbaObj);
00104     static PyObject *PyPointCloud_XYZNormal_append(PyPointCloud *self, PyObject *xyz_nxnynz_curvObj);
00105     static PyObject *PyPointCloud_XYZINormal_append(PyPointCloud *self, PyObject *xyz_i_nxnynz_curvObj);
00106     static PyObject *PyPointCloud_XYZRGBNormal_append(PyPointCloud *self, PyObject *xyz_i_nxnynz_curvObj, PyObject *rgbaObj);
00107 
00108     static PyPointCloud* createEmptyPyPointCloud();
00109     
00110     //-------------------------------------------------------------------------------------------------
00111     // getter / setter
00112     //-------------------------------------------------------------------------------------------------
00113     static PyObject* PyPointCloud_GetType(PyPointCloud *self, void *closure);
00114     static PyObject* PyPointCloud_GetSize(PyPointCloud *self, void *closure);
00115     static PyObject* PyPointCloud_GetHeight(PyPointCloud *self, void *closure);
00116     static PyObject* PyPointCloud_GetWidth(PyPointCloud *self, void *closure);
00117     static PyObject* PyPointCloud_GetEmpty(PyPointCloud *self, void *closure);
00118     static PyObject* PyPointCloud_GetOrganized(PyPointCloud *self, void *closure);
00119     static PyObject* PyPointCloud_GetDense(PyPointCloud *self, void *closure);
00120     static int       PyPointCloud_SetDense(PyPointCloud *self, PyObject *value, void *closure);
00121     static PyObject* PyPointCloud_GetFields(PyPointCloud *self, void *closure);
00122 
00123     //-------------------------------------------------------------------------------------------------
00124     // sequence protocol
00125     //-------------------------------------------------------------------------------------------------
00126     static Py_ssize_t PyPointCloud_seqLength(PyPointCloud *self);
00127     static PyObject *PyPointCloud_seqConcat(PyPointCloud *self, PyObject *rhs);
00128     static PyObject *PyPointCloud_seqRepeat(PyPointCloud *self, Py_ssize_t size);
00129     static PyObject *PyPointCloud_seqItem(PyPointCloud *self, Py_ssize_t size);
00130     static int PyPointCloud_seqAssItem(PyPointCloud *self, Py_ssize_t size, PyObject *point);
00131     static PyObject *PyPointCloud_seqInplaceConcat(PyPointCloud *self, PyObject *rhs);
00132     static PyObject *PyPointCloud_seqInplaceRepeat(PyPointCloud *self, Py_ssize_t size);
00133 
00134     //-------------------------------------------------------------------------------------------------
00135     // mapping protocol
00136     //-------------------------------------------------------------------------------------------------
00137     static Py_ssize_t PyPointCloud_mappingLength(PyPointCloud *self);
00138     static PyObject *PyPointCloud_mappingGetElem(PyPointCloud *self, PyObject *key);
00139     static int PyPointCloud_mappingSetElem(PyPointCloud *self, PyObject *key, PyObject *value);
00140 
00141     //-------------------------------------------------------------------------------------------------
00142     // pickling
00143     //-------------------------------------------------------------------------------------------------
00144     static PyObject* PyPointCloud_Reduce(PyPointCloud *self, PyObject *args);
00145     static PyObject* PyPointCloud_SetState(PyPointCloud *self, PyObject *args);
00146 
00147     //-------------------------------------------------------------------------------------------------
00148     // static methods
00149     //-------------------------------------------------------------------------------------------------
00150     static PyObject *PyPointCloud_fromXYZ(PyPointCloud *self, PyObject *args);
00151     static PyObject *PyPointCloud_fromXYZI(PyPointCloud *self, PyObject *args);
00152     static PyObject *PyPointCloud_fromDisparity(PyPointCloud *self, PyObject *args, PyObject *kwds);
00153 
00154     //-------------------------------------------------------------------------------------------------
00155     // type structures
00156     //------------------------------------------------------------------------------------------------- 
00157     //static PyMemberDef PyNpDataObject_members[];
00158     static PyMethodDef PyPointCloud_methods[];
00159     static PyTypeObject PyPointCloudType;
00160     static PyModuleDef PyPointCloudModule;
00161     static PyGetSetDef PyPointCloud_getseters[];
00162     static PySequenceMethods PyPointCloud_sequenceProtocol;
00163     static PyMappingMethods PyPointCloud_mappingProtocol;
00164 
00165     static void PyPointCloud_addTpDict(PyObject *tp_dict);
00166 
00167     //--------------------------------------------------------------------------------------------------
00168     // PCL Point
00169     //--------------------------------------------------------------------------------------------------
00170     typedef struct
00171     {
00172         PyObject_HEAD
00173         ito::PCLPoint *point;
00174         PyObject* base;
00175     }
00176     PyPoint;
00177 
00178     //-------------------------------------------------------------------------------------------------
00179     // constructor, deconstructor, alloc, dellaoc
00180     //------------------------------------------------------------------------------------------------- 
00181     static void PyPoint_dealloc(PyPoint *self);
00182     static PyObject* PyPoint_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
00183     static int PyPoint_init(PyPoint *self, PyObject *args, PyObject *kwds);
00184 
00185        
00186     //-------------------------------------------------------------------------------------------------
00187     // general members
00188     //------------------------------------------------------------------------------------------------- 
00189     static PyObject *PyPoint_name(PyPoint *self);
00190     static PyObject *PyPoint_repr(PyPoint *self);
00191     
00192     //-------------------------------------------------------------------------------------------------
00193     // getter / setter
00194     //-------------------------------------------------------------------------------------------------
00195     static PyObject* PyPoint_GetType(PyPoint *self, void *closure);
00196 
00197     static PyObject* PyPoint_GetXYZ(PyPoint *self, void *closure);
00198     static int PyPoint_SetXYZ(PyPoint *self, PyObject *value, void *closure);
00199 
00200     static PyObject* PyPoint_GetIntensity(PyPoint *self, void *closure);
00201     static int PyPoint_SetIntensity(PyPoint *self, PyObject *value, void *closure);
00202 
00203     static PyObject* PyPoint_GetRgb(PyPoint *self, void *closure);
00204     static int PyPoint_SetRgb(PyPoint *self, PyObject *value, void *closure);
00205 
00206     static PyObject* PyPoint_GetRgba(PyPoint *self, void *closure);
00207     static int PyPoint_SetRgba(PyPoint *self, PyObject *value, void *closure);
00208 
00209     static PyObject* PyPoint_GetCurvature(PyPoint *self, void *closure);
00210     static int PyPoint_SetCurvature(PyPoint *self, PyObject *value, void *closure);
00211 
00212     static PyObject* PyPoint_GetNormal(PyPoint *self, void *closure);
00213     static int PyPoint_SetNormal(PyPoint *self, PyObject *value, void *closure);
00214 
00215     //-------------------------------------------------------------------------------------------------
00216     // mapping members
00217     //-------------------------------------------------------------------------------------------------
00218     static PyObject* PyPoint_mappingGetElem(PyPoint* self, PyObject* key);
00219     static int PyPoint_mappingSetElem(PyPoint* self, PyObject* key, PyObject* value);
00220 
00221     //-------------------------------------------------------------------------------------------------
00222     // type structures
00223     //------------------------------------------------------------------------------------------------- 
00224     //static PyMemberDef PyNpDataObject_members[];
00225     static PyMethodDef PyPoint_methods[];
00226     static PyTypeObject PyPointType;
00227     static PyModuleDef PyPointModule;
00228     static PyGetSetDef PyPoint_getseters[];
00229     static PyMappingMethods PyPoint_mappingProtocol;
00230 
00231     static void PyPoint_addTpDict(PyObject *tp_dict);
00232 
00233 
00234 
00235 
00236 
00237 
00238     //--------------------------------------------------------------------------------------------------
00239     // PCL PolygonMesh
00240     //--------------------------------------------------------------------------------------------------
00241     typedef struct
00242     {
00243         PyObject_HEAD
00244         ito::PCLPolygonMesh *polygonMesh;
00245         PyObject* base;
00246     }
00247     PyPolygonMesh;
00248 
00249     #define PyPolygonMesh_Check(op) PyObject_TypeCheck(op, &PythonPCL::PyPolygonMeshType)
00250 
00251     //-------------------------------------------------------------------------------------------------
00252     // constructor, deconstructor, alloc, dellaoc
00253     //------------------------------------------------------------------------------------------------- 
00254     static void PyPolygonMesh_dealloc(PyPolygonMesh *self);
00255     static PyObject* PyPolygonMesh_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
00256     static int PyPolygonMesh_init(PyPolygonMesh *self, PyObject *args, PyObject *kwds);
00257 
00258        
00259     //-------------------------------------------------------------------------------------------------
00260     // general members
00261     //------------------------------------------------------------------------------------------------- 
00262     static PyObject *PyPolygonMesh_name(PyPolygonMesh *self);
00263     static PyObject *PyPolygonMesh_repr(PyPolygonMesh *self);
00264     static PyObject *PyPolygonMesh_data(PyPolygonMesh *self);
00265 
00266     static PyObject *PyPolygonMesh_get(PyPolygonMesh *self, PyObject *args, PyObject *kwds);
00267     static PyObject* PyPolygonMesh_getCloud(PyPolygonMesh *self, PyObject *args);
00268     static PyObject* PyPolygonMesh_getPolygons(PyPolygonMesh *self, PyObject *args);
00269 
00270         //-------------------------------------------------------------------------------------------------
00271     // pickling
00272     //-------------------------------------------------------------------------------------------------
00273     static PyObject* PyPolygonMesh_Reduce(PyPolygonMesh *self, PyObject *args);
00274     static PyObject* PyPolygonMesh_SetState(PyPolygonMesh *self, PyObject *args);
00275 
00276     //-------------------------------------------------------------------------------------------------
00277     // mapping
00278     //-------------------------------------------------------------------------------------------------
00279     static PyObject* PyPolygonMesh_mappingGetElem(PyPolygonMesh* self, PyObject* key);
00280     static int PyPolygonMesh_mappingLength(PyPolygonMesh* self);
00281 
00282     //-------------------------------------------------------------------------------------------------
00283     // static methods
00284     //-------------------------------------------------------------------------------------------------
00285     static PyObject* PyPolygonMesh_FromCloudAndPolygons(PyObject *self, PyObject *args, PyObject *kwds);
00286 
00287     //-------------------------------------------------------------------------------------------------
00288     // getter / setter
00289     //-------------------------------------------------------------------------------------------------
00290     static PyObject* PyPolygonMesh_getNrOfPolygons(PyPolygonMesh *self, void *closure);
00291 
00292     //-------------------------------------------------------------------------------------------------
00293     // type structures
00294     //------------------------------------------------------------------------------------------------- 
00295     //static PyMemberDef PyNpDataObject_members[];
00296     static PyMethodDef PyPolygonMesh_methods[];
00297     static PyTypeObject PyPolygonMeshType;
00298     static PyModuleDef PyPolygonMeshModule;
00299     static PyGetSetDef PyPolygonMesh_getseters[];
00300     static PyMappingMethods PyPolygonMesh_mappingProtocol;
00301 
00302     static void PyPolygonMesh_addTpDict(PyObject *tp_dict);
00303 
00304     static PyPolygonMesh* createEmptyPyPolygonMesh();
00305 
00306 private:
00307     static PyObject* parseObjAsFloat32Array(PyObject *obj, npy_intp mRequired, npy_intp &n, float32 **elemRows);
00308     static PyObject* parseObjAsUInt8Array(PyObject *obj, npy_intp mRequired, npy_intp &n, uint8_t **elemRows);
00309 
00310 };
00311 
00312 }; //end namespace ito
00313 
00314 
00315 #endif //#if ITOM_POINTCLOUDLIBRARY > 0 
00316 
00317 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends