예제 #1
0
        private Vector2 AddBezier(SKCanvas canvas, SKPath pathBuilder, PartEntityBezier entity, Vector2 position, SKColor lineColor,
                                  bool showAttribue, bool showConstruction, bool showSA)
        {
            if (showAttribue)
            {
                using (var paint = new SKPaint())
                {
                    paint.IsAntialias = true;
                    paint.Color       = colorAttributes;
                    paint.IsStroke    = false;
                    canvas.DrawCircle(ToP(Scale(entity.Control1) + position), 3f, paint);
                    canvas.DrawLine(ToP(Scale(entity.Control1) + position), ToP(Scale(entity.Start) + position), paint);
                    canvas.DrawCircle(ToP(Scale(entity.Control2) + position), 3f, paint);
                    canvas.DrawLine(ToP(Scale(entity.Control2) + position), ToP(Scale(entity.End) + position), paint);
                }
            }

            entity.Lines.ForEach(x =>
            {
                AddLine(canvas, pathBuilder, x, position, lineColor, showConstruction, showSA);
            });

            return(entity.End);
        }
예제 #2
0
        public void BuildSleeve(float scpPeakLength, float adjustForLength = 0)
        {
            Entities.Clear();

            float frontStartCurvatureAdjustment = 60;
            float backEndCurvatureAdjustment    = 40;
            float frontScyBaseLineLength        = Measurements.BicepCirc * Utils.half;
            float backScyBaseLineLength         = Measurements.BicepCirc * Utils.half;
            float forearmDeltaLength            = (Measurements.ForeArmCirc - Measurements.WristCirc) * Utils.half;
            float scylineDeltaLength            = (Measurements.BicepCirc - Measurements.ForeArmCirc) * Utils.half;

            PartEntityLine writstLine =
                AddLineEntity(LineDirection.Right, Start, Measurements.WristCirc);

            AddLineEntity(LineDirection.Up, Measurements.WristToForeArm - adjustForLength, EntityType.Construction);
            AddLineEntity(LineDirection.Right, forearmDeltaLength, EntityType.Construction);
            AddLineEntity(LineDirection.Up, Measurements.ForeArmToBicep + Measurements.BicepToUpperBicep, EntityType.Construction);
            PartEntityLine scyRightSideLine =
                AddLineEntity(LineDirection.Right, scylineDeltaLength, EntityType.Construction);

            PartEntityLine frontScyBaseLine =
                AddLineEntity(LineDirection.Left, frontScyBaseLineLength, EntityType.Construction);
            PartEntityLine scyLeftSideLine =
                AddLineEntity(LineDirection.Left, backScyBaseLineLength, EntityType.Construction);

            AddLineEntity(LineDirection.Right, scylineDeltaLength, EntityType.Construction);
            AddLineEntity(LineDirection.Down, Measurements.ForeArmToBicep + Measurements.BicepToUpperBicep, EntityType.Construction);
            AddLineEntity(LineDirection.Right, forearmDeltaLength, EntityType.Construction);
            AddLineEntity(LineDirection.Down, Measurements.WristToForeArm, EntityType.Construction);

            PartEntityBezier sleeveLengthFrontBezier =
                AddBezierEntity(writstLine.End, scyRightSideLine.End, Utils.Up(40) + Utils.Right(10), Utils.Down(40));

            PartEntityLine scyPeakLine =
                AddLineEntity(LineDirection.Up, frontScyBaseLine.End, scpPeakLength, EntityType.Construction);

            AddLineEntity(LineDirection.Right, scyPeakLine.End, frontScyBaseLineLength * Utils.threeFifths, EntityType.Construction);
            PartEntityLine frontBezierEndLine1 =
                AddLineEntity(LineDirection.Down, scpPeakLength * Utils.threeFifths, EntityType.Construction);

            AddLineEntity(LineDirection.Left, scyPeakLine.End, backScyBaseLineLength * Utils.threeFifths, EntityType.Construction);
            PartEntityLine backBezierEndLine1 =
                AddLineEntity(LineDirection.Down, scpPeakLength * Utils.threeFifths, EntityType.Construction);

            PartEntityBezier frontBezier1 =
                AddBezierEntity(scyRightSideLine.End, frontBezierEndLine1.End, Utils.Left(frontStartCurvatureAdjustment), Utils.Down(20) + Utils.Right(10));

            PartEntityBezier frontBezier2 =
                AddBezierEntity(frontBezier1.End, scyPeakLine.End, Utils.Up(20) + Utils.Left(5), Utils.Right(80));

            PartEntityBezier backBezier1 =
                AddBezierEntity(backBezierEndLine1.End, Utils.Left(80), Utils.Up(20) + Utils.Right(15));

            PartEntityBezier backBezier2 =
                AddBezierEntity(scyLeftSideLine.End, Utils.Down(20) + Utils.Left(15), Utils.Right(backEndCurvatureAdjustment));

            PartEntityBezier sleeveLengthBackBezier =
                AddBezierEntity(scyLeftSideLine.End, Start, Utils.Down(40), Utils.Up(40) + Utils.Left(10));

            FrontBezierLengthCalculated = frontBezier1.Length + frontBezier2.Length;
            BackBezierLengthCalculated  = backBezier1.Length + backBezier2.Length;
            FrontBezier1            = frontBezier1;
            FrontBezier2            = frontBezier2;
            BackBezier1             = backBezier1;
            BackBezier2             = backBezier2;
            ScyeHeightCalculated    = scpPeakLength;
            WristLine               = writstLine;
            SleeveLengthFrontBezier = sleeveLengthFrontBezier;
            SleeveLengthBackBezier  = sleeveLengthBackBezier;
            SleeveHeightCalculated  = Math.Abs(Start.Y - scyPeakLine.End.Y);
        }
