Exemplo n.º 1
0
        private (ISiteModel siteModelId, Guid alignmentId) ConstructSimpleArcNFFFileModel()
        {
            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();

            var arc = new NFFLineworkArcEntity(0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, true, false)
            {
                StartStation = 0
            };

            var alignment = new NFFGuidableAlignmentEntity();

            alignment.Entities.Add(arc);

            var alignmentGuid = Guid.NewGuid();
            var testDesign    = new SVLAlignmentDesign(alignment);

            siteModel.Alignments.AddAlignmentDetails(alignmentGuid, new DesignDescriptor(alignmentGuid, "", ""), BoundingWorldExtent3D.Full());

            var mockDesignFiles = new Mock <IDesignFiles>();

            mockDesignFiles.Setup(x => x.Lock(It.IsAny <Guid>(), It.IsAny <ISiteModelBase>(), It.IsAny <double>(), out It.Ref <DesignLoadResult> .IsAny))
            .Returns(new GobbleDesignFilesLockReturns((Guid designUid, ISiteModelBase siteModel, double cellSize, out DesignLoadResult result) =>
            {
                result = DesignLoadResult.Success;
                return(testDesign);
            }));

            DIBuilder.
            Continue()
            .Add(x => x.AddSingleton(mockDesignFiles.Object))
            .Complete();

            return(siteModel, alignmentGuid);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads the content of an SVL file into a memory model for use
        /// </summary>
        public override DesignLoadResult LoadFromFile(string fileName, bool saveIndexFiles = true)
        {
            DesignLoadResult result;
            var nffFile = NFFFile.CreateFromFile(fileName);

            try
            {
                result = nffFile.GuidanceAlignments.Count > 0 ? DesignLoadResult.NoAlignmentsFound : DesignLoadResult.NoMasterAlignmentsFound;

                for (var i = 0; i < nffFile.GuidanceAlignments.Count; i++)
                {
                    if (nffFile.GuidanceAlignments[i].IsMasterAlignment())
                    {
                        _data = nffFile.GuidanceAlignments[i];

                        nffFile.GuidanceAlignments.RemoveAt(i);

                        if (_data != null)
                        {
                            _boundingBox = _data.BoundingBox();
                            result       = DesignLoadResult.Success;
                        }

                        break;
                    }
                }

                if (result == DesignLoadResult.NoAlignmentsFound)
                {
                    _log.LogDebug($"SVL file {fileName} contains no guidance alignments");
                }

                if (result == DesignLoadResult.NoMasterAlignmentsFound)
                {
                    _log.LogDebug($"SVL file {fileName} contains {nffFile.GuidanceAlignments.Count} alignments, none of which are master alignments");
                }
            }
            catch (Exception e)
            {
                _log.LogError(e, $"Exception in {nameof(LoadFromFile)}");
                result = DesignLoadResult.UnknownFailure;
            }

            return(result);
        }
Exemplo n.º 3
0
        public bool ConstructSVLCenterlineDXFAlignment(NFFGuidableAlignmentEntity alignment,
                                                       out DesignProfilerRequestResult calcResult, out MemoryStream ms)
        {
            ms = null;
            if ((calcResult = Validate(alignment)) != DesignProfilerRequestResult.OK)
            {
                return(false);
            }

            DXF = new DXFFile();
            DXF.Layers.Add("B");

            // Run through the entities in the alignment and add them to the DXF file
            for (var I = 0; I < alignment.Entities.Count; I++)
            {
                AddEntityToDXF(alignment.Entities[I]);
            }

            // Construct the stationing text entities along the alignment
            var StationIncrement = AlignmentLabelingInterval;
            var CurrentStation   = alignment.StartStation;

            while (CurrentStation <= alignment.EndStation + 0.001)
            {
                alignment.ComputeXY(CurrentStation, 0, out var X1, out var Y1);
                alignment.ComputeXY(CurrentStation, -1, out var X2, out var Y2);

                GeometryUtils.RectToPolar(Y1, X1, Y2, X2, out var textOrientation, out _);

                DXF.Entities.Add(new DXFTextEntity("B",
                                                   kAlignmentCenterLineColor,
                                                   X1, Y1, Consts.NullDouble,
                                                   $"{CurrentStation / UnitUtils.DistToMeters(Units):F2}",
                                                   textOrientation - (Math.PI / 2),
                                                   2,
                                                   "Arial",
                                                   //[],
                                                   //0,
                                                   0, 0));

                if (CurrentStation + StationIncrement <= alignment.EndStation)
                {
                    CurrentStation = CurrentStation + StationIncrement;
                }
                else if (CurrentStation > alignment.EndStation - 0.001)
                {
                    break;
                }
                else
                {
                    CurrentStation = alignment.EndStation;
                }
            }

            if (DXF.Entities.Count > 0)
            {
                ms = new MemoryStream();
                using var writer = new StreamWriter(ms);
                DXF.SaveToFile(writer);
            }

            calcResult = DesignProfilerRequestResult.OK;

            return(true);
        }
Exemplo n.º 4
0
 public override void Dispose()
 {
     _data        = null;
     _boundingBox = null;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Constructs a guidance alignment design for computing filter patches
 /// </summary>
 public SVLAlignmentDesign(NFFGuidableAlignmentEntity data)
 {
     _data = data;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Constructs a guidance alignment design used for computing filter patches
 /// </summary>
 public SVLAlignmentDesign()
 {
     _data = new NFFGuidableAlignmentEntity();
 }
Exemplo n.º 7
0
        public async Task Geometry_SimpleLine()
        {
            AddDesignProfilerGridRouting();

            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();

            var polyline = new NFFLineworkPolyLineEntity();

            polyline.Vertices.Add(new NFFLineworkPolyLineVertexEntity(polyline, 1, 2, 3, 0));
            polyline.Vertices.Add(new NFFLineworkPolyLineVertexEntity(polyline, 2, 2, 4, 1));

            var alignment = new NFFGuidableAlignmentEntity();

            alignment.Entities.Add(polyline);

            var alignmentGuid = Guid.NewGuid();
            var testDesign    = new SVLAlignmentDesign(alignment);

            siteModel.Alignments.AddAlignmentDetails(alignmentGuid, new DesignDescriptor(alignmentGuid, "", ""), BoundingWorldExtent3D.Full());

            var mockDesignFiles = new Mock <IDesignFiles>();

            mockDesignFiles.Setup(x => x.Lock(It.IsAny <Guid>(), It.IsAny <ISiteModelBase>(), It.IsAny <double>(), out It.Ref <DesignLoadResult> .IsAny))
            .Returns(new GobbleDesignFilesLockReturns((Guid designUid, ISiteModelBase siteModel, double cellSize, out DesignLoadResult result) =>
            {
                result = DesignLoadResult.Success;
                return(testDesign);
            }));

            DIBuilder.
            Continue()
            .Add(x => x.AddSingleton(mockDesignFiles.Object))
            .Complete();

            var request  = new AlignmentDesignGeometryRequest();
            var response = await request.ExecuteAsync(new AlignmentDesignGeometryArgument
            {
                ProjectID              = siteModel.ID,
                AlignmentDesignID      = alignmentGuid,
                ConvertArcsToPolyLines = false,
                ArcChordTolerance      = 0.0
            });

            response.RequestResult.Should().Be(DesignProfilerRequestResult.OK);
            response.Vertices.Should().NotBeNull();
            response.Vertices.Length.Should().Be(1);
            response.Vertices[0].Length.Should().Be(2);
            response.Vertices[0][0].Length.Should().Be(3);
            response.Vertices[0][1].Length.Should().Be(3);

            response.Vertices[0][0].Should().BeEquivalentTo(new double[] { 1, 2, 0 });
            response.Vertices[0][1].Should().BeEquivalentTo(new double[] { 2, 2, 1 });

            response.Arcs.Should().BeNullOrEmpty();

            response.Labels.Length.Should().Be(2);

            response.Labels[0].Station.Should().BeApproximately(0.0, 0.001);
            response.Labels[0].X.Should().BeApproximately(1.0, 0.001);
            response.Labels[0].Y.Should().BeApproximately(2.0, 0.001);
            response.Labels[0].Rotation.Should().BeApproximately(Math.PI / 2, 0.001);

            response.Labels[1].Station.Should().BeApproximately(1.0, 0.001);
            response.Labels[1].X.Should().BeApproximately(2.0, 0.001);
            response.Labels[1].Y.Should().BeApproximately(2.0, 0.001);
            response.Labels[1].Rotation.Should().BeApproximately(Math.PI / 2, 0.001);
        }