示例#1
0
        internal void Flipping(GhostTriangle2DCollection ghostTriangles)
        {
            for (int i = 0; i < ghostTriangles.Count; i++)
            {
                for (int j = i; j < ghostTriangles.Count; j++)
                {
                    GhostTriangle2D t1 = ghostTriangles[i];
                    GhostTriangle2D t2 = ghostTriangles[j];

                    if (isNeighbor(t1, t2))
                    {
                        Polygon2D p1 = FlipArea(t1, t2, this.FirstPolygon);
                        Polygon2D p2 = FlipArea(t1, t2, this.SecondPolygon);

                        if (p1.isConvex && p2.isConvex)
                        {
                            double d1 = QualityDeterminer.CompatibleTriangleQuality(t1, this.FirstPolygon, this.SecondPolygon);
                            double d2 = QualityDeterminer.CompatibleTriangleQuality(t2, this.FirstPolygon, this.SecondPolygon);

                            double d = Math.Min(d1, d2);

                            FlipGhostTriangle(t1, t2);

                            d1 = QualityDeterminer.CompatibleTriangleQuality(t1, this.FirstPolygon, this.SecondPolygon);
                            d2 = QualityDeterminer.CompatibleTriangleQuality(t2, this.FirstPolygon, this.SecondPolygon);

                            if (d > Math.Min(d1, d2))
                            {
                                FlipGhostTriangle(t1, t2);
                            }
                        }
                    }
                }
            }
        }
 private GhostTriangle2D Split(GhostTriangle2D ghostTriangle)
 {
     if (QualityDeterminer.TriangleQuality(ghostTriangle, firstPolygon) < QualityDeterminer.TriangleQuality(ghostTriangle, secondPolygon))
     {
         return(Split(this.firstPolygon, this.secondPolygon, ghostTriangle));
     }
     else
     {
         return(Split(this.secondPolygon, this.firstPolygon, ghostTriangle));
     }
 }
        internal void Split(GhostTriangle2DCollection ghostTriangles)
        {
            int Count = ghostTriangles.Count;

            for (int i = 0; i < Count; i++)
            {
                Triangle2D t1 = ghostTriangles[i].ToTriangle(firstPolygon);
                Triangle2D t2 = ghostTriangles[i].ToTriangle(secondPolygon);

                double d1 = QualityDeterminer.ShapeQuality(t1);
                double d2 = QualityDeterminer.ShapeQuality(t2);

                if (d1 < TriangleDiviser.ShapeTolerance || d2 < TriangleDiviser.ShapeTolerance)
                {
                    GhostTriangle2D ghostTriangle = Split(ghostTriangles[i]);
                    SplitGhostTriangle(ghostTriangles, ghostTriangle);
                }
            }
        }
        internal void Divide(GhostTriangle2DCollection ghostTriangles)
        {
            int Count = ghostTriangles.Count;

            for (int i = 0; i < Count; i++)
            {
                if (QualityDeterminer.AreaQuality(ghostTriangles[i], firstPolygon) < AreaTolerance || QualityDeterminer.AreaQuality(ghostTriangles[i], secondPolygon) < AreaTolerance)
                {
                    Divide(ghostTriangles[i]);

                    GhostTriangle2D ghostTriangle = new GhostTriangle2D(ghostTriangles[i].A, ghostTriangles[i].B, this.firstPolygon.PointCount - 1);

                    ghostTriangles.Add(ghostTriangle);

                    ghostTriangle = new GhostTriangle2D(ghostTriangles[i].A, this.firstPolygon.PointCount - 1, ghostTriangles[i].C);

                    ghostTriangles.Add(ghostTriangle);

                    ghostTriangles[i].A = this.firstPolygon.PointCount - 1;
                }
            }
        }