示例#1
0
 /// <summary>
 ///     Fills the edge event using the specified tcx
 /// </summary>
 /// <param name="tcx">The tcx</param>
 /// <param name="edge">The edge</param>
 /// <param name="node">The node</param>
 private static void FillEdgeEvent(DtSweepContext tcx, DtSweepConstraint edge, AdvancingFrontNode node)
 {
     if (tcx.EdgeEvent.Right)
     {
         FillRightAboveEdgeEvent(tcx, edge, node);
     }
     else
     {
         FillLeftAboveEdgeEvent(tcx, edge, node);
     }
 }
示例#2
0
 /// <summary>
 ///     Fills the left above edge event using the specified tcx
 /// </summary>
 /// <param name="tcx">The tcx</param>
 /// <param name="edge">The edge</param>
 /// <param name="node">The node</param>
 private static void FillLeftAboveEdgeEvent(DtSweepContext tcx, DtSweepConstraint edge, AdvancingFrontNode node)
 {
     while (node.Prev.Point.X > edge.P.X)
     {
         // Check if next node is below the edge
         Orientation o1 = TriangulationUtil.Orient2d(edge.Q, node.Prev.Point, edge.P);
         if (o1 == Orientation.Cw)
         {
             FillLeftBelowEdgeEvent(tcx, edge, node);
         }
         else
         {
             node = node.Prev;
         }
     }
 }
示例#3
0
 /// <summary>
 ///     Fills the left concave edge event using the specified tcx
 /// </summary>
 /// <param name="tcx">The tcx</param>
 /// <param name="edge">The edge</param>
 /// <param name="node">The node</param>
 private static void FillLeftConcaveEdgeEvent(DtSweepContext tcx, DtSweepConstraint edge,
                                              AdvancingFrontNode node)
 {
     Fill(tcx, node.Prev);
     if (node.Prev.Point != edge.P)
     {
         // GetNext above or below edge?
         if (TriangulationUtil.Orient2d(edge.Q, node.Prev.Point, edge.P) == Orientation.Cw)
         {
             // Below
             if (TriangulationUtil.Orient2d(node.Point, node.Prev.Point, node.Prev.Prev.Point) == Orientation.Cw)
             {
                 // GetNext is concave
                 FillLeftConcaveEdgeEvent(tcx, edge, node);
             }
         }
     }
 }
示例#4
0
        /// <summary>
        ///     Fills the left below edge event using the specified tcx
        /// </summary>
        /// <param name="tcx">The tcx</param>
        /// <param name="edge">The edge</param>
        /// <param name="node">The node</param>
        private static void FillLeftBelowEdgeEvent(DtSweepContext tcx, DtSweepConstraint edge, AdvancingFrontNode node)
        {
            if (node.Point.X > edge.P.X)
            {
                if (TriangulationUtil.Orient2d(node.Point, node.Prev.Point, node.Prev.Prev.Point) == Orientation.Cw)
                {
                    // Concave
                    FillLeftConcaveEdgeEvent(tcx, edge, node);
                }
                else
                {
                    // Convex
                    FillLeftConvexEdgeEvent(tcx, edge, node);

                    // Retry this one
                    FillLeftBelowEdgeEvent(tcx, edge, node);
                }
            }
        }
示例#5
0
 /// <summary>
 ///     Fills the right convex edge event using the specified tcx
 /// </summary>
 /// <param name="tcx">The tcx</param>
 /// <param name="edge">The edge</param>
 /// <param name="node">The node</param>
 private static void FillRightConvexEdgeEvent(DtSweepContext tcx, DtSweepConstraint edge,
                                              AdvancingFrontNode node)
 {
     // GetNext concave or convex?
     if (TriangulationUtil.Orient2d(node.Next.Point, node.Next.Next.Point, node.Next.Next.Next.Point) ==
         Orientation.Ccw)
     {
         // Concave
         FillRightConcaveEdgeEvent(tcx, edge, node.Next);
     }
     else
     {
         // Convex
         // GetNext above or below edge?
         if (TriangulationUtil.Orient2d(edge.Q, node.Next.Next.Point, edge.P) == Orientation.Ccw)
         {
             // Below
             FillRightConvexEdgeEvent(tcx, edge, node.Next);
         }
     }
 }
示例#6
0
        /// <summary>
        ///     Edges the event using the specified tcx
        /// </summary>
        /// <param name="tcx">The tcx</param>
        /// <param name="edge">The edge</param>
        /// <param name="node">The node</param>
        private static void EdgeEvent(DtSweepContext tcx, DtSweepConstraint edge, AdvancingFrontNode node)
        {
            try
            {
                tcx.EdgeEvent.ConstrainedEdge = edge;
                tcx.EdgeEvent.Right           = edge.P.X > edge.Q.X;

                if (IsEdgeSideOfTriangle(node.Triangle, edge.P, edge.Q))
                {
                    return;
                }

                // For now we will do all needed filling
                // TODO: integrate with flip process might give some better performance
                //       but for now this avoid the issue with cases that needs both flips and fills
                FillEdgeEvent(tcx, edge, node);

                EdgeEvent(tcx, edge.P, edge.Q, node.Triangle, edge.Q);
            }
            catch (PointOnEdgeException e)
            {
                Debug.WriteLine("Skipping Edge: {0}", e.Message);
            }
        }