End-to-End Tool Path Generation for Triangular Mesh Surfaces in Five-Axis CNC Machining
Abstract
1. Introduction
2. Related Work
3. Methodology
3.1. Optimal Setup Direction Selection
| Algorithm 1 Optimal Setup Direction Selection |
| Require: Mesh Faces F, Weights , Cluster Count k |
| Ensure: Optimal Setup Direction , Setup Base Region |
|
3.2. Shallow–Steep Division
3.3. Collision Detection on Triangular Mesh
- 1.
- Vertex Inclusion Test: If any vertex of P satisfies the quadric inequality, a collision is detected:
- 2.
- Edge Intersection Test: The intersection between the boundary edges of P and the quadric surface is determined by solving the quadratic equation along each edge segment . Real roots within indicate a collision.
- 3.
- Axis Intersection Test (for Cylinder/Frustum): The intersection curve may be entirely contained within the interior of P without crossing any edges. For quadrics of revolution, this topological case is detected by checking if the intersection point of the tool axis L and plane lies within P:Note that for open curves (hyperbolas/parabolas), the Jordan Curve Theorem guarantees that if the interior intersection is non-empty, the curve must cross the polygon boundary (detected by Step 2). Thus, this step is specific to closed curves (ellipses).
- 4.
- Center Projection Test (for Sphere): For a spherical tool component with center and radius R, the intersection region on is a disk. A collision occurs if the orthogonal projection of onto falls within P and the distance condition is met:
- Data Mapping and Memory Layout: We utilize a Structure of Arrays (SoA) layout for the Tool Buffer and a linearized array for the BVH Buffer. The compute shader dispatch aligns the global invocation ID with the tool buffer index, enabling a one-to-one mapping where each GPU thread processes a unique tool pose independently.
- Stack-based BVH Traversal: To adapt to the GPU’s non-recursive execution model, we implement a stackless traversal algorithm. Each thread maintains a local array (size 64) acting as a software stack. The traversal loop performs broad-phase culling by testing the intersection between the tool’s bounding capsule and the BVH node’s AABB.
- Exact Geometry Test: Upon reaching a leaf node, we perform rigorous narrow-phase detection. As shown in the right panel of Figure 5b, the algorithm employs a “slicing” strategy. The target triangle is clipped by horizontal planes defined by the tool’s geometric junctions (cylinder-cone and cone-sphere interfaces). The resulting polygons are then tested against the corresponding analytic surfaces (cylinder, cone, and sphere) to ensure mathematical exactness.
| Algorithm 2 GPU-Based Parallel Exact Collision Detection |
| Require: Triangle T, Tool Definition (Cylinder, Cone, Ball parameters) |
| Ensure: Collision Status |
|
3.4. Path Segment Generation Based on Iso-Planar Method
3.4.1. Accessibility Analysis
3.4.2. Forward and Backward Traversal Algorithm
| Algorithm 3 Heuristic Forward and Backward Traversal |
| Require: Contour Atomic Segments |
| Ensure: Connected Path Segments |
|
3.5. Optimal Machining Direction Selection for Shallow Regions
3.6. Path Segment Connection Based on TSP
3.6.1. Path Segment Endpoint Distance Calculation
- The straight-line distance from the starting point A to its projection along the tool axis.
- The shortest distance along the geodesic (great circle arc) of the sphere from to .
- The straight-line distance from to the endpoint B along the tool axis.
3.6.2. Minimizing Transfer Path Length
- Topology Transformation: To map the open-path problem to a closed-loop model, we introduce a dummy node O to construct an extended graph by connecting O to all original nodes with zero-weight edges. The optimal open path in G is thereby equivalent to the optimal Hamiltonian cycle in .
- Weight Adjustment: To ensure the traversal of fixed machining segments (required edges), we employ a penalty-based weight adjustment. Let M be the maximum edge weight. By assigning a weight (where m is the node count and n is the required edge count) to all required edges, we mathematically guarantee that any optimal cycle must include all required edges [6]. A positive offset is subsequently added to ensure non-negative weights for the solver.
3.7. Adaptive Path Refinement
4. Experimental Results and Analysis
4.1. Parameter Settings
4.2. GPU Acceleration Performance Analysis
4.3. Tool Path Result Analysis
4.4. Scallop Height Analysis
4.5. Comparison with Commercial Software UG
4.6. Comparison with Iso-Scallop Method
4.7. Physical Machining Verification
5. Conclusions
Author Contributions
Funding
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- Ma, H.Y.; Shen, L.Y.; Jiang, X.; Zou, Q.; Yuan, C.M. A survey of path planning and feedrate interpolation in computer numerical control. J. Graph. 2022, 43, 967–986. [Google Scholar]
- Liang, F.; Kang, C.; Fang, F. A review on tool orientation planning in multi-axis machining. Int. J. Prod. Res. 2021, 59, 5690–5720. [Google Scholar] [CrossRef] [Scilit]
- Zhao, H.; Zhang, H.; Xin, S.; Deng, Y.; Tu, C.; Wang, W.; Cohen-Or, D.; Chen, B. Dscarver: Decompose and spiral carve for subtractive manufacturing. ACM Trans. Graph. 2018, 37, 137. [Google Scholar] [CrossRef] [Scilit]
- Ma, H.Y.; Shen, L.Y.; Yuan, C.M.; Feng, Y. A theoretically complete surface segmentation method for CNC subtractive fabrication. CSIAM Trans. Appl. Math. 2023, 4, 325–344. [Google Scholar] [CrossRef] [Scilit]
- Nuvoli, S.; Tola, A.; Muntoni, A.; Pietroni, N.; Gobbetti, E.; Scateni, R. Automatic surface segmentation for seamless fabrication using 4-axis milling machines. Comput. Graph. Forum 2021, 40, 191–203. [Google Scholar] [CrossRef] [Scilit]
- Zhang, Z.; Shi, Z.; Zhong, F.; Zhang, K.; Zhang, W.; Guo, J.; Tu, C.; Zhao, H. Continuous Toolpath Optimization for Simultaneous Four-Axis Subtractive Manufacturing. Comput. Graph. Forum 2025, 44, e15204. [Google Scholar] [CrossRef] [Scilit]
- Snapmaker. Luban v4.9.1. Available online: https://snapmaker.cn/snapmaker-luban (accessed on 13 April 2025).
- Gan, W.F.; Fu, J.Z.; Shen, H.Y.; Chen, Z.Y.; Lin, Z.W. Five-axis tool path generation in CNC machining of T-spline surfaces. Comput.-Aided Des. 2014, 52, 51–63. [Google Scholar] [CrossRef] [Scilit]
- Elber, G.; Cohen, E. Tool path generation for freeform surface models. In Proceedings of the Second ACM Symposium on Solid Modeling and Applications, Montreal, QC, Canada, 19–21 May 1993; pp. 419–428. [Google Scholar]
- Hu, P.; Chen, L.; Tang, K. Efficiency-optimal iso-planar tool path generation for five-axis finishing machining of free-form surfaces. Comput.-Aided Des. 2017, 83, 33–50. [Google Scholar] [CrossRef] [Scilit]
- Au, C. A path interval generation algorithm in sculptured object machining. Int. J. Adv. Manuf. Technol. 2001, 17, 558–561. [Google Scholar] [CrossRef] [Scilit]
- Ma, H.Y.; Yuan, C.M.; Shen, L.Y. Tool path planning with confined scallop height error using optimal Connected Fermat Spirals. Commun. Math. Stat. 2022, 12, 55–78. [Google Scholar] [CrossRef] [Scilit]
- Cheng, M. A new iso-scallop height tool path planning method in three-dimensional space. CADDM 2012, 22, 35–42. [Google Scholar]
- Giri, V.; Bezbaruah, D.; Bubna, P.; Choudhury, A.R. Selection of master cutter paths in sculptured surface machining by employing curvature principle. Int. J. Mach. Tools Manuf. 2005, 45, 1202–1209. [Google Scholar] [CrossRef] [Scilit]
- Fanni, F.A.; Cherchi, G.; Muntoni, A.; Tola, A.; Scateni, R. Fabrication oriented shape decomposition using polycube mapping. Comput. Graph. 2018, 77, 183–193. [Google Scholar] [CrossRef] [Scilit]
- Muntoni, A.; Livesu, M.; Scateni, R.; Panozzo, D.; Sheffer, A. Axis-Aligned height-field block decomposition of 3D shapes. ACM Trans. Graph. 2018, 37, 169. [Google Scholar] [CrossRef] [Scilit]
- Yang, J.; Araújo, C.; Vining, N.; Ferguson, Z.; Alla, S. DHFSlicer: Double height-field slicing for milling fixed-height materials. ACM Trans. Graph. 2015, 39, 205. [Google Scholar] [CrossRef] [Scilit]
- Herholz, P.; Matusik, W.; Alexa, M. Approximating free-form geometry with height fields for manufacturing. Comput. Graph. Forum 2015, 23, 239–251. [Google Scholar] [CrossRef] [Scilit]
- Autodesk. Fusion 360. Available online: https://www.autodesk.com.cn/products/fusion-360/overview (accessed on 18 April 2025).
- SIEMENS. NX Software. Available online: https://plm.sw.siemens.com/en-US/nx/ (accessed on 18 April 2025).
- Shen, L.Y.; Wang, M.X.; Ma, H.Y.; Feng, Y.F.; Yuan, C.M. A framework from point clouds to workpieces. Vis. Comput. Ind. Biomed. Art 2022, 5, 21. [Google Scholar] [CrossRef] [Scilit]
- Takeuchi, Y.; Watanabe, T. Generation of 5-axis control collision-free tool path and postprocessing for NC data. CIRP Ann. 1992, 41, 539–542. [Google Scholar] [CrossRef] [Scilit]
- Du, J.; Yan, X.G.; Tian, X.T. The avoidance of cutter gouging in five-axis machining with a fillet-end milling cutter. Int. J. Adv. Manuf. Technol. 2012, 62, 89–97. [Google Scholar] [CrossRef] [Scilit]
- Ding, S.; Mannan, M.; Poo, A. Oriented bounding box and octree based global interference detection in 5-axis machining of free-form surfaces. Comput.-Aided Des. 2004, 36, 1281–1294. [Google Scholar] [CrossRef] [Scilit]
- Tang, T.; Bohez, E.L.; Koomsap, P. The sweep plane algorithm for global collision detection with workpiece geometry update for five-axis NC machining. Comput.-Aided Des. 2007, 39, 1012–1024. [Google Scholar] [CrossRef] [Scilit]
- Schneider, P.J.; Eberly, D. Geometric Tools for Computer Graphics; Elsevier Science Inc.: Amsterdam, The Netherlands, 2002. [Google Scholar]
- Bi, Q.Z.; Wang, Y.H.; Ding, H. A GPU-based algorithm for generating collision-free and orientation-smooth five-axis finishing tool paths of a ball-end cutter. Int. J. Prod. Res. 2010, 48, 1105–1124. [Google Scholar] [CrossRef] [Scilit]
- Khronos Group. Home|Vulkan|Cross 3D Graphics Platform. Available online: https://www.vulkan.org (accessed on 18 April 2025).
- Zou, Q. Robust and efficient tool path generation for machining low-quality triangular mesh surfaces. Int. J. Prod. Res. 2021, 59, 7457–7467. [Google Scholar] [CrossRef] [Scilit]
- Zou, Q. Length-optimal tool path planning for freeform surfaces with preferred feed directions based on Poisson formulation. Comput.-Aided Des. 2021, 139, 103072. [Google Scholar] [CrossRef] [Scilit]
- Wu, Q.; Yuan, C.; Shen, L.; He, S.; Gao, X. Cubic time-spline fitting and interpolation for five-axis CNC machining. J. Comput. Des. Eng. 2023, 10, 2345–2360. [Google Scholar] [CrossRef] [Scilit]




















| Model Name | Size (cm) | Number of Faces |
|---|---|---|
| Bunny | 59,694 | |
| Beetle | 7558 | |
| Kitten | 6356 | |
| Bone | 9328 | |
| Twirl | 10,398 | |
| Hand | 7406 |
| Model | CPU Time (ms) | GPU Time (ms) | ×Speedup |
|---|---|---|---|
| Bunny | 12,802.70 | 130.47 | 98.13 |
| Beetle | 2539.74 | 18.06 | 140.63 |
| Kitten | 4136.00 | 19.76 | 209.31 |
| Bone | 5309.78 | 43.45 | 122.20 |
| Twirl | 8239.82 | 38.16 | 215.93 |
| Hand | 3311.19 | 30.45 | 108.74 |
| Method | Model | Maximum | Average | RMS | Unprocessed | Path |
|---|---|---|---|---|---|---|
| Name | S.-H. (mm) | S.-H. (mm) | S.-H. (mm) | Ratio (%) | Length (mm) | |
| Proposed Method | Bunny | 0.58 | 0.05 | 0.07 | 0.00% | 16.55 |
| Beetle | 0.53 | 0.03 | 0.05 | 0.00% | 5.59 | |
| Kitten | 0.48 | 0.04 | 0.06 | 0.00% | 11.92 | |
| Bone | 2.00 | 0.05 | 0.05 | 0.06% | 4.60 | |
| Twirl | 0.53 | 0.02 | 0.03 | 0.00% | 12.06 | |
| Hand | 0.58 | 0.03 | 0.04 | 0.00% | 8.27 | |
| Four-axis Method [5] | Bunny | 2.00 | 0.25 | 0.51 | 5.53% | 8.06 |
| Beetle | 2.00 | 0.34 | 0.72 | 12.16% | 2.87 | |
| Kitten | 2.00 | 0.18 | 0.41 | 3.49% | 7.09 | |
| Bone | 2.00 | 0.18 | 0.40 | 3.43% | 2.65 | |
| Twirl | 2.00 | 0.44 | 0.80 | 14.75% | 2.42 | |
| Hand | 2.00 | 0.13 | 0.27 | 1.24% | 4.27 | |
| Refinement of Method [5] | Bunny | 2.00 | 0.06 | 0.20 | 0.88% | 19.78 |
| Beetle | 2.00 | 0.12 | 0.44 | 4.72% | 7.30 | |
| Kitten | 2.00 | 0.05 | 0.11 | 0.17% | 13.81 | |
| Bone | 2.00 | 0.07 | 0.17 | 0.53% | 5.03 | |
| Twirl | 2.00 | 0.05 | 0.21 | 1.03% | 8.08 | |
| Hand | 2.00 | 0.05 | 0.09 | 0.06% | 6.28 |
| Model | UG | Proposed Method | ||||
|---|---|---|---|---|---|---|
| Retraction |
Path Length
( ) | Time | Retraction |
Path Length
( ) | Time | |
| Bunny | 127 | 20.35 | ≈1.3 h | 42 | 16.55 | 21.43 min |
| Kitten | 56 | 7.20 | ≈0.5 h | 2 | 11.92 | 1.68 min |
| Hand | 263 | 14.74 | ≈1.8 h | 0 | 8.27 | 5.63 min |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.
Share and Cite
Li, S.-C.; Ma, H.-Y.; Zhang, B.-W.; Shen, L.-Y. End-to-End Tool Path Generation for Triangular Mesh Surfaces in Five-Axis CNC Machining. AppliedMath 2026, 6, 35. https://doi.org/10.3390/appliedmath6030035
Li S-C, Ma H-Y, Zhang B-W, Shen L-Y. End-to-End Tool Path Generation for Triangular Mesh Surfaces in Five-Axis CNC Machining. AppliedMath. 2026; 6(3):35. https://doi.org/10.3390/appliedmath6030035
Chicago/Turabian StyleLi, Shi-Chu, Hong-Yu Ma, Bo-Wen Zhang, and Li-Yong Shen. 2026. "End-to-End Tool Path Generation for Triangular Mesh Surfaces in Five-Axis CNC Machining" AppliedMath 6, no. 3: 35. https://doi.org/10.3390/appliedmath6030035
APA StyleLi, S.-C., Ma, H.-Y., Zhang, B.-W., & Shen, L.-Y. (2026). End-to-End Tool Path Generation for Triangular Mesh Surfaces in Five-Axis CNC Machining. AppliedMath, 6(3), 35. https://doi.org/10.3390/appliedmath6030035

