Exemplo n.º 1
0
        private static void EdgeEvent(DTSweepContext tcx, TriangulationPoint ep, TriangulationPoint eq, DelaunayTriangle triangle, TriangulationPoint point)
        {
            TriangulationPoint p1, p2;

            if (tcx.IsDebugEnabled)
            {
                tcx.DTDebugContext.PrimaryTriangle = triangle;
            }

            if (IsEdgeSideOfTriangle(triangle, ep, eq))
            {
                return;
            }

            p1 = triangle.PointCCWFrom(point);
            Orientation o1 = TriangulationUtil.Orient2d(eq, p1, ep);

            if (o1 == Orientation.Collinear)
            {
                // TODO: Split edge in two
                ////            splitEdge( ep, eq, p1 );
                //            edgeEvent( tcx, p1, eq, triangle, point );
                //            edgeEvent( tcx, ep, p1, triangle, p1 );
                //            return;
                throw new PointOnEdgeException("EdgeEvent - Point on constrained edge not supported yet", eq, p1, ep);
            }

            p2 = triangle.PointCWFrom(point);
            Orientation o2 = TriangulationUtil.Orient2d(eq, p2, ep);

            if (o2 == Orientation.Collinear)
            {
                // TODO: Split edge in two
                //            edgeEvent( tcx, p2, eq, triangle, point );
                //            edgeEvent( tcx, ep, p2, triangle, p2 );
                //            return;
                throw new PointOnEdgeException("EdgeEvent - Point on constrained edge not supported yet", eq, p2, ep);
            }

            if (o1 == o2)
            {
                // Need to decide if we are rotating CW or CCW to get to a triangle
                // that will cross edge
                if (o1 == Orientation.CW)
                {
                    triangle = triangle.NeighborCCWFrom(point);
                }
                else
                {
                    triangle = triangle.NeighborCWFrom(point);
                }
                EdgeEvent(tcx, ep, eq, triangle, point);
            }
            else
            {
                // This triangle crosses constraint so lets flippin start!
                FlipEdgeEvent(tcx, ep, eq, triangle, point);
            }
        }
Exemplo n.º 2
0
        private static void RotateTrianglePair(DelaunayTriangle t, TriangulationPoint p, DelaunayTriangle ot, TriangulationPoint op)
        {
            DelaunayTriangle triangle           = t.NeighborCCWFrom(p);
            DelaunayTriangle triangle2          = t.NeighborCWFrom(p);
            DelaunayTriangle triangle3          = ot.NeighborCCWFrom(op);
            DelaunayTriangle triangle4          = ot.NeighborCWFrom(op);
            bool             constrainedEdgeCCW = t.GetConstrainedEdgeCCW(p);
            bool             constrainedEdgeCW  = t.GetConstrainedEdgeCW(p);
            bool             ce              = ot.GetConstrainedEdgeCCW(op);
            bool             flag4           = ot.GetConstrainedEdgeCW(op);
            bool             delaunayEdgeCCW = t.GetDelaunayEdgeCCW(p);
            bool             delaunayEdgeCW  = t.GetDelaunayEdgeCW(p);
            bool             flag7           = ot.GetDelaunayEdgeCCW(op);
            bool             flag8           = ot.GetDelaunayEdgeCW(op);

            t.Legalize(p, op);
            ot.Legalize(op, p);
            ot.SetDelaunayEdgeCCW(p, delaunayEdgeCCW);
            t.SetDelaunayEdgeCW(p, delaunayEdgeCW);
            t.SetDelaunayEdgeCCW(op, flag7);
            ot.SetDelaunayEdgeCW(op, flag8);
            ot.SetConstrainedEdgeCCW(p, constrainedEdgeCCW);
            t.SetConstrainedEdgeCW(p, constrainedEdgeCW);
            t.SetConstrainedEdgeCCW(op, ce);
            ot.SetConstrainedEdgeCW(op, flag4);
            t.Neighbors.Clear();
            ot.Neighbors.Clear();
            if (triangle != null)
            {
                ot.MarkNeighbor(triangle);
            }
            if (triangle2 != null)
            {
                t.MarkNeighbor(triangle2);
            }
            if (triangle3 != null)
            {
                t.MarkNeighbor(triangle3);
            }
            if (triangle4 != null)
            {
                ot.MarkNeighbor(triangle4);
            }
            t.MarkNeighbor(ot);
        }
