Ejemplo n.º 1
0
        // Cut the leg "legObj" with respect to "otherObj", if they overlap
        private static void CutLegWithRespectTo(EventDB eventDB, CourseAppearance appearance, CourseDesignator courseDesignator, LineCourseObj legObj, PointCourseObj otherObj)
        {
            float radiusOther = otherObj.ApparentRadius;
            PointF nearestPointOnLeg;
            float distance = legObj.path.DistanceFromPoint(otherObj.location, out nearestPointOnLeg);

            if (distance < radiusOther && Geometry.Distance(nearestPointOnLeg, legObj.path.FirstPoint) > 0.5 && Geometry.Distance(nearestPointOnLeg, legObj.path.LastPoint) > 0.5) {
                float gapRadius = (float) Math.Sqrt(radiusOther * radiusOther - distance * distance);  // pythagorean theorem.
                gapRadius += appearance.autoLegGapSize / 2;

                CutLegAtPoint(legObj, nearestPointOnLeg, gapRadius);
            }
        }
Ejemplo n.º 2
0
        // Cut the leg "legObj" with respect to "otherObj", if they intersect
        private static void CutLegWithRespectTo(EventDB eventDB, CourseAppearance appearance, CourseDesignator courseDesignator, LineCourseObj legObj, LineCourseObj otherObj)
        {
            PointF[] intersectionPoints;

            if (legObj.path.Intersects(otherObj.path, out intersectionPoints) && intersectionPoints != null) {
                // The other line intersections this one. Only the later leg is split.
                if (QueryEvent.DoesCourseControlPrecede(eventDB, courseDesignator, otherObj.courseControlId, legObj.courseControlId)) {
                    foreach (PointF intersectionPoint in intersectionPoints) {
                        float gapRadius = appearance.autoLegGapSize / 2;
                        CutLegAtPoint(legObj, intersectionPoint, gapRadius);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 // Check this leg and add cuts to it if needed.
 private static void AutoCutLeg(EventDB eventDB, CourseAppearance appearance, CourseDesignator courseDesignator, LineCourseObj legObj, CourseLayout courseLayout)
 {
     foreach (CourseObj courseObj in courseLayout) {
         if (courseObj != legObj && courseObj.layer == legObj.layer && (courseObj is LegCourseObj || courseObj is FlaggedLegCourseObj))
             CutLegWithRespectTo(eventDB, appearance, courseDesignator, legObj, (LineCourseObj)courseObj);
         if (courseObj != legObj && courseObj.layer == legObj.layer && courseObj is PointCourseObj)
             CutLegWithRespectTo(eventDB, appearance, courseDesignator, legObj, (PointCourseObj)courseObj);
     }
 }
Ejemplo n.º 4
0
 private static void CutLegAtPoint(LineCourseObj legObj, PointF intersectionPoint, float gapRadius)
 {
     float distanceAlongLine = legObj.path.LengthToPoint(intersectionPoint);
     PointF pt1 = legObj.path.PointAtLength(distanceAlongLine - gapRadius);
     PointF pt2 = legObj.path.PointAtLength(distanceAlongLine + gapRadius);
     legObj.gaps = LegGap.AddGap(legObj.path, legObj.gaps, pt1, pt2);
 }
Ejemplo n.º 5
0
        LineCourseObj courseObj; // object to modify.

        #endregion Fields

        #region Constructors

        public RemoveLegGapMode(Controller controller, LineCourseObj courseObj)
        {
            this.controller = controller;
            this.courseObj = (LineCourseObj) courseObj.Clone();
        }