MeVisLabToolboxReference
MeVisLab/Standard/Sources/Shared/MLPointCloudUtils/MLMinimalDistancePointClouds/TileSphere.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00008 
00013 //----------------------------------------------------------------------------------
00014 
00015 
00016 #ifndef __TileSphere_H
00017 #define __TileSphere_H
00018 
00019 #include "../MLPointCloudUtilsSystem.h"
00020 
00021 #include <mlVector3.h>
00022 
00023 
00024 ML_START_NAMESPACE
00025 
00026 class MinimalDistancePointClouds;
00027 
00033 class TileSphere 
00034 {
00035 public:
00036 
00038   TileSphere();  
00040   TileSphere(MinimalDistancePointClouds* minimalDistance, int maxPartition = 2, int numElements = 1103, float error = 0);
00042   virtual ~TileSphere();
00043 
00045   void setParameter(MinimalDistancePointClouds* minimalDistance, int maxPartition, int numElements, float error);
00046 
00048   void setBB(float  minX, float  maxX, float  minY, float  maxY, float  minZ, float  maxZ);
00050   void addPoint(float* position);
00052   void getDeFactoSize();
00054   float computeDistance(TileSphere* tileSphere, float*& point1, float*& point2);
00055 
00057   float computeDistance(TileSphere* tileSphere, unsigned int& node1, unsigned int& nodet2);
00058 
00059 
00061   unsigned int getSphereIndex();
00062 
00064   void getStatistics(int &_treeDepth, int &usedSpheres, int &leafSpheres, int &_maxEnt);
00065 
00066 
00067 private:
00068 
00070   void _initSphere(MinimalDistancePointClouds* minimalDistance, int partition, int numElements, float error);
00072   MinimalDistancePointClouds* _minimalDistance;
00074   TileSphere* _tileSpheres;
00075 
00077   unsigned int _sphereIndex;
00078 
00080   float _error;
00081 
00083   bool _hasSubSpheresFlag;
00085   unsigned int _partition;
00087   unsigned int _cubicPartition;
00088 
00089 
00091   float** _subset;
00093   unsigned int _numEntries;
00095   int _maxEntries;
00096 
00098   float _minX, _maxX, _minY, _maxY, _minZ, _maxZ;
00100   float _position[3];
00102   float _radius;
00103 
00105   void _getBB(float& minX, float& maxX, float& minY, float& maxY, float& minZ, float& maxZ);
00107   float* _getPosition();
00109   float _getRadius();
00111   void _getSubset(float** &subset, int &size);
00113   bool _hasSubSpheres();
00114 
00118   TileSphere* _getPreciserSphere(TileSphere* referenceSphere, float distance);
00119 
00122   float _distance(TileSphere* tileSphere1, TileSphere* tileSphere2);
00123 
00125   inline float _distance(register float* point1, register float* point2) {
00126     register float d1 = * point1      - * point2;
00127     register float d2 = *(point1 + 1) - *(point2 + 1);
00128     register float d3 = *(point1 + 2) - *(point2 + 2);
00129     return sqrtf(d1*d1 + d2*d2 + d3*d3);
00130   }
00131 
00133   inline float _fastDistance(register float* point1, register float* point2) {
00134     register float d1 = * point1      - * point2;
00135     register float d2 = *(point1 + 1) - *(point2 + 1);
00136     register float d3 = *(point1 + 2) - *(point2 + 2);
00137     return (d1*d1 + d2*d2 + d3*d3);
00138   }
00139 };
00140 
00141 ML_END_NAMESPACE
00142 
00143 #endif // __TileSphere_H
00144