Provide easier way to recognize contours in the mesh (#28)
This commit is contained in:
@@ -69,6 +69,13 @@ namespace TriangleNet.Geometry
|
||||
/// <param name="index">The index of the segment endpoint to add to the points list (must be 0 or 1).</param>
|
||||
void Add(ISegment segment, int index);
|
||||
|
||||
/// <summary>
|
||||
/// Add a contour to the polygon.
|
||||
/// </summary>
|
||||
/// <param name="contour">The contour to insert.</param>
|
||||
/// <param name="regionlabel">label to ease finding contours in the created mesh.</param>
|
||||
void Add(Contour contour, int regionlabel );
|
||||
|
||||
/// <summary>
|
||||
/// Add a contour to the polygon.
|
||||
/// </summary>
|
||||
|
||||
@@ -111,6 +111,23 @@ namespace TriangleNet.Geometry
|
||||
points.Add(segment.GetVertex(index));
|
||||
}
|
||||
|
||||
private void AddContourPointsAndSegments(Contour contour)
|
||||
{
|
||||
points.AddRange(contour.Points);
|
||||
segments.AddRange(contour.GetSegments());
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Add(Contour contour, int regionlabel )
|
||||
{
|
||||
if (regionlabel != 0)
|
||||
{
|
||||
var interiorPoint = contour.FindInteriorPoint();
|
||||
Regions.Add(new RegionPointer(interiorPoint.X, interiorPoint.Y, regionlabel));
|
||||
}
|
||||
AddContourPointsAndSegments(contour);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Add(Contour contour, bool hole = false)
|
||||
{
|
||||
@@ -120,17 +137,14 @@ namespace TriangleNet.Geometry
|
||||
}
|
||||
else
|
||||
{
|
||||
points.AddRange(contour.Points);
|
||||
segments.AddRange(contour.GetSegments());
|
||||
AddContourPointsAndSegments(contour);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Add(Contour contour, Point hole)
|
||||
{
|
||||
points.AddRange(contour.Points);
|
||||
segments.AddRange(contour.GetSegments());
|
||||
|
||||
AddContourPointsAndSegments(contour);
|
||||
holes.Add(hole);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user