/// <summary> /// Constructor. /// </summary> /// <param name="Other">Other polygon to set this to.</param> public C2DHoledPolyArc(C2DHoledPolyArc Other) { _Rim = new C2DPolyArc(Other.Rim); for (int i = 0; i < Other.HoleCount; i++) { _Holes.Add(new C2DPolyArc(Other.GetHole(i))); } }
/// <summary> /// Assignment. /// </summary> /// <param name="Other">Other polygon to set this to.</param> public void Set(C2DHoledPolyArc Other) { _Rim.Set(Other.Rim); _Holes.Clear(); for (int i = 0; i < Other.HoleCount; i++) { _Holes.Add(new C2DPolyArc(Other.GetHole(i))); } }
/// <summary> /// Gets the overlaps of the 2 shapes. /// </summary> /// <param name="Other">The other shape.</param> /// <param name="Polygons">The set to recieve the result.</param> /// <param name="grid">The degenerate settings.</param> public void GetOverlaps(C2DHoledPolyArc Other, List <C2DHoledPolyArc> Polygons, CGrid grid) { List <C2DHoledPolyBase> NewPolys = new List <C2DHoledPolyBase>(); base.GetOverlaps(Other, NewPolys, grid); for (int i = 0; i < NewPolys.Count; i++) { Polygons.Add(new C2DHoledPolyArc(NewPolys[i])); } }
/// <summary> /// Gets the union of the 2 shapes. /// </summary> /// <param name="Other">The other shape.</param> /// <param name="Polygons">The set to recieve the result.</param> /// <param name="grid">The degenerate settings.</param> public void GetUnion(C2DHoledPolyArc Other, List <C2DHoledPolyArc> Polygons, CGrid grid) { var NewPolys = new List <C2DHoledPolyBase>(); base.GetUnion(Other, NewPolys, grid); for (var i = 0; i < NewPolys.Count; i++) { Polygons.Add(new C2DHoledPolyArc(NewPolys[i])); } }
C2DHoledPolyArc makeCircle(C2DPoint pos, float radius) { C2DPolyArc shape = new C2DPolyArc (); shape.SetStartPoint (new C2DPoint(pos.x+radius,pos.y)); for (int i = 0; i < 16; i++) { shape.LineTo(new C2DPoint (pos.x + Mathf.Cos(Mathf.PI*2*i/16)*radius, pos.y+ Mathf.Sin(Mathf.PI*2*i/16)*radius), radius, false, true); } shape.Close (radius, false, true); C2DHoledPolyArc result = new C2DHoledPolyArc (); result.Rim = shape; return result; }
/// <summary> /// Gets the overlaps of the 2 shapes. /// </summary> /// <param name="Other">The other shape.</param> /// <param name="Polygons">The set to recieve the result.</param> /// <param name="grid">The degenerate settings.</param> public void GetOverlaps(C2DHoledPolyArc Other, List<C2DHoledPolyArc> Polygons, CGrid grid) { List<C2DHoledPolyBase> NewPolys = new List<C2DHoledPolyBase>(); base.GetOverlaps(Other, NewPolys, grid); for (int i = 0; i < NewPolys.Count; i++) Polygons.Add(new C2DHoledPolyArc(NewPolys[i])); }
void merge(C2DHoledPolyArc stoneShape, List<C2DHoledPolyArc> shapesToMerge, List<C2DHoledPolyArc> ownShape) { List<C2DHoledPolyArc> acc = new List<C2DHoledPolyArc>(); CGrid grid = new CGrid (); grid.SetGridSize(0.01f); if (shapesToMerge.Count == 0) { ownShape.Add(stoneShape); return; } foreach (C2DHoledPolyArc shape in shapesToMerge) { ownShape.Remove(shape); } foreach (C2DHoledPolyArc shape in shapesToMerge) { shape.GetUnion(stoneShape, acc, grid); } ownShape.Add(acc[acc.Count-1]); }