示例#1
0
        /// <summary>
        /// Inserts a new distance into this face.
        /// </summary>
        /// <param name="index">The index where the new distance should go.</param>
        /// <param name="newdist">The distance to insert.</param>
        /// <param name="wantLine">Should a new line be created (it won't happen until rollforward
        /// occurs, but it will get marked to happen).</param>
        void InsertAt(int index, Distance newdist, bool wantLine)
        {
            // Expand the array of span data
            int numSpan = NumSpan;

            SpanInfo[] newSpans = new SpanInfo[numSpan + 1];

            // Copy over stuff prior to the new distance
            for (int i = 0; i < index; i++)
            {
                newSpans[i] = m_Spans[i];
            }

            // Stick in the new guy with miss-connect flag
            SpanInfo extraSpan = new SpanInfo();

            extraSpan.ObservedDistance = newdist;
            extraSpan.Flags            = LegItemFlag.MissConnect;
            newSpans[index]            = extraSpan;

            // If a line is required, flag it for creation when rollforward runs (we can't do
            // it right now, since the end positions are currently coincident).
            if (wantLine)
            {
                extraSpan.Flags |= LegItemFlag.NewLine;
            }

            // Copy over the rest.
            for (int i = index; i < numSpan; i++)
            {
                newSpans[i + 1] = m_Spans[i];
            }

            // Replace original arrays with the new ones
            m_Spans = newSpans;

            /*
             * // If we inserted at the very start, ensure that any
             * // deflection angle switch is still with the very first span.
             * if (index==0 && (m_Spans[1].Flags & LegItemFlag.Deflection)!=0)
             * {
             *  m_Spans[0].Flags |= LegItemFlag.Deflection;
             *  m_Spans[1].Flags &= (~LegItemFlag.Deflection);
             * }
             */
        }
示例#2
0
        /// <summary>
        /// Obtains a string that corresponds to the observed distances for spans on this face.
        /// </summary>
        /// <param name="defaultEntryUnit">The distance units that should be treated as the default
        /// (null if there is no default).
        /// Formatted distances that were specified using these units will not contain the units
        /// abbreviation. Specify null if the units should always be appended.</param>
        /// <returns>A data entry string corresponding to the distances for this face</returns>
        string GetEntryString(DistanceUnit defaultEntryUnit)
        {
            // Return if there are no observed spans.
            if (NumSpan == 0)
            {
                return(String.Empty);
            }

            string[] dists = new string[m_Spans.Length];

            // Format each distance.
            for (int i = 0; i < m_Spans.Length; i++)
            {
                SpanInfo sd = m_Spans[i];
                Distance d  = sd.ObservedDistance;
                if (d == null) // is this possible?
                {
                    dists[i] = String.Empty;
                }
                else
                {
                    // Get the formatted distance
                    string distString = FormatDistance(d, defaultEntryUnit);

                    // Append any qualifiers
                    if (sd.IsMissConnect)
                    {
                        distString += "/-";
                    }

                    if (sd.IsOmitPoint)
                    {
                        distString += "/*";
                    }

                    dists[i] = distString;
                }
            }

            // Output the first distance
            var str = new StringBuilder();

            str.Append(dists[0]);

            // Output subsequent distances (with possible repeat count for unqualified spans)
            int numDist = (dists[0].Contains("/") ? 0 : 1);

            for (int i = 1; i < dists.Length; i++)
            {
                // If the current distance has a qualifier, flush out any repeat count and
                // the current distance (rather than something like 10*4/-, we output 10*3 10/-).
                // This is just to avoid potential confusion.

                if (dists[i].Contains("/"))
                {
                    if (numDist > 1)
                    {
                        str.Append("*" + numDist);
                    }

                    str.Append(" ");
                    str.Append(dists[i]);
                    numDist = 0;
                }
                else
                {
                    if (dists[i] == dists[i - 1])
                    {
                        numDist++;
                    }
                    else
                    {
                        if (numDist > 1)
                        {
                            str.Append("*" + numDist);
                        }

                        str.Append(" ");
                        str.Append(dists[i]);
                        numDist = 1;
                    }
                }
            }

            if (numDist > 1)
            {
                str.Append("*" + numDist);
            }

            return(str.ToString());
        }
示例#3
0
        /// <summary>
        /// Creates spatial features (points and lines) for this face. The created
        /// features don't have any geometry.
        /// </summary>
        /// <param name="ff">The factory for creating new spatial features</param>
        /// <param name="startPoint">The point (if any) at the start of this leg. May be
        /// null in a situation where the preceding leg ended with an "omit point" directive.</param>
        /// <param name="lastPoint">The point that should be used for the very end
        /// of the leg (specify null if a point should be created at the end of the leg).</param>
        internal void CreateFeatures(FeatureFactory ff, PointFeature startPoint, PointFeature lastPoint)
        {
            PointFeature from = startPoint;
            PointFeature to   = null;

            // The initial item sequence relates to the face itself. The first feature along the face will
            // have a sequence number one higher.
            uint maxSequence = this.Sequence.ItemSequence;

            int nSpan = m_Spans.Length;

            for (int i = 0; i < nSpan; i++, from = to)
            {
                SpanInfo span = GetSpanData(i);

                // If we have an end point, add it (so long as this span is not
                // at the very end of the connection path).

                to = null;
                maxSequence++;

                if (span.HasEndPoint)
                {
                    if (i == (nSpan - 1))
                    {
                        to = lastPoint;
                    }

                    if (to == null)
                    {
                        to = ff.CreatePointFeature(maxSequence.ToString());
                    }

                    Debug.Assert(to != null);
                }

                // A line can only exist if both end points are defined (the "omit point"
                // directive may well be used to finish a leg without a point, so the first
                // span in the next leg can't have a line).

                maxSequence++;
                if (span.HasLine && from != null)
                {
                    LineFeature line = this.Leg.CreateLine(ff, maxSequence.ToString(), from, to);
                    line.ObservedLength = span.ObservedDistance;

                    // Alternate faces should by non-topological. And mark as "void" so that it can be
                    // skipped on export to AutoCad.
                    if (FaceNumber == 2)
                    {
                        line.SetTopology(false); // should probably be false already
                        line.IsVoid = true;
                    }

                    span.CreatedFeature = line;
                }
                else
                {
                    span.CreatedFeature = to;
                }
            }
        }