Thin-wall part tool path processing method and system
By combining spatial indexing structure and Möller-Trumbore algorithm, the problem of low toolpath compensation efficiency in CNC machining of large thin-walled parts is solved, achieving efficient error compensation and toolpath optimization, and improving machining accuracy and surface quality.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-30
- Publication Date
- 2026-04-07
AI Technical Summary
In the CNC machining of large thin-walled parts, existing technologies have low computational efficiency for traditional toolpath compensation methods, making it difficult to process large-scale triangular mesh data. Furthermore, they neglect the synergistic optimization of toolpath spatial geometric continuity and tool axis posture, resulting in difficulty in guaranteeing machining accuracy and surface quality.
A spatial indexing structure combined with the Möller-Trumbore algorithm is used for efficient intersection detection. The tool offset is calculated by the intersection distance, and an adaptive machining program is generated through iterative optimization to ensure the geometric continuity of the toolpath and the smoothness of the tool axis posture.
It improves the machining accuracy and surface quality of thin-walled parts, achieves efficient error compensation and toolpath optimization, and enhances machining efficiency and precision.
Smart Images

Figure CN121806703A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of thin-walled parts processing technology, and in particular to a method and system for processing toolpaths for thin-walled parts. Background Technology
[0002] Large, thin-walled parts are widely used in the aerospace field. During CNC machining, elastic deformation occurs due to factors such as clamping force, cutting force, and thermal deformation, resulting in significant deviations between the actual machined surface and the theoretical model. Existing preset toolpaths based on theoretical models cannot adapt to the actual deformation state of the parts, making it difficult to guarantee machining accuracy in subsequent finishing stages.
[0003] Traditional toolpath compensation methods often rely on point cloud nearest neighbor search or surface fitting techniques, which are computationally inefficient and difficult to handle large-scale triangular mesh data. Furthermore, existing smoothing algorithms only consider a single smoothness metric, neglecting the synergistic optimization of toolpath spatial geometric continuity and tool axis attitude, leading to problems such as abrupt angle changes or excessive curvature in the generated toolpath. Summary of the Invention
[0004] The main objective of this invention is to provide a method and system for processing toolpaths for thin-walled parts. This invention effectively compensates for deformation errors during the machining process of thin-walled parts, and improves the machining accuracy and surface quality of large thin-walled curved parts.
[0005] To achieve the above objectives, the present invention provides a method for processing toolpaths in thin-walled parts, comprising the following steps: Read the triangular mesh file, construct the offset triangle set, and establish a spatial index structure; The theoretical machining program is read to extract the tool position to be compensated and the tool movement direction. A spatial ray is constructed along the tool movement direction with the tool position to be compensated as the starting point. Based on the spatial index structure, the intersection detection between the spatial ray and the offset triangle set is performed and the intersection distance is calculated. Calculate the tool position offset based on the intersection distance, and translate the tool position point to be compensated along the tool movement direction by the tool position offset to obtain the error compensation toolpath; The desired smoothing point in the error compensation toolpath is determined, and the desired smoothing point is iteratively optimized to generate an adaptive machining program.
[0006] Optionally, in a first implementation of the first aspect of the present invention, the step of reading the triangular mesh file, constructing the offset triangle set, and establishing a spatial index structure includes: Obtain a triangular mesh file in STL format; Extract the coordinates of the three vertices and the face normal vector of each triangle from the triangular mesh file to construct a triangle set; For each triangle in the triangle set, calculate the cross product of the two sides to obtain the unit surface normal vector. Offset the three vertices of each triangle along the unit surface normal vector by the radius of the tool ball to obtain the offset three vertices. Construct an offset triangle set based on the offset three vertices. The offset triangular set is hierarchically organized according to its spatial location using an octree or KD tree to obtain a spatial index structure.
[0007] Optionally, in a second implementation of the first aspect of the present invention, the step of reading the theoretical machining program to extract the tool position to be compensated and the tool movement direction, constructing a spatial ray along the tool movement direction with the tool position to be compensated as the starting point, and performing intersection detection and calculating the intersection distance between the spatial ray and the offset triangle set based on the spatial index structure includes: The theoretical machining program is analyzed, the three-dimensional coordinates of each tool position to be compensated and the corresponding tool movement direction are extracted, and the unit direction vector is calculated based on the tool movement direction; A spatial ray is constructed with the point to be compensated as the starting point and the unit direction vector as the direction. The spatial sub-regions traversed by the spatial ray are located through the spatial index structure, and candidate offset triangles within the corresponding spatial sub-regions are selected. The Möller-Trumbore algorithm is used to solve for the ray parameters and centroid coordinates of the candidate offset triangles. Based on the ray parameters and centroid coordinates, it is determined whether the intersection condition is met, and the ray parameters that meet the intersection condition are taken as the intersection distance.
[0008] Optionally, in a third implementation of the first aspect of the present invention, the step of using the Möller-Trumbore algorithm to solve for the ray parameters and centroid coordinates of the candidate offset triangle, and determining whether the intersection condition is satisfied based on the ray parameters and the centroid coordinates, and using the ray parameters that satisfy the intersection condition as the intersection distance, includes: A system of linear equations is established for the parametric equations of the candidate offset triangle and the spatial ray. The Möller-Trumbore algorithm is used to solve the system of linear equations to obtain the ray parameters and the centroid coordinates of the triangle. When the ray parameter is greater than zero and both components of the centroid coordinates of the triangle are non-negative and their sum is not greater than one, and the intersection condition is met, the ray parameter is recorded as the intersection distance of the tool point to be compensated. Multiple tool points to be compensated are assigned to multiple computing threads. Each computing thread independently performs spatial ray construction and intersection detection, and then the intersection distance of each tool point to be compensated is summarized.
[0009] Optionally, in a fourth implementation of the first aspect of the present invention, the step of calculating the tool position offset based on the intersection distance and translating the tool position point to be compensated along the tool movement direction by the tool position offset to obtain the error compensation toolpath includes: The spatial deviation between each tool position to be compensated and the offset triangle set is extracted from the intersection distance as the tool position offset. Determine whether the tool positions to be compensated intersect. For the tool positions to be compensated that intersect, translate the tool position offset along the tool movement direction to obtain the compensated tool positions. For the tool positions to be compensated that do not intersect, keep the original position unchanged. Arrange all compensated tool positions according to the machining sequence in the theoretical machining program to obtain the error-compensated toolpath.
[0010] Optionally, in a fifth implementation of the first aspect of the present invention, determining the point to be smoothed in the error compensation toolpath and iteratively optimizing the point to be smoothed to generate an adaptive machining program includes: For adjacent compensated tool points in the error compensation toolpath, calculate the toolpath segment direction vector, and calculate the inverse cosine by the ratio of the dot product of the direction vectors of the two consecutive toolpath segments to the modulus, and obtain the toolpath segment angle. The area of the triangle is calculated by the cross product of the two side vectors for three adjacent compensated tool points, and the spatial curvature of the three points is obtained by combining the lengths of the three sides. The compensated tool path points with an included angle less than an angle threshold or a three-point spatial curvature greater than a curvature threshold are marked as tool path points to be smoothed. A front auxiliary point and a rear auxiliary point are generated along the front and rear tool path segments to replace the point to be smoothed by the front auxiliary point, the point to be smoothed by the front auxiliary point, and the rear auxiliary point to replace the point to be smoothed by the rear auxiliary point, thus obtaining the first smoothed tool path. The included angle curvature detection and three-point smooth segment replacement processing are repeatedly performed on the first smooth toolpath. The iteration is terminated when the toolpath change is less than the convergence threshold to obtain the second smooth toolpath. An adaptive machining program is then generated based on the second smooth toolpath.
[0011] Optionally, in a sixth implementation of the first aspect of the present invention, the step of generating a front auxiliary point and a rear auxiliary point of the point to be smoothed along the direction of the front and rear toolpath segments, and replacing the point to be smoothed with a three-point smooth segment composed of the front auxiliary point, the point to be smoothed, and the rear auxiliary point to obtain the first smoothed toolpath, includes: Generate the front auxiliary point and the rear auxiliary point of the point to be smoothed along the direction of the front and rear cutter sections; The front auxiliary point, the point to be smoothed by the tool, and the rear auxiliary point are arranged in sequence to form a three-point smoothing segment. The point to be smoothed by the tool is replaced by the three-point smoothing segment. After all the points to be smoothed by the tool are processed, the first smoothing tool path is obtained.
[0012] Optionally, in a seventh implementation of the first aspect of the present invention, the step of repeatedly performing included angle curvature detection and three-point smoothing segment replacement processing on the first smooth toolpath, terminating the iteration when the toolpath change is less than a convergence threshold, obtaining a second smooth toolpath, and generating an adaptive machining program based on the second smooth toolpath, includes: The first smooth toolpath is used as input to repeatedly perform the calculation of the toolpath segment angle and three-point spatial curvature, as well as the three-point smooth segment replacement process, to calculate the toolpath change. Determine whether the change in the toolpath is less than the convergence threshold. If the convergence condition is met, terminate the iteration to obtain the second smooth toolpath. If the condition is not met, continue iterating until the maximum number of iterations is reached and then output the second smooth toolpath. The second smooth toolpath is interpolated and refined to obtain a dense tool position sequence, and the dense tool position sequence and tool axis direction vector are converted into an adaptive machining program.
[0013] Optionally, in an eighth implementation of the first aspect of the present invention, the step of repeatedly performing the calculation of the toolpath segment angle and three-point spatial curvature, and the three-point smoothing segment replacement processing, using the first smooth toolpath as input, to calculate the toolpath change includes: Using the first smooth toolpath as the current iteration input toolpath, the toolpath segment angle and three-point spatial curvature of adjacent tool points in the current iteration input toolpath are recalculated, and new tool points to be smoothed that meet the smoothing conditions are marked. The new toolpath to be smoothed is then subjected to a smoothing ratio coefficient translation to generate a three-point smoothing segment replacement and a weighted average normalization of the tool axis direction vector to obtain the next iteration of the smoothing toolpath. Calculate the position difference between the tool point corresponding to the next iteration of the smooth toolpath and the current iteration of the input toolpath. Sum the position differences of all tool points and divide by the total number of tool points to obtain the toolpath change.
[0014] The present invention also provides a toolpath processing system for thin-walled parts, comprising: The read module is used to read triangular mesh files, construct offset triangular sets, and establish a spatial index structure; The intersection detection module is used to read the theoretical machining program to extract the tool position to be compensated and the tool movement direction, construct a spatial ray along the tool movement direction with the tool position to be compensated as the starting point, and perform intersection detection on the spatial ray and the offset triangle set based on the spatial index structure and calculate the intersection distance. The error compensation module is used to calculate the tool position offset based on the intersection distance, and to translate the tool position point to be compensated along the tool movement direction by the tool position offset to obtain the error compensation toolpath; The iterative optimization module is used to determine the point where the tool needs to be smoothed in the error compensation toolpath, and to iteratively optimize the point where the tool needs to be smoothed to generate an adaptive machining program.
[0015] In summary, this invention employs a spatial indexing structure combined with the Möller-Trumbore algorithm for efficient intersection detection of spatial rays and offset triangular sets. Compared to traditional point cloud nearest neighbor search or surface fitting methods, this improves the computational efficiency of tool position compensation and accelerates the solution process for large-scale tool positions through parallel computing mechanisms. By using a dual detection criterion of toolpath segment angle and three-point spatial curvature, the geometric continuity of the toolpath is evaluated, accurately identifying abrupt changes requiring smoothing. A smoothing scaling factor is used to generate front and rear auxiliary points to form a three-point smooth segment for local replacement, minimizing deviation from the original toolpath while ensuring smoothing. Simultaneously, a weighted average normalization process is applied to the tool axis direction vector to ensure a smooth transition of tool axis posture during five-axis machining. Through iterative evaluation and dynamic adjustment mechanisms, iteration terminates when the toolpath change is less than a convergence threshold, obtaining an adaptive machining toolpath that simultaneously satisfies spatial geometric continuity and tool axis direction smoothness. This effectively compensates for deformation errors during the machining of thin-walled parts, improving the machining accuracy and surface quality of large thin-walled curved parts. Attached Figure Description
[0016] Figure 1 This is a schematic diagram of the steps of a toolpath processing method for thin-walled parts in one embodiment of the present invention; Figure 2 This is a cloud map showing the surface error distribution of uncompensated toolpath machining in one embodiment of the present invention; Figure 3 This is a cloud map showing the surface error distribution of adaptive compensation toolpath machining in one embodiment of the present invention; Figure 4 This is a structural block diagram of a toolpath processing system for thin-walled parts according to an embodiment of the present invention.
[0017] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0019] Reference Figure 1This embodiment provides a method for processing toolpaths for thin-walled parts, including the following steps: S1, Read the triangular mesh file, construct the offset triangular set, and establish a spatial index structure; Specifically, an STL format triangular mesh file representing the actual machined surface topography of the part is obtained, and the STL format triangular mesh file is parsed to extract all facet data. In the STL file, each triangular facet consists of three sets of vertex coordinates and one facet normal vector. Considering that the normal vectors provided in the STL file may have accuracy errors or be missing, the unit facet normal vector of each triangle is recalculated. For the three vertices of a triangle, the normal vector is calculated by the cross product of the two sides to ensure that each normal vector is normalized and has an accurate direction. To incorporate the ball end radius of the tool into the mesh calculation, the three vertices of each triangle are translated along the direction of the unit normal vector, and the offset triangles are constructed accordingly. The set of all offset triangles is the offset triangle set. For the offset triangular set Construct a spatial index structure, hierarchically divide it according to the coordinate range of each triangle in three-dimensional space, and recursively organize it using an octree or KD tree. Each node records its spatial bounding box and the index of the triangular facets it contains.
[0020] S2, read the theoretical machining program to extract the tool position to be compensated and the tool movement direction, construct a spatial ray along the tool movement direction with the tool position to be compensated as the starting point, and perform intersection detection on the spatial ray and the offset triangle set based on the spatial index structure and calculate the intersection distance; Specifically, semantic parsing is performed on the theoretical machining program to extract the three-dimensional spatial coordinates of each tool position to be compensated and the corresponding tool motion direction vector. The motion direction vector is then standardized to obtain the unit direction vector. Using the tool position as the ray origin and the unit direction vector as the ray direction, the parametric equations of the spatial ray are constructed. To accelerate the intersection point calculation process, a spatial index structure based on an octree or KD-tree is used to quickly locate the spatial sub-regions traversed by the ray. From these sub-regions, a subset of candidate offset triangles overlapping with the sub-regions is selected as the calculation target, thus avoiding a full traversal of the entire triangle set. For each candidate offset triangle, the Möller-Trumbore algorithm is applied to solve for the intersection relationship between the candidate offset triangle and the ray. The Möller-Trumbore algorithm constructs a system of linear equations to explicitly calculate the ray parameters and the corresponding triangle centroid coordinate parameters, determining that the ray and the offset triangle have a valid intersection point, and the corresponding parameter is the intersection distance between the tool position and the offset surface.
[0021] S3, calculate the tool position offset based on the intersection distance, and translate the tool position point to be compensated along the tool movement direction by the tool position offset to obtain the error compensation toolpath; Specifically, the spatial distance between each tool position to be compensated and the offset triangle is extracted from the intersection detection results of the spatial ray and the offset triangle set. This distance is the actual spatial deviation between the tool movement direction and the offset surface, defined as the tool position offset of the tool position. Each tool position to be compensated is judged individually. If a valid intersection exists between the spatial ray corresponding to a tool position, it is considered that there is a spatial deviation between that point and the actual machining surface, requiring geometric compensation. The tool position is translated by a displacement along its unit movement direction, i.e., the compensated tool position is calculated, so that the center of the tool sphere is located above the real surface at an offset position equivalent to the theoretical position, achieving matching between the machining contact point and the fusion surface. If no valid intersection result is obtained for a tool position in the intersection detection, i.e., the ray does not pass through any triangular facet in the offset triangle set, it indicates that no geometric correction is needed for that point, and its original position remains unchanged. All judged and corrected tool positions are arranged in an orderly manner according to the machining sequence of the original sequence of the theoretical machining program, forming a spatially compensated error compensation toolpath sequence with a consistent topological structure.
[0022] S4. Determine the point to be smoothed in the error compensation toolpath, and iteratively optimize the point to be smoothed to generate an adaptive machining program.
[0023] Specifically, extract the complete compensated tool position sequence from the toolpath that has undergone error compensation, and then sequentially process each pair of adjacent tool positions. and Calculate its toolpath segment direction vector Select each intermediate knife point (in Using as the center, construct the direction vectors of its front and rear segments respectively. and The angle between the two direction vectors is calculated by the ratio of the dot product of the two vectors to their magnitudes; simultaneously, to characterize the degree of spatial curvature, the angle between each group of three adjacent tool points is calculated. , , Construct a triangle and calculate the area of the triangle obtained by the cross product of the vectors on both sides. Then, combine the lengths of the three sides to calculate the spatial curvature of the three points, and use this to determine the nodes in the toolpath that have abrupt changes or sharp bends.
[0024] The function for calculating the included angle between adjacent segments is: ; : The angle between the two toolpath segments before and after the i-th tool point. Inverse cosine function : The direction vector of the (i-1)th tool path segment : The direction vector of the i-th toolpath segment. The angle between two adjacent toolpath segments is calculated by the vector dot product and the modulus. First, the cosine value is calculated, then the inverse cosine function is used to obtain the angle in radians, and finally, the conversion factor is multiplied to obtain the angle in degrees. This angle is used to determine whether there is an angle abrupt change in the toolpath at that point.
[0025] The function for calculating the curvature of three points in space is: ; The spatial curvature of the three points at the i-th tool position. The area of the triangle formed by three adjacent tool points; calculate the Menger curvature at three points, and measure the local curvature of the toolpath by the ratio of the area of the triangle formed by the three tool points to the product of the three side lengths. The larger the curvature value, the more severe the curvature of the toolpath at that point.
[0026] When the tool path angle at a certain point Less than the preset angle threshold , or curvature value Greater than the set curvature threshold Then mark that point as the site to be prepared for smoothing. For each site to be prepared for smoothing... Using the directional vectors of its anterior and posterior segments as a reference, auxiliary transition points are constructed, and the proportional factor of the flat bone is defined. Along this point and The directions are translated to generate the front auxiliary points. With rear auxiliary point And a smooth three-point segment formed by these three points. The original single-point structure is replaced to eliminate local angle abrupt changes and smooth path changes, resulting in the first smooth toolpath. The angle and curvature detection process is repeated on the first smooth toolpath, and a three-point smoothing replacement operation is applied to newly identified abrupt change points to form the second round of iterative smooth toolpath. This process continues until the toolpath change between any two iterations is lower than a preset convergence threshold. At this point, the smoothing process is considered converged, and the second smooth toolpath is output. Based on the second smooth toolpath, fixed-distance or fixed-time-step interpolation processing is performed according to the machine tool interpolation cycle requirements to generate an adaptive machining program that meets CNC control requirements.
[0027] In one example, reading a triangular mesh file, constructing an offset triangular set, and establishing a spatial index structure include: Obtain a triangular mesh file in STL format; Extract the coordinates of the three vertices and the face normal vectors of each triangle from the triangular mesh file to construct a triangle set; Calculate the cross product of the two sides of each triangle in the triangle set to obtain the unit plane normal vector. Offset the three vertices of each triangle along the unit plane normal vector by the radius of the tool ball to obtain the offset three vertices. Construct an offset triangle set based on the offset three vertices. The offset triangular set is hierarchically organized according to its spatial location using an octree or KD tree to obtain a spatial index structure.
[0028] In this example, the standard STL format is used as the geometric data input source. The triangular mesh file stores the triangular mesh cells representing the solid surface in ASCII or binary form. During the parsing process, the data structure of each triangular facet is read one by one, the coordinates of the three vertices of the triangle are extracted, and the attached face normal vector information is also extracted. Due to the inaccuracy or missing face normal vectors in the STL, the normal vectors of all triangles are recalculated to ensure the accuracy of the geometric calculation. For each triangle, based on its three sets of vertices, two edge vectors are first constructed, and the face normal vector is calculated by cross product. The resulting vector is then normalized to obtain the unit face normal vector. Each triangle is shifted by a distance equal to the radius of the tool ball joint along its corresponding unit plane normal vector to obtain the offset vertex coordinates. Then, these three offset points are used to reconstruct the offset triangle. The set of all offset triangles is denoted as [the set of triangles]. Use after offset As the geometric basis for intersection point determination, tool radius constraints are embedded. To improve intersection detection efficiency, a high-performance spatial index structure is constructed to accelerate intersection queries between 3D rays and offset triangular faces, and to improve the efficiency of the set... All offset triangles are organized according to their spatial location characteristics, using either an octree or a KD-tree as the data structure. An octree recursively divides the entire 3D space into eight cubic sub-regions, while a KD-tree constructs a balanced binary partitioning structure by periodically splitting the spatial coordinate axes. Each spatial child node records a list of its contained triangular facet numbers, and the containment relationships between upper and lower level nodes are recursively established, generating an index tree structure that supports fast location of spatial query ranges and their correspondence with geometric units.
[0029] Before organizing the offset triangle set hierarchically using an octree or KD tree to obtain a spatial index structure, the process includes local adaptive refinement of the offset triangle set based on curvature features. Specifically, this includes: calculating the triangle curvature feature value for each offset triangle in the offset triangle set; calculating the local curvature angle using the angle between the face normal vectors of the offset triangle and its adjacent offset triangles; using the ratio of the local curvature angle to the triangle side length as the triangle curvature feature value; partitioning the offset triangle set according to a preset curvature threshold; marking offset triangles with a curvature feature value greater than the curvature threshold as high-curvature triangles and assigning them to the high-curvature region; and refining the triangle curvature feature value... Offset triangles with curvature less than or equal to the curvature threshold are marked as low-curvature triangles and assigned to the low-curvature region. Loop subdivision or Butterfly subdivision is performed on each high-curvature triangle within the high-curvature region. The midpoints of the three sides of each high-curvature triangle are used as new vertices. Connecting these three new vertices subdivides the original triangle into four sub-triangles. The positions of the vertices of the newly generated sub-triangles are adjusted along the normal direction of the original triangle's unit face to maintain surface smoothness. The subdivided sub-triangles replace the original high-curvature triangles and are merged with the offset triangles within the low-curvature region to form a refined offset triangle set. The refined offset triangle set is then hierarchically organized according to spatial location to obtain a spatial index structure.
[0030] In one example, the theoretical machining program is read to extract the tool position to be compensated and the tool movement direction. A spatial ray is constructed along the tool movement direction starting from the tool position. Based on the spatial index structure, the intersection detection between the spatial ray and the offset triangular set is performed and the intersection distance is calculated, including: The theoretical machining program is analyzed, the three-dimensional coordinates of each tool position to be compensated and the corresponding tool movement direction are extracted, and the unit direction vector is calculated based on the tool movement direction; A spatial ray is constructed with the point to be compensated as the starting point and the unit direction vector as the direction. The spatial sub-regions traversed by the spatial ray are located through the spatial index structure, and candidate offset triangles within the corresponding spatial sub-regions are selected. The Möller-Trumbore algorithm is used to solve for the ray parameters and centroid coordinates of the candidate offset triangles. Based on the ray parameters and centroid coordinates, it is determined whether the intersection condition is met, and the ray parameters that meet the intersection condition are taken as the intersection distance.
[0031] In this example, the theoretical machining program file is structured and parsed to extract the three-dimensional coordinates of each tool position defined in the program, as well as the tool movement direction vector of each tool position. Each direction vector is then normalized to obtain a standardized unit direction vector for the tool position to be compensated. Starting from the point of origin, construct a straight line using the unit vector of the tool's motion direction, and then apply this to the offset triangulation set. For any triangle in the array, the Möller–Trumbore algorithm is used based on the spatial index structure to determine whether the line intersects with the triangle, and a parallel computing mechanism is used to accelerate the solution when compensating multiple tool points.
[0032] To achieve fast lookup between spatial rays and triangle sets, a spatial index structure (such as an octree or KD-tree) is used. Based on the ray's initial point position and direction vector, the spatial sub-region traversed by the ray is located in the index structure, and candidate offset triangles are extracted only from this sub-region. For each candidate offset triangle, the Möller-Trumbore algorithm is used to calculate the intersection between the ray and the triangle. The Möller-Trumbore algorithm explicitly solves for the ray parameters by constructing a system of linear equations containing the ray's origin, direction vector, and triangle side vectors. and the triangular centroid coordinate parameters If the solution satisfies the following conditions: , , ,and This indicates that the ray intersects the triangle inside the triangle, and the intersection point lies within the effective positive half-space along the ray direction. In this case, the intersection parameter... This serves as the spatial intersection distance between the current tool position and the triangle. The minimum positive value corresponding to each tool position is recorded. This constitutes the precise intersection information between the ray and the offset triangular set.
[0033] The process involves locating the spatial sub-regions traversed by the spatial ray using a spatial index structure and filtering candidate offset triangles within those sub-regions. This includes: constructing a ray envelope cone based on the location of the tool point to be compensated, the unit direction vector, and the tool ball radius. The apex of the ray envelope cone is located at the tool point to be compensated, the cone axis is along the unit direction vector, and the cone angle is determined by the tool ball radius. The process involves traversing each spatial sub-region using the spatial index structure, calculating the intersection relationship between the axis-aligned bounding box of each sub-region and the ray envelope cone, and marking the spatial sub-regions intersecting with the ray envelope cone as potential intersection regions. For each offset triangle within the potential intersection region, the process calculates the vertical distance from the center of the bounding box of the triangle to the spatial ray, and marking offset triangles whose vertical distance is less than the sum of the tool ball radius and the radius of the circumcircle of the triangle as first-level candidate triangles. The first-level candidate triangles are then sorted in ascending order according to their distance from the center of the bounding box to the tool point to be compensated, with the nearest preset number of offset triangles selected as candidate offset triangles.
[0034] In one example, the Möller-Trumbore algorithm is used to solve for the ray parameters and centroid coordinates of the candidate offset triangles. Based on the ray parameters and centroid coordinates, it is determined whether the intersection condition is met. The ray parameters that meet the intersection condition are used as the intersection distance, including: A linear system of equations is established for the parametric equations of the candidate offset triangle and the spatial ray. The Möller-Trumbore algorithm is used to solve the linear system of equations to obtain the ray parameters and the centroid coordinates of the triangle. If the ray parameter is greater than zero and both components of the centroid coordinates of the triangle are non-negative and their sum is not greater than one, and the intersection condition is met, the ray parameter is recorded as the intersection distance of the tool point to be compensated. Multiple tool points to be compensated are assigned to multiple computing threads. Each computing thread independently performs spatial ray construction and intersection detection, and then the intersection distance of each tool point to be compensated is summarized.
[0035] In this example, the spatial coordinates and unit motion direction of each tool position to be compensated are clearly defined, and the spatial ray parametric equations are constructed accordingly. ,in Indicates the starting position of the cutting point. It is a unit direction vector. Let be the ray parameters to be solved. For each candidate offset triangle, its three vertices are denoted as . The Möller-Trumbore algorithm parameterizes the triangle as follows: And by constructing a system of three linear equations Solve Three parameters. Calculated by edge vectors. , Then, for the direction vector and The intermediate vector is obtained by performing a cross product. Calculate the determinant And determine if its absolute value is close to zero to rule out the coplanar case. If If it is non-zero, then continue to find the vector. This yields the coordinates of the first barycenter, which in turn allows for the calculation of the coordinates of the second barycenter, thus providing the ray parameters. If the obtained , , ,and This indicates that the ray passes through the triangle and intersects within it; therefore, this... The value is recorded as the intersection distance between the tool position point and the offset triangle. All tool positions are evenly distributed to multiple parallel computing threads. Each thread is independently responsible for constructing a spatial ray for its tool position point and executing the Möller-Trumbore algorithm in the candidate triangle set to solve for intersection points and determine intersection. After all threads have completed, the main control thread summarizes the minimum effective intersection distance for each tool position point.
[0036] The process includes arranging all compensated tool points according to the machining sequence in the theoretical machining program to obtain the error-compensated toolpath, followed by partitioned adaptive compensation based on the intersection distance gradient field. Specifically, this involves: calculating the intersection distance difference between adjacent compensated tool points in the error-compensated toolpath; dividing the intersection distance difference by the spatial distance between adjacent tool points to obtain the intersection distance gradient, thus constructing the intersection distance gradient field for the entire toolpath; analyzing the intersection distance gradient field according to a preset gradient threshold; marking tool point regions where the absolute value of the intersection distance gradient is less than the threshold as stable compensation regions, and marking tool point regions where the absolute value of the intersection distance gradient is greater than or equal to the threshold as abrupt compensation regions; smoothing the intersection distance of each compensated tool point within the abrupt compensation region using a moving average filtering method; weighting the intersection distances within each preset window length range before and after the tool point to obtain the smoothed intersection distance; recalculating the tool position offset of each tool point within the abrupt compensation region based on the smoothed intersection distance; and translating the tool point to be compensated along the tool movement direction to recalculate the recalculated tool position offset.
[0037] The process involves determining if the ray parameter is greater than zero and both components of the triangle's centroid coordinates are non-negative and their sum is not greater than one. When the intersection condition is met, the ray parameter is recorded as the intersection distance of the tool point to be compensated. This also includes handling cases with multiple candidate intersection points. Specifically, this involves: statistically analyzing all intersection results between the spatial ray of the tool point to be compensated and the candidate offset triangles; when multiple candidate offset triangles satisfy the intersection condition, recording the ray parameter corresponding to each intersection result as a candidate intersection distance and constructing a candidate intersection distance set; calculating the confidence weight for each candidate intersection distance in the candidate intersection distance set, using the cosine of the angle between the triangle face normal vector and the unit direction vector at the intersection point, the distance from the triangle's centroid coordinates to the triangle center, and the relative position of the triangle. The area of the intersecting triangle is used to calculate the comprehensive confidence score, which is then normalized and used as the confidence weight of the candidate intersection distance. The candidate intersection distances in the set are weighted and summed according to their corresponding confidence weights to obtain the fused intersection distance of the cutter point to be compensated. Simultaneously, the standard deviation of the candidate intersection distance set is calculated as the compensation reliability index. It is then determined whether the compensation reliability index exceeds a preset reliability threshold. If the compensation reliability index is less than the reliability threshold, the fused intersection distance is used as the final intersection distance of the cutter point to be compensated. If the compensation reliability index is greater than or equal to the reliability threshold, the candidate intersection distance with the highest confidence weight in the candidate intersection distance set is selected as the intersection distance of the cutter point to be compensated.
[0038] In one example, the tool offset is calculated based on the intersection distance. The tool position point to be compensated is then translated by the tool offset along the tool movement direction to obtain the error compensation toolpath, including: The spatial deviation between each tool position point to be compensated and the offset triangle set is extracted from the intersection distance as the tool position offset. Determine whether the tool positions to be compensated intersect. For the tool positions to be compensated that intersect, translate the tool position offset along the tool movement direction to obtain the compensated tool positions. For the tool positions to be compensated that do not intersect, keep the original position unchanged. Arrange all compensated tool positions according to the machining sequence in the theoretical machining program to obtain the error-compensated toolpath.
[0039] In this example, the ray parameters of each tool position to be compensated are... The spatial deviation between this point and the set of offset triangles is defined as the tool offset. Since the ray only intersects with a certain offset triangle if the condition is met... Furthermore, only when the corresponding barycenter coordinates satisfy the constraints is the spatial offset of the tool position considered to exist for error correction. Therefore, the intersection result set of all tool positions is traversed, and the ray parameters of the points with valid intersections are extracted. As the translation along the tool direction, and based on the original position of the tool position and the unit motion direction vector, the offset is calculated to obtain the new compensated tool position.
[0040] The discrete tool position sequence of the toolpath after error compensation, which includes multiple tool position points, is as follows: P: Discrete tool position sequence set, representing the ordered set of all tool positions after error compensation; : The tool positions in the sequence are arranged in the order of machining; N: The total number of tool positions in the tool position sequence; p i : The i-th tool position point, representing the coordinate position of that point in three-dimensional space; x i : X-axis coordinate component of the i-th tool position point; y i : The Y-axis coordinate component of the i-th tool position point; z i : The Z-axis coordinate component of the i-th tool position.
[0041] For tool positions that do not produce a valid intersection in the candidate triangulation set (i.e., the corresponding ray does not pass through any offset patch or a solution satisfying the intersection condition does not exist), it is determined that no geometric correction is needed, thus maintaining their original spatial coordinates. After completing point-by-point judgment and correction for all tool positions, all compensated tool positions are rearranged according to the machining order defined in the original theoretical machining program to ensure that the trajectory sequence is consistent with the expected cutting path in spatial topology, avoiding machining direction errors or path intersections caused by spatial rearrangement. The resulting compensated toolpath sequence maintains overall structural consistency with the theoretical toolpath, but compensation for actual surface deviations has been completed at the spatial position of each tool position.
[0042] In one example, the desired smoothing point in the error compensation toolpath is determined, and the smoothing point is iteratively optimized to generate an adaptive machining program, including: For adjacent compensated tool points in the error compensation toolpath, calculate the toolpath segment direction vector, and calculate the inverse cosine by the ratio of the dot product of the direction vectors of the two consecutive toolpath segments to the modulus, and obtain the angle between the toolpath segments. The area of the triangle is calculated by the cross product of the two side vectors for three adjacent compensated tool points, and the spatial curvature of the three points is obtained by combining the lengths of the three sides. The compensated tool path points with an included angle less than the angle threshold or a three-point spatial curvature greater than the curvature threshold are marked as tool path points to be smoothed. A front auxiliary point and a rear auxiliary point are generated along the direction of the front and rear toolpath segments to obtain the first smooth toolpath. The front auxiliary point, the smooth toolpath, and the rear auxiliary point form a three-point smooth segment to replace the smooth toolpath, thus obtaining the first smooth toolpath. The included angle curvature detection and three-point smooth segment replacement processing are repeatedly performed on the first smooth toolpath. The iteration is terminated when the toolpath change is less than the convergence threshold to obtain the second smooth toolpath. An adaptive machining program is then generated based on the second smooth toolpath.
[0043] In this example, a local geometric feature analysis model is established on the toolpath point sequence after error compensation. For each intermediate toolpath point, the direction vectors of the toolpath segment formed by its two adjacent toolpath points are calculated. The angle between the two segments is calculated using the ratio of the dot product of these two direction vectors to the modulus, determining whether there is a drastic angle change in the toolpath at that point. Simultaneously, to detect significant curvature distortion in space, a triangle is constructed for each group of three consecutive toolpath points, its area is calculated, and the spatial curvature of the three points is obtained by combining the lengths of the three sides. When the angle... Less than the set angle threshold or curvature Greater than the preset curvature threshold At that point, the point is determined to be the location for the optically guided cutter. For each location to be optically guided... Perform local structural replacement, respectively along its front section direction. and the direction of the latter part Generate two auxiliary points and define the smoothing scaling factor. Calculate the front auxiliary point Calculate the rear auxiliary points and point set The original single-point result is replaced by a smoothed segment inserted at that position to eliminate local abrupt changes and improve path continuity, forming the first smoothed toolpath. This first smoothed toolpath is used as the new input sequence. The angle and curvature detection process is repeated to identify new nodes to be smoothed and replace them with new three-point smoothed segments, forming the toolpath for the next iteration. After each iteration, the overall change in the toolpath is calculated. If the overall change in the toolpath is less than a set convergence threshold... If the smoothing process reaches the convergence criterion, the iteration terminates, and the second smoothing toolpath is output. Combining the spatial point sequence of the second smoothing toolpath with the corresponding tool axis direction, an adaptive machining program that meets the interpolation cycle and acceleration limits of the CNC system is generated through interpolation refinement and format conversion.
[0044] The process involves generating front and rear auxiliary points along the direction of the toolpath segments to be smoothed, including a dynamic adjustment process under the constraint of tool axis posture continuity. Specifically, this includes: extracting the tool axis direction vector at the tool path to be smoothed; calculating the angle between this tool axis direction vector and the tool axis direction vector at the previous tool path point, and the angle between this tool axis direction vector and the tool axis direction vector at the subsequent tool path point, to obtain the tool axis direction angle; dynamically adjusting the smoothing ratio coefficient based on the magnitude of the tool axis direction angle. When the tool axis direction angle is less than a preset tool axis smoothing threshold, a baseline smoothing ratio coefficient is used; when the tool axis direction angle is greater than or equal to the tool axis smoothing threshold, the baseline smoothing ratio coefficient and the tool axis smoothing ratio coefficient are used. The product of the axis angle correction factors is used as the adjusted smoothing ratio coefficient. The tool position to be smoothed is translated along the normalized direction vector of the previous tool segment and the normalized direction vector of the next tool segment using the adjusted smoothing ratio coefficient to obtain the initial front auxiliary point and the initial rear auxiliary point. The interpolated tool axis direction vector is calculated for the initial front auxiliary point and the initial rear auxiliary point. It is determined whether the angle between the interpolated tool axis direction vector and the tool axis direction vector of the adjacent tool position satisfies the tool axis continuity constraint. If it does not satisfy the constraint, the adjusted smoothing ratio coefficient is reduced and the auxiliary point is regenerated until the constraint is satisfied or the minimum smoothing ratio coefficient is reached to obtain the front auxiliary point and the rear auxiliary point.
[0045] This process includes generating front and rear auxiliary points along the direction of the front and rear cutter paths, and adaptive adjustment of smooth segment density based on the rate of curvature change. Specifically, this involves calculating the local rate of curvature change in a continuous five-point region consisting of the cutter site to be smoothed and its adjacent front and rear cutter sites. The previous and subsequent curvature values are calculated using three adjacent points. The difference between the previous and subsequent curvature values is divided by the corresponding cutter path length to obtain the rate of curvature change. The smooth segment density level is determined based on the absolute value of the rate of curvature change. When the absolute value of the rate of curvature change is less than a first rate of change threshold, it is set to a low density level using a single pair of auxiliary points. When the absolute value of the rate of curvature change is between the first and second rate of change thresholds, it is set to a medium density level using a double pair of auxiliary points. When the value is greater than the second rate of change threshold, it is set to a high density level and a three-pair auxiliary point mode is adopted. According to the density level of the smooth segment, a corresponding number of auxiliary point pairs are generated along the front and rear tool paths. For the low density level, a single smoothing ratio coefficient is used to generate a pair of front auxiliary points and a pair of rear auxiliary points. For the medium density level, two sets of increasing smoothing ratio coefficients are used to generate two pairs of auxiliary points respectively. For the high density level, three sets of increasing smoothing ratio coefficients are used to generate three pairs of auxiliary points respectively. The point to be smoothed and the pairs of auxiliary points are arranged in the order of front auxiliary point, point to be smoothed and rear auxiliary point to form multiple smooth segments. The point to be smoothed and the tool axis direction vector of each auxiliary point are calculated by interpolation with the point to be smoothed and the tool axis direction vector of the adjacent tool points to complete the generation of variable density smooth segments.
[0046] In one example, front and rear auxiliary points are generated along the direction of the front and rear toolpath segments to obtain the first smooth toolpath, which consists of the front auxiliary points, the smooth toolpath, and the rear auxiliary points forming a three-point smooth segment that replaces the smooth toolpath. Generate front and rear auxiliary points for the point to be smoothed along the direction of the front and rear cutter paths; A three-point smoothing segment is formed by the front auxiliary point, the point to be smoothed, and the rear auxiliary point in sequence. The point to be smoothed is replaced by the three-point smoothing segment. After all the points to be smoothed are processed, the first smoothing path is obtained.
[0047] In this example, within the toolpath that has undergone error compensation, the identified toolpath points requiring smoothing are processed point by point, and a local smoothing structure is constructed to replace the original abrupt change nodes. For each toolpath point marked as requiring smoothing, its adjacent toolpath points are obtained, and the direction vectors of the preceding and following toolpath segments are calculated. The normalized direction vector is used as the reference direction, combined with a preset smoothing scaling factor. Two auxiliary points are generated, spatially offset by a certain distance. These two points are located in the front and rear directions of the toolpath, respectively, and are symmetrically distributed around the center point, forming a local three-point smooth transition structure. These three points are combined in spatial order and inserted into the original toolpath as interpolation replacement units. Simultaneously, single abrupt toolpath points in their original positions are removed from the path, mitigating local directional abrupt changes and curvature distortion without altering the overall path orientation. By performing the above construction and replacement operations on all points to be smoothed, all high curvature nodes and abrupt angle nodes in the original compensation toolpath are replaced with structurally reasonable, directionally gradually changing, and continuously smoothed three-point segments, resulting in a significant smoothing effect on the local path. After completing the smoothing replacement of all nodes to be smoothed, the updated toolpath sequence is obtained by recombination, i.e., the first smoothed toolpath.
[0048] In one example, the included angle curvature detection and three-point smoothing segment replacement processing are repeatedly performed on the first smooth toolpath. The iteration terminates when the toolpath change is less than the convergence threshold, resulting in the second smooth toolpath. An adaptive machining program is then generated based on the second smooth toolpath, including: The first smooth toolpath is used as input to repeatedly perform the calculation of the toolpath segment angle and the three-point spatial curvature, as well as the three-point smooth segment replacement process, to calculate the toolpath change. Determine whether the change in toolpath is less than the convergence threshold. If the convergence condition is met, terminate the iteration to obtain the second smooth toolpath. If not, continue iterating until the maximum number of iterations is reached and then output the second smooth toolpath. The second smooth toolpath is interpolated and refined to obtain a dense tool position sequence. The dense tool position sequence and tool axis direction vector are then converted into an adaptive machining program.
[0049] In this example, the first smooth toolpath is used as a new input sequence to re-perform the toolpath angle detection and three-point spatial curvature calculation operations, and the three-point smooth segment replacement strategy is repeatedly applied based on the detection results. In each iteration, for each intermediate toolpath point, the direction vectors of its preceding and following segments are calculated and the included angle is obtained. Simultaneously, the area and spatial curvature of the triangle formed by this point and its two adjacent points are calculated. or When the condition is met, the point is marked as a point to be smoothed and replaced with a three-point smoothing segment. After each round of replacement, the difference between the previous round of smoothed toolpath and the currently updated toolpath is evaluated, and the global toolpath change is calculated. If the global toolpath change is less than the convergence threshold... If the current smoothing result has reached a stable state, the iteration terminates, and the second smoothing toolpath is output as the final result; if it has not converged but the number of iterations has not reached the maximum allowed number, the iteration terminates. Then, the angle detection and three-point substitution operations described above are performed on the new output toolpath until any termination condition is met. The second smooth toolpath is spatially discretized, and a fixed-distance interpolation or fixed-time interpolation strategy is used to resample the curve at equal intervals to obtain a dense tool position sequence. Simultaneously, a smooth and continuous tool axis direction vector is constructed for each tool position, and axial continuity is maintained using a three-point weighted average normalization method. The interpolated dense tool position sequence is then bound one-to-one with the corresponding tool axis direction and converted into an adaptive machining program that conforms to the semantic requirements of the CNC system (such as G-code format).
[0050] In one example, the first smooth toolpath is used as input to repeatedly perform toolpath segment angle and three-point spatial curvature calculations, as well as three-point smooth segment replacement processing, to calculate toolpath changes, including: The first smooth toolpath is used as the current iteration input toolpath. The toolpath segment angle and three-point spatial curvature of adjacent tool points in the current iteration input toolpath are recalculated, and the new tool points to be smoothed that meet the smoothing conditions are marked. The new toolpath to be smoothed is obtained by performing a smoothing ratio coefficient translation to generate a three-point smoothing segment replacement and a weighted average normalization of the tool axis direction vector. Calculate the position difference between the tool point corresponding to the smooth toolpath in the next iteration and the input toolpath in the current iteration. Sum the position differences of all tool points and divide by the total number of tool points to obtain the toolpath change.
[0051] In this example, the first smooth toolpath is taken as the first... The input path sequence of each iteration is used to extract all adjacent compensated tool position combinations. The toolpath segment angle and three-point spatial curvature of each intermediate point are calculated sequentially. The toolpath segment angle is calculated as the inverse cosine of the ratio of the dot product of two direction vectors to the magnitude. The three-point spatial curvature is calculated as the area of a triangle based on the cross product of vectors and the side length. When the angle of a tool position is less than a set angle threshold or the curvature is greater than a curvature threshold, it is marked as a new tool position to be smoothed in the next round. For each tool position to be smoothed, a smoothing coefficient is applied along the direction vectors of the preceding and following toolpath segments based on the current position. A directional translation is performed to generate front and rear auxiliary points. These two points, along with the center point, form a three-point smooth segment to replace the original single-point structure. Simultaneously, the tool axis direction vector of this point is weighted, averaged, and normalized with the direction vectors of its adjacent tool points before and after it, yielding the smoothed tool axis direction in the new iteration path. After replacing and updating the directions of all new points to be smoothed, the 1st iteration is generated. The toolpath of the next iteration is smoothed. The smoothing effect of this iteration is evaluated by calculating the first... Each tool point in the second toolpath corresponds to the first... First, input the spatial position difference between the toolpath points, then sum the differences of all points and divide by the total number of points. The average value is calculated to obtain the toolpath change in this round. The toolpath change is used as the criterion for judging the convergence of the iteration. When it is less than the preset convergence threshold, it means that the smoothing process can be terminated. Otherwise, the output of this round is used as the input of the next round of iteration for the curvature angle determination and segment replacement, so as to realize the spatial smooth evolution of the error compensation toolpath while maintaining the surface fitting accuracy.
[0052] In this embodiment, the adaptive processing experiment is conducted as follows: After completing the fusion model prediction, this experiment further verified the practical application effect of the adaptive toolpath compensation method based on fusion data in ball end mill machining. The experiment used an STL triangular mesh constructed based on the predicted high-fidelity contact points to represent the workpiece surface. Based on this, a compensated toolpath was generated and compared with the uncompensated toolpath. The experimental procedure included four steps: point cloud triangular mesh construction, ball end mill center point calculation, line-triangle intersection calculation, and tool position compensation, as shown in the figure.
[0053] First, the high-fidelity predicted point cloud is triangularly meshed using normal estimation and greedy projection triangulation. In the normal estimation stage, the K-nearest neighbor method, combined with the point cloud centroid and the model bounding box center, guides normal uniformity, ensuring all normals face outwards. Subsequently, incremental triangulation is performed on the local projection plane using greedy projection triangulation, setting the search radius to 5% of the model diagonal and constraining the maximum and minimum angles to ensure the generated triangles do not degenerate, while maintaining normal uniformity and vertex order consistency. The generated triangular mesh is used for STL file output and also provides the foundation for subsequent data structures, achieving seamless integration of toolpath planning and 3D geometry processing.
[0054] In the toolpath compensation stage, the algorithm first calculates the ball center base point based on the original toolpath point along the tool axis direction according to the ball end mill radius. Then, a straight line is constructed using the ball center point and the tool axis vector, and the Möller–Trumbore algorithm is used to find the nearest neighbor intersection point between the straight line and the STL triangle. After obtaining the intersection point, the spherical contact point is obtained through spherical center symmetry mapping, and the ball end mill radius is retracted along the tool axis direction to obtain the final compensated toolpath point. To improve computational efficiency, the straight line-triangle intersection process is processed in parallel, enabling large-scale toolpath compensation to be completed within a reasonable time.
[0055] Figure 2 This is a contour plot of the workpiece surface error distribution after ball end mill machining using the original theoretical toolpath. The horizontal and vertical axes represent the X and Y coordinates of the workpiece surface (unit: mm), respectively. The color scale on the right represents the normal deviation (unit: mm) between the actual measured value and the theoretical design value of the machined surface. As can be seen from the contour plot, after machining with the toolpath without adaptive compensation, the entire workpiece surface exhibits a relatively uniform red high-error area, indicating a significant deviation between the actual machined surface and the theoretically designed surface. The corresponding root mean square error (RMSE) is 0.169829 mm, reflecting the systematic machining error caused by deformation accumulation in the machining of thin-walled parts using a traditional fixed toolpath.
[0056] Figure 3 This is a surface error distribution cloud map of the workpiece after ball end mill machining using an adaptive compensation toolpath based on fused data. The meanings of the horizontal and vertical axes in the figure are as follows: Figure 1 Similarly, the color scale on the right also represents the normal deviation of the machined surface (unit: mm). After toolpath adaptive compensation guided by the high-fidelity prediction model, the error distribution on the workpiece surface exhibits obvious localization characteristics. Most areas show a dark blue low-error state, with only a few local areas showing relatively high error values. The root mean square error (RMSE) corresponding to this figure is reduced to 0.0116023 mm, a reduction of approximately 93% compared to the uncompensated toolpath error. This verifies that the toolpath adaptive compensation method based on the triangular mesh model can effectively reduce the ball end mill contact point deviation, control the machined surface error within the ten-micron range, and improve the machining accuracy of thin-walled parts.
[0057] Experimental results show that, compared to the original uncompensated toolpath, the adaptively compensated toolpath can accurately match the workpiece surface, reducing machining errors caused by ball end mill contact point deviation. In actual machining, the surface error after compensation is significantly reduced, and the deviation between the ball end mill contact point and the workpiece surface is controlled within the ten-micrometer range. This verifies that the adaptive toolpath method based on fused prediction data can effectively convert prediction results into machining toolpaths, improving machining accuracy and stability. In summary, this experiment demonstrates that the high-fidelity prediction results provided by the fusion model not only numerically improve the accuracy of contact point prediction but also achieve adaptive toolpath adjustment in actual machining scenarios through point cloud triangular mesh construction and the ball end mill compensation algorithm.
[0058] Reference Figure 4 This embodiment provides a toolpath processing system for thin-walled parts, including: Reading module 1 is used to read triangular mesh files, construct offset triangular sets, and establish spatial index structures; Intersection detection module 2 is used to read the theoretical machining program to extract the tool position to be compensated and the tool movement direction, construct a spatial ray along the tool movement direction with the tool position to be compensated as the starting point, and perform intersection detection on the spatial ray and the offset triangle set based on the spatial index structure and calculate the intersection distance. Error compensation module 3 is used to calculate the tool position offset based on the intersection distance, and to translate the tool position point to be compensated along the tool movement direction by the tool position offset to obtain the error compensation tool path; Iterative optimization module 4 is used to determine the points to be smoothed in the error compensation toolpath, and to iteratively optimize the points to be smoothed to generate an adaptive machining program.
[0059] In this embodiment, the specific implementation of each unit in the above system embodiment is described in the above method embodiment, and will not be repeated here.
[0060] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, system, article, or method that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, system, article, or method. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, system, article, or method that includes that element.
[0061] The above description is only a preferred embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A method for processing toolpaths in thin-walled parts, characterized in that, include: Read the triangular mesh file, construct the offset triangular set, and establish a spatial index structure; The theoretical machining program is read to extract the tool position to be compensated and the tool movement direction. A spatial ray is constructed along the tool movement direction with the tool position to be compensated as the starting point. Based on the spatial index structure, the intersection detection between the spatial ray and the offset triangle set is performed and the intersection distance is calculated. Calculate the tool position offset based on the intersection distance, and translate the tool position point to be compensated along the tool movement direction by the tool position offset to obtain the error compensation toolpath; The desired smoothing point in the error compensation toolpath is determined, and the desired smoothing point is iteratively optimized to generate an adaptive machining program.
2. The method for processing toolpaths for thin-walled parts according to claim 1, characterized in that, The process of reading the triangular mesh file, constructing the offset triangular set, and establishing the spatial index structure includes: Obtain a triangular mesh file in STL format; Extract the coordinates of the three vertices and the face normal vector of each triangle from the triangular mesh file to construct a triangle set; For each triangle in the triangle set, calculate the cross product of the two sides to obtain the unit surface normal vector. Offset the three vertices of each triangle along the unit surface normal vector by the radius of the tool ball to obtain the offset three vertices. Construct an offset triangle set based on the offset three vertices. The offset triangular set is hierarchically organized according to its spatial location using an octree or KD tree to obtain a spatial index structure.
3. The method for processing toolpaths for thin-walled parts according to claim 1, characterized in that, The process of reading the theoretical machining program to extract the tool position to be compensated and the tool movement direction, constructing a spatial ray along the tool movement direction with the tool position to be compensated as the starting point, and performing intersection detection and calculating the intersection distance between the spatial ray and the offset triangle set based on the spatial index structure includes: The theoretical machining program is analyzed, the three-dimensional coordinates of each tool position to be compensated and the corresponding tool movement direction are extracted, and the unit direction vector is calculated based on the tool movement direction; A spatial ray is constructed with the point to be compensated as the starting point and the unit direction vector as the direction. The spatial sub-regions traversed by the spatial ray are located through the spatial index structure, and candidate offset triangles within the corresponding spatial sub-regions are selected. The Möller-Trumbore algorithm is used to solve for the ray parameters and centroid coordinates of the candidate offset triangles. Based on the ray parameters and centroid coordinates, it is determined whether the intersection condition is met, and the ray parameters that meet the intersection condition are taken as the intersection distance.
4. The method for processing toolpaths for thin-walled parts according to claim 3, characterized in that, The process involves using the Möller-Trumbore algorithm to solve for the ray parameters and centroid coordinates of the candidate offset triangles, and determining whether the intersection condition is met based on the ray parameters and centroid coordinates. The ray parameters that meet the intersection condition are then used as the intersection distance. This includes: A system of linear equations is established for the parametric equations of the candidate offset triangle and the spatial ray. The Möller-Trumbore algorithm is used to solve the system of linear equations to obtain the ray parameters and the centroid coordinates of the triangle. When the ray parameter is greater than zero and both components of the centroid coordinates of the triangle are non-negative and their sum is not greater than one, and the intersection condition is met, the ray parameter is recorded as the intersection distance of the tool point to be compensated. Multiple tool points to be compensated are assigned to multiple computing threads. Each computing thread independently performs spatial ray construction and intersection detection, and then the intersection distance of each tool point to be compensated is summarized.
5. The method for processing toolpaths for thin-walled parts according to claim 1, characterized in that, The step of calculating the tool position offset based on the intersection distance, and shifting the tool position point to be compensated along the tool movement direction by the tool position offset to obtain the error compensation toolpath includes: The spatial deviation between each tool position to be compensated and the offset triangle set is extracted from the intersection distance as the tool position offset. Determine whether the tool positions to be compensated intersect. For the tool positions to be compensated that intersect, translate the tool position offset along the tool movement direction to obtain the compensated tool positions. For the tool positions to be compensated that do not intersect, keep the original position unchanged. Arrange all compensated tool positions according to the machining sequence in the theoretical machining program to obtain the error-compensated toolpath.
6. The method for processing toolpaths for thin-walled parts according to claim 5, characterized in that, The process of determining the desired smoothing point in the error compensation toolpath and iteratively optimizing the desired smoothing point to generate an adaptive machining program includes: For adjacent compensated tool points in the error compensation toolpath, calculate the toolpath segment direction vector, and calculate the inverse cosine by the ratio of the dot product of the direction vectors of the two consecutive toolpath segments to the modulus, and obtain the toolpath segment angle. The area of the triangle is calculated by the cross product of the two side vectors for three adjacent compensated tool points, and the spatial curvature of the three points is obtained by combining the lengths of the three sides. The compensated tool path points with an included angle less than an angle threshold or a three-point spatial curvature greater than a curvature threshold are marked as tool path points to be smoothed. A front auxiliary point and a rear auxiliary point are generated along the front and rear tool path segments to replace the point to be smoothed by the front auxiliary point, the point to be smoothed by the front auxiliary point, and the rear auxiliary point to replace the point to be smoothed by the rear auxiliary point, thus obtaining the first smoothed tool path. The included angle curvature detection and three-point smooth segment replacement processing are repeatedly performed on the first smooth toolpath. The iteration is terminated when the toolpath change is less than the convergence threshold to obtain the second smooth toolpath. An adaptive machining program is then generated based on the second smooth toolpath.
7. The method for processing toolpaths for thin-walled parts according to claim 6, characterized in that, The process involves generating a front auxiliary point and a rear auxiliary point along the direction of the front and rear toolpath segments to obtain the first smooth toolpath. The front auxiliary point, the point to be smoothed, and the rear auxiliary point form a three-point smooth segment that replaces the point to be smoothed, thus obtaining the first smooth toolpath. Generate the front auxiliary point and the rear auxiliary point of the point to be smoothed along the direction of the front and rear cutter sections; The front auxiliary point, the point to be smoothed by the tool, and the rear auxiliary point are arranged in sequence to form a three-point smoothing segment. The point to be smoothed by the tool is replaced by the three-point smoothing segment. After all the points to be smoothed by the tool are processed, the first smoothing tool path is obtained.
8. The method for processing toolpaths for thin-walled parts according to claim 7, characterized in that, The first smooth toolpath is repeatedly subjected to included angle curvature detection and three-point smoothing segment replacement processing. The iteration is terminated when the toolpath change is less than the convergence threshold to obtain the second smooth toolpath. An adaptive machining program is then generated based on the second smooth toolpath, including: The first smooth toolpath is used as input to repeatedly perform the calculation of the toolpath segment angle and three-point spatial curvature, as well as the three-point smooth segment replacement process, to calculate the toolpath change. Determine whether the change in the toolpath is less than the convergence threshold. If the convergence condition is met, terminate the iteration to obtain the second smooth toolpath. If the condition is not met, continue iterating until the maximum number of iterations is reached and then output the second smooth toolpath. The second smooth toolpath is interpolated and refined to obtain a dense tool position sequence, and the dense tool position sequence and tool axis direction vector are converted into an adaptive machining program.
9. The method for processing toolpaths for thin-walled parts according to claim 8, characterized in that, The step of repeatedly performing toolpath segment angle and three-point spatial curvature calculation and three-point smoothing segment replacement processing, using the first smooth toolpath as input, to calculate toolpath changes includes: Using the first smooth toolpath as the current iteration input toolpath, the toolpath segment angle and three-point spatial curvature of adjacent tool points in the current iteration input toolpath are recalculated, and new tool points to be smoothed that meet the smoothing conditions are marked. The new toolpath to be smoothed is then subjected to a smoothing ratio coefficient translation to generate a three-point smoothing segment replacement and a weighted average normalization of the tool axis direction vector to obtain the next iteration of the smoothing toolpath. Calculate the position difference between the tool point corresponding to the next iteration of the smooth toolpath and the current iteration of the input toolpath. Sum the position differences of all tool points and divide by the total number of tool points to obtain the toolpath change.
10. A toolpath processing system for thin-walled parts, characterized in that, The steps for implementing the toolpath processing method for thin-walled parts according to any one of claims 1 to 9 include: The read module is used to read triangular mesh files, construct offset triangular sets, and establish a spatial index structure; The intersection detection module is used to read the theoretical machining program to extract the tool position to be compensated and the tool movement direction, construct a spatial ray along the tool movement direction with the tool position to be compensated as the starting point, and perform intersection detection on the spatial ray and the offset triangle set based on the spatial index structure and calculate the intersection distance. The error compensation module is used to calculate the tool position offset based on the intersection distance, and to translate the tool position point to be compensated along the tool movement direction by the tool position offset to obtain the error compensation toolpath; The iterative optimization module is used to determine the point where the tool needs to be smoothed in the error compensation toolpath, and to iteratively optimize the point where the tool needs to be smoothed to generate an adaptive machining program.