1 Introduction

With the rapid development of aerospace, automobile and mold manufacturing industry, sculptured surface is more and more used in configuration design for better performance and esthetic feature. Numerical control (NC) machining is a main processing method of sculptured surface, and tool path plays an important role in quality and efficiency of NC machining [1].

Iso-parameter, iso-planar and iso-scallop method are main ways of tool path generation for sculptured surface. Iso-parametric method [2,3,4] sets a constant value as u or v parameter increment to plan CC curves, and tool path is generated based on CC curves. Iso-planar method [5,6,7,8] makes a series of parallel planes intersect with surface, and the intersecting lines are taken as CC curves. Iso-planar method can be applicable to almost all surfaces and widely used in commercial CAM software. Iso-scallop method [9,10,11,12,13] plans tool path line by line and ensure the scallop height between two adjacent lines be the allowed maximum. Iso-scallop tool path has shorter length than other methods but needs more computing time.

A group of CC curves can be planned by the above three methods. Tool path is usually generated based on discrete CC points on CC curves one by one. As shown in Fig. 1, iso-parameter, iso-length and iso-error methods are main methods of CC point generation. As the name implies, iso-parameter method sets a constant value as parameter increment and CC points are calculated by incremental parameters in Fig. 1a. Similarly, iso-length method sets a constant arc or chord length as step length in Fig. 1b. Both methods have simple construction and efficient calculation.

Fig. 1
figure 1

Methods of CC point generation

As shown in Fig. 1c, iso-error method can generate CC points with uniformed error. The error between CC curve and line segments of CC points is usually named chord error or linear error. Sculptured surface generally has complex shape and uneven curvature. Constant parameter or length increment cannot generate uniformed chord errors, and chord errors between CC points may be greater than the allowed maximum. Line segments of CC points and chord error are not real cutting contours and machining error. When cutting tool moves from a CL point to the next one along the feed direction, tool envelope surface forms, which is the real cutting contour. The real machining error between two adjacent CC points is the maximum error between tool envelope surface and CC curve, which is named step error in this paper and affected by both step length and curve contour [14].

To make all step error not greater than the allowable maximum, the parameter and length increments in iso-parametric and iso-length methods need to be set conservative values. As a result, a lot of redundant CC points are generated, which is not beneficial to improve efficiency of tool path generation and NC machining. But greater step length may cause step error greater than the maximum. In order to minimize the number of CC points and meet the error requirement, iso-error method calculates suitable step length for every CC point to make step error equal or close to the allowed maximum.

Figure 2 shows errors between two adjacent CC points. All points (including CC, CL, points on CC curves), curves and errors are not in a plane because CC curves are three-dimensional and normal vectors of CC points are different. In three-axis machining, tool envelope surface of ball-end tool is a cylindrical surface along CL path, which is the real cutting contour or path. As shown in Fig. 2a, the step error \(e_{\max }^{{}}\) is the maximum error between the cylindrical surface and CC curve, and is less than the chord error \(e_{\max }^{L}\) when the local CC curve between two adjacent CC points is concave. Conversely, \(e_{\max }^{{}}\) is greater than \(e_{\max }^{L}\) when the local CC curve is convex.

Fig. 2
figure 2

Errors between two adjacent CC points

Compared with three-axis ball-end tool machining, because two rotating axes can make tool flexible enough, five-axis flat-end tool machining can contact surface more closely, which brings better machined surface quality and much larger cutting width.

The actual cutting contours of flat-end tool are also not the CC line segments but tool envelope surface with complicated and irregularly shape, and the error between them is called non-linear error. As shown in Fig. 2b, the step error \(e_{\max }^{{}}\) is not the sum or difference between chord error \(e_{\max }^{L}\) and non-linear error \(e_{\max }^{NL}\). Actually, the step error \(e_{\max }^{{}}\) is the maximum error between tool envelope surface and CC curve. It is hard for flat-end tool to obtain accurate tool envelope surface and calculate the accurate value of step error directly, which is the main bottleneck in developing five-axis iso-error method.

Calculating accurate step error is the base of iso-error tool path generation. Many scholars have researched about these. Li et al. [14] presented a geometry-based error evaluation method and a tool path discretization method for five-axis sculptured surface machining. Lu et al. [15] estimated step length with the radius of normal curvature of the design surface at CC point along the feed direction. Du et al. [16] presented a third-order method that estimates the chord error using conical helices. Can and Ünüvar [17] used iterative algorithm in step length calculation to optimize the discretization of CC points. Xu et al. [18], redundant points are removed by maximizing each cutting step length using geodesic curvature matching, and the remaining fewer CC points can maintain the tolerance limits. Zhao et al. [19] presented a constant chord error method with variable step length. Golden section method is used to search the maximum chord error, which is more efficient and accurate than conventional mid-point method. Lin et al. [20] used an accurate chord evaluation method to calculate the next CC point based on the cutting simulation process. Dense grasses are planted on the tool path curve and they are cut when the tool moves. The length values of the grasses are considered as the machining error, and CC points with uniform chord error can be generated.

Fountas et al. [21] presented a methodology based on a virus-evolutionary genetic algorithm for multi-objective optimization including chord error, machining time, the number of cutter location points and so on. Zhang and Tang [22] used the finite element method (FEM) to minimize tool path length and machining time for ball-end tool. Ma et al. [23] constructed cutter location mesh units to optimize tool-path parameters for three-axis machining curved surface. The length values of mesh units are adjusted to meet error requirement by an iterative process, and the nodes of the units are taken as the cutter location points. For larger step length, Dong et al. [24] planed CC points laid on CC curve or the chord error offset curve when CC curve is concave or concave. Segments connected by the adjacent CC points are between the two curves, and meet error requirement.

From the present research work, the error calculation is mainly based on curvature estimation algorithms [14,15,16] and iterative calculation algorithms [17,18,19,20, 23, 24]. Curvature estimation algorithms have an advantage in efficiency but a disadvantage on accuracy. Iterative calculation algorithms cost more calculation and obtain more accurate results than curvature estimation algorithms.

Most of the previous work focused on error calculation including chord and step error, which is the premise of generating iso-error tool path. However, how to calculate real step error efficiently and adjust step length to make step error meet the iso-error requirement further is the most significant bottleneck. Both the difficulties make main commercial CAM software hardly generate five-axis iso-error NC tool path methods, and few methods have been reported and applicated.

The purpose of this study is to develop an iso-error tool path generation method for flat-end tool. This paper mainly focuses on how to calculate accurate step error efficiently and obtain maximum step length meeting iso-error requirement so as to reduce redundant CL points for NC machining. In Sect. 2.1, initial local gouging-free CL points and tool vectors are calculated. In order to calculate more accurate step error, step error is expressed as the maximum distance between the actual cutting path and CC curve, and calculated based on the geometrical relationship among tool location, CC curve and actual cutting path. Two step error calculation algorithms for specified tool location and CC point are presented in Sect. 2.2 respectively and used in iso-error CC point calculation in Sect. 2.3. Two examples are implemented in Sect. 3 to verify the feasibility of the algorithms. Conclusions are summarized in Sect. 4.

2 Iso-error tool path generation

This section mainly presents the process of calculating accurate step error and generating iso-error tool path. The interval size is simply planned by iso-parametric method. Initial CL points and tool vectors are calculated firstly in Sect. 2.1. In Sect. 2.2, accurate step error of every two adjacent tool locations is computed based on the geometric relationship among tool locations (including CL points and tool vectors), CC points and step error. Finally, in Sect. 2.3, step length is adjusted by changing CC parameters iteratively so as to compute iso-error CC point and iso-error tool path. This section takes the \(i\) th line CC curve \(CC_{i}\) and the \(j\) th,\(j + 1\) th CC points \(P_{i,j}^{CC}\) and \(P_{i,j + 1}^{CC}\) as examples to describe all algorithms. The main calculation process is shown in Fig. 3. In the process, all CC curves are 3D parametric curves on the surface \(S\). All the figures including CC and CL points just show basic geometrical relationship, and adjacent CC points and CL points are not on a plane.

Fig. 3
figure 3

Process of iso-error tool path generation

2.1 Calculate initial CL points and tool vectors for CC curves

This section presents a calculation process of initial CL points and tool vectors for CC curve. Local short curves near CC points are approximately seen as arcs, and initial values of step length are calculated by chord error to establish discrete CC points. Then initial CL points and tool vectors are calculated by the inclination angle \(\alpha\). If there is concave region in the machining surface, \(\alpha\) should be great enough so as to avoid local gouging [25]. Taking the \(i\) th line CC curve \(CC_{i}\) as an example, the calculation process is as following.

Step 1 obtain CC curve

Let \(u\) and \(v\) be the interval and feed directions of machined parametric surface \(S\), respectively. The \(i\) th line CC curve \(CC_{i}\) can be obtained by Eq. (1). \(n\) is the total number of lines of tool path. \(u_{\min }\) and \(u_{\max }\) are minimum and maximum of \(u\) parameter, respectively.

$$\begin{cases} CC_{i} { = }S\left( {u_{i} } \right) \\ u_{i} = \frac{n - i}{{n - 1}}u_{\min } + \frac{i - 1}{{n - 1}}u_{\max } \end{cases}$$
(1)

Step 2 calculate discrete CC points on CC curve

