Beispiel #1
0
        private BezierCalculator.CalcResult BuildBodiceNeck(float neckDepth, float curvinessFactor)
        {
            Entities.Clear();

            float garmentLengthLessNeckDepth = Measurements.GarmentBodiceLength - neckDepth;
            float neckLength = Measurements.NeckCircumference * Utils.quarter;

            GarmentLengthLine =
                AddLineEntity(LineDirection.Up, Start, garmentLengthLessNeckDepth);
            AddLineEntity(LineDirection.Right, neckLength, EntityType.Construction);
            PartEntityLine endNeckCons2 =
                AddLineEntity(LineDirection.Up, neckDepth, EntityType.Construction);

            BezierCalculator.CalcResult adjustmentsNeck = BezierCalculator.CalcLength(
                GarmentLengthLine.End,
                endNeckCons2.End,
                BezierCalculator.BezierCalculatorControlPointDirection.Right,
                BezierCalculator.BezierCalculatorControlPointDirection.Down,
                curvinessFactor * neckLengthRequired,
                curvinessFactor * neckLengthRequired
                );

            NeckBezier = AddBezierEntity(GarmentLengthLine.End, endNeckCons2.End, adjustmentsNeck.Firstpoint, adjustmentsNeck.SecondPoint);

            return(adjustmentsNeck);
        }
Beispiel #2
0
        public BezierCalculatorResult CalcNeckDepth(float curvinessFactor)
        {
            int rangeMin = 1;
            int rangeMax = (int)Measurements.GarmentBodiceLength;

            int currentIterationValue  = ((rangeMax - rangeMin) / 2) + rangeMin;
            int previousIterationValue = 0;

            for (int i = 1; i < 51; i++)
            {
                BezierCalculator.CalcResult result = BuildBodiceNeck(currentIterationValue, curvinessFactor);
                if (Math.Abs(neckLengthRequired - result.FoundLength) <= 0.5F)
                {
                    //System.Diagnostics.Debug.WriteLine("Bodice " + bodiceType.ToString() + " Neck, solution found for neckDepth = " + currentIterationValue + ", required length " + neckLengthRequired + " foundLength = " + result.FoundLength);
                    return(BezierCalculatorResult.SolutionFound);
                }

                if (result.FoundLength > neckLengthRequired)
                {
                    rangeMax = currentIterationValue;
                }

                if (result.FoundLength < neckLengthRequired)
                {
                    rangeMin = currentIterationValue;
                }

                currentIterationValue = ((rangeMax - rangeMin) / 2) + rangeMin;
                if (currentIterationValue == previousIterationValue)
                {
                    break;
                }
                previousIterationValue = currentIterationValue;
            }
            throw new SolutionFailureException("Bodice " + bodiceType.ToString() + " solution failure, could not calculate neck line length to match hood");
            //return BezierCalculatorResult.NoSolutionFound;
        }
Beispiel #3
0
        public override void BuildPart(Vector2 start)
        {
            base.BuildPart(start);

            BodiceMaker maker = new BodiceMaker(Start, Measurements, neckBezierLength, bodiceType);

            maker.CalcNeckDepth(curvinessFactor);
            Entities.AddRange(maker.Entities);

            PartEntityLine shoulderLine =
                AddLineEntity(Measurements.ShoulderLength, 270 + Measurements.ShoulderAngle);

            float bodiceSleeveCutoutHeightFromShoulderCircumference = Measurements.ShoulderCirc * 0.44f;

            PartEntityLine endScyeDepthCons1 =
                AddLineEntity(LineDirection.Down, bodiceSleeveCutoutHeightFromShoulderCircumference, EntityType.Construction);
            //1/4 of chest circ - measurement from start (CF) to shoulder end (start of scy depth line)
            float          chest             = (Measurements.ChestCirc * Utils.quarter) - (endScyeDepthCons1.End.X - start.X);
            PartEntityLine endScyeDepthCons2 =
                AddLineEntity(LineDirection.Right, chest, EntityType.Construction);

            BezierCalculator.CalcResult adjustmentsSleeve = BezierCalculator.Calc(
                sleeveBezierLength,
                shoulderLine.End,
                endScyeDepthCons2.End,
                BezierCalculator.BezierCalculatorControlPointDirection.Down,
                BezierCalculator.BezierCalculatorControlPointDirection.Left);

            if (!adjustmentsSleeve.SolutionFound)
            {
                throw new SolutionFailureException("Bodice " + bodiceType.ToString() + " solution failure, could not calculate sleeve line length to match sleeve");
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Bodice " + bodiceType.ToString() + " Shoulder solution found, required length " + sleeveBezierLength + " foundLength =" + adjustmentsSleeve.FoundLength);
            }

            //arm
            PartEntityBezier armBezier =
                AddBezierEntity(shoulderLine.End, endScyeDepthCons2.End, adjustmentsSleeve.Firstpoint, adjustmentsSleeve.SecondPoint);

            PartEntityLine remainingLengthLine =
                AddLineEntity(endScyeDepthCons2.End, new Vector2(endScyeDepthCons2.End.X, start.Y));
            PartEntityLine lastLine =
                AddLineEntity(remainingLengthLine.End, start);

            Vector2 textPos = start + Utils.Right(25) + Utils.Up(100);

            AddTextEntity(textPos, bodiceType.ToString());
            AddPartEntityGrainLine(
                textPos + Utils.Up(50),
                textPos + Utils.Up(200),
                "Grain", false);

            //add seam and hem allowance entities
            float sa = Measurements.GarmentSeamAllowance;
            float ha = Measurements.GarmentHemAllowance;

            List <PartEntityOffset> offsetLines = new List <PartEntityOffset>
            {
                maker.GarmentLengthLine.CalcOffset(sa, PerpendicularRotation.Clockwise, EntityType.PerpConstruction, EntityType.SA),
                maker.NeckBezier.CalcOffset(sa, PerpendicularRotation.Clockwise, EntityType.PerpConstruction, EntityType.SA),
                shoulderLine.CalcOffset(sa, PerpendicularRotation.Clockwise, EntityType.PerpConstruction, EntityType.SA),
                armBezier.CalcOffset(sa, PerpendicularRotation.Clockwise, EntityType.PerpConstruction, EntityType.SA),
                remainingLengthLine.CalcOffset(sa, PerpendicularRotation.Clockwise, EntityType.PerpConstruction, EntityType.SA),
                lastLine.CalcOffset(ha, PerpendicularRotation.Clockwise, EntityType.PerpConstruction, EntityType.HA),
            };

            PartEntityOffset.Intersect(offsetLines, EntityType.PerpConstruction);
            offsetLines.ForEach(x => AddLineEntities(x));

            //List<PerpConstructionLines> consLines = AddDefaultSAConstructionLines(sa, PerpendicularRotation.Clockwise, EntityType.ConstructionSA);
            //consLines.ForEach(x => x.AddLinesToPattern(this));
            //AddSALines(consLines);
        }