#include <fstream>
#include <CGAL/basic.h>
#include <CGAL/Arr_extended_dcel.h>
#include <CGAL/IO/Arr_iostream.h>
#include <CGAL/IO/Arr_text_formatter.h>
#include "arr_exact_construction_segments.h"
enum Color {BLUE, RED, WHITE};
std::ostream&
operator<<(std::ostream& os,
const Color& color) {
switch (color) {
case BLUE: os << "BLUE"; break;
case RED: os << "RED"; break;
case WHITE: os << "WHITE"; break;
default: os << "ERROR!";
}
return os;
}
std::istream&
operator>>(std::istream& is, Color& color) {
std::string str;
is >> str;
if (str == "BLUE") color = BLUE;
else if (str == "RED") color = RED;
else if (str == "WHITE") color = WHITE;
return is;
}
int main() {
Ext_arrangement arr;
Segment s1(Point(4, 1), Point(7, 6));
Segment s2(Point(1, 6), Point(7, 6));
Segment s3(Point(4, 1), Point(1, 6));
Segment s4(Point(1, 3), Point(7, 3));
Segment s5(Point(1, 3), Point(4, 8));
Segment s6(Point(4, 8), Point(7, 3));
for (auto vit = arr.vertices_begin(); vit != arr.vertices_end(); ++vit) {
auto degree = vit->degree();
if (degree == 0) vit->set_data(BLUE);
else if (degree <= 2) vit->set_data(RED);
else vit->set_data(WHITE);
}
for (auto eit = arr.edges_begin(); eit != arr.edges_end(); ++eit) {
auto flag = (eit->source()->point() == eit->curve().source());
eit->set_data(flag);
eit->twin()->set_data(! flag);
}
int boundary_size;
for (auto fit = arr.faces_begin(); fit != arr.faces_end(); ++fit) {
boundary_size = 0;
if (! fit->is_unbounded()) {
auto curr = fit->outer_ccb();
do ++boundary_size;
while (++curr != fit->outer_ccb());
}
fit->set_data(boundary_size);
}
std::ofstream out_file("arr_ex_dcel_io.dat");
Formatter formatter;
out_file.close();
Ext_arrangement arr2;
std::ifstream in_file("arr_ex_dcel_io.dat");
in_file.close();
std::cout << "The arrangement vertices:\n";
for (auto vit = arr2.vertices_begin(); vit != arr2.vertices_end(); ++vit)
std::cout << '(' << vit->point() << ") - " << vit->data() << std::endl;
return 0;
}
Arr_extended_dcel_text_formatter defines the format of an arrangement in an input or output stream (t...
Definition: Arr_text_formatter.h:29
The Arr_extended_dcel class-template extends the topological-features of the DCEL namely the vertex,...
Definition: Arr_extended_dcel.h:46
Definition: Arrangement_2.h:57
Arrangement_2< Traits, Dcel >::Halfedge_handle insert_non_intersecting_curve(Arrangement_2< Traits, Dcel > &arr, const typename Traits::X_monotone_curve_2 &xc, const PointLocation &pl=walk_pl)
Inserts a given -monotone curve into a given arrangement, where the interior of the given curve is di...
void insert(Arrangement_2< Traits, Dcel > &arr, const Curve &c, const PointLocation &pl=walk_pl)
The function insert inserts one or more curves or -monotone curves into a given arrangement,...
std::istream & read(Arrangement_2< Traits, Dcel > &arr, std::istream &is, Formatter &formatter)
Reads the arrangement object arr from the given input stream is using a specific input format defined...
std::ostream & write(const Arrangement_2< Traits, Dcel > &arr, std::ostream &os, Formatter &formatter)
Writes the arrangement object arr into the given output stream os using a specific output format defi...
std::ostream & operator<<(std::ostream &out, const Polyhedron_3< Traits > &P)
std::istream & operator>>(std::istream &in, Polyhedron_3< Traits > &P)