public static List <Point> PointLayout(this MultiLinearLayout layout2D, IEnumerable <ICurve> hostRegionCurves, IEnumerable <ICurve> openingCurves = null) { Point refPoint = ReferencePoint(hostRegionCurves, openingCurves, layout2D.ReferencePoint); BoundingBox bounds = Geometry.Query.Bounds(hostRegionCurves.Select(x => x.IBounds()).ToList()); Vector offsetDir = AlignOffsetVector(Vector.ZAxis.CrossProduct(layout2D.Direction), refPoint, bounds.Centre()); refPoint = refPoint + layout2D.Offset * offsetDir; int remainingPoints = layout2D.NumberOfPoints; List <Point> result = new List <Point>(); offsetDir = offsetDir.Normalise() * layout2D.PerpendicularMinimumSpacing; while (remainingPoints > 0) { Line axis = new Line { Start = refPoint, End = refPoint + layout2D.Direction, Infinite = true }; List <Line> distributionLines = IntersectionLines(hostRegionCurves, openingCurves, axis, layout2D.ParallelMinimumSpacing); if (distributionLines.Count == 0) { //No lines found and axis is within boundingbox of the curve, try next layer if (axis.IsInRange(bounds) && offsetDir.SquareLength() != 0) { Engine.Reflection.Compute.RecordNote("Could not find distribution lines for one or more layer."); refPoint += offsetDir; continue; } else { //No more lines can be found Engine.Reflection.Compute.RecordError("Could not generate distribution lines for the reinforcement. The number of points might not fit in the region curve. The resulting number of points might be different from the number requested."); remainingPoints = 0; } } int layerDivs = 0; for (int i = 0; i < distributionLines.Count; i++) { int divs = (int)Math.Ceiling(distributionLines[i].ILength() / layout2D.ParallelMinimumSpacing); layerDivs += divs; } layerDivs = Math.Min(layerDivs, remainingPoints); //SamplePoints adds extra point at start/ end.Hence subtracting count here to make sure correct number is extracted. result.AddRange(DivisionPoints(distributionLines, layerDivs)); remainingPoints -= layerDivs; //Find next layer by moving the centre of the axis refPoint += offsetDir; } return(result); }
/***************************************************/ private static int LayoutCount(MultiLinearLayout layout) { return(layout.NumberOfPoints); }