Пример #1
0
        internal void AddEdge(PathEdge edge)
        {
            if (Edges.Count == 0)
            {
                var dir = (edge.Target - edge.Source).CompassDirection;
                switch (dir)
                {
                case Core.Geometry.Directions.South:
                    dir = Core.Geometry.Directions.North;
                    break;

                case Core.Geometry.Directions.West:
                    dir = Core.Geometry.Directions.East;
                    break;
                }
                CompassDirection = dir;
                start            = edge.Source;
                end = edge.Source; //does not matter; it will be fixed immediately
            }

            switch (CompassDirection)
            {
            case Core.Geometry.Directions.North:
                TryPointForStartAndEndNorth(edge.Source);
                TryPointForStartAndEndNorth(edge.Target);
                break;

            case Core.Geometry.Directions.East:
                TryPointForStartAndEndEast(edge.Source);
                TryPointForStartAndEndEast(edge.Target);
                break;
            }
            Edges.Add(edge);
        }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="axisEdge">axisEdge together with the axisEdgeIsReversed parameter define direction of the movement over the paths</param>
 /// <param name="direction"></param>
 /// <returns></returns>
 static int CompareInDirectionStartingFromAxisEdge(PathEdge x, PathEdge y, AxisEdge axisEdge, Directions direction)
 {
     while (true)
     {
         x = GetNextPathEdgeInDirection(x, axisEdge, direction);
         if (x == null)
         {
             return(0);
         }
         y = GetNextPathEdgeInDirection(y, axisEdge, direction);
         if (y == null)
         {
             return(0);
         }
         if (x.AxisEdge == y.AxisEdge)
         {
             direction = FindContinuedDirection(axisEdge, direction, x.AxisEdge);
             axisEdge  = x.AxisEdge;
             int r = GetExistingOrder(x, y);
             if (r == NotOrdered)
             {
                 continue;
             }
             return(direction == axisEdge.Direction ? r : -r);
         }
         //there is a fork
         var forkVertex = direction == axisEdge.Direction ? axisEdge.Target : axisEdge.Source;
         var xFork      = OtherVertex(x.AxisEdge, forkVertex);
         var yFork      = OtherVertex(y.AxisEdge, forkVertex);
         var projection = ProjectionForCompare(axisEdge, direction != axisEdge.Direction);
         return(projection(xFork.Point).CompareTo(projection(yFork.Point)));
     }
 }
 internal void AddEdge(PathEdge edge) {
     edge.Path = this;
     Debug.Assert(edge.Source == LastEdge.Target);
     LastEdge.Next = edge;
     edge.Prev = LastEdge;
     LastEdge = edge;
 }
        internal void AddEdge(PathEdge edge) {
            if (Edges.Count == 0) {
                var dir = (edge.Target - edge.Source).CompassDirection;
                switch (dir) {
                    case Core.Geometry.Directions.South:
                        dir = Core.Geometry.Directions.North;
                        break;
                    case Core.Geometry.Directions.West:
                        dir = Core.Geometry.Directions.East;
                        break;
                }
                CompassDirection = dir;
                start = edge.Source;
                end = edge.Source; //does not matter; it will be fixed immediately
            }

            switch (CompassDirection) {
                case Core.Geometry.Directions.North:
                    TryPointForStartAndEndNorth(edge.Source);
                    TryPointForStartAndEndNorth(edge.Target);
                    break;
                case Core.Geometry.Directions.East:
                    TryPointForStartAndEndEast(edge.Source);
                    TryPointForStartAndEndEast(edge.Target);
                    break;
            }
            Edges.Add(edge);
        }
Пример #5
0
 internal void AddEdge(PathEdge edge)
 {
     edge.Path = this;
     Debug.Assert(edge.Source == LastEdge.Target);
     LastEdge.Next = edge;
     edge.Prev     = LastEdge;
     LastEdge      = edge;
 }
Пример #6
0
        static int CompareTwoPathEdges(PathEdge x, PathEdge y)
        {
            if (x == y)
            {
                return(0);
            }
            Debug.Assert(x.AxisEdge == y.AxisEdge);
            //Nudger.ShowOrderedPaths(null, new[] { x.Path, y.Path }, x.AxisEdge.SourcePoint, x.AxisEdge.TargetPoint);
            int r = CompareInDirectionStartingFromAxisEdge(x, y, x.AxisEdge, x.AxisEdge.Direction);

            return(r != 0 ? r : -CompareInDirectionStartingFromAxisEdge(x, y, x.AxisEdge, CompassVector.OppositeDir(x.AxisEdge.Direction)));
        }
        void CreateConstraintsOfThePathOrder(IEnumerable <PathEdge> pathOrder)
        {
            PathEdge prevEdge = null;

            foreach (var pathEdge in pathOrder.Where(p => p.LongestNudgedSegment != null))
            {
                if (prevEdge != null)
                {
                    ConstraintTwoLongestSegs(prevEdge.LongestNudgedSegment, pathEdge.LongestNudgedSegment);
                }
                prevEdge = pathEdge;
            }
        }
