void CreateVariablesOfLongestSegment(LongestNudgedSegment segment) { if (!segment.IsFixed) { var leftBound = segment.GetLeftBound(); var rightBound = segment.GetRightBound(); if (leftBound >= rightBound) //don't move the segment from the way it was generated { Solver.AddFixedVariable(segment.Id, SegmentPosition(segment, NudgingDirection)); segment.IsFixed = true; } else { Solver.AddVariable(segment.Id, SegmentPosition(segment, NudgingDirection), segment.IdealPosition, segment.Width); // Debug.Assert(leftBound + Curve.DistanceEpsilon < rightBound); //this assert does not hold for overlaps if (leftBound != Double.NegativeInfinity) { Solver.SetLowBound(leftBound, segment.Id); } if (rightBound != Double.PositiveInfinity) { Solver.SetUpperBound(segment.Id, rightBound); } } } else { Solver.AddFixedVariable(segment.Id, SegmentPosition(segment, NudgingDirection)); } }
static void MoveLongestSegIdealPositionsInsideFeasibleInterval(LongestNudgedSegment seg) { if (seg.IsFixed) { return; } var leftBound = seg.GetLeftBound(); var rightBound = seg.GetRightBound(); if (seg.IdealPosition < leftBound) { seg.IdealPosition = leftBound; } else if (seg.IdealPosition > rightBound) { seg.IdealPosition = rightBound; } }
void ShowSegmentBounds(LongestNudgedSegment segment) { // ReSharper restore UnusedMember.Local var dd = GetObstacleBoundaries(Obstacles, "black"); var segtop = segment.Edges.Max(e => Math.Max(e.Source.Y, e.Target.Y)); var segbottom = segment.Edges.Min(e => Math.Min(e.Source.Y, e.Target.Y)); var segx = segment.Start.X; var seg = new DebugCurve(80, 1, "brown", new LineSegment(new Point(segx, segbottom), new Point(segx, segtop))); var leftbound = new DebugCurve(80, 1.0, "red", new LineSegment(new Point(segment.GetLeftBound(), segbottom), new Point(segment.GetLeftBound(), segtop))); var rightbound = new DebugCurve(80, 1, "green", new LineSegment(new Point(segment.GetRightBound(), segbottom), new Point(segment.GetRightBound(), segtop))); LayoutAlgorithmSettings.ShowDebugCurvesEnumeration(dd.Concat(new[] { seg, leftbound, rightbound })); }
void ShowSegmentBounds(LongestNudgedSegment segment) { // ReSharper restore UnusedMember.Local var dd = GetObstacleBoundaries(Obstacles, "black"); var segtop = segment.Edges.Max(e => Math.Max(e.Source.Y, e.Target.Y)); var segbottom = segment.Edges.Min(e => Math.Min(e.Source.Y, e.Target.Y)); var segx = segment.Start.X; var seg = new DebugCurve(80, 1, "brown", new LineSegment(new Point(segx, segbottom), new Point(segx, segtop))); var leftbound = new DebugCurve(80, 1.0, "red", new LineSegment(new Point(segment.GetLeftBound(), segbottom), new Point(segment.GetLeftBound(), segtop))); var rightbound = new DebugCurve(80, 1, "green", new LineSegment(new Point(segment.GetRightBound(), segbottom), new Point(segment.GetRightBound(), segtop))); LayoutAlgorithmSettings.ShowDebugCurvesEnumeration(dd.Concat(new[] { seg, leftbound, rightbound })); }
void CreateVariablesOfLongestSegment(LongestNudgedSegment segment) { if (!segment.IsFixed) { var leftBound = segment.GetLeftBound(); var rightBound = segment.GetRightBound(); if (leftBound >= rightBound) {//don't move the segment from the way it was generated Solver.AddFixedVariable(segment.Id, SegmentPosition(segment, NudgingDirection)); segment.IsFixed = true; } else { Solver.AddVariable(segment.Id, SegmentPosition(segment, NudgingDirection), segment.IdealPosition, segment.Width); // Debug.Assert(leftBound + Curve.DistanceEpsilon < rightBound); //this assert does not hold for overlaps if (leftBound != Double.NegativeInfinity) Solver.SetLowBound(leftBound, segment.Id); if (rightBound != Double.PositiveInfinity) Solver.SetUpperBound(segment.Id, rightBound); } } else Solver.AddFixedVariable(segment.Id, SegmentPosition(segment, NudgingDirection)); }
static void MoveLongestSegIdealPositionsInsideFeasibleInterval(LongestNudgedSegment seg) { if (seg.IsFixed) return; var leftBound = seg.GetLeftBound(); var rightBound = seg.GetRightBound(); if (seg.IdealPosition < leftBound) seg.IdealPosition=leftBound; else if( seg.IdealPosition> rightBound) seg.IdealPosition=rightBound; }