Exemplo n.º 1
0
        public Slice_sequence Run(List <Point2F> points, double tool_r, double slice_radius, RotationDirection dir)
        {
            Slice root_slice = new Slice(points[0], slice_radius, dir == RotationDirection.Unknown ? RotationDirection.CCW : dir);

            _sequence.Add(root_slice);

            for (int i = 1; i < points.Count; i++)
            {
                Slice new_slice = new Slice(_sequence.Last_slice, points[i], slice_radius, dir, tool_r, _sequence.Last_slice.End);

                if (new_slice.Placement != Slice_placement.NORMAL)
                {
                    throw new Exception("bad slice placement");
                }

                if (true)
                {
                    new_slice.Refine(_sequence.Find_slices_colliding_with(new_slice), tool_r, tool_r);
                }

                if (i == 1)
                {
                    Logger.log("changing startpoint of root slice");
                    _sequence.Root_slice.Change_startpoint(new_slice.Start);
                    new_slice.Append_leadin_and_leadout(0, Slice_leadout_angle);
                }
                else
                {
                    new_slice.Append_leadin_and_leadout(Slice_leadin_angle, Slice_leadout_angle);
                }
                _sequence.Add(new_slice);
            }

            return(_sequence);
        }
Exemplo n.º 2
0
        private int evaluate_possible_slice(Slice parent, Point2F pt, ref Slice _candidate)
        {
            double radius = Get_radius(pt);

            if (radius <= 0)
            {
                return(-1);             // assuming the branch is always starting from passable mics, so it's a narrow channel and we should be more conservative, go left
            }
            Slice s = new Slice(parent, pt, radius, _dir, _tool_r, _sequence.Last_slice.End);

            if (s.Placement != Slice_placement.NORMAL)
            {
                if (s.Placement == Slice_placement.INSIDE_ANOTHER)
                {
                    return(1);                                                  // go right
                }
                if (s.Placement == Slice_placement.TOO_FAR)
                {
                    return(-1);                                                 // go left
                }
                throw new Exception("unknown slice placement");
            }
            // intersection
            // XXX: is this candidate is better than the last ?
            _candidate = s;
            s.Refine(_sequence.Find_slices_colliding_with(s), _tool_r, _tool_r);

            if (s.Max_ted > _max_ted)
            {
                return(-1);                                                                 // overshoot, go left
            }
            if ((_max_ted - s.Max_ted) / _max_ted > TED_TOLERANCE_PERCENTAGE)
            {
                return(1);                                                                  // undershoot outside the strict TED tolerance, go right
            }
            return(0);                                                                      // good slice inside the tolerance, stop search
        }