Let the \(v\) range of \(CC_{i}\) be \(\left[ {v_{\min } ,v_{\max } } \right]\). The first CC point has the parameter \(v_{1} = v_{\min }\). For the \(j\) th CC point \(P_{i,j}^{CC}\), the coordinate \(\left( {x_{i,j}^{CC} ,y_{i,j}^{CC} ,z_{i,j}^{CC} } \right)\), curve length \(L_{j}\), curvature \(k_{j}\), tangent vector \({\varvec{t}}_{j}\) and normal vector \({\varvec{n}}_{j}\) can be calculated and expressed as Eq. (2). \({\varvec{S}}_{{\varvec{u}}}\) and \({\varvec{S}}_{{\varvec{v}}}\) are the tangent vectors of an arbitrary point on the surface along the directions of parameter \(u\) and \(v\).

$$\begin{cases} P_{i,j}^{CC} \left( {x_{i,j}^{CC} ,y_{i,j}^{CC} ,z_{i,j}^{CC} } \right){ = }S\left( {u_{i} ,v_{j} } \right) = CC_{i} \left( {v_{j} } \right) \hfill \\ L_{j} = L\left( {v_{j} } \right) \hfill \\ k_{j} = k\left( {v_{j} } \right) \hfill \\ {\varvec{t}}_{j} = t\left( {v_{j} } \right) \hfill \\ {\varvec{n}} = \frac{{{\varvec{S}}_{{\varvec{u}}} \times {\varvec{S}}_{{\varvec{v}}} }}{{\left| {{\varvec{S}}_{{\varvec{u}}} \times {\varvec{S}}_{{\varvec{v}}} } \right|}},{\varvec{S}}_{{\varvec{u}}} = \frac{{\partial S\left( {u,v} \right)}}{\partial u},{\varvec{S}}_{{\varvec{v}}} = \frac{{\partial S\left( {u,v} \right)}}{\partial v} \hfill \\ \end{cases}$$
(2)

For the next CC point \(P_{i,j + 1}^{CC}\), when the actual step error is equal to the allowed maximum \(e_{\max }\), the step length is also the theoretical maximum. Considering the value of \(e_{\max }\) in finish machining is small and the curvature of surface changes smoothly, the local curve \(CC_{i,j}\) between \(P_{i,j}^{CC}\) and \(P_{i,j + 1}^{CC}\) is short in length and supposed iso-curvature in this section. As shown in Fig. 4, the chord error (linear error) between the segment line \(P_{i,j}^{CC} P_{i,j + 1}^{CC^{\prime}}\) and the arc \(P_{i,j}^{CC} P_{i,j + 1}^{CC^{\prime}}\) is set \(e_{\max }\). \(P_{i,j + 1}^{CC}\) is the actual CC point on the curve \(CC_{i}\). Based on the relationship, \(v_{j + 1}\) of \(P_{i,j + 1}^{CC}\) can be calculated by Eq. (3) and the other data of \(P_{i,j + 1}^{CC}\) can be obtained by Eq. (2).

$$\left\{ {\begin{array}{*{20}l} {v_{j + 1} = L^{ - 1} \left( {P_{i,j}^{CC} P_{i,j + 1}^{CC^{\prime}} + L\left( {v_{j} } \right)} \right)} \hfill \\ {P_{i,j}^{CC} P_{i,j + 1}^{CC^{\prime}} = \frac{2\theta }{{\left| {k\left( {v_{j} } \right)} \right|}}} \hfill \\ {\theta = \arccos \left( {1 - \left| {k\left( {v_{j} } \right)} \right|e_{\max } } \right)} \hfill \\ \end{array} } \right.$$
(3)
Fig. 4
figure 4

Chord error calculation

Step 3 calculate initial CL points and tool vectors for CC points

Taking \(P_{i,j}^{CC}\) as an example, the tangent vector \({\varvec{t}}_{j}\) and normal vector \({\varvec{n}}_{j}\) can be obtained by Eq. (2). A local coordinate centered at \(P_{i,j}^{CC}\) can be established by \({\varvec{y}}_{j} \user2{ = t}_{j}\)\({\varvec{z}}_{j} \user2{ = n}_{j}\) and \({\varvec{x}}_{j} \user2{ = t}_{j} \times {\varvec{n}}_{j}\). As shown in Fig. 5, CL point and tool vector are established by the inclination angle \(\alpha\) and can be obtained by Eq. (4).

$$\begin{cases} {\varvec{T}} = {\varvec{n}}\cos \alpha + {\varvec{t}}\sin \alpha \hfill \\ P_{{}}^{CL} = P_{{}}^{CC} + R\left( {{\varvec{t}} \times {\varvec{n}}} \right) \times {\varvec{T}} \hfill \\ \end{cases}$$
(4)
Fig. 5
figure 5

CL point and tool vector

All CC points can be obtained by the above process. In Step 2, if \(P_{i,j}^{CC}\) is an inflection point or near an inflection point, the curvature will be very small and \(P_{i,j + 1}^{CC}\) will have an abnormally large step length, which causes the actual step error greater than \(e_{\max }\). In order to avoid this situation, every step error will be calculated accurately in Sect. 2.2 and step length will be adjusted to generate ios-error CC points and tool path in Sect. 2.3.

2.2 Compute step error of two adjacent tool locations

As shown in Fig. 6, when the flat-end tool moves along a line of tool path with changed rotation angles, the cutting circle on the tool bottom sweeps and builds non-uniform envelope surface on machined surface. Part of the cutting circle (cutting arc in Fig. 6) is the curve on the machined surface.

Fig. 6
figure 6

Flat-end tool machining

As shown in Fig. 7, the local curve \(CC_{i,j}\) between \(P_{i,j}^{CC}\) and \(P_{i,j + 1}^{CC}\) usually has smooth figure on sculptured surface. In this section, the maximum distance between \(CC_{i,j}\) and the envelope surface is the wanted step error between two adjacent locations. In order to simply the calculation, a set \(\left\{ {p_{k}^{i,j} } \right\}\) of discrete points on \(CC_{i,j}\) and the cutting circles on the tool bottom are obtained to replace \(CC_{i,j}\) and the envelope surface in calculation.

Fig. 7
figure 7

Errors between two adjacent locations

Supposed \(p_{m}^{i,j}\) on \(CC_{i,j}\) has the maximum \(e_{\max }^{i,j}\) of step error, the value of step error increases monotonically from \(P_{i,j}^{CC}\) to \(p_{m}^{i,j}\) and decreases monotonically from \(p_{m}^{i,j}\) to \(P_{i,j + 1}^{CC}\). Supposed \(p_{n}^{i,j}\) and \(p_{k}^{i,j}\) have the maximums of linear error and non-linear error, the wanted \(p_{m}^{i,j}\) is located near \(p_{n}^{i,j}\) and \(p_{k}^{i,j}\). This section firstly obtains \(\left\{ {p_{k}^{i,j} } \right\}\) on the curve \(CC_{i,j}\) and calculates the point \(p_{n}^{i,j}\) with the maximum \(e_{\max }^{L}\) of linear error in Sect. 2.2.1. Then a step error calculation method of specified tool location is presented in Sect. 2.2.2 to obtain the point \(p_{k}^{i,j}\) with the maximum \(e_{\max }^{NL}\) of non-linear error. A step error calculation method for specified CC point is presented to calculate the step error \(e_{n}^{i,j}\) of \(p_{n}^{i,j}\) in Sect. 2.2.3. Finally, the maximum step error can be searched near \(p_{n}^{i,j}\) and \(p_{k}^{i,j}\), which is the wanted step error between \(P_{i,j}^{CC}\) and \(P_{i,j + 1}^{CC}\).

2.2.1 Calculate CC points with maximum linear error on CC curve

The CC curve \(CC_{i,j}\) between \(P_{i,j}^{CC}\) and \(P_{i,j + 1}^{CC}\) can be obtained by Eq. (5). \(v_{j} ,v_{j + 1}\) are \(v\) parameters of \(P_{i,j}^{CC}\) and \(P_{i,j + 1}^{CC}\), respectively. Discrete points \(\left\{ {p_{k}^{i,j} } \right\}\) on the local curve \(CC_{i,j}\) are calculated by Eq. (6) with the increment \(\Delta v\) to replace \(CC_{i,j}\) in the calculation process, which can improve the calculation efficiency. The distance \(e_{k}^{L}\) between \(p_{k}^{i,j}\) and the segment \(P_{i,j}^{CC} P_{i,j + 1}^{CC}\) can be calculated by Eq. (7). Let \(p_{n}^{i,j}\) in \(\left\{ {p_{k}^{i,j} } \right\}\) have the maximum \(e_{\max }^{L}\). As the chord error between the segment \(P_{i,j}^{CC} P_{i,j + 1}^{CC}\) and \(CC_{i,j}\), \(e_{\max }^{L}\) is the wanted maximum of linear error.

$$CC_{i,j} = CC_{i} \left( v \right),v \in \left[ {v_{j} ,v_{j + 1} } \right]$$
(5)
$$p_{k}^{i,j} { = }CC_{i} \left( {v_{j} + k \cdot \Delta v} \right),k = 1,2,3...$$
(6)
$$e_{k}^{L} = \frac{{\overrightarrow {{P_{i,j}^{CC} p_{k}^{i,j} }} \times \overrightarrow {{P_{i,j}^{CC} P_{i,j + 1}^{CC} }} }}{{\left| {\overrightarrow {{P_{i,j}^{CC} P_{i,j + 1}^{CC} }} } \right|}}$$
(7)

2.2.2 Calculate step error of a tool location between adjacent CL points

As shown in Fig. 7, \(O_{i,j}^{{}}\) and \(O_{i,j + 1}^{{}}\) are top points of tool and seen as the location point of tool holder. \(O_{m}^{{}}\) is the midpoint of \(O_{i,j}^{{}} O_{i,j + 1}^{{}}\). On the bottom circle of the tool location on \(O_{m}^{{}}\), there is a point which has a minimum distance to the curve \(CC_{i,j}\), and the minimum distance is the step error of tool location \(O_{m}^{{}}\). A geometric algorithm of step error calculation is presented for the distances between the point set \(\left\{ {p_{k}^{i,j} } \right\}\) and the bottom circle of tool. Taking the middle position \(O_{m}^{{}}\) of \(O_{i,j}^{{}}\) and \(O_{i,j + 1}^{{}}\) as an example, the detailed process of step error calculation is as following.

Step 1 calculate tool data of middle position of two adjacent tool locations

As shown in Fig. 7, when tool moves from \(P_{i,j}^{CL}\) to \(P_{i,j + 1}^{CL}\), the tool holder moves in the straight line \(O_{i,j}^{{}} O_{i,j + 1}^{{}}\). The tool location on the midpoint \(O_{m}^{{}}\) of \(O_{i,j}^{{}} O_{i,j + 1}^{{}}\) has the maximum of non-linear error. The tool data of \(O_{m}^{{}}\) can be calculated by Eq. (8), where \(L{}_{T}\) is the tool length.

$$\begin{cases} P_{m}^{CL} = O_{m}^{{}} - L_{T} {\varvec{T}}_{m} \hfill \\ {\varvec{T}}_{m} = \left( {{\varvec{T}}_{i,j} + {\varvec{T}}_{i,j + 1} } \right)/2 \hfill \\ O_{m}^{{}} = \left( {O_{i,j}^{{}} + O_{i,j + 1}^{{}} } \right)/2 \hfill \\ O_{i,j}^{{}} { = }P_{i,j}^{CL} + L_{T} {\varvec{T}}_{i,j} \hfill \\ O_{i,j + 1}^{{}} { = }P_{i,j + 1}^{CL} + L_{T} {\varvec{T}}_{i,j + 1} \hfill \\ \end{cases}$$
(8)

Step 2 calculate initial step error for tool location \(O_{m}^{{}}\).

As shown in Fig. 8, \(B_{k}\) on the plane of tool bottom is the foot point of \(p_{k}^{i,j}\). \(C_{k}\) is the intersection point of \(P_{m}^{CL} B_{k}\) and \(\odot P_{m}^{CL}\). The triangles \(\Delta p_{k}^{i,j} B_{k} C_{k}\) and \(\Delta p_{k}^{i,j} B_{k} p_{m}^{CL}\) are constructed, and the distance \(p_{k}^{i,j} C_{k}\) can be calculated with \(p_{k}^{i,j} B_{k}\) and \(B_{k} C_{k}\) by Eq. (9). In \(\Delta p_{k}^{i,j} B_{k} C_{k}\), \(C_{k} B_{k}\) is the minimum distance between \(\odot P_{m}^{CL}\) and \(B_{k}\), and \(p_{k}^{i,j} B_{k}\) is the minimum distance between \(p_{k}^{i,j}\) and the tool bottom plane. So, \(p_{k}^{i,j} C_{k}\) is the minimum distance between \(p_{k}^{i,j}\) and \(\odot P_{m}^{CL}\). The maximum of the minimum distances of all points in \(\left\{ {p_{k}^{i,j} } \right\}\) is the initial step error of the tool location on \(O_{m}^{{}}\).

$$\begin{cases} p_{k}^{i,j} C_{k} = \sqrt {p_{k}^{i,j} B_{k}^{2} + B_{k} C_{k}^{2} } \hfill \\ B_{k} C_{k} = \left| {R - P_{m}^{CL} B_{k} } \right| \hfill \\ P_{m}^{CL} B_{k} = \sqrt {P_{m}^{CL} p_{k}^{i,j2} - p_{k}^{i,j} B_{k}^{2} } \hfill \\ p_{k}^{i,j} B_{k} = \frac{{\overrightarrow {{p_{m}^{CL} p_{k}^{i,j} }} \cdot {\varvec{T}}_{m} }}{{\left| {{\varvec{T}}_{m} } \right|}} \hfill \\ \end{cases}$$
(9)
Fig. 8
figure 8

Geometrical relationship between CC points and tool bottom circle

Step 3 judge if the step error meets the precision requirement

Supposed that the distance \(d_{k}^{i,j}\) of \(p_{k}^{i,j}\) is the calculated step error in Step 2, the minimum difference \(\Delta d_{\min }^{k}\) between \(d_{k - 1}^{i,j}\)\(d_{k + 1}^{i,j}\) and \(d_{k}^{i,j}\) can be obtained by Eq. (10). If \(\Delta d_{\min }^{k}\) is greater than the user-defined precision \(\Delta e\) of step error, \(d_{k}^{i,j}\) cannot meet the precision requirement. The process goes to Step 4. If \(\Delta d_{\min }^{k}\) is less than \(\Delta e\), \(d_{k}^{i,j}\) can meet the precision requirement and is the wanted step error. The process ends. The flow chart of step error calculation is shown in Fig. 9.

$$\Delta d_{\min }^{k} = \min \left( {d_{k - 1}^{i,j} - d_{k}^{i,j} ,d_{k + 1}^{i,j} - d_{k}^{i,j} } \right)$$
(10)
Fig. 9
figure 9

Flow chart of calculating step error of tool location \(O_{m}\)

Step 4 obtain new CC points and calculate step error

Two midpoints \(p_{k - 1}^{m}\) and \(p_{k}^{m}\) of \(p_{k - 1}^{i,j} p_{k}^{i,j}\) and \(p_{k}^{i,j} p_{k + 1}^{i,j}\) can be obtained by Eq. (11). The distances \(d_{k - 1}^{m}\)\(d_{k}^{m}\) from \(p_{k - 1}^{m}\)\(p_{k}^{m}\) to \(\odot P_{m}^{CL}\) can be calculated by Eq. (9). The maximum distance \(d_{\max }^{k}\) is obtained by Eq. (12). Plug the distances into Step 3 and judges if \(d_{\max }^{k}\) meets the precision requirement.

$$\begin{cases} p_{k - 1}^{m} = CC_{i} \left( {v_{k - 1}^{m} } \right) \hfill \\ v_{k - 1}^{m} = \left( {v_{k - 1}^{i,j} + v_{k}^{i,j} } \right)/2 \hfill \\ \end{cases}$$
(11)
$$d_{\max }^{k} = \max \left( {d_{k - 1}^{m} ,d_{k}^{i,j} ,d_{k}^{m} } \right)$$
(12)

2.2.3 Calculate step error of a point on CC curve

\(p_{n}^{i,j}\) and \(p_{k}^{i,j}\) have the maximums of linear and non-linear errors, which can be calculated in Sects. 2.2.1 and 2.2.2. The wanted \(p_{m}^{i,j}\) with the maximum of step error is located near \(p_{n}^{i,j}\) and \(p_{k}^{i,j}\). This section firstly calculates step error of \(p_{n}^{i,j}\), and then search \(p_{m}^{i,j}\) by calculating step error with iterative parameter. The detailed process is as following.

Step 1 Calculate tool location point based on CC point

As shown in Fig. 10, \(p_{n}^{B}\) and \(p_{k}^{B}\) on the segment \(P_{i,j}^{CC} P_{i,j + 1}^{CC}\) are foot points of \(p_{n}^{i,j}\) and \(p_{k}^{i,j}\), respectively. The location coefficient \(k_{n}\) of \(p_{n}^{B}\) on \(P_{i,j}^{CC} p_{k}^{B}\) is obtained by Eq. (13). Supposed that \(O_{n}^{{}}\) has the same location coefficient \(k_{n}\) on \(O_{i,j}^{{}} O_{k}^{{}}\), \(O_{n}^{{}}\) can be obtained by Eq. (14).

$$k_{n} = \frac{{\overrightarrow {{P_{i,j}^{CC} p_{n}^{B} }} }}{{\overrightarrow {{P_{i,j}^{CC} p_{k}^{B} }} }}$$
(13)
$$\overrightarrow {{O_{i,j}^{{}} O_{n}^{{}} }} = k_{n} \cdot \overrightarrow {{O_{i,j}^{{}} O_{k}^{{}} }}$$
(14)
Fig. 10
figure 10

Tool location on \(O_{n}^{{}}\)

Step 2 calculate the initial step error of tool location

The CL point \(P_{n}^{CL}\) and tool vector \({\varvec{T}}_{n}^{i,j}\) of \(O_{n}^{{}}\) can be calculated by Eq. (15). The step error of tool location \(O_{n}^{{}}\) can be calculated by the algorithm in Sect. 2.2.2 and is taken as the initial value.

$$\begin{cases} P_{n}^{CL} = O_{n}^{{}} - L{\varvec{T}}_{n}^{i,j} \hfill \\ {\varvec{T}}_{n}^{i,j} = \left( {1 - k_{n} } \right){\varvec{T}}_{i,j}^{{}} + k_{n} {\varvec{T}}_{k}^{i,j} \hfill \\ \end{cases}$$
(15)

Step 3 calculate more accurate step error

Let \(k_{n + \Delta k} = k_{n} + \Delta k\) and \(k_{n - \Delta k} = k_{n} - \Delta k\)\(\Delta k\) is the increment of location coefficient, which can be usually set from 0.05 to 0.1. Greater \(\Delta k\) makes calculation more efficient but lower precision. Same with \(k_{n}\), tool locations of \(k_{n + \Delta k}\)\(k_{n - \Delta k}\) and their step error \(e_{n + \Delta k}\)\(e_{n - \Delta k}\) can be calculated by Step 1 and Step 2. If \(e_{n + \Delta k} > e_{n}\), let \(k_{n + \Delta k}\) plus \(\Delta k\) to search greater step error. If \(e_{n - \Delta k} > e_{n}\), let \(k_{n - \Delta k}\) minus \(\Delta k\) to search greater step error. If \(e_{n} > e_{n + \Delta k}\) and \(e_{n} > e_{n - \Delta k}\), \(e_{n}\) is the wanted more accurate step error.

2.3 Compute iso-error CC points and tool path

Section 2.2 presents the step error computation method of \(P_{i,j}^{CL}\) and \(P_{i,j + 1}^{CL}\). Rename the step error of \(P_{i,j}^{CL}\) and \(P_{i,j + 1}^{CL}\) with \(e_{i,j}\). \(e_{i,j}\) can hardly be exactly equal to the maximum allowable value \(e_{\max }\). In this section, a range \(\left[ {e_{\max }^{low} ,e_{\max } } \right]\) is used to judge if \(e_{i,j}\) meets error requirement. \(e_{\max }^{low}\) is user-defined lower limit of \(e_{\max }\), which is close to \(e_{\max }\) such as 0.9 \(e_{\max }\). If \(e_{i,j} \in \left[ {e_{\max }^{low} ,e_{\max } } \right]\), \(e_{i,j}\) will be seen as meeting error requirement and \(P_{i,j + 1}^{CL}\) is the wanted iso-error CL point. Otherwise, the parameter of \(P_{i,j + 1}^{CC}\) will be adjusted to make \(e_{i,j} \in \left[ {e_{\max }^{low} ,e_{\max } } \right]\). The detailed process is as following.

Step 1

If \(e_{i,j} \notin \left[ {e_{\max }^{low} ,e_{\max } } \right]\), the step length needs to be adjusted and the process goes to Step 2. If \(e_{i,j} \in \left[ {e_{\max }^{low} ,e_{\max } } \right]\), the process goes to Step 3.

Step 2

Supposed step error and step length are linear relationship, the parameter increment \(\Delta v_{i,j + 1}\) of CC point is obtained by Eq. (16). An increment coefficient \(k_{e}\) \(\left( {k_{e} < 1} \right)\) is added in Eq. (16) to adjust parameter increment, which can make the iterative process convergent. The adjusted CC point \(P_{i,j + 1}^{CC} = CC_{i,j} \left( {v_{i,j + 1} + \Delta v_{i,j + 1} } \right)\) is obtained to calculate new CL point \(P_{i,j + 1}^{CL}\) and tool vector \({\varvec{T}}_{i,j}\) with Eq. (4). And new step error \(e_{i,j}\) can be calculated by the methods in Sect. 2.2. The process goes to Step 1.

$$\Delta v_{i,j + 1} = k_{e} \frac{{e_{\max } - e_{i,j} }}{{e_{\max } }}v_{i,j + 1}$$
(16)

Step 3

The step error \(e_{i,j}\) between \(P_{i,j + 1}^{CL}\) and \(P_{i,j + 1}^{CL}\) meets the requirement. \(P_{i,j + 1}^{CL}\) and \({\varvec{T}}_{i,j}\) are the wanted iso-error CL point and tool vector.

Same with \(P_{i,j + 1}^{CL}\), the subsequent CL points and tool vectors can also be calculated one by one. And all iso-error CL points and tool vectors of all CC curves can be obtained by the above algorithms.

3 Examples

All the algorithms in Sect. 2 have been implemented in our tool path generation software based on Visual Studio 2017 and Opencascade.7.4.0. As shown in Figs. 11a and 15a, a typical free-form surface and a blade are selected for tool path generation to verify the feasibility and efficiency of the iso-error method presented in this paper, which contain concave, convex and large curvature regions. The information and machining parameters of two models are shown in Table 1. Besides, the increment of location coefficient \(\Delta k\) is 0.1, which is used to calculate step error for specified CC point. The increment coefficient \(k_{e}\) is 0.8, which is used to adjust parameter increment when searching iso-error CC points.

Fig. 11
figure 11

Free-form surface and tool path

Table 1 Information and machining parameters of two models

The free-form surface’s iso-error tool path generated by the iso-error method presented in this paper is shown in Fig. 11b. Another similar tool path generation method including geometry-based error evaluation method in [14], iso-parameter and iso-length methods are employed to generated tool path for comparison. Figure 11c shows the tool path generated by the method in [14]. The parameter and length increments in iso-parameter and iso-length methods are 0.01 and 1 mm, respectively.

Considering all lines of tool path are too dense to show clearly, eight lines of all tool path are evenly selected to show in Fig. 12 to compare the distribution of CC points on CC curves. The CC points on iso-error tool path and the tool path generated by the method in [14] are non-uniformly located on CC curves. The numbers of CC points of all tool path are shown in Table 2. The iso-error tool path has least CC points. Figure 13 shows the step errors of eight lines of all tool path. All the step errors of the iso-error tool path are in the defined range [0.004 mm, 0.005 mm]. Only the last step errors in every line are lower than 0.004 mm because the last CC points are the end point of CC curves. All the step errors of the tool path generated by the method in [14] are less than 0.005 mm. However, a few of them are less than 0.004 mm. As shown in Figs. 13c, d, most step errors of iso-parameter tool path and iso-length tool path are out of the range [0.004 mm, 0.005 mm]. In practical application, smaller parameter and length increments should be defined to make step errors less than the upper limit, which will generate much more CC points than iso-error tool path. Figure 14 shows the parameter increments of the tool path generated by the iso-error method presented in this paper and the method in [14]. The parameter increments of iso-error tool path are generally greater, which means greater step length and makes the step errors are closer to the upper limit.

Fig. 12
figure 12

Eight lines of the free-form surface’s all tool path

Table 2 Numbers of CC points on the free-form surface’s tool path generated by four methods
Fig. 13
figure 13

Step error of eight lines of the free-form surface’s all tool path

Fig. 14
figure 14

Parameter increments of the free-form surface’s two kinds of tool path

In another example, the blade is also performed by the same comparison with the free-form surface. Eight lines of four kinds of tool path is shown in Figs. 15b–e. The parameter and length increments are 0.113 and 0.1 mm, respectively. The numbers of CC points are shown in Table 3. The v parameter ranges [25, 34] and [58, 68] are lead and trail regions with much greater curvature. As shown in Fig. 16, the tool path generated by the methods in this paper and the paper [14] has no step errors greater than the upper limit, and Fig. 17 shows the parameter increments. Many step errors of iso-parameter tool path and iso-length tool path are out of the defined error range. A few step errors in the tool path generated by the method in [14] are less than the lower limit, especially in the lead and trail regions. Figure 18 shows the machined blade with the iso-error tool path.

Fig. 15
figure 15

Blade and eight lines of tool path generated by four methods

Table 3 Numbers of CC points on the blade’s tool path generated by four methods
Fig. 16
figure 16

Step error of eight lines of the blade’s all tool path

Fig. 17
figure 17

Parameter increments of the blade’s two kinds of tool path

Fig. 18
figure 18

Machined blade

Both examples have similar results. The tool path generated by iso-parameter and iso-length methods have many step errors greater than the defined upper limit, which cannot meet the error requirement and needs smaller parameter and length increments. Step errors of the tool path generated by the method in [14] are not greater than the defined upper limit. The method in this paper can generate iso-error tool path which has least CC points and all step errors in the defined range.

4 Conclusion

Calculating CL points and tool vectors based on discrete CC points is a main tool path generation method for sculptured surface. In order to void step error greater than the maximum allowance, step length is usually set conservative, which generate a lot of redundant CL points. For maximizing step length and minimizing redundant CC and CL points, this paper presents a five-axis iso-error tool path generation method for flat-end tool machining sculptured surface.

Because step error between adjacent tool locations is hard to calculate directly, two step error calculation algorithms of tool locations and CC points are presented respectively. For a tool location, the bottom circle of tool can be seen as contour of tool envelope surface. The minimum distance between the bottom circle and CC curve is the wanted step error of the tool location, which is obtained by calculating distances from CC points to the bottom circle iteratively. For a CC point, the minimum distance to tool envelope surface is the wanted step error of the CC point. There are different distances between the CC point and different tool locations. Discrete tool locations and bottom circles are obtained iteratively to replace tool envelope surface. The distances between the CC point and bottom circles are calculated to search the minimum distance, which is the step error of the CC point.

The real step error between two adjacent CC points can be calculated by the above two algorithms. In order to compute iso-error CC point, step length is adjusted by changing CC parameters iteratively until step error is in the defined range. Iso-error tool path are calculated based on iso-error CC points.

To meet the requirement of calculation precision, the algorithms in this paper use parameter iterations. However, iterative calculation costs a lot of time and is not an efficient way. Our future work will focus on improving efficiency on algorithms and calculation in order to reduce the time of iso-error tool path generation, which helps to the promotion of iso-error tool path.