Example #1
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]
                };
            }
        }