You are on page 1of 7

Computer-AidedDesign, 30, NO.2. pp. 123-129, Vol.

0 1998 Else&r

PII: SOOlO-4485(97)00064-X
ELSEVIER

1998 Science Ltd. All rights reserved Printed in Great Britain 0010~4485/98/$19.00+0.00

An algorithm for reducing tool retractions in zigzag pocket machining


Kai Tang*, Shuo-Yan Chou and Lin-Lin Chen
One major concern in pocket machining is the excessive retraction motions of the tool, in which the tool is elevated from the surface being cut and moved to a different position to continue the cutting process. The dotted line segments shown in Figure I depict the tool retraction motions for the two cutting strategies. These non-productive retraction motions are clearly undesirable, as they contribute to the total manufacturing time, and hence should be minimized. One approach to reducing the tool retractions for zigzag milling is to partition the region to be cut into subregions and cut them separately. The tool retractions then occur only between the subregions6. Figure 2 illustrates such a partitioning and its corresponding zigzag tool paths, which requires two tool retractions. In practice, the region partitioning approach is preferable to the non-partitioning one because the number of retractions for the latter increases as the step distance of the tool decreases. A region is said to be traceable (to be formally defined in the next section) if it does not require any tool retraction with respect to a given reference line. A partitioning is a traceable partitioning if all of its constituting subregions are traceable, e.g. as in Figure 2. Furthermore, a traceable partitioning is said to be minimum if it has the smallest number of subregions among all the traceable partitionings (with respect to the same reference line). The traceable partitioning shown in Figure 2a is minimum. Before proceeding further, it is necessary to clarify an important issue in traceable partitioning. Notice that adjacent subregions shown in Figure 2a are separated only by line segment(s) parallel to the reference line. Figure 3 depicts a different partitioning where not all the line segments separating a pair of adjacent subregions are parallel to the reference line. While the latter case demands fewer number of tool retractions (only one), it nevertheless introduces non-parallel (to the reference line) texture between adjacent subregions. Algorithmically, the freedom of nonparallelism tremendously increases the difficulty of the analysis for minimizing tool retractions. Therefore, this paper only considers the partitioning with separating lines parallel to the reference line only. Specificaily, it is assumed that the boundary curve of every subregion in a partitioning has elements either belonging to the boundary of the region itself or are line segments parallel to the reference line. It is noted that the total number of tool retractions depends not only on the geometry of the region but also the orientation of the reference line. As shown in Figure 4, a traceable partitioning with only two subregions (instead

An important issue in zigzag pocket machining is to design a machining strategy such that the resulting tool path requires a minimum number of tool retraction motions. The minimization is further classified as either local or global. In a local minimization, the inclination of a zigzag path is given a priori, and the goal is to partition the planar region to be machined into a minimum number of retraction-free subregions. The global minimization finds an inclination angle such that the local minimization with respect to this inclination is the minimum among all the possible inclination angles. This paper presents simple O(n log n) algorithms for solving both the local and the global minimization problems of a region with holes, where n is the number of line segments or arcs on the boundary of the region. The optimality of the presented algorithms is proved by using geometric analysis. 0 1998 Elsevier Science Ltd. All rights reserved Keywords: pocket machining, minimum polygon partitioning, zigzag path tool retractions,

INTRODUCTION
In pocket machining, two strategies are commonly used for cutting a planar area: contour milling and zigzag milling. As illustrated in Figure la, contour milling uses successive offsets of the pocket contour as the cutting paths of the tool . Each contour path can be constructed by computing the Voronoi diagram with respect to the immediately previous path, which is computationally expensive23. In contrast, the paths for zigzag milling, as shown in Figure lb, are much simpler computationally: milling takes place along line segments to a specified reference line in alternating directions between adjacent paths. As a recent development, Hilber curves are also used as an alternative for pocket machining4.5.
*To whom correspondence should be addressed. Applicon Inc., 425 1 Plymouth Road, PO Box 986, Ann Arbor, MI 48 1060986, USA Department of Industrial Management, National Taiwan University of Science and Technology, Taipei, Taiwan Graduate School of Engineering and Technology, National Taiwan University of Science and Technology, Taipei, Taiwan Paper Received: 5 January 1996. Revised: 19 September 1997. Accepted: 19 September 1997

123

Reducing tool retractions in zigzag pocket machining: K Tang et a/.

Figure

(a) Contour milling, (b) zigzag milling

of three as in Figure 2) can be obtained by rotating the reference line in Figure 2 by 90, and hence only one tool retraction. Formally, let N(P,@ denote the number of the constituting subregions in a minimum traceable partitioning of a given region P, where 19(05 0 5 180) is the inclination angle between the reference line and the X-axis. The global minimization problem to be solved is then defined as finding an angle t and a corresponding traceable partitioning of P such that the number N(P, t) is the minimum among all the N(P, 0). It should be mentioned that although boundary elements are required to be circular arcs or line segments, the presented approach is capable of dealing with nearly any type of curves, provided that the tangents and local extrema are available or can be computed analytically. In the next section, basic terminologies needed for the development of the algorithms are introduced. In Section 3, algorithms are presented for solving the local minimization problem, i.e. for a given P and 6, compute the minimum N(P, 0) and a corresponding traceable partitioning of P. An optimal algorithm that minimized N(P,B) for a given 8 is presented. The algorithm runs in O(n log n) time and requires only O(n) space, where n is the total number of arcs and line segments on the boundaries of P. The global minimization is addressed in Section 4, where it is proved that the globally minimized N(P, 13), 0 5 195 180 can be obtained by means of a simple range searching on the tangent angles of the reflex elements on the boundaries of P. Such a procedure requires only O(n log n) time and linear space, helped by an important invariant relation between P and N(P, 0). Finally in Section 5, the paper is concluded with a few remarks.

(a) Figure paths 3


A partitioning

(h)
with non-parallel separating lines and its tool

reference line

Figure

A traceable

partitioning

that has a minimum N(P, 0) for all 0

Figure 5. Let p be a point on the boundary of P. Point p is a scan-rejlex point (SRP) if (a) the internal angle at p is greater than ?r, and (b) there is a neighborhood 6 at p such that the boundary of P within 6 is on one side of the vertical line passing through p. In the example shown in Figure 5, only points pl, p2, p3, p4, p5, and p6 are SRPs of P. A scanline segment is said to be critical if one of its two ends

PRELIMINARIES
Before giving a formal definition of the traceability of a region, some basic terminologies are first introduced. A scan-line segment (SLS) of P is a vertical line segment whose two ends lie on the boundary of P and whose interior lies entirely inside P, e.g. line segments s, s1 and s2 in

coincides with a scan-reflex point. Each SRP has two critical SLSs coincident at it, the upper and lower ones, e.g. s, and s2 of p2 in Figure 5. A simple curve, which is a curve that does not have self-intersections, inside P is said to be a trace curve in P if it intersects every SLS in P at most once. For instance, curve r is a trace curve in P, as shown in Figure 5. Notice that a trace curve does not have to be monotone with respect to the X-axis. The union of the subregions bounded by the SLSs intersected by a trace curve is called the traceable region of that trace curve. In the example shown in Figure 5, the shaded area corresponds to the traceable region of the trace curve r. A trace curve r provides an advancing direction for the zigzag path of tool through the subregions that r passes. More specifically, an ordered list of points { ql, q2, , qm } on r can be sampled, with q1 and qm being the start and the end of T, respectively, such that the projected distance on the X-axis between every pair of adjacent points m - 1) is equal to the given stepping (qi,qi+I)(i=1,2,...,

(a) Figure 2
A traceable

(b)
partitioning and the corresponding tool path Figure 5 Illustrations on basic terminologies

124

Reducing tool retractions in zigzag pocket machining: K Tang et al.


mid-points of every consecutive pairs of zigzag passes). Therefore, the two minimizations, that of the number of tool retractions and that of the number of constituting subregions in a traceable partitioning, are equivalent. The following lemma states an important relationship between a minimum traceable partitioning and critical scan-line segments.

