#define CGAL_AW2_DEBUG_PP
#include "output_helper.h"
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/alpha_wrap_2.h>
#include <CGAL/Multipolygon_with_holes_2.h>
#include <CGAL/Real_timer.h>
#include <CGAL/IO/WKT.h>
#include <iostream>
#include <string>
using Point_2 = K::Point_2;
using Points = std::vector<Point_2>;
using Polyline = std::vector<Point_2>;
using Polylines = std::vector<Polyline>;
int main(int argc, char** argv)
{
std::cout.precision(17);
std::cerr.precision(17);
Points pts_in;
Polylines mls_in;
Multipolygon mp_in;
std::ifstream in(filename);
{
std::cerr << "Can't read input file " << filename << std::endl;
return EXIT_FAILURE;
}
std::cout << mls_in.size() << " input polylines" << std::endl;
const double relative_alpha = (argc > 2) ? std::stod(argv[2]) : 20.;
const double relative_offset = (argc > 3) ? std::stod(argv[3]) : 300.;
for(const Polyline& ls : mls_in) {
for(const Point_2& pt : ls) {
bbox += pt.bbox();
}
}
const double alpha = diag_length / relative_alpha;
const double offset = diag_length / relative_offset;
std::cout << "absolute alpha = " << alpha << " absolute offset = " << offset << std::endl;
CGAL::Real_timer t;
t.start();
Multipolygon wrap;
t.stop();
std::cout << "Result: " << wrap.polygons_with_holes().size() << " polygons" << std::endl;
std::cout << "Took " << t.time() << " s." << std::endl;
const std::string output_name = generate_output_name(filename, relative_alpha, relative_offset);
std::cout << "Writing to " << output_name << std::endl;
std::ofstream out(output_name);
out.precision(std::numeric_limits<double>::max_digits10);
std::cout << "Done." << std::endl;
return EXIT_SUCCESS;
}
void alpha_wrap_2(const PointRange &points, const FaceRange &faces, const double alpha, const double offset, MultipolygonWithHoles &alpha_wrap, const InputNamedParameters &np)
computes a watertight, 1-manifold, simple multipolygon that strictly contains an input indexed face s...
Definition: alpha_wrap_2.h:153
std::ostream & write_multi_polygon_WKT(std::ostream &out, MultiPolygon &polygons)
bool read_WKT(std::istream &is, MultiPoint &points, MultiLineString &polylines, MultiPolygon &polygons)
std::string data_file_path(const std::string &filename)