43 #include <pcl/surface/reconstruction.h>
47 #include <Eigen/Geometry>
62 isVisible (
const Eigen::Vector2f &X,
const Eigen::Vector2f &S1,
const Eigen::Vector2f &S2,
63 const Eigen::Vector2f &R = Eigen::Vector2f::Zero ())
65 double a0 = S1[1] - S2[1];
66 double b0 = S2[0] - S1[0];
67 double c0 = S1[0]*S2[1] - S2[0]*S1[1];
71 if (R != Eigen::Vector2f::Zero())
75 c1 = R[0]*X[1] - X[0]*R[1];
77 double div = a0*b1 - b0*a1;
78 double x = (b0*c1 - b1*c0) / div;
79 double y = (a1*c0 - a0*c1) / div;
81 bool intersection_outside_XR;
82 if (R == Eigen::Vector2f::Zero())
85 intersection_outside_XR = (x <= 0) || (x >= X[0]);
87 intersection_outside_XR = (x >= 0) || (x <= X[0]);
89 intersection_outside_XR = (y <= 0) || (y >= X[1]);
91 intersection_outside_XR = (y >= 0) || (y <= X[1]);
93 intersection_outside_XR =
true;
98 intersection_outside_XR = (x <= R[0]) || (x >= X[0]);
100 intersection_outside_XR = (x >= R[0]) || (x <= X[0]);
101 else if (X[1] > R[1])
102 intersection_outside_XR = (y <= R[1]) || (y >= X[1]);
103 else if (X[1] < R[1])
104 intersection_outside_XR = (y >= R[1]) || (y <= X[1]);
106 intersection_outside_XR =
true;
108 if (intersection_outside_XR)
111 return (x <= S2[0]) || (x >= S1[0]);
113 return (x >= S2[0]) || (x <= S1[0]);
115 return (y <= S2[1]) || (y >= S1[1]);
117 return (y >= S2[1]) || (y <= S1[1]);
128 template <
typename Po
intInT>
132 using Ptr = shared_ptr<GreedyProjectionTriangulation<PointInT> >;
133 using ConstPtr = shared_ptr<const GreedyProjectionTriangulation<PointInT> >;
245 inline std::vector<int>
251 inline std::vector<int>
301 doubleEdge () =
default;
303 Eigen::Vector2f first;
304 Eigen::Vector2f second;
312 std::vector<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f> > coords_{};
315 std::vector<nnAngle> angles_{};
319 std::vector<int> state_{};
327 std::vector<int> part_{};
329 std::vector<int> fringe_queue_{};
332 bool is_current_free_{
false};
336 bool prev_is_ffn_{
false};
338 bool prev_is_sfn_{
false};
340 bool next_is_ffn_{
false};
342 bool next_is_sfn_{
false};
344 bool changed_1st_fn_{
false};
346 bool changed_2nd_fn_{
false};
353 bool already_connected_{
false};
356 Eigen::Vector3f proj_qp_;
362 Eigen::Vector2f uvn_ffn_;
364 Eigen::Vector2f uvn_sfn_;
366 Eigen::Vector2f uvn_next_ffn_;
368 Eigen::Vector2f uvn_next_sfn_;
371 Eigen::Vector3f tmp_;
383 performReconstruction (std::vector<pcl::Vertices> &polygons)
override;
389 reconstructPolygons (std::vector<pcl::Vertices> &polygons);
393 getClassName ()
const override {
return (
"GreedyProjectionTriangulation"); }
406 connectPoint (std::vector<pcl::Vertices> &polygons,
410 const Eigen::Vector2f &uvn_current,
411 const Eigen::Vector2f &uvn_prev,
412 const Eigen::Vector2f &uvn_next);
419 closeTriangle (std::vector<pcl::Vertices> &polygons);
424 std::vector<std::vector<std::size_t> >
440 const Eigen::Vector3f pv = p.getVector3fMap ();
441 if (p.getNormalVector3fMap ().dot (
462 polygons.push_back (triangle_);
470 addFringePoint (
int v,
int s)
474 fringe_queue_.push_back(v);
483 nnAngleSortAsc (
const nnAngle& a1,
const nnAngle& a2)
485 if (a1.visible == a2.visible)
486 return (a1.angle < a2.angle);
493 #ifdef PCL_NO_PRECOMPILE
494 #include <pcl/surface/impl/gp3.hpp>
GreedyProjectionTriangulation is an implementation of a greedy triangulation algorithm for 3D points ...
void setSearchRadius(double radius)
Set the sphere radius that is to be used for determining the k-nearest neighbors used for triangulati...
double eps_angle_
Maximum surface angle.
double maximum_angle_
The maximum angle for the triangles.
double getMaximumAngle() const
Get the parameter for distance based weighting of neighbors.
int getMaximumNearestNeighbors() const
Get the maximum number of nearest neighbors to be searched for.
void setConsistentVertexOrdering(bool consistent_ordering)
Set the flag to order the resulting triangle vertices consistently (positive direction around normal)...
typename PointCloudIn::ConstPtr PointCloudInConstPtr
bool getNormalConsistency() const
Get the flag for consistently oriented normals.
pcl::Indices getFFN() const
Get the ffn list.
bool consistent_ordering_
Set this to true if the output triangle vertices should be consistently oriented.
GreedyProjectionTriangulation()=default
Empty constructor.
shared_ptr< const GreedyProjectionTriangulation< PointInT > > ConstPtr
bool getConsistentVertexOrdering() const
Get the flag signaling consistently ordered triangle vertices.
int nnn_
The maximum number of nearest neighbors accepted by searching.
double getMaximumSurfaceAngle() const
Get the maximum surface angle.
pcl::Indices getSFN() const
Get the sfn list.
typename PointCloudIn::Ptr PointCloudInPtr
double mu_
The nearest neighbor distance multiplier to obtain the final search radius.
double search_radius_
The nearest neighbors search radius for each point and the maximum edge length.
void setNormalConsistency(bool consistent)
Set the flag if the input normals are oriented consistently.
void setMaximumNearestNeighbors(int nnn)
Set the maximum number of nearest neighbors to be searched for.
bool consistent_
Set this to true if the normals of the input are consistently oriented.
std::vector< int > getPartIDs() const
Get the ID of each point after reconstruction.
double getSearchRadius() const
Get the sphere radius used for determining the k-nearest neighbors.
double getMu() const
Get the nearest neighbor distance multiplier.
double getMinimumAngle() const
Get the parameter for distance based weighting of neighbors.
void setMinimumAngle(double minimum_angle)
Set the minimum angle each triangle should have.
double minimum_angle_
The preferred minimum angle for the triangles.
shared_ptr< GreedyProjectionTriangulation< PointInT > > Ptr
void setMaximumAngle(double maximum_angle)
Set the maximum angle each triangle can have.
void setMu(double mu)
Set the multiplier of the nearest neighbor distance to obtain the final search radius for each point ...
std::vector< int > getPointStates() const
Get the state of each point after reconstruction.
void setMaximumSurfaceAngle(double eps_angle)
Don't consider points for triangulation if their normal deviates more than this value from the query ...
MeshConstruction represents a base surface reconstruction class.
PointCloudConstPtr input_
The input point cloud dataset.
IndicesPtr indices_
A pointer to the vector of point indices to use.
shared_ptr< PointCloud< PointInT > > Ptr
shared_ptr< const PointCloud< PointInT > > ConstPtr
bool isVisible(const Eigen::Vector2f &X, const Eigen::Vector2f &S1, const Eigen::Vector2f &S2, const Eigen::Vector2f &R=Eigen::Vector2f::Zero())
Returns if a point X is visible from point R (or the origin) when taking into account the segment bet...
detail::int_type_t< detail::index_type_size, detail::index_type_signed > index_t
Type used for an index in PCL.
IndicesAllocator<> Indices
Type used for indices in PCL.
Describes a set of vertices in a polygon mesh, by basically storing an array of indices.