本文整理汇总了C#中ClipperLib.Clipper.AddPolygons方法的典型用法代码示例。如果您正苦于以下问题:C# Clipper.AddPolygons方法的具体用法?C# Clipper.AddPolygons怎么用?C# Clipper.AddPolygons使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClipperLib.Clipper
的用法示例。
在下文中一共展示了Clipper.AddPolygons方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoCircleClipping
public void DoCircleClipping(Vector2 pos, float radius)
{
List<VertexPosition[]> shape_old = shape;
bool isCleared = false;
int sc = 0;
for (sc = 0; sc < shape_old.Count; sc++)
{
ClippingPolygons subj = new ClippingPolygons(1);
subj.Add(new ClippingPolygon(shape_old[sc].Length));
foreach (VertexPosition point in shape_old[sc])
{
subj[0].Add(new IntPoint((int)((point.Position.X) * accuracy), (int)((point.Position.Y) * accuracy)));
}
ClippingPolygons clip = new ClippingPolygons(1);
clip.Add(new ClippingPolygon());
for (int alpha = 0; alpha < 360; alpha += 10)
{
clip[0].Add(new IntPoint((int)(((Math.Sin((alpha) * Math.PI / 180.0) * radius) + pos.X) * accuracy), (int)(((Math.Cos((alpha) * Math.PI / 180.0) * radius) + pos.Y) * accuracy)));
//log.Log(pos.ToString());
}
ClippingPolygons solution = new ClippingPolygons();
Clipper c = new Clipper();
c.AddPolygons(subj, PolyType.ptSubject);
c.AddPolygons(clip, PolyType.ptClip);
if (c.Execute(ClipType.ctDifference, solution, PolyFillType.pftEvenOdd, PolyFillType.pftEvenOdd))
{
if (!isCleared)
{
shape = new List<VertexPosition[]>();
drawer.Clear();
isCleared = true;
}
for (int f = 0; f < solution.Count; f++)
{
shape.Add(new VertexPosition[solution[f].Count]);
drawer.Add(new ChunkDrawer(ref log));
for (int i = 0; i < solution[f].Count; i++)
{
shape[shape.Count-1][i] = new VertexPosition(solution[f][i].X / accuracy, solution[f][i].Y / accuracy, 0);
}
drawer[shape.Count-1].BufferVertices(shape[shape.Count - 1]);
}
}
}
}
示例2: DoCircleClipping
public void DoCircleClipping(Vector2 pos, float radius)
{
ClippingPolygons subj = new ClippingPolygons(1);
subj.Add(new ClippingPolygon(shape.Length));
foreach(VertexPosition point in shape){
subj[0].Add(new IntPoint((int)((point.Position.X) * accuracy), (int)((point.Position.Y) * accuracy)));
}
ClippingPolygons clip = new ClippingPolygons(1);
clip.Add(new ClippingPolygon());
for (int alpha = 0; alpha < 360; alpha += 10)
{
clip[0].Add(new IntPoint((int)(((Math.Sin((alpha) * Math.PI / 180.0) * radius)+pos.X) * accuracy), (int)(((Math.Cos((alpha) * Math.PI / 180.0) * radius)+pos.Y) * accuracy)));
//log.Log(pos.ToString());
}
ClippingPolygons solution = new ClippingPolygons();
Clipper c = new Clipper();
c.AddPolygons(subj, PolyType.ptSubject);
c.AddPolygons(clip, PolyType.ptClip);
if (c.Execute(ClipType.ctDifference, solution, PolyFillType.pftEvenOdd, PolyFillType.pftEvenOdd))
{
for (int f = 0; f < solution.Count; f++)
{
if (f == 0)
{
shape = new VertexPosition[solution[f].Count];
for (int i = 0; i < solution[f].Count; i++)
{
shape[i] = new VertexPosition(solution[f][i].X / accuracy, solution[f][i].Y / accuracy, 0);
}
}
}
}
BufferVertices(ref shape);
}
示例3: DrawBitmap
//---------------------------------------------------------------------------
private void DrawBitmap(bool justClip = false)
{
if (!justClip)
{
if (rbTest2.Checked)
GenerateAustPlusRandomEllipses((int)nudCount.Value);
else
GenerateRandomPolygon((int)nudCount.Value);
}
Cursor.Current = Cursors.WaitCursor;
Graphics newgraphic;
newgraphic = Graphics.FromImage(mybitmap);
newgraphic.SmoothingMode = SmoothingMode.AntiAlias;
newgraphic.Clear(Color.White);
GraphicsPath path = new GraphicsPath();
if (rbNonZero.Checked) path.FillMode = FillMode.Winding;
//draw subjects ...
foreach (Polygon pg in subjects)
{
PointF[] pts = PolygonToPointFArray(pg, scale);
path.AddPolygon(pts);
pts = null;
}
Pen myPen = new Pen(Color.FromArgb(196, 0xC3, 0xC9, 0xCF), (float)0.6);
SolidBrush myBrush = new SolidBrush(Color.FromArgb(127, 0xDD, 0xDD, 0xF0));
newgraphic.FillPath(myBrush, path);
newgraphic.DrawPath(myPen, path);
path.Reset();
//draw clips ...
if (rbNonZero.Checked) path.FillMode = FillMode.Winding;
foreach (Polygon pg in clips)
{
PointF[] pts = PolygonToPointFArray(pg, scale);
path.AddPolygon(pts);
pts = null;
}
myPen.Color = Color.FromArgb(196, 0xF9, 0xBE, 0xA6);
myBrush.Color = Color.FromArgb(127, 0xFF, 0xE0, 0xE0);
newgraphic.FillPath(myBrush, path);
newgraphic.DrawPath(myPen, path);
//do the clipping ...
if ((clips.Count > 0 || subjects.Count > 0) && !rbNone.Checked)
{
Polygons solution2 = new Polygons();
Clipper c = new Clipper();
c.AddPolygons(subjects, PolyType.ptSubject);
c.AddPolygons(clips, PolyType.ptClip);
exSolution.Clear();
solution.Clear();
bool succeeded = c.Execute(GetClipType(), solution, GetPolyFillType(), GetPolyFillType());
if (succeeded)
{
myBrush.Color = Color.Black;
path.Reset();
//It really shouldn't matter what FillMode is used for solution
//polygons because none of the solution polygons overlap.
//However, FillMode.Winding will show any orientation errors where
//holes will be stroked (outlined) correctly but filled incorrectly ...
path.FillMode = FillMode.Winding;
//or for something fancy ...
if (nudOffset.Value != 0)
solution2 = Clipper.OffsetPolygons(solution, (double)nudOffset.Value * scale, JoinType.jtMiter);
else
solution2 = new Polygons(solution);
foreach (Polygon pg in solution2)
{
PointF[] pts = PolygonToPointFArray(pg, scale);
if (pts.Count() > 2)
path.AddPolygon(pts);
pts = null;
}
myBrush.Color = Color.FromArgb(127, 0x66, 0xEF, 0x7F);
myPen.Color = Color.FromArgb(255, 0, 0x33, 0);
myPen.Width = 1.0f;
newgraphic.FillPath(myBrush, path);
newgraphic.DrawPath(myPen, path);
//now do some fancy testing ...
Font f = new Font("Arial", 8);
SolidBrush b = new SolidBrush(Color.Navy);
double subj_area = 0, clip_area = 0, int_area = 0, union_area = 0;
c.Clear();
c.AddPolygons(subjects, PolyType.ptSubject);
c.Execute(ClipType.ctUnion, solution2, GetPolyFillType(), GetPolyFillType());
foreach (Polygon pg in solution2) subj_area += Clipper.Area(pg);
c.Clear();
c.AddPolygons(clips, PolyType.ptClip);
c.Execute(ClipType.ctUnion, solution2, GetPolyFillType(), GetPolyFillType());
foreach (Polygon pg in solution2) clip_area += Clipper.Area(pg);
c.AddPolygons(subjects, PolyType.ptSubject);
c.Execute(ClipType.ctIntersection, solution2, GetPolyFillType(), GetPolyFillType());
foreach (Polygon pg in solution2) int_area += Clipper.Area(pg);
//.........这里部分代码省略.........
示例4: SimplifyPolygons
//------------------------------------------------------------------------------
public static Polygons SimplifyPolygons(Polygons polys)
{
Polygons result = new Polygons();
Clipper c = new Clipper();
c.AddPolygons(polys, PolyType.ptSubject);
c.Execute(ClipType.ctUnion, result);
return result;
}
示例5: PolyOffsetBuilder
public PolyOffsetBuilder(Polygons pts, Polygons solution, double delta, JoinType jointype, double MiterLimit = 2)
{
//precondtion: solution != pts
if (delta == 0)
{
solution = pts;
return;
}
this.pts = pts;
this.delta = delta;
if (MiterLimit <= 1) MiterLimit = 1;
double RMin = 2/(MiterLimit*MiterLimit);
normals = new List<DoublePoint>();
double deltaSq = delta*delta;
solution.Clear();
solution.Capacity = pts.Count;
for (m_i = 0; m_i < pts.Count; m_i++)
{
int len = pts[m_i].Count;
if (len > 1 && pts[m_i][0].X == pts[m_i][len - 1].X &&
pts[m_i][0].Y == pts[m_i][len - 1].Y) len--;
if (len == 0 || (len < 3 && delta <= 0))
continue;
else if (len == 1)
{
Polygon arc;
arc = BuildArc(pts[m_i][len - 1], 0, 2 * Math.PI, delta);
solution.Add(arc);
continue;
}
//build normals ...
normals.Clear();
normals.Capacity = len;
for (int j = 0; j < len -1; ++j)
normals.Add(GetUnitNormal(pts[m_i][j], pts[m_i][j+1]));
normals.Add(GetUnitNormal(pts[m_i][len - 1], pts[m_i][0]));
currentPoly = new Polygon();
m_k = len - 1;
for (m_j = 0; m_j < len; ++m_j)
{
switch (jointype)
{
case JoinType.jtMiter:
{
m_R = 1 + (normals[m_j].X*normals[m_k].X +
normals[m_j].Y*normals[m_k].Y);
if (m_R >= RMin) DoMiter(); else DoSquare(MiterLimit);
break;
}
case JoinType.jtRound:
DoRound();
break;
case JoinType.jtSquare:
DoSquare(1);
break;
}
m_k = m_j;
}
solution.Add(currentPoly);
}
//finally, clean up untidy corners ...
Clipper clpr = new Clipper();
clpr.AddPolygons(solution, PolyType.ptSubject);
if (delta > 0)
{
clpr.Execute(ClipType.ctUnion, solution, PolyFillType.pftPositive, PolyFillType.pftPositive);
}
else
{
IntRect r = clpr.GetBounds();
Polygon outer = new Polygon(4);
outer.Add(new IntPoint(r.left - 10, r.bottom + 10));
outer.Add(new IntPoint(r.right + 10, r.bottom + 10));
outer.Add(new IntPoint(r.right + 10, r.top - 10));
outer.Add(new IntPoint(r.left - 10, r.top - 10));
clpr.AddPolygon(outer, PolyType.ptSubject);
clpr.Execute(ClipType.ctUnion, solution, PolyFillType.pftNegative, PolyFillType.pftNegative);
if (solution.Count > 0)
{
solution.RemoveAt(0);
for (int i = 0; i < solution.Count; i++)
solution[i].Reverse();
}
}
}
示例6: FindDistictObjectBounds
static public PolyTree FindDistictObjectBounds(ImageBuffer image)
{
MarchingSquaresByte marchingSquaresData = new MarchingSquaresByte(image, 5, 0);
marchingSquaresData.CreateLineSegments();
Polygons lineLoops = marchingSquaresData.CreateLineLoops(1);
if (lineLoops.Count == 1)
{
return null;
}
// create a bounding polygon to clip against
IntPoint min = new IntPoint(long.MaxValue, long.MaxValue);
IntPoint max = new IntPoint(long.MinValue, long.MinValue);
foreach (Polygon polygon in lineLoops)
{
foreach (IntPoint point in polygon)
{
min.X = Math.Min(point.X - 10, min.X);
min.Y = Math.Min(point.Y - 10, min.Y);
max.X = Math.Max(point.X + 10, max.X);
max.Y = Math.Max(point.Y + 10, max.Y);
}
}
Polygon boundingPoly = new Polygon();
boundingPoly.Add(min);
boundingPoly.Add(new IntPoint(min.X, max.Y));
boundingPoly.Add(max);
boundingPoly.Add(new IntPoint(max.X, min.Y));
// now clip the polygons to get the inside and outside polys
Clipper clipper = new Clipper();
clipper.AddPolygons(lineLoops, PolyType.ptSubject);
clipper.AddPolygon(boundingPoly, PolyType.ptClip);
PolyTree polyTreeForPlate = new PolyTree();
clipper.Execute(ClipType.ctIntersection, polyTreeForPlate);
return polyTreeForPlate;
}
示例7: calculateRegionPath
void calculateRegionPath(ClipType clipType)
{
Clipper c = new Clipper();
var subjects = solution;
//subjects.Add (solution);
var clips = new Paths ();
foreach (var path in regionList [regionList.Count - 1].regionPath)
clips.Add (path);
c.AddPolygons(subjects, PolyType.ptSubject);
c.AddPolygons(clips, PolyType.ptClip);
solution.Clear();
bool succeeded = c.Execute(clipType, solution, SUBJ_FILL_TYPE, CLIP_FILL_TYPE);
if (succeeded)
{
PathsToInternalPath (solution);
// Not sure what this is returning
// var bounds = c.GetBounds ();
// regionBounds.X = bounds.left / scale;
// regionBounds.Y = bounds.top / scale;
// regionBounds.Width = (bounds.right - bounds.left) / scale;
// regionBounds.Height = (bounds.bottom - bounds.top) / scale;
if (regionPath.IsEmpty)
regionBounds = RectangleF.Empty;
else
regionBounds = regionPath.BoundingBox;
}
}
示例8: SimplifyPolygons
//------------------------------------------------------------------------------
public static Polygons SimplifyPolygons(Polygons polys,
PolyFillType fillType = PolyFillType.pftEvenOdd)
{
Polygons result = new Polygons();
Clipper c = new Clipper();
c.AddPolygons(polys, PolyType.ptSubject);
c.Execute(ClipType.ctUnion, result, fillType, fillType);
return result;
}
示例9: PolyOffsetBuilder
//.........这里部分代码省略.........
IntPoint botPt = pts[botI][0];
for (int i = botI; i < Len; ++i)
{
if (pts[i].Count == 0) continue;
if (UpdateBotPt(pts[i][0], ref botPt)) botI = i;
for (int j = pts[i].Count -1; j > 0; j--)
{
if (PointsEqual(pts[i][j], pts[i][j -1]))
pts[i].RemoveAt(j);
else if (UpdateBotPt(pts[i][j], ref botPt))
botI = i;
}
}
if (!Orientation(pts[botI]))
ReversePolygons(pts);
}
if (MiterLimit <= 1) MiterLimit = 1;
double RMin = 2.0 / (MiterLimit*MiterLimit);
normals = new List<DoublePoint>();
double deltaSq = delta*delta;
solution.Clear();
solution.Capacity = pts.Count;
for (m_i = 0; m_i < pts.Count; m_i++)
{
int len = pts[m_i].Count;
if (len > 1 && pts[m_i][0].X == pts[m_i][len - 1].X &&
pts[m_i][0].Y == pts[m_i][len - 1].Y) len--;
if (len == 0 || (len < 3 && delta <= 0))
continue;
else if (len == 1)
{
Polygon arc;
arc = BuildArc(pts[m_i][len - 1], 0, 2 * Math.PI, delta);
solution.Add(arc);
continue;
}
//build normals ...
normals.Clear();
normals.Capacity = len;
for (int j = 0; j < len -1; ++j)
normals.Add(GetUnitNormal(pts[m_i][j], pts[m_i][j+1]));
normals.Add(GetUnitNormal(pts[m_i][len - 1], pts[m_i][0]));
currentPoly = new Polygon();
m_k = len - 1;
for (m_j = 0; m_j < len; ++m_j)
{
switch (jointype)
{
case JoinType.jtMiter:
{
m_R = 1 + (normals[m_j].X*normals[m_k].X +
normals[m_j].Y*normals[m_k].Y);
if (m_R >= RMin) DoMiter(); else DoSquare(MiterLimit);
break;
}
case JoinType.jtRound:
DoRound();
break;
case JoinType.jtSquare:
DoSquare(1);
break;
}
m_k = m_j;
}
solution.Add(currentPoly);
}
//finally, clean up untidy corners ...
Clipper clpr = new Clipper();
clpr.AddPolygons(solution, PolyType.ptSubject);
if (delta > 0)
{
clpr.Execute(ClipType.ctUnion, solution, PolyFillType.pftPositive, PolyFillType.pftPositive);
}
else
{
IntRect r = clpr.GetBounds();
Polygon outer = new Polygon(4);
outer.Add(new IntPoint(r.left - 10, r.bottom + 10));
outer.Add(new IntPoint(r.right + 10, r.bottom + 10));
outer.Add(new IntPoint(r.right + 10, r.top - 10));
outer.Add(new IntPoint(r.left - 10, r.top - 10));
clpr.AddPolygon(outer, PolyType.ptSubject);
clpr.Execute(ClipType.ctUnion, solution, PolyFillType.pftNegative, PolyFillType.pftNegative);
if (solution.Count > 0)
{
solution.RemoveAt(0);
for (int i = 0; i < solution.Count; i++)
solution[i].Reverse();
}
}
}
示例10: PolyOffsetBuilder
//.........这里部分代码省略.........
if (isPolygon || forceClose)
{
m_k = len - 1;
for (m_j = 0; m_j < len; ++m_j)
OffsetPoint(jointype, limit);
solution.Add(currentPoly);
if (!isPolygon)
{
currentPoly = new Polygon();
m_delta = -m_delta;
m_k = len - 1;
for (m_j = 0; m_j < len; ++m_j)
OffsetPoint(jointype, limit);
m_delta = -m_delta;
currentPoly.Reverse();
solution.Add(currentPoly);
}
}
else
{
m_k = 0;
for (m_j = 1; m_j < len - 1; ++m_j)
OffsetPoint(jointype, limit);
IntPoint pt1;
if (endtype == EndType.etButt)
{
m_j = len - 1;
pt1 = new IntPoint((Int64)Round(pts[m_i][m_j].X + normals[m_j].X *
delta), (Int64)Round(pts[m_i][m_j].Y + normals[m_j].Y * delta));
AddPoint(pt1);
pt1 = new IntPoint((Int64)Round(pts[m_i][m_j].X - normals[m_j].X *
delta), (Int64)Round(pts[m_i][m_j].Y - normals[m_j].Y * delta));
AddPoint(pt1);
}
else
{
m_j = len - 1;
m_k = len - 2;
normals[m_j].X = -normals[m_j].X;
normals[m_j].Y = -normals[m_j].Y;
if (endtype == EndType.etSquare) DoSquare();
else DoRound(limit);
}
//re-build Normals ...
for (int j = len - 1; j > 0; j--)
{
normals[j].X = -normals[j - 1].X;
normals[j].Y = -normals[j - 1].Y;
}
normals[0].X = -normals[1].X;
normals[0].Y = -normals[1].Y;
m_k = len - 1;
for (m_j = m_k - 1; m_j > 0; --m_j)
OffsetPoint(jointype, limit);
if (endtype == EndType.etButt)
{
pt1 = new IntPoint((Int64)Round(pts[m_i][0].X - normals[0].X * delta),
(Int64)Round(pts[m_i][0].Y - normals[0].Y * delta));
AddPoint(pt1);
pt1 = new IntPoint((Int64)Round(pts[m_i][0].X + normals[0].X * delta),
(Int64)Round(pts[m_i][0].Y + normals[0].Y * delta));
AddPoint(pt1);
}
else
{
m_k = 1;
if (endtype == EndType.etSquare) DoSquare();
else DoRound(limit);
}
solution.Add(currentPoly);
}
}
//finally, clean up untidy corners ...
Clipper clpr = new Clipper();
clpr.AddPolygons(solution, PolyType.ptSubject);
if (delta > 0)
{
clpr.Execute(ClipType.ctUnion, solution, PolyFillType.pftPositive, PolyFillType.pftPositive);
}
else
{
IntRect r = clpr.GetBounds();
Polygon outer = new Polygon(4);
outer.Add(new IntPoint(r.left - 10, r.bottom + 10));
outer.Add(new IntPoint(r.right + 10, r.bottom + 10));
outer.Add(new IntPoint(r.right + 10, r.top - 10));
outer.Add(new IntPoint(r.left - 10, r.top - 10));
clpr.AddPolygon(outer, PolyType.ptSubject);
clpr.ReverseSolution = true;
clpr.Execute(ClipType.ctUnion, solution, PolyFillType.pftNegative, PolyFillType.pftNegative);
if (solution.Count > 0) solution.RemoveAt(0);
}
}
示例11: Main
//.........这里部分代码省略.........
}
string subjFilename = args[1];
string clipFilename = args[2];
if (!File.Exists(subjFilename))
{
Console.WriteLine("Error: file - {0} - does not exist.", subjFilename);
return;
}
if (!File.Exists(clipFilename))
{
Console.WriteLine("Error: file - {0} - does not exist.", clipFilename);
return;
}
int decimal_places = 0;
if (!Int32.TryParse(args[3], out decimal_places))
{
Console.WriteLine("Error: invalid number of decimal places - {0}", args[3]);
return;
}
if (decimal_places > 8) decimal_places = 8;
else if (decimal_places < 0) decimal_places = 0;
double svg_scale = 0;
if (!double.TryParse(args[4], out svg_scale))
{
Console.WriteLine("Error: invalid value for SVG_SCALE - {0}", args[4]);
return;
}
if (svg_scale < -18) svg_scale = -18;
else if (svg_scale > 18) svg_scale = 18;
svg_scale = Math.Pow(10, svg_scale - decimal_places);//nb: also compensate for decimal places
PolyFillType pftSubj = PolyFillType.pftEvenOdd;
PolyFillType pftClip = PolyFillType.pftEvenOdd;
if (args.Length > 6)
{
switch (args[5].ToUpper())
{
case "EVENODD": pftSubj = PolyFillType.pftEvenOdd; break;
case "NONZERO": pftSubj = PolyFillType.pftNonZero; break;
default: Console.WriteLine("Error: invalid cliptype - {0}", args[5]); return;
}
switch (args[6].ToUpper())
{
case "EVENODD": pftClip = PolyFillType.pftEvenOdd; break;
case "NONZERO": pftClip = PolyFillType.pftNonZero; break;
default: Console.WriteLine("Error: invalid cliptype - {0}", args[6]); return;
}
}
Polygons subjs = new Polygons();
Polygons clips = new Polygons();
if (!LoadFromFile(subjFilename, subjs, decimal_places))
{
Console.WriteLine("Error processing subject polygons file - {0} ", subjFilename);
OutputFileFormat();
return;
}
if (!LoadFromFile(clipFilename, clips, decimal_places))
{
Console.WriteLine("Error processing clip polygons file - {0} ", clipFilename);
OutputFileFormat();
return;
}
Console.WriteLine("wait ...");
Clipper cp = new Clipper();
cp.AddPolygons(subjs, PolyType.ptSubject);
cp.AddPolygons(clips, PolyType.ptClip);
Polygons solution = new Polygons();
//Polygons solution = new Polygons();
if (cp.Execute(ct, solution, pftSubj, pftClip))
{
SaveToFile("solution.txt", solution, decimal_places);
//solution = Clipper.OffsetPolygons(solution, -4, JoinType.jtRound);
SVGBuilder svg = new SVGBuilder();
svg.style.brushClr = Color.FromArgb(0x20, 0, 0, 0x9c);
svg.style.penClr = Color.FromArgb(0xd3, 0xd3, 0xda);
svg.AddPolygons(subjs);
svg.style.brushClr = Color.FromArgb(0x20, 0x9c, 0, 0);
svg.style.penClr = Color.FromArgb(0xff, 0xa0, 0x7a);
svg.AddPolygons(clips);
svg.style.brushClr = Color.FromArgb(0xAA, 0x80, 0xff, 0x9c);
svg.style.penClr = Color.FromArgb(0, 0x33, 0);
svg.AddPolygons(solution);
svg.SaveToFile("solution.svg", svg_scale);
Console.WriteLine("finished!");
}
else
{
Console.WriteLine("failed!");
}
}
示例12: Slice
//.........这里部分代码省略.........
{
Vector3 result = Vector3.Transform(vertex, transform);
polygon.Add(new IntPoint((long)result.X, (long)result.Y));
}
polygon.RemoveAt(0);
c.AddPolygon(polygon, PolyType.ptClip);
GL.PushMatrix();
GL.Translate(new Vector3(0, 0, 100));
//loop.Draw();
GL.PopMatrix();
}
List<List<IntPoint>> union = new List<List<IntPoint>>();
bool r = c.Execute(ClipType.ctUnion, union, PolyFillType.pftNonZero, PolyFillType.pftNonZero);
List<List<IntPoint>> with_offset = Clipper.OffsetPolygons(union, toolRadius, JoinType.jtSquare);
List<List<IntPoint>> whatsLeft = Clipper.OffsetPolygons(with_offset, -toolRadius, JoinType.jtRound);
List<LineStrip> strips = new List<LineStrip>();
foreach (List<IntPoint> polygon in with_offset)
{
LineStrip strip = new LineStrip();
foreach (IntPoint point in polygon)
{
strip.Append(Vector3.Transform(new Vector3(point.X, point.Y, 0.0f), inverseTransform));
}
strip.Append(Vector3.Transform(new Vector3(polygon[0].X, polygon[0].Y, 0.0f), inverseTransform));
strips.Add(strip);
//new LineLoop(strip).Draw();
}
List<List<IntPoint>> removeArea = new List<List<IntPoint>>();
c.Clear();
c.AddPolygons(with_offset, PolyType.ptClip);
c.AddPolygon(boundingBox, PolyType.ptSubject);
List<List<IntPoint>> resultingPolygon = new List<List<IntPoint>>();
c.Execute(ClipType.ctDifference, removeArea, PolyFillType.pftNonZero, PolyFillType.pftNonZero);
removeArea = Clipper.CleanPolygons(removeArea, toolRadius / 100);
c.Clear();
c.AddPolygons(removeArea, PolyType.ptClip);
PolyTree test = new PolyTree();
c.Execute(ClipType.ctUnion, test, PolyFillType.pftNonZero, PolyFillType.pftNonZero);
//PolyNode pn = test.GetFirst();
//while (pn != null)
//{
// if (pn.IsHole)
// {
// LineLoop l = new LineLoop(pn.Contour, inverseTransform);
// l.Draw();
// }
// pn = pn.GetNext();
//}
List<Polygons> polys = FlattenPolyTree(test);
//GL.PushMatrix();
foreach (Polygons polygons in polys)
{
//GL.Translate(new Vector3 (0, 0, 100));
//foreach (Polygon polygon in polygons)
//{
// LineLoop l = new LineLoop(polygon, inverseTransform);
// l.Draw();
//}
List<Polygons> paths = ReducePolygon(polygons, toolRadius, inverseTransform);