Search

CN-121544778-B - Processing surface quality visualization method based on GPU and grid search algorithm

CN121544778BCN 121544778 BCN121544778 BCN 121544778BCN-121544778-B

Abstract

The invention discloses a processing surface quality visualization method based on a Graphic Processing Unit (GPU) and a grid search algorithm, which belongs to the technical field of machining and comprises the steps of obtaining cutter point cloud data, performing discretization processing to construct a three-dimensional grid structure surrounding point cloud, linearly mapping the three-dimensional grid data into a one-dimensional array, completing packaging, creating four types of structured GPU calculation buffer areas to realize batch data transmission, realizing parallelization data access and local neighborhood quick query by using a GPU shader program, completing high-precision real-time reconstruction of normal vectors of a chip element surface by neighborhood search and signed projection distance calculation, and outputting a realism rendering result based on an optimized Phong illumination model. The method plays the advantages of GPU parallel computing, accurately restores the processing surface characteristics of complex textures, microstructures, special curved surfaces and the like, and is suitable for surface quality detection, abrasion assessment and process optimization of milling parts and tools.

Inventors

  • SHEN BIN
  • YUE TING
  • Xu Lianyuan
  • ZHANG HAOBO
  • CHEN SULIN

Assignees

  • 上海交通大学

Dates

Publication Date
20260505
Application Date
20260121

