I'm working on a visualizer in WPF which has a function to display a cutting plane through a 3-D shape. For example, a 3-d geometry like this:
... is cut with a plane. After cutting, the algorithm identifies all the unique outlines along the cutting plane and populates a list of line segments, in either CW or CCW winding order. Any simple polygon is easy to triangulate and render using the Cutting Ears algorithm, like this:
Given an input of the triangulation on the right, and the inner polyline visible on the plane surface on the left, is there an algorithm which can reconfigure the triangulation to construct a hole outlined by the polyline?
If there are algorithms already rolled in C# or another CLR language, I'd love to learn about them. I'm using the Point3D lists called for by WPF to describe MeshGeometry3D triangle meshes, but I can obviously fill any data structure if needed or spin my own class by studying other language code or pseudocode.
EDIT: See the accepted answer; I'm making use of the C# implementation of Poly2Tri, a Constrained Delaunay Triangulation. However, (images not to scale) the Poly2Tri algorithm (center) failed with a 780-segment polyline, while Cutting Ears (right) did not, until I stripped the inputs of their precision, supplying single precision values upcast as doubles instead of doubles. It now produces a different triangulation than Cutting Ears but respects the boundaries of the outer polyline.