## Constraint Edges

When you triangulate the vertices of a polygon then its edges are not necessarily contained in the resulting Delaunay triangulation. But you can enforce Constraint Edges and the result is a Constrained Delaunay Triangulation then. It’s easy, see *example3.cpp (contained in the download)*, the code is described below.

## Create a Delaunay triangulation

std::vector<Point2> vInputPoints; vInputPoints.push_back(Point2(-100,-100)); vInputPoints.push_back(Point2(+100,+100)); vInputPoints.push_back(Point2(-50,-70)); vInputPoints.push_back(Point2(-50,-30)); vInputPoints.push_back(Point2(50,70)); vInputPoints.push_back(Point2(50,30)); Fade_2D dt; dt.insert(vInputPoints); dt.show("example3_noConstraints.ps");

## Constrained Delaunay: Insert Constraint Edges

And now assume that we want to enforce an edge from the lower left to the upper right corner. There are two different insertion strategies:

**CIS_CONSTRAINED_DELAUNAY**inserts a constraint edge**without**subdivision. More precisely subdivision takes place in only two cases: When the constraint edge hits an existing vertex or when it intersects another constraint edge. This is the recommended way to insert constraint edges.

**CIS_CONFORMING_DELAUNAY**subdivides a constraint edge such that it appears naturally as part of the Delaunay triangulation where every triangle keeps its empty circle property. This insertion strategy creates more (but better shaped) triangles. Be careful: Narrow geometric settings may enforce many tiny triangles and even prevent complete insertion when subsegments get too small.

## Code for Constrained Delaunay

We prepare a vector of one or more constraint segments and call createConstraint() using the constraint insertion strategy CIS_CONSTRAINED_DELAUNAY.

std::vector<Segment2> vSegments; vSegments.push_back(Segment2(vInputPoints[0],vInputPoints[1])); ConstraintGraph2* pCG; pCG=dt.createConstraint(vSegments,CIS_CONSTRAINED_DELAUNAY);

## Code for Conforming Delaunay

The same again, but with the constraint insertion strategy CIS_CONFORMING_DELAUNAY. Only for the constraint insertion strategy CIS_CONFORMING_DELAUNAY we need to call applyConstraintsAndZones() to establish the constraint graph in the triangulation. Subsequent changes in the triangulation may make the conforming constraints disappear and for efficiency reasons Fade does not automatically re-establish them. You must call applyConstraintsAndZones() again at the time you need the conforming constraints in your triangulation.

std::vector<Segment2> vSegments; vSegments.push_back(Segment2(vInputPoints[0],vInputPoints[1])); ConstraintGraph2* pCG; pCG=dt.createConstraint(vSegments,CIS_CONFORMING_DELAUNAY); dt.applyConstraintsAndZones();

Now that you know how to create constraint graphs you are ready use polygonal zones.

## 2 Comments