예제 #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);
        }
예제 #4
0
        public override void BuildPart(Vector2 start)
        {
            base.BuildPart(start);

            float garmentHoodBaseStep   = 50f;// (Measurements.GarmentBodiceFrontNeckDepth - Measurements.GarmentBodiceBackNeckDepth) * Utils.half;
            float hoodHeight            = (Utils.half * Measurements.ShoulderToShoulderOverHead) + (Utils.twoThirds * (garmentHoodBaseStep));
            float hoodHeightLessZipEdge = hoodHeight - Measurements.GarmentHoodZipEdge;
            float hoodInsertWidth       = Measurements.GarmentHoodInsertWidth * Utils.half;
            float hoodWidth             = Measurements.GarmentHoodLenghtFromTemple + (Utils.half * Measurements.CircTempleToTemple) - hoodInsertWidth;
            float hoodHeadCurveRadius   = Measurements.HeadBackCurveRadius;

            float fullHoodWidth           = hoodWidth + Measurements.GarmentHoodSetBackFromZip;
            float frontBaseLength         = (fullHoodWidth + hoodInsertWidth) * Utils.threeFifths;
            float backBaseLength          = fullHoodWidth - frontBaseLength;
            float backBezierVerticalPoint = Utils.twoThirds * garmentHoodBaseStep;

            PartEntityLine hoodZipEdge =
                AddLineEntity(LineDirection.Up, start, Measurements.GarmentHoodZipEdge);
            PartEntityLine hoodSetBackUp1 =
                AddLineEntity(LineDirection.Left, Measurements.GarmentHoodSetBackFromZip, EntityType.Construction);
            PartEntityLine hoodSetBackUp2 =
                AddLineEntity(LineDirection.Up, hoodHeightLessZipEdge * Utils.third, EntityType.Construction);

            //PartEntity zipBezier;
            //if (Measurements.GarmentHoodSetBackFromZip == 0)
            //{
            //    zipBezier =
            //        AddLineEntity(hoodZipEdge.End, hoodSetBackUp2.End);
            //}
            //else
            //{
            //    zipBezier =
            //        AddBezierEntity(hoodZipEdge.End, hoodSetBackUp2.End,
            //        Measurements.GarmentHoodSetBackFromZip > 0 ? Utils.Left(40) : Utils.Left(0),
            //        Measurements.GarmentHoodSetBackFromZip > 0 ? Utils.Down(80) : Utils.Left(0));
            //}

            PartEntityBezier zipBezier =
                AddBezierEntity(hoodZipEdge.End, hoodSetBackUp2.End,
                                Measurements.GarmentHoodSetBackFromZip > 0 ? Utils.Left(40) : Utils.Left(0),
                                Measurements.GarmentHoodSetBackFromZip > 0 ? Utils.Down(80) : Utils.Left(0));

            PartEntityLine hoodHeightLessZipEdgeLine =
                AddLineEntity(LineDirection.Up, zipBezier.End, hoodHeightLessZipEdge * Utils.twoThirds);
            PartEntityLine hoodTopToHeadCurveStart =
                AddLineEntity(LineDirection.Left, hoodWidth - hoodHeadCurveRadius);

            AddLineEntity(LineDirection.Left, hoodHeadCurveRadius, EntityType.Construction);
            PartEntityLine hoodTopToHeadCurveEnd =
                AddLineEntity(LineDirection.Down, hoodHeadCurveRadius, EntityType.Construction);
            PartEntityBezier headBezier =
                AddBezierEntity(hoodTopToHeadCurveStart.End, hoodTopToHeadCurveEnd.End, Utils.Left(100), Utils.Up(100));
            PartEntityLine hoodToEndWidth =
                AddLineEntity(LineDirection.Down, hoodTopToHeadCurveEnd.End, (start.Y - hoodTopToHeadCurveEnd.End.Y) - garmentHoodBaseStep);

            AddLineEntity(LineDirection.Right, backBaseLength, EntityType.Construction);
            PartEntityLine baseNeckLineDown =
                AddLineEntity(LineDirection.Down, garmentHoodBaseStep, EntityType.Construction);

            AddLineEntity(LineDirection.Right, frontBaseLength, EntityType.Construction);
            PartEntityBezier neckBezierBack =
                AddBezierEntity(hoodToEndWidth.End, baseNeckLineDown.End + Utils.Up(backBezierVerticalPoint), Utils.Right(20), Utils.Left(20) + Utils.Up(20));
            PartEntityBezier neckBezierFront =
                AddBezierEntity(neckBezierBack.End, start, Utils.Right(40) + Utils.Down(40), Utils.Left(50));

            Vector2 textPos = start + Utils.Left(fullHoodWidth) + Utils.Right(25) + Utils.Up(75);

            AddTextEntity(textPos, "Hood");
            AddPartEntityGrainLine(
                textPos + Utils.Up(0) + Utils.Right(75),
                textPos + Utils.Up(150) + Utils.Right(75),
                "Grain", false);

            HoodPathLengthForCutout += hoodTopToHeadCurveStart.Length();
            HoodPathLengthForCutout += headBezier.Length;;
            HoodPathLengthForCutout += hoodToEndWidth.Length();
            HoodNeckFrontLength      = neckBezierFront.Length;
            HoodNeckBackLength       = neckBezierBack.Length + hoodInsertWidth;

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

            List <PartEntityOffset> offsetLines = new List <PartEntityOffset>
            {
                hoodZipEdge.CalcOffset(ha, PerpendicularRotation.AntiClockwise, EntityType.PerpConstruction, EntityType.HA),
                zipBezier.CalcOffset(ha, PerpendicularRotation.AntiClockwise, EntityType.PerpConstruction, EntityType.HA),
                hoodHeightLessZipEdgeLine.CalcOffset(ha, PerpendicularRotation.AntiClockwise, EntityType.PerpConstruction, EntityType.HA),
                hoodTopToHeadCurveStart.CalcOffset(sa, PerpendicularRotation.AntiClockwise, EntityType.PerpConstruction, EntityType.SA),
                headBezier.CalcOffset(sa, PerpendicularRotation.AntiClockwise, EntityType.PerpConstruction, EntityType.SA),
                hoodToEndWidth.CalcOffset(sa, PerpendicularRotation.AntiClockwise, EntityType.PerpConstruction, EntityType.SA),
                neckBezierBack.CalcOffset(sa, PerpendicularRotation.AntiClockwise, EntityType.PerpConstruction, EntityType.SA),
                neckBezierFront.CalcOffset(sa, PerpendicularRotation.AntiClockwise, EntityType.PerpConstruction, EntityType.SA),
            };

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