protected static Linestring GetTargetSubcurve( [NotNull] Linestring target, [NotNull] IntersectionPoint3D fromIntersection, [NotNull] IntersectionPoint3D toIntersection, bool forward) { double fromDistanceAlongAsRatio; int fromIndex = fromIntersection.GetLocalTargetIntersectionSegmentIdx( target, out fromDistanceAlongAsRatio); double toDistanceAlongAsRatio; int toIndex = toIntersection.GetLocalTargetIntersectionSegmentIdx( target, out toDistanceAlongAsRatio); if (!forward && fromIntersection.VirtualTargetVertex > toIntersection.VirtualTargetVertex) { } Linestring subcurve = target.GetSubcurve( fromIndex, fromDistanceAlongAsRatio, toIndex, toDistanceAlongAsRatio, false, !forward); // Replace the start / end with the actual intersection (correct source Z, exactly matching previous subcurve end) subcurve.ReplacePoint(0, fromIntersection.Point); subcurve.ReplacePoint(subcurve.SegmentCount, toIntersection.Point); return(subcurve); }
private static Linestring CreateWithBoundaryLoop(Linestring containingSourceRing, Linestring touchingInteriorRing, IntersectionPoint3D touchIntersection, double tolerance) { double sourceTouchPointRatio; int sourceTouchSegmentIdx = touchIntersection.GetLocalSourceIntersectionSegmentIdx( containingSourceRing, out sourceTouchPointRatio); List <Linestring> subcurves = new List <Linestring>(); subcurves.Add(containingSourceRing.GetSubcurve( 0, 0, sourceTouchSegmentIdx, sourceTouchPointRatio, false)); double targetTouchPointRatio; int targetTouchSegmentIdx = touchIntersection.GetLocalTargetIntersectionSegmentIdx( touchingInteriorRing, out targetTouchPointRatio); subcurves.Add(touchingInteriorRing.GetSubcurve( targetTouchSegmentIdx, targetTouchPointRatio, false, true)); subcurves.Add(containingSourceRing.GetSubcurve( sourceTouchSegmentIdx, sourceTouchPointRatio, containingSourceRing.SegmentCount - 1, 1, false)); Linestring withBoundaryLoop = GeomTopoOpUtils.MergeConnectedLinestrings(subcurves, null, tolerance); return(withBoundaryLoop); }
/// <summary> /// Gets the line that enters the intersection point when moving along as specified /// with the direction parameters alongSource and forward. /// </summary> /// <param name="intoIntersection"></param> /// <param name="target"></param> /// <param name="alongSource"></param> /// <param name="forward"></param> /// <param name="source"></param> /// <returns></returns> protected static Line3D GetEntryLine([NotNull] IntersectionPoint3D intoIntersection, [NotNull] Linestring source, [NotNull] Linestring target, bool alongSource, bool forward) { Line3D entryLine; if (alongSource) { double distanceAlongSource; int sourceSegmentIdx = intoIntersection.GetLocalSourceIntersectionSegmentIdx( source, out distanceAlongSource); entryLine = distanceAlongSource > 0 ? source[sourceSegmentIdx] : source.PreviousSegmentInRing(sourceSegmentIdx); } else { double distanceAlongTarget; int targetSegmentIdx = intoIntersection.GetLocalTargetIntersectionSegmentIdx( target, out distanceAlongTarget); if (forward) { if (distanceAlongTarget > 0) { entryLine = target[targetSegmentIdx]; } else { // There must be a previous segment if we have come along the target int previousTargetIdx = Assert.NotNull(target.PreviousSegmentIndex(targetSegmentIdx)).Value; entryLine = target[previousTargetIdx]; } } else { if (distanceAlongTarget < 1) { entryLine = target[targetSegmentIdx]; } else { // There must be a next segment if we have come backwards along the target int nextTargetIdx = Assert.NotNull(target.NextSegmentIndex(targetSegmentIdx)).Value; entryLine = target[nextTargetIdx]; } entryLine = entryLine.Clone(); entryLine.ReverseOrientation(); } } return(entryLine); }