diff --git a/src/Triangle/Geometry/IPolygon.cs b/src/Triangle/Geometry/IPolygon.cs
index 0a4c834..e07daf5 100644
--- a/src/Triangle/Geometry/IPolygon.cs
+++ b/src/Triangle/Geometry/IPolygon.cs
@@ -69,6 +69,13 @@ namespace TriangleNet.Geometry
/// The index of the segment endpoint to add to the points list (must be 0 or 1).
void Add(ISegment segment, int index);
+ ///
+ /// Add a contour to the polygon.
+ ///
+ /// The contour to insert.
+ /// label to ease finding contours in the created mesh.
+ void Add(Contour contour, int regionlabel );
+
///
/// Add a contour to the polygon.
///
diff --git a/src/Triangle/Geometry/Polygon.cs b/src/Triangle/Geometry/Polygon.cs
index 99a6c97..87d5fd9 100644
--- a/src/Triangle/Geometry/Polygon.cs
+++ b/src/Triangle/Geometry/Polygon.cs
@@ -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());
+ }
+
+ ///
+ 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);
+ }
+
///
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);
}
}
///
public void Add(Contour contour, Point hole)
{
- points.AddRange(contour.Points);
- segments.AddRange(contour.GetSegments());
-
+ AddContourPointsAndSegments(contour);
holes.Add(hole);
}
}