Ejemplo n.º 1
0
        // Function GetStartCrossSlope : Double; Override;
        // Function GetEndCrossSlope : Double; Override;

        // procedure SetStartCrossSlope(Value : Double); Override;
        // procedure SetEndCrossSlope(Value : Double); Override;

        public override void Reverse()
        {
            MinMax.Swap(ref StartLeftCrossSlope, ref EndRightCrossSlope);
            MinMax.Swap(ref StartRightCrossSlope, ref EndLeftCrossSlope);

            switch (TransitDirection)
            {
            case NFFLineworkArcTransitDirection.atdUnknown: // do nothing
                break;

            case NFFLineworkArcTransitDirection.atdStartToEnd:
                TransitDirection = NFFLineworkArcTransitDirection.atdEndToStart;
                break;

            case NFFLineworkArcTransitDirection.atdEndToStart:
                TransitDirection = NFFLineworkArcTransitDirection.atdStartToEnd;
                break;
            }
        }
Ejemplo n.º 2
0
        /*
         * function GetVertexLeftCrossSlope(VertexNum: Integer): Double; Override;
         * procedure SetVertexLeftCrossSlope(VertexNum: Integer;
         * const Value: Double); Override;
         *
         * function GetVertexRightCrossSlope(VertexNum: Integer): Double; Override;
         * procedure SetVertexRightCrossSlope(VertexNum: Integer;
         * const Value: Double); Override;
         */

        public NFFLineworkArcEntity()
        {
            ElementType = NFFLineWorkElementType.kNFFLineWorkArcElement;

            StartLeftCrossSlope  = Consts.NullDouble;
            StartRightCrossSlope = Consts.NullDouble;
            EndLeftCrossSlope    = Consts.NullDouble;
            EndRightCrossSlope   = Consts.NullDouble;

            // By definition, an arc in an NFF/SVL file is define as clockwise. Unless
            // an outside agent independently determines that the arc was in an anticlockwise
            // sense when the arc was constructed we must assume the arc was clockwise in
            // orientation
            WasClockWise = true;

            TransitDirection = NFFLineworkArcTransitDirection.atdStartToEnd;

            OriginalEndPointsHash = Consts.NullDouble;
        }
Ejemplo n.º 3
0
        public NFFLineworkArcEntity(int AColour,
                                    double AX1, double AY1, double AZ1, double AX2, double AY2, double AZ2,
                                    double ACX, double ACY, double ACZ,
                                    bool AClockwise,
                                    bool ASingleArcEdgePoint) : this()
        {
            Colour = AColour;

            X1 = AX1;
            Y1 = AY1;
            Z1 = AZ1;
            X2 = AX2;
            Y2 = AY2;
            Z2 = AZ2;
            CX = ACX;
            CY = ACY;
            //  CZ = ACZ;

            if (!AClockwise)
            {
                MinMax.Swap(ref X1, ref X2);
                MinMax.Swap(ref Y1, ref Y2);
                MinMax.Swap(ref Z1, ref Z2);
            }

            WasClockWise       = AClockwise;
            SingleArcEdgePoint = ASingleArcEdgePoint;

            if (AClockwise)
            {
                TransitDirection = NFFLineworkArcTransitDirection.atdStartToEnd;
            }
            else
            {
                TransitDirection = NFFLineworkArcTransitDirection.atdEndToStart;
            }

            OriginalEndPointsHash = X1 + (Y1 * 2) + (X2 * 4) + (Y2 * 8) + (CX * 16) + (CY * 32);
        }
Ejemplo n.º 4
0
        public override void Assign(NFFLineworkEntity Entity)
        {
            base.Assign(Entity);

            var ArcEty = Entity as NFFLineworkArcEntity;

            X1 = ArcEty.X1;
            Y1 = ArcEty.Y1;
            Z1 = ArcEty.Z1;
            X2 = ArcEty.X2;
            Y2 = ArcEty.Y2;
            Z2 = ArcEty.Z2;
            CX = ArcEty.CX;
            CY = ArcEty.CY;
            //  CZ                   = ArcEty.CZ;
            WasClockWise         = ArcEty.WasClockWise;
            SingleArcEdgePoint   = ArcEty.SingleArcEdgePoint;
            StartLeftCrossSlope  = ArcEty.StartLeftCrossSlope;
            StartRightCrossSlope = ArcEty.StartRightCrossSlope;
            EndLeftCrossSlope    = ArcEty.EndLeftCrossSlope;
            EndRightCrossSlope   = ArcEty.EndRightCrossSlope;

            TransitDirection = ArcEty.TransitDirection;
        }
