43 #include <pcl/common/angles.h>
44 #include <pcl/common/point_tests.h>
45 #include <pcl/surface/reconstruction.h>
65 template <
typename Po
intInT>
69 using Ptr = shared_ptr<OrganizedFastMesh<PointInT> >;
70 using ConstPtr = shared_ptr<const OrganizedFastMesh<PointInT> >;
207 if (angle_tolerance > 0)
304 addTriangle (
int a,
int b,
int c,
int idx, std::vector<pcl::Vertices>& polygons)
306 assert (idx < static_cast<int> (polygons.size ()));
307 polygons[idx].vertices.resize (3);
308 polygons[idx].vertices[0] = a;
309 polygons[idx].vertices[1] = b;
310 polygons[idx].vertices[2] = c;
322 addQuad (
int a,
int b,
int c,
int d,
int idx, std::vector<pcl::Vertices>& polygons)
324 assert (idx < static_cast<int> (polygons.size ()));
325 polygons[idx].vertices.resize (4);
326 polygons[idx].vertices[0] = a;
327 polygons[idx].vertices[1] = b;
328 polygons[idx].vertices[2] = c;
329 polygons[idx].vertices[3] = d;
342 int field_x_idx = 0,
int field_y_idx = 1,
int field_z_idx = 2)
344 float new_value = value;
355 isShadowed (
const PointInT& point_a,
const PointInT& point_b)
359 Eigen::Vector3f dir_a = viewpoint_ - point_a.getVector3fMap ();
360 Eigen::Vector3f dir_b = point_b.getVector3fMap () - point_a.getVector3fMap ();
361 float distance_to_points = dir_a.norm ();
362 float distance_between_points = dir_b.norm ();
364 if (cos_angle_tolerance_ > 0)
366 float cos_angle = dir_a.dot (dir_b) / (distance_to_points*distance_between_points);
367 if (std::isnan(cos_angle))
371 bool check_distance =
true;
372 if (check_angle && (distance_tolerance_ > 0))
375 if (distance_dependent_)
377 float d = distance_to_points;
378 if (use_depth_as_distance_)
379 d = std::max(point_a.z, point_b.z);
381 dist_thresh *= dist_thresh;
383 check_distance = (distance_between_points > dist_thresh);
385 valid = !(check_angle && check_distance);
389 if (max_edge_length_set_)
391 float dist = (use_depth_as_distance_ ? std::max(point_a.z, point_b.z) : distance_to_points);
393 if (std::fabs(max_edge_length_b_) > std::numeric_limits<float>::min())
394 dist_thresh += max_edge_length_b_ * dist;
395 if (std::fabs(max_edge_length_c_) > std::numeric_limits<float>::min())
396 dist_thresh += max_edge_length_c_ * dist * dist;
397 valid = (distance_between_points <= dist_thresh);
438 isValidQuad (
const int& a,
const int& b,
const int& c,
const int& d)
489 #ifdef PCL_NO_PRECOMPILE
490 #include <pcl/surface/impl/organized_fast_mesh.hpp>
void setTriangulationType(TriangulationType type)
Set the triangulation type (see TriangulationType)
void makeQuadMesh(std::vector< pcl::Vertices > &polygons)
Create a quad mesh.
void setDistanceTolerance(float distance_tolerance, bool depth_dependent=false)
bool isFinite(const PointT &pt)
Tests if the 3D components of a point are all finite param[in] pt point to be tested return true if f...
std::vector<::pcl::PCLPointField > fields
shared_ptr< PointCloud< PointT > > Ptr
float deg2rad(float alpha)
Convert an angle from degrees to radians.
bool check_tree_
A flag specifying whether or not the derived reconstruction algorithm needs the search object tree...
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.
void makeAdaptiveCutMesh(std::vector< pcl::Vertices > &polygons)
Create an adaptive cut mesh.
Eigen::Vector3f viewpoint_
Viewpoint from which the point cloud has been acquired (in the same coordinate frame as the data)...
Simple triangulation/surface reconstruction for organized point clouds.
~OrganizedFastMesh()
Destructor.
bool distance_dependent_
flag whether or not distance_tolerance_ is distance dependent (multiplied by the squared distance to ...
void setTrianglePixelSizeRows(int triangle_size)
Set the edge length (in pixels) used for iterating over rows when constructing the fixed mesh...
void setTrianglePixelSize(int triangle_size)
Set the edge length (in pixels) used for constructing the fixed mesh.
void makeLeftCutMesh(std::vector< pcl::Vertices > &polygons)
Create a left cut mesh.
void reconstructPolygons(std::vector< pcl::Vertices > &polygons)
Perform the actual polygonal reconstruction.
TriangulationType triangulation_type_
Type of meshing scheme (quads vs.
int triangle_pixel_size_rows_
size of triangle edges (in pixels) for iterating over rows.
void makeRightCutMesh(std::vector< pcl::Vertices > &polygons)
Create a right cut mesh.
float max_edge_length_a_
max length of edge, scalar component
void setAngleTolerance(float angle_tolerance)
Set the angle tolerance used for checking whether or not an edge is occluded.
typename pcl::PointCloud< PointInT >::Ptr PointCloudPtr
float max_edge_length_b_
max length of edge, scalar component
int triangle_pixel_size_columns_
size of triangle edges (in pixels) for iterating over columns
bool isValidTriangle(const int &a, const int &b, const int &c)
Check if a triangle is valid.
void setTrianglePixelSizeColumns(int triangle_size)
Set the edge length (in pixels) used for iterating over columns when constructing the fixed mesh...
bool isShadowedQuad(const int &a, const int &b, const int &c, const int &d)
Check if a triangle is shadowed.
bool isValidQuad(const int &a, const int &b, const int &c, const int &d)
Check if a quad is valid.
void setMaxEdgeLength(float a, float b=0.0f, float c=0.0f)
Set a maximum edge length.
void setViewpoint(const Eigen::Vector3f &viewpoint)
Set the viewpoint from where the input point cloud has been acquired.
float max_edge_length_c_
max length of edge, scalar component
float cos_angle_tolerance_
(Cosine of the) angle tolerance used when checking whether or not an edge between two points is shado...
MeshConstruction represents a base surface reconstruction class.
void unsetMaxEdgeLength()
std::vector< std::uint8_t > 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.
const Eigen::Vector3f & getViewpoint() const
Get the viewpoint from where the input point cloud has been acquired.
void useDepthAsDistance(bool enable)
Use the points' depths (z-coordinates) instead of measured distances (points' distances to the viewpo...
::pcl::PCLPointCloud2 cloud
void addTriangle(int a, int b, int c, int idx, std::vector< pcl::Vertices > &polygons)
Add a new triangle to the current polygon mesh.
shared_ptr< const OrganizedFastMesh< PointInT > > ConstPtr
shared_ptr< OrganizedFastMesh< PointInT > > Ptr
float distance_tolerance_
distance tolerance for filtering out shadowed/occluded edges
PointCloudConstPtr input_
The input point cloud dataset.
bool isShadowedTriangle(const int &a, const int &b, const int &c)
Check if a triangle is shadowed.
void storeShadowedFaces(bool enable)
Store shadowed faces or not.
void performReconstruction(std::vector< pcl::Vertices > &polygons) override
Create the surface.
std::vector< pcl::Vertices > Polygons
bool max_edge_length_set_
flag whether or not edges are limited in length
bool use_depth_as_distance_
flag whether or not the points' depths are used instead of measured distances (points' distances to t...
bool isShadowed(const PointInT &point_a, const PointInT &point_b)
Check if a point is shadowed by another point.
bool store_shadowed_faces_
Whether or not shadowed faces are stored, e.g., for exploration.
bool max_edge_length_dist_dependent_
flag whether or not max edge length is distance dependent.
OrganizedFastMesh()
Constructor.