Provide easier way to recognize contours in the mesh (#28)

This commit is contained in:
a5rGithub
2022-09-08 23:50:13 +02:00
committed by GitHub
parent a3495f53ec
commit f70be6a937
2 changed files with 26 additions and 5 deletions
+7
View File
@@ -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>
+19 -5
View File
@@ -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);
}
}