Exemplo n.º 3
0
 private static void EdgeEvent(DTSweepContext tcx, TriangulationPoint ep, TriangulationPoint eq, DelaunayTriangle triangle, TriangulationPoint point)
 {
     if (tcx.IsDebugEnabled)
     {
         tcx.DTDebugContext.PrimaryTriangle = triangle;
     }
     if (!IsEdgeSideOfTriangle(triangle, ep, eq))
     {
         TriangulationPoint pb          = triangle.PointCCWFrom(point);
         Orientation        orientation = TriangulationUtil.Orient2d(eq, pb, ep);
         if (orientation == Orientation.Collinear)
         {
             throw new PointOnEdgeException("EdgeEvent - Point on constrained edge not supported yet", eq, pb, ep);
         }
         TriangulationPoint point3       = triangle.PointCWFrom(point);
         Orientation        orientation2 = TriangulationUtil.Orient2d(eq, point3, ep);
         if (orientation2 == Orientation.Collinear)
         {
             throw new PointOnEdgeException("EdgeEvent - Point on constrained edge not supported yet", eq, point3, ep);
         }
         if (orientation == orientation2)
         {
             if (orientation == Orientation.CW)
             {
                 triangle = triangle.NeighborCCWFrom(point);
             }
             else
             {
                 triangle = triangle.NeighborCWFrom(point);
             }
             EdgeEvent(tcx, ep, eq, triangle, point);
         }
         else
         {
             FlipEdgeEvent(tcx, ep, eq, triangle, point);
         }
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Rotates a triangle pair one vertex CW
        ///       n2                    n2
        ///  P +-----+             P +-----+
        ///    | t  /|               |\  t |
        ///    |   / |               | \   |
        ///  n1|  /  |n3           n1|  \  |n3
        ///    | /   |    after CW   |   \ |
        ///    |/ oT |               | oT \|
        ///    +-----+ oP            +-----+
        ///       n4                    n4
        /// </summary>
        private static void RotateTrianglePair(DelaunayTriangle t, TriangulationPoint p, DelaunayTriangle ot, TriangulationPoint op)
        {
            DelaunayTriangle n1, n2, n3, n4;

            n1 = t.NeighborCCWFrom(p);
            n2 = t.NeighborCWFrom(p);
            n3 = ot.NeighborCCWFrom(op);
            n4 = ot.NeighborCWFrom(op);

            bool ce1, ce2, ce3, ce4;

            ce1 = t.GetConstrainedEdgeCCW(p);
            ce2 = t.GetConstrainedEdgeCW(p);
            ce3 = ot.GetConstrainedEdgeCCW(op);
            ce4 = ot.GetConstrainedEdgeCW(op);

            bool de1, de2, de3, de4;

            de1 = t.GetDelaunayEdgeCCW(p);
            de2 = t.GetDelaunayEdgeCW(p);
            de3 = ot.GetDelaunayEdgeCCW(op);
            de4 = ot.GetDelaunayEdgeCW(op);

            t.Legalize(p, op);
            ot.Legalize(op, p);

            // Remap dEdge
            ot.SetDelaunayEdgeCCW(p, de1);
            t.SetDelaunayEdgeCW(p, de2);
            t.SetDelaunayEdgeCCW(op, de3);
            ot.SetDelaunayEdgeCW(op, de4);

            // Remap cEdge
            ot.SetConstrainedEdgeCCW(p, ce1);
            t.SetConstrainedEdgeCW(p, ce2);
            t.SetConstrainedEdgeCCW(op, ce3);
            ot.SetConstrainedEdgeCW(op, ce4);

            // Remap neighbors
            // XXX: might optimize the markNeighbor by keeping track of
            //      what side should be assigned to what neighbor after the
            //      rotation. Now mark neighbor does lots of testing to find
            //      the right side.
            t.Neighbors.Clear();
            ot.Neighbors.Clear();
            if (n1 != null)
            {
                ot.MarkNeighbor(n1);
            }
            if (n2 != null)
            {
                t.MarkNeighbor(n2);
            }
            if (n3 != null)
            {
                t.MarkNeighbor(n3);
            }
            if (n4 != null)
            {
                ot.MarkNeighbor(n4);
            }
            t.MarkNeighbor(ot);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Rotates a triangle pair one vertex CW
        ///       n2                    n2
        ///  P +-----+             P +-----+
        ///    | t  /|               |\  t |  
        ///    |   / |               | \   |
        ///  n1|  /  |n3           n1|  \  |n3
        ///    | /   |    after CW   |   \ |
        ///    |/ oT |               | oT \|
        ///    +-----+ oP            +-----+
        ///       n4                    n4
        /// </summary>
        private static void RotateTrianglePair( DelaunayTriangle t, TriangulationPoint p, DelaunayTriangle ot, TriangulationPoint op )
        {
            DelaunayTriangle n1, n2, n3, n4;
            n1 = t.NeighborCCWFrom(p);
            n2 = t.NeighborCWFrom(p);
            n3 = ot.NeighborCCWFrom(op);
            n4 = ot.NeighborCWFrom(op);

            bool ce1, ce2, ce3, ce4;
            ce1 = t.GetConstrainedEdgeCCW(p);
            ce2 = t.GetConstrainedEdgeCW(p);
            ce3 = ot.GetConstrainedEdgeCCW(op);
            ce4 = ot.GetConstrainedEdgeCW(op);

            bool de1, de2, de3, de4;
            de1 = t.GetDelaunayEdgeCCW(p);
            de2 = t.GetDelaunayEdgeCW(p);
            de3 = ot.GetDelaunayEdgeCCW(op);
            de4 = ot.GetDelaunayEdgeCW(op);

            t.Legalize(p, op);
            ot.Legalize(op, p);

            // Remap dEdge
            ot.SetDelaunayEdgeCCW(p, de1);
            t.SetDelaunayEdgeCW(p, de2);
            t.SetDelaunayEdgeCCW(op, de3);
            ot.SetDelaunayEdgeCW(op, de4);

            // Remap cEdge
            ot.SetConstrainedEdgeCCW(p, ce1);
            t.SetConstrainedEdgeCW(p, ce2);
            t.SetConstrainedEdgeCCW(op, ce3);
            ot.SetConstrainedEdgeCW(op, ce4);

            // Remap neighbors
            // XXX: might optimize the markNeighbor by keeping track of
            //      what side should be assigned to what neighbor after the
            //      rotation. Now mark neighbor does lots of testing to find
            //      the right side.
            t.Neighbors.Clear();
            ot.Neighbors.Clear();
            if (n1 != null) ot.MarkNeighbor(n1);
            if (n2 != null) t.MarkNeighbor(n2);
            if (n3 != null) t.MarkNeighbor(n3);
            if (n4 != null) ot.MarkNeighbor(n4);
            t.MarkNeighbor(ot);
        }
Exemplo n.º 6
0
        private static void EdgeEvent( DTSweepContext tcx, TriangulationPoint ep, TriangulationPoint eq, DelaunayTriangle triangle, TriangulationPoint point )
        {
            TriangulationPoint p1, p2;

            if (tcx.IsDebugEnabled) tcx.DTDebugContext.PrimaryTriangle=triangle;

            if (IsEdgeSideOfTriangle(triangle, ep, eq)) return;

            p1 = triangle.PointCCWFrom(point);
            Orientation o1 = TriangulationUtil.Orient2d(eq, p1, ep);
            if (o1 == Orientation.Collinear) {
                // TODO: Split edge in two
                ////            splitEdge( ep, eq, p1 );
                //            edgeEvent( tcx, p1, eq, triangle, point );
                //            edgeEvent( tcx, ep, p1, triangle, p1 );
                //            return;
                throw new PointOnEdgeException("EdgeEvent - Point on constrained edge not supported yet",eq,p1,ep);
            }

            p2 = triangle.PointCWFrom(point);
            Orientation o2 = TriangulationUtil.Orient2d(eq, p2, ep);
            if (o2 == Orientation.Collinear) {
                // TODO: Split edge in two
                //            edgeEvent( tcx, p2, eq, triangle, point );
                //            edgeEvent( tcx, ep, p2, triangle, p2 );
                //            return;
                throw new PointOnEdgeException("EdgeEvent - Point on constrained edge not supported yet",eq,p2,ep);
            }

            if (o1 == o2) {
                // Need to decide if we are rotating CW or CCW to get to a triangle
                // that will cross edge
                if (o1 == Orientation.CW) {
                    triangle = triangle.NeighborCCWFrom(point);
                } else {
                    triangle = triangle.NeighborCWFrom(point);
                }
                EdgeEvent(tcx, ep, eq, triangle, point);
            } else {
                // This triangle crosses constraint so lets flippin start!
                FlipEdgeEvent(tcx, ep, eq, triangle, point);
            }
        }