コード例 #1
0
        private static void FlipEdgeEvent(DTSweepContext tcx, TriangulationPoint ep, TriangulationPoint eq, DelaunayTriangle t, TriangulationPoint p)
        {
            DelaunayTriangle   ot = t.NeighborAcrossFrom(p);
            TriangulationPoint pd = ot.OppositePoint(t, p);

            if (ot == null)
            {
                throw new InvalidOperationException("[BUG:FIXME] FLIP failed due to missing triangle");
            }
            if (tcx.IsDebugEnabled)
            {
                tcx.DTDebugContext.PrimaryTriangle   = t;
                tcx.DTDebugContext.SecondaryTriangle = ot;
            }
            if (TriangulationUtil.InScanArea(p, t.PointCCWFrom(p), t.PointCWFrom(p), pd))
            {
                RotateTrianglePair(t, p, ot, pd);
                tcx.MapTriangleToNodes(t);
                tcx.MapTriangleToNodes(ot);
                if ((p == eq) && (pd == ep))
                {
                    if ((eq == tcx.EdgeEvent.ConstrainedEdge.Q) && (ep == tcx.EdgeEvent.ConstrainedEdge.P))
                    {
                        t.MarkConstrainedEdge(ep, eq);
                        ot.MarkConstrainedEdge(ep, eq);
                        Legalize(tcx, t);
                        Legalize(tcx, ot);
                    }
                }
                else
                {
                    Orientation o = TriangulationUtil.Orient2d(eq, pd, ep);
                    t = NextFlipTriangle(tcx, o, t, ot, p, pd);
                    FlipEdgeEvent(tcx, ep, eq, t, p);
                }
            }
            else
            {
                TriangulationPoint point2 = NextFlipPoint(ep, eq, ot, pd);
                FlipScanEdgeEvent(tcx, ep, eq, t, ot, point2);
                EdgeEvent(tcx, ep, eq, t, p);
            }
        }
コード例 #2
0
 public void MarkEdge(DelaunayTriangle triangle)
 {
     for (int i = 0; i < 3; i++) if ( EdgeIsConstrained[i] ) {
         triangle.MarkConstrainedEdge(Points[(i+1)%3], Points[(i+2)%3]);
     }
 }
コード例 #3
0
ファイル: DTSweep.cs プロジェクト: doctorpangloss/Cordon2
 private static bool IsEdgeSideOfTriangle( DelaunayTriangle triangle, TriangulationPoint ep, TriangulationPoint eq )
 {
     int index = triangle.EdgeIndex(ep, eq);
     if ( index == -1 ) return false;
     triangle.MarkConstrainedEdge(index);
     triangle = triangle.Neighbors[index];
     if (triangle != null) triangle.MarkConstrainedEdge(ep, eq);
     return true;
 }
コード例 #4
0
ファイル: DTSweep.cs プロジェクト: doctorpangloss/Cordon2
        private static void FlipEdgeEvent( DTSweepContext tcx, TriangulationPoint ep, TriangulationPoint eq, DelaunayTriangle t, TriangulationPoint p )
        {
            DelaunayTriangle ot = t.NeighborAcrossFrom(p);
            TriangulationPoint op = ot.OppositePoint(t, p);

            if (ot == null) {
                // If we want to integrate the fillEdgeEvent do it here
                // With current implementation we should never get here
                throw new InvalidOperationException("[BUG:FIXME] FLIP failed due to missing triangle");
            }

            if (tcx.IsDebugEnabled) {
                tcx.DTDebugContext.PrimaryTriangle   = t;
                tcx.DTDebugContext.SecondaryTriangle = ot;
            } // TODO: remove

            bool inScanArea = TriangulationUtil.InScanArea(p, t.PointCCWFrom(p), t.PointCWFrom(p), op);
            if (inScanArea) {
                // Lets rotate shared edge one vertex CW
                RotateTrianglePair(t, p, ot, op);
                tcx.MapTriangleToNodes(t);
                tcx.MapTriangleToNodes(ot);

                if (p == eq && op == ep) {
                    if (eq == tcx.EdgeEvent.ConstrainedEdge.Q
                        && ep == tcx.EdgeEvent.ConstrainedEdge.P) {
                        if (tcx.IsDebugEnabled) Console.WriteLine("[FLIP] - constrained edge done"); // TODO: remove
                        t.MarkConstrainedEdge(ep, eq);
                        ot.MarkConstrainedEdge(ep, eq);
                        Legalize(tcx, t);
                        Legalize(tcx, ot);
                    } else {
                        if (tcx.IsDebugEnabled) Console.WriteLine("[FLIP] - subedge done"); // TODO: remove
                        // XXX: I think one of the triangles should be legalized here?
                    }
                } else {
                    if (tcx.IsDebugEnabled) Console.WriteLine("[FLIP] - flipping and continuing with triangle still crossing edge"); // TODO: remove
                    Orientation o = TriangulationUtil.Orient2d(eq, op, ep);
                    t = NextFlipTriangle(tcx, o, t, ot, p, op);
                    FlipEdgeEvent(tcx, ep, eq, t, p);
                }
            } else {
                TriangulationPoint newP = NextFlipPoint(ep, eq, ot, op);
                FlipScanEdgeEvent(tcx, ep, eq, t, ot, newP);
                EdgeEvent(tcx, ep, eq, t, p);
            }
        }