Пример #1
0
        private void TestAxeSimple1(AxeSimple1 arg)
        {
            BezierSegment3D[][] segmentSets = new BezierSegment3D[5][];

            PrepFor3D();

            #region Lines

            for (int cntr = 0; cntr < 5; cntr++)
            {
                if (!chkAxe3D.IsChecked.Value && cntr != 2)
                {
                    continue;
                }

                #region scale, z

                double zL, zR, scaleX, scaleY;

                switch (cntr)
                {
                    case 0:
                    case 4:
                        zL = arg.Z2L;
                        zR = arg.Z2R;
                        scaleX = arg.Scale2X;
                        scaleY = arg.Scale2Y;
                        break;

                    case 1:
                    case 3:
                        zL = zR = arg.Z1;
                        scaleX = arg.Scale1X;
                        scaleY = arg.Scale1Y;
                        break;

                    case 2:
                        zL = zR = 0;
                        scaleX = scaleY = 1;
                        break;

                    default:
                        throw new ApplicationException("Unknown cntr: " + cntr.ToString());
                }

                if (cntr < 2)
                {
                    zL *= -1d;
                    zR *= -1d;
                }

                #endregion

                Point3D[] endPoints = new[]
                    {
                        new Point3D(-arg.leftX, -arg.leftY * scaleY, zL),     // top left
                        new Point3D(-arg.leftX, arg.leftY * scaleY, zL),     // bottom left
                        new Point3D(arg.rightX * scaleX, -arg.rightY * scaleY, zR),       // top right
                        new Point3D(arg.rightX * scaleX, arg.rightY * scaleY, zR),        // bottom right
                    };

                BezierSegment3D[] segments = TestAxeSimple1_Segments(endPoints, arg);
                segmentSets[cntr] = segments;

                DrawBezierLines(segments, chkAxeLine.IsChecked.Value, chkAxeControl.IsChecked.Value, chkAxeEnd.IsChecked.Value);
            }

            #endregion
            #region Plates

            if (chkAxe3D.IsChecked.Value)
            {
                Color edgeColor = Colors.GhostWhite;
                Color middleColor = Colors.DimGray;

                int squareCount = 8;

                DrawBezierPlates(squareCount, segmentSets[0], segmentSets[1], middleColor, false);

                DrawBezierPlates(squareCount, new[] { segmentSets[1][0], segmentSets[1][1] }, new[] { segmentSets[2][0], segmentSets[2][1] }, middleColor, false);
                DrawBezierPlate(squareCount, segmentSets[1][2], segmentSets[2][2], edgeColor, true);

                DrawBezierPlates(squareCount, new[] { segmentSets[2][0], segmentSets[2][1] }, new[] { segmentSets[3][0], segmentSets[3][1] }, middleColor, false);
                DrawBezierPlate(squareCount, segmentSets[2][2], segmentSets[3][2], edgeColor, true);

                DrawBezierPlates(squareCount, segmentSets[3], segmentSets[4], middleColor, false);

                // End cap plates
                if (arg.isCenterFilled)
                {
                    for (int cntr = 0; cntr < 2; cntr++)
                    {
                        int index = cntr == 0 ? 0 : 4;

                        DrawBezierPlate(squareCount, segmentSets[index][0], segmentSets[index][1], middleColor, false);        // top - bottom

                        BezierSegment3D extraSeg = new BezierSegment3D(segmentSets[index][2].EndIndex0, segmentSets[index][2].EndIndex1, null, segmentSets[index][2].AllEndPoints);
                        DrawBezierPlate(squareCount, extraSeg, segmentSets[index][2], middleColor, false);     // edge
                    }
                }
                else
                {
                    DrawBezierPlates(squareCount, segmentSets[0], segmentSets[4], middleColor, false);
                }
            }

            #endregion
        }
Пример #2
0
        private static BezierSegment3D[] TestAxeSimple1_Segments(Point3D[] endPoints, AxeSimple1 arg)
        {
            const int TOPLEFT = 0;
            const int BOTTOMLEFT = 1;
            const int TOPRIGHT = 2;
            const int BOTTOMRIGHT = 3;

            // Edge
            Point3D controlTR = BezierUtil.GetControlPoint_End(endPoints[TOPRIGHT], endPoints[BOTTOMRIGHT], endPoints[TOPLEFT], true, arg.edgeAngle, arg.edgePercent);
            Point3D controlBR = BezierUtil.GetControlPoint_End(endPoints[BOTTOMRIGHT], endPoints[TOPRIGHT], endPoints[BOTTOMLEFT], true, arg.edgeAngle, arg.edgePercent);
            BezierSegment3D edge = new BezierSegment3D(TOPRIGHT, BOTTOMRIGHT, new[] { controlTR, controlBR }, endPoints);

            // Bottom
            Point3D controlBL = BezierUtil.GetControlPoint_End(endPoints[BOTTOMLEFT], endPoints[BOTTOMRIGHT], endPoints[TOPRIGHT], arg.leftAway, arg.leftAngle, arg.leftPercent);
            controlBR = BezierUtil.GetControlPoint_End(endPoints[BOTTOMRIGHT], endPoints[BOTTOMLEFT], endPoints[TOPRIGHT], arg.rightAway, arg.rightAngle, arg.rightPercent);
            BezierSegment3D bottom = new BezierSegment3D(BOTTOMLEFT, BOTTOMRIGHT, new[] { controlBL, controlBR }, endPoints);

            // Top
            Point3D controlTL = BezierUtil.GetControlPoint_End(endPoints[TOPLEFT], endPoints[TOPRIGHT], endPoints[BOTTOMRIGHT], arg.leftAway, arg.leftAngle, arg.leftPercent);
            controlTR = BezierUtil.GetControlPoint_End(endPoints[TOPRIGHT], endPoints[TOPLEFT], endPoints[BOTTOMRIGHT], arg.rightAway, arg.rightAngle, arg.rightPercent);
            BezierSegment3D top = new BezierSegment3D(TOPLEFT, TOPRIGHT, new[] { controlTL, controlTR }, endPoints);

            return new[] { bottom, top, edge };
        }
Пример #3
0
        private void btnAxeSimple1_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                _savedAxe = new AxeSimple1();

                Axe_Checked(this, new RoutedEventArgs());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }