private void MergeInnerWithInner(Polygon WindowHole, Polygon PolygonHole) { PolygonMerger PM = new PolygonMerger(WindowHole, PolygonHole, MergedContoursType.INNER_WITH_INNER/* 3*/); List<Polygon> contoursToAdd = PM.MakeUnion(); if (PM.NoIntersect) { if (Utility.PointInPolygon(WindowHole, PolygonHole.GetVertex(0)) == Utility.Inside) { RESULT.AddSubPolygon(PolygonHole); } else if (Utility.PointInPolygon(PolygonHole, WindowHole.GetVertex(0)) == Utility.Inside) { RESULT.AddSubPolygon(WindowHole); } } else { for (int i = 0; i < contoursToAdd.Count; i++) { RESULT.AddSubPolygon(contoursToAdd[i]); } } }
private void MergeOuterContours() { PolygonMerger PM = new PolygonMerger(WINDOW, POLYGON, MergedContoursType.OUTER_WITH_OUTER); List<Polygon> contoursToAdd = PM.MakeUnion(); if (PM.NoIntersect) { if (Utility.PointInPolygon(WINDOW, POLYGON.GetVertex(0)) == Utility.Inside) { for (int i = 0; i < WINDOW.VertexCount; i++) { RESULT.AddVertex(WINDOW.GetVertex(i)); } } else if (Utility.PointInPolygon(POLYGON, WINDOW.GetVertex(0)) == Utility.Inside) { for (int i = 0; i < POLYGON.VertexCount; i++) { RESULT.AddVertex(POLYGON.GetVertex(i)); } } else { MessageBox.Show("Полигоны не имеют общих точек"); noSharedPoints = true; } } else { for (int i = 0; i < contoursToAdd.Count; i++) { if (Utility.PolygonSquare(contoursToAdd[i]) > 0) { // добавить внешyнюю границу к ответу for (int j = 0; j < contoursToAdd[i].VertexCount; j++) { RESULT.AddVertex(contoursToAdd[i].GetVertex(j)); } } else // добавить внутреннюю границу к ответу { RESULT.AddSubPolygon(contoursToAdd[i]); } } } }
public void MergePolygons(Polygon mergingWindow) { if (mergingSubject == null) { mergingSubject = mergingWindow; } else if (mergingSubject == mergingWindow) { mergingSubject = null; } else { Polygon union = PolygonMerger.Union(this, mergingWindow, mergingSubject); if (union != null) { polygons.Remove(mergingWindow); polygons.Remove(mergingSubject); polygons.Insert(0, union); } mergingSubject = null; } }
public void UpdatePipeline(PathPointLayout layout, Calculator calculator, VectorBrush brush) { bool layoutChanged = false; if ((Layout == null) || (layout.ChannelMask != Layout.ChannelMask)) { Layout = layout; layoutChanged = true; } if (mPathProducer == null || calculator != mPathProducer.PathPointCalculator || layoutChanged) { mPathProducer = new PathProducer(Layout, calculator) { KeepAllData = true }; } if (mSmoothingFilter == null || layoutChanged) { mSmoothingFilter = new SmoothingFilter(Layout.Count) { KeepAllData = true }; } if (SplineProducer == null || layoutChanged) { SplineProducer = new SplineProducer(Layout) { KeepAllData = true }; } if (SplineInterpolator == null || layoutChanged) { SplineInterpolator = new CurvatureBasedInterpolator(Layout) { KeepAllData = true }; } if (BrushApplier == null || (brush != BrushApplier.Prototype) || layoutChanged) { BrushApplier = new BrushApplier(Layout, brush) { KeepAllData = true }; } if (ConvexHullChainProducer == null) { ConvexHullChainProducer = new ConvexHullChainProducer() { KeepAllData = true }; } if (mPolygonMerger == null) { mPolygonMerger = new PolygonMerger() { KeepAllData = true }; } if (PolygonSimplifier == null) { PolygonSimplifier = new PolygonSimplifier(0.1f) { KeepAllData = true }; } }