Пример #8
0
        static int GetExistingOrder(PathEdge x, PathEdge y)
        {
            int xi = x.Index;

            if (xi == -1)
            {
                return(NotOrdered);
            }
            int yi = y.Index;

            Debug.Assert(yi != -1);
            return(xi.CompareTo(yi));
        }
        static void SetWidthsOfArrowheadsForEdge(Path path)
        {
            var edgeGeom = path.EdgeGeometry;

            if (edgeGeom.TargetArrowhead != null)
            {
                PathEdge pathEdge = path.LastEdge;
                pathEdge.Width = Math.Max(edgeGeom.TargetArrowhead.Width, pathEdge.Width);
            }
            if (edgeGeom.SourceArrowhead != null)
            {
                PathEdge pathEdge = path.FirstEdge;
                pathEdge.Width = Math.Max(edgeGeom.SourceArrowhead.Width, pathEdge.Width);
            }
        }
 public static bool EdgesAreParallel(PathEdge edge, PathEdge pathEdge) {
     return VectorsAreParallel(edge.AxisEdge.TargetPoint-edge.AxisEdge.SourcePoint,
                               pathEdge.AxisEdge.TargetPoint-pathEdge.AxisEdge.SourcePoint);
 }
 Point ShiftedEdgePositionOfTarget(PathEdge e)
 {
     return(e.LongestNudgedSegment != null || e.Next == null
                ? ShiftedPoint(e.Target, e.LongestNudgedSegment)
                : ShiftedPoint(e.Next.Source, e.Next.LongestNudgedSegment));
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="axisEdge">axisEdge together with the axisEdgeIsReversed parameter define direction of the movement over the paths</param>
 /// <param name="direction"></param>
 /// <returns></returns>
 static int CompareInDirectionStartingFromAxisEdge(PathEdge x, PathEdge y, AxisEdge axisEdge, Directions direction){
     while (true) {
         x = GetNextPathEdgeInDirection(x, axisEdge, direction);
         if (x == null)
             return 0;
         y = GetNextPathEdgeInDirection(y, axisEdge, direction);
         if (y == null)
             return 0;
         if (x.AxisEdge == y.AxisEdge) {
             direction = FindContinuedDirection(axisEdge, direction, x.AxisEdge);
             axisEdge = x.AxisEdge;
             int r = GetExistingOrder(x, y);
             if (r == NotOrdered) continue;
             return direction == axisEdge.Direction ? r : -r;
         }
         //there is a fork
         var forkVertex = direction == axisEdge.Direction ? axisEdge.Target : axisEdge.Source;
         var xFork = OtherVertex(x.AxisEdge, forkVertex);
         var yFork = OtherVertex(y.AxisEdge, forkVertex);
         var projection = ProjectionForCompare(axisEdge, direction != axisEdge.Direction);
         return projection(xFork.Point).CompareTo(projection(yFork.Point));
     }
 }
Пример #13
0
 static PathEdge GetNextPathEdgeInDirection(PathEdge e, AxisEdge axisEdge, Directions direction)
 {
     Debug.Assert(e.AxisEdge == axisEdge);
     return(axisEdge.Direction == direction ? (e.Reversed ? e.Prev : e.Next) : (e.Reversed ? e.Next : e.Prev));
 }
 public static bool EdgesAreParallel(PathEdge edge, PathEdge pathEdge)
 {
     return(VectorsAreParallel(edge.AxisEdge.TargetPoint - edge.AxisEdge.SourcePoint,
                               pathEdge.AxisEdge.TargetPoint - pathEdge.AxisEdge.SourcePoint));
 }
 static PathEdge GetNextPathEdgeInDirection(PathEdge e, AxisEdge axisEdge, Directions direction) {
     Debug.Assert(e.AxisEdge==axisEdge);
     return axisEdge.Direction == direction ? (e.Reversed ? e.Prev : e.Next) : (e.Reversed ? e.Next : e.Prev);
 }
 static int GetExistingOrder(PathEdge x, PathEdge y ) {
     int xi = x.Index;
     if (xi == -1)
         return NotOrdered;
     int yi = y.Index;
     Debug.Assert(yi!=-1);
     return xi.CompareTo(yi);
 }
 static int CompareTwoPathEdges(PathEdge x, PathEdge y) {
     if (x == y)
         return 0;
     Debug.Assert(x.AxisEdge == y.AxisEdge);
     //Nudger.ShowOrderedPaths(null, new[] { x.Path, y.Path }, x.AxisEdge.SourcePoint, x.AxisEdge.TargetPoint);
     int r = CompareInDirectionStartingFromAxisEdge(x, y, x.AxisEdge, x.AxisEdge.Direction);
     return r!=0 ? r : -CompareInDirectionStartingFromAxisEdge(x, y, x.AxisEdge, CompassVector.OppositeDir(x.AxisEdge.Direction));
 }
 Point ShiftedEdgePositionOfTarget(PathEdge e) {
     return e.LongestNudgedSegment != null || e.Next == null
                ? ShiftedPoint(e.Target, e.LongestNudgedSegment)
                : ShiftedPoint(e.Next.Source, e.Next.LongestNudgedSegment);
 }
Пример #19
0
 internal void SetFirstEdge(PathEdge edge) {
     LastEdge = FirstEdge = edge;
     edge.Path = this;
 }
Пример #20
0
 internal void SetFirstEdge(PathEdge edge)
 {
     LastEdge  = FirstEdge = edge;
     edge.Path = this;
 }