Exemple #1
0
        public virtual void Append_slice(Slice slice, List <Point2F> guide)
        {
            if (_last_slice == null)
            {
                throw new Exception("attempt to install slice without the root slice");
            }

            if (guide == null)
            {
                Path.Add(connect_slices(slice, _last_slice));
            }
            else
            {
                Sliced_path_item p = new Sliced_path_item(Sliced_path_item_type.GUIDE);

                p.Add(_last_slice.End);
                foreach (Point2F pt in guide)
                {
                    p.Add(pt);
                }
                p.Add(slice.Start);

                Path.Add(p);
            }

            append_slice(slice);
        }
Exemple #2
0
        protected Sliced_path_item connect_slices(Slice dst, Slice src)
        {
            Sliced_path_item path = new Sliced_path_item(Sliced_path_item_type.CHORD);

            path.Add(src.End);
            path.Add(dst.Start);
            return(path);
        }
Exemple #3
0
        public void Append_return_to_base(List <Point2F> exit)
        {
            Sliced_path_item p = new Sliced_path_item(Sliced_path_item_type.RETURN_TO_BASE);

            p.Add(_last_slice.End);
            foreach (Point2F pt in exit)
            {
                p.Add(pt);
            }

            Path.Add(p);
        }
Exemple #4
0
        protected void append_slice(Slice slice)
        {
            // emit segments
            for (int segidx = 0; segidx < slice.Segments.Count; segidx++)
            {
                // connect segments
                if (segidx > 0)
                {
                    Sliced_path_item shortcut = new Sliced_path_item(Sliced_path_item_type.SLICE_SHORTCUT);
                    shortcut.Add(slice.Segments[segidx - 1].P2);
                    shortcut.Add(slice.Segments[segidx].P1);
                    Path.Add(shortcut);
                }

                Sliced_path_item arc = new Sliced_path_item(Sliced_path_item_type.SLICE);
                arc.Add(slice.Segments[segidx], _general_tolerance);
                Path.Add(arc);
            }

            _last_slice = slice;
        }
Exemple #5
0
        public void Append_spiral(Point2F start, Point2F end, Vector2d start_tangent, double ted, double tool_r, RotationDirection dir)
        {
            Sliced_path_item spiral = new Sliced_path_item(Sliced_path_item_type.SPIRAL);

            double spacing = Spiral_generator.Calc_reverse_spacing(end.DistanceTo(start), tool_r, ted, _general_tolerance);

            foreach (Biarc2d biarc in Spiral_generator.Gen_archimedean_spiral(start, end, start_tangent, spacing, dir))
            {
                spiral.Add(biarc, _general_tolerance);
            }

            Path.Add(spiral);
        }
Exemple #6
0
        private Sliced_path_item connect_slices_with_biarc(Slice dst, Slice src)
        {
            Point2F start = src.End;
            Point2F end   = dst.Start;
            // unit normals to points
            Vector2d vn_start = new Vector2d(src.Center, start).Unit();
            Vector2d vn_end   = new Vector2d(dst.Center, end).Unit();
            // tangents to points
            Vector2d vt_start;
            Vector2d vt_end;

            if (src.Dir == RotationDirection.CW)
            {
                vt_start = new Vector2d(vn_start.Y, -vn_start.X);
            }
            else
            {
                vt_start = new Vector2d(-vn_start.Y, vn_start.X);
            }

            if (dst.Dir == RotationDirection.CW)
            {
                vt_end = new Vector2d(vn_end.Y, -vn_end.X);
            }
            else
            {
                vt_end = new Vector2d(-vn_end.Y, vn_end.X);
            }

            Biarc2d biarc = new Biarc2d(start, vt_start, end, vt_end);

            if (!is_biarc_inside_ball(biarc, src.Ball))
            {
                return(null);
            }

            Sliced_path_item path = new Sliced_path_item(Sliced_path_item_type.SMOOTH_CHORD);

            path.Add(biarc, _general_tolerance);
            return(path);
        }