Exemplo n.º 1
0
        private static void ImportWorkspaceFile(object sender, DoWorkEventArgs args)
        {
            var           fileName      = ((List <object>)args.Argument)[0] as string;
            var           serializer    = new System.Xml.Serialization.XmlSerializer(typeof(WorkspaceFile));
            WorkspaceFile workspaceFile = null;

            frmStudioMain.SceneControl.DisableRendering();

            using (var streamReader = new StreamReader(fileName))
            {
                workspaceFile = (WorkspaceFile)serializer.Deserialize(streamReader);

                foreach (var object3d in workspaceFile.Objects)
                {
                    var stlModel = new STLModel3D(STLModel3D.TypeObject.Model, ObjectView.BindingSupported, object3d, ObjectView.NextObjectIndex, false);

                    stlModel.Triangles.UpdateSelectedOrientationTriangles(stlModel);
                    stlModel.UpdateBoundries();
                }

                if (!string.IsNullOrEmpty(PrintJobManager.PrintjobName))
                {
                    PrintJobManager.PrintjobName = workspaceFile.PrintJobName;
                }
            }
        }
Exemplo n.º 2
0
        void CreateMeasureCube(Vector2 startPoint, string text, double width, double height)
        {
            //outerbox
            var cubeModel = new STLModel3D(TypeObject.None, false);
            //cubeModel = (new Cube(12.8f, 8f, 5f)).AsSTLModel3D(Managers.MaterialManager.DefaultMaterial);

            var outerPath         = new Polygon(new PolygonPoint(-(width / 2), -(height / 2)), new PolygonPoint((width / 2), -(height / 2)), new PolygonPoint((width / 2), (height / 2)), new PolygonPoint(-(width / 2), (height / 2)));
            var textAsPolygonSet  = new PolygonSet();
            var letterPolygonsTop = FontTessellationEngine.ConvertStringToTrianglesWithOuterPath(text, FontStyle.Bold, outerPath, out textAsPolygonSet);

            outerPath = new Polygon(new PolygonPoint(-(width / 2), -(height / 2)), new PolygonPoint((width / 2), -(height / 2)), new PolygonPoint((width / 2), (height / 2)), new PolygonPoint(-(width / 2), (height / 2)));
            var letterPolygonsBottom = FontTessellationEngine.ConvertStringToTrianglesWithOuterPath(text, FontStyle.Bold, outerPath, out textAsPolygonSet);

            foreach (var t in letterPolygonsBottom[0])
            {
                t.Flip();
            }

            cubeModel.Triangles = letterPolygonsTop;
            foreach (var t in letterPolygonsTop[0])
            {
                t.Vectors[0].Position += new Vector3Class(0, 0, 5);
                t.Vectors[1].Position += new Vector3Class(0, 0, 5);
                t.Vectors[2].Position += new Vector3Class(0, 0, 5);
            }

            cubeModel.Triangles[0].AddRange(letterPolygonsBottom[0]);

            cubeModel._scaleFactorX = cubeModel._scaleFactorY = cubeModel._scaleFactorZ = 1;
            cubeModel.Scale(0.1f, 0.1f, 1f, Events.ScaleEventArgs.TypeAxis.ALL, true, true);

            CreateExtrudeTriangles(cubeModel, outerPath.Points);
            foreach (var polygon in outerPath.Holes)
            {
                CreateExtrudeTriangles(cubeModel, polygon.Points, true);

                foreach (var holePolygon in polygon.Holes)
                {
                    CreateExtrudeTriangles(cubeModel, holePolygon.Points, true);
                }
            }

            //center triangle
            cubeModel.UpdateBoundries();
            cubeModel.UpdateDefaultCenter();
            cubeModel.Triangles.UpdateWithMoveTranslation(new Vector3Class(startPoint.X, startPoint.Y, 0) - new Vector3Class(cubeModel.LeftPoint, cubeModel.BackPoint, -0.2f));

            //orient model properly
            cubeModel.HorizontalMirror(false, true);
            cubeModel.Rotate(0, 0, 180, Events.RotationEventArgs.TypeAxis.Z);
            cubeModel.UpdateTrianglesMinMaxZ();

            this.Triangles[0].AddRange(cubeModel.Triangles[0]);
        }
Exemplo n.º 3
0
        internal static void Calculate(STLModel3D model, DAL.Materials.Material selectedMaterial, Vector3Class modelTranslation,
                                       float maxBuildSizeX, float maxBuildSizeY,
                                       float sideABHeight, float sideBDHeight, float sideBCAngleOffset, float sideABAngleOffset,
                                       double sideABAngle, double sideBCAngle,
                                       float sideB,
                                       float calibrationModelSizeX, float calibrationModelSizeY)
        {
            model.UpdateBoundries();
            var moveYFactor = -(maxBuildSizeY / 2);

            for (var arrayIndex = 0; arrayIndex < model.Triangles.Count; arrayIndex++)
            {
                for (var triangleIndex = 0; triangleIndex < model.Triangles[arrayIndex].Count; triangleIndex++)
                {
                    model.Triangles[arrayIndex][triangleIndex].Vectors[0].Position += new Vector3Class(0, moveYFactor, 0);
                    model.Triangles[arrayIndex][triangleIndex].Vectors[1].Position += new Vector3Class(0, moveYFactor, 0);
                    model.Triangles[arrayIndex][triangleIndex].Vectors[2].Position += new Vector3Class(0, moveYFactor, 0);
                }
            }

            model.UpdateBoundries();

            float sideDHeightDifference = (float)(sideABHeight - sideBDHeight);

            if (sideDHeightDifference < 0)
            {
                sideDHeightDifference = -sideDHeightDifference;
            }
            //change model vectors

            if (float.IsNaN(sideABAngleOffset))
            {
                sideABAngleOffset = 0;
            }
            if (float.IsNaN(sideBCAngleOffset))
            {
                sideBCAngleOffset = 0;
            }

            var leftSideMaxCorrection  = new Vector3((sideABAngleOffset), sideDHeightDifference, 0);
            var rightSideMaxCorrection = new Vector3((sideBCAngleOffset), 0, 0);

            if (sideABHeight >= sideBDHeight)                                        //highest point at right side
            {
                leftSideMaxCorrection  = new Vector3(leftSideMaxCorrection.X, 0, 0); //NO Y correction
                rightSideMaxCorrection = new Vector3(rightSideMaxCorrection.X, sideDHeightDifference, 0);
            }

            for (var arrayIndex = 0; arrayIndex < model.Triangles.Count; arrayIndex++)
            {
                for (var triangleIndex = 0; triangleIndex < model.Triangles[arrayIndex].Count; triangleIndex++)
                {
                    for (var vectorIndex = 0; vectorIndex < 3; vectorIndex++)
                    {
                        var correctionVector = new Vector3Class();

                        var orgPoint = model.Triangles[arrayIndex][triangleIndex].Vectors[vectorIndex].Position;

                        var vectorOffSetPercentageABY = orgPoint.Y / (float)sideABHeight;
                        var vectorOffSetPercentageBDY = orgPoint.Y / (float)sideBDHeight;

                        var horizontalABOffsetPercentage = ((calibrationModelSizeX / 2) + orgPoint.X) / calibrationModelSizeX;
                        var horizontalBCOffsetPercentage = (1 - (orgPoint.X / (calibrationModelSizeX / 2))) / 2;

                        if (orgPoint.X < 0)
                        {
                            horizontalABOffsetPercentage = 1 - (0.5f / (calibrationModelSizeX / 2)) * ((calibrationModelSizeX / 2) - orgPoint.X);
                            horizontalBCOffsetPercentage = (-orgPoint.X + (calibrationModelSizeX / 2)) / calibrationModelSizeX;
                        }

                        var verticalOffsetPercentage = vectorOffSetPercentageABY * (1 - horizontalABOffsetPercentage);

                        if (sideABHeight < sideBDHeight)
                        {
                            verticalOffsetPercentage = vectorOffSetPercentageBDY * (1 - horizontalBCOffsetPercentage);
                        }

                        if (sideABAngle <= 90)    //angle A forward /
                        {
                            correctionVector = new Vector3Class(-vectorOffSetPercentageABY * rightSideMaxCorrection.X * horizontalABOffsetPercentage, 0, 0);
                        }
                        else if (sideABAngle > 90)    //angle A backward
                        {
                            correctionVector = new Vector3Class(vectorOffSetPercentageABY * leftSideMaxCorrection.X * horizontalABOffsetPercentage, 0, 0);
                        }

                        if (sideBCAngle <= 90)    //angle C forward \
                        {
                            correctionVector += new Vector3Class(-vectorOffSetPercentageBDY * leftSideMaxCorrection.X * horizontalBCOffsetPercentage, 0, 0);
                        }
                        else if (sideBCAngle > 90)    //angle C backward /
                        {
                            correctionVector += new Vector3Class(vectorOffSetPercentageBDY * rightSideMaxCorrection.X * horizontalBCOffsetPercentage, 0, 0);
                        }

                        //Y correction
                        if (sideABHeight < sideBDHeight && sideDHeightDifference != 0)
                        {
                            correctionVector += new Vector3Class(0, verticalOffsetPercentage * sideDHeightDifference, 0);
                        }
                        else if (sideDHeightDifference != 0)
                        {
                            correctionVector += new Vector3Class(0, verticalOffsetPercentage * sideDHeightDifference, 0);
                        }

                        model.Triangles[arrayIndex][triangleIndex].Vectors[vectorIndex].Position += correctionVector;
                    }
                }
            }

            //move model back to normal position
            moveYFactor = (maxBuildSizeY / 2);
            for (var arrayIndex = 0; arrayIndex < model.Triangles.Count; arrayIndex++)
            {
                for (var triangleIndex = 0; triangleIndex < model.Triangles[arrayIndex].Count; triangleIndex++)
                {
                    model.Triangles[arrayIndex][triangleIndex].Vectors[0].Position += new Vector3Class(0, moveYFactor, 0);
                    model.Triangles[arrayIndex][triangleIndex].Vectors[1].Position += new Vector3Class(0, moveYFactor, 0);
                    model.Triangles[arrayIndex][triangleIndex].Vectors[2].Position += new Vector3Class(0, moveYFactor, 0);
                }
            }

            //find highest vector and calc the scaling factor with original factor
            var scaleFactorY = maxBuildSizeY / sideABHeight;

            if (sideBDHeight > sideABHeight)
            {
                scaleFactorY = maxBuildSizeY / sideBDHeight;
            }

            var resolutionScalingFactor = maxBuildSizeX / 192f;

            var modelScaleFactorX = ((maxBuildSizeX / sideB) / BasicCorrectionModel.ModelDefaultCorrectionFactorX) / resolutionScalingFactor * (float)selectedMaterial.ShrinkFactor * model.ScaleFactorX;
            var modelScaleFactorY = ((scaleFactorY / BasicCorrectionModel.ModelDefaultCorrectionFactorY) / resolutionScalingFactor) * (float)selectedMaterial.ShrinkFactor * model.ScaleFactorY;

            model.Scale(modelScaleFactorX, 1, 1, Events.ScaleEventArgs.TypeAxis.X, false);
            model.Scale(1, modelScaleFactorY, 1, Events.ScaleEventArgs.TypeAxis.Y, false);
            model.Scale(1, 1, model.ScaleFactorZ * (float)selectedMaterial.ShrinkFactor, Events.ScaleEventArgs.TypeAxis.Z, false);

            //combine movetranslation with scaled vector
            if (model is SupportCone)
            {
                model.MoveTranslation += modelTranslation;
            }

            model.UpdateBoundries();

            var stopwatch = new Stopwatch();

            stopwatch.Start();

            //update triangle normals
            foreach (var triangleArray in model.Triangles)
            {
                foreach (var triangle in triangleArray)
                {
                    triangle.CalcNormal();
                }
            }

            if (!(model is SupportCone))
            {
                if (model.SupportStructure != null)
                {
                    foreach (var supportCone in model.TotalObjectSupportCones)
                    {
                        Calculate(supportCone, selectedMaterial, new Vector3Class(), maxBuildSizeX, maxBuildSizeY, sideABHeight, sideBDHeight, sideBCAngleOffset, sideABAngleOffset, sideABAngle, sideBCAngle, sideB, calibrationModelSizeX, calibrationModelSizeY);
                    }
                }
            }

            if (model.SupportBasementStructure != null)
            {
                Calculate(model.SupportBasementStructure, selectedMaterial, modelTranslation, maxBuildSizeX, maxBuildSizeY, sideABHeight, sideBDHeight, sideBCAngleOffset, sideABAngleOffset, sideABAngle, sideBCAngle, sideB, calibrationModelSizeX, calibrationModelSizeY);
            }
        }
