Exemple #1
0
        public Sliced_path run()
        {
            if (_dir == RotationDirection.Unknown && _should_smooth_chords)
            {
                throw new Exception("smooth chords are not allowed for the variable mill direction");
            }

            Logger.log("building medial axis");

            Branch tree  = new Branch(null);
            bool   is_ok = _topo.Build_medial_tree(tree, _tool_r / 10, _general_tolerance, _startpoint, _min_passable_mic_radius + _tool_r + _margin, _startpoint_is_a_hint);

            if (!is_ok)
            {
                Logger.warn("failed to build tree");
                return(null);
            }

            Branch_slicer slicer = new Branch_slicer(_topo.Min, _topo.Max, _general_tolerance);

            slicer.Slice_leadin_angle  = _slice_leadin_angle;
            slicer.Slice_leadout_angle = _slice_leadout_angle;
            slicer.Get_radius          = radius_getter;

            Logger.log("generating slices");
            Slice_sequence sequence = slicer.Run(tree, _tool_r, _max_ted, _min_ted, _dir);

            Logger.log("generating path");
            return(generate_path(sequence));
        }
Exemple #2
0
        public void Append_slice_sequence(Slice_sequence sequence)
        {
            this.Append_root_slice(sequence.Root_slice);

            for (int i = 1; i < sequence.Slices.Count; i++)
            {
                Slice s = sequence.Slices[i];
                this.Append_slice(s, s.Guide);
            }
        }
Exemple #3
0
        private Sliced_path generate_path(Slice_sequence sequence)
        {
            Sliced_path_generator gen;

            if (!_should_smooth_chords)
            {
                gen = new Sliced_path_generator(_general_tolerance);
            }
            else
            {
                gen = new Sliced_path_smooth_generator(_general_tolerance, 0.1 * _tool_r);
            }

            gen.Append_spiral(sequence.Root_slice.Center, sequence.Root_slice.End, _spiral_tangent, _max_ted, _tool_r, _dir == RotationDirection.Unknown ? RotationDirection.CCW : _dir);
            gen.Append_slice_sequence(sequence);

            return(gen.Path);
        }
Exemple #4
0
        public Sliced_path run()
        {
            if (_dir == RotationDirection.Unknown && _should_smooth_chords)
            {
                throw new Exception("smooth chords are not allowed for the variable mill direction");
            }

            _topo = new Topographer(_poly, new Polyline[] { });

            double         step          = calc_optimal_step();
            List <Point2F> slice_centers = _topo.Get_samples_exact(step);

            Bypoint_slicer slicer = new Bypoint_slicer(_topo.Min, _topo.Max, _general_tolerance);

            slicer.Slice_leadin_angle  = _slice_leadin_angle;
            slicer.Slice_leadout_angle = _slice_leadout_angle;

            Logger.log("generating slices");
            Slice_sequence sequence = slicer.Run(slice_centers, _tool_r, _slice_radius, _dir);

            Logger.log("generating path");
            return(generate_path(sequence));
        }
Exemple #5
0
        private Sliced_path generate_path(Slice_sequence sequence)
        {
            Sliced_path_generator gen;

            if (!_should_smooth_chords)
            {
                gen = new Sliced_path_generator(_general_tolerance);
            }
            else
            {
                gen = new Sliced_path_smooth_generator(_general_tolerance, 0.1 * _tool_r);
            }

            // NOTE: this manipulations are to make the beginning of spiral tangent to the polyline
            object   obj     = _poly.GetSegment(0);
            Vector2d tangent = new Vector2d();

            if (obj is Line2F)
            {
                Line2F line = (Line2F)obj;
                tangent = new Vector2d(line.p1, line.p2);
            }
            else if (obj is Arc2F)
            {
                Arc2F arc = (Arc2F)obj;
                tangent = new Vector2d(arc.Center, arc.P1).Normal();
                if (arc.Direction == RotationDirection.CW)
                {
                    tangent = tangent.Inverted();
                }
            }

            gen.Append_spiral(sequence.Root_slice.Center, sequence.Root_slice.End, tangent, _max_ted, _tool_r, _dir == RotationDirection.Unknown ? RotationDirection.CCW : _dir);
            gen.Append_slice_sequence(sequence);

            return(gen.Path);
        }
Exemple #6
0
 public Bypoint_slicer(Point2F min, Point2F max, double general_tolerance)
 {
     _sequence          = new Slice_sequence(min, max, general_tolerance);
     _general_tolerance = general_tolerance;
 }