Beispiel #1
0
        /// <summary>
        /// Takes 2 stations and cases and returns a list of appropraite endpoints for a
        /// line connection those stations, respecting jumps between databands.
        /// </summary>
        /// <param name="csFrom">Station and case of starting point.</param>
        /// <param name="csTo">Station and case of ending point.</param>
        /// <returns></returns>
        public static List <(SimplePoint2d, SimplePoint2d)> TranslateLine(CaseStation csFrom, CaseStation csTo)
        {
            double stationFrom = csFrom.Station;
            double stationTo   = csTo.Station;

            List <(double, double)> modelXJumps =
                StationToXConverter.FindModelXsOfJumps(stationFrom, stationTo);

            double xFrom = csFrom.X;
            double xTo   = csTo.X;
            List <(double, double)> modelXOfLineEndPoints =
                GetModelXOfLineEndPoints(xFrom, modelXJumps, xTo);

            double yFrom = csFrom.Y;
            double yTo   = csTo.Y;
            List <(double, double)> modelYOfLineEndPoints = GetModelYOfLineEndPoints(yFrom, modelXOfLineEndPoints, yTo);

            var linePoints = new List <(SimplePoint2d, SimplePoint2d)>();
            int linecount  = modelXOfLineEndPoints.Count;

            for (int i = 0; i < linecount; i++)
            {
                double        point1X = modelXOfLineEndPoints[i].Item1;
                double        point1Y = modelYOfLineEndPoints[i].Item1;
                SimplePoint2d point1  = new SimplePoint2d(point1X, point1Y);

                double        point2X = modelXOfLineEndPoints[i].Item2;
                double        point2Y = modelYOfLineEndPoints[i].Item2;
                SimplePoint2d point2  = new SimplePoint2d(point2X, point2Y);

                linePoints.Add((point1, point2));
            }
            return(linePoints);
        }
        private void AddTransition(int assignmentIndex)
        {
            double          station = _assignments[assignmentIndex].FromStation;
            CalculationCase toCase  = _assignments[assignmentIndex].CalcCase;
            CaseStation     csTo    = new CaseStation(toCase, station);

            _caseEntHandler.AddTransition(csTo);
        }
        private void StartCaseLine(int assignmentIndex)
        {
            double          station  = _assignments[assignmentIndex].FromStation;
            CalculationCase calcCase = _assignments[assignmentIndex].CalcCase;
            CaseStation     cs       = new CaseStation(calcCase, station);

            _caseEntHandler.StartCaseLine(cs);
        }
        private void EndCaseLine(int assignmentIndex)
        {
            double          station = _assignments[assignmentIndex].ToStation;
            CalculationCase toCase  = _assignments[assignmentIndex].CalcCase;
            CaseStation     csTo    = new CaseStation(toCase, station);

            _caseEntHandler.EndCaseLine(csTo);
        }
        internal static double StationDelta(CaseStation from, CaseStation to)
        {
            double deltaY =
                Math.Abs(CaseToYConverter.ToY(from.CalcCase) -
                         CaseToYConverter.ToY(to.CalcCase));
            double deltaStation = deltaY / steepness;

            return(deltaStation);
        }
