Beispiel #1
0
        internal void AddEdge(HalfEdge edge)
        {
            // Make sure the half edge being added goes from left to right.
            if (edge.InitVertex.X > edge.NextVertex.X)
            {
                edge = edge.Opposite;
            }

            Trapezoid lNeighborTop = null, lNeighborBottom = null;

            foreach (var trap in LocateTrapezoids(edge))
            {
                PlacementNode repl;
                if (trap.Left <= edge.InitVertex.X || trap.Right >= edge.NextVertex.X)
                {
                    repl = _map.UpdateEndTrapezoid(trap, edge, ref lNeighborTop, ref lNeighborBottom);
                }
                else
                {
                    repl = _map.UpdateMiddleTrapezoid(trap, edge, ref lNeighborTop, ref lNeighborBottom);
                }

                foreach (var parent in trap.Node.Parents)
                {
                    parent.ReplaceSon(trap.Node, repl);
                }

                if (Root == null)
                {
                    Root = repl;
                }
            }
        }