/// <summary> /// Добавление внутренних стен /// </summary> private void AddIWalls() { var wallsH = Elements.OfType <WallHatch>().ToList(); using (var disposeLines = new DisposableSet <Line>()) { var lines = wallsH.Select(s => GetExtentLine(s.Ext, false)).Where(w => w.Length > 2500).ToList(); disposeLines.AddRange(lines); var lineEqComparer = new LineEqualityComparer(new Tolerance(0.1, 0.1), 450, 450); while (true) { var linesCountBefore = lines.Count; lines = lines.GroupBy(g => g, lineEqComparer).Select(s => s.ToList().GetUnionLine()).ToList(); disposeLines.AddRange(lines); if (lines.Count == linesCountBefore) { break; } } foreach (var line in lines) { line.TransformBy(transform); if (IsInnerWall(line)) { line.LayerId = settings.LayerApart.LayerId; block.AppendEntity(line); t.AddNewlyCreatedDBObject(line, true); } } } }
/// <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); } } }