Point Cloud Library (PCL)
1.10.1
|
41 #include <pcl/surface/boost.h>
42 #include <pcl/surface/reconstruction.h>
44 #include <unordered_map>
50 {0, 4}, {1, 5}, {2, 6}, {3, 7},
51 {0, 1}, {1, 2}, {2, 3}, {3, 0},
52 {4, 5}, {5, 6}, {6, 7}, {7, 4}
73 template <
typename Po
intNT>
98 typedef std::unordered_map<int, Leaf, std::hash<int>, std::equal_to<>, Eigen::aligned_allocator<std::pair<const int, Leaf>>>
HashMap;
117 leaf_size_ = resolution;
138 padding_size_ = padding_size;
143 return (padding_size_);
168 max_binary_search_level_ = max_binary_search_level;
173 return (max_binary_search_level_);
180 return (cell_hash_map_);
183 inline const std::vector<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f> >&
186 return (vector_at_data_point_);
189 inline const std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> >&
232 std::vector<pcl::Vertices> &polygons)
override;
250 for (
int i = 0; i < 3; ++i)
251 index[i] =
static_cast<int> ((p[i] - min_p_(i)) / leaf_size_);
262 for (
int i = 0; i < 3; ++i)
264 min_p_[i] +
static_cast<float> (index[i]) *
265 static_cast<float> (leaf_size_) +
266 static_cast<float> (leaf_size_) / 2.0f;
275 std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> > &pts)
const;
285 return (index[0] * data_size_ * data_size_ +
286 index[1] * data_size_ + index[2]);
298 index_3d[0] = index_1d / (data_size_ * data_size_);
299 index_1d -= index_3d[0] * data_size_ * data_size_;
300 index_3d[1] = index_1d / data_size_;
301 index_1d -= index_3d[1] * data_size_;
302 index_3d[2] = index_1d;
310 fillPad (
const Eigen::Vector3i &index);
317 getDataPtsUnion (
const Eigen::Vector3i &index, std::vector <int> &pt_union_indices);
337 getProjection (
const Eigen::Vector4f &p, std::vector<int> &pt_union_indices, Eigen::Vector4f &projection);
348 std::vector<int> &pt_union_indices,
349 Eigen::Vector4f &projection);
359 std::vector <int> &pt_union_indices, Eigen::Vector3f &vo);
370 std::vector<int> &k_indices,
371 std::vector<float> &k_squared_distances,
372 Eigen::Vector3f &vo);
379 getMagAtPoint (
const Eigen::Vector4f &p,
const std::vector <int> &pt_union_indices);
387 getD1AtPoint (
const Eigen::Vector4f &p,
const Eigen::Vector3f &vec,
388 const std::vector <int> &pt_union_indices);
396 getD2AtPoint (
const Eigen::Vector4f &p,
const Eigen::Vector3f &vec,
397 const std::vector <int> &pt_union_indices);
408 isIntersected (
const std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> > &end_pts,
409 std::vector<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f> > &vect_at_end_pts,
410 std::vector <int> &pt_union_indices);
422 const std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> > &end_pts,
423 const std::vector<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f> > &vect_at_end_pts,
424 const Eigen::Vector4f &start_pt,
425 std::vector<int> &pt_union_indices,
426 Eigen::Vector4f &intersection);
444 std::vector<int> &pt_union_indices,
const Leaf &cell_data);
467 Eigen::Vector4f min_p_, max_p_;
473 double gaussian_scale_;
479 int max_binary_search_level_;
491 std::vector<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f> > vector_at_data_point_;
494 std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> > surface_;
497 boost::dynamic_bitset<> occupied_cell_list_;
500 std::string getClassName ()
const override {
return (
"GridProjection"); }
void performReconstruction(pcl::PolygonMesh &output) override
Create the surface.
Defines all the PCL and non-PCL macros used.
This file defines compatibility wrappers for low level I/O functions.
void getProjectionWithPlaneFit(const Eigen::Vector4f &p, std::vector< int > &pt_union_indices, Eigen::Vector4f &projection)
Given the coordinates of one point, project it onto the surface, return the projected point.
KdTree represents the base spatial locator class for kd-tree implementations.
void setResolution(double resolution)
Set the size of the grid cell.
double getD1AtPoint(const Eigen::Vector4f &p, const Eigen::Vector3f &vec, const std::vector< int > &pt_union_indices)
Get the 1st derivative.
Grid projection surface reconstruction method.
void getVectorAtPoint(const Eigen::Vector4f &p, std::vector< int > &pt_union_indices, Eigen::Vector3f &vo)
Given the location of a point, get it's vector.
void getVertexFromCellCenter(const Eigen::Vector4f &cell_center, std::vector< Eigen::Vector4f, Eigen::aligned_allocator< Eigen::Vector4f > > &pts) const
Given cell center, caluate the coordinates of the eight vertices of the cell.
const HashMap & getCellHashMap() const
typename KdTree::Ptr KdTreePtr
void setMaxBinarySearchLevel(int max_binary_search_level)
Binary search is used in projection.
void setPaddingSize(int padding_size)
When averaging the vectors, we find the union of all the input data points within the padding area,...
void getIndexIn3D(int index_1d, Eigen::Vector3i &index_3d) const
Given an index in 1d, translate it into the index (x, y, z) in 3d.
void storeVectAndSurfacePointKNN(int index_1d, const Eigen::Vector3i &index_3d, const Leaf &cell_data)
Go through all the entries in the hash table and update the cellData.
SurfaceReconstruction represents a base surface reconstruction class.
void scaleInputDataPoint(double scale_factor)
When the input data points don't fill into the 1*1*1 box, scale them so that they can be filled in th...
void setNearestNeighborNum(int k)
Set this only when using the k nearest neighbors search instead of finding the point union.
double getMagAtPoint(const Eigen::Vector4f &p, const std::vector< int > &pt_union_indices)
Get the magnitude of the vector by summing up the distance.
void createSurfaceForCell(const Eigen::Vector3i &index, std::vector< int > &pt_union_indices)
Given the index of a cell, exam it's up, left, front edges, and add the vectices to m_surface list....
void storeVectAndSurfacePoint(int index_1d, const Eigen::Vector3i &index_3d, std::vector< int > &pt_union_indices, const Leaf &cell_data)
Go through all the entries in the hash table and update the cellData.
typename pcl::PointCloud< PointNT >::Ptr PointCloudPtr
const std::vector< Eigen::Vector3f, Eigen::aligned_allocator< Eigen::Vector3f > > & getVectorAtDataPoint() const
Eigen::Vector4f pt_on_surface
void findIntersection(int level, const std::vector< Eigen::Vector4f, Eigen::aligned_allocator< Eigen::Vector4f > > &end_pts, const std::vector< Eigen::Vector3f, Eigen::aligned_allocator< Eigen::Vector3f > > &vect_at_end_pts, const Eigen::Vector4f &start_pt, std::vector< int > &pt_union_indices, Eigen::Vector4f &intersection)
Find point where the edge intersects the surface.
shared_ptr< const GridProjection< PointNT > > ConstPtr
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
std::vector< int > data_indices
double getD2AtPoint(const Eigen::Vector4f &p, const Eigen::Vector3f &vec, const std::vector< int > &pt_union_indices)
Get the 2nd derivative.
bool reconstructPolygons(std::vector< pcl::Vertices > &polygons)
The actual surface reconstruction method.
int getIndexIn1D(const Eigen::Vector3i &index) const
Given an index (x, y, z) in 3d, translate it into the index in 1d.
double getResolution() const
shared_ptr< PointCloud< PointT > > Ptr
GridProjection()
Constructor.
int getMaxBinarySearchLevel() const
shared_ptr< KdTree< PointT > > Ptr
const int I_SHIFT_EDGE[3][2]
shared_ptr< GridProjection< PointNT > > Ptr
Eigen::Vector3f vect_at_grid_pt
const std::vector< Eigen::Vector4f, Eigen::aligned_allocator< Eigen::Vector4f > > & getSurface() const
void getBoundingBox()
Get the bounding box for the input data points, also calculating the cell size, and the gaussian scal...
const int I_SHIFT_EP[12][2]
The 12 edges of a cell.
int getPaddingSize() const
~GridProjection()
Destructor.
void fillPad(const Eigen::Vector3i &index)
For a given 3d index of a cell, test whether the cells within its padding area exist in the hash tabl...
void getCellCenterFromIndex(const Eigen::Vector3i &index, Eigen::Vector4f ¢er) const
Given the 3d index (x, y, z) of the cell, get the coordinates of the cell center.
std::unordered_map< int, Leaf, std::hash< int >, std::equal_to<>, Eigen::aligned_allocator< std::pair< const int, Leaf > > > HashMap
void getCellIndex(const Eigen::Vector4f &p, Eigen::Vector3i &index) const
Get the 3d index (x,y,z) of the cell based on the location of the cell.
bool isIntersected(const std::vector< Eigen::Vector4f, Eigen::aligned_allocator< Eigen::Vector4f > > &end_pts, std::vector< Eigen::Vector3f, Eigen::aligned_allocator< Eigen::Vector3f > > &vect_at_end_pts, std::vector< int > &pt_union_indices)
Test whether the edge is intersected by the surface by doing the dot product of the vector at two end...
void getDataPtsUnion(const Eigen::Vector3i &index, std::vector< int > &pt_union_indices)
Obtain the index of a cell and the pad size.
void getProjection(const Eigen::Vector4f &p, std::vector< int > &pt_union_indices, Eigen::Vector4f &projection)
Given the coordinates of one point, project it onto the surface, return the projected point.
boost::shared_ptr< T > shared_ptr
Alias for boost::shared_ptr.
void getVectorAtPointKNN(const Eigen::Vector4f &p, std::vector< int > &k_indices, std::vector< float > &k_squared_distances, Eigen::Vector3f &vo)
Given the location of a point, get it's vector.
int getNearestNeighborNum() const