64 const Point & p = it.get_current_vertex();
93 out <<
"site_index,site_x,site_y,vertex_count,wkt\n";
95 for (
size_t i = 0; i < cells.
size(); ++i)
97 const auto & c = cells(i);
98 out << c.site_index <<
","
101 << c.polygon.size() <<
",\"";
114 Point(0, 0),
Point(6, 0),
Point(8, 4),
Point(5, 8),
Point(1, 7),
129 cout << fixed << setprecision(4);
130 cout <<
"Voronoi clipped cells (site-indexed)\n";
131 cout <<
"===================================\n";
132 cout <<
"Sites: " <<
vor.sites.size() <<
"\n";
133 cout <<
"Cells: " << cells.
size() <<
"\n\n";
138 for (
size_t i = 0; i < cells.
size(); ++i)
140 const auto & c = cells(i);
141 cout <<
"Cell #" << c.site_index
144 <<
" vertices=" << c.polygon.size() <<
"\n";
146 assert(c.polygon.is_closed());
147 assert(c.polygon.size() >= 3);
151 const char * path = (
argc > 1) ?
argv[1] :
"voronoi_clipped_cells_output.csv";
155 cerr <<
"Cannot open output file: " << path <<
"\n";
159 file << fixed << setprecision(8);
163 cout <<
"\nCSV/WKT exported to: " << path <<
"\n";
164 cout <<
"Format: site_index, site_x, site_y, vertex_count, WKT polygon\n";
Simple dynamic array with automatic resizing and functional operations.
constexpr size_t size() const noexcept
Return the number of elements stored in the stack.
bool has_curr() const noexcept
Return true if the iterator has current item.
Exact point-in-polygon classification via winding number.
Represents a point with rectangular coordinates in a 2D plane.
const Geom_Number & get_x() const noexcept
Gets the x-coordinate value.
const Geom_Number & get_y() const noexcept
Gets the y-coordinate value.
A general (irregular) 2D polygon defined by a sequence of vertices.
void add_vertex(const Point &point)
Add a vertex to the polygon.
Voronoi diagram derived as the dual of a Delaunay triangulation.
Computational geometry algorithms.
Main namespace for Aleph-w library functions.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
double geom_number_to_double(const Geom_Number &n)
Converts a Geom_Number to its double precision representation.
Iterator over the vertices of a polygon.
static void export_cells_csv(ostream &out, const Array< VoronoiDiagramFromDelaunay::ClippedCell > &cells)
static void write_polygon_wkt(ostream &out, const Polygon &poly)