Original Article Conversion method study from cutter-location points to nonuniform rational B-spline toolpath NC file for high-speed machining Proc IMechE Part C: J Mechanical Engineering Science 0(0) 1–12 ! IMechE 2018 Reprints and permissions: sagepub.co.uk/journalsPermissions.nav DOI: 10.1177/0954406218762018 journals.sagepub.com/home/pic Jian-wei Ma , De-ning Song, Zhen-yuan Jia, Guo-qing Hu and Wei-wei Su Abstract Parts with complex curved surfaces are widely applied and the demands for the machining quality and the machining efficiency of such complex parts become increasingly higher. In order to realize high-speed and high-quality machining, the nonuniform rational B-spline interpolator is widely researched and demonstrated to be superior to the conventional linear or circular interpolators. However, the nonuniform rational B-spline toolpath NC files cannot be directly generated from the computer-aided design (CAD) models by using commercial computer-aided manufacturing (CAM) software. To deal with this problem, a conversion method from the cutter-location points to the nonuniform rational Bspline toolpath numerical control (NC) file is presented. To avoid the bad curve-fitting effect at sharp corners of the toolpath and to meanwhile reduce the computational burden, the cutter-location pre-processing method, consisting data segmentation and data simplification, is provided first. Then, the least-square method is employed to fit the cutter locations to the nonuniform rational B-spline curves, and an iterative fitting approach is proposed for linear/nonuniform rational B-spline hybrid toolpath generation. Finally, a user interface is designed for displaying the fitting results and outputting the NC file with nonuniform rational B-spline toolpaths. By using this method, nonuniform rational B-spline and linear toolpaths hybrid interpolation NC program can be generated for the high-speed machining of complex curved surface parts with the utilization of the nonuniform rational B-spline interpolator. The experimental results demonstrate the feasibility and the advantages of the presented method. Keywords Nonuniform rational B-spline toolpath, parametric curve interpolation, curve fitting, high-speed machining, complex curved surface, cutter-location points Date received: 17 August 2017; accepted: 5 February 2018 Introduction Parts with complex curved surfaces are widely applied in the equipment of fields, such as aerospace, automation, and die/molds.1,2 With the development of the high-end equipment used in these fields, demands for the machining quality and the machining efficiency of such complex parts become increasingly higher. Normally, the curved toolpath of these complex parts is expressed as continuous short-line or circular segments, thus using the linear/circular interpolator to machine these parts.3,4 However, there exists inevitable drawbacks for the linear/circular interpolator. First, the rapid acceleration/deceleration at the transition points between two adjacent segments must be executed due to the first-order discontinuity at these points.5–7 Then, the approximation of the desired free-form curved toolpath by linear/circular segments will result in a large file size.7 Both of the above factors lead to the degradation of machining quality and efficiency. To address the shortcomings of the traditional linear/circular interpolator, the parametric curve interpolation methods are widely researched and Key Laboratory for Precision and Non-traditional Machining Technology of the Ministry of Education, School of Mechanical Engineering, Dalian University of Technology, Dalian, China Corresponding author: Jian-wei Ma, Key Laboratory for Precision and Non-traditional Machining Technology of the Ministry of Education, School of Mechanical Engineering, Dalian University of Technology, Dalian 116024, China. Email: mjw2011@dlut.edu.cn 2 developed to generate the smooth curved toolpath directly without the rapid acceleration/deceleration for the high-speed and high-precision machining.5–9 Lots of modern computer numerical control (CNC) systems, such as Siemens (Germany), FANUC (Japan), and Guangyang numerical control (GNC) (China) can provide cubic spline or nonuniform rational B-spline (NURBS) interpolation function. Taking the GNC numerical control system as an instance, the G-code of NURBS interpolation is G6.2. When utilizing these curved interpolation functions, the parametric curve NC file with the corresponding requested format must be generated in advance. However, most existing commercial CAM applications, such as UG/NX and solid CAM, do not have the capability to generate the curved interpolation toolpath and can only output the routine linear/circular interpolation NC files or the cutter location points, which makes it also difficult to realize the machining with the parametric curve interpolator, although the CNC system provides this function. As a result, research on the generation method of the parametric curved interpolation toolpath becomes significant for filling up the vacancy between the CAD model of the complex parts and the curve interpolator of the CNC system, thus realizing high-speed and high-quality machining. To generate the curved toolpath NC file for the parametric interpolator, Ma and Kruth10 provided an NURBS curve-fitting method. Similarly, Yu11 also fitted the NURBS curve based on arc-centripetal parameterization for the parametric toolpath generation. Recently, Yang et al.12 presented a curve-fitting and optimal interpolation method for CNC machining under the confined error by using the quadratic B-splines. However, these methods fitted the whole free-form toolpath as a single parametric curve, which could hardly keep the sound-fitting precision at the large-curvature regions. Although Lin et al.13 and Wu et al.14 split the whole toolpath to several fitting sections, and they utilized all of the cutter locations to fit the NURBS curve at each section, which might make the algorithms time-consuming or obtain too many control points of the fitted NURBS curve. In addition, Lin15 and Deng and Lin16 proposed an adaptive data-fitting approach by the progressiveiterative approximation for the spline curve fitting. Garcia-Capulin et al.17 presented a hierarchical genetic algorithm approach for the curve fitting with B-splines. These methods all considered the whole path as one curve and fitted the data to splines using the time-consuming iterations. It can be seen from their results that the fitting errors are large unless the iteration for extremely much times. Furthermore, although there are also some other curve-fitting methods,18,19 they are proposed for the mathematical computations but not for the NURBS-toolpath generation where extra issues, such as the NC-file size and the toolpath combination of NURBS and linesegment, should be considered. Based on the above Proc IMechE Part C: J Mechanical Engineering Science 0(0) discussion, more appropriate NURBS-toolpath generation method is also in urgent need. As a result, this study takes both fitting precision and computational burden into consideration and presents a NURBS-toolpath NC-file generation method from the original cutter-location points for realization of high-speed machining with the NURBS interpolator. First, the cutter location points are pre-processed by data segmentation and simplification, so as to ensure the sound-fitting precision at sharp corners and the low computational burden. After that, the simplified data are utilized to fit the NURBS curves at every sections of the whole toolpath according to the least squared method. Then, the fitting precision is judged and the iterative fitting approach is given. When the fitting precision also cannot be satisfied after the iterative fitting, the linear interpolation toolpath is exported, otherwise, the NURBS toolpath is outputted. Finally, the user interface is designed based on the MATLAB/graphical user interface (GUI) so as to generate the NURBStoolpath NC file for the high-speed machining of the complex curved surface parts. Academic contribution of this approach concentrates on the combination of data segmentation, data simplification, and leastsquare curve-fitting algorithms for generation of the piecewise NURBS and line-segment hybrid toolpath, thus realizing the high-efficiency machining. Pre-processing of cutter location points In this section, the cutter-location points obtained from the CAD model of the complex curved surface parts are pre-processed in order to ensure a better performance of the further NURBS curve fitting. The pre-processing contains two blocks: the data segmentation and the data simplification. During data segmentation, the integral curved toolpath is split into several segments at the sharp-corner positions. Afterward, the cutter-location data at each segment are simplified into key points by using the data-simplification block. Both of the above two procedures are conductive to the fitting precision and the computational efficiency of the NURBS curve fitting. In order to avoid the bad-fitting effect at the largecurvature regions, the cutter-location data are first segmented at the sharp corners. Denote the original desired cutter-location sequence as {Qri}, i ¼ 1,. . ., nq, where nq is the total amount of the cutter-location points. Given the angle condition for the segmentation as q, scan the cutter-location sequence {Qri} from i ¼ 2 to i ¼ nq 1 and calculate the included angle between the vector Qri 1Qri and the vector QriQri þ 1 by ! ðQri Qri1 Þ Qriþ1 Qri ¼ arccos Qri Qri1 Qriþ1 Qri ð1Þ As shown in Figure 1, compare with q, and if > q is satisfied, denote the current cutter location Ma et al. 3 Figure 1. Schematic diagram of data segmentation. Figure 3. Illustration diagram of data pre-processing. Figure 2. Schematic diagram of data simplification. Qri as a segmentation point, thus realizing the data segmentation. Denote the total number of the data sections after the toolpath splitting as nc and the amount of the cutter locations at ith section as ki, thus the cutter-location sequence of ith section can be expressed as {Qci,j}, i ¼ 1,. . ., nc, j ¼ 1,. . ., ki. Considering that the overcrowding cutter locations is adverse to the fitting precision and the numerical efficiency, the data simplification is conducted after the data segmentation. Given the precision condition for the retrenching data as eq, scan the cutter-location sequence {Qci,j} from i ¼ 1 to i ¼ nc and j ¼ 2 to j ¼ ki 1 with the calculation of the distance from the point Qci,j to the line Qci,j 1Qci,j þ 1 by ) Qci,jþ1 Qci,j1 Qci,jþ1 Qci,j Qci,jþ1 Qci,j1 d ¼ ( ) Qci,jþ1 Qci,j1 Qci,jþ1 Qci,j Qci,jþ1 Qci,j1 Qci,jþ1 Qci,j ð2Þ As illustrated in Figure 2, judge the relation between d and eq. If d > eq is not satisfied, then get rid of the Qci,j point, otherwise, leave this point and retain it. Repeat above scanning until the condition d > eq is satisfied for every reserved cutter locations. Two notes should be clarified for the data simplification approach as follows. First, the d > eq condition is judged iteratively point-by-point instead of one-pass judging after calculating the distances of all points, so as to retain the key points that can reflect the main shape of the toolpath. Taking a standard circle as an instance, the discretized points will have the same d values computed by equation (2), and in this case, either no point or all points should be removed if they are judged in the meanwhile. On the contrary, when using the proposed iterative judging and removing method by scanning {Qci,j} from i ¼ 1 to i ¼ nc and j ¼ 2 to j ¼ ki 1, the d value for one point will be larger once its adjacent point is removed, so that the key points can be kept to reflect the shape of the toolpath. Second, the data simplification is started from j ¼ 2 and end by j ¼ ki 1, and this is because if the first or the final point is removed, the discontinuous between two adjacent data sections will occur. As the ending point of ith section is the starting point of (i þ 1)th section, keep the first and the final points of each section from being removed can thus ensure the continuity of the whole toolpath. Denote the amount of reserved cutter locations after the data simplification as ti, thus the cutter-location sequence after simplification can be expressed as {Qi,j}, i ¼ 1,. . ., nc, j ¼ 1,. . ., ti. By conducting above procedure, the remained cutter locations are all key points that can reflect the overall shape of the desired curved toolpath without the redundant points, and this is conductive to the precise curve fitting with a lower computational burden. In order to further explain the cutter-location preprocessing procedure in detail, the data segmentation and the data simplification are simultaneously plotted in the same illustration figure (see Figure 3). As shown in Figure 3 and according to the above definition, the original cutter-location points are Qr1 to Qr7. After the data segmentation, at Qr4 where the included angle between the vector Qr3Qr4 and the vector Qr4Qr5 is larger than q in this illustration, the cutter-location points are divided into two segments, i.e., segment 1 from Qc1,1 to Qc1,4 and segment 2 from Qc2,1 to Qc2,3. The data simplification is employed within each segment so as to retain the key points, instead of all tedious points, to fit the NURBS curves at every segments. In this illustration, the point Qc1,3 in the first segment and the point Qc2,2 in the second segment are removed, according to the distance principle presented above. After the data 4 Proc IMechE Part C: J Mechanical Engineering Science 0(0) simplification, the final points used for the curve fitting become Q1,1 to Q1,3 in the first segment and Q2,1 to Q2,2 in the second segment. Conversion from cutter location points to NURBS-toolpath NC file In this section, the conversion method from the cutterlocation points to the NURBS-toolpath NC file is presented. First, the curve fitting from the simplified cutter locations to the NURBS curve is introduced. Then, the iterative fitting method for the toolpath generation is given. Finally, the user interface for the NC-file creation is designed. Fitting of simplified cutter-location data by NURBS curve 8 m > > > j ¼ int i < np > m m > > þ j u j u j ¼ 1 i þ i u : pþi j1 np np ð6Þ In which, int(x) stands for the maximum integer no more than x. Then, the basic functions {Ni,p(u)} are obtained using the Cox–deBoor recursion formula as 8 > > < Ni,1 ðuÞ ¼ In general, the parametric equation of the p-order NURBS curve C(u) can be expressed as Pn Ni,p ðuÞ!i Pi CðuÞ ¼ Pi¼1 , n i¼1 Ni,p ðuÞ!i Denote the knot vector as U ¼ u1 , upþ1 , upþ2 , . . ., un , unþ1 , . . ., um g, where u1 , upþ1 equal to 0 and unþ1 , . . ., um equal to 1. The other knot values are calculated as Piegl and Tiller20 1, ui 4u 5 uiþ1 0, others uiþpþ1 u u ui > > : Ni,p ðuÞ ¼ Ni,p1 ðuÞ þ Niþ1,p1 ðuÞ uiþp ui uiþpþ1 uiþ1 ð7Þ u1 4u4unþpþ1 ð3Þ In which, {Pi} is the set of control points, {!i} is the set of weights, {Ni,p(u)} is the set of p-order B-spline basic functions defined on the nonuniform knot vector U, and U ¼ {u1, u2,. . ., un þ p þ 1}. To fit a NURBS curve, the parameters in equation (3) in terms of U, {Ni,p(u)}, {!i}, and {Pi} should all be determined. Here, the weights {!i} are set as constant 1.0 for every control points so as to avoid the nonlinear calculation, thus saving the computational time. In addition, the global approximation method is utilized to fit a curved toolpath as smooth as possible. The determine procedure of knot vector U, B-spline basic functions {Ni,p(u)}, and control points {Pi} is presented below. Given the initial order value pmin and the initial amount of control points nmin, the spline parameter corresponding to each simplified cutter location is first calculated using the endocentric parameterization method. For the cutter-location sequence {Qi,j}, i ¼ 1,. . ., nc, j ¼ 1,. . ., ti, the spline parameter u j corresponding to each point is calculated as Piegl and Tiller20 8 < u 1 ¼ 0, u ti ¼ 1 pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi Qi,j Qi,j1 k : u j ¼ u j1 þ Pti kpffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi , kQi,k Qi,k1 k k¼2 In which, ‘‘0/0 ¼ 0’’ is stipulated and i ¼ 1, 2,. . ., n. At last, to obtain the control points {Pi}, i ¼ 1, 2,. . ., n, let the initial and the final control points equal to the first and the last cutter locations of the corresponding data section, respectively, and the other inner control points are calculated using the least square method. In detail, they are given as Piegl and Tiller20 8 P1 ¼ Qi,1 , Pn ¼ Qi,ti > > > > < 0 P2 1 B .. C T 1 > @ . A¼ N N R > > > : Pn1 ð8Þ Note that for ith section of the simplified data Qi,j (j ¼ 1,2,. . .,ti), the number of control points of the fitted NURBS is n who is adjusted adaptively during the following iterative fitting procedure, and n is always smaller than the ti which is the number of the points of ith section data Qi,j (j ¼ 1, 2,. . ., ti) so as to keep the advantage of NURBS interpolation in reducing NC-file size. The control points {Pi}, i ¼ 1, 2,. . ., n, are calculated using equation (8), in which the matrix N and R are computed as 0 j ¼ 2, . . ., ti 1 1 N2,p ðu 2 Þ Nn1,p ðu 2 Þ B C .. .. .. N¼@ A . . . N2,p u ti 1 Nn1,p u ti 1 ð9Þ ð4Þ Then, to obtain the knot vector of the fitted curve, let the spline order p equals to pmin and the amount of control points n as nmin, thus the amount of the knots m in the knot vector U can be computed as m¼nþpþ1 ð5Þ and 1 N2,p ðu 2 Þr2 þ þ N2,p u ti 1 rti 1 C B .. C R¼B A @ . Nn1,p ðu 2 Þr2 þ þ Nn1,p uti 1 rti 1 0 ð10Þ Ma et al. 5 In equation (10), rj, j ¼ 2,. . ., ti 1 is obtained as rj ¼ Qi,j N1,p u j Qi,1 Nn,p u j Qi,ti , j ¼ 2, . . ., ti 1 ð11Þ By using the above method, the NURBS curve can be fitted at each data section, then, the fitting precision should be judged before generation of the NURBS-toolpath NC file. To deal with this problem, the iterative fitting approach is provided in the following subsection. Iterative fitting of NURBS curve for toolpath generation As the curve fitting method instead of the curve interpolation method in Piegl and Tiller20 is utilized here to keep the smoothness of the obtained NURBS toolpath, the fitting errors must be constrained. To satisfy the precision condition during the curve fitting, the original cutter locations before data simplification {Qci,j} instead of those after data simplification are utilized for the calculation of the fitting errors. In addition to {Qci,j} (j ¼ 1, 2,. . ., ki), the middle points Qcm,i,j (j ¼ 1, 2,. . ., ki 1) between each two adjacent cutter locations Qci,j and Qci,j þ 1 (j ¼ 1, 2,. . ., ki 1) are also utilized to compute the fitting errors, in order that the chord error can be confined within the given tolerance thus obtaining enough small fitting error. For a fitted NURBS curve C(u), the distance from the cutter location Qci,j or the middle point Qcm,i,j to the curve is first computed. To reduce the computational burden, the distance is obtained by the adaptive segmentation. Figure 4(a) shows the schematic of the data points and the fitted curve, while Figure 4(b) Figure 4. Schematic diagram for calculation of distance from desired cutter location to fitted curve. (a) Geometry of distances. (b) Calculation procedure of distance. illustrates the fitting-error rapid computation procedure. As shown in Figure 4(a), although the simplified points Qi,j are utilized for curve fitting, the original cutter locations Qci,j, and the middle points Qcm,i,j of the original cutter locations are used for the fittingerror calculation so as to ensure the fitting precision. As shown in Figure 4(b), first, the fitted curve C(u) is divided into nd portions, and the distance between each equipartition point and the cutter location Qci,j or the middle point Qcm,i,j is calculated. Then, the closest point from the curve to the cutter location or the middle point is recorded, and the curve between the former and latter adjacent points of this closest point on the curve is further divided into nd portions. Similarly, the distance between each equipartition point and the cutter location Qci,j or the middle point Qcm,i,j is calculated again. Repeat above procedure until the difference between the former and latter minimum distances is less than the given precision condition. Thus, the distance from the desired cutter location Qci,j to the fitted curve, denoted as di,j, and the distance from the middle point Qcm,i,j to the fitted curve, denoted as dm,i,j, can be obtained. Given the maximum fitting-error tolerance ec, if equation (12) is satisfied, output the NURBS toolpath; else, add the amount of control points by letting n ¼ n þ 1 and conduct the curve fitting once again. In detail, first let n ¼ n þ 1 and then calculate the knot vector {Ui}, i ¼ 1, 2,. . ., n þ p þ 1, using equation (6), and after that, compute all of the control points {Pi} (i ¼ 1, 2,. . ., n) again using equation (8). di,j 5 ec , j ¼ 1, . . ., ki dm,i,j 5 ec , j ¼ 1, . . ., ki 1 ð12Þ Take the maximum amount of the control points nmax as ti 3 because if the number of control points is too large, the advantage of the NURBS interpolation in reducing the file size will disappear. If equation (12) cannot be satisfied even when n ¼ nmax, add the spline order value by letting p ¼ p þ 1 and fit the curve again. Given the maximum order pmax, if equation (12) also cannot be satisfied when p ¼ pmax, indicating that the appropriate curve fitting can hardly be realized, output the linear interpolation toolpath. By using above iterative fitting method at every cutter-location sections, the integral toolpath can be generated, and the procedure is further summarized in Figure 5 for concise, and the variable parameters illustrated in Figure 5 are summarized in Table 1. After the above iterative fitting, the NURBS toolpath can be generated, although there exists a few linear interpolation toolpaths at areas where the fitting precision cannot be satisfied. By using NURBS toolpath instead of the linear toolpath for machining of the complex curved surface parts, the more smooth motion can be obtained, which is beneficial to the high-speed machining. 6 Proc IMechE Part C: J Mechanical Engineering Science 0(0) Design of user interface for NURBS-toolpath NC-file generation Figure 5. Flow chart of presented toolpath-generation method for high-speed machining. To realize the NC machining with NURBS interpolator, the NURBS-toolpath NC file with a required format of the corresponding CNC system should be generated in advance. Therefore, a user interface for NURBS-toolpath NC-file generation is designed here based on MATLAB/GUI for the convenient utilization. The designed interface is illustrated in Figure 6. In the ‘‘User Defination’’ panel, the angle condition for data segmentation (q), the precision conditions for data simplification (eq) and NURBS fitting (ec), the minimum and maximum order values (pmin and pmax), the minimum amount of control points (nmin), and the feedrate value for machining can be defined by users. By pushing the ‘‘Load CL File’’ button, a pop-up dialog for selection of the cutter-location file will appear and the cutter locations in the selected file will then be plotted in the figure below this button. After that, the iterative NURBS-fitting procedure will be conducted when pressing the ‘‘NURBS Fitting’’ button, and the fitting result along with the original desired cutter locations will be illustrated in the corresponding figure. In addition, the fitting error, i.e. the distances from the desired cutter locations to the fitted curves, will be calculated and shown when pushing the ‘‘Display Fitting Error’’ button, in order that the fitting result can be seen by the users. Finally, the NC file for high-speed machining with the NURBS interpolator can be generated and displayed in the text box when clicking the ‘‘Output NC File’’ button. By utilization of this user interface, it becomes extremely convenient to converse the cutter-location points to the NURBS-toolpath NC file, so that the gap between the complex CAD model and the NURBS interpolator can be filled up. Experimental results Table 1. Summary of the used parameters. Parameter Definition Qr Qc nc Q C(u) d dm ec n nmin nmax p pmin pmax Original cutter location point Cutter location after data segmentation Total amount of segmented sections Cutter location after data simplification Fitted NURBS curve Distance from Qc to C(u) Distance from Qcm to C(u) Maximum fitting-error limitation Number of control points during curve fitting Minimum control points during curve fitting Maximum control points during curve fitting Order of the fitted curve Minimum order of the fitted curve Maximum order of the fitted curve NURBS: nonuniform rational B-spline. To verify the feasibility of the presented methods, experiments are conducted and the results are illustrated in this section. A VGM 210 machine tool with the CNC system of GNC61 by GONA Corporation shown in Figure 7 is utilized here, and the NURBS-interpolation NC-file format of the GNC61 system is provided below. G6.2 P_ (Spline order) K_ (Knot vector) X_ Y_ Z_ (Control points) R_ (Weights) F_ (Feedrate). KXYZRF KXYZRF KXYZRF KXYZRF K1: K1: ... Ma et al. 7 Figure 6. User interface for NURBS-toolpath NC-file generation. Figure 8. Butterfly toolpath used for experiments. Figure 7. Machine tool used for experimental tests. A butterfly-shape curved toolpath shown in Figure 8 is employed for the experiments. The CAM software UG/NX 8.0 is used for generation of the original cutter-location file. Set the angle condition for the data segmentation q as 35 , the precision conditions for data simplification and NURBS fitting as 0.05 mm and 0.06 mm, respectively, and the pmin, pmax, and nmin as 2, 3, and 3, respectively. It should be noticed that the maximum fitting error condition can be set arbitrarily according to the machining tolerance, and if the curve fitting cannot satisfy the set condition, linear interpolation toolpath, instead of NURBS toolpath, will be generated in order to ensure the precision. When the error condition is set relative larger, there will be more NURBS toolpaths than linear toolpaths, which is beneficial to the efficiency, and on the contrary if the error is set as an extremely small value, more linear toolpaths will be generated. By utilizing the cutter-location pre-processing method presented in Pre-processing of cutter location points section and the iterative fitting method presented in Conversion from cutter location points to NURBS-toolpath NC file section, the obtained linear/NURBS toolpath is illustrated in Figure 9, where the fitting result is also compared with the desired cutter locations obtained from the CAM software. In Figure 9, the fitted toolpaths with different colors represent different sections after the data segmentation. As can be seen, a wellfitting effect is got. The real fitting errors between the desired cutter locations and the fitted toolpaths are further calculated and illustrated in Figure 10. It can be seen that in some segments, the fitting error is large, and this is because the curvature variations of these segments are relatively large, but even though, 8 Proc IMechE Part C: J Mechanical Engineering Science 0(0) Figure 9. Comparison of desired cutter locations and fitted toolpaths. Figure 10. Fitting error between desired cutter locations and fitted toolpaths when error tolerance is 0.06 mm. the errors can be effectively confined within the maximum fitting error tolerance set here, i.e., 0.06 mm. In addition, it should be noted that the fitting error tolerance can be set artificially here. When the tolerance is changed to 0.03 mm instead of 0.06 mm, the final fitting errors become those shown in Figure 11, where it indicates that the presented method can also confine the fitting error within the set limitation. The above results are obtained by programing the proposed method with Cþþ on an i7 core Intel CUP computer with 3.4 GHz frequency. The total computation time of the two tests are recorded in the program as about 430 ms, which indicates that the algorithm is computational efficiency and the computation time can be neglected. In order to verify the advantages of the presented method, the existing method proposed in Lin et al.13 that is utilized for NURBS toolpath fitting is also employed here as a comparison. Note that although that existing method contains data segmentation as well, it does not simplify the data points, and all of the cutter locations are utilized for the curve fitting. The computation time of the method in Lin et al.13 is Figure 11. Fitting error between desired cutter locations and fitted toolpaths when error tolerance is 0.03 mm. Figure 12. Fitting result of conventional method. about 480 ms, and the fitting result is shown in Figure 12. It is seen that the computational time is longer than the proposed method, and this is because the conventional method utilizes all of the cutter locations to fit curves, while the proposed method Ma et al. 9 Table 2. Comparison results of the linear-toolpath and linear/NURBS-toolpath NC files. NC file Total number of rows File size Pure linear toolpaths Linear/NURBS hybrid toolpaths G55 G90 N0090 G01 X0.0 Y0.0 F800 N0100 X.11 Y-.103 N0110 X.18 Y-.231 N0120 X.217 Y-.377 N0130 X.246 Y-.524 N0140 X.304 Y-.815 N0150 X.348 Y-.958 N0160 X.43 Y-1.081 N0170 X.564 Y-1.146 N0180 X.713 Y-1.15 ... N2850 X-.216 Y-.377 N2860 X-.176 Y-.232 N2870 X-.112 Y-.093 N2880 X0.0 Y0.0 N2890 M02 282 6.04 kB G55 G90 F800 G6.2 P3 K0 X0 Y0 K0 X0.313 Y-0.413 K0 X0.348 Y-0.958 K1 K1 K1 G1 X0.564 Y-1.146 G6.2 P3 K0 X0.564 Y-1.146 K0 X0.646 Y-1.165 K0 X1.044 Y-1.084 K0.00947 X1.633 Y-0.781 ... K1 K1 K1 M02 172 3.07 kB NURBS: nonuniform rational B-spline. Figure 13. Comparison of machining times of pure linear toolpath and linear/NURBS toolpath for butterfly toolpath. (a) Linear toolpath. (b) Linear/NURBS hybrid toolpath. merely uses the key points after data simplification. Additionally, it can be seen from Figure 12 that the fitting errors in zone I and zone II are extremely large, and the reasons are analyzed below. At zone I, the conventional method employing all the cutter-location points to fit a curve, while the proposed method utilizes simplified points merely. As the curvature variation is relatively large at zone I, the intensive data can hardly result in a well fitting result. On the contrary, a better effect can be got when using the key points to fit a curve. Additionally at zone II, both of the conventional and the proposed methods cannot realize a well fitting, however, the conventional method output the fitted curve as the toolpath, while the proposed method output the original linear toolpath to keep a well machining precision. That is to say, the proposed method generates linear and NURBS hybrid toolpath, so as to improve the machining efficiency under the premise of machining precision being ensured. To evaluate the machining efficiency of the presented method, the real application is conducted. The generated hybrid toolpath NC file using the proposed method is compared with the NC file with the pure linear interpolation toolpaths in Table 2. As can be seen, the file size of the NC code is reduced from the original 6.04 kB to the regenerated 3.07 kB when 10 using the NURBS toolpaths instead of the linear toolpaths, and this is beneficial to the file transition and storage. By using the generated linear/NURBS-toolpath NC file and the traditional linear interpolation toolpath for machining, the machining times are recorded by the GNC61 system, and they are shown in Figure 13. When machining with pure lineartoolpath NC file, the machining time is about 10.0 s, Figure 14. Star toolpath used for experiments. Proc IMechE Part C: J Mechanical Engineering Science 0(0) while the time becomes 8.0 s when using the linear/NURBS-toolpath NC file. Thus, the machining time is reduced by 20%, and this is because the firstorder discontinuous points are dramatically reduced when using the NURBS toolpath instead of the shortline segment toolpath, so that the rapid deceleration/ acceleration processes are decreased. Therefore, it is more appropriate for the NURBS toolpath than the traditional linear toolpath to realize the high-speed machining. Another case with large-scale star toolpath shown in Figure 14 is then conducted to further verify the feasibility of the presented method. Also, the conventional method in Lin et al.13 is taken as a comparison. The maximum fitting error limitation is set as an extremely small value of 0.005 mm, and other constraints are same as those in the first case. The fitting result of the two methods are compared in Figure 15, and the fitting errors are compared in Figure 16. It can be seen that in zone I, the proposed method generates linear toolpath because the maximum fitting error is larger than the set limitation in this zone, while the conventional method generates curved toolpath, and cannot ensure a predefined error constraint. Furthermore, the computation time of the proposed algorithm is about 85 ms, and that of the conventional Figure 15. Comparison of fitting results of different method. (a) Proposed method. (b) Conventional method. Ma et al. 11 Figure 16. Comparison of fitting errors of different method. (a) Proposed method. (b) Conventional method. Figure 17. Comparison of machining times of pure linear toolpath and linear/NURBS toolpath for star toolpath. (a) Linear toolpath. (b) Linear/NURBS hybrid toolpath. method is about 94 ms, which is similar to the results of the first case. In addition, the hybrid NC file generated by the proposed method consists 143 lines with a file size of 3.05 kB, while the original linear toolpath NC file consists 668 lines with a file size of 11.6 kB. As for the machining time, the linear toolpath takes about 29 s, while machining with the proposed hybrid toolpath, the machining time is reduced to 22 s, as shown in Figure 17. Again, the advantages of the proposed method are demonstrated. Conclusion In order to realize high-speed and high-quality machining, the parametric curve interpolation methods are widely researched and developed to generate the smooth curved toolpath for the complex curved surface parts, and the NURBS interpolator possesses superiorities over conventional linear or circular interpolators. In this study, a conversion method from cutter-location points to NURBS-toolpath NC file is presented in order to fill in the gap between the CAD model of complex parts and the parametric curve interpolator provided by the modern CNC systems, thus realizing the high-speed and high-quality machining of parts with complex curved surfaces. To ensure a well curve-fitting effect and reduce the computational burden, the cutter-location pre-processing consisted by data segmentation and data simplification is provided. The least-square method for NURBS curve fitting is used and an iterative fitting approach is presented for the generation of the NURBS toolpath. A user interface for the convenient NURBS-toolpath NC-file outputting is designed, where the fitting results and the fitting errors can be seen directly. Experimental results demonstrate the feasibility of the presented conversion method. Additionally, the superiority of NURBS toolpath in realization of high-speed machining compared with the traditional 12 Proc IMechE Part C: J Mechanical Engineering Science 0(0) continuous short-line toolpath is also verified. This research achievements are of vital importance for realizing the high-quality and high-efficient machining for the complex curved surface parts. Acknowledgements The authors wish to thank the anonymous reviewers for their comments which led to improvements of this paper. Declaration of Conflicting Interests The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article. Funding The author(s) disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: This work was supported by National Natural Science Foundation of China (Grant No. 51575087 and Grant No. 51675081), National Science and Technology Major Project of China (No. 2016ZX04001002), Innovation Project for Supporting High-level Talent in Dalian (No. 2016RQ012), Science Fund for Creative Research Groups (No. 51621064), and the Fundamental Research Funds for the Central Universities (No. DUT17LAB13). ORCID iD Jian-wei Ma http://orcid.org/0000-0002-2177-529X References 1. Khalick MAE and Uchiyama N. Discrete-time model predictive contouring control for biaxial feed drive systems and experimental verification. Mechatron 2011; 21: 918–926. 2. Heng M and Erkorkmaz K. Design of a NURBS interpolator with minimal feed fluctuation and continuous feed modulation capability. Int J Mach Tools Manuf 2010; 50: 281–293. 3. Sencer B, Ishizaki K and Shamoto E. A curvature optimal sharp corner smoothing algorithm for high-speed feed motion generation of NC systems along linear tool paths. Int J Adv Manuf Technol 2015; 76: 1977–1992. 4. Dong JC, Wang TY, Li B, et al. Smooth feedrate planning for continuous short line tool path with contour error constraint. Int J Mach Tools Manuf 2014; 76: 1–12. 5. Liu M, Huang Y, Yin L, et al. Development and implementation of a NURBS interpolator with smooth feedrate scheduling for CNC machine tools. Int J Mach Tools Manuf 2014; 87: 1–15. 6. Annoni M, Bardine A, Campanelli S, et al. A real-time configurable NURBS interpolator with bounded acceleration, jerk and chord error. Comput-Aided Desi 2012; 44: 509–521. 7. Lai YL. Tool-path generation of planar NURBS curves. Robot Comput-Integr Manuf 2010; 26: 471–482. 8. Feng J, Li Y, Wang Y, et al. Design of a real-time adaptive NURBS interpolator with axis acceleration limit. Int J Adv Manuf Technol 2010; 48: 227–241. 9. Lin MT, Tsai MS and Yau HT. Development of a dynamics-based NURBS interpolator with real-time look-ahead algorithm. Int J Mach Tools Manuf 2007; 47: 2246–2262. 10. Ma W and Kruth JP. NURBS curve and surface fitting for reverse engineering. Int J Adv Manuf Technol 1998; 14: 918–927. 11. Yu CG. NURBS curve fitting based on arc centripetal parameterization for tool path generation. Appl Mech Mater 2013; 274: 121–123. 12. Yang Z, Shen LY, Yuan CM, et al. Curve fitting and optimal interpolation for CNC machining under confined error using quadratic B-splines. Comput-Aided Des 2015; 66: 62–72. 13. Lin KY, Ueng WD and Lai JY. CNC codes conversion from linear and circular paths to NURBS curves. Int J Adv Manuf Technol 2008; 39: 760–773. 14. Wu J, Zhou H, Tang X, et al. Implementation of CL points preprocessing methodology with NURBS curve fitting technique for high-speed machining. Comput Ind Eng 2015; 81: 58–64. 15. Lin HW. Adaptive data fitting by the progressive-iterative approximation. Comput Aided Geom Des 2012; 29: 463–473. 16. Deng C and Lin H. Progressive and iterative approximation for least squares B-spline curve and surface fitting. Comput-Aided Des 2014; 47: 32–44. 17. Garcia-Capulin CH, Cuevas FJ, Trejo-Caballero G, et al. A hierarchical genetic algorithm approach for curve fitting with B-splines. Genet Program Evolvable Mach 2015; 16: 151–166. 18. Liang F, Zhao J, Ji S, et al. A novel knot selection method for the error-bounded B-spline curve fitting of sampling points in the measuring process. Meas Sci Technol 2017; 28: 065015. 19. Dung VT and Tjahjowidodo T. A direct method to solve optimal knots of B-spline curves: an application for non-uniform B-spline curves fitting. Plos One 2017; 12: e0173857. 20. Piegl L and Tiller W. The NURBS Book. 2nd ed. Berlin, Heidelberg: Springer, 1997.