Constraint Edges – Example3

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, the code is described below.

Constrained Delaunay Triangulation

Constrained Delaunay Triangulation


Create a Delaunay triangulation

To start, we create and draw a simple Delaunay triangulation without constraint edges:

	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");
Delaunay Triangulation without Constraint Edges

Delaunay Triangulation without Constraint Edges


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.
Constrained Delaunay

Constrained Delaunay


  • 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.
Conforming Delaunay

Conforming Delaunay


Be aware that exact intersection points may be unrepresentable by IEEE754 double precision coordinates and thus rounding can be involved.

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.

Spread the word. Share this post!

Leave A Reply

Your email address will not be published. Required fields are marked *

*

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close