public IEnumerable <IShape> GetShapePositions(IShape shape, IAlloy alloy) { if (!(shape is Round)) { throw new AlloyProcessorException(AlloyProcessorException.Error.InvalidShapeProcessor, shape.GetType().Name); } if (shape.Dimensions.Width > alloy.InnerBounds.Width || shape.Dimensions.Length > alloy.InnerBounds.Length) { throw new AlloyProcessorException(AlloyProcessorException.Error.ShapeOutOfBounds, shape, alloy); } var radius = ((Round)shape).Radius; var positions = GetNextPosition( new List <Round>() { new Round( //inject first round (no need to calculate position) new Position() { X = radius + alloy.MinimumBorderDistance, Y = radius + alloy.MinimumBorderDistance, }, radius) }, alloy); return(positions); }
private List <Round> GetNextPosition(List <Round> rounds, IAlloy alloy) { var lastRound = rounds.Last(); //locate previous round var nextRound = new Round( new Position() { X = lastRound.Coordinates.X + lastRound.Radius + alloy.MinimumShapeDistance, //TODO: needs proper position calculation Y = lastRound.Coordinates.Y, //same row (for now) TODO: needs proper position calculation }, lastRound.Radius); if (nextRound.Coordinates.X + nextRound.Radius > alloy.InnerBounds.Length) //out of bounds { return(rounds); } return(GetNextPosition(rounds, alloy)); }
public Alloy(IAlloy other) : this(other, other.Name, other.UltimateStress, other.YieldStress) { }