Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StraightLeg"/> class that corresponds to
 /// the end of a face on another leg (for use when breaking a leg).
 /// </summary>
 /// <param name="face">The face on the other leg</param>
 /// <param name="startIndex">The array index of the first span that should be copied.</param>
 StraightLeg(LegFace face, int startIndex)
     : base(face, startIndex)
 {
     // Stick in a (clockwise) angle of 180 degrees.
     m_StartAngle   = Math.PI;
     m_IsDeflection = false;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Obtains line sections for a specific face in this path.
        /// </summary>
        /// <param name="face">The face of interest</param>
        /// <returns>The corresponding sections</returns>
        internal ILineGeometry[] GetSections(LegFace face)
        {
            EnsureAdjusted();

            // Initialize position to the start of the path.
            IPosition p = new Position(m_From);

            // Initial bearing is whatever the rotation is.
            double bearing = m_Rotation;

            // Get the position at the start of the required leg.
            foreach (Leg leg in m_Legs)
            {
                if (leg == face.Leg)
                {
                    break;
                }

                leg.Project(ref p, ref bearing, m_ScaleFactor);
            }

            // We've now got the position at the start of the required leg, and the bearing of the previous leg.
            // If the leg we actually want if a straight leg (or an extra leg layered on a straight), add on any
            // initial angle.
            StraightLeg sLeg = (face.Leg as StraightLeg);

            if (sLeg != null)
            {
                bearing = sLeg.AddStartAngle(bearing);
            }

            return(face.Leg.GetSpanSections(p, bearing, m_ScaleFactor, face.Spans));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StraightLeg"/> class that corresponds to
 /// the end of a face on another leg (for use when breaking a leg).
 /// </summary>
 /// <param name="face">The face on the other leg</param>
 /// <param name="startIndex">The array index of the first span that should be copied.</param>
 StraightLeg(LegFace face, int startIndex)
     : base(face, startIndex)
 {
     // Stick in a (clockwise) angle of 180 degrees.
     m_StartAngle = Math.PI;
     m_IsDeflection = false;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LegFace"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal LegFace(EditDeserializer editDeserializer)
        {
            // Only connection paths should generate LegFace instances
            PathOperation op = (editDeserializer.CurrentEdit as PathOperation);

            if (op == null)
            {
                throw new ApplicationException("Unexpected creating edit for a leg face");
            }

            this.Sequence = editDeserializer.ReadInternalId(DataField.Id);

            if (editDeserializer.IsNextField(DataField.PrimaryFaceId))
            {
                InternalIdValue primaryFaceId = editDeserializer.ReadInternalId(DataField.PrimaryFaceId);
                LegFace         face          = op.FindFace(primaryFaceId);

                if (face == null)
                {
                    throw new ApplicationException("Cannot locate primary face " + primaryFaceId);
                }

                Leg = face.Leg;
                Leg.AlternateFace = this;
            }
            else
            {
                // This should never happen. Primary faces are not serialized using the LegFace
                // class (we only use LegFace as part of a PathOperation to simplify import of
                // extra legs from old CEdit files).

                throw new ApplicationException();
            }

            // Convert the data entry string into observed spans
            string       entryString      = editDeserializer.ReadString(DataField.EntryString);
            DistanceUnit defaultEntryUnit = EditingController.Current.EntryUnit;

            Distance[] dists = LineSubdivisionFace.GetDistances(entryString, defaultEntryUnit, false);
            m_Spans = new SpanInfo[dists.Length];

            for (int i = 0; i < m_Spans.Length; i++)
            {
                m_Spans[i] = new SpanInfo()
                {
                    ObservedDistance = dists[i]
                };
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LegFace"/> class.
        /// </summary>
        /// <param name="leg">The leg this face relates to.</param>
        /// <param name="copy">The face to copy from.</param>
        /// <param name="startIndex">The start index of the first span to copy</param>
        internal LegFace(Leg leg, LegFace copy, int startIndex)
        {
            this.Leg = leg;

            int nSpan = copy.m_Spans.Length - startIndex;

            if (nSpan <= 0)
            {
                throw new IndexOutOfRangeException();
            }

            // Perform shallow copy
            m_Spans = new SpanInfo[nSpan];
            Array.Copy(copy.m_Spans, startIndex, m_Spans, 0, nSpan);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LegFace"/> class.
        /// </summary>
        /// <param name="leg">The leg this face relates to.</param>
        /// <param name="copy">The face to copy from.</param>
        /// <param name="startIndex">The start index of the first span to copy</param>
        internal LegFace(Leg leg, LegFace copy, int startIndex)
        {
            this.Leg = leg;

            int nSpan = copy.m_Spans.Length - startIndex;
            if (nSpan <= 0)
                throw new IndexOutOfRangeException();

            // Perform shallow copy
            m_Spans = new SpanInfo[nSpan];
            Array.Copy(copy.m_Spans, startIndex, m_Spans, 0, nSpan);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Leg"/> class that corresponds to
 /// the end of another leg face (for use when breaking a straight leg).
 /// </summary>
 /// <param name="face">The face on the other leg</param>
 /// <param name="startIndex">The array index of the first span that should be copied.</param>
 protected Leg(LegFace face, int startIndex)
 {
     m_FirstSide = new LegFace(this, face, startIndex);
     m_OtherSide = null;
 }
Ejemplo n.º 8
0
 protected Leg(int nspan)
 {
     m_FirstSide = new LegFace(this, nspan);
     m_OtherSide = null;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Obtains line sections for a specific face in this path.
        /// </summary>
        /// <param name="face">The face of interest</param>
        /// <returns>The corresponding sections</returns>
        internal ILineGeometry[] GetSections(LegFace face)
        {
            EnsureAdjusted();

            // Initialize position to the start of the path.
            IPosition p = new Position(m_From);

            // Initial bearing is whatever the rotation is.
            double bearing = m_Rotation;

            // Get the position at the start of the required leg.
            foreach (Leg leg in m_Legs)
            {
                if (leg == face.Leg)
                    break;

                leg.Project(ref p, ref bearing, m_ScaleFactor);
            }

            // We've now got the position at the start of the required leg, and the bearing of the previous leg.
            // If the leg we actually want if a straight leg (or an extra leg layered on a straight), add on any
            // initial angle.
            StraightLeg sLeg = (face.Leg as StraightLeg);
            if (sLeg != null)
                bearing = sLeg.AddStartAngle(bearing);

            return face.Leg.GetSpanSections(p, bearing, m_ScaleFactor, face.Spans);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Leg"/> class that corresponds to
 /// the end of another leg face (for use when breaking a straight leg).
 /// </summary>
 /// <param name="face">The face on the other leg</param>
 /// <param name="startIndex">The array index of the first span that should be copied.</param>
 protected Leg(LegFace face, int startIndex)
 {
     m_FirstSide = new LegFace(this, face, startIndex);
     m_OtherSide = null;
 }
Ejemplo n.º 11
0
 protected Leg(int nspan)
 {
     m_FirstSide = new LegFace(this, nspan);
     m_OtherSide = null;
 }