Beispiel #1
0
        bool Calculate()
        {
            // Ensure any previously defined end positions have been turfed.
            m_South = null;
            m_North = null;

            // Can't do nothing if the reference line is undefined.
            if (m_Line == null)
            {
                return(false);
            }

            // Calculate the parallel points, depending on what sort of
            // observation we've got.

            IPosition north = null;
            IPosition south = null;
            bool      ok    = false;

            // Ensure the correct sign is defined in case of an offset distance.

            if (m_Offset != null)
            {
                if (m_IsLeft)
                {
                    m_Offset.SetNegative();
                }
                else
                {
                    m_Offset.SetPositive();
                }

                ok = ParallelLineUI.Calculate(m_Line, m_Offset, out south, out north);
            }
            else if (m_Point != null)
            {
                ok = ParallelLineUI.Calculate(m_Line, m_Point, out south, out north);
            }

            // If the calculation succeeded, allocate vertices to
            // hold the results we got.

            if (ok)
            {
                m_South = south;
                m_North = north;
            }

            return(ok);
        }
        /// <summary>
        /// Calculates the terminal positions for the parallel.
        /// </summary>
        /// <param name="refLine">The reference line.</param>
        /// <param name="offset">The observed offset (either a <c>Distance</c>
        /// or an <c>OffsetPoint</c>).</param>
        /// <param name="term1">A line that the parallel should start on (may be null).</param>
        /// <param name="term2">A line that the parallel should end on (may be null).</param>
        /// <param name="spar">The start of the parallel.</param>
        /// <param name="epar">The end of the parallel.</param>
        /// <returns>True if calculated ok.</returns>
        bool Calculate(LineFeature refLine
                       , Observation offset
                       , LineFeature term1
                       , LineFeature term2
                       , out IPosition spar
                       , out IPosition epar)
        {
            spar = epar = null;

            if (!ParallelLineUI.Calculate(refLine, offset, out spar, out epar))
            {
                return(false);
            }

            // If the start of the parallel should begin on a specific
            // line, get the closest intersection.

            if (term1 != null)
            {
                spar = ParallelLineUI.GetIntersect(refLine, spar, term1);
                if (spar == null)
                {
                    throw new Exception("Parallel does not intersect terminal line.");
                }
            }

            // And similarly for the end of the parallel.

            if (term2 != null)
            {
                IPosition tpar = ParallelLineUI.GetIntersect(refLine, epar, term2);
                if (tpar == null)
                //epar = ParallelLineUI.GetIntersect(refLine, epar, term2);
                //if (epar == null)
                {
                    epar = ParallelLineUI.GetIntersect(refLine, epar, term2);
                    throw new Exception("Parallel does not intersect terminal line.");
                }
                else
                {
                    epar = tpar;
                }
            }

            return(true);
        }