/// <summary> /// Offset the source polyline to specified side(s). /// </summary> /// <param name="source">The polyline to be offseted.</param> /// <param name="offsetDist">The offset distance.</param> /// <param name="side">The offset side(s).</param> /// <returns>A polyline sequence resulting from the offset of the source polyline.</returns> public static IEnumerable <Polyline> Offset(this Polyline source, double offsetDist, OffsetSide side) { side = OffsetSide.Out; offsetDist = Math.Abs(offsetDist); using (var plines = new DisposableSet <Polyline>()) { var offsetRight = source.GetOffsetCurves(offsetDist).Cast <Polyline>(); plines.AddRange(offsetRight); var offsetLeft = source.GetOffsetCurves(-offsetDist).Cast <Polyline>(); plines.AddRange(offsetLeft); var areaRight = offsetRight.Select(pline => pline.Area).Sum(); var areaLeft = offsetLeft.Select(pline => pline.Area).Sum(); switch (side) { case OffsetSide.In: return(plines.RemoveRange( areaRight < areaLeft ? offsetRight : offsetLeft)); case OffsetSide.Out: return(plines.RemoveRange( areaRight < areaLeft ? offsetLeft : offsetRight)); case OffsetSide.Left: return(plines.RemoveRange(offsetLeft)); case OffsetSide.Right: return(plines.RemoveRange(offsetRight)); case OffsetSide.Both: plines.Clear(); return(offsetRight.Concat(offsetLeft)); default: return(null); } } }
public void ClearTemporaryResources() { lock (resourcesSyncRoot) { temporaryResources.Clear(); } }