Lemma 1
In a minimum traceable partitioning, every scan-line segment on the boundary of a constituting subregion is a critical scan-line segment,

Proof
Refer to Figure 6u, where a non-critical scan-line segment s separates two subregions R and R from each other in a minimum traceable partitioning and r and 7 are the corresponding trace curves of R and R, respectively. Let s 1and s2 be two SLSs on the opposite sides of s, which form two trapezoids in R and R respectively. Obviously, the curve made of the union of 7 and 7 minus their portions inside the two trapezoids between s 1and s2 and plus the line segment connecting them between s 1 and s2 is a trace curve for region R + R. This contradicts the assumption that the given partitioning is minimum. Let p be a scan-reflex point of P. Consider the configurations between p and the subregions that contain p in a minimum traceable partitioning of P. There are five possible cases-#, T, I, > , and II- as depicted in Figure 7. Type # configuration can be ruled out immediately, since any two of the three subregions in the configuration can be merged into a single traceable subregion, as shown in Figure 6b. While it is possible for a minimum traceable

(cl Figure 6 Merging adjacent subregions by connecting their trace curves

distance. Extend the vertical line segment passing through a point q. until both ends hit the boundary of P, resulting a scan-line segment. Each scan-line segment determined by a point q then defines a zigzag pass, and the zigzag path of the tool from q1 to qm along r does not require any retractions. Conversely, if a region can be machined with zigzag path requiring no tool retractions, it must have a corresponding trace curve (e.g. the piecewise linear curve that connects the

#
Figure 7 Five possible configurations

T in a traceable partitioning

>

II

(a)

(b)

Cd) Figure 8 Proof of Lemma 2

125

Reducing tool retractions

in zigzag pocket machining:

K Tang et al.

partitioning to have all the other four types of configurations, the analysis in the following will show that there is always a minimum traceable partioning that consists of type T configurations only. This homogeneity greatly facilitates the search for the minimum traceable partitioning. The following lemma will be used in the next section for ensuring such homogeneity.

Figure 10

Conversion

of a type

> configuration

Lemma 2
In a traceable partioning, for every type there exists a type II configuration. > configuration

original one, it is subsequently proved that the T partitioning is indeed minimum. With II(P) denoting this intermediate partitioning, the conversion is carried out in two phases, executed in the order: Phase 1: While there is a type > or a type II configuration in II(P) do convert the type > or the type II configuration to a type T configuration; Phase 2: While there is a type I in II(P) do convert it to a type T configuration.
Figure 10 demonstrates how the conversion for type > is conducted. let R be the subregion contributing to a type > configuration at a scan-reflex point p, r be its trace curve. According to Lemma 2, there is a type II configuration at another scan-reflex point q on the boundary of a hole where the two associated critical scan-line segments separate R from another subregion R. Obviously, r must pass through q. The lower critical scan-line segment of p is then added to the partitioning, and the upper critical scan-line segment of q removed. The original two trace curves r and T are now replaced by two new trace curves rr and r2, where r, is made of the upper portion of r (as delimited by point q) plus the original r after a local connection between the two (similar to that shown in Figure 6) and r2 is just the other portion of 7. The region traced by 7, is then labeled as RI and that traced by r2 is labeled as R2. Obviously, the two unions R + R and RI + R2 are identical, and hence so are the numbers of the constituting subregions in the new and the old partitionings. Next, consider a type II configuration at a scan-reflex point p, and let R and R be the two adjacent subregions separated by the two critical scan-line segments coincident at p, with r and r being their trace curves, respectively. The conversion proceeds depending on whether r is closed or open. For a closed 7, due to the reasoning similar to that in Lemma 2, there must exist a type II configuration of R at another scanreflex point q, as illustrated in Figure I la. Region R is then merged with the region traced by one of the two portions on r between the two points p and q, converting both type II

Proof
Refer to Figure 8, where three points q, q, and q are to be connected by a trace curve r such that the scan-line segment s in the subregion cannot be intersected by r for more than once. The trace curve r can only take one of the three shapes shown in Figure 8a-c. In any of them, r completely encloses a hole of P, due to the fact that it encloses a boundary point of P, e.g. point p in the figures. Therefore, as revealed in Figure 8d, there must exist at least one type II configuration on this enclosed hole, for otherwise, some scan-line segments--s or .r-would be intersected twice by the trace curve r, as shown in Figure 8e.

LOCAL MINIMIZATION
This section solves the local minimization problem: given a region P and a reference line of inclination angle 0, find a minimal traceable partitioning of P that realizes N(P, 0). Without loss of generality, the reference line is set to be parallel to the Y-axis, i.e. 8 = 90, and N(P, 90) is replaced with N(P) for simplicity. Let us consider a particular traceable partitioning of P, called the T partitioning of P. It is constructed by removing those critical scan-line segments whose lower end points coincide with a scan-reflex point of P. Each constituting subregion in the T partitioning is bounded by some boundary elements of P plus one or more lower critical scan-line segments. Figure 9 shows an example of the T partitioning. Conceivably, every constituting subregion--R,, R2, ., and R5 in Figure 9-in this T partitioning is traceable, since every one of them is monotone with respect to the X-axis. As to be proved next, it is also minimum, i.e. it realizes the number N(P). In the following, an algorithm that converts an arbitrary minimum traceable partitioning of P into the T partitioning is devised. By guaranteeing that at any time during the conversion the number of constituting subregions in an intermediate partitioning is no greater than that of the

(b) Figure 9 The T partitioning of a region P Figure 11 Conversion of a type II configuration

126

Reducing tool retractions in zigzag pocket machining: K Tang et al.

(a)

(b)

Figure 12

Proof of Lemma 3

configurations at p and q to type T. Notice that the other subregion at point q must be R, for otherwise a smaller number of subregions in the new traceable partitioning of P would have resulted from the merging, which is not possible since the current partitioning has ben assumed to be minimum. On the other hand, if r is open, R can be merged with the region traced by r between point p and one of its two ends, as demonstrated in Figure lib. Obviously, this merging does not change the number of constituting subregions in the partitioning. With the conversion between type I and type T configurations defined as that in Figure 6c, it is now proved that the proposed conversion algorithm will terminate in a finite number of steps. This proof is imperative since new configurations that are not of type T configuration may emerge after a conversion and it needs to be shown that this emergence of new configurations will not cause an infinite algorithmic loop.

Lemma 3
To convert a minimum traceable partitioning of P into its T partitioning, the while loop at Phase 1 iterates at most nil times, and the number of conversions carried out in Phase 2 is no more than n, times, where n, is the number of scan-reflex points of P and nil is the number of type IIconfigurations in the original minimum traceable partitioning.

Proof
It is first shown that a non-T type configuration may indeed emerge after a conversion at Phase 1. In the example shown in Figure 12~1,after the type II configuration at point p is converted to type T, a new type > configuration emerges at another point q which was originally of type T. Fortunately, this new configuration can never be of type II, be it in Phase 1 or Phase 2. This is because if a type II configuration is created at a point q, the original configuration at q before the conversion must be of type # as

manifested in Figure 12b. This is, however, not possible since the partitioning is assumed to be minimum, as illustrated in Figure 6b. Now that each iteration in the while loop at Phase 1 eliminates at least one type II configuration and no new type II configurations will be created, it follows that this while loop iterates at most nil times. At Phase 2, the only probable type of a new configuration emerging from a conversion is type > , e.g. a new type > configuration emerges at point q in Figure 12~. This, however, is impossible due to Lemma 2, that is, at Phase 2 no longer is there any type II configuration in the partitioning. Computationally, the T partitioning of P can be constructed in O(n log n) time, where n is the total number of line segments and circular arcs on the boundary of P. First, the set of all the scan-reflex points can be identified in O(n) time by checking the end points of each element and its interior X-extrema point if the element is an arc. Next, the set of all the lower critical scan-line segments can be obtained by computing the intersections between the boundary of P and the vertical lines through the scan-reflex points, which can be achieved in O(n log n) time by means of the well-known plane-sweep technique 7.* Each constituting subregion in the T partitioning can then be constructed in linear time by means of traversing along the graph made of the elements on the boundary of P as well as the lower critical scan-line segments. Finally, the following lemma establishes an important invariant property of the number N(P), which is the number of the constituting subregions in the T partitioning. Such an invariant will guarantee the success in finding the global minimization.

Lemma 4
The number
N(P)

is equal to n, - ah + 1, where n, is the


in the

* In case P is a simple polygon, the intersections can be computed theoretically optimal linear time by using the algorithm in Ref. *.

127

Reducing tool retractions

in zigzag pocket machining:

K Tang et al.

Figure 13 region P

The minimum

embedding

graph of the T partitioning

of a

number of scan-reflex holes in P.

points of P, and nh is the number of

Proof
Let the minimum embedding graph of the T partitioning of P be denoted as a planar graph (V, E) where V is the set of end points of the lower critical scan-line segments of P, and E is the collection of edges each of which a curve replacing the boundary elements of P between the two nodes in the T partitioning. Because the graph is planar, Eular formula dictates that the number of faces in (V, E) be equal to 1[El 1- I(VI 1+ 1. As an example, Figure 13 depicts the minimum embedding graph of the T partitioning shown in Figure 9, where the number of faces in (V, E&-f throughf, in Figure 13-equals (18 - 12 + 1). As there is no type II configurations in the Tpartitioning of P, it follows that every constituting subregion in the T partitioning is wellconnected.? Consequently, the number of faces in (V, E) must be equal to N(P) + nh. Since every node in (V, E) is of degree three, IIEII is equal to (3/2) IIVII. The proof is complete with the fact that IIVII equals 24.

being the tangents of the arc at its two ends, e.g. the tangent range of cl in Figure 14b. For a reflex vertex on P, its tangent range is the double wedge at the origin defined by the two tangents at the vertex, as also illustrated in Figure 14b. The tangent ranges of all the reflex vertices and elements partition the angular space into a number of intervals, called the characteristic intervals of P. Figure 14~ depicts the characteristic intervals of P shown in Figure 1411. Apparently, each characteristic interval is congruent by itself in terms of the number of scan-reflex points. That is, any two reference lines in the same characteristic interval have the same number of corresponding scan-reflex points, even though the two point sets may not be identical. Therefore, the minimization on the number of scan-reflex points is transformed to finding a characteristic interval that falls into fewest tangent ranges. A global minimum traceable partitioning of P can thus be computed by following the three steps given below. Step 1. Identify all the reflex vertices and elements on P and compute their tangent ranges. Step 2. Find a characteristic interval of P which belongs to the smallest number of tangent ranges. Step 3. Pick an arbitrary line inside the characteristic interval found at step 2 and construct the T partitioning of P with respect to this reference line.

Theorem
Given P (with holes) with a total of n line segments or circular arcs on the boundary, its global minimum traceable partitioning can be computed in O(n log n) time and O(n) space.

Proof
Step I trivially takes linear O(n) time and space. To accomplish step 2, the bounding lines of tangent ranges are sorted angularly in O(n log n) time, as there are less than 4n tangent ranges. A clockwise traversing of the sorted bounding lines then yields the sought interval. (Refer to Refs 6, for algorithmic details.) The last step takes O(n log n) time and linear space, due the result from Section 3.

GLOBAL MINIMIZATION
The equation N(P) = fl, - nh + 1 given in Lemma 4 implies an important invariant, that is, the number N(P) relates linearly to n, and ah, but independent of other geometric characteristics of P. Since ah is a constant regardless the choice of the reference line, the minimization of N(P, f3) is then equivalent to finding an angle t such that the number of scan-reflex points of P is minimized when the Y-axis coincides with the reference line of t. Let us first clarify the reflexiveness of a vertex or an element on P. A circular arc element on the boundary of P is reflex if the portion of P in the neighborhood of a point on the arc lies to the convex side of the arc. A vertex, which is an end point shared by two adjacent elements on P, is reflex if its interior angle, defined by the two tangents of the two adjacent elements at the point, is greater than ?r. Refer to Figure 14~ for examples. Obviously, only a reflex vertex or element can contribute to a scan-reflex point. For instance, c, in Figure 14a contributes to a single scanreflex point with respect to the reference line 1. A geometric term called tangent range is now in order. For a reflex circular arc on P, its tangent range is a double wedge with its apex at the origin and two bounding lines
t A planar region is well-connected if for any two interior points p and q in the region there is a curve connectingp and q which lies only in the interior of the region lo.

CONCLUSION
Since the landmark paper by Persson on using Voronoi diagram for computing contouring milling tool paths in pocket machining, there have been a great number of publications and discussions on how to efficient1 and robustly compute generalized Voronoi diagrams (see Y,7and the references therein). Surprisingly, however, there exist very few reported investigations on optimizing zigzag machining, be it minimizing tool retractions or other types of optimizations. The only serious published report on minimizing tool retractions, to the best of the authors knowledge, is by Held6. He presents near-optimal algorithms for minimizing tool retractions in zigzag machining. While both local and global minimizations were addressed, and actually Helds algorithm for finding an optimal reference line is identical to the one reported in this paper, no formal proof is given6 for verifying the optimality of the reference line. Furthermore, there is no provision given in Ref. 6 for analyzing the local optimality

128

Reducing tool retractions in zigzag pocket machining: K Tang et al.

reflex

vertices and elements: Y, v*

VT! c,. and cF

(b)

characteristic intervals

Figure 14

Reflex vertices and elements, tangent ranges, and characteristic

intervals

of the mesh connection approach proposed therein. Another investigation on the optimization of zigzag ocket machinR ing was recently reported by Arkin et al. , m which an approach related to that described in Ref. 6 is presented. In this paper, the global minimization of tool retractions is formulated as a minimum partitioning problem and an optimal solution is presented for it. Notwithstanding the surprisingly simple and straightforward minimum partitioning algorithm itself, the paper contributes by providing a rigorous and non-trivial proof for the optimality of the presented minimization algorithms.

REFERENCES
1. Persson, H., NC machining of arbitrarily shaped pockets. ComputerAided Design, 1978, 10(3), 169-174. 2. Held, M., On the Computational Geometry of Pocket Machining. Springer, Berlin/Heidelberg/New York, 1991. 3. Tiller, W. and Hanson, E., Offsets of two-dimensional profiles. IEEE Computer Graphics and Applications, 1984, 4, 36-46.

Cox, J. J., Takezaki, Y., Ferguson, H. R. P., Kohkonen, K. E. and M&lay, E. L.. Space-filling curves in tool-path applications. Computer-Aided Design, 1994, 26, 215-224. 5. Marshall, S. and Griffits, J. G., A new cutterpath topology for milling machines. Computer-Aided Design, 1994, 26, 204-214. 6. Held, M., A geometry-based investigation of the tool path generation for zigzag pocket machining. Visual Computer, 1991, 7(5-6), 296308. Zntro7. Preparata, F. and Shamos, M., Computational Geometry-An duction. Springer-Verlag, New York, 1985. a simple polygon in linear time. Disc. 8. Chazelle, B., Triangulating Comp. Geom., 1991,6,485-524. 9. BollobBs, B., Graph Theory, An Zntroductory Course. SpringerVerlag, New York, 1979. 10. Tang, K. and Woo, T., Algorithmic aspects of alternating sum of volumes. Part 2: Nonconvergence and its remedy. Computer-Aided Design, 1991,23(6), 435-443. 11. Tang, K., Woo, T. and Gan, J., Maximum intersection of spherical polygons and workpiece orientation for 4- and 5-axis machining. ASME Journal of Mechanical Design, 1992, 144, 477-485. 12. Arkin, E. M., Held, M. and Smith, C. L., Optimization related to < http://www.ics.uci.edu/-eppstein/ zigzag pocket machining, gina/cam.html > 4.

129

You might also like