41 #ifndef PCL_SURFACE_ORGANIZED_FAST_MESH_H_ 42 #define PCL_SURFACE_ORGANIZED_FAST_MESH_H_ 44 #include <pcl/common/angles.h> 45 #include <pcl/surface/reconstruction.h> 64 template <
typename Po
intInT>
71 using pcl::MeshConstruction<PointInT>::input_;
72 using pcl::MeshConstruction<PointInT>::check_tree_;
206 if (angle_tolerance > 0)
303 addTriangle (
int a,
int b,
int c,
int idx, std::vector<pcl::Vertices>& polygons)
305 assert (idx < static_cast<int> (polygons.size ()));
306 polygons[idx].vertices.resize (3);
307 polygons[idx].vertices[0] = a;
308 polygons[idx].vertices[1] = b;
309 polygons[idx].vertices[2] = c;
321 addQuad (
int a,
int b,
int c,
int d,
int idx, std::vector<pcl::Vertices>& polygons)
323 assert (idx < static_cast<int> (polygons.size ()));
324 polygons[idx].vertices.resize (4);
325 polygons[idx].vertices[0] = a;
326 polygons[idx].vertices[1] = b;
327 polygons[idx].vertices[2] = c;
328 polygons[idx].vertices[3] = d;
340 resetPointData (
const int &point_index, pcl::PolygonMesh &mesh,
const float &value = 0.0f,
341 int field_x_idx = 0,
int field_y_idx = 1,
int field_z_idx = 2)
343 float new_value = value;
344 memcpy (&mesh.cloud.data[point_index * mesh.cloud.point_step + mesh.cloud.fields[field_x_idx].offset], &new_value, sizeof (
float));
345 memcpy (&mesh.cloud.data[point_index * mesh.cloud.point_step + mesh.cloud.fields[field_y_idx].offset], &new_value, sizeof (
float));
346 memcpy (&mesh.cloud.data[point_index * mesh.cloud.point_step + mesh.cloud.fields[field_z_idx].offset], &new_value, sizeof (
float));
354 isShadowed (
const PointInT& point_a,
const PointInT& point_b)
358 Eigen::Vector3f dir_a = viewpoint_ - point_a.getVector3fMap ();
359 Eigen::Vector3f dir_b = point_b.getVector3fMap () - point_a.getVector3fMap ();
360 float distance_to_points = dir_a.norm ();
361 float distance_between_points = dir_b.norm ();
363 if (cos_angle_tolerance_ > 0)
365 float cos_angle = dir_a.dot (dir_b) / (distance_to_points*distance_between_points);
366 if (cos_angle != cos_angle)
370 bool check_distance =
true;
371 if (check_angle && (distance_tolerance_ > 0))
374 if (distance_dependent_)
376 float d = distance_to_points;
377 if (use_depth_as_distance_)
380 dist_thresh *= dist_thresh;
382 check_distance = (distance_between_points > dist_thresh);
384 valid = !(check_angle && check_distance);
388 if (max_edge_length_set_)
390 float dist = (use_depth_as_distance_ ?
std::max(point_a.z, point_b.z) : distance_to_points);
393 dist_thresh += max_edge_length_b_ * dist;
395 dist_thresh += max_edge_length_c_ * dist * dist;
396 valid = (distance_between_points <= dist_thresh);
424 if (
isShadowed (input_->points[a], input_->points[b]))
return (
true);
425 if (
isShadowed (input_->points[b], input_->points[c]))
return (
true);
426 if (
isShadowed (input_->points[c], input_->points[a]))
return (
true);
437 isValidQuad (
const int& a,
const int& b,
const int& c,
const int& d)
455 if (
isShadowed (input_->points[a], input_->points[b]))
return (
true);
456 if (
isShadowed (input_->points[b], input_->points[c]))
return (
true);
457 if (
isShadowed (input_->points[c], input_->points[d]))
return (
true);
458 if (
isShadowed (input_->points[d], input_->points[a]))
return (
true);
490 #endif // PCL_SURFACE_ORGANIZED_FAST_MESH_H_
bool RTABMAP_EXP isFinite(const cv::Point3f &pt)
void addTriangle(int a, int b, int c, int idx, std::vector< pcl::Vertices > &polygons)
Add a new triangle to the current polygon mesh.
void setViewpoint(const Eigen::Vector3f &viewpoint)
Set the viewpoint from where the input point cloud has been acquired.
virtual ~OrganizedFastMesh()
Destructor.
void reconstructPolygons(std::vector< pcl::Vertices > &polygons)
Perform the actual polygonal reconstruction.
GLM_FUNC_DECL genType min(genType const &x, genType const &y)
void setTriangulationType(TriangulationType type)
Set the triangulation type (see TriangulationType)
Simple triangulation/surface reconstruction for organized point clouds. Neighboring points (pixels in...
float max_edge_length_b_
max length of edge, scalar component
void setTrianglePixelSizeColumns(int triangle_size)
Set the edge length (in pixels) used for iterating over columns when constructing the fixed mesh...
void setAngleTolerance(float angle_tolerance)
Set the angle tolerance used for checking whether or not an edge is occluded. Standard values are 5de...
int triangle_pixel_size_rows_
size of triangle edges (in pixels) for iterating over rows.
void setTrianglePixelSizeRows(int triangle_size)
Set the edge length (in pixels) used for iterating over rows when constructing the fixed mesh...
float cos_angle_tolerance_
(Cosine of the) angle tolerance used when checking whether or not an edge between two points is shado...
bool use_depth_as_distance_
flag whether or not the points' depths are used instead of measured distances (points' distances to t...
const Eigen::Vector3f & getViewpoint() const
Get the viewpoint from where the input point cloud has been acquired.
Eigen::Vector3f viewpoint_
Viewpoint from which the point cloud has been acquired (in the same coordinate frame as the data)...
void addQuad(int a, int b, int c, int d, int idx, std::vector< pcl::Vertices > &polygons)
Add a new quad to the current polygon mesh.
bool store_shadowed_faces_
Whether or not shadowed faces are stored, e.g., for exploration.
bool isShadowedQuad(const int &a, const int &b, const int &c, const int &d)
Check if a triangle is shadowed.
OrganizedFastMesh()
Constructor. Triangulation type defaults to QUAD_MESH.
std::vector< pcl::Vertices > Polygons
void setTrianglePixelSize(int triangle_size)
Set the edge length (in pixels) used for constructing the fixed mesh.
void storeShadowedFaces(bool enable)
Store shadowed faces or not.
pcl::PointCloud< PointInT >::Ptr PointCloudPtr
void useDepthAsDistance(bool enable)
Use the points' depths (z-coordinates) instead of measured distances (points' distances to the viewpo...
void unsetMaxEdgeLength()
bool isShadowedTriangle(const int &a, const int &b, const int &c)
Check if a triangle is shadowed.
void makeRightCutMesh(std::vector< pcl::Vertices > &polygons)
Create a right cut mesh.
bool isValidQuad(const int &a, const int &b, const int &c, const int &d)
Check if a quad is valid.
bool isValidTriangle(const int &a, const int &b, const int &c)
Check if a triangle is valid.
void makeQuadMesh(std::vector< pcl::Vertices > &polygons)
Create a quad mesh.
int triangle_pixel_size_columns_
size of triangle edges (in pixels) for iterating over columns
float max_edge_length_c_
max length of edge, scalar component
void makeLeftCutMesh(std::vector< pcl::Vertices > &polygons)
Create a left cut mesh.
bool distance_dependent_
flag whether or not distance_tolerance_ is distance dependent (multiplied by the squared distance to ...
virtual void performReconstruction(std::vector< pcl::Vertices > &polygons)
Create the surface.
bool isShadowed(const PointInT &point_a, const PointInT &point_b)
Check if a point is shadowed by another point.
void resetPointData(const int &point_index, pcl::PolygonMesh &mesh, const float &value=0.0f, int field_x_idx=0, int field_y_idx=1, int field_z_idx=2)
Set (all) coordinates of a particular point to the specified value.
GLM_FUNC_DECL genType max(genType const &x, genType const &y)
boost::shared_ptr< OrganizedFastMesh< PointInT > > Ptr
boost::shared_ptr< const OrganizedFastMesh< PointInT > > ConstPtr
void makeAdaptiveCutMesh(std::vector< pcl::Vertices > &polygons)
Create an adaptive cut mesh.
float distance_tolerance_
distance tolerance for filtering out shadowed/occluded edges
void setDistanceTolerance(float distance_tolerance, bool depth_dependent=false)
bool max_edge_length_set_
flag whether or not edges are limited in length
bool max_edge_length_dist_dependent_
flag whether or not max edge length is distance dependent.
float max_edge_length_a_
max length of edge, scalar component
void setMaxEdgeLength(float a, float b=0.0f, float c=0.0f)
Set a maximum edge length. Using not only the scalar a, but also b and c, allows for using a distance...
TriangulationType triangulation_type_
Type of meshing scheme (quads vs. triangles, left cut vs. right cut ...