Example #1
0
        /// <summary>
        /// Removes the inbound/outbound target intersections that would allow going into a dead-end.
        /// This analysis has to be performed on a per-source-ring basis.
        /// </summary>
        /// <param name="intersectionsInboundTarget"></param>
        /// <param name="intersectionsOutboundTarget"></param>
        protected virtual void RemoveDeadEndIntersections(
            IList <IntersectionPoint3D> intersectionsInboundTarget,
            IList <IntersectionPoint3D> intersectionsOutboundTarget)
        {
            var firstAlongTarget = IntersectionsAlongTarget.FirstOrDefault();

            if (firstAlongTarget != null &&
                intersectionsOutboundTarget.Contains(firstAlongTarget))
            {
                intersectionsOutboundTarget.Remove(firstAlongTarget);
            }

            var lastAlongTarget = IntersectionsAlongTarget.LastOrDefault();

            if (lastAlongTarget != null &&
                intersectionsInboundTarget.Contains(lastAlongTarget))
            {
                // dangle at the end of the cut line
                intersectionsInboundTarget.Remove(lastAlongTarget);
            }
        }
        protected override void RemoveDeadEndIntersections(
            IList <IntersectionPoint3D> intersectionsInboundTarget,
            IList <IntersectionPoint3D> intersectionsOutboundTarget)
        {
            foreach (int sourcePartIdx in _intersectionPoints
                     .Select(ip => ip.SourcePartIndex).Distinct())
            {
                var firstAlongTarget =
                    IntersectionsAlongTarget.FirstOrDefault(
                        ip => ip.SourcePartIndex == sourcePartIdx);

                if (firstAlongTarget != null &&
                    intersectionsOutboundTarget.Contains(firstAlongTarget))
                {
                    // The first intersection is outbound -> cannot cut, unless this part is closed
                    if (!Target.GetPart(firstAlongTarget.TargetPartIndex).IsClosed)
                    {
                        intersectionsOutboundTarget.Remove(firstAlongTarget);
                    }
                }

                var lastAlongTarget =
                    IntersectionsAlongTarget.LastOrDefault(
                        ip => ip.SourcePartIndex == sourcePartIdx);

                if (lastAlongTarget != null &&
                    intersectionsInboundTarget.Contains(lastAlongTarget))
                {
                    // dangle at the end of the cut line: cannot cut, unless the part is closed
                    if (!Target.GetPart(lastAlongTarget.TargetPartIndex).IsClosed)
                    {
                        intersectionsInboundTarget.Remove(lastAlongTarget);
                    }
                }
            }
        }