示例#1
0
        protected override void SetVertexStation(int VertexNum, double Value)
        {
            Debug.Assert(Range.InRange(VertexNum, 0, Vertices.Count - 1),
                         "VertexNum out of range in NFFLineworkPolyLineEntity.SetVertexStation");

            Vertices[VertexNum].Chainage = Value;
        }
示例#2
0
        protected override double GetVertexStation(int VertexNum)
        {
            Debug.Assert(Range.InRange(VertexNum, 0, Vertices.Count - 1),
                         "VertexNum out of range in NFFLineworkPolyLineEntity.GetVertexStation");

            return(Vertices[VertexNum].Chainage);
        }
示例#3
0
        private static void PerformScan(double siteModelCellSize, FilteredValueAssignmentContext assignmentContext,
                                        SubGridTreeBitmapSubGridBits sieveBitmask,
                                        int numRowsToScan, int numColsToScan,
                                        double stepNorthX, double stepNorthY, double stepEastX, double stepEastY,
                                        double subGridMinX, double subGridMinY,
                                        double firstScanPointEast, double firstScanPointNorth)
        {
            // Skip-Iterate through the cells marking those cells that require values
            // calculated for them in the bitmask. Also record the actual probe locations
            // that determined the cells to be processed.

            for (var I = 0; I < numRowsToScan; I++)
            {
                var currentNorth = firstScanPointNorth + I * stepNorthY;
                var currentEast  = firstScanPointEast + I * stepNorthX;

                for (var J = 0; J < numColsToScan; J++)
                {
                    var eastCol  = (int)Math.Floor((currentEast - subGridMinX) / siteModelCellSize);
                    var northRow = (int)Math.Floor((currentNorth - subGridMinY) / siteModelCellSize);

                    if (Range.InRange(eastCol, 0, SubGridTreeConsts.SubGridTreeDimensionMinus1) &&
                        Range.InRange(northRow, 0, SubGridTreeConsts.SubGridTreeDimensionMinus1))
                    {
                        sieveBitmask.SetBit(eastCol, northRow);
                        assignmentContext.ProbePositions[eastCol, northRow]
                        .SetOffsets((float)(currentEast - subGridMinX), (float)(currentNorth - subGridMinY));
                    }

                    currentEast  += stepEastX;
                    currentNorth += stepEastY;
                }
            }
        }
示例#4
0
        public override double ElementLength(int Index)
        {
            if (!Range.InRange(Index, 0, Vertices.Count - 1))
            {
                throw new TRexException("Out of range vertex index in NFFLineworkPolyLineEntity.ElementLength");
            }

            if (Index == Vertices.Count - 1)
            {
                return(0);
            }

            return(MathUtilities.Hypot(Vertices[Index].X - Vertices[Index + 1].X,
                                       Vertices[Index].Y - Vertices[Index + 1].Y));
        }
示例#5
0
        /// <summary>
        /// Computes a filter patch for a sub grid with respect to the alignment and a station/offset range over the alignment.
        /// Note: This is a CPU intensive operation. TRex currently uses an approach of polygonal spatial filtering with a boundary
        /// computed from the alignment geometry and station/offset bounds.
        /// </summary>
        public override bool ComputeFilterPatch(double startStn, double endStn, double leftOffset, double rightOffset,
                                                SubGridTreeBitmapSubGridBits mask, SubGridTreeBitmapSubGridBits patch,
                                                double originX, double originY, double cellSize, double offset)
        {
            var leftOffsetValue  = -leftOffset;
            var rightOffsetValue = rightOffset;

            if (leftOffsetValue > rightOffsetValue)
            {
                MinMax.Swap(ref leftOffsetValue, ref rightOffsetValue);
            }

            //   SIGLogMessage.PublishNoODS(Self, Format('Constructing filter patch for Stn:%.3f-%.3f, Ofs:%.3f-%.3f, originX:%.3f, originY:%.3f',
            //   [startStn, endStn, LeftOffsetValue, RightOffsetValue, originX, originY]));

            if (_data == null)
            {
                _log.LogError("No data element provided to SVL filter patch calculation");
                return(false);
            }

            patch.Clear();

            // Check the corners of the sub grid. If all are out of the offset range then assume
            // none of the cells are applicable. All four corners need to be on the same side of the
            // alignment in terms of offset to fail the sub grid.
            var cornersOutOfOffsetRange     = 0;
            var cornersOutOfOffsetRangeSign = 0;

            var originXPlusHalfCellSize = originX + cellSize / 2;
            var originYPlusHalfCellSize = originY + cellSize / 2;

            for (var i = 0; i < _corners.Length; i++)
            {
                _data.ComputeStnOfs(originXPlusHalfCellSize + _corners[i].X * cellSize, originYPlusHalfCellSize + _corners[i].Y * cellSize, out var stn, out var ofs);

                if (!(stn != Consts.NullDouble && ofs != Consts.NullDouble && Range.InRange(stn, startStn, endStn)) &&
                    !Range.InRange(ofs, leftOffsetValue, rightOffsetValue))
                {
                    if (i == 0)
                    {
                        cornersOutOfOffsetRangeSign = Math.Sign(ofs);
                    }

                    if (cornersOutOfOffsetRangeSign == Math.Sign(ofs))
                    {
                        cornersOutOfOffsetRange++;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            if (cornersOutOfOffsetRange == _corners.Length)
            {
                // Return success with the empty patch
                //SIGLogMessage.PublishNoODS(Self, 'All corners of patch exceed stn:ofs boundary');
                return(true);
            }

            // Iterate across the cells in the mask computing and checking the stn:ofs of
            // each point using the previously successful element as a hint for the next
            // computation
            for (var i = 0; i < SubGridTreeConsts.SubGridTreeDimension; i++)
            {
                for (var j = 0; j < SubGridTreeConsts.SubGridTreeDimension; j++)
                {
                    if (!mask.BitSet(i, j))
                    {
                        continue;
                    }

                    // Force element to be nil for all calculation until we resolve the issue
                    // of an in appropriate element 'capturing' the focus and then being used to
                    // calculate inappropriate offsets due to it's station range covering the
                    // points being computed.

                    NFFStationedLineworkEntity element = null;

                    _data.ComputeStnOfs(originXPlusHalfCellSize + i * cellSize, originYPlusHalfCellSize + j * cellSize,
                                        out var stn, out var ofs, ref element);

                    if (stn != Consts.NullDouble && ofs != Consts.NullDouble)
                    {
                        patch.SetBitValue(i, j, Range.InRange(stn, startStn, endStn) && Range.InRange(ofs, leftOffsetValue, rightOffsetValue));
                    }
                }
            }

            //  SIGLogMessage.PublishNoODS(Self, Format('Filter patch construction successful with %d bits', [patch.CountBits]));

            return(true);
        }
示例#6
0
        public override NFFLineworkPolyLineVertexEntity GetVertex(int VertexNum)
        {
            Debug.Assert(Range.InRange(VertexNum, 0, Vertices.Count - 1), "Vertex index out of range");

            return(Vertices[VertexNum]);
        }