Claims (8)

  1. 1. The processing surface quality visualization method based on the GPU and the grid search algorithm is characterized by comprising the following steps of: S1, acquiring cutter point cloud data, performing file reading and discretization processing, dividing a point cloud space into uniform three-dimensional grid structures, and distributing each point and normal vector thereof into corresponding grid units; S2, performing three-dimensional to one-dimensional linearization mapping and data packaging on the point cloud data; s3, creating a GPU calculation buffer area, and transmitting the packaged data of the CPU end to a GPU video memory in batches; s4, implementing parallelization data access and quick query through a GPU shader program; S5, constructing a nearest neighbor search algorithm based on grid acceleration for high-precision real-time reconstruction of point cloud surface normal vectors in a fragment shader, and reconstructing accurate surface normal vectors for each rendering fragment in parallel in a GPU shader program; s6, optimizing a Phong illumination model for real-time coloring of the point cloud surface, and synthesizing final surface color output through linear superposition of three physical components of ambient light, diffuse reflection light and specular reflection light.
  2. 2. The method for visualizing the quality of a processing surface based on a GPU and a grid search algorithm as recited in claim 1, wherein in S1, the method specifically comprises the steps of: S11, extracting coordinates of tool point cloud data, wherein the coordinates comprise three-dimensional space coordinates of each point and corresponding surface normal vectors; s12, traversing all data points, calculating the axial boundary of the point cloud in a three-dimensional space, determining the minimum boundary coordinate and the maximum boundary coordinate of the point cloud, and further defining a cube bounding box capable of completely bounding all the point cloud; S13, according to grid division granularity parameters preset by a user, uniformly dividing the cube bounding box into a series of regular three-dimensional grid cells in a three-dimensional space, wherein the physical size of each grid cell is obtained by dividing the total size of the cube bounding box by the number of grids in each direction, and the calculation formula of the physical size of each grid cell in the X direction is as follows: BoxSizeX=(Xmax Xmin)/GridSizeX (1); wherein BoxSizeX denotes the length of a single grid cell in the X direction, xmax and Xmin denote the maximum and minimum coordinate values of the cube bounding box in the X direction, gridSizeX denotes the number of grids in the X direction; S14, calculating the size of each direction according to the formula (1), and setting the space origin of the grid system as the minimum boundary coordinate; After the division is completed, the system constructs a three-dimensional grid container PointsBox for storing the coordinates of the points falling into each grid unit, and constructs a parallel three-dimensional normal vector container NormalsBox for storing the corresponding normal vectors.
  3. 3. The method for visualizing the quality of a processing surface based on a GPU and a grid search algorithm according to claim 2, wherein in S2, to adapt to a linear memory model of the GPU, the three-dimensional grid structure is converted into a compact one-dimensional array format, comprising the steps of: S21, converting each three-dimensional grid unit into a continuous one-dimensional index GridIndex, wherein the conversion formula is as follows: (2); Wherein GridIndex represents the number corresponding to the conversion of the three-dimensional grid into the one-dimensional grid, x, y and z represent the numbers of the grid in three dimensions, and GridSizeX, gridSizeY, gridSizeZ represents the grid numbers in the x, y and z directions respectively; s22, traversing all grid cells one by one, sequentially storing all point coordinate data stored in each cell into a one-dimensional point coordinate array FlatPointArray, and sequentially storing all normal vector data corresponding to the point coordinate data into a one-dimensional normal vector array FlatNormalArray; s23, synchronously constructing a key point index buffer PointIndexBuffer which is a one-dimensional array and has the length equal to the total grid number, wherein the value stored in each position GridIndex represents the initial position of the point data contained in the corresponding grid unit in the one-dimensional point coordinate array, and the structure provides an important mapping relation for the GPU end to quickly position the point data in any grid.
  4. 4. A method of visualizing a surface quality of a process based on a GPU and a grid search algorithm as in claim 3, wherein in S3 the GPU calculation buffer comprises 4 structured calculation buffers: The point coordinate buffer PointBuffer is bound to the packed one-dimensional point coordinate array and is used for storing the three-dimensional space position information of all points; The normal vector buffer NormalBuffer is bound to the packed one-dimensional normal vector array and is used for storing three-dimensional normal vector information corresponding to all points; A grid information buffer GridInfoBuffer, which stores a structure defining global parameters of the grid system, including a grid origin GridOrigin, the number of grids in each dimension, the physical size BoxSize of the grid cells, and the total number TotalPoints of point clouds; the point index buffer PointIndexBuffer is used for storing a point index mapping relation array so as to realize rapid positioning from grid indexes to point cloud data; The 4 structured calculation buffers are used for transmitting the packaged data of the CPU end to the GPU video memory in one batch through ComputeBuffer interfaces provided by the Unity engine, so that huge performance overhead and communication delay caused by point-by-point transmission in the traditional method are avoided, and the transmission efficiency of large-scale point cloud data is improved.
  5. 5. The method for visualizing the processing surface quality based on the GPU and the grid search algorithm according to claim 4, wherein in S4, the specific process is that in a Shader program loader of the GPU, 4 structured calculation buffers in S3 are accessed in parallel and efficiently through StructuredBuffer interfaces, when a certain point in world space is required to be rendered, the Shader uses grid index calculation which is inverse to formula (2) to quickly determine a grid unit where the point is located, and by means of the initial position recorded in the point index buffer, the Shader immediately locates point cloud data of the grid unit in a one-dimensional array, and rapidly reduces the search range from global point cloud to local neighborhood.
  6. 6. The method for visualizing the quality of a surface being processed based on the GPU and the grid search algorithm as recited in claim 5, wherein in S5, the method specifically comprises the steps of: S51, determining the world space position of the fragment and the grid unit to which the fragment belongs, wherein each fragment carries three-dimensional coordinate information in world space when the fragment shader is executed, calling GETGRIDCELL functions, converting world coordinates into a grid coordinate system, specifically, obtaining local coordinates by subtracting grid origin coordinates GridOrigin from the world coordinates of the fragment, dividing each component of the local coordinates by the physical size BoxSize of the grid unit, and executing a downward rounding floor operation to obtain three-dimensional grid unit index coordinates to which the fragment belongs, wherein the step is the key of discretizing continuous space inquiry into accurate grid indexes; S52, performing local search based on a 3X 3 neighborhood range, namely adopting a 3X 3 cube neighborhood taking a current grid cell as a center as a search range, limiting the search range from the whole point cloud data set to at most 27 adjacent grid cells, and reducing the computational complexity; S53, quickly locating point cloud data in candidate grid cells and calculating projection distance, namely, for each candidate grid cell, calling GetPointBoxIndex a function, converting three-dimensional cell coordinates of the candidate grid cell into corresponding one-dimensional indexes according to a formula (2), inquiring a point index buffer area pointIndexBuffer, acquiring a start index and an end index of point data stored in the cell in a point coordinate buffer area PointBuffer, and accurately locating and traversing all stored points in the cell; the method comprises the following steps of taking the current world space position of a patch as a starting point, projecting the patch to the local surface where a candidate point is located along the opposite direction of the current normal vector direction, and calculating a distance value dist according to the following formula: dist=dot ((voxel position) Candidate point location), current normal vector PointRadius (3); PointRadius is a preset point radius parameter for correcting surface reconstruction deviation caused by the sparsity of point cloud data, wherein the distance value is a signed value, and the situation that the fragment is positioned on the front surface and the back surface of the point can be effectively distinguished; And S54, selecting an optimal adjacent point and assigning normal vectors thereof, namely traversing all candidate points in all 27 candidate grid cells, continuously tracking and recording a minimum projection distance value minDist and a corresponding candidate point index, taking out the normal vector corresponding to the candidate point with the minimum projection distance from a normal vector buffer NormalBuffer after the whole local search is finished, and assigning the normal vector as a final surface normal vector finalNormal of the current element, wherein the mechanism ensures that each element can acquire accurate orientation information from the nearest adjacent and most relevant surface points.
  7. 7. The method for visualizing the quality of a processing surface based on the GPU and the grid search algorithm as recited in claim 6, wherein in S6, the method specifically comprises the steps of: S61, carrying out dynamic consistency correction on the normal vector direction, namely carrying out direction consistency check and correction on the reconstructed surface normal vector to ensure the correctness of illumination calculation, wherein the specific method is to construct a branching-free correction algorithm based on symbol function simulation, and the core operation of the branching-free correction algorithm is as follows: (4); Wherein, the built-in step function judges whether the dot product of the normal vector and the sight line direction eyeDir is more than or equal to 0, if the dot product is non-negative, the step returns to 1, and the following steps are carried out 2.0-1.0, The multiplier factor is +1, the normal vector direction remains unchanged, if the dot product is negative, step returns to 0, the multiplier factor becomes-1, the normal vector direction will be automatically reversed, the process avoids flow control instruction, and ensures the execution efficiency of GPU shader units; S62, respectively calculating three components of the Phong illumination model and performing linear superposition, wherein the three components comprise an ambient light component, a diffuse reflection component and a specular reflection component; S63, performing validity check and clamping of a color output range, namely processing a final color by adopting a component limiting algorithm, comparing components of three synthesized RGB color channels with an upper limit value of 1.0 respectively, and taking a minimum value, wherein the expression is as follows: (5); The step ensures that the color value output to the screen frame buffer area is always in the range of [0,1] which is legal and can be correctly interpreted by the equipment, and ensures the color accuracy and visual stability of the final rendered image.
  8. 8. The method for visualizing a surface quality of a process based on a GPU and a grid search algorithm as recited in claim 7, wherein in S62, the three components are calculated as follows: The ambient light component calculation is used for simulating global indirect illumination in a scene, providing basic brightness for the surface and preventing the complete backlight area from sinking into pure black, and the calculation process is that a fixed coefficient is set to 0.2 and is directly multiplied by the basic color BaseColor of the object surface, namely the object=0.2 Col, this component is independent of both the direction of the light and the viewing angle; The diffuse reflection component calculation is to follow the Law of Lanbert cosine for simulating the uniform scattering of light on rough surface, the intensity depends on the cosine of the angle between the normal vector of the surface and the direction of incident light, the light direction lightDir is-rayDirection opposite to the direction of line of sight, the dot product ndotl of the normal vector and the direction of light is calculated first, and is clamped in the non-negative range of [0,1] by max function, and finally the diffusion light is obtained by multiplying the basic color, namely diffuse=max (dot (normal, lightDir), 0.0 col; The specular reflection component calculation is used for simulating high-light flare on a smooth surface and enhancing the material texture of an object, the calculation process is that the ideal reflection direction r of light rays is calculated by using a reflection function according to the incident light direction and the normal vector of the surface, the cosine value rdotv of the included angle between the reflection direction and the sight direction v is calculated to be nonnegative through a max function, finally the cosine value is obtained to be a high power, called glossiness index, and is set to be 32 and then is multiplied by a specular intensity parameter to be 0.15, and the specular light color is obtained, so that specular reflection light is obtained, namely specular =pow (max (r, v), 0.0 and 32.0 float3(1.0) The higher the gloss index, the more concentrated and sharp the highlight region; The three components are linearly overlapped to obtain a primary synthesized color: result=ambient+diffuse+specular。

Description

Processing surface quality visualization method based on GPU and grid search algorithm Technical Field The invention relates to the technical field of machining, in particular to a processing surface quality visualization method based on a GPU and a grid search algorithm. Background In the precise machining processes such as milling, grinding and the like, the quality of the machined surface directly influences the service performance and the service life of the part, so that the method has important significance for accurately evaluating and visualizing the surface morphology. Especially for parts with complex molded surfaces and high-quality surface requirements such as aero-engine blades, precision dies and the like, the surface integrity standard is severe, and the processing out-of-tolerance is more likely to cause the rejection of the whole part, so that great economic loss is caused. Therefore, the method has the key effects of optimizing process parameters and controlling surface states by effectively predicting and visually analyzing the surface quality in the process planning stage. The existing mainstream processing surface quality evaluation method has two limitations that firstly, a traditional evaluation system based on two-dimensional contours or statistical parameters is difficult to completely characterize the three-dimensional surface morphology with complex texture, anisotropy and microstructure characteristics, visual reflection on the real morphology is lacking, and secondly, the existing visualization means depend on discrete point clouds or simplified geometric models, high-reality and interactive microscopic morphology rendering cannot be realized, and deep application of the method in process optimization and defect detection is limited. Disclosure of Invention The invention aims to provide a processing surface quality visualization method based on a GPU and a grid search algorithm, which is used for carrying out high-precision three-dimensional morphology rendering and visual evaluation on the surface of a milling part with any geometric shape and providing a general solution for realizing real reproduction and depth analysis of the processing surface quality. In order to achieve the above object, the present invention provides a processing surface quality visualization method based on a GPU and a grid search algorithm, comprising the steps of: S1, acquiring cutter point cloud data, performing file reading and discretization processing, dividing a point cloud space into uniform three-dimensional grid structures, and distributing each point and normal vector thereof into corresponding grid units; S2, performing three-dimensional to one-dimensional linearization mapping and data packaging on the point cloud data; s3, creating a GPU calculation buffer area, and transmitting the packaged data of the CPU end to a GPU video memory in batches; s4, implementing parallelization data access and quick query through a GPU shader program; S5, constructing a nearest neighbor search algorithm based on grid acceleration for high-precision real-time reconstruction of point cloud surface normal vectors in a fragment shader, and reconstructing accurate surface normal vectors for each rendering fragment in parallel in a GPU shader program; s6, optimizing a Phong illumination model for real-time coloring of the point cloud surface, and synthesizing final surface color output through linear superposition of three physical components of ambient light, diffuse reflection light and specular reflection light. Preferably, in S1, the method specifically includes the following steps: S11, extracting coordinates of tool point cloud data, wherein the coordinates comprise three-dimensional space coordinates of each point and corresponding surface normal vectors; s12, traversing all data points, calculating the axial boundary of the point cloud in a three-dimensional space, determining the minimum boundary coordinate and the maximum boundary coordinate of the point cloud, and further defining a cube bounding box capable of completely bounding all the point cloud; S13, according to grid division granularity parameters preset by a user, uniformly dividing the cube bounding box into a series of regular three-dimensional grid cells in a three-dimensional space, wherein the physical size of each grid cell is obtained by dividing the total size of the cube bounding box by the number of grids in each direction, and the calculation formula of the physical size of each grid cell in the X direction is as follows: BoxSizeX=(XmaxXmin)/GridSizeX (1); wherein BoxSizeX denotes the length of a single grid cell in the X direction, xmax and Xmin denote the maximum and minimum coordinate values of the cube bounding box in the X direction, gridSizeX denotes the number of grids in the X direction; S14, calculating the size of each direction according to the formula (1), and setting the space origin of the grid system as the minimum bo