AdaptiveKSearchSurface.hpp
Go to the documentation of this file.
1 
28  /*
29  * AdaptiveKSearchSurface.h
30  *
31  * Created on: 07.02.2011
32  * Author: Thomas Wiemann
33  * co-Author: Dominik Feldschnieders (dofeldsc@uos.de)
34  */
35 
36 #ifndef LVR2_RECONSTRUCTION_ADAPTIVEKSEARCHSURFACE_H_
37 #define LVR2_RECONSTRUCTION_ADAPTIVEKSEARCHSURFACE_H_
38 
39 #include <cassert>
40 #include <fstream>
41 #include <iostream>
42 #include <limits>
43 #include <memory>
44 #include <string>
45 #include <chrono>
46 #include <cmath>
47 
48 #include "lvr2/io/PointBuffer.hpp"
49 #include "lvr2/geometry/Normal.hpp"
50 #include "lvr2/geometry/Plane.hpp"
51 #include "lvr2/io/Progress.hpp"
53 
54 
55 
56 #include "PointsetSurface.hpp"
57 
58 // #ifdef LVR2_USE_STANN
59 // // SearchTreeStann
60 // #include "SearchTreeStann.hpp"
61 // #endif
62 
63 // #include "SearchTreeNanoflann.hpp"
64 #include "SearchTreeFlann.hpp"
65 
66 // // SearchTreePCL
67 // #ifdef LVR2_USE_PCL
68 // #include "SearchTreeFlannPCL.hpp"
69 // #endif
70 
71 // // SearchTreeNabo
72 // #ifdef LVR2_USE_NABO
73 // #include "SearchTreeNabo.hpp"
74 // #endif
75 
76 
77 // using std::cout;
78 // using std::endl;
79 // using std::ifstream;
80 using std::numeric_limits;
81 // using std::ofstream;
82 // using std::shared_ptr;
83 using std::string;
84 using std::unique_ptr;
85 using std::isnan;
86 
87 
88 namespace lvr2
89 {
90 
97 template<typename BaseVecT>
98 class AdaptiveKSearchSurface : public PointsetSurface<BaseVecT>
99 {
100 public:
101 
102  // typedef shared_ptr<AdaptiveKSearchSurface<BaseVecT>> Ptr;
103 
115  PointBufferPtr loader,
116  std::string searchTreeName,
117  int kn = 10,
118  int ki = 10,
119  int kd = 10,
120  int calcMethod = 0,
121  string poseFile = ""
122  );
123 
136 
141 
142 
144  virtual pair<typename BaseVecT::CoordType, typename BaseVecT::CoordType>
145  distance(BaseVecT v) const;
146 
151  virtual void calculateSurfaceNormals();
152 
153 
154 
155 
156  // /**
157  // * @brief Returns the number of managed points
158  // */
159  // virtual size_t getNumPoints();
160 
161  // /**
162  // * @brief Calculates a tangent plane for the query point using the provided
163  // * k-neighborhood
164  // *
165  // * @param queryPoint The point for which the tangent plane is created
166  // * @param k The size of the used k-neighborhood
167  // * @param points The neighborhood points
168  // * @param ok True, if RANSAC interpolation was succesfull
169  // *
170  // * @return the resulting plane
171  // */
172  // Plane<BaseVecT> calcPlaneRANSACfromPoints(
173  // const BaseVecT& queryPoint,
174  // int k,
175  // vector<BaseVecT> points,
176  // NormalT c_normal,
177  // bool& ok
178  // );
179 
180 
181 
182  // /**
183  // * @brief Returns the point at the given \ref{index}.
184  // */
185  // virtual const BaseVecT operator[](size_t index) const;
186 
187 
188  // virtual void colorizePointCloud( typename AdaptiveKSearchSurface<VertexT, NormalT>::Ptr pcm,
189  // const float &sqrtMaxDist = std::numeric_limits<float>::max(),
190  // const unsigned char* blankColor = NULL );
191 
192  // /**
193  // * @brief If set to true, normals will be calculated using RANSAC instead of
194  // * plane fitting
195  // */
196  // void useRansac(bool use_it) { m_useRANSAC = use_it; }
197 
198 
199  // /// Color information for points public: TODO: This is not the best idea!
200  // color3bArr m_colors;
201 
206 
207 private:
208 
213  void parseScanPoses(string posefile);
214 
215  // /**
216  // * @brief Returns the k closest neighbor vertices to a given queryy point
217  // *
218  // * @param v A query vertex
219  // * @param k The (max) number of returned closest points to v
220  // * @param nb A vector containing the determined closest points
221  // */
222  // virtual void getkClosestVertices(const BaseVecT &v,
223  // const size_t &k, vector<BaseVecT> &nb);
224 
225 
229  void init();
230 
242  bool boundingBoxOK(float dx, float dy, float dz);
243 
244  // /**
245  // * @brief Returns the mean distance of the given point set from
246  // * the given plane
247  // *
248  // * @param p The query plane
249  // * @param id A list of point id's
250  // * @param k The number of points in the list
251  // */
252  // float meanDistance(const Plane<VertexT, NormalT> &p, const vector<unsigned long> &id, const int &k);
253 
254  // /**
255  // * @brief Returns a vertex representation of the given point in the
256  // * point array
257  // *
258  // * @param i A id of a point in the current point set
259  // * @return A vertex representation of the given point
260  // */
261  // VertexT fromID(int i);
262 
263  // /**
264  // * @brief Returns the distance between vertex v and plane p
265  // */
266  // float distance(VertexT v, Plane<VertexT, NormalT> p);
267 
268 
269  // void radiusSearch(const VertexT &v, double r, vector<VertexT> &resV, vector<NormalT> &resN){};
270 
281  const BaseVecT &queryPoint,
282  int k,
283  const vector<size_t> &id
284  );
285 
287  const BaseVecT &queryPoint,
288  int k,
289  const vector<size_t> &id,
290  bool &ok
291  );
292 
294  const BaseVecT &queryPoint,
295  int k,
296  const vector<size_t> &id
297  );
298 
299 
300 
301 
303  BaseVecT m_centroid;
304 
305  // 0: PCA
306  // 1: RANSAC
307  // 2: Iterative
309 
310  // /// The currently stored points
311  // coord3fArr m_points;
312 
313  // /// The point normals
314  // coord3fArr m_normals;
315 
316  // /// A model of the current pointcloud
317  // boost::shared_ptr<Model> m_model;
318 
319  // size_t m_numPoints;
320 
322  std::shared_ptr<SearchTree<BaseVecT>> m_poseTree;
323 
326 
327 };
328 
329 
330 } // namespace lvr2
331 
332 #include "lvr2/reconstruction/AdaptiveKSearchSurface.tcc"
333 
334 #endif // LVR2_RECONSTRUCTION_ADAPTIVEKSEARCHSURFACE_H_
lvr2::AdaptiveKSearchSurface::boundingBoxOK
bool boundingBoxOK(float dx, float dy, float dz)
Checks if the bounding box of a point set is "well formed", i.e. no dimension is significantly larger...
BaseVector.hpp
lvr2::AdaptiveKSearchSurface::calcPlane
Plane< BaseVecT > calcPlane(const BaseVecT &queryPoint, int k, const vector< size_t > &id)
Calculates a tangent plane for the query point using the provided k-neighborhood.
lvr2::AdaptiveKSearchSurface::calcPlaneIterative
Plane< BaseVecT > calcPlaneIterative(const BaseVecT &queryPoint, int k, const vector< size_t > &id)
lvr2::AdaptiveKSearchSurface::~AdaptiveKSearchSurface
virtual ~AdaptiveKSearchSurface()
Destructor.
Definition: AdaptiveKSearchSurface.hpp:140
PointsetSurface.hpp
lvr2::AdaptiveKSearchSurface::m_centroid
BaseVecT m_centroid
The centroid of the point set.
Definition: AdaptiveKSearchSurface.hpp:303
lvr2::AdaptiveKSearchSurface::calculateSurfaceNormals
virtual void calculateSurfaceNormals()
Calculates initial point normals using a least squares fit to the m_kn nearest points.
lvr2::PointBufferPtr
std::shared_ptr< PointBuffer > PointBufferPtr
Definition: PointBuffer.hpp:130
isnan
#define isnan(x)
Definition: PCDIO.cpp:35
lvr2::Plane
A plane.
Definition: Plane.hpp:50
lvr2::AdaptiveKSearchSurface::distance
virtual pair< typename BaseVecT::CoordType, typename BaseVecT::CoordType > distance(BaseVecT v) const
See interface documentation.
lvr2::AdaptiveKSearchSurface::m_searchTreeName
string m_searchTreeName
Type of used search tree.
Definition: AdaptiveKSearchSurface.hpp:325
lvr2::AdaptiveKSearchSurface::AdaptiveKSearchSurface
AdaptiveKSearchSurface()
standard Constructor
lvr2::AdaptiveKSearchSurface::m_calcMethod
int m_calcMethod
Definition: AdaptiveKSearchSurface.hpp:308
lvr2::AdaptiveKSearchSurface
A point cloud manager class that uses the STANN nearest neighbor search library to handle the data....
Definition: AdaptiveKSearchSurface.hpp:98
PointBuffer.hpp
lvr2::PointsetSurface
An interface class to wrap all functionality that is needed to generate a surface approximation from ...
Definition: PointsetSurface.hpp:61
lvr2::AdaptiveKSearchSurface::interpolateSurfaceNormals
void interpolateSurfaceNormals()
Interpolate the initial normals with the m_ki neighbors.
Progress.hpp
SearchTreeFlann.hpp
lvr2::AdaptiveKSearchSurface::calcPlaneRANSAC
Plane< BaseVecT > calcPlaneRANSAC(const BaseVecT &queryPoint, int k, const vector< size_t > &id, bool &ok)
lvr2::AdaptiveKSearchSurface::init
void init()
Helper function for constructors.
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::AdaptiveKSearchSurface::parseScanPoses
void parseScanPoses(string posefile)
Parses the file with scan poses and creates a search tree to search for the nearest pose when flippin...
Plane.hpp
lvr2::AdaptiveKSearchSurface::m_poseTree
std::shared_ptr< SearchTree< BaseVecT > > m_poseTree
Search tree for scan poses.
Definition: AdaptiveKSearchSurface.hpp:322
Normal.hpp


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:22