Exemplo n.º 1
0
        internal void SetArcMetrics(int legIndex, CircularLegMetrics metrics)
        {
            var edit = new CircularLegUpdate((uint)legIndex, metrics);

            edit.Apply(m_Legs);
            m_Changes.Add(edit);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new <c>CircularLeg</c> with no spans.
        /// </summary>
        /// <param name="radius">The radius of the circular leg.</param>
        /// <param name="clockwise">True if the curve is clockwise.</param>
        /// <param name="span">The number of spans on the curve.</param>
        internal CircularLeg(Distance radius, bool clockwise, int nspan)
            : base(nspan)
        {
            m_Metrics = new CircularLegMetrics(radius, clockwise);

            // The circle for this leg won't be known till we create a span.
            m_Circle = null;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new <c>CircularLeg</c> with no spans.
        /// </summary>
        /// <param name="radius">The radius of the circular leg.</param>
        /// <param name="clockwise">True if the curve is clockwise.</param>
        /// <param name="span">The number of spans on the curve.</param>
        internal CircularLeg(Distance radius, bool clockwise, int nspan)
            : base(nspan)
        {
            m_Metrics = new CircularLegMetrics(radius, clockwise);

            // The circle for this leg won't be known till we create a span.
            m_Circle = null;
        }
Exemplo n.º 4
0
 internal void SetArcMetrics(int legIndex, CircularLegMetrics metrics)
 {
     var edit = new CircularLegUpdate((uint)legIndex, metrics);
     edit.Apply(m_Legs);
     m_Changes.Add(edit);
 }
Exemplo n.º 5
0
 internal CircularLegUpdate(uint legIndex, CircularLegMetrics metrics)
     : base(legIndex)
 {
     m_Metrics = metrics;
 }
Exemplo n.º 6
0
 internal CircularLegUpdate(uint legIndex, CircularLegMetrics metrics)
     : base(legIndex)
 {
     m_Metrics = metrics;
 }
Exemplo n.º 7
0
        /// <summary>
        /// Creates a circular leg.
        /// </summary>
        /// <param name="items">Array of path items.</param>
        /// <param name="si">Index to the item where the leg data starts.</param>
        /// <param name="nexti">Index of the item where the next leg starts.</param>
        /// <returns>The new leg.</returns>
        static CircularLeg CreateCircularLeg(PathItem[] items, int si, out int nexti)
        {
            // Confirm that the first item refers to the BC.
            if (items[si].ItemType != PathItemType.BC)
            {
                throw new Exception("PathParser.CreateCircularLeg - Not starting at BC");
            }

            // The BC has to be followed by at least 3 items: angle, radius
            // and EC (add an extra 1 to account for 0-based indexing).
            if (items.Length < si + 4)
            {
                throw new Exception("PathParser.CreateCircularLeg - Insufficient curve data");
            }

            double bangle    = 0.0;         // Angle at BC
            double cangle    = 0.0;         // Central angle
            double eangle    = 0.0;         // Angle at EC
            bool   twoangles = false;       // True if bangle & eangle are both defined.
            bool   clockwise = true;        // True if curve is clockwise
            int    irad      = 0;           // Index of the radius item
            bool   cul       = false;       // True if cul-de-sac case

            // Point to item following the BC.
            nexti = si + 1;
            PathItemType type = items[nexti].ItemType;

            // If the angle following the BC is a central angle
            if (type == PathItemType.CentralAngle)
            {
                // We have a cul-de-sac
                cul = true;

                // Get the central angle.
                cangle = items[nexti].Value;
                nexti++;
            }
            else if (type == PathItemType.BcAngle)
            {
                // Get the entry angle.
                bangle = items[nexti].Value;
                nexti++;

                // Does an exit angle follow?
                if (items[nexti].ItemType == PathItemType.EcAngle)
                {
                    eangle    = items[nexti].Value;
                    twoangles = true;
                    nexti++;
                }
            }
            else
            {
                // The field after the BC HAS to be an angle.
                throw new ApplicationException("Angle does not follow BC");
            }

            // Must be followed by radius.
            if (items[nexti].ItemType != PathItemType.Radius)
            {
                throw new ApplicationException("Radius does not follow angle");
            }

            // Get the radius
            Distance radius = items[nexti].GetDistance();

            irad = nexti;
            nexti++;

            // The item after the radius indicates whether the curve is counterclockwise.
            if (items[nexti].ItemType == PathItemType.CounterClockwise)
            {
                nexti++;
                clockwise = false;
            }

            // Get the leg ID.
            int legnum = items[si].LegNumber;

            // How many distances have we got?
            int ndist = 0;

            for (; nexti < items.Length && items[nexti].LegNumber == legnum; nexti++)
            {
                if (items[nexti].IsDistance)
                {
                    ndist++;
                }
            }

            // Create the leg.
            CircularLeg        leg     = new CircularLeg(radius, clockwise, ndist);
            CircularLegMetrics metrics = leg.Metrics;

            // Set the entry angle or the central angle, depending on what we have.
            if (cul)
            {
                metrics.SetCentralAngle(cangle);
            }
            else
            {
                metrics.SetEntryAngle(bangle);
            }

            // Assign second angle if we have one.
            if (twoangles)
            {
                metrics.SetExitAngle(eangle);
            }

            // Assign each distance, starting one after the radius.
            ndist = 0;
            for (int i = irad + 1; i < nexti; i++)
            {
                Distance dist = items[i].GetDistance();
                if (dist != null)
                {
                    // See if there is a qualifier after the distance
                    LegItemFlag qual = LegItemFlag.Null;
                    if (i + 1 < nexti)
                    {
                        PathItemType nexttype = items[i + 1].ItemType;
                        if (nexttype == PathItemType.MissConnect)
                        {
                            qual = LegItemFlag.MissConnect;
                        }
                        if (nexttype == PathItemType.OmitPoint)
                        {
                            qual = LegItemFlag.OmitPoint;
                        }
                    }

                    leg.PrimaryFace.SetDistance(dist, ndist, qual);
                    ndist++;
                }
            }

            // Return the new leg.
            return(leg);
        }