CGAL 6.1 - Point Set Processing

Loading...
Searching...
No Matches
Point_set_processing_3/edges_example.cpp
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/vcm_estimate_edges.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_points.h>
#include <utility> // defines std::pair
#include <vector>
#include <fstream>
// Types
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point;
typedef Kernel::Vector_3 Vector;
// Point with normal vector stored in a std::pair.
typedef std::pair<Point, Vector> PointVectorPair;
typedef std::vector<PointVectorPair> PointList;
typedef std::array<double,6> Covariance;
int main (int , char**)
{
// Reads a polygon mesh file in points[].
std::list<PointVectorPair> points;
if(!CGAL::IO::read_points(CGAL::data_file_path("meshes/fandisk_large.off"),
std::back_inserter(points),
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())))
{
std::cerr << "Error: cannot read file data/fandisk_large.off" << std::endl;
return EXIT_FAILURE;
}
// Estimates covariance matrices per points.
double R = 0.2,
r = 0.1;
std::vector<Covariance> cov;
CGAL::First_of_pair_property_map<PointVectorPair> point_map;
CGAL::compute_vcm(points, cov, R, r,
CGAL::parameters::point_map (point_map).geom_traits (Kernel()));
// Find the points on the edges.
// Note that this step is not expensive and can be done several time to get better results
double threshold = 0.16;
std::ofstream output("points_on_edges.xyz");
int i = 0;
for(const PointVectorPair& p : points)
{
if(CGAL::vcm_is_on_feature_edge(cov[i], threshold))
output << p.first << "\n";
++i;
}
return 0;
}
CGAL::Exact_predicates_inexact_constructions_kernel
Kernel::Point_3
Kernel::Vector_3
CGAL::compute_vcm
void compute_vcm(const PointRange &points, std::vector< std::array< double, 6 > > &ccov, double offset_radius, double convolution_radius, const NamedParameters &np=parameters::default_values())
computes the Voronoi Covariance Measure (VCM) of a point cloud, a construction that can be used for n...
Definition: vcm_estimate_normals.h:262
CGAL::vcm_is_on_feature_edge
bool vcm_is_on_feature_edge(std::array< FT, 6 > &cov, double threshold, VCMTraits)
determines if a point is on a sharp feature edge from a point set for which the Voronoi covariance Me...
Definition: vcm_estimate_edges.h:47
CGAL::IO::read_points
bool read_points(const std::string &fname, PointOutputIterator output, const NamedParameters &np=parameters::default_values())
reads the point set from an input file.
Definition: read_points.h:89
Kernel
CGAL::First_of_pair_property_map