CGAL 6.1.1 - Point Set Processing

Loading...
Searching...
No Matches
Point_set_processing_3/poisson_eliminate_example.cpp
#include <vector>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/poisson_eliminate.h>
#include <CGAL/IO/write_points.h>
#include <CGAL/IO/read_points.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::Point_3 Point_3;
void sampling(const std::string& filename, double size_factor = 0.2) {
if (size_factor >= 1.0) {
std::cout << "usage poisson_eliminate_example filename size_factor" << std::endl
<< "0 < size_factor < 1" << std::endl;
return;
}
std::vector<Point_3> points;
if (!CGAL::IO::read_points(
filename,
std::back_inserter(points))) {
std::cerr << "Error: cannot read file!" << std::endl;
return;
}
std::size_t target_size = std::size_t(points.size() * size_factor);
std::vector<Point_3> output;
output.reserve(target_size);
CGAL::poisson_eliminate(points, target_size, std::back_inserter(output));
CGAL::IO::write_points("out.xyz", output, CGAL::parameters::stream_precision(17));
}
int main(int argc, char* argv[])
{
if (argc < 2)
sampling(CGAL::data_file_path("points_3/radar.xyz"));
else if (argc < 3)
sampling(argv[1]);
else if (argc < 4)
sampling(argv[1], std::atof(argv[2]));
return 0;
}
CGAL::poisson_eliminate
void poisson_eliminate(const PointRange &points, std::size_t number_of_points, OutputIterator output, const NamedParameters &np=parameters::default_values())
performs Poisson disk elimination with a desired output size.
Definition: poisson_eliminate.h:279
CGAL::IO::write_points
bool write_points(const std::string &fname, const PointRange &points, const NamedParameters &np=parameters::default_values(),)
writes the range of points with properties to a file.
Definition: write_points.h:92
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
CGAL::Simple_cartesian