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 HighQualityTriangulator(Polygon2D a, Polygon2D b)
        {
            if (!a.isRegular && !b.isRegular)
            {
                throw (new ArgumentException());
            }
            if (a.VertexCount != b.VertexCount)
            {
                throw (new ArgumentException());
            }

            FirstPolygons = new Polygon2DDiviser(a);
            SecondPolygons = new Polygon2DDiviser(b);
        }
        public void Divide()
        {
            UpdateStatus(this, "Dividing...");
            targetDiviser.UpdateStatus += new Microsoft.VS.Akira.Triangulations.TargetDiviser.ShowStatus(UpdateStatus);
            targetDiviser.Divide();
            Polygon2D poly = this.firstPolygon;
            this.firstPolygonCollection.Add(this.firstPolygon);
            this.secondPolygonCollection.Add(this.secondPolygon);
            UpdateStatus(this, "Mapping...");
            for (int i = 0; i < targetDiviser.Divisers.Count; i++)
            {
                int first_index = this.secondPolygon.GetPointIndex(targetDiviser.Divisers[i].FirstPoint);
                int second_index = this.secondPolygon.GetPointIndex(targetDiviser.Divisers[i].LastPoint);

                LineSegment2D line = new LineSegment2D(this.firstPolygon.GetPoint(first_index), this.firstPolygon.GetPoint(second_index));

                for (int j = 0; j < this.firstPolygonCollection.Count; j++)
                {
                    if (this.firstPolygonCollection[j].HasVertex(line.FirstPoint) != Polygon2D.NoSuchPoint
                        &&this.firstPolygonCollection[j].HasVertex(line.LastPoint) != Polygon2D.NoSuchPoint)
                    {
                        poly = this.firstPolygonCollection[j];
                        this.firstPolygonCollection.Remove(j);
                        break;
                    }
                }
                int from = 0;
                int to = 0;

                from = poly.GetPointIndex(line.FirstPoint);
                to = poly.GetPointIndex(line.LastPoint);

                linkMaker = new Polygon2DLinkMaker(poly, from, to);

                linkMaker.Divide();
                int extraPoints = linkMaker.LinkDistance - 1;
                linkMaker.BuildPath();
                Polygon2DDiviser pd = new Polygon2DDiviser(poly);
                pd.DividedBy(linkMaker.LinkDivisers, poly);
                this.firstPolygonCollection.Add(pd.SubDivision[1]);
                this.firstPolygonCollection.Add(pd.SubDivision[2]);

                //divide target polygon
                line = targetDiviser.Divisers[i];

                for (int j = 0; j < this.secondPolygonCollection.Count; j++)
                {
                    if (this.secondPolygonCollection[j].HasVertex(line.FirstPoint) != Polygon2D.NoSuchPoint
                        &&this.secondPolygonCollection[j].HasVertex(line.LastPoint) != Polygon2D.NoSuchPoint)
                    {
                        poly = this.secondPolygonCollection[j];
                        this.secondPolygonCollection.Remove(j);
                        break;
                    }
                }

                from = poly.GetPointIndex(line.FirstPoint);
                to = poly.GetPointIndex(line.LastPoint);

                Point2DCollection path = line.ToPath(extraPoints);

                pd = new Polygon2DDiviser(poly);
                pd.DividedBy(path, poly);

                this.secondPolygonCollection.Add(pd.SubDivision[1]);
                this.secondPolygonCollection.Add(pd.SubDivision[2]);
            }
        }