Digital twin triaxial milling material removal visualization method based on height map
By employing a heightmap-based digital twin three-axis milling material removal method, combined with GPU parallel computing and a rendering pipeline, the problems of high computational burden and poor visual performance in existing technologies are solved, achieving efficient and intuitive visualization of material removal.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-13
- Publication Date
- 2026-03-27
AI Technical Summary
Existing digital twin machine tool milling material removal visualization methods suffer from problems such as high computational burden, low computational efficiency, high computational memory consumption, and poor performance of cutting edges and curved surfaces, making it impossible to achieve efficient real-time monitoring and prediction.
A heightmap-based digital twin three-axis milling material removal method is adopted. By utilizing GPU parallel computing and heightmap mesh, a digital twin model of the workpiece and tool is established, and the material removal effect is updated in real time by combining the heightmap and rendering pipeline.
It achieves high-resolution, high-visual-quality, and high-real-time visualization of material removal, avoiding mosaic-like cutting edges and inverted trapezoidal milling groove cross-sections, and improving the real-time monitoring effect of the machining process.
Smart Images

Figure CN121746607A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of CNC machining simulation and machine tool digital twin technology, and in particular to a visualization method for material removal in three-axis milling based on height maps. Background Technology
[0002] CNC milling is one of the most widely used material removal methods in the mechanical manufacturing field. With increasing demands for efficiency and precision in CNC milling, real-time visual monitoring during the machining process is essential to promptly detect problems such as tool interference, wear, overcutting, and undercutting. Therefore, real-time monitoring of the CNC machine tool machining process can reduce machining costs and improve machining accuracy.
[0003] Digital twin technology creates a virtual digital twin model of a CNC machine tool and establishes communication with the physical machine tool to collect, analyze, and process data from the machining process. This enables real-time monitoring and even prediction of the milling process's status and outcome. Generally, there are three methods for visualizing material removal during milling simulation using a digital twin machine tool: One method is Boolean operations, which involve performing real-time Boolean operations on the tool and workpiece models in space to visualize material removal. This method offers high precision, producing clear edges on the workpiece. However, due to the large number of triangular faces used in Boolean operations, it suffers from high computational burden and low efficiency. Furthermore, the number of triangular faces in the 3D model increases geometrically after repeated calculations. Therefore, this method is typically only suitable for model shaping and cutting, and cannot be used for real-time milling simulation on digital twin machine tools.
[0004] The second method is the voxel mesh method, which converts a continuous 3D workpiece model into a regular mesh composed of tiny cubes, with each voxel representing a small unit of material. This method does not require direct modification of the mesh, thus enabling real-time simulation of digital twins. However, because the voxel mesh method constructs a cubic mesh, the cutting edges and curved surfaces exhibit obvious steps and mosaic effects, and increasing the mesh resolution significantly increases computational memory consumption. Therefore, this method can only be used for simple visualization simulations of material removal during the milling process in a digital twin machine tool.
[0005] Thirdly, there is the dynamic mesh vertex displacement method, which changes the shape of the workpiece by directly modifying the vertex coordinates of the workpiece mesh. The corresponding vertices in the tool contact area move downwards, achieving material removal. This method is suitable for real-time simulation of material removal in digital twin machine tool milling processes due to its simple code structure and fast computation speed. However, this method does not regenerate mesh vertices; it only modifies the existing mesh. Therefore, when the resolution is limited, a wide slope will form between adjacent cut and uncut vertices, resulting in a noticeably inverted trapezoidal cross-section of the milled groove, which does not match the vertical cross-section of real metal cutting. Therefore, the dynamic mesh vertex displacement method is suitable for visualizing material removal in curved surface machining, but its performance is poor in visualizing material removal in milling slots or holes. Summary of the Invention
[0006] To address the problems existing in the above methods, the purpose of this invention is to provide a visualization method for material removal in three-axis milling based on height maps using digital twins.
[0007] To achieve this objective, the present invention adopts the following technical solution: A heightmap-based digital twin three-axis milling material removal visualization method, comprising the following steps: Step S1: Establish a digital twin model of the workpiece to be milled: Import or generate the workpiece model, establish a regular mesh on the XZ plane of the workpiece at a set resolution, and use a height map to store the workpiece surface height value corresponding to each mesh point; Step S2: Establish a digital twin model of the tool: Import the tool model and define the tool type, geometric parameters, and actual cutting position; Step S3: Execute the material removal visualization algorithm using GPU parallel computing: Using each cell of the height map grid as a thread processing unit, based on the tool type, geometric parameters, and real-time position in the workpiece local coordinate system, determine whether each grid point in the height map is within the tool projection radius. If not, end the processing of that grid point; if it is within the tool projection radius, calculate the theoretical height corresponding to the tool envelope surface at that location and update it to the height value of that grid point. Step S4: Based on the updated height map data, adjust the vertex positions through the GPU rendering pipeline and reconstruct the top surface normals for lighting calculations.
[0008] Preferably, step S1 specifically includes: S1.1 Import or generate a workpiece model, calculate the number of discrete grid points in the X and Z directions of the height field based on the physical dimensions of the workpiece and the simulation resolution, and form a regular grid on the XZ plane of the workpiece. S1.2 Create a two-dimensional floating-point texture as the storage carrier for the height field, with each pixel storing the height value of the workpiece surface at the corresponding grid point; S1.3. Initialize the two-dimensional floating-point texture using the GPU computing shader, and set the height value of each pixel to the initial top surface height of the workpiece; S1.4 Construct a basic mesh model and establish a correspondence between its vertices and the texture coordinates of the height map, thus visualizing the height field data as a three-dimensional geometry.
[0009] Preferably, step S1.4 specifically includes: using a regular grid with the same resolution as the height map on the top of the workpiece, that is, generating a set number of vertices on the XZ plane; using a four-point simplified plane on the bottom surface to cover the entire bottom of the workpiece; and using an appropriate number of vertices to generate rectangular patches along the boundaries of the four side walls.
[0010] Preferably, step S2 specifically includes: importing the tool model; defining the tool type, tool radius, and tool length parameters; converting the tool world coordinates into workpiece local coordinates; and calculating the reference Y coordinate of the tool milling vertex based on the tool length.
[0011] Preferably, step S3 specifically includes: S3.1 In each simulation frame, if a change in tool position is detected, obtain the center position coordinates of the tool in the local coordinate system of the workpiece and trigger the material removal update. S3.2 For the current grid point in the height field, calculate its projected distance d with the tool center on the XZ plane; S3.3 If d is greater than the tool radius R, then keep the height value of the grid point unchanged and end the processing of the grid point; if d is less than or equal to the tool radius R, then calculate the theoretical height of the tool envelope at the grid point according to the tool type and update it to the height value of the grid point.
[0012] Preferably, in step S3.3, the tool type includes a flat end mill and a ball end mill; if the tool type is a flat end mill, the theoretical height is the height of the milling vertex of the tool; if the tool type is a ball end mill, the theoretical height is calculated according to the spherical equation of the ball end mill.
[0013] Preferably, step S4 specifically includes: sampling the corresponding height from the height map texture using a vertex function before rendering, dynamically replacing the y-coordinates of the relevant vertices on the top surface with height map values, and reconstructing the top surface normals based on the modified height map for lighting calculations.
[0014] The beneficial effects of this invention are as follows: by using height maps to reduce the three-dimensional cutting problem to two-dimensional data updates, and by combining the parallel computing and shader capabilities of GPUs, it is possible to simulate the material removal effect of milling in real time at high resolution, and avoid the mosaic problem at the cutting edge and the phenomenon of the milled groove cross section being inverted trapezoidal. Attached Figure Description
[0015] The accompanying drawings further illustrate the present invention, but the content of the drawings does not constitute any limitation on the present invention.
[0016] Figure 1 This is a flowchart illustrating the present invention; Figure 2 This is a schematic diagram of the overall process of one embodiment of the present invention; Figure 3 This is a workpiece model diagram according to one embodiment of the present invention; Figure 4 This is a mesh model diagram of the workpiece after meshing according to one embodiment of the present invention; Figure 5 (a) is a schematic diagram simulating milling operations according to one embodiment of the present invention; Figure 5 (b) is a diagram showing the material removal effect during the milling process according to one embodiment of the present invention. Detailed Implementation
[0017] The technical solution of the present invention will be further described below with reference to the accompanying drawings and specific embodiments.
[0018] This embodiment presents a visualization method for material removal in three-axis milling based on a heightmap, using the Unity engine as the simulation platform and relying on GPU parallel computing and height field representation. The method includes the following steps: S1. The workpiece model can be imported from an external file or generated internally. Based on the set workpiece size and simulation resolution, the height field data structure and initial mesh model of the workpiece are constructed, mainly including the following steps: S1.1. By controlling the parameters of the workpiece script, the physical dimensions and simulation resolution of the workpiece are set. The three-dimensional vectors of the workpiece dimensions represent the physical dimensions of the workpiece along the X, Y, and Z directions, respectively. The simulation resolution is the number of sampling points per unit length. The program calculates the number of discrete grid points in the X and Z directions of the height field based on the above parameters, thereby forming a regular grid on the XZ plane of the workpiece, which is used to construct the Dexel height field.
[0019] S1.2 Utilize the GPU for efficient storage and reading / writing of workpiece height data. Create a two-dimensional floating-point texture as the height field carrier. This texture preferably uses a single-channel floating-point format and enables random write functionality. Each pixel stores a floating-point number, representing the height value of the workpiece surface at the corresponding grid point. The created texture serves as a data carrier shared between the Compute Shader and the Surface Shader.
[0020] S1.3. Use the first kernel function CSInit in Compute Shader to initialize the entire height map. Iterate through all pixels of the height map in a thread group and set the height of each pixel to the initial top surface height of the workpiece.
[0021] S1.4. Construct a basic mesh model on the CPU and establish a correspondence between its vertices and the texture coordinates of the height map, visualizing the height field data as a 3D geometry. A regular mesh with the same resolution as the height map is used on the top of the workpiece, i.e., a set number of vertices are generated on the XZ plane; a four-point simplified plane is used on the bottom surface, covering the entire bottom of the workpiece; rectangular patches are generated along the boundaries of the four side walls using an appropriate number of vertices. The mesh topology remains unchanged throughout the simulation process; only during the rendering stage is the GPU modifying the vertex heights based on the height map.
[0022] S2. Import the external tool model, define parameters such as tool type, tool radius, and tool length through the tool script, convert the tool world coordinates to workpiece local coordinates, and calculate the reference Y coordinate of the tool milling vertex based on the tool length.
[0023] S3. Using GPUs for material removal calculations mainly includes the following steps: S3.1 In each simulation frame, a change in tool position is detected, triggering the main computing kernel to perform material removal and update.
[0024] S3.2 In the kernel, the corresponding physical coordinates are calculated using the grid index. For the Dexel point corresponding to the current thread, the distance d between it and the center of the tool's horizontal projection is calculated. If d is greater than the tool radius R, it is determined that the point is not covered by the tool, and the height at that point is not updated; if d is less than or equal to the tool radius R, the new height is calculated using the corresponding analytical formula based on the tool type.
[0025] Wherein, the distance d between the grid point and the center of the tool's horizontal projection is: at any given time, the center position of the tool in the workpiece's local coordinate system is denoted as C = (C x C y C z Under three-axis machining conditions, the tool axis is parallel to the Y-axis of the workpiece coordinate system. For any grid point in the height field, its planar position in the workpiece coordinate system is denoted as (x...). i ,z j ), calculate the distance d² between this point and the tool center on the XZ plane = (x i C x )² + (z j C z )².
[0026] This example can use both flat end mills and ball end mills: 3.2.1 If a flat-bottom milling cutter is used for machining, the new height of the workpiece is the height of the milling apex of the cutter.
[0027] 3.2.2 If a ball end mill is used for machining, the height of the ball center is the height of the milling vertex of the tool plus the tool radius. The arc-shaped surface of the workpiece after machining is calculated according to the spherical equation.
[0028] S4. To improve the visual quality of the cut surface, this embodiment performs custom normal reconstruction on the top surface pixels in the surface function of the Surface Shader. For fragments marked as the top surface, the Surface Shader samples the height value of the current point on the height map, calculates the gradient components along the X and Z directions based on the height difference, constructs the normal vector in the tangent space and normalizes it, and then assigns the reconstructed normal to the Surface Shader, which is then further physically rendered by Unity's lighting model.
[0029] Through the above implementation methods, the present invention achieves intuitive, continuous, and near-realistic visualization simulation of material removal in three-axis milling processes while ensuring high resolution, high visual quality, and high real-time performance.
[0030] The technical principles of the present invention have been described above with reference to specific embodiments. These descriptions are merely for explaining the principles of the invention and should not be construed as limiting the scope of protection of the invention in any way. Based on this explanation, those skilled in the art can readily conceive of other specific embodiments of the invention without inventive effort, and these embodiments will all fall within the scope of protection of the present invention.
Claims
1. A visualization method for material removal in three-axis milling based on heightmaps, characterized in that, The method includes the following steps: Step S1: Establish a digital twin model of the workpiece to be milled: Import or generate the workpiece model, establish a regular mesh on the XZ plane of the workpiece at a set resolution, and use a height map to store the workpiece surface height value corresponding to each mesh point; Step S2: Establish a digital twin model of the tool: Import the tool model and define the tool type, geometric parameters, and actual cutting position; Step S3: Perform material removal using GPU parallel computing: Using each cell of the height map grid as a thread processing unit, based on the tool type, geometric parameters, and real-time position in the workpiece local coordinate system, determine whether each grid point in the height map is within the tool projection radius. If not, end the processing of that grid point; if it is within the tool projection radius, calculate the theoretical height corresponding to the tool envelope surface at that location and update it to the height value of that grid point. Step S4: Based on the updated height map data, adjust the vertex positions through the GPU rendering pipeline and reconstruct the top surface normals for lighting calculations.
2. The method for visualizing material removal in digital twin three-axis milling based on heightmaps according to claim 1, characterized in that, Step S1 specifically includes: S1.1 Import or generate a workpiece model, calculate the number of discrete grid points in the X and Z directions of the height field based on the physical dimensions of the workpiece and the simulation resolution, and form a regular grid on the XZ plane of the workpiece. S1.2 Create a two-dimensional floating-point texture as the storage carrier for the height field, with each pixel storing the height value of the workpiece surface at the corresponding grid point; S1.
3. Initialize the two-dimensional floating-point texture using the GPU computing shader, and set the height value of each pixel to the initial top surface height of the workpiece; S1.4 Construct a basic mesh model and establish a correspondence between its vertices and the texture coordinates of the height map, thus visualizing the height field data as a three-dimensional geometry.
3. The method for visualizing material removal in digital twin three-axis milling based on heightmaps according to claim 2, characterized in that, Step S1.4 specifically includes: using a regular mesh with the same resolution as the height map on the top of the workpiece, that is, generating a set number of vertices on the XZ plane; using a four-point simplified plane on the bottom surface to cover the entire bottom of the workpiece; and using an appropriate number of vertices to generate rectangular patches along the boundaries of the four side walls.
4. The method for visualizing material removal in three-axis milling based on heightmaps according to claim 2, characterized in that, Step S2 specifically includes: importing the tool model; defining the tool type, tool radius, and tool length parameters; converting the tool world coordinates to the workpiece local coordinates; and calculating the reference Y coordinate of the tool milling vertex based on the tool length.
5. The method for visualizing material removal in digital twin three-axis milling based on heightmaps according to claim 4, characterized in that, Step S3 specifically includes: S3.1 In each simulation frame, if a change in tool position is detected, obtain the center position coordinates of the tool in the local coordinate system of the workpiece and trigger the material removal update. S3.2 For the current grid point in the height field, calculate its projected distance d with the tool center on the XZ plane; S3.3 If d is greater than the tool radius R, then keep the height value of the grid point unchanged and end the processing of the grid point; if d is less than or equal to the tool radius R, then calculate the theoretical height of the tool envelope at the grid point according to the tool type and update it to the height value of the grid point.
6. The method for visualizing material removal in digital twin three-axis milling based on heightmaps according to claim 5, characterized in that, In step S3.3, the tool type includes flat end mills and ball end mills; if the tool type is a flat end mill, the theoretical height is the height of the milling vertex of the tool; if the tool type is a ball end mill, the theoretical height is calculated according to the spherical equation of the ball end mill.
7. The method for visualizing material removal in three-axis milling based on heightmaps according to claim 1, characterized in that, Step S4 specifically includes: sampling the corresponding height from the height map texture using the vertex function before rendering, dynamically replacing the y coordinates of the relevant vertices on the top surface with height map values, and reconstructing the top surface normals based on the modified height map for lighting calculations.