Exemplo n.º 4
0
        internal static void Calculate(STLModel3D model, DAL.Materials.Material selectedMaterial, Vector3Class modelTranslation)
        {
            model.UpdateBoundries();

            //properties of right part of trapezoid
            var sideA = PrintJobManager.SelectedPrinter.TrapeziumCorrectionInputA;
            var sideB = PrintJobManager.SelectedPrinter.TrapeziumCorrectionInputB;
            var sideC = PrintJobManager.SelectedPrinter.TrapeziumCorrectionInputC;
            var sideD = PrintJobManager.SelectedPrinter.TrapeziumCorrectionInputD;
            var sideE = PrintJobManager.SelectedPrinter.TrapeziumCorrectionInputE;
            var sideF = PrintJobManager.SelectedPrinter.TrapeziumCorrectionInputF;

            var sideBCAngleOffset = 0f;
            var sideBCAngle       = 90d;

            var maxBuildSizeX = PrintJobManager.SelectedPrinter.MaxBuildSizeX;
            var maxBuildSizeY = PrintJobManager.SelectedPrinter.MaxBuildSizeY;

            var calibrationModelSizeX = BasicCorrectionModel.ModelSizeX;
            var calibrationModelSizeY = BasicCorrectionModel.ModelSizeY;

            var triangleBArea = Math.Sqrt(((sideC + sideB + sideF) / 2)
                                          * (((sideC + sideB + sideF) / 2) - sideC)
                                          * (((sideC + sideB + sideF) / 2) - sideB)
                                          * (((sideC + sideB + sideF) / 2) - sideF));

            var sideBDHeight = ((float)(triangleBArea * 2) / sideB);

            if (sideA != calibrationModelSizeY || sideB != calibrationModelSizeX ||
                sideC != calibrationModelSizeY || sideD != calibrationModelSizeX ||
                sideE != sideF)
            {
                sideBCAngle       = MathHelper.RadiansToDegrees(Math.Acos((Math.Pow(sideC, 2) + Math.Pow(sideB, 2) - Math.Pow(sideF, 2)) / (2 * sideC * sideB)));
                sideBCAngleOffset = (float)Math.Sqrt(Math.Pow(sideC, 2) - Math.Pow(sideBDHeight, 2));

                if (sideBCAngle > 90)
                {
                    sideBCAngleOffset = -sideBCAngleOffset;
                }
            }

            //properties of left part of trapezoid
            var sideABAngleOffset = 0f;
            var sideABAngle       = 90d;

            var triangleAArea = Math.Sqrt(((sideA + sideB + sideE) / 2)
                                          * (((sideA + sideB + sideE) / 2) - sideA)
                                          * (((sideA + sideB + sideE) / 2) - sideB)
                                          * (((sideA + sideB + sideE) / 2) - sideE));

            var sideABHeight = ((float)(triangleAArea * 2) / sideB);

            if (sideA != calibrationModelSizeY || sideB != calibrationModelSizeX ||
                sideC != calibrationModelSizeY || sideD != calibrationModelSizeX ||
                sideE != sideF)
            {
                sideABAngleOffset = (float)Math.Sqrt(Math.Pow(sideA, 2) - Math.Pow(sideABHeight, 2));
                sideABAngle       = MathHelper.RadiansToDegrees(Math.Acos((Math.Pow(sideA, 2) + Math.Pow(sideB, 2) - Math.Pow(sideE, 2)) / (2 * sideA * sideB)));
                if (sideABAngle < 90)
                {
                    sideABAngleOffset = -sideABAngleOffset;
                }
            }

            Calculate(model, selectedMaterial, modelTranslation, maxBuildSizeX, maxBuildSizeY, sideABHeight, sideBDHeight, sideBCAngleOffset,
                      sideABAngleOffset, sideABAngle, sideBCAngle, sideB, calibrationModelSizeX, calibrationModelSizeY);
        }
Exemplo n.º 5
0
        internal static void Calculate(STLModel3D model)
        {
            model.UpdateBoundries();

            //properties of right part of trapezoid
            var sideBCAngleOffset = 0f;
            var sideBCAngle       = 90d;
            var sideBDHeight      = Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputC;

            if (Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputA != 70 || Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputB != 120 ||
                Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputC != 70 || Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputD != 120)
            {
                sideBCAngleOffset = (float)(Math.Pow(Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputC, 2) - Math.Pow(Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputF, 2) + Math.Pow(Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputD, 2)) / (2 * Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputD);
                sideBCAngle       = MathHelper.RadiansToDegrees(Math.Acos(-sideBCAngleOffset / Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputF));
                sideBDHeight      = (float)Math.Sqrt(Math.Pow(Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputC, 2) - Math.Pow(sideBCAngleOffset, 2));
            }

            //properties of left part of trapezoid
            var sideABAngleOffset = 0f;
            var sideABAngle       = 90d;
            var sideABHeight      = Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputA;

            if (Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputA != 70 || Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputB != 120 ||
                Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputC != 70 || Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputD != 120)
            {
                sideABAngleOffset = (float)(Math.Pow(Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputA, 2) - Math.Pow(Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputE, 2) + Math.Pow(Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputB, 2)) / (2 * Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputB);
                sideABAngle       = MathHelper.RadiansToDegrees(Math.Acos(-sideABAngleOffset / Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputE));
                sideABHeight      = (float)Math.Sqrt(Math.Pow(Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputA, 2) - Math.Pow(sideABAngleOffset, 2));
            }
            model.UpdateBoundries();
            var moveYFactor = -model.FrontPoint;

            for (var arrayIndex = 0; arrayIndex < model.Triangles.Count; arrayIndex++)
            {
                for (var triangleIndex = 0; triangleIndex < model.Triangles[arrayIndex].Count; triangleIndex++)
                {
                    model.Triangles[arrayIndex][triangleIndex].Vectors[0].Position += new Vector3(0, moveYFactor, 0);
                    model.Triangles[arrayIndex][triangleIndex].Vectors[1].Position += new Vector3(0, moveYFactor, 0);
                    model.Triangles[arrayIndex][triangleIndex].Vectors[2].Position += new Vector3(0, moveYFactor, 0);
                }
            }

            model.UpdateBoundries();

            var modelWidth = model.RightPoint - model.LeftPoint;

            float sideDHeightDifference = (float)(sideABHeight - sideBDHeight);

            if (sideDHeightDifference < 0)
            {
                sideDHeightDifference = -sideDHeightDifference;
            }
            if (sideABAngle <= 90)    //angle A forward /
            {
                var leftSideMaxCorrection = new Vector3((sideABAngleOffset), ((float)(sideABHeight - sideBDHeight)), 0);
                if (sideABHeight >= sideBDHeight)                                       //highest point at right side
                {
                    leftSideMaxCorrection = new Vector3(leftSideMaxCorrection.X, 0, 0); //NO Y correction
                }

                //change model vectors
                for (var arrayIndex = 0; arrayIndex < model.Triangles.Count; arrayIndex++)
                {
                    for (var triangleIndex = 0; triangleIndex < model.Triangles[arrayIndex].Count; triangleIndex++)
                    {
                        for (var vectorIndex = 0; vectorIndex < 3; vectorIndex++)
                        {
                            var orgPoint = model.Triangles[arrayIndex][triangleIndex].Vectors[vectorIndex].Position;
                            if (orgPoint.X <= 0)
                            {
                                var vectorOffSetPercentageX = orgPoint.Y / (float)sideABHeight;
                                var vectorOffSetPercentageY = 1 - (-orgPoint.X / (modelWidth / 2));

                                var vectorOffSetPercentageYOffset = vectorOffSetPercentageY * (sideDHeightDifference / 2);

                                var correctionVectorY = (vectorOffSetPercentageX * vectorOffSetPercentageYOffset);
                                correctionVectorY = sideABAngle >= sideBDHeight ? -correctionVectorY : correctionVectorY;
                                var correctionVector = new Vector3(leftSideMaxCorrection.X * vectorOffSetPercentageX, correctionVectorY, 0);
                                model.Triangles[arrayIndex][triangleIndex].Vectors[vectorIndex].Position += correctionVector;
                            }
                        }
                    }
                }
            }
            else if (sideABAngle > 90)    //angle A backward
            {
                var leftSideMaxCorrection = new Vector3(sideABAngleOffset, sideDHeightDifference, 0);
                if (sideABHeight >= sideBDHeight)                                       //highest point at right side
                {
                    leftSideMaxCorrection = new Vector3(leftSideMaxCorrection.X, 0, 0); //NO Y correction
                }

                //change model vectors
                for (var arrayIndex = 0; arrayIndex < model.Triangles.Count; arrayIndex++)
                {
                    for (var triangleIndex = 0; triangleIndex < model.Triangles[arrayIndex].Count; triangleIndex++)
                    {
                        for (var vectorIndex = 0; vectorIndex < 3; vectorIndex++)
                        {
                            var orgPoint = model.Triangles[arrayIndex][triangleIndex].Vectors[vectorIndex].Position;
                            if (orgPoint.X <= 0)
                            {
                                var vectorOffSetPercentageX = orgPoint.Y / sideABHeight;
                                var vectorOffSetPercentageY = 1 - (-orgPoint.X / (modelWidth / 2));

                                var vectorOffSetPercentageYOffset = vectorOffSetPercentageY * (sideDHeightDifference / 2);
                                var correctionVectorY             = (vectorOffSetPercentageX * vectorOffSetPercentageYOffset);
                                correctionVectorY = sideABAngle >= sideBDHeight ? correctionVectorY : -correctionVectorY;
                                var correctionVector = new Vector3(leftSideMaxCorrection.X * vectorOffSetPercentageX, correctionVectorY, 0);

                                model.Triangles[arrayIndex][triangleIndex].Vectors[vectorIndex].Position += correctionVector;
                            }
                        }
                    }
                }
            }

            if (sideBCAngle <= 90)    //angle C forward \
            {
                var rightSideMaxCorrection = new Vector3(-sideBCAngleOffset, sideDHeightDifference, 0);

                if (sideABHeight < sideBDHeight)                                          //highest point at right side
                {
                    rightSideMaxCorrection = new Vector3(rightSideMaxCorrection.X, 0, 0); //NO Y correction
                }

                //change model vectors
                for (var arrayIndex = 0; arrayIndex < model.Triangles.Count; arrayIndex++)
                {
                    for (var triangleIndex = 0; triangleIndex < model.Triangles[arrayIndex].Count; triangleIndex++)
                    {
                        for (var vectorIndex = 0; vectorIndex < 3; vectorIndex++)
                        {
                            //var vectorOffSetPercentage = 0f;
                            var orgPoint = model.Triangles[arrayIndex][triangleIndex].Vectors[vectorIndex].Position;

                            if (orgPoint.X > 0)
                            {
                                var vectorOffSetPercentageX = orgPoint.Y / (float)sideBDHeight;
                                var vectorOffSetPercentageY = ((modelWidth / 2) + orgPoint.X) / modelWidth;
                                var correctionVectorX       = vectorOffSetPercentageX * rightSideMaxCorrection.X;
                                var correctionVectorY       = (vectorOffSetPercentageY * vectorOffSetPercentageX * sideDHeightDifference);
                                correctionVectorY = sideABHeight < correctionVectorY ? -correctionVectorY : correctionVectorY;
                                model.Triangles[arrayIndex][triangleIndex].Vectors[vectorIndex].Position += new Vector3(-correctionVectorX, correctionVectorY, 0);
                            }
                        }
                    }
                }
            }
            if (sideBCAngle > 90)    //angle C backward /
            {
                var rightSideMaxCorrection = new Vector3(-sideBCAngleOffset, sideDHeightDifference, 0);

                if (sideABHeight < sideBDHeight)                                          //highest point at right side
                {
                    rightSideMaxCorrection = new Vector3(rightSideMaxCorrection.X, 0, 0); //NO Y correction
                }

                //change model vectors
                for (var arrayIndex = 0; arrayIndex < model.Triangles.Count; arrayIndex++)
                {
                    for (var triangleIndex = 0; triangleIndex < model.Triangles[arrayIndex].Count; triangleIndex++)
                    {
                        for (var vectorIndex = 0; vectorIndex < 3; vectorIndex++)
                        {
                            var orgPoint = model.Triangles[arrayIndex][triangleIndex].Vectors[vectorIndex].Position;
                            if (orgPoint.X > 0)
                            {
                                var vectorOffSetPercentageX = orgPoint.Y / (float)sideBDHeight;
                                var vectorOffSetPercentageY = ((modelWidth / 2) + orgPoint.X) / modelWidth;
                                var correctionVectorX       = vectorOffSetPercentageX * rightSideMaxCorrection.X;
                                var correctionVectorY       = (vectorOffSetPercentageY * vectorOffSetPercentageX * sideDHeightDifference);
                                correctionVectorY = sideABHeight < correctionVectorY ? correctionVectorY : -correctionVectorY;
                                model.Triangles[arrayIndex][triangleIndex].Vectors[vectorIndex].Position += new Vector3(-correctionVectorX, correctionVectorY, 0);
                            }
                        }
                    }
                }
            }

            model.Scale(144 / Managers.PrinterManager.DefaultPrinter.TrapeziumCorrectionInputB, 1, 1, Events.ScaleEventArgs.TypeAxis.X);
            model.Scale(1, 90f / Math.Max(sideABHeight, sideBDHeight), 1, Events.ScaleEventArgs.TypeAxis.Y);
            model.UpdateDefaultCenter();

            //var rotate model with angle of side D

            if (model.SupportStructure != null)
            {
                foreach (var supportCone in model.SupportStructure)
                {
                    ModelCorrections.Trapezoid.Calculate(supportCone);
                }
            }

            if (model.Triangles.HorizontalSurfaces != null && model.Triangles.HorizontalSurfaces.SupportStructure != null)
            {
                foreach (var supportCone in model.Triangles.HorizontalSurfaces.SupportStructure)
                {
                    ModelCorrections.Trapezoid.Calculate(supportCone);
                }
            }

            if (model.Triangles.FlatSurfaces != null && model.Triangles.FlatSurfaces.SupportStructure != null)
            {
                foreach (var supportCone in model.Triangles.FlatSurfaces.SupportStructure)
                {
                    ModelCorrections.Trapezoid.Calculate(supportCone);
                }
            }

            if (model.SupportBasementStructure != null)
            {
                ModelCorrections.Trapezoid.Calculate(model.SupportBasementStructure);
            }
        }