private void BuildEndLp(Dictionary <Point3d, Point3dCollection> scanlines) { var orientationAngle = _properties.Parts.SelectedLp.GetOrientationAngle(_properties.Algorythim.GlobalOrientationAngle); foreach (var scanline in scanlines) { var p = scanline.Value[2]; var dist = scanline.Value[0].DistanceTo(scanline.Value[2]); Part firstLp, secondLp; FindBetterLpCombination(_properties, dist, out firstLp, out secondLp); if (firstLp != null) { var firtLpOutline = GetOrCreatePartOutline(firstLp); if (CanPlacePart(p, firstLp, orientationAngle, firtLpOutline)) { PlacePart(firstLp, p, orientationAngle, GetOrCreatePart(firstLp)); } if (secondLp != null) { var lpDirection = SlabAlgorythim.VectorFrom(orientationAngle); var nextPoint = p.Add(lpDirection * (firstLp.Width + _properties.Algorythim.Options.DistanceBetweenLp)); var secondLpOutline = GetOrCreatePartOutline(secondLp); if (CanPlacePart(nextPoint, secondLp, orientationAngle, secondLpOutline)) { PlacePart(firstLp, nextPoint, orientationAngle, GetOrCreatePart(secondLp)); } } } } }
private Point3dCollection InitializeLdsMesh() { var list = new Point3dCollection(); var ld = _properties.Parts.SelectedLd; var lp = _properties.Parts.SelectedLp; var cast = _properties.Parts.SelectedCast; var spacing = _properties.Algorythim.Options.DistanceBetweenLpAndLd; var startVector = new Vector3d(0, lp.Height + spacing, 0); var startPoint = _properties.StartPoint.Add(startVector); var incrVector = new Vector2d(cast.Width, ld.Width + spacing * 2.0 + lp.Height); for (double y = startPoint.Y; y < _properties.MaxPoint.Y; y += incrVector.Y) { list.Add(new Point3d(startPoint.X, y, 0)); double x = 0; for (x = startPoint.X; x < _properties.MaxPoint.X && SlabAlgorythim.IsInsidePolygon(_outline, new Point3d(x + incrVector.X + 10, y, 0)); x += incrVector.X) { ; } if (SlabAlgorythim.IsInsidePolygon(_outline, new Point3d(x + _properties.Algorythim.Options.OutlineDistance / 2.0 + cast.Width, y, 0))) { list.Add(new Point3d(x, y, 0)); } else { list.Add(new Point3d(x, y, 0)); } } return(list); }
private void FindBetterLpCombination(SlabProperties properties, double dist, out Part firstLp, out Part secondLp) { var secondUsageType = properties.Algorythim.Options.UseEndLp ? UsageType.EndLp : UsageType.Lp; var firstList = _partRepository.GetByModulaton(properties.Algorythim.SelectedModulation).WhereType(UsageType.Lp); var secondList = _partRepository.GetByModulaton(properties.Algorythim.SelectedModulation).WhereType(secondUsageType); SlabAlgorythim.FindBetterLpCombination(properties, firstList.ToArray(), secondList.ToArray(), dist, out firstLp, out secondLp); }
private void BuildAlternativeZoneStartLp(Point3dCollection points, double orientationAngle, ObjectIdCollection placedObjects) { var alternativePoints = new Point3dCollection(); var direction = SlabAlgorythim.VectorFrom(orientationAngle); var lastPart = _properties.Algorythim.SelectedStartLp; var part = _partRepository.GetNextSmaller(lastPart, lastPart.UsageType); do { foreach (Point3d point in points) { var desloc = direction * (lastPart.Width - part.Width); alternativePoints.Add(point.Add(desloc)); } points = PlaceMultipleParts(points, part, placedObjects); } while (points.Count > 0 && (part = _partRepository.GetNextSmaller(part, lastPart.UsageType)) != null); }
protected Point3d?LineCast(Point3d startPoint, double angle, double distance) { var intersections = new Point3dCollection(); var direction = SlabAlgorythim.VectorFrom(angle); using (var line = new Line(startPoint, startPoint.Add(direction * distance))) { _environment.Outline.IntersectWith(line, Intersect.OnBothOperands, intersections, IntPtr.Zero, IntPtr.Zero); foreach (var o in _environment.Girders) { line.IntersectWith(o, Intersect.OnBothOperands, intersections, IntPtr.Zero, IntPtr.Zero); } foreach (var o in _environment.Collumns) { line.IntersectWith(o, Intersect.OnBothOperands, intersections, IntPtr.Zero, IntPtr.Zero); } foreach (var o in _environment.Empties) { line.IntersectWith(o, Intersect.OnBothOperands, intersections, IntPtr.Zero, IntPtr.Zero); } } var smallestDistance = double.MaxValue; Point3d?nearestPoint = null; foreach (Point3d p in intersections) { var dist = startPoint.DistanceTo(p); if (dist < smallestDistance) { smallestDistance = dist; nearestPoint = p; } } return(nearestPoint); }
public void BuildAlternativeLd(Point3dCollection points, Part lastPart) { if (points.Count == 0) { return; } var part = lastPart; var direction = SlabAlgorythim.VectorFrom(90 - _properties.Algorythim.GlobalOrientationAngle); var nextPart = _partRepository.GetNextSmaller(part, lastPart.UsageType); for (int i = 0; i < points.Count; i++) { points[i] = points[i].Add(direction * (lastPart.Width - part.Width)); } points = PlaceMultipleParts(points, part); if (points.Count > 0 && nextPart != null) { BuildAlternativeLd(points, nextPart); } }
protected bool CanPlacePart(Point3d loc, Part part, float orientationAngle, ObjectId outlinePartId) { var isInside = SlabAlgorythim.IsInsidePolygon(_environment.Outline, loc); if (!isInside) { return(false); } //if (part.UsageType == UsageType.Head) return true; using (var t = _acad.StartTransaction()) { var partOutlineRefId = PlacePart(part, loc, orientationAngle, outlinePartId); var partOutlineRef = t.GetObject(partOutlineRefId, OpenMode.ForRead) as BlockReference; var intersections = new Point3dCollection(); _environment.Outline.IntersectWith(partOutlineRef, Intersect.OnBothOperands, intersections, IntPtr.Zero, IntPtr.Zero); if (intersections.Count > 0) { return(false); } foreach (var e in _environment.Girders) { partOutlineRef.IntersectWith(e, Intersect.OnBothOperands, intersections, IntPtr.Zero, IntPtr.Zero); if (intersections.Count > 0) { return(false); } } foreach (var e in _environment.Collumns) { partOutlineRef.IntersectWith(e, Intersect.OnBothOperands, intersections, IntPtr.Zero, IntPtr.Zero); if (intersections.Count > 0) { return(false); } } foreach (var e in _environment.Empties) { partOutlineRef.IntersectWith(e, Intersect.OnBothOperands, intersections, IntPtr.Zero, IntPtr.Zero); if (intersections.Count > 0) { return(false); } if (SlabAlgorythim.IsInsidePolygon(e, loc)) { return(false); } } partOutlineRef?.Erase(); t.Commit(); } return(true); }