CGAL 6.0.1 - 2D Arrangements
Loading...
Searching...
No Matches
Arrangement_on_surface_2/generic_curve_data.cpp
// Associating a name attribute with segments using the generic curve-data
// traits.
#include <CGAL/basic.h>
#include <CGAL/Arr_curve_data_traits_2.h>
#include "arr_polylines.h"
using Name = std::string; // The name-field type.
struct Merge_names {
Name operator() (const Name& s1, const Name& s2) const
{ return (s1 + " " + s2); }
};
using Ex_polyline = Ex_traits::Curve_2;
using Ex_x_monotone_polyline = Ex_traits::X_monotone_curve_2;
using Ex_arrangement = CGAL::Arrangement_2<Ex_traits>;
int main() {
// Construct an arrangement of four polylines named A--D.
Ex_traits traits;
Ex_arrangement arr(&traits);
auto ctr_curve = traits.construct_curve_2_object();
Point pts1[5] =
{Point(0, 0), Point(2, 4), Point(3, 3), Point(4, 4), Point(6, 0)};
insert(arr, Ex_polyline(ctr_curve(pts1, pts1 + 5), "A"));
Point pts2[3] = {Point(1, 5), Point(3, 3), Point(5, 5)};
insert(arr, Ex_polyline(ctr_curve(pts2, pts2 + 3), "B"));
Point pts3[4] = {Point(1, 0), Point(2, 2), Point(4, 2), Point(5, 0)};
insert(arr, Ex_polyline(ctr_curve(pts3, pts3 + 4), "C"));
Point pts4[2] = {Point(0, 2), Point(6, 2)};
insert(arr, Ex_polyline(ctr_curve(pts4, pts4 + 2), "D"));
// Print all edges that correspond to an overlapping polyline.
std::cout << "The overlapping subcurves:\n";
for (auto eit = arr.edges_begin(); eit != arr.edges_end(); ++eit) {
if (eit->curve().data().length() > 1) {
std::cout << " [" << eit->curve() << "] "
<< "named: " << eit->curve().data() << std::endl;
// Modify the curve associated with the edge.
arr.modify_edge(eit, Ex_x_monotone_polyline(eit->curve(), "overlap"));
}
}
return 0;
}
The class Arr_curve_data_traits_2 is a model of the ArrangementTraits_2 concept and serves as a decor...
Definition: Arr_curve_data_traits_2.h:55
Definition: Arrangement_2.h:57
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,...