A method for generating a multi-axis numerical control machining tool path based on a part model
By constructing a refined triangular mesh model and performing normal vector calculation and tool posture optimization, the problem of large toolpath error in multi-axis CNC machining was solved, achieving high-precision and high-efficiency machining results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN ZHENGGONG PRECISE HARDWARE&PLASTIC CO LTD
- Filing Date
- 2025-01-09
- Publication Date
- 2026-06-19
AI Technical Summary
Existing multi-axis CNC machining methods fail to fully consider the three-dimensional complexity of parts and the changes in tool posture, resulting in large errors in toolpaths, which affect machining accuracy and surface quality. In particular, when dealing with parts with complex curved surfaces or complex geometries, traditional methods cannot provide accurate tool posture optimization.
By acquiring the 3D model data of the part, a refined triangular mesh model is constructed, the normal vector of the triangular mesh is calculated, and preliminary toolpath design and tool posture optimization are performed. Combined with collision detection and smoothing optimization, the final optimized toolpath data is generated.
It improves the accuracy of toolpath generation and machining quality, ensures correct contact between the tool and the workpiece surface, avoids collisions, reduces machine tool damage and machining errors, and enhances machining stability and efficiency.
Smart Images

Figure CN119987290B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of program control technology, and in particular to a method for generating toolpaths for multi-axis CNC machining based on part models. Background Technology
[0002] In multi-axis CNC machining, the accuracy of toolpath generation directly affects machining quality. Current toolpath generation methods mostly rely on empirical formulas or simple geometric models for path planning, failing to fully consider the three-dimensional complexity of the part and the changes in tool posture during machining. Especially when dealing with parts with complex curved surfaces or complex geometries, traditional methods often cannot accurately fit the part surface, resulting in significant errors in the toolpath and consequently affecting machining accuracy and surface quality. Tool posture is a key factor in multi-axis CNC machining, determining the contact state between the tool and the workpiece. In current toolpath generation methods, the calculation and adjustment of tool posture largely depend on manual settings, which are highly subjective and limited. Especially when dealing with complex geometries, traditional tool posture optimization methods often cannot provide accurate posture adjustment schemes, leading to poor contact between the tool and the part surface, or even abrupt posture changes and uneven tool stress. Summary of the Invention
[0003] Therefore, it is necessary for the present invention to provide a method for generating multi-axis CNC machining toolpaths based on part models, so as to solve at least one of the above-mentioned technical problems.
[0004] To achieve the above objectives, a method for generating multi-axis CNC machining toolpaths based on part models includes the following steps:
[0005] Step S1: Obtain the 3D model data of the part; construct a triangular mesh model based on the 3D model data of the part, and perform adaptive meshing on the triangular mesh model to generate a refined triangular mesh model;
[0006] Step S2: Calculate the normal vectors of each triangle based on the refined triangular mesh model to obtain the triangular mesh normal vector data;
[0007] Step S3: Design the initial toolpath based on the refined triangular mesh model to obtain the initial toolpath data;
[0008] Step S4: Optimize the tool attitude of the initial toolpath data using the triangular mesh normal vector data to obtain optimized tool attitude data;
[0009] Step S5: Perform collision detection based on the initial toolpath data and optimized tool attitude data, and optimize and adjust the initial toolpath data based on the collision detection results to obtain collision-optimized toolpath data;
[0010] Step S6: Perform smooth optimization on the collision-optimized toolpath data and convert the toolpath code to obtain the final optimized toolpath data.
[0011] This invention acquires 3D model data of a part and constructs a refined triangular mesh model based on this data, accurately reflecting the part's geometry and surface features. Adaptive mesh generation optimizes the mesh according to the complexity of different regions, ensuring sufficient mesh density in critical areas, thereby improving toolpath generation accuracy. This provides detailed and accurate foundational data for subsequent toolpath design and optimization. By calculating the normal vector of each triangle in the refined triangular mesh model, accurate normal direction data can be provided for toolpath design. The calculation of normal vectors is crucial for tool attitude optimization, ensuring the tool correctly contacts the part surface during machining, effectively improving machining accuracy and surface quality. Preliminary toolpath design based on the refined triangular mesh model generates a reasonable machining path according to the shape and features of the part surface. This process ensures the toolpath covers the entire part surface, meeting machining requirements and providing preliminary path references for subsequent tool attitude optimization and collision detection. Optimizing the attitude of the preliminary toolpath using the triangular mesh normal vector data ensures the tool cuts at the correct angle and direction during machining. This optimization avoids unnecessary tool adjustments or positioning errors at path changes, further improving machining stability and quality. Collision detection and optimization of the toolpath ensure that the tool does not collide with parts, fixtures, or other components during machining. Collision optimization not only improves machining safety but also prevents machine tool damage, reducing errors and unexpected downtime. Smoothing the toolpath and converting it into toolpath code ensures the tool moves along a smooth and safe path during machining, reducing vibration and tool wear. The generated optimized toolpath data can be directly used in CNC machine tool operation, guaranteeing machining accuracy and efficiency. Attached Figure Description
[0012] Other features, objects, and advantages of the invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:
[0013] Figure 1 This is a schematic diagram of the steps of the multi-axis CNC machining toolpath generation method based on a part model according to the present invention;
[0014] Figure 2 for Figure 1 A detailed flowchart of step S1;
[0015] Figure 3 for Figure 1A detailed flowchart of step S2. Detailed Implementation
[0016] The technical method of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.
[0017] Furthermore, the accompanying drawings are merely illustrative of the invention and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor methods and / or microcontroller methods.
[0018] It should be understood that although the terms "first," "second," etc., may be used herein to describe various units, these units should not be limited by these terms. These terms are used merely to distinguish one unit from another. For example, without departing from the scope of the exemplary embodiments, a first unit may be referred to as a second unit, and similarly, a second unit may be referred to as a first unit. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0019] To achieve the above objectives, please refer to Figures 1 to 3 This invention provides a method for generating toolpaths for multi-axis CNC machining based on a part model, the method comprising the following steps:
[0020] Step S1: Obtain the 3D model data of the part; construct a triangular mesh model based on the 3D model data of the part, and perform adaptive meshing on the triangular mesh model to generate a refined triangular mesh model;
[0021] Step S2: Calculate the normal vectors of each triangle based on the refined triangular mesh model to obtain the triangular mesh normal vector data;
[0022] Step S3: Design the initial toolpath based on the refined triangular mesh model to obtain the initial toolpath data;
[0023] Step S4: Optimize the tool attitude of the initial toolpath data using the triangular mesh normal vector data to obtain optimized tool attitude data;
[0024] Step S5: Perform collision detection based on the initial toolpath data and optimized tool attitude data, and optimize and adjust the initial toolpath data based on the collision detection results to obtain collision-optimized toolpath data;
[0025] Step S6: Perform smooth optimization on the collision-optimized toolpath data and convert the toolpath code to obtain the final optimized toolpath data.
[0026] In this embodiment of the invention, reference Figure 1 The above is a flowchart illustrating the steps of a multi-axis CNC machining toolpath generation method based on a part model according to the present invention. In this example, the multi-axis CNC machining toolpath generation method based on a part model includes the following steps:
[0027] Step S1: Obtain the 3D model data of the part; construct a triangular mesh model based on the 3D model data of the part, and perform adaptive meshing on the triangular mesh model to generate a refined triangular mesh model;
[0028] This invention imports or generates 3D model data of the part to be processed using computer-aided design (CAD) software or other 3D modeling tools. After importation, the 3D model data is initially checked to ensure data integrity and error-free operation. Based on the acquired 3D model data, a preliminary triangular mesh model is constructed using a meshing algorithm (such as Delaunay triangulation or marching cubes algorithm). This triangular mesh model discretizes the 3D geometric surface of the part into a geometric representation composed of multiple triangular units. Adaptive meshing is performed on the initially constructed triangular mesh model. Specifically, the size and density of the mesh units are adjusted according to the local features of the part's geometric surface. In areas with drastic geometric changes (such as sharp corners or surfaces with large curvature), the mesh units are densified to increase resolution; in areas with gentle geometric changes, the number of mesh units is appropriately reduced to decrease computational complexity. During meshing, Laplacian smoothing algorithms or other smoothing techniques can be used to further optimize the mesh quality and avoid excessively long or thin triangular units. Finally, a refined triangular mesh model that meets the machining accuracy requirements is generated.
[0029] Step S2: Calculate the normal vectors of each triangle based on the refined triangular mesh model to obtain the triangular mesh normal vector data;
[0030] This invention, in its embodiments, calculates the normal vector of each triangular element in a refined triangular mesh model using the cross product method based on the vertex coordinates. The calculated normal vectors are then normalized to a unit length. A direction consistency check is performed on the normal vectors of all triangles. By determining whether the normal vectors are pointing outwards from the model, if any abnormal directions are found, they are adjusted by reversing the operation (i.e., taking a negative value) to ensure consistency in normal direction. The normalized normal vector data is then bound to the corresponding triangular element index to generate the triangular mesh normal vector data.
[0031] Step S3: Design the initial toolpath based on the refined triangular mesh model to obtain the initial toolpath data;
[0032] This invention, based on a refined triangular mesh model, partitions the machined surface of a part and determines the machining area and path of the tool according to machining process requirements. The initial toolpath design must adhere to the principle of comprehensive optimization of machining efficiency and quality, generating path data that conforms to the geometric characteristics of the machined surface. The machined surface is partitioned according to the geometric characteristics of the refined triangular mesh model (such as curvature changes or normal directions). Refined machining paths are designed for areas with large curvature or complex features; relatively simplified machining paths are designed for areas with small curvature or gentle geometric changes. Regular or adaptive sampling of toolpath points is performed on the machined surface. Regular sampling involves uniform sampling along the machining direction with a fixed step size; adaptive sampling increases the sampling point density in areas with large curvature changes and decreases the sampling point density in areas with small changes, thereby balancing machining accuracy and computational efficiency. Interpolation algorithms are used to connect the sampling points, generating a continuous initial toolpath. Specifically, straight line segments, circular arc segments, or other smooth curves can be used as the toolpath form to ensure the continuity and operability of the toolpath within the machining area. The initially generated toolpath is optimized by eliminating overly dense path points to reduce redundant calculations; the positions of the path points are adjusted to better fit the machined surface and reduce machining errors. Finally, preliminary toolpath data is generated.
[0033] Step S4: Optimize the tool attitude of the initial toolpath data using the triangular mesh normal vector data to obtain optimized tool attitude data;
[0034] This invention uses triangular mesh normal vector data and preliminary toolpath data as input. The triangular mesh normal vector data provides the geometric orientation information of each triangular surface, while the preliminary toolpath data provides the initial position and path sequence of the toolpath points. Based on machining requirements, the objectives for tool posture optimization are determined. These objectives include, but are not limited to, adjusting the tool posture to ensure the cutting part of the tool conforms to the machined surface, thereby improving machining accuracy; ensuring that the non-cutting part of the tool does not interfere with or collide with the machined surface or other workpiece parts; and optimizing the continuity of the tool posture to avoid sudden angle changes and improve machining stability. Based on the triangular mesh normal vector data and preliminary toolpath data, the tool posture is optimized. Using the triangular mesh normal vectors corresponding to the toolpath points, the tool's spindle direction is set to be consistent with the normal vector direction, and the tool posture is initially adjusted. According to the machine tool's motion limitations (such as the tilt angle range of the tool spindle), the initially adjusted tool posture is constrained to ensure that the tool posture is within the machine tool's allowable range. An interpolation algorithm is used to smooth the tool posture of continuous path points, reducing fluctuations in posture changes and ensuring the stability of the machining process. The optimized tool posture is verified, including the degree of fit between the tool posture and the geometric features of the machined surface; whether the tool posture meets the machine tool motion constraints; and the smoothness and continuity of the path after posture adjustment. If the verification results do not meet the requirements, the optimization parameters are readjusted according to the optimization objectives, and the optimization process is repeated until the requirements are met. The optimized tool posture data is then associated with the corresponding toolpath points to generate structured optimized tool posture data.
[0035] Step S5: Perform collision detection based on the initial toolpath data and optimized tool attitude data, and optimize and adjust the initial toolpath data based on the collision detection results to obtain collision-optimized toolpath data;
[0036] This invention uses preliminary toolpath data and optimized tool attitude data as input. The preliminary toolpath data provides the position sequence of toolpath points, while the optimized tool attitude data provides the spatial orientation information of the tool at each toolpath point. The tool is treated as a geometric entity (such as a cylinder, cone, or complex tool model), and combined with a refined triangular mesh model of the part, the overlapping area between the tool and the mesh model is detected. The motion path of the tool attitude is analyzed to ensure a reasonable safe distance between the tool and the part surface, avoiding dynamic collisions caused by rapid attitude changes. Based on the toolpath points and the corresponding tool attitude data, the position and orientation of the tool at each path point are mapped to the refined triangular mesh model of the part, and the spatial relationship between the tool shape and the part model is calculated. If an overlap is found between the tool shape and the triangular face of the part model, the collision point and its corresponding toolpath point index are recorded. The severity of the collision is assessed based on the collision depth or contact area to determine the specific toolpath points that need optimization. For the detected collision points, the preliminary toolpath data is optimized. The collision point is offset by a certain distance along the normal direction to ensure a safe clearance between the tool and the part surface. Without altering the toolpath point positions, collisions are reduced or eliminated by finely adjusting the tool orientation. For path segments experiencing consecutive collisions, the path is redesigned using local triangular mesh features to ensure the tool can avoid collision areas. The optimized toolpath data undergoes a second collision check to ensure all path points meet safety requirements. If collisions persist, the path points or orientations are further adjusted until the requirements are met. The collision-detected and optimized toolpath data is stored in a structured data format to generate collision-optimized toolpath data.
[0037] Step S6: Perform smooth optimization on the collision-optimized toolpath data and convert the toolpath code to obtain the final optimized toolpath data.
[0038] This invention provides a smoothing optimization for collision-optimized toolpath data. An interpolation algorithm is used to smooth the spatial positions of path points and the tool posture, eliminating abrupt changes between path points and improving path continuity and machining stability. Subsequently, the optimized toolpath data is converted into CNC machining code recognizable by the machine tool. Specifically, this involves encoding the path points and tool posture data into an instruction format conforming to CNC machining standards (such as G-code or APT code), verifying the compatibility of the instructions, and finally outputting the final optimized toolpath data for actual machining.
[0039] This invention acquires 3D model data of a part and constructs a refined triangular mesh model based on this data, accurately reflecting the part's geometry and surface features. Adaptive mesh generation optimizes the mesh according to the complexity of different regions, ensuring sufficient mesh density in critical areas, thereby improving toolpath generation accuracy. This provides detailed and accurate foundational data for subsequent toolpath design and optimization. By calculating the normal vector of each triangle in the refined triangular mesh model, accurate normal direction data can be provided for toolpath design. The calculation of normal vectors is crucial for tool attitude optimization, ensuring the tool correctly contacts the part surface during machining, effectively improving machining accuracy and surface quality. Preliminary toolpath design based on the refined triangular mesh model generates a reasonable machining path according to the shape and features of the part surface. This process ensures the toolpath covers the entire part surface, meeting machining requirements and providing preliminary path references for subsequent tool attitude optimization and collision detection. Optimizing the attitude of the preliminary toolpath using the triangular mesh normal vector data ensures the tool cuts at the correct angle and direction during machining. This optimization avoids unnecessary tool adjustments or positioning errors at path changes, further improving machining stability and quality. Collision detection and optimization of the toolpath ensure that the tool does not collide with parts, fixtures, or other components during machining. Collision optimization not only improves machining safety but also prevents machine tool damage, reducing errors and unexpected downtime. Smoothing the toolpath and converting it into toolpath code ensures the tool moves along a smooth and safe path during machining, reducing vibration and tool wear. The generated optimized toolpath data can be directly used in CNC machine tool operation, guaranteeing machining accuracy and efficiency.
[0040] Preferably, step S1 includes the following steps:
[0041] Step S11: Obtain the 3D model data of the part, and perform standardization processing on the 3D model data of the part to obtain standardized 3D model data;
[0042] Step S12: Discretize the surface of the part based on the standardized 3D model data to obtain the discretized surface data of the part;
[0043] Step S13: Construct a triangular mesh model using the discretized data of the part surface to obtain a preliminary triangular mesh model;
[0044] Step S14: Perform discrete curvature calculation on the preliminary three-dimensional mesh model to obtain the surface curvature data of the part;
[0045] Step S15: Based on the surface curvature data of the part, perform adaptive mesh generation on the preliminary three-dimensional mesh model to obtain an adaptive triangular mesh model;
[0046] Step S16: Optimize the mesh quality of the adaptive triangular mesh model to obtain a refined triangular mesh model.
[0047] As an embodiment of the present invention, reference Figure 2 As shown, Figure 1 A detailed flowchart of step S1 is shown below. In this embodiment of the invention, step S1 includes the following steps:
[0048] Step S11: Obtain the 3D model data of the part, and perform standardization processing on the 3D model data of the part to obtain standardized 3D model data;
[0049] In this embodiment of the invention, three-dimensional model data of parts are acquired by a three-dimensional scanner or computer-aided design (CAD) software, and the acquired three-dimensional model data is standardized, including unifying the size units, coordinate system and topology of the model, while removing redundant data and repairing geometric defects, so as to ensure the integrity and consistency of the model data, thereby generating standardized three-dimensional model data.
[0050] Step S12: Discretize the surface of the part based on the standardized 3D model data to obtain the discretized surface data of the part;
[0051] This invention, based on standardized 3D model data, discretizes the surface of a part and extracts feature point data from the part surface using uniform or adaptive sampling methods. This ensures that the sampling points cover the key geometric areas of the model surface. The discretized surface data of the part is generated by combining the complexity and machining accuracy requirements of the part, laying the foundation for the subsequent construction of a triangular mesh model.
[0052] Step S13: Construct a triangular mesh model using the discretized data of the part surface to obtain a preliminary triangular mesh model;
[0053] This invention constructs a preliminary triangular mesh model based on discretized part surface data using a triangular mesh generation algorithm. An appropriate mesh generation method, such as Delaunay triangulation or a Voronoi diagram-based algorithm, is selected to connect the discretized point sets into a triangular mesh. During mesh construction, it is ensured that the mesh nodes and boundaries accurately cover the part surface, maintaining the mesh's uniformity and rationality for subsequent processing. Simultaneously, overlapping or redundant data is processed to generate the preliminary triangular mesh model.
[0054] Step S14: Perform discrete curvature calculation on the preliminary three-dimensional mesh model to obtain the surface curvature data of the part;
[0055] This invention, based on a preliminary 3D mesh model, performs discrete curvature calculations on each triangle within the mesh. By calculating the curvature values on the surface of each triangle, the geometric properties of the part surface are analyzed. Common curvature calculation methods include using local fitting methods (such as least squares) to estimate the curvature of each triangle, or extrapolating based on boundary curvature and the normal direction of the facets. The curvature data of the part surface is obtained through these calculations.
[0056] Step S15: Based on the surface curvature data of the part, perform adaptive mesh generation on the preliminary three-dimensional mesh model to obtain an adaptive triangular mesh model;
[0057] This invention employs adaptive mesh generation on a preliminary 3D mesh model based on the surface curvature data of the part. Depending on the variations in surface curvature and the part's machining requirements, finer meshes are used in areas of greater curvature, while coarser meshes are used in areas of less curvature or flatter surfaces. This adaptive mesh generation method ensures accurate representation of mesh density in critical areas (such as complex surfaces or detailed parts) while avoiding wasting computational resources in simpler areas. The mesh size is dynamically adjusted through algorithm optimization to obtain an adaptive triangular mesh model.
[0058] Step S16: Optimize the mesh quality of the adaptive triangular mesh model to obtain a refined triangular mesh model.
[0059] This invention optimizes the mesh quality of an adaptive triangular mesh model. The optimization process includes, but is not limited to, checking the uniformity, angles, size, and shape of the mesh to ensure the stability and accuracy of the mesh structure. Common optimization methods include eliminating small-angle triangles in the mesh, reducing the proportion of elongated triangles, and adjusting the node positions to improve mesh regularity. Furthermore, local refinement or merging of triangles is used to improve mesh quality, ensuring that the computational error of each mesh cell is minimized. Finally, a refined triangular mesh model is obtained.
[0060] This invention eliminates data discrepancies caused by different measuring tools or technologies by acquiring and standardizing 3D model data of parts, unifying data formats and ensuring consistency in subsequent processing. Standardization enables part models from different sources to be analyzed and calculated in the same processing environment, improving the versatility and reliability of data processing. Discretizing the part surface based on the standardized 3D model data helps transform a continuous surface into a series of discrete point sets, providing accurate discretized data for subsequent triangular mesh model construction. The discretized data can more accurately describe the local features of the part surface, ensuring more accurate and efficient toolpath generation. Constructing a preliminary triangular mesh model using the discretized part surface data lays the foundation for subsequent multi-axis CNC toolpath generation. The triangular mesh model can accurately represent the geometry of the part surface and is easily compatible with other calculation methods, providing refined machining path data. Discrete curvature calculation of the preliminary 3D mesh model can extract local shape features of the part surface, especially areas with large curvature. This information is crucial for tool attitude optimization and machining strategy selection, helping to ensure that the tool contacts the part surface at an appropriate angle, thereby improving machining accuracy and surface quality. Adaptive meshing is performed on the initial 3D mesh model based on the surface curvature data of the part. This allows for finer meshing in areas with significant curvature variations, while using a coarser mesh in flatter areas. Adaptive meshing optimizes mesh quality, reduces computational resource waste, and provides sufficient detail in critical areas, improving the accuracy and efficiency of toolpath generation. Mesh quality optimization is then applied to the adaptive triangular mesh model to ensure mesh connectivity and smoothness, avoiding computational errors caused by mesh quality issues.
[0061] Preferably, step S2 includes the following steps:
[0062] Step S21: Extract the triangle vertices from the refined triangular mesh model to obtain the triangle vertex coordinate dataset;
[0063] Step S22: Calculate the triangle normal vector based on the triangle vertex coordinate dataset to obtain the initial triangle normal vector data;
[0064] Step S23: Standardize the initial triangle normal vector data to obtain standardized triangle normal vector data;
[0065] Step S24: Smooth the standardized triangle normal vector data to obtain smoothed triangle normal vector data;
[0066] Step S25: Perform a consistency check on the normal vector direction of the smooth triangle normal vector data and mark the model feature regions to obtain the triangle normal vector data.
[0067] As an embodiment of the present invention, reference Figure 3 As shown, Figure 1 A detailed flowchart of step S2 is provided. In this embodiment of the invention, step S2 includes the following steps:
[0068] Step S21: Extract the triangle vertices from the refined triangular mesh model to obtain the triangle vertex coordinate dataset;
[0069] This invention extracts the vertex coordinate data of each triangle from a refined triangular mesh model. All triangles in the mesh model are traversed, and the coordinate values of the three vertices of each triangle are obtained. For each triangle, the three-dimensional coordinates (X, Y, Z) of its vertices are recorded, and these coordinate data are stored in a vertex dataset.
[0070] Step S22: Calculate the triangle normal vector based on the triangle vertex coordinate dataset to obtain the initial triangle normal vector data;
[0071] This invention calculates the triangle normal vectors based on a dataset of triangle vertex coordinates. For each triangle, the normal vector is calculated using the coordinates of its three vertices. The calculation typically employs the cross product method: first, the vectors of the two sides are calculated, and then the cross product of these two vectors is performed to obtain a normal vector perpendicular to the triangle. By calculating the direction and magnitude of the normal vector, the normal vector data for each triangle is obtained. During the calculation process, to ensure the accuracy of the normal vectors, the vertex coordinates of each triangle are precisely processed, and the calculation results are ensured to meet geometric constraints. Finally, the initial triangle normal vector data is obtained.
[0072] Step S23: Standardize the initial triangle normal vector data to obtain standardized triangle normal vector data;
[0073] This invention standardizes the initial triangle normal vector data. The magnitude of each normal vector, i.e., the length of the vector, is calculated. For each triangle's normal vector, its length is uniformly 1 by dividing it by its magnitude. Standardized normal vectors will have the same scale, which helps with subsequent smoothing and direction consistency checks. During the standardization process, if a zero vector is encountered (e.g., the normal vector of a planar triangle is zero), an appropriate processing method (such as skipping it or assigning a default value) can be used to avoid calculation errors. Finally, standardized triangle normal vector data is obtained.
[0074] Step S24: Smooth the standardized triangle normal vector data to obtain smoothed triangle normal vector data;
[0075] This invention smooths standardized triangle normal vector data. For each triangle's normal vector, the smoothed value of the current normal is calculated by considering the normal vectors of its neighboring triangles and using a weighted average. Typically, smoothing combines the current triangle's normal vector with those of its neighboring triangles, adjusting the direction of the current normal based on the similarity between the neighboring triangles. The smoothing algorithm can employ a simple neighborhood averaging algorithm or a more complex weighted averaging method, where the weights are usually related to the area or angle of the neighboring triangles. The smoothing process can be repeated until the normal vectors achieve a certain degree of smoothness within their neighborhood, thereby reducing fluctuations in the normal direction caused by grid irregularities or excessive dispersion. Finally, smoothed triangle normal vector data is obtained.
[0076] Step S25: Perform a consistency check on the normal vector direction of the smooth triangle normal vector data and mark the model feature regions to obtain the triangle normal vector data.
[0077] This invention verifies the consistency of the directions of adjacent triangles in smoothed normal vector data by performing a direction consistency check on the normal vectors to ensure that the directions of the normal vectors meet the expected smoothness and continuity requirements. If there is a significant inconsistency in the directions of the normal vectors of adjacent triangles (e.g., the direction difference exceeds a certain threshold), these regions need to be specially processed, such as readjusting the normal vectors or marking them as feature regions. To achieve the direction consistency check, the judgment can be based on the angle between the normal vectors. When the angle between the normal vectors of adjacent triangles is less than a certain set allowable value, their normal directions are considered to be consistent; otherwise, inconsistency is considered to exist. During the check, weights can be assigned to the normal vectors, and their values can be adjusted according to the consistency of the normal directions, or regions with inconsistent directions can be directly marked. Based on the results of the normal direction consistency check, the feature regions of the model are marked. Finally, triangle normal vector data containing the consistency check results and feature region markings are obtained.
[0078] This invention extracts the vertices of triangles from a refined triangular mesh model, enabling the acquisition of precise geometric information for each triangle on the part's surface. Ensuring accurate coordinates for each triangle vertex, effectively representing the part's surface shape, is a prerequisite for high-precision toolpath generation. Calculating the triangle normal vectors based on the triangle vertex coordinate dataset provides accurate surface normal vectors for each triangle. These normal vectors are crucial data for determining the tool entry angle, orientation, and surface machining sequence, influencing tool movement stability and machining results, and providing necessary geometric basis for subsequent tool orientation optimization and path planning. Standardizing the initial triangle normal vector data eliminates size differences between different triangle normal vectors, ensuring all normal vectors have a uniform scale. This process improves the accuracy and reliability of subsequent steps, especially during tool orientation adjustment, where standardized normal vectors help ensure the tool operates in a consistent direction. Smoothing the standardized triangle normal vector data eliminates abrupt changes in normal direction, preventing drastic changes or instability in tool orientation. Smoothed normal vectors result in smoother toolpath changes, reducing vibration, tool wear, and machining errors caused by abrupt changes in tool posture during machining, thus improving machining quality and efficiency. Performing a normal vector direction consistency check on the smoothed triangle normal vector data and marking model feature regions helps identify complex and critical feature areas on the part surface. Consistency checks ensure that the tool's entry angle remains consistent across different positions, preventing errors or inconsistencies during machining. Marking feature regions allows for focusing on complex areas during path planning, thereby optimizing machining strategies and improving machining accuracy.
[0079] Preferably, step S3 includes the following steps:
[0080] Step S31: Identify key feature regions on the surface of the part from the refined triangular mesh model to obtain surface feature data of the part;
[0081] This invention utilizes curvature calculation algorithms (such as Gaussian curvature and mean curvature) to analyze the local curvature value of each vertex in a refined triangular mesh model. During calculation, for each vertex, the curvature value is calculated using differential geometry formulas based on the rate of change and relative position of the normal vectors of its connected neighboring triangles. After curvature calculation, the curvature values are compared with a preset threshold, and vertices with higher curvature are selected as preliminary markers of high-curvature regions. Subsequently, key feature regions are expanded by tracing the neighborhood connections of high-curvature points and performing cluster analysis on connected regions. The clustering method can employ distance-based region growing to group adjacent points and triangles into the same feature region. Finally, the identified feature regions are classified and labeled to generate key feature data for the part surface.
[0082] Step S32: Obtain tool parameter data, select toolpath generation strategy based on part surface feature data and tool parameter data, and obtain toolpath generation strategy selection data;
[0083] This invention selects a toolpath generation strategy based on key surface feature data of the part and tool parameter data (e.g., tool diameter, depth of cut, feed rate, and tool shape). The tool parameter file is parsed, relevant values are extracted, and stored in a structured data format. The part surface feature data is matched with the tool parameters, with matching rules based on the complexity of the machining area features (e.g., high curvature or narrow regions) and tool performance limitations. For example, if the feature area contains many high curvature points, a small-diameter tool is selected, and a local fine cutting strategy is employed; if the feature area is a smooth, large-area region, a large-diameter tool is selected, and a parallel cutting strategy is used. After matching, toolpath generation strategy selection data is generated.
[0084] Step S33: Use the key feature data of the part surface and the toolpath generation strategy to select data for preliminary toolpath design.
[0085] This invention designs preliminary toolpaths based on key feature data of the part surface and toolpath generation strategy selection data, using a geometric path calculation method. The triangular mesh region of the part surface is divided into different machining sub-regions, each corresponding to a toolpath generation strategy. For high-curvature regions, a layered cutting path design method is used, offsetting the region equidistantly along the surface normal direction to generate multi-layered contour cutting paths. For smooth, large-area regions, a parallel cutting path design method is employed, generating straight-line trajectories parallel to the machining plane by calculating the spindle direction. The spacing of these straight-line trajectories is set according to the tool diameter and surface roughness requirements. During path design, the toolpaths need to be smoothed by using interpolation algorithms to eliminate discontinuities between paths, ensuring smoothness. After design, the toolpaths are stored as serialized point sets or vector curves, yielding preliminary toolpath data.
[0086] This invention identifies key feature regions on the surface of parts using a refined triangular mesh model, effectively extracting complex geometric shapes and functional features. This process helps to clearly identify the functional areas of the part, ensuring precise machining of these key areas during toolpath generation. Identifying surface feature regions provides crucial information for tool selection and path planning, improving machining accuracy and quality. Acquiring tool parameter data and selecting a toolpath generation strategy based on part surface feature data and tool parameters helps determine the most suitable toolpath generation method. This strategy selection ensures the tool can complete the task efficiently and stably during machining, avoiding unnecessary machining errors. By integrating the geometric features of the part and the performance of the tool, an optimized machining strategy can be formulated, thereby improving machining efficiency and reducing tool wear. Using key feature data of the part surface and toolpath generation strategy selection data for preliminary toolpath design, a preliminary toolpath that conforms to the part surface features and machining requirements can be generated. This design ensures that the toolpath planning can adapt to the part surface shape and machining requirements to the greatest extent, avoiding unnecessary deviations during machining.
[0087] Preferably, step S33 includes the following steps:
[0088] Step S331: Subdivide the key feature data of the part surface into tiny units to obtain subdivided key feature region data;
[0089] In this embodiment of the invention, after identifying key feature regions on the surface of a part, a recursive subdivision method is used to divide these feature regions into tiny units. Based on the geometric properties of each feature region, the area and curvature value of that region are calculated. By setting a specific threshold, regions with curvature greater than the threshold are further subdivided. The subdivision operation can be performed by meshing, decomposing the region into multiple smaller triangular or rectangular units, with the size of each unit automatically adjusted according to the surface curvature and local geometric complexity. For example, in high-curvature regions, the subdivided units will be smaller to ensure the accuracy of path calculation; in flatter regions, the subdivided units will be larger. The subdivided data structure is typically stored in the form of a two-dimensional array or mesh, containing the geometric information of each tiny unit (such as vertex coordinates and normal vectors), thus obtaining the subdivided key feature region data.
[0090] Step S332: Design path points based on the subdivided key feature region data and toolpath generation strategy to obtain coarse toolpath path point data;
[0091] This invention, in its embodiments, uniformly distributes path points within each sub-triangle based on the surface shape of each tiny unit in the subdivided key feature region data, typically using a uniform distance interval method. For high curvature regions, the point density can be determined by calculating the rate of change of the normal vector within that region. For example, in regions with significant curvature variations, the distance between path points is set smaller to ensure that the path points can cover complex surface geometry. The toolpath generation strategy influences the arrangement of path points; for flat regions, path points are arranged in a regular grid, while for curved regions, contour lines or equidistant projections are used. During the design process, path points must be adjusted according to the size and shape of the tool to ensure that the tool can smoothly pass through each path point. The final coarse toolpath point data is stored in three-dimensional coordinate form.
[0092] Step S333: Connect the path points of the roughing toolpath based on the preset machining requirements to obtain the roughing toolpath path segment data;
[0093] This invention, based on coarse path point data, calculates the shortest distance between adjacent path points and connects them sequentially. During connection, considering the directionality of machining and tool movement, interpolation algorithms, such as linear interpolation or spline interpolation, are used to ensure smooth transitions between path segments without abrupt directional changes. For more complex areas, Bézier curves or NURBS (Non-Uniform Rational B-Splines) are used to connect path segments. This method effectively maintains the smoothness of the curves and reduces tool jitter. During the connection process, the angle of each tool turn is ensured to be smooth, avoiding excessive angle changes that could lead to machining vibration or tool damage. Each path segment consists of several path points, ultimately forming coarse toolpath segment data.
[0094] Step S334: Optimize the path segment connection order based on the coarse toolpath path segment data to obtain optimized toolpath path segment data;
[0095] This invention analyzes the relative positions of the start and end points of each path segment, as well as the connection cost of adjacent path segments, based on coarse toolpath segment data. The connection cost is typically calculated based on the distance between path segments, angle changes, and machining time. For example, the connection cost is lower when the end point of a path segment is close to the start point of the next path segment; conversely, the connection cost is higher if the interval between path segments is large or the angle changes drastically. To reduce tool idle time and path repetition, a greedy algorithm or genetic algorithm is used to optimize the arrangement order of path segments. Through multiple iterations of adjusting the path segment order, the machining time of the entire path is minimized, and the tool movement along the path is made smoothest. After optimization, the resulting path segments are arranged in the optimized order to form optimized toolpath segment data.
[0096] Step S335: Integrate the optimized toolpath segment data to obtain preliminary toolpath data.
[0097] This invention's path segment integration method connects optimized path segments into a complete preliminary toolpath. The integration process begins by sequentially piecing together each path segment according to their connection order. Interpolation is used to smoothly transition between each pair of path segments, ensuring that the tool does not experience sudden directional changes as it moves between paths. During path segment integration, any unnecessary repetitions or redundancies between paths are removed and merged to maintain path simplicity. Furthermore, the path is modified based on the actual size and shape of the tool to ensure that the tool covers the entire machining surface, preventing missed or overcutting. Finally, preliminary toolpath data is obtained.
[0098] This invention, by subdividing key feature data of a part surface into tiny units, can more precisely describe the geometric features of the part, especially in complex or intricate machining areas. This subdivision helps improve machining accuracy, ensuring that the toolpath can accurately match the complex geometry of the part surface. Simultaneously, the subdivided key feature regions provide a more precise machining area, laying the foundation for subsequent toolpath path point design. Path point design based on the subdivided key feature region data and toolpath generation strategy ensures that the generated toolpath accurately matches the feature regions of the part surface. Path point design, by considering the working principle of the tool and machining requirements, avoids excessively sparse or dense paths, improving the rationality of the toolpath path and machining efficiency. Optimizing the layout of path points can better reduce the ineffective time of tool movement during machining, thereby improving machining efficiency. Connecting path points based on preset machining requirements ensures that the tool can reasonably complete the machining task according to specific machining needs. The connection of path points makes the toolpath more continuous and smooth, avoiding repeated tool movement or excessive path correction, improving machining efficiency and reducing machining time. By optimizing the connection sequence of coarse toolpath segments, the optimization level of the toolpath can be further improved, reducing repetitive tool movements and redundant paths. Optimizing the connection sequence of path segments helps reduce unnecessary movement during machine tool operation, improving machining efficiency and reducing mechanical wear. Optimized path segment sequence ensures smooth tool movement and avoids potential machining problems. Integrating the optimized toolpath segment data yields preliminary toolpath data, providing a clear path framework for subsequent toolpath smoothing optimization and attitude adjustment.
[0099] Preferably, step S4 includes the following steps:
[0100] Step S41: Perform correlation analysis on the triangular mesh normal vector data and the preliminary toolpath data to obtain path point-normal vector correlation data;
[0101] In this embodiment of the invention, when performing correlation analysis between triangular mesh normal vector data and preliminary toolpath data, the coordinates of path points in the preliminary toolpath data and the direction data of normal vectors in the triangular mesh normal vector data are extracted. By matching the spatial positions of path points with the spatial positions of triangular mesh vertices, the triangular facet containing the path point is determined using the perpendicular projection method from point to face, and the normal vector of that facet is obtained. In the calculation of each path point, the facet with the smallest perpendicular distance is preferentially selected as the corresponding facet of the path point to avoid matching errors. For areas with densely packed path points, a weighted average method of normal vector directions is used to calculate the comprehensive normal vector in the neighborhood to reduce discretization errors. The data matching results of path points and normal vectors are stored as a combination of path point coordinates and normal vectors, forming path point-normal vector correlation data.
[0102] Step S42: Obtain CNC machine tool parameter data, set the tool posture range based on tool parameter data and CNC machine tool parameter data, and obtain tool posture adjustment constraint data;
[0103] After acquiring CNC machine tool parameter data and tool parameter data, this embodiment of the invention sets tool posture adjustment constraints according to actual machining requirements. The machine tool parameter data includes the angle limits of the rotary axes, the travel range of the linear axes, and their dynamic characteristics (such as maximum acceleration and velocity). The tool parameter data includes the tool radius, length, and cutting edge angle. Based on this data, a constraint model is established, for example, using the Lagrange multiplier method to constrain the boundary conditions of the tool motion space. Upper and lower limits are set for the tool's rotation angle; for example, the tool spindle angle range is defined as -90° to 90°, while a limit is set on the rate of change of the tilt angle to avoid violent movement. Furthermore, situations where the tool length exceeds the machine tool's working range are determined, and the machining path and tool posture range are dynamically adjusted, ultimately generating tool posture adjustment constraint data.
[0104] Step S43: Perform preliminary tool posture calculation based on path point-normal vector correlation data and tool posture adjustment constraint data to obtain preliminary tool posture data;
[0105] This invention calculates preliminary tool posture data based on path point-normal vector correlation data and tool posture adjustment constraints. Using geometric calculation methods, the normal vector of the path point is used as the tool axial reference, and the initial tool posture value is determined in conjunction with machine tool motion parameters. Euler angles or quaternions are used to represent the tool posture angles, and inverse kinematics methods are used to solve for the tool posture parameters, ensuring they satisfy the machining surface characteristics and constraints. In specific operation, the normal vector of the path point is used as the directional constraint of the tool spindle, and the contact point between the tool and the workpiece is adjusted in conjunction with the machining curvature and tool length. During calculation, interpolation methods are used to generate continuous tool posture trajectories for discrete path points, ensuring smooth tool movement between path points, ultimately forming preliminary tool posture data.
[0106] Step S44: Smooth the initial tool attitude data to obtain optimized tool attitude data.
[0107] The smoothing process for initial tool attitude data in this invention aims to eliminate discontinuities and abrupt changes between attitudes. By interpolating and curve fitting the tool attitude trajectory, the smoothing process employs spline curves or low-pass filtering techniques, such as using the B-spline method to fit discrete attitude points into a continuous curve. During processing, the rate of change of angle for each segment of the tool attitude is limited to a certain range, for example, controlling the angle change to no more than 5° per second to avoid vibration or mechanical overload during machining. The smoothing algorithm also needs to consider the complexity of the machined surface, appropriately increasing the sensitivity of tool attitude adjustment for complex areas. After smoothing, the generated optimized tool attitude data exhibits continuity and stability throughout the entire path, meeting the requirements of machining path planning.
[0108] This invention, through correlation analysis of triangular mesh normal vector data and preliminary toolpath data, ensures precise alignment between the toolpath and the surface features of the part. The correlation between path points and normal vectors not only helps determine the cutting direction but also allows for precise adjustment of the tool's posture, thereby improving the accuracy of the machined surface. This step, by optimizing the selection of path points and matching normal vectors, ensures that the toolpath matches the part surface, avoiding unnecessary machining errors. Acquiring CNC machine tool parameter data and setting the tool posture range based on tool and machine tool parameter data provides crucial constraints for tool posture adjustment during machining. Precise setting of machine tool and tool parameters ensures that the tool's movement is adapted to the machine tool's working environment, preventing machining problems caused by improper tool posture and ensuring a smooth and safe machining process. Preliminary tool posture calculation is performed based on path point-normal vector correlation data and tool posture adjustment constraint data, providing correct initial posture data for the tool during actual machining. This step ensures the initial rationality of the tool orientation, avoids uncoordinated contact between the tool and the workpiece surface, guarantees machining accuracy, and provides basic data for subsequent tool orientation optimization. Smoothing the initial tool orientation data helps reduce drastic changes or discontinuities caused by tool orientation adjustments during machining. Through smoothing, the tool's motion trajectory is optimized, avoiding the adverse effects of sudden orientation changes on machining results, improving the stability of the machining process and extending tool life. The optimized tool orientation helps ensure machining accuracy and reduces errors caused by unstable orientations.
[0109] Preferably, step S41 includes the following steps:
[0110] Step S411: Extract the three-dimensional spatial coordinates of the path points from the preliminary toolpath data to obtain the three-dimensional spatial coordinate data of the path points;
[0111] In this embodiment of the invention, for the initial toolpath data, the three-dimensional spatial coordinates of the path points are first extracted. Specifically, the coordinate information of each path point in the initial toolpath data is deconstructed into individual coordinate values, divided into three components: X, Y, and Z, and stored in the path point coordinate dataset. The operation is completed using numerical analysis techniques or by directly reading the geometric data fields of the toolpath file. For example, the point data of the G-code is located in the toolpath data generated by NC code or CAD / CAM, the corresponding coordinate values for each path point instruction are read, and stored in the path order as an ordered set of three-dimensional vectors, forming the three-dimensional spatial coordinate data of the path points.
[0112] Step S412: Perform triangular mesh patch mapping based on the 3D spatial coordinate data of the path points to obtain path point-mesh patch mapping data;
[0113] This invention constructs a KD-tree accelerated structure to represent the spatial distribution of triangular meshes based on the 3D spatial coordinate data of path points. The 3D coordinates of each path point are input, and the nearest neighbor search algorithm of the KD-tree quickly locates the triangular facet containing the path point, recording the mapping relationship between the path point and the mesh facet. If the path point is not directly located within a facet, the nearest facet is selected as the mapping target by calculating its distance to neighboring faces. For path points falling on facet boundaries, a unique facet mapping result is determined by calculating the angle between the path point and the facet's normal vector and the weight relationship to vertices, and the path point and facet information is stored as path point-mesh facet mapping data.
[0114] Step S413: Extract the normal vectors of each path point from the triangular mesh normal vector data based on the path point-mesh patch mapping data to obtain the path point-normal vector mapping data;
[0115] This invention utilizes path point-mesh patch mapping data to extract the corresponding path point normal vectors from triangular mesh normal vector data. For path points entirely within a single patch, the normal vector of that patch is directly used as the path point's normal vector. For path points located at or around the boundaries of multiple patches, the path point's normal vector is calculated using patch vertex normal vector interpolation. Specifically, the calculation method involves weighted averaging of the vertex normal vectors based on the centroid weights from the path point to the three vertices of the patch, yielding the path point's normal vector. After extraction, the path points and normal vectors are stored as path point-normal vector mapping data.
[0116] Step S414: Verify the path point-normal vector mapping data, and integrate the path point 3D spatial coordinate data, triangular mesh normal vector data and verification results to obtain path point-normal vector association data.
[0117] This invention validates the path point-normal vector mapping data by calculating the angle between the path point's normal vector and the corresponding mesh surface's normal vector, ensuring the angle value is less than a specified threshold (e.g., 10 degrees) to verify data accuracy. For path points with angles outside this range, the normal vectors are corrected by recalculating their interpolated normal vector values or adjusting the path point mapping surface. After validation, the validation results are integrated with the path point's 3D coordinate data and the triangular mesh normal vector data into complete path point-normal vector association data, stored as a structured data file. In the final result, each path point corresponds to a unique normal vector and its associated 3D coordinates.
[0118] This invention extracts the three-dimensional spatial coordinates of path points from preliminary toolpath data, accurately converting the toolpath into coordinate data in three-dimensional space. This step provides fundamental data for subsequent toolpath analysis and optimization, ensuring the accurate positional relationship between the toolpath and the part surface, and avoiding positional deviations or errors during CNC machining. Based on the three-dimensional spatial coordinate data of the path points, triangular mesh facet mapping is performed, corresponding the toolpath path points to the facets of the triangular mesh model. This mapping process better integrates the toolpath with the part surface, making the toolpath design closely related to the geometric features of the part, thereby improving machining accuracy and the tool's adaptability to surface shapes. Based on the path point-mesh facet mapping data, path point normal vectors are extracted from the triangular mesh normal vector data, providing precise cutting direction information for each path point. The extraction of normal vectors ensures that the tool posture is consistent with the surface normal, thus avoiding uneven cutting or tool wear caused by incorrect tool posture during cutting, improving machining accuracy and tool efficiency. By verifying the path point-normal vector mapping data and integrating the 3D spatial coordinate data of the path points, the triangular mesh normal vector data, and the verification results, the precise matching between the toolpath and the part surface can be verified. Through data verification and integration, potential machining problems can be identified, such as inconsistencies between the path and the surface or incorrect normal vector directions, allowing for timely adjustments and ensuring optimized toolpaths and smooth machining processes.
[0119] Preferably, step S43 includes the following steps:
[0120] Step S431: Set the initial orientation of the tool posture based on the path point-normal vector correlation data to obtain preliminary tool posture orientation data;
[0121] This invention, based on path point-normal vector correlation data, analyzes the normal vector of each path point and sets the initial direction of the tool posture using the normal vector as a reference. Specifically, the direction of the normal vector is set to the direction of the tool axis, and the tool feed direction is set to the direction of the line connecting the path points. Assume the path point normal vector is [n...]. x ,n y ,n z ], initialize the tool axis direction vector to be parallel to the normal vector [t] x ,t y ,t z ] = [n x ,n y ,n zWhen machining complex curved surfaces, a local coordinate system is established, and the tool angle is adjusted within this system to avoid excessive angular offsets between path points. Finally, the initial orientation data is stored as a three-dimensional vector, forming preliminary tool attitude orientation data.
[0122] Step S432: Adjust the tool posture direction constraint of the preliminary tool posture direction data according to the tool posture adjustment constraint data to obtain the preliminary tool posture constraint data;
[0123] This invention adjusts the constraint range of preliminary tool posture direction data based on tool posture adjustment constraint data. By analyzing CNC machine tool parameters, the tool's motion range is obtained, including the angular limitations of the rotary axis, the motion range of the linear axis, and the spatial limitations of the machining area. For the tool posture direction data at each path point, the angle between the tool axis direction and the normal vector is calculated to ensure that the angle is within the actual motion range of the tool. If the angle exceeds the limit (e.g., ±45°), the posture direction is recalculated by adjusting the rotation angle of the tool relative to the normal vector. For directional changes between path points, corrections are made by adding intermediate interpolation points or adjusting the angle distribution of path segments. Finally, the adjusted data is saved as preliminary tool posture constraint data.
[0124] Step S433: Based on the preliminary tool attitude constraint data, perform adjacent path point attitude interpolation calculation on the preliminary tool attitude direction data to obtain the preliminary tool attitude interpolation data;
[0125] This invention, based on preliminary tool attitude constraint data, performs interpolation calculations on the tool attitude directions between adjacent path points. First, the tool attitude direction of each path point is represented as a quaternion to ensure the smoothness and accuracy of the direction interpolation. Then, the spherical linear interpolation (SLERP) algorithm is used to calculate the attitude interpolation values between adjacent path points. The interpolation results are stored as a continuous attitude direction dataset, forming preliminary tool attitude interpolation data.
[0126] Step S434: Perform conflict identification on the preliminary tool posture interpolation data, and correct it based on the conflict identification results to obtain the preliminary tool posture data.
[0127] This invention performs conflict identification on preliminary tool posture interpolation data by detecting whether the tool posture exceeds motion limits between path segments, including excessive angle changes, tool-workpiece collisions, or the tool exceeding the CNC machine tool's motion range. For identified conflict path segments, corrections are made by recalculating interpolation points or adjusting the posture direction. Specific methods include adding intermediate posture direction points to the conflict points to reduce the angle of posture change; or adjusting the angle between the tool and the normal vector in the conflict segment to ensure it remains within the tool's motion range. The corrected data is verified through simulation to check whether the conflict has been completely eliminated. Finally, the corrected data is saved as preliminary tool posture data.
[0128] This invention sets the initial tool orientation based on path point-normal vector correlation data, which helps determine the initial tool orientation for each path point. By precisely setting the tool orientation, it ensures that the tool maintains the correct cutting direction with the workpiece surface normal during machining, thereby improving machining accuracy and reducing machining deviations caused by incorrect orientation. The initial tool orientation data is adjusted according to tool orientation adjustment constraint data to ensure that the tool orientation meets various constraints during machining, such as the maximum tool rotation angle or interference limits. This step, by reasonably constraining the tool orientation, avoids inappropriate orientation adjustments during machining, ensuring that interference between the tool and workpiece is avoided, thus improving machining safety and reliability. Based on the initial tool orientation constraint data, attitude interpolation calculations are performed on the initial tool orientation orientation data for adjacent path points, enabling a smooth transition of tool orientation and avoiding abrupt attitude changes between path points. Through interpolation calculations, the continuity of tool orientation between path points is ensured, thereby reducing cutting instability caused by excessive attitude jumps or changes during machining, improving surface quality and tool life. Conflict identification of preliminary tool posture interpolation data can effectively identify and avoid interference or collisions between the tool posture and the machining environment. By correcting conflicting tool postures, it is ensured that the tool path will not collide with other components or equipment during machining, avoiding the risk of damaging the tool or equipment or affecting machining quality, thereby ensuring the safety and accuracy of the machining process.
[0129] Preferably, step S5 includes the following steps:
[0130] Step S51: Perform path attitude matching between the preliminary toolpath data and the optimized tool attitude data to obtain path point-attitude matching data;
[0131] In this embodiment of the invention, when matching preliminary toolpath data with optimized tool posture data, a correspondence between path points and posture data is established to ensure that the tool posture at each path point is consistent with the three-dimensional coordinates of the path point. First, the spatial coordinate information of each path point in the preliminary toolpath data is parsed. Simultaneously, corresponding tool posture parameters, including the tool axis direction and rotation angle, are extracted from the optimized tool posture data. Based on the index number of the path point, the posture data is assigned to the corresponding path point, generating a path point-posture matching dataset. During the matching process, a data structure is used to store the three-dimensional coordinates of the path points and the corresponding tool posture parameters, and all matching relationships are verified to ensure that the posture direction is consistent with the machining requirements of the path point. Finally, the path point-posture matching data is obtained.
[0132] Step S52: Construct a three-dimensional virtual model of the machining environment using the part's three-dimensional model data, tool parameter data, and CNC machine tool parameter data to obtain the three-dimensional virtual model of the machining environment;
[0133] This invention utilizes 3D model data of a part, tool parameters, and CNC machine tool parameters to construct a 3D virtual model of the machining environment. First, the 3D model data of the part is loaded, and a visual model of the part is generated using a 3D geometric modeling tool (such as OpenGL or Unity3D). Second, a 3D model of the tool is established based on the tool parameter data. Combined with the CNC machine tool parameter data, a geometric model of the CNC machine tool is generated, and motion constraints are set. The part model, tool model, and machine tool model are aligned in coordinates, and a unified coordinate system is established with the machining datum of the part model as the origin. Finally, a 3D virtual model of the machining environment is output through a 3D modeling platform.
[0134] Step S53: Based on the path point-attitude matching data, and using the three-dimensional virtual model of the machining environment, simulate the tool motion collision to obtain tool collision detection data;
[0135] This invention, based on path-point-attitude matching data and combined with a 3D virtual model of the machining environment, performs collision simulation detection on tool motion. First, the path-point-attitude matching data is loaded, and the path points and tool attitudes are inserted into the virtual machining environment to simulate the tool's trajectory between path points. A collision detection algorithm, such as a bounding volume hierarchy (BVH) based method, is used to determine in real time whether interference occurs between the tool and the workpiece surface, fixture, or machine tool structure. The collision detection criterion is whether the shortest distance between two geometric objects is less than a preset safety clearance value. If it is less than the safety value, a collision is determined, and the collision location and path point index are recorded. The output tool collision detection data includes the coordinates of the path point where the collision occurred, attitude parameters, and collision type information.
[0136] Step S54: Mark and extract collision path points based on tool collision detection data to obtain tool collision path point data;
[0137] This invention, in its embodiments, marks and extracts detected collision path points based on tool collision detection data. The extraction operation locates the collision path point by parsing the path point index and corresponding 3D coordinates recorded in the collision detection data. During the marking process, additional flag fields are added to the original path point dataset to distinguish collision path points from normal path points. For each collision path point, the deviation angle between its normal direction and the tool posture, as well as the collision type (e.g., direct collision between the tool and the workpiece or fixture interference), are further recorded. The marked path point data is stored in a separate data file to obtain the tool collision path point data.
[0138] Step S55: Use the tool collision path point data to adjust the path point position of the path point-attitude matching data and optimize the tool attitude to obtain collision-optimized toolpath path data.
[0139] This invention utilizes collision path point data to adjust and optimize path point-attitude matching data. First, for path points where collisions occur, the path point spacing or offset is adjusted by recalculating the path point's position coordinates to avoid collisions. For example, when a path point is too close to the part surface, the coordinate values of the path point are adjusted by increasing the distance between the tool and the part. Second, for the adjusted path points, the corresponding tool attitude parameters are recalculated to ensure that the angle between the tool axis direction and the normal vector meets the machining requirements, and the tool rotation angle is optimized to avoid new conflicts. The adjusted and optimized path point and attitude matching data is finally stored as collision-optimized toolpath data.
[0140] This invention performs path and posture matching between preliminary toolpath data and optimized tool posture data, effectively combining the toolpath and tool posture to ensure that the tool can cut in the optimal posture at each path point during the machining process. Through path and posture matching, the correct contact direction and angle between the tool and the workpiece surface are ensured, reducing machining deviations and improving machining accuracy and efficiency. A 3D virtual model of the machining environment is constructed using part 3D model data, tool parameter data, and CNC machine tool parameter data, facilitating accurate simulation of the entire machining process in a virtual environment. This step can intuitively display the tool movement, workpiece state, and CNC machine tool working state during machining, providing a reliable 3D virtual scene for subsequent collision detection and optimization, ensuring machining safety. Based on path point-posture matching data and using the 3D virtual model of the machining environment, tool movement collision simulation is performed, effectively identifying collisions between the tool and other components or workpieces during machining. Through real-time collision detection, damage or errors caused by interference during machining can be avoided, ensuring a safe distance between the tool and the equipment, improving machining safety and quality. By marking and extracting collision path points based on tool collision detection data, collision points can be accurately identified, providing crucial data support for further path optimization. Marking these collision path points clarifies potential risk areas in the machining process, allowing for targeted optimization and preventing potential tool interference at these points. Using the tool collision path point data, path point positions are adjusted based on the path point-attitude matching data, and tool attitude is optimized, thereby eliminating collision risks and optimizing the tool trajectory. This adjustment process ensures a smooth and interference-free tool path, optimizes tool attitude, improves machining efficiency and accuracy, reduces tool-workpiece contact issues, and ultimately enhances overall machining quality and safety.
[0141] Preferably, step S6 includes the following steps:
[0142] Step S61: Perform path point smoothing on the collision-optimized toolpath path data to obtain smoothed optimized toolpath path point data;
[0143] In this embodiment of the invention, when processing collision-optimized toolpath data, path point smoothing is a crucial step in reducing discontinuities or sudden changes between path points. First, the three-dimensional spatial coordinates of each path point and its connection relationships with preceding and following points are extracted from the path point set. For smoothing, common smoothing algorithms, such as Bézier curve smoothing or spline interpolation, are employed to gradually transition drastic changes between path points to smooth curves. Through smoothing, abrupt changes in angle and irregular fluctuations between path points are reduced, thereby optimizing the smoothness of the toolpath. During processing, it is necessary to maintain reasonable path point intervals based on the motion characteristics of the CNC machine tool to ensure that the tool movement does not experience excessive acceleration or deceleration. Finally, smoothed and optimized toolpath point data is output.
[0144] Step S62: Perform tool posture smoothing processing on the smoothed optimized toolpath point data to obtain smoothed optimized tool posture data;
[0145] This invention performs tool posture smoothing processing on the smoothed and optimized toolpath path point data. The purpose is to ensure that the tool moves with a smooth posture during the path movement, avoiding excessively drastic posture changes that could affect machining quality. First, tool posture data, including tool angle and direction, is extracted from the smoothed and optimized toolpath path point data for each path point. Next, the tool posture at each path point is optimized by applying a Kalman filter algorithm or a Lagrange interpolation method to the tool posture data, making the tool posture adjustment between adjacent path points smoother and more gradual, thereby reducing abrupt tool turning or position changes. During posture smoothing, the range of tool posture changes is ensured to be within predetermined constraints to avoid excessive deviation from the original plan. Finally, smoothed and optimized tool posture data is obtained, ensuring that the tool moves along the path with a stable posture.
[0146] Step S63: Perform consistency verification between path points and tool posture on the smoothed and optimized tool posture data to obtain the verified path point-posture data;
[0147] The consistency verification of path points and tool posture in this invention is a crucial step in ensuring that the tool can accurately perform machining based on the position of the path points. First, the three-dimensional coordinates of each path point and the corresponding tool posture data are obtained through path point-posture data. Geometric relationships are used to compare the normal direction of each path point with the direction of the tool posture to ensure that the tool posture is consistent with the normal direction of the part surface. During the consistency verification process, if the tool posture of a path point deviates too much, or if the tool posture is opposite to the normal direction of the part machining surface at some path points, adjustments are required. Through geometric transformation calculations, inconsistent tool postures are adjusted to ensure that the posture of each path point is consistent with the actual machining requirements, ultimately obtaining the verified path point-posture data.
[0148] Step S64: Generate toolpath code based on the verified path point-attitude data to obtain toolpath code;
[0149] In this embodiment of the invention, after verifying the consistency between path points and tool posture, the toolpath code required by the CNC machine tool is generated based on the verified path point-posture data. The toolpath code is typically expressed using G-code or M-code CNC programming languages. Following standard CNC programming language rules, the three-dimensional coordinates of each path point and the corresponding tool posture are output through programming commands. First, for each path point, a corresponding G-code instruction is generated, instructing the machine tool control system to move to a specific coordinate position in space. Simultaneously, instructions for adjusting the tool angle and direction are added based on the verified tool posture data. The generation of the toolpath code must not only consider the accuracy of the path but also ensure that the tool posture is compatible with the control logic of the CNC machine tool. In the generated G-code, each line corresponds to a tool movement operation, and these instructions control the tool to move precisely along the optimized path. Finally, the toolpath code is obtained.
[0150] Step S65: Simulate the toolpath code using the 3D virtual model of the machining environment, and verify its executability and safety. If the verification fails, return to step S62. If the verification passes, obtain the final optimized toolpath data.
[0151] In this embodiment of the invention, after generating the toolpath code, the toolpath code is simulated using a three-dimensional virtual model of the machining environment to verify its executability and safety. First, the generated toolpath code is input into a virtual CNC system, and the tool movement is simulated using virtual machining software. At this time, combined with the three-dimensional virtual model of the machining environment, the tool's movement trajectory during the machining process is monitored in real time, checking for interference or collisions between the tool and the workpiece, fixture, and machine tool. A specialized collision detection algorithm is used to simulate the interaction between the tool movement and the environment at each path point, outputting the detection results. If a tool collision occurs during the simulation or the path does not meet safety requirements, an error message is fed back, and the process returns to step S62 for tool posture smoothing or path adjustment, regenerating optimized path data. If the verification passes, the safety and executability of the path are ensured, and the final optimized toolpath data is obtained.
[0152] This invention performs path point smoothing on collision-optimized toolpath data, helping to eliminate abrupt changes or uneven transitions in the path data and ensuring a smooth transition of the tool during machining. This step, by optimizing the continuity of the path, avoids excessive vibration or unstable movement of the tool during path changes, improving the accuracy, stability, and efficiency of the machining process. Smoothing the tool posture of the smoothed optimized toolpath path point data further optimizes the tool's posture changes throughout the entire path. This step ensures that the tool operates with a reasonable and stable posture throughout the machining path, avoiding machining errors or instability caused by excessively drastic posture changes, thereby improving machining accuracy and tool life. Verifying the consistency between path points and tool posture in the smoothed optimized tool posture data ensures that the tool posture at each path point is highly consistent with the machining requirements. This verification process verifies the matching between the toolpath and tool posture, ensuring accuracy and stability during machining, avoiding unnecessary posture adjustments or errors, and guaranteeing machining quality. Based on the verified path point-posture data, toolpath code is generated, converting the optimized toolpath and tool posture information into code that can be recognized by the CNC machine tool. This process transforms all optimized path data into specific machining instructions, ensuring that the CNC machine tool can execute these instructions correctly and accurately, thereby efficiently completing the machining task. Simulating the toolpath code using a 3D virtual model of the machining environment and verifying its executability and safety can effectively avoid collisions or interference between the tool and the workpiece or machine tool components. Simulation and verification within the virtual model can identify potential problems before actual machining and, by adjusting the toolpath code, avoid safety hazards during machining, ensuring the safety and effectiveness of the machining process.
[0153] Therefore, the embodiments should be considered as exemplary and non-limiting in all respects, and the scope of the invention is not limited by the foregoing description. Thus, all changes falling within the meaning and scope of the equivalents of the application are intended to be included within the scope of the invention.
[0154] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features of the invention herein.
Claims
1. A method for generating a multi-axis NC machining tool path based on a part model, characterized by, Includes the following steps: Step S1: Obtain the 3D model data of the part; A triangular mesh model is constructed based on the 3D model data of the part, and adaptive meshing is performed on the triangular mesh model to generate a refined triangular mesh model; wherein, step S1 includes the following steps: Step S11: Obtain the 3D model data of the part, and perform standardization processing on the 3D model data of the part to obtain standardized 3D model data; Step S12: Discretize the surface of the part based on the standardized 3D model data to obtain the discretized surface data of the part; Step S13: Construct a triangular mesh model using the discretized data of the part surface to obtain a preliminary triangular mesh model; Step S14: Perform discrete curvature calculation on the preliminary three-dimensional mesh model to obtain the surface curvature data of the part; Step S15: Based on the surface curvature data of the part, perform adaptive mesh generation on the preliminary three-dimensional mesh model to obtain an adaptive triangular mesh model; Step S16: Optimize the mesh quality of the adaptive triangular mesh model to obtain a refined triangular mesh model; Step S2: Calculate the normal vectors of each triangle based on the refined triangular mesh model to obtain the triangular mesh normal vector data; Step S3: Design the initial toolpath based on the refined triangular mesh model to obtain the initial toolpath data; Step S4: Optimize the tool attitude of the initial toolpath data using the triangular mesh normal vector data to obtain optimized tool attitude data; Step S4 includes the following steps: Step S41: Perform correlation analysis on the triangular mesh normal vector data and the preliminary toolpath data to obtain path point-normal vector correlation data; wherein, step S41 includes the following steps: Step S411: Extract the three-dimensional spatial coordinates of the path points from the preliminary toolpath data to obtain the three-dimensional spatial coordinate data of the path points; Step S412: Perform triangular mesh patch mapping based on the 3D spatial coordinate data of the path points to obtain path point-mesh patch mapping data; Step S413: Extract the normal vectors of each path point from the triangular mesh normal vector data based on the path point-mesh patch mapping data to obtain the path point-normal vector mapping data; Step S414: Verify the path point-normal vector mapping data, and integrate the path point 3D spatial coordinate data, triangular mesh normal vector data and verification results to obtain path point-normal vector association data; Step S42: Obtain CNC machine tool parameter data, set the tool posture range based on tool parameter data and CNC machine tool parameter data, and obtain tool posture adjustment constraint data; Step S43: Perform preliminary tool posture calculation based on the path point-normal vector correlation data and tool posture adjustment constraint data to obtain preliminary tool posture data; wherein, step S43 includes the following steps: Step S431: Set the initial orientation of the tool posture based on the path point-normal vector correlation data to obtain preliminary tool posture orientation data; Step S432: Adjust the tool posture direction constraint of the preliminary tool posture direction data according to the tool posture adjustment constraint data to obtain the preliminary tool posture constraint data; Step S433: Based on the preliminary tool attitude constraint data, perform adjacent path point attitude interpolation calculation on the preliminary tool attitude direction data to obtain the preliminary tool attitude interpolation data; Step S434: Perform conflict identification on the preliminary tool posture interpolation data, and correct it based on the conflict identification results to obtain the preliminary tool posture data; Step S44: Smooth the initial tool attitude data to obtain optimized tool attitude data; Step S5: Perform collision detection based on the initial toolpath data and optimized tool attitude data, and optimize and adjust the initial toolpath data based on the collision detection results to obtain collision-optimized toolpath data; Step S6: Perform smooth optimization on the collision-optimized toolpath data and convert the toolpath code to obtain the final optimized toolpath data.
2. The method of claim 1, wherein, Step S2 includes the following steps: Step S21: Extract the triangle vertices from the refined triangular mesh model to obtain the triangle vertex coordinate dataset; Step S22: Calculate the triangle normal vector based on the triangle vertex coordinate dataset to obtain the initial triangle normal vector data; Step S23: Standardize the initial triangle normal vector data to obtain standardized triangle normal vector data; Step S24: Smooth the standardized triangle normal vector data to obtain smoothed triangle normal vector data; Step S25: Perform a consistency check on the normal vector direction of the smooth triangle normal vector data and mark the model feature regions to obtain the triangle normal vector data.
3. The method of claim 1, wherein, Step S3 includes the following steps: Step S31: Identify key feature regions on the surface of the part from the refined triangular mesh model to obtain surface feature data of the part; Step S32: Obtain tool parameter data, select toolpath generation strategy based on part surface feature data and tool parameter data, and obtain toolpath generation strategy selection data; Step S33: Use the key feature data of the part surface and the toolpath generation strategy to select data for preliminary toolpath design and obtain preliminary toolpath data.
4. The method of claim 3, wherein, Step S33 includes the following steps: Step S331: Subdivide the key feature data of the part surface into tiny units to obtain subdivided key feature region data; Step S332: Design path points based on the subdivided key feature region data and toolpath generation strategy to obtain coarse toolpath path point data; Step S333: Connect the path points of the roughing toolpath based on the preset machining requirements to obtain the roughing toolpath path segment data; Step S334: Optimize the path segment connection order based on the coarse toolpath path segment data to obtain optimized toolpath path segment data; Step S335: Integrate the optimized toolpath segment data to obtain preliminary toolpath data.
5. The method of claim 1, wherein, Step S5 includes the following steps: Step S51: Perform path attitude matching between the preliminary toolpath data and the optimized tool attitude data to obtain path point-attitude matching data; Step S52: Construct a three-dimensional virtual model of the machining environment using the part's three-dimensional model data, tool parameter data, and CNC machine tool parameter data to obtain the three-dimensional virtual model of the machining environment; Step S53: Based on the path point-attitude matching data, and using the three-dimensional virtual model of the machining environment, simulate the tool motion collision to obtain tool collision detection data; Step S54: Mark and extract collision path points based on tool collision detection data to obtain tool collision path point data; Step S55: Use the tool collision path point data to adjust the path point position of the path point-attitude matching data and optimize the tool attitude to obtain collision-optimized toolpath path data.
6. The method of claim 1, wherein, Step S6 includes the following steps: Step S61: Perform path point smoothing on the collision-optimized toolpath path data to obtain smoothed optimized toolpath path point data; Step S62: Perform tool posture smoothing processing on the smoothed optimized toolpath point data to obtain smoothed optimized tool posture data; Step S63: Perform consistency verification between path points and tool posture on the smoothed and optimized tool posture data to obtain the verified path point-posture data; Step S64: Generate toolpath code based on the verified path point-attitude data to obtain toolpath code; Step S65: Simulate the toolpath code using the 3D virtual model of the machining environment, and verify its executability and safety. If the verification fails, return to step S62. If the verification passes, obtain the final optimized toolpath data.