public Polygon2DTriangulator(Polygon2DAdorner a,Polygon2DAdorner b)
        {
            Polygon2DEditor polygonEditor = null;

            if (!a.polygon.isSimple || !b.polygon.isSimple)
            {
                throw (new ArgumentException());
            }
            if (a.polygon.PointDirection != b.polygon.PointDirection)
            {
                polygonEditor = new Polygon2DEditor(a.polygon);
                polygonEditor.Invert();
            }

            Debug.Assert(a.polygon.PointDirection == b.polygon.PointDirection);
            FirstPolygon = a;
            SecondPolygon = b;
            Diviser = new Polygon2DDiviser(a.Count);
            ghostPoint = new GhostPoint2DCollection();
            ghostTriangle = new GhostTriangle2DCollection();

            polygonEditor = new Polygon2DEditor(this.FirstPolygon.polygon);
            polygonEditor.Clear();
            polygonEditor = new Polygon2DEditor(this.SecondPolygon.polygon);
            polygonEditor.Clear();
        }
        public Polygon2DTriangulator(Polygon2DAdorner a, Polygon2DAdorner b)
        {
            Polygon2DEditor polygonEditor = null;

            if (!a.polygon.isSimple || !b.polygon.isSimple)
            {
                throw (new ArgumentException());
            }
            if (a.polygon.PointDirection != b.polygon.PointDirection)
            {
                polygonEditor = new Polygon2DEditor(a.polygon);
                polygonEditor.Invert();
            }

            Debug.Assert(a.polygon.PointDirection == b.polygon.PointDirection);
            FirstPolygon  = a;
            SecondPolygon = b;
            Diviser       = new Polygon2DDiviser(a.Count);
            ghostPoint    = new GhostPoint2DCollection();
            ghostTriangle = new GhostTriangle2DCollection();

            polygonEditor = new Polygon2DEditor(this.FirstPolygon.polygon);
            polygonEditor.Clear();
            polygonEditor = new Polygon2DEditor(this.SecondPolygon.polygon);
            polygonEditor.Clear();
        }
        private void AddInnerPoints(Polygon2DAdorner polygon)
        {
            for (int j = 0; j < this.ghostPoint.Count; j++)
            {
                for (int i = 0; i < polygon.internalSegments.Count; i++)
                {
                    int a = (int)(polygon.internalSegments[i].X);
                    int b = (int)(polygon.internalSegments[i].Y);

                    if (a == this.ghostPoint[j].FirstIndex && b == this.ghostPoint[j].LastIndex || a == this.ghostPoint[j].LastIndex && b == this.ghostPoint[j].FirstIndex)
                    {
                        Point2D       point       = null;
                        LineSegment2D lineSegment = null;

                        lineSegment = new LineSegment2D(polygon.polygon.GetPoint(a), polygon.polygon.GetPoint(b));

                        point = lineSegment.GetPoint(this.ghostPoint[j].LocalPosition);

                        Polygon2DEditor polygonEditor = new Polygon2DEditor(polygon.polygon);

                        polygonEditor.AddInnerPoint(point);

                        break;
                    }
                }
            }
        }
Example #4
0
        internal void AppendChild(Polygon2DAdorner child)
        {
            Polygon2DAdorner currentAdorner = this;

            while (currentAdorner.child != null)
            {
                currentAdorner = currentAdorner.child;
            }
            currentAdorner.child = child;
        }
        public void show(Graphics dc)
        {
            for (int i = 0; i < polygonLink.SubDivision.Count; i++)
            {
                Polygon2DAdorner polygonAdorner = new Polygon2DAdorner(polygonLink.SubDivision[i]);
                polygonAdorner.Show(dc, new PointF(0.0F, -30.0F), 1.0);
            }

            if (polygonLink.LinkDivisers == null || polygonLink.LinkDivisers.Count == 0)
            {
                return;
            }

            PointF[] points = new PointF[polygonLink.LinkDivisers.Count];

            for (int i = 0; i < polygonLink.LinkDivisers.Count; i++)
            {
                points[i] = new PointF((float)polygonLink.LinkDivisers[i].X, (float)polygonLink.LinkDivisers[i].Y + 30);
            }

            Pen redPen = new Pen(Color.Red);

            dc.DrawLines(redPen, points);
        }
        public void show(Graphics dc)
        {
            for (int i = 0; i < polygonLink.SubDivision.Count; i++)
            {
                Polygon2DAdorner polygonAdorner = new Polygon2DAdorner(polygonLink.SubDivision[i]);
                polygonAdorner.Show(dc, new PointF(0.0F, -30.0F), 1.0);
            }

            if (polygonLink.LinkDivisers == null || polygonLink.LinkDivisers.Count == 0)
            {
                return;
            }

            PointF[] points = new PointF[polygonLink.LinkDivisers.Count];

            for (int i = 0; i < polygonLink.LinkDivisers.Count; i++)
            {
                points[i] = new PointF((float)polygonLink.LinkDivisers[i].X, (float)polygonLink.LinkDivisers[i].Y + 30);
            }

            Pen redPen = new Pen(Color.Red);

            dc.DrawLines(redPen, points);
        }
Example #7
0
        private void Initialize()
        {
            this.MoveTimer.Stop();
            this.splitingMenuItem1.Checked = true;
            this.subDivisionMenuItem.Checked = true;
            this.flippingMenuItem1.Checked = true;
            this.areaBasedRemeshingMenuItem.Checked = true;

            this.competibleTriangulationMenuItem.Checked = true;
            StatusController.Triangulator = TriangulationTech.Simple;

            Polygon2D firstPolygon = new Polygon2D(new Point2DCollection());
            LeftPolygon = new Polygon2DAdorner(firstPolygon);
            Polygon2D secondPolygon = new Polygon2D(new Point2DCollection());
            RightPolygon = new Polygon2DAdorner(secondPolygon);

            this.triangulationMenuItem.Enabled = false;
            StatusController.canAddPoint = true;
            this.toolBarButton4.Enabled = true;
            this.toolBarButton4.Pushed = true;
            this.toolBar1.Buttons[5].Enabled = false;
            StatusController.LeftZoom.ratio = 1.0;
            StatusController.LeftZoom.Offset = new PointF(0.0F, -30.0F);
            StatusController.RightZoom.ratio = 1.0;
            StatusController.RightZoom.Offset = new PointF(0.0F, -30.0F);
            this.statusBarPanel1.Text = this.GetPolygonStatus(new Point2D(1, 1));
            this.statusBarPanel2.Text = "Hint Index : -1 ";
            this.Invalidate();
        }
Example #8
0
        private void DivideTarget()
        {
            CompatibleDiviser cd = new CompatibleDiviser(this.FirstPolygon, this.SecondPolygon);
            cd.UpdateStatus += new Microsoft.VS.Akira.Triangulations.CompatibleDiviser.ShowStatus(surfaceFitter_UpdateStatus);
            cd.Divide();

            this.surfaceFitter_UpdateStatus(this, "Building...");
            this.LeftPolygon = new Polygon2DAdorner(cd.FirstPolygonDivisions[0]);
            this.RightPolygon  = new Polygon2DAdorner(cd.SecondPolygonDivisions[0]);

            for (int i = 1; i < cd.FirstPolygonDivisions.Count; i++)
            {
                Debug.Assert(cd.FirstPolygonDivisions[i].VertexCount == cd.SecondPolygonDivisions[i].VertexCount);
                this.LeftPolygon.AppendChild(new Polygon2DAdorner(cd.FirstPolygonDivisions[i]));
                this.RightPolygon.AppendChild(new Polygon2DAdorner(cd.SecondPolygonDivisions[i]));
            }

            this.LeftPolygon.Triangulation();

            this.surfaceFitter_UpdateStatus(this, "Done");
            this.Invalidate();
        }
Example #9
0
        private void Restart()
        {
            this.FileName = null;

            this.Clear();

            StatusController.canRestart = true;
            polygonLinkAdorner = null;

            if (StatusController.availablePartition == Partition.Left)
            {
                Polygon2D firstPolygon = new Polygon2D(new Point2DCollection());
                LeftPolygon = new Polygon2DAdorner(firstPolygon);
            }
            else
            {
                Polygon2D secondPolygon = new Polygon2D(new Point2DCollection());
                RightPolygon = new Polygon2DAdorner(secondPolygon);
            }
            this.triangulationMenuItem.Enabled = false;
            StatusController.canAddPoint = true;
            this.toolBarButton4.Enabled = true;
            this.toolBarButton4.Pushed = true;
            this.toolBar1.Buttons[5].Enabled = false;

            StatusController.LeftZoom.ratio = 1.0;
            StatusController.LeftZoom.Offset = new PointF(0.0F, -30.0F);
            StatusController.RightZoom.ratio = 1.0;
            StatusController.RightZoom.Offset = new PointF(0.0F, -30.0F);

            this.statusBarPanel1.Text = this.GetPolygonStatus(new Point2D(1,1));
            this.statusBarPanel2.Text = "Hint Index : -1 ";

            this.Invalidate();
        }
Example #10
0
        private void Open(string strFileName)
        {
            WFParser wfParser = new WFParser(strFileName);

            Polygon2D polygon = wfParser.Read();

            if (StatusController.availablePartition == Partition.Left)
            {
                this.LeftPolygon = new Polygon2DAdorner(polygon);
                this.FileName1 = strFileName;
            }
            else
            {
                this.RightPolygon = new Polygon2DAdorner(polygon);
                this.FileName2 = strFileName;
            }
            this.LeftPolygon.ShowIndices = this.showIndicesMenuItem.Checked;
            this.RightPolygon.ShowIndices = this.showIndicesMenuItem.Checked;
        }
Example #11
0
 private void menuItem14_Click(object sender, System.EventArgs e)
 {
     XWFParser parser = new XWFParser("test.xml");
     Polygon2D polygon = parser.Read();
     this.LeftPolygon = new Polygon2DAdorner(polygon);
     this.Invalidate();
 }
        private void AddInnerPoints(Polygon2DAdorner polygon)
        {
            for (int j = 0; j < this.ghostPoint.Count; j++)
            {
                for (int i = 0; i < polygon.internalSegments.Count; i++)
                {
                    int a = (int)(polygon.internalSegments[i].X);
                    int b = (int)(polygon.internalSegments[i].Y);

                    if (a == this.ghostPoint[j].FirstIndex && b == this.ghostPoint[j].LastIndex || a == this.ghostPoint[j].LastIndex && b == this.ghostPoint[j].FirstIndex)
                    {
                        Point2D point = null;
                        LineSegment2D lineSegment = null;

                        lineSegment = new LineSegment2D(polygon.polygon.GetPoint(a), polygon.polygon.GetPoint(b));

                        point = lineSegment.GetPoint(this.ghostPoint[j].LocalPosition);

                        Polygon2DEditor polygonEditor = new Polygon2DEditor(polygon.polygon);

                        polygonEditor.AddInnerPoint(point);

                        break;
                    }
                }
            }
        }
 internal void AppendChild(Polygon2DAdorner child)
 {
     Polygon2DAdorner currentAdorner = this;
     while(currentAdorner.child != null)
     {
         currentAdorner = currentAdorner.child;
     }
     currentAdorner.child = child;
 }