MeVisLab Toolbox Reference
TileSphere.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 
19 
20 #pragma once
21 
22 #include "../MLPointCloudUtilsSystem.h"
23 
24 #include <mlVector3.h>
25 
26 
27 ML_START_NAMESPACE
28 
29 class MinimalDistancePointClouds;
30 
37 {
38 public:
39 
43  TileSphere(MinimalDistancePointClouds* minimalDistance, int maxPartition = 2, int numElements = 1103, float error = 0);
45  virtual ~TileSphere();
46 
48  void setParameter(MinimalDistancePointClouds* minimalDistance, int maxPartition, int numElements, float error);
49 
51  void setBB(float minX, float maxX, float minY, float maxY, float minZ, float maxZ);
53  void addPoint(float* position);
57  float computeDistance(TileSphere* tileSphere, float*& point1, float*& point2);
58 
60  float computeDistance(TileSphere* tileSphere, unsigned int& node1, unsigned int& nodet2);
61 
62 
64  unsigned int getSphereIndex();
65 
67  void getStatistics(int &_treeDepth, int &usedSpheres, int &leafSpheres, int &_maxEnt);
68 
69 
70 private:
71 
73  void _initSphere(MinimalDistancePointClouds* minimalDistance, int partition, int numElements, float error);
75  MinimalDistancePointClouds* _minimalDistance;
77  TileSphere* _tileSpheres;
78 
80  unsigned int _sphereIndex;
81 
83  float _error;
84 
86  bool _hasSubSpheresFlag;
88  unsigned int _partition;
90  unsigned int _cubicPartition;
91 
92 
94  float** _subset;
96  unsigned int _numEntries;
98  int _maxEntries;
99 
101  float _minX, _maxX, _minY, _maxY, _minZ, _maxZ;
103  float _position[3];
105  float _radius;
106 
108  void _getBB(float& minX, float& maxX, float& minY, float& maxY, float& minZ, float& maxZ);
110  float* _getPosition();
112  float _getRadius();
114  void _getSubset(float** &subset, int &size);
116  bool _hasSubSpheres();
117 
121  TileSphere* _getPreciserSphere(TileSphere* referenceSphere, float distance);
122 
125  float _distance(TileSphere* tileSphere1, TileSphere* tileSphere2);
126 
128  inline float _distance(const float* point1, const float* point2)
129  {
130  const float d1 = * point1 - * point2;
131  const float d2 = *(point1 + 1) - *(point2 + 1);
132  const float d3 = *(point1 + 2) - *(point2 + 2);
133  return sqrtf(d1*d1 + d2*d2 + d3*d3);
134  }
135 
137  inline float _fastDistance(const float* point1, const float* point2)
138  {
139  const float d1 = * point1 - * point2;
140  const float d2 = *(point1 + 1) - *(point2 + 1);
141  const float d3 = *(point1 + 2) - *(point2 + 2);
142  return (d1*d1 + d2*d2 + d3*d3);
143  }
144 };
145 
146 ML_END_NAMESPACE
The MinimalDistancePointClouds implements a fast nearest pair search algorithm described by Sean Quin...
TileSphere is used in the class MinimalDistancePointClouds.
Definition: TileSphere.h:37
void setBB(float minX, float maxX, float minY, float maxY, float minZ, float maxZ)
Defines which points will be put into this sphere.
float computeDistance(TileSphere *tileSphere, float *&point1, float *&point2)
Computes the distance and returns references to the nearest points of both sets.
virtual ~TileSphere()
Destructor.
TileSphere()
Default Constructor.
void getDeFactoSize()
Computes the optimal bounding sphere.
void addPoint(float *position)
Put a point into this sphere (or one of its sub spheres).
unsigned int getSphereIndex()
Returns the index of the TileSphere.
TileSphere(MinimalDistancePointClouds *minimalDistance, int maxPartition=2, int numElements=1103, float error=0)
Constructor with a pointer on the main class and presets for the distance computation.
void getStatistics(int &_treeDepth, int &usedSpheres, int &leafSpheres, int &_maxEnt)
Returns statistics for debugging purposes.
void setParameter(MinimalDistancePointClouds *minimalDistance, int maxPartition, int numElements, float error)
Must be called, when TileSphere was instantiated with the default constructor.
float computeDistance(TileSphere *tileSphere, unsigned int &node1, unsigned int &nodet2)
Computes the distance and returns a references to the entryNumbers of the nearest nodes of both sets.