Пример #1
0
        private Sliced_path gen_pocket_toolpath(ShapeListItem shape, Point2F startpoint, Vector2F start_tangent)
        {
            Polyline outline;

            Polyline[] islands;

            if (shape.Shape is Polyline)
            {
                outline = (Polyline)shape.Shape;
                islands = new Polyline[] { };
            }
            else if (shape.Shape is CamBam.CAD.Region)
            {
                CamBam.CAD.Region reg = (CamBam.CAD.Region)shape.Shape;
                outline = reg.OuterCurve;
                islands = reg.HoleCurves;
            }
            else
            {
                return(null);
            }

            Pocket_generator gen = new Pocket_generator(outline, islands);

            gen.General_tolerance = is_inch_units() ? 0.001 / 25.4 : 0.001;
            gen.Tool_d            = base.ToolDiameter.Cached;
            gen.Max_ted           = base.ToolDiameter.Cached * _stepover.Cached;
            gen.Min_ted           = base.ToolDiameter.Cached * _stepover.Cached * _min_stepover_percentage;
            if (startpoint.IsUndefined)
            {
                startpoint = (Point2F)outline.FirstPoint;
            }
            gen.Startpoint           = startpoint;
            gen.Startpoint_is_a_hint = true;
            gen.Margin         = 0;
            gen.Spiral_tangent = start_tangent;

            if (_milling_direction.Cached == MillingDirectionOptions.Mixed || base.SpindleDirection.Cached == SpindleDirectionOptions.Off)
            {
                gen.Mill_direction       = RotationDirection.Unknown; // means 'mixed' here
                gen.Should_smooth_chords = false;
            }
            else
            {
                int dir = (int)(base.SpindleDirection.Cached);
                if (_milling_direction.Cached == MillingDirectionOptions.Climb)
                {
                    dir = -dir;
                }
                gen.Mill_direction       = (RotationDirection)dir;
                gen.Should_smooth_chords = _should_smooth_chords;
            }

            return(gen.run());
        }
Пример #2
0
        private List <Sliced_path> gen_profile(CamBam.CAD.Region region, bool is_inside, Point2F startpoint)
        {
            List <Sliced_path> trajectories = new List <Sliced_path>();

            trajectories.AddRange(gen_profile(region.OuterCurve, is_inside, startpoint));

            foreach (Polyline hole in region.HoleCurves)
            {
                if (trajectories.Count != 0)
                {
                    startpoint = lastpt(trajectories);
                }
                trajectories.AddRange(gen_profile(hole, !is_inside, startpoint));
            }

            return(trajectories);
        }