Guest User

Untitled

a guest
Aug 17th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. class ImplicitSurface {
  2. public:
  3. virtual float evaluate(float x , float y , float z) const = 0;
  4. };
  5.  
  6. class MarchingCubes : public pcl::MarchingCubes<pcl::PointNormal> {
  7. public:
  8. MarchingCubes(ImplicitSurface*);
  9. void voxelizeData();
  10.  
  11. private:
  12. ImplicitSurface* implicitSurface;
  13. };
  14.  
  15. void MarchingCubes::voxelizeData() {
  16. for (int x = 0; x < res_x_; ++x)
  17. for (int y = 0; y < res_y_; ++y)
  18. for (int z = 0; z < res_z_; ++z)
  19. {
  20. std::vector<int> nn_indices;
  21. std::vector<float> nn_sqr_dists;
  22.  
  23. Eigen::Vector3f point;
  24. point[0] = min_p_[0] + (max_p_[0] - min_p_[0]) * float (x) / float (res_x_);
  25. point[1] = min_p_[1] + (max_p_[1] - min_p_[1]) * float (y) / float (res_y_);
  26. point[2] = min_p_[2] + (max_p_[2] - min_p_[2]) * float (z) / float (res_z_);
  27.  
  28. pcl::PointNormal p;
  29. p.getVector3fMap () = point;
  30.  
  31. tree_->nearestKSearch (p, 1, nn_indices, nn_sqr_dists);
  32.  
  33. float currentValue = implicitSurface->evaluate (point[0], point[1], point[2]);
  34. grid_[x * res_y_ * res_z_ + y * res_z_ + z] = currentValue;
  35. }
  36. }
Add Comment
Please, Sign In to add comment