Exemplo n.º 1
0
        public override void ComputeInputs(BuildComponentFactory factory)
        {
            if (Produces.Count == 0)
            {
                return;
            }

            var output = (BuildComponentFlyingGoose)Produces.Where(r => r is BuildComponentFlyingGoose).First();

            Dimension seamAllowance;

            if (output.Trim)
            {
                seamAllowance = new Dimension(0.875, DimensionUnits.Inch);
            }
            else
            {
                seamAllowance = new Dimension(1, DimensionUnits.Inch);
            }

            var producesCount = Produces.Where(r => r is BuildComponentFlyingGoose).Sum(r => r.Quantity);

            var bodyCount  = producesCount;
            var bodyWidth  = output.Area.Width + seamAllowance;
            var bodyHeight = output.Area.Height + seamAllowance;
            var bodyArea   = new Area(bodyWidth, bodyHeight).Round();

            var cornerCount  = producesCount * 2;
            var cornerWidth  = (output.Area.Width / 2) + seamAllowance;
            var cornerHeight = output.Area.Height + seamAllowance;
            var cornerArea   = new Area(cornerWidth, cornerHeight).Round();

            var input1 = factory.CreateBuildComponentRectangle(output.FabricStyles[0], bodyArea);

            input1.Quantity = bodyCount;
            AddInput(input1);

            var input2 = factory.CreateBuildComponentRectangle(output.FabricStyles[1], cornerArea);

            input2.Quantity = cornerCount;
            AddInput(input2);
        }
        public override void ComputeInputs(BuildComponentFactory factory)
        {
            //Consumes.Clear();

            if (Produces.Count == 0)
            {
                return;
            }

            // BUG: Assumes all outputs are the same.
            //
            var output = (BuildComponentHalfSquareTriangle)Produces[0];

            var seamAllowance = output.Trim
                ? new Dimension(0.875, DimensionUnits.Inch)
                : new Dimension(1, DimensionUnits.Inch);

            var producesCount = 0;

            foreach (var o in Produces)
            {
                producesCount += o.Quantity;
            }

            var inputCount = (producesCount + 1) / 2;
            var width      = output.Area.Width + seamAllowance;
            var height     = output.Area.Height + seamAllowance;

            var area = new Area(width, height).Round();

            var input1 = factory.CreateBuildComponentRectangle(output.FabricStyles[0], area);

            input1.Quantity = inputCount;
            AddInput(input1);

            var input2 = factory.CreateBuildComponentRectangle(output.FabricStyles[1], area);

            input2.Quantity = inputCount;
            AddInput(input2);
        }
Exemplo n.º 3
0
        private void AddRectangleInput(BuildComponentFactory factory, Area area, FabricStyle fabricStyle)
        {
            var matchingComponent = FindRectangle(BuildComponentRectangle.CreateStyleKey(fabricStyle, area));

            if (matchingComponent != null)
            {
                matchingComponent.Quantity += 1;
            }
            else
            {
                var component = factory.CreateBuildComponentRectangle(fabricStyle, area);
                AddInput(component);
            }
        }
Exemplo n.º 4
0
        private void AddOrUpdateInput(BuildComponentFactory factory, FabricStyle style, Area area)
        {
            foreach (var input in Consumes)
            {
                if (input is BuildComponentRectangle inputRectangle &&
                    inputRectangle.FabricStyle.Sku == style.Sku &&
                    inputRectangle.Area.Matches(area))
                {
                    inputRectangle.Quantity += 1;
                    return;
                }
            }

            var component = factory.CreateBuildComponentRectangle(style, area);

            AddInput(component);
        }
Exemplo n.º 5
0
 protected override IBuildComponent Clone(BuildComponentFactory factory)
 {
     return(factory.CreateBuildComponentRectangle(FabricStyle, Area));
 }