Beispiel #6
0
        public void CreateBlockInsert(CaseStation cs)
        {
            Point3d insertPoint = new Point3d(cs.X, cs.Y, 0);

            using (var blockref = new BlockReference(insertPoint, _blocktable[_blockname])) {
                blockref.Layer = _layername;
                _modelspace.AppendEntity(blockref);
                _trans.AddNewlyCreatedDBObject(blockref, true);
            }
        }
        public void TranslateLine_LineSpanningOneJump_ReturnsCorrectModelCoords()
        {
            CaseStation CSfrom = new CaseStation(CalculationCase.Case1, 55600);
            CaseStation CSto   = new CaseStation(CalculationCase.Case4b, 55700);
            List <(SimplePoint2d, SimplePoint2d)> expected = new List <(SimplePoint2d, SimplePoint2d)> {
                (new SimplePoint2d(3553070.0, 5349924.0), new SimplePoint2d(3553120.0, 5349897.5)),
                (new SimplePoint2d(3554000.0, 5349897.5), new SimplePoint2d(3554050.0, 5349871.0))
            };

            List <(SimplePoint2d, SimplePoint2d)> actual = LineModelCoordTranslator.TranslateLine(CSfrom, CSto);

            for (int i = 0; i < actual.Count; i++)
            {
                output.WriteLine($"{i + 1:00} " +
                                 $"\n -> Exp. - Item1: {expected[i].Item1} --- Item2: {expected[i].Item2}" +
                                 $"\n -> Act. - Item1: {actual[i].Item1} --- Item2: {actual[i].Item2}");
            }

            Assert.Equal(expected, actual);
        }
        public void AddTransition(CaseStation csTo)
        {
            double deltaStation = DeltaStationCalculator.StationDelta(csLast, csTo);

            CalculationCase startPointCase       = csLast.CalcCase;
            double          startPointStation    = csTo.Station - deltaStation / 2;
            CaseStation     TransitionStartPoint = new CaseStation(startPointCase, startPointStation);

            AddBlockInsert(TransitionStartPoint);
            DrawLine(csLast, TransitionStartPoint);

            CalculationCase endPointCase       = csTo.CalcCase;
            double          endPointStation    = csTo.Station + deltaStation / 2;
            CaseStation     TransitionEndPoint = new CaseStation(endPointCase, endPointStation);

            AddBlockInsert(TransitionEndPoint);
            DrawLine(TransitionStartPoint, TransitionEndPoint);

            csLast = TransitionEndPoint;
        }
        public void TranslateLine_LineSpanningMultipleJumps_ReturnsCorrectModelCoords()
        {
            CaseStation CSfrom = new CaseStation(CalculationCase.Case1, 55000);
            CaseStation CSto   = new CaseStation(CalculationCase.Case4b, 59000);
            List <(SimplePoint2d, SimplePoint2d)> expected = new List <(SimplePoint2d, SimplePoint2d)> {
                (new SimplePoint2d(3552470, 5349924), new SimplePoint2d(3553120.00000003, 5349915.38750001)),
                (new SimplePoint2d(3554000, 5349915.38750001), new SimplePoint2d(3554910.00000002, 5349903.33000001)),
                (new SimplePoint2d(3556000, 5349903.33000001), new SimplePoint2d(3557110.00000003, 5349888.62250001)),
                (new SimplePoint2d(3558000, 5349888.62250001), new SimplePoint2d(3559070.00000003, 5349874.445)),
                (new SimplePoint2d(3560000, 5349874.445), new SimplePoint2d(3560259.9999999, 5349871.00000001)),
            };

            List <(SimplePoint2d, SimplePoint2d)> actual = LineModelCoordTranslator.TranslateLine(CSfrom, CSto);

            for (int i = 0; i < actual.Count; i++)
            {
                output.WriteLine($"{i + 1:00} " +
                                 $"\n -> Exp. - Item1: {expected[i].Item1} --- Item2: {expected[i].Item2}" +
                                 $"\n -> Act. - Item1: {actual[i].Item1} --- Item2: {actual[i].Item2}");
            }

            Assert.Equal(expected, actual);
        }
Beispiel #10
0
 internal static Point3d ToPoint3d(this CaseStation cs)
 {
     return(new Point3d(cs.X, cs.Y, 0));
 }
        private void DrawLine(CaseStation csFrom, CaseStation csTo)
        {
            List <(SimplePoint2d, SimplePoint2d)> endPoints = LineModelCoordTranslator.TranslateLine(csFrom, csTo);

            _creator.CreateLines(endPoints);
        }
 private void AddBlockInsert(CaseStation cs)
 {
     _creator.CreateBlockInsert(cs);
 }
 public void EndCaseLine(CaseStation csTo)
 {
     DrawLine(csLast, csTo);
     AddBlockInsert(csTo);
     csLast = null;
 }
 public void StartCaseLine(CaseStation cs)
 {
     AddBlockInsert(cs);
     csLast = cs;
 }