/// <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)); }
/// <summary> /// Draws the path on the specified display /// </summary> /// <param name="display">The display to draw to</param> internal void Render(ISpatialDisplay display) { EnsureAdjusted(); // Do nothing if the scale factor is undefined. if (Math.Abs(m_ScaleFactor) < MathConstants.TINY) { return; } // Initialize position to the start of the path. IPosition gotend = new Position(m_From); // Initial bearing is whatever the rotation is. double bearing = m_Rotation; for (int i = 0; i < m_Legs.Length; i++) { Leg leg = m_Legs[i]; // Include any angle specified at the start of the leg StraightLeg sLeg = (leg as StraightLeg); if (sLeg != null) { bearing = sLeg.AddStartAngle(bearing); } // Determine exit bearing for circular leg (do it now, in case an extra leg complicates matters below) double exitBearing = bearing; CircularLeg cLeg = (leg as CircularLeg); if (cLeg != null) { exitBearing = cLeg.GetExitBearing(gotend, bearing, m_ScaleFactor); } // Obtain geometry for each span and draw SpanInfo[] spans = leg.PrimaryFace.Spans; ILineGeometry[] sections = leg.GetSpanSections(gotend, bearing, m_ScaleFactor, spans); DrawSpans(display, spans, sections); // If we're dealing with the first face of a staggered leg, process the second face if (leg.AlternateFace != null) { spans = leg.AlternateFace.Spans; sections = leg.GetSpanSections(gotend, bearing, m_ScaleFactor, spans); DrawSpans(display, spans, sections); } // Get to the end of the leg gotend = sections[sections.Length - 1].End; bearing = exitBearing; } // Re-draw the terminal points to ensure that their color is on top. DrawEnds(display); }