/// <summary> /// Fills a space with the given algorithms. /// Dierction indicates the direction of the lines. /// /// E.g. /// Direction X = 1 (Y = 0) <para/> /// ----- <para/> /// ----- <para/> /// Direction Y = 1 (X = 0) <para/> /// ||||| <para/> /// ||||| <para/> /// -> Length /// Direction /// </summary> /// <param name="totalLength"></param> /// <param name="totalWidth"></param> /// <returns></returns> public IEnumerable <IEnumerable <FS_Rectangle> > Fill(FS_LineFilledSpace space) { var lengthsAccrossLines = AlgoAccrossLines.FillLine( new FL_Line() { Length = space.LengthAlongLine }); double currentPosAccross = 0; foreach (var lengthAccross in lengthsAccrossLines) { var lengthsAlongLine = AlgoAlongLine.FillLine( new FL_Line() { Length = space.LengthAccrossLines }); yield return(FL_Utils.LineLengthsAsRectangles(lengthsAlongLine, lengthAccross, space.LineDirection, currentPosAccross).ToList()); currentPosAccross += lengthAccross; } }
public static Dictionary <string, object> CreateFloorPlates(FloorPlateProperties props) { //Berechne Offset-Positionen für jeden Space/WhiteLine //TODO: Siehe Beschreibung var positions = new List <Tuple <FamilyType, double> >(); var currentDistance = 0.0; if (props.FirstLineIsWhite) { positions.Add(new Tuple <FamilyType, double>(props.WhitePlates, 0.0)); currentDistance += props.WhitePlateWidth + props.GapWidthToNormalPlate; } for (int k = props.FirstLineIsWhite ? 1 : 0; k < props.DistancesBetweenWhiteLines.Count; k++) { positions.Add(new Tuple <FamilyType, double>(props.NormalPlates, currentDistance)); currentDistance += props.DistancesBetweenWhiteLines[k] + props.GapWidthToNormalPlate; positions.Add(new Tuple <FamilyType, double>(props.WhitePlates, currentDistance)); currentDistance += props.WhitePlateWidth + props.GapWidthToNormalPlate; } //Last normal width positions.Add(new Tuple <FamilyType, double>(props.NormalPlates, currentDistance)); //Vorgehen: Erstelle Liste von Listen mit SFRectangles + Typ (Weiß/normal) var rectangleTypes = new List <Tuple <List <FS_Rectangle>, FamilyType> >(); //TODO: Create Rectangles int i = 0; foreach (var pos in positions) { if (pos.Item1 == props.WhitePlates) { var lineGenerator = new FL_FixedPartSize_VariableEnding(props.WhitePlateLength); var lengths = lineGenerator.FillLine(new FL_Line() { Length = props.Space.Length }); var rectangles = FL_Utils.LineLengthsAsRectangles( lengths, props.WhitePlateWidth, props.LineDirection.X > 0 ? FS_XYDirection.XDirection : FS_XYDirection.YDirection, pos.Item2, props.BorderThickness); rectangleTypes.Add(new Tuple <List <FS_Rectangle>, FamilyType>(rectangles.ToList(), props.WhitePlates)); } else { var spaceGenerator = new FS_WithLines( new FL_FixedPartSize_VariableEnding(props.NormalPlateLength), new FL_FixedPartSize_VariableEnding(props.NormalPlateWidth)); //var nextSpaceBegin = positions.Count > (i + 1) ? positions[i + 1].Item2 : props.Space.LengthAccrossLines; var rectangles = spaceGenerator.Fill(props.Space).SelectMany(l => l).ToList(); rectangleTypes.Add(new Tuple <List <FS_Rectangle>, FamilyType>(rectangles.ToList(), props.NormalPlates)); } i++; } var instanceProps = ByPointInstanceProperties.CreateList( rectangleTypes.Select(l => l.Item1.Select(r => r.Length)).SelectMany(r1 => r1).ToList(), rectangleTypes.Select(l => l.Item1.Select(r => r.Width)).SelectMany(r1 => r1).ToList(), rectangleTypes.Select(l => l.Item2).ToList(), rectangleTypes.Select(l => l.Item1.Select(r => r.CenterPosition)).SelectMany(r1 => r1).ToList(), props.PlateRotation ); return(ByPointInstanceProperties.AsDictionary(instanceProps)); }