Ejemplo n.º 5
0
        // Procedure SaveToStream(Stream : TStream); Override;

        /*
         * public override void LoadFromStream(BinaryReader reader)
         * {
         * base.LoadFromStream(reader);
         *
         * NFFUtils.ReadXYZFromStream(reader, out X1, out Y1, out Z1);
         * NFFUtils.ReadXYZFromStream(reader, out X2, out Y2, out Z2);
         * NFFUtils.ReadXYFromStream(reader, out CX, out CY);
         * SingleArcEdgePoint = reader.ReadBoolean();
         * WasClockWise = reader.ReadBoolean();
         *
         * byte ReadByte = reader.ReadByte();
         * if (Range.InRange(ReadByte, (byte)NFFLineworkArcTransitDirection.atdUnknown, (byte)NFFLineworkArcTransitDirection.atdEndToStart))
         * TransitDirection = (NFFLineworkArcTransitDirection)ReadByte;
         * else
         * TransitDirection = NFFLineworkArcTransitDirection.atdUnknown;
         *
         * OriginalEndPointsHash = reader.ReadDouble();
         *
         * StartLeftCrossSlope= reader.ReadDouble();
         * EndLeftCrossSlope = reader.ReadDouble();
         * StartRightCrossSlope = reader.ReadDouble();
         * EndRightCrossSlope = reader.ReadDouble();
         * }
         */

        // procedure DumpToText(Stream: TTextDumpStream; const OriginX, OriginY : Double); override;
        //Procedure SaveToNFFStream(Stream : TStream;
        //const OriginX, OriginY : Double;
        //                          FileVersion : NFFFileVersion); Override;

        public override void LoadFromNFFStream(BinaryReader reader,
                                               double OriginX, double OriginY,
                                               bool HasGuidanceID,
                                               NFFFileVersion FileVersion)
        {
            // There is no need to read the entity type as this will have already been
            // read in order to determine we should be reading this type of entity!

            if (HasGuidanceID)
            {
                _guidanceID = reader.ReadUInt16();
            }

            byte _ = reader.ReadByte(); //{ LineWidth= }

            Colour       = NFFUtils.ReadColourFromStream(reader);
            _entityFlags = reader.ReadByte();

            NFFUtils.ReadRectFromStream(reader, out double MinX, out double MinY, out double MaxX, out double MaxY, OriginX, OriginY);

            NFFUtils.ReadCoordFromStream(reader, out CX, out CY, OriginX, OriginY);

            //  CZ = NullReal;
            //SPR 8763: Remove height field from arcs in SVL files
            //  if (FFlags and kNFFElementHeaderHasElevation) <> 0 then
            //    ReadFixedPoint32FromStream(Stream);

            NFFUtils.ReadCoordFromStream(reader, out X1, out Y1, OriginX, OriginY);
            if ((HeaderFlags & NFFConsts.kNFFElementHeaderHasElevation) != 0)
            {
                Z1 = NFFUtils.ReadFixedPoint32FromStream(reader);
            }
            else
            {
                Z1 = Consts.NullDouble;
            }

            if ((HeaderFlags & NFFConsts.kNFFElementHeaderHasCrossSlope) != 0)
            {
                NFFUtils.ReadCrossSlopeInformationFromStream(reader, out StartLeftCrossSlope, out StartRightCrossSlope);
            }
            else
            {
                StartLeftCrossSlope  = Consts.NullDouble;
                StartRightCrossSlope = Consts.NullDouble;
            }

            NFFUtils.ReadCoordFromStream(reader, out X2, out Y2, OriginX, OriginY);
            if ((HeaderFlags & NFFConsts.kNFFElementHeaderHasElevation) != 0)
            {
                Z2 = NFFUtils.ReadFixedPoint32FromStream(reader);
            }
            else
            {
                Z2 = Consts.NullDouble;
            }

            if ((HeaderFlags & NFFConsts.kNFFElementHeaderHasCrossSlope) != 0)
            {
                NFFUtils.ReadCrossSlopeInformationFromStream(reader, out EndLeftCrossSlope, out EndRightCrossSlope);
            }
            else
            {
                EndLeftCrossSlope  = Consts.NullDouble;
                EndRightCrossSlope = Consts.NullDouble;
            }

            double start_angle = reader.ReadSingle();
            double end_angle   = reader.ReadSingle();
            double radius      = reader.ReadSingle();

            if ((_headerFlags & NFFConsts.kNFFElementHeaderHasStationing) != 0)
            {
                // Read the Start Station
                StartStation = reader.ReadDouble();

                // Read and discard EndStation value (it can be re-calculated any time it is needed)
                var TempEndStation = reader.ReadDouble();

                // Within SVD/ SVL no record is kept of whether arc was initially described as
                //   CW or CCW, Stationing is stored with convention that arc is CW.When
                //   creating / reading a arc entity from stream, we need to figure out and restore
                //      <WasClockWise> value in order for any subsequent write to stream to write

                //     Stationing around the right way
                if (StartStation > TempEndStation)
                {
                    // Arc was initially defined CCW
                    WasClockWise     = false;
                    StartStation     = TempEndStation;
                    TransitDirection = NFFLineworkArcTransitDirection.atdEndToStart;
                }
                else
                {
                    WasClockWise     = true;
                    TransitDirection = NFFLineworkArcTransitDirection.atdStartToEnd;
                }
            }

            // Convert the start/end angle into end points. Even though we have
            // read in the end points, we recalculate then to undo loss of precision when written
            // into the NFF file
            // Angles are mathematical angles, PolarToRect wants azimuth angles

            GeometryUtils.PolarToRect(CY, CX, out Y1, out X1,
                                      Math.PI / 2 - start_angle,
                                      radius);
            GeometryUtils.PolarToRect(CY, CX, out Y2, out X2,
                                      Math.PI / 2 - end_angle,
                                      radius);
        }