private void FormSkeleton(InputGeometry input)
{
Vertex endpoint1, endpoint2;
int end1, end2;
int boundmarker;
this.insegments = 0;
if (behavior.Poly)
{
// If the input vertices are collinear, there is no triangulation,
// so don't try to insert segments.
if (triangles.Count == 0)
{
return;
}
// If segments are to be inserted, compute a mapping
// from vertices to triangles.
if (input.HasSegments)
{
MakeVertexMap();
}
boundmarker = 0;
// Read and insert the segments.
foreach (var seg in input.segments)
{
this.insegments++;
end1 = seg.P0;
end2 = seg.P1;
boundmarker = seg.Boundary;
if ((end1 < 0) || (end1 >= invertices))
{
if (Behavior.Verbose)
{
logger.Warning("Invalid first endpoint of segment.", "Mesh.FormSkeleton().1");
}
}
else if ((end2 < 0) || (end2 >= invertices))
{
if (Behavior.Verbose)
{
logger.Warning("Invalid second endpoint of segment.", "Mesh.FormSkeleton().2");
}
}
else
{
// TODO: Is using the vertex ID reliable???
// It should be. The ID gets appropriately set in TransferNodes().
// Find the vertices numbered 'end1' and 'end2'.
endpoint1 = vertices[end1];
endpoint2 = vertices[end2];
if ((endpoint1.x == endpoint2.x) && (endpoint1.y == endpoint2.y))
{
if (Behavior.Verbose)
{
logger.Warning("Endpoints of segments are coincident.", "Mesh.FormSkeleton()");
}
}
else
{
InsertSegment(endpoint1, endpoint2, boundmarker);
}
}
}
}
if (behavior.Convex || !behavior.Poly)
{
// Enclose the convex hull with subsegments.
MarkHull();
}
}