Implement Region.GetContourCopies
This commit is contained in:
parent
6744f5e967
commit
75d12d6a5a
3 changed files with 21 additions and 22 deletions
|
@ -111,7 +111,12 @@ namespace Boprs
|
|||
|
||||
BooleanOperation bopr = new BooleanOperation(subject, clip, type);
|
||||
|
||||
bopr.Result.Draw();
|
||||
List <Contour> contours = bopr.Result.GetContourCopies();
|
||||
|
||||
foreach (Contour contour in contours)
|
||||
{
|
||||
contour.Draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
13
Contour.cs
13
Contour.cs
|
@ -20,17 +20,17 @@ namespace Boprs
|
|||
/// <summary>
|
||||
/// Simple closed polygon.
|
||||
/// </summary>
|
||||
public class Contour
|
||||
public class Contour : ICloneable
|
||||
{
|
||||
/// <summary>
|
||||
/// Depth of the contour within the region.
|
||||
/// </summary>
|
||||
internal int ContourDepth { get; set; }
|
||||
public object Clone()
|
||||
{
|
||||
return new Contour() { Vertices = new List<Point2d>(Vertices) };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Vertices of the contour.
|
||||
/// </summary>
|
||||
public List<Point2d> Vertices { get; }
|
||||
public List<Point2d> Vertices { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Are the vertices of the contour arranged in clockwise manner?
|
||||
|
@ -70,7 +70,6 @@ namespace Boprs
|
|||
/// </summary>
|
||||
public Contour()
|
||||
{
|
||||
ContourDepth = 0;
|
||||
Vertices = new List<Point2d>();
|
||||
}
|
||||
|
||||
|
|
23
Region.cs
23
Region.cs
|
@ -173,13 +173,11 @@ namespace Boprs
|
|||
SweepVertex acVx = vertices[i];
|
||||
bool shouldBeCW = !acVx.Edge.TransitionInside;
|
||||
|
||||
Point2d target = acVx.Point;
|
||||
|
||||
|
||||
// Traverse connected edges, and mark taversed vertices as processed,
|
||||
// until we loop back to the first discovered vertex on the contour.
|
||||
int pos = i;
|
||||
processed[i] = true;
|
||||
Point2d target = acVx.Point;
|
||||
contour.Vertices.Add(vertices[pos].Point);
|
||||
acVx.Edge.ParentContour = contour;
|
||||
while (!Utils.DoubleEquals(vertices[pos].OtherVertex().Point.GetDistanceTo(target), 0))
|
||||
|
@ -226,7 +224,14 @@ namespace Boprs
|
|||
/// <returns>List of copies of the regions contours.</returns>
|
||||
public List<Contour> GetContourCopies()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
List<Contour> copies = new List<Contour>();
|
||||
|
||||
foreach (Contour contour in Contours)
|
||||
{
|
||||
copies.Add((Contour)contour.Clone());
|
||||
}
|
||||
|
||||
return copies;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -253,15 +258,5 @@ namespace Boprs
|
|||
|
||||
return region;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
internal void Draw()
|
||||
{
|
||||
foreach (Contour contour in Contours)
|
||||
{
|
||||
contour.Draw();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue