CGAL 6.1.2 - 2D Triangulations: Triangulation_2/constrained.cpp

CGAL 6.1.2 - 2D Triangulations

Loading...
Searching...
No Matches
Triangulation_2/constrained.cpp
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
#include <CGAL/draw_constrained_triangulation_2.h>
#include <cassert>
#include <iostream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Exact_predicates_tag Itag;
typedef CGAL::Constrained_Delaunay_triangulation_2<K, CGAL::Default, Itag> CDT;
typedef CDT::Point Point;
typedef CDT::Edge Edge;
int
main( )
{
CDT cdt;
std::cout << "Inserting a grid of 5x5 constraints " << std::endl;
for (int i = 1; i < 6; ++i)
cdt. insert_constraint( Point(0,i), Point(6,i));
for (int j = 1; j < 6; ++j)
cdt.insert_constraint( Point(j,0), Point(j,6));
assert(cdt.is_valid());
int count = 0;
for (const Edge& e : cdt.finite_edges())
if (cdt.is_constrained(e))
++count;
std::cout << "The number of resulting constrained edges is ";
std::cout << count << std::endl;
CGAL::draw(cdt);
return 0;
}
CGAL::Constrained_Delaunay_triangulation_2
A constrained Delaunay triangulation is a triangulation with constrained edges which tries to be as m...
Definition: Constrained_Delaunay_triangulation_2.h:96
CGAL::Constrained_Delaunay_triangulation_2::insert_constraint
void insert_constraint(Point a, Point b)
Inserts the line segment ab as a constraint in the triangulation.
CGAL::Exact_predicates_inexact_constructions_kernel
CGAL::draw
void draw(const T3 &at3, const GSOptions &gso)
CGAL::Exact_predicates_tag
Intersection tag for constrained triangulations, if the geometric traits provides exact predicates bu...
Definition: Constrained_triangulation_2.h:51