bool BIsReached()
        {
            var node = piercedToTheLeftFrontElemNode ?? piercedToTheRightFrontElemNode;

            if (node != null)
            {
                return(node.Item.Edge.IsAdjacent(b));
            }
            return(piercedEdge.IsAdjacent(b));
        }
Ejemplo n.º 2
0
        static CdtEdge Flip(CdtSite pi, CdtEdge edge)
        {
            Debug.Assert(!edge.IsAdjacent(pi));
            Debug.Assert(edge.CcwTriangle.Contains(pi) || edge.CwTriangle.Contains(pi));
            //get surrounding data
            CdtTriangle t, ot;

            if (edge.CcwTriangle.Contains(pi))
            {
                t  = edge.CcwTriangle;
                ot = edge.CwTriangle;
            }
            else
            {
                t  = edge.CwTriangle;
                ot = edge.CcwTriangle;
            }
            Debug.Assert(t.Contains(pi));
            var eIndex      = t.Edges.Index(edge);
            var eOtherIndex = ot.Edges.Index(edge);

            Debug.Assert(eIndex > -1 && eOtherIndex > -1);
            var pl          = ot.Sites[eOtherIndex + 2];
            var edgeBeforPi = t.Edges[eIndex + 1];
            var edgeBeforPl = ot.Edges[eOtherIndex + 1];

            //changing t
            var newEdge = Cdt.GetOrCreateEdge(pi, pl);

            t.Sites[eIndex + 1] = pl;
            t.Edges[eIndex]     = edgeBeforPl;
            t.Edges[eIndex + 1] = newEdge;
            //changing ot
            ot.Sites[eOtherIndex + 1] = pi;
            ot.Edges[eOtherIndex]     = edgeBeforPi;
            ot.Edges[eOtherIndex + 1] = newEdge;
            //orient the new edge and the two edges that move from one triangle to another
            if (edgeBeforPl.lowerSite == pl)
            {
                edgeBeforPl.CcwTriangle = t;
            }
            else
            {
                edgeBeforPl.CwTriangle = t;
            }

            if (edgeBeforPi.lowerSite == pi)
            {
                edgeBeforPi.CcwTriangle = ot;
            }
            else
            {
                edgeBeforPi.CwTriangle = ot;
            }

            if (newEdge.upperSite == pi)
            {
                newEdge.CcwTriangle = ot;
                newEdge.CwTriangle  = t;
            }
            else
            {
                newEdge.CcwTriangle = t;
                newEdge.CwTriangle  = ot;
            }
            Debug.Assert(CheckTriangle(t));
            Debug.Assert(CheckTriangle(t));
            //ShowFlip(pi, t, ot);
            edge.upperSite.Edges.Remove(edge); //forget the edge
            return(newEdge);
        }
        static CdtEdge Flip(CdtSite pi, CdtEdge edge) {
            Debug.Assert(!edge.IsAdjacent(pi));
            Debug.Assert(edge.CcwTriangle.Contains(pi) || edge.CwTriangle.Contains(pi));
            //get surrounding data
            CdtTriangle t, ot;
            if (edge.CcwTriangle.Contains(pi)) {
                t = edge.CcwTriangle;
                ot = edge.CwTriangle;
            } else {
                t = edge.CwTriangle;
                ot = edge.CcwTriangle;
            }
            Debug.Assert(t.Contains(pi));
            var eIndex = t.Edges.Index(edge);
            var eOtherIndex = ot.Edges.Index(edge);
            Debug.Assert(eIndex > -1 && eOtherIndex > -1);
            var pl = ot.Sites[eOtherIndex + 2];
            var edgeBeforPi = t.Edges[eIndex + 1];
            var edgeBeforPl = ot.Edges[eOtherIndex + 1];

            //changing t 
            var newEdge = Cdt.GetOrCreateEdge(pi, pl);
            t.Sites[eIndex + 1] = pl;
            t.Edges[eIndex] = edgeBeforPl;
            t.Edges[eIndex + 1] = newEdge;
            //changing ot
            ot.Sites[eOtherIndex + 1] = pi;
            ot.Edges[eOtherIndex] = edgeBeforPi;
            ot.Edges[eOtherIndex + 1] = newEdge;
            //orient the new edge and the two edges that move from one triangle to another
            if (edgeBeforPl.lowerSite == pl)
                edgeBeforPl.CcwTriangle = t;
            else
                edgeBeforPl.CwTriangle = t;

            if (edgeBeforPi.lowerSite == pi)
                edgeBeforPi.CcwTriangle = ot;
            else
                edgeBeforPi.CwTriangle = ot;

            if (newEdge.upperSite == pi) {
                newEdge.CcwTriangle = ot;
                newEdge.CwTriangle = t;
            } else {
                newEdge.CcwTriangle = t;
                newEdge.CwTriangle = ot;
            }
            Debug.Assert(CheckTriangle(t));
            Debug.Assert(CheckTriangle(t));
            //ShowFlip(pi, t, ot);
            edge.upperSite.Edges.Remove(edge); //forget the edge 
            return newEdge;
        }