Пример #1
0
        private void simulateLinearMachining(HeightMap stock, BallnoseEndMill tool, HeightMap model, double toolDiameter, double machiningStep, bool useDirX)
        {
            var machiningMargin = toolDiameter;
            var toolX           = -machiningMargin;
            var toolY           = -machiningMargin;
            var mapEnd          = stock.End;
            var mapStepSize     = stock.StepSize;
            var toolConvolution = tool.AsConvolution(mapStepSize);

            var resolutionStep = mapStepSize * 0.999;

            if (useDirX)
            {
                while (toolX < mapEnd.X + machiningMargin)
                {
                    toolY = -machiningMargin;

                    while (toolY < mapEnd.Y + machiningMargin)
                    {
                        var machinedPoint    = new Point(toolX, toolY);
                        var convolutedHeight = model.GetMaxAddConvolution(machinedPoint, toolConvolution);
                        var offset           = convolutedHeight; //(blockHeight - convolutedHeight);

                        if (!double.IsInfinity(offset))
                        {
                            stock.ApplyMinSubConvolution(machinedPoint, offset, toolConvolution);
                        }

                        toolY += resolutionStep;
                    }
                    toolX += machiningStep;
                }
            }
            else
            {
                while (toolY < mapEnd.Y + machiningMargin)
                {
                    toolX = -machiningMargin;

                    while (toolX < mapEnd.X + machiningMargin)
                    {
                        var machinedPoint    = new Point(toolX, toolY);
                        var convolutedHeight = model.GetMaxAddConvolution(machinedPoint, toolConvolution);
                        var offset           = convolutedHeight; //(blockHeight - convolutedHeight);

                        if (!double.IsInfinity(offset))
                        {
                            stock.ApplyMinSubConvolution(machinedPoint, offset, toolConvolution);
                        }

                        toolX += resolutionStep;
                    }
                    toolY += machiningStep;
                }
            }
        }