diff --git a/src/Shaper2D/BezierLineSegment.cs b/src/Shaper2D/BezierLineSegment.cs
index 6caa79e..6633d98 100644
--- a/src/Shaper2D/BezierLineSegment.cs
+++ b/src/Shaper2D/BezierLineSegment.cs
@@ -51,7 +51,6 @@ namespace Shaper2D
: this(new[] { start, controlPoint1, controlPoint2, end }.Merge(additionalPoints))
{
}
-
///
/// Returns the current a simple linear path.
diff --git a/src/Shaper2D/Helpers/ArrayExtensions.cs b/src/Shaper2D/Helpers/ArrayExtensions.cs
index 1114084..0869fef 100644
--- a/src/Shaper2D/Helpers/ArrayExtensions.cs
+++ b/src/Shaper2D/Helpers/ArrayExtensions.cs
@@ -1,24 +1,41 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
+//
+// Copyright (c) Scott Williams and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
namespace Shaper2D
{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+
+ ///
+ /// Extensions on arrays.
+ ///
internal static class ArrayExtensions
{
+ ///
+ /// Merges the specified source2.
+ ///
+ /// the type of the array
+ /// The source1.
+ /// The source2.
+ /// the Merged arrays
public static T[] Merge(this T[] source1, T[] source2)
{
if (source2 == null)
{
return source1;
}
+
var target = new T[source1.Length + source2.Length];
for (var i = 0; i < source1.Length; i++)
{
target[i] = source1[i];
}
+
for (var i = 0; i < source2.Length; i++)
{
target[i + source1.Length] = source2[i];
diff --git a/src/Shaper2D/PolygonClipper/Clipper.cs b/src/Shaper2D/PolygonClipper/Clipper.cs
index 9dbec3d..d7ae939 100644
--- a/src/Shaper2D/PolygonClipper/Clipper.cs
+++ b/src/Shaper2D/PolygonClipper/Clipper.cs
@@ -41,12 +41,11 @@ namespace Shaper2D.PolygonClipper
///
/// The path.
/// Type of the poly.
- ///
public void AddPaths(IEnumerable path, PolyType polyType)
{
foreach (var p in path)
{
- AddPath(p, polyType);
+ this.AddPath(p, polyType);
}
}
@@ -55,12 +54,11 @@ namespace Shaper2D.PolygonClipper
///
/// The path.
/// Type of the poly.
- ///
public void AddPaths(IEnumerable path, PolyType polyType)
{
foreach (var p in path)
{
- AddPath(p, polyType);
+ this.AddPath(p, polyType);
}
}
@@ -69,7 +67,6 @@ namespace Shaper2D.PolygonClipper
///
/// The path.
/// Type of the poly.
- ///
public void AddPath(IShape path, PolyType polyType)
{
if (path is IPath)
@@ -297,48 +294,15 @@ namespace Shaper2D.PolygonClipper
return true;
}
- private static List ExtractOutlines(PolyNode tree)
- {
- var result = new List();
- ExtractOutlines(tree, result);
- return result;
-
- }
-
- private static void ExtractOutlines(PolyNode tree, List shapes)
- {
- if (tree.Contour.Any())
- {
- // if the source path is set then we clipper retained the full path intact thus we can freely
- // use it and get any shape optimisations that are availible.
- if (tree.SourcePath != null)
- {
- shapes.Add((IShape)tree.SourcePath);
- }
- else
- {
- Polygon polygon = new Polygon(new LinearLineSegment(tree.Contour.Select(x => new Point(x)).ToArray()));
-
- shapes.Add(polygon);
- }
- }
-
- foreach (PolyNode c in tree.Children)
- {
- ExtractOutlines(c, shapes);
- }
- }
-
///
/// Executes the specified clip type.
///
///
- /// Returns the containing the converted polygons.
+ /// Returns the array containing the converted polygons.
///
public IShape[] Execute()
{
PolyTree polytree = new PolyTree();
-
bool succeeded = this.ExecuteInternal();
// build the return polygons ...
@@ -365,6 +329,37 @@ namespace Shaper2D.PolygonClipper
return edge.Bot.X + Round(edge.Dx * (currentY - edge.Bot.Y));
}
+ private static List ExtractOutlines(PolyNode tree)
+ {
+ var result = new List();
+ ExtractOutlines(tree, result);
+ return result;
+ }
+
+ private static void ExtractOutlines(PolyNode tree, List shapes)
+ {
+ if (tree.Contour.Any())
+ {
+ // if the source path is set then we clipper retained the full path intact thus we can freely
+ // use it and get any shape optimisations that are availible.
+ if (tree.SourcePath != null)
+ {
+ shapes.Add((IShape)tree.SourcePath);
+ }
+ else
+ {
+ Polygon polygon = new Polygon(new LinearLineSegment(tree.Contour.Select(x => new Point(x)).ToArray()));
+
+ shapes.Add(polygon);
+ }
+ }
+
+ foreach (PolyNode c in tree.Children)
+ {
+ ExtractOutlines(c, shapes);
+ }
+ }
+
private static double DistanceFromLineSqrd(Vector2 pt, Vector2 ln1, Vector2 ln2)
{
// The equation of a line in general form (Ax + By + C = 0)
@@ -3084,9 +3079,7 @@ namespace Shaper2D.PolygonClipper
// outRec1 contains outRec2 ...
outRec2.IsHole = !outRec1.IsHole;
outRec2.FirstLeft = outRec1;
-
this.FixupFirstLefts2(outRec2, outRec1);
-
}
else if (Poly2ContainsPoly1(outRec1.Pts, outRec2.Pts))
{
@@ -3095,19 +3088,14 @@ namespace Shaper2D.PolygonClipper
outRec1.IsHole = !outRec2.IsHole;
outRec2.FirstLeft = outRec1.FirstLeft;
outRec1.FirstLeft = outRec2;
-
-
this.FixupFirstLefts2(outRec1, outRec2);
-
}
else
{
// the 2 polygons are completely separate ...
outRec2.IsHole = outRec1.IsHole;
outRec2.FirstLeft = outRec1.FirstLeft;
-
this.FixupFirstLefts1(outRec1, outRec2);
-
}
}
else
@@ -3126,7 +3114,6 @@ namespace Shaper2D.PolygonClipper
outRec2.FirstLeft = outRec1;
this.FixupFirstLefts3(outRec2, outRec1);
-
}
}
}
@@ -3188,9 +3175,7 @@ namespace Shaper2D.PolygonClipper
outrec.IsHole = !outrec2.IsHole;
outrec2.FirstLeft = outrec.FirstLeft;
outrec.FirstLeft = outrec2;
-
this.FixupFirstLefts2(outrec, outrec2);
-
}
else
{
@@ -3198,7 +3183,6 @@ namespace Shaper2D.PolygonClipper
outrec2.IsHole = outrec.IsHole;
outrec2.FirstLeft = outrec.FirstLeft;
this.FixupFirstLefts1(outrec, outrec2);
-
}
op2 = op; // ie get ready for the next iteration
diff --git a/src/Shaper2D/PolygonClipper/TEdge.cs b/src/Shaper2D/PolygonClipper/Edge.cs
similarity index 85%
rename from src/Shaper2D/PolygonClipper/TEdge.cs
rename to src/Shaper2D/PolygonClipper/Edge.cs
index d7b6d1f..560f752 100644
--- a/src/Shaper2D/PolygonClipper/TEdge.cs
+++ b/src/Shaper2D/PolygonClipper/Edge.cs
@@ -1,4 +1,4 @@
-//
+//
// Copyright (c) Scott Williams and contributors.
// Licensed under the Apache License, Version 2.0.
//
@@ -49,7 +49,7 @@ namespace Shaper2D.PolygonClipper
///
/// The top.
///
- internal System.Numerics.Vector2 Top { get; set; }
+ public System.Numerics.Vector2 Top { get; set; }
///
/// Gets or sets the delta.
@@ -84,7 +84,6 @@ namespace Shaper2D.PolygonClipper
/// Side only refers to current side of solution poly
public EdgeSide Side { get; set; }
-
///
/// Gets or sets the wind delta.
///
@@ -97,10 +96,16 @@ namespace Shaper2D.PolygonClipper
public int WindindDelta { get; set; }
///
- /// The winding count
+ /// Gets or sets the winding count
///
public int WindingCount { get; set; }
+ ///
+ /// Gets or sets the type of the winding count in opposite poly.
+ ///
+ ///
+ /// The type of the winding count in opposite poly.
+ ///
public int WindingCountInOppositePolyType { get; set; }
///
@@ -120,11 +125,10 @@ namespace Shaper2D.PolygonClipper
public Edge NextEdge { get; set; }
///
- /// The previous
+ /// Gets or sets the previous
///
public Edge PreviousEdge { get; set; }
-
///
/// Gets or sets the next in LML.
///
@@ -142,18 +146,21 @@ namespace Shaper2D.PolygonClipper
public Edge NextInAEL { get; set; }
///
- /// The previous in ael
+ /// Gets or sets the previous in ael
///
public Edge PreviousInAEL { get; set; }
///
- /// The next in sel
+ /// Gets or sets the next in sel
///
public Edge NextInSEL { get; set; }
///
- /// The previous in sel
+ /// Gets or sets the previous in sel.
///
+ ///
+ /// The previous in sel.
+ ///
public Edge PreviousInSEL { get; set; }
}
}
\ No newline at end of file