//////////////////////////////////////////////// static Polygons ExPolygons2Polygons(ExPolygons epgs) { Polygons result = new Polygons(); foreach (ExPolygon epg in epgs) { result.Add(epg.outer); foreach (Polygon hole in epg.holes) { result.Add(hole); } } return(result); }
//--------------------------------------------------------------------- private void Form1_Load(object sender, EventArgs e) { mybitmap = new Bitmap( pictureBox1.ClientRectangle.Width, pictureBox1.ClientRectangle.Height, PixelFormat.Format32bppArgb); subjects = new Polygons(); clips = new Polygons(); solution = new Polygons(); exSolution = new ExPolygons(); toolStripStatusLabel1.Text = "Tip: Use the mouse-wheel (or +,-,0) to adjust the offset of the solution polygons."; DrawBitmap(); }
//------------------------------------------------------------------------------ public bool Execute(ClipType clipType, ExPolygons solution, PolyFillType subjFillType, PolyFillType clipFillType) { if (m_ExecuteLocked) return false; m_ExecuteLocked = true; solution.Clear(); m_SubjFillType = subjFillType; m_ClipFillType = clipFillType; m_ClipType = clipType; bool succeeded = ExecuteInternal(true); //build the return polygons ... if (succeeded) BuildResultEx(solution); m_ExecuteLocked = false; return succeeded; }
//------------------------------------------------------------------------------ private void BuildResultEx(ExPolygons polyg) { polyg.Clear(); polyg.Capacity = m_PolyOuts.Count; int i = 0; while (i < m_PolyOuts.Count) { OutRec outRec = m_PolyOuts[i++]; if (outRec.pts == null) break; //nb: already sorted here OutPt p = outRec.pts; int cnt = PointCount(p); if (cnt < 3) continue; ExPolygon epg = new ExPolygon(); epg.outer = new Polygon(cnt); epg.holes = new Polygons(); for (int j = 0; j < cnt; j++) { epg.outer.Add(p.pt); p = p.next; } while (i < m_PolyOuts.Count) { outRec = m_PolyOuts[i]; if (outRec.pts == null || !outRec.isHole) break; Polygon pg = new Polygon(); p = outRec.pts; do { pg.Add(p.pt); p = p.next; } while (p != outRec.pts); epg.holes.Add(pg); i++; } polyg.Add(epg); } }
//------------------------------------------------------------------------------ public bool Execute(ClipType clipType, ExPolygons solution) { return Execute(clipType, solution, PolyFillType.pftEvenOdd, PolyFillType.pftEvenOdd); }