Slicing Algorithm and Partition Scanning Strategy for 3D Printing Based on GPU Parallel Computing

Aiming at the problems of over stacking, warping deformation and rapid adjustment of layer thickness in electron beam additive manufacturing, the 3D printing slicing algorithm and partition scanning strategy for numerical control systems are studied. The GPU (graphics processing unit) is used to slice the 3D model, and the STL (stereolithography) file is calculated in parallel according to the normal vector and the vertex coordinates. The voxel information of the specified layer is dynamically obtained by adjusting the projection matrix to the slice height. The MS (marching squares) algorithm is used to extract the coordinate sequence of the binary image, and the ordered contour coordinates are output. In order to avoid shaking of the electron gun when the numerical control system is forming the microsegment straight line, and reduce metal overcrowding in the continuous curve C0, the NURBS (non-uniform rational b-splines) basis function is used to perform curve interpolation on the contour data. Aiming at the deformation problem of large block components in the forming process, a hexagonal partition and parallel line variable angle scanning technology is adopted, and an effective temperature and deformation control strategy is formed according to the European-distance planning scan order of each partition. The results show that the NURBS segmentation fits closer to the original polysurface cut line, and the error is reduced by 34.2% compared with the STL file slice data. As the number of triangular patches increases, the algorithm exhibits higher efficiency, STL files with 1,483,132 facets can be cut into 4488 layers in 89 s. The slicing algorithm involved in this research can be used as a general data processing algorithm for additive manufacturing technology to reduce the waiting time of the contour extraction process. Combined with the partition strategy, it can provide new ideas for the dynamic adjustment of layer thickness and deformation control in the forming process of large parts.


Introduction
Electron beam additive manufacturing (EBAM) uses metal wires or strips as raw materials to rapidly form metal components with mechanical properties equivalent to castings, and is widely used in the rapid manufacturing of precision blanks for large parts, such as aerospace, automobile manufacturing, etc. [1][2][3][4][5][6][7]. However, with the increase of the area of the forming area, the temperature gradient at both ends of the scanning line increases sharply [8][9][10][11][12][13][14]. When the layer-by-layer accumulated thermal stress exceeds the yield strength of the formed material, it will cause local warpage and deformation of the workpiece. Moreover, the large deformation is not conducive to positioning and cutting in the postprocessing process. Therefore, research on efficient, reliable and stable slicing methods and partition scanning strategies is of great significance to reduce part deformation and improve shape and position accuracy.
Currently, in order to improve the efficiency of data processing and molding accuracy, a large number of research studies on Slicing Algorithm and scanning strategy have emerged. Jaiswal et al. [15] sliced the model along the vertical direction before slicing, then identified the thin wall, sharp corner and other features in the model, and finally quantitatively evaluated the formability of different features to find the best forming direction to improve the forming quality. Pandey et al. [16] deduced the recursive formula of slice thickness according to the step effect and the requirements of the surface roughness of the formed part to realize adaptive slicing. Song et al. [17] used the MS algorithm to slice the implicit surface directly, and the efficiency and accuracy of slicing can be controlled by changing the number of sampling points to avoid the accuracy loss caused by the conversion between the hermit surface and STL file. The above algorithm is the mainstream data processing method in the current additive manufacturing process. During the execution of the algorithm, it is necessary to classify the triangular patches or even establish the topological relationship between the patches, which causes a lot of wasted time. For this reason, this article proposes a direct slicing technology of a 3D model based on GPU computing, which performs parallel coloring according to the normal vector and vertex coordinates of the triangular facets in the STL data, and changes the slice position by adjusting the projection matrix to the slice height. After that, the cross-section binary graph is output according to the intersection result of the ray and the triangular facet. Finally, the MS algorithm is used to complete the contour data extraction. The algorithm does not need to sort and delete triangles, and combines the GPU's concurrency to shorten the contour extraction time.
Manmadhachary et al. [18] used the FFT method to smooth the contour data in the CT image, then used the triangular meshing algorithm to reconstruct and repair the three-dimensional model to improve its surface quality, and finally used the traditional slicing method for slicing. The algorithm has achieved good accuracy in the mandibular model slice test. The above algorithm is mainly suitable for offline processing of the model, and it is difficult to dynamically adjust the process parameters according to the feedback information in the molding process. Jia et al. [19,20] studied the influence of different scanning angles on the deformation of parts under three scanning methods through thermal indirect structural coupling simulation, and found that the 15 • rotating scanning strategy produced the least stress, while this scanning strategy had almost no effect on the size of the molten pool. Chun-YuTsai et al. [21] compared the accumulation of residual stress in the part, under the two forming methods of s-shaped scanning and partition scanning, and found that the partition scanning strategy can clearly reduce the tensile stress of the part boundary. The numerical simulation of the optimization of the partitioning method and the scanning strategy mainly focuses on the influence of the angle change of the filling line on the stress and deformation. It is difficult to carry out large-scale calculations in the simulation of the macroscale scanning sequence, so in-depth research needs to be carried out through experimental means.
Due to the large size of the formed part, the traditional STL slicing algorithm needs a long data processing time in the preprocessing stage, which makes it difficult to meet the deformation control requirements of real-time data adjustment. Moreover, the electron beam additive manufacturing is often combined with the numerical control system, so a large number of line data will lead to frequent acceleration and deceleration of the motor in the forming process, resulting in the phenomenon of "tool shaking". In order to solve the above problems, the research of this article mainly focuses on the following three aspects: (1) The reverse ray tracing algorithm is used to slice the 3D model in parallel, and then the slice position or slice direction is adjusted in real time according to the height feedback information in the forming process. (2) According to the area of the forming layer and the thickness of the part, the number of zones and the scanning sequence of the zones are planned to make the temperature field distribution relatively uniform. (3) The NURBS basis function is used to fit the slice data, combined with the high-order curve processing commands of the CNC system, to reduce the amount of G code transmission while keeping the linear velocity constant.

Slicing Algorithm Based on Reverse Ray Tracing
STL (stereolithography) is one of the main data formats used in additive manufacturing, including ascii format and binary format. The generation process of the STL file is to discretize the three-dimensional surface into triangular patches according to the given triangle tolerance, where the three vertices of the outer patch are stored in counterclockwise order, as shown by the red arrow in Figure 1, and the three vertices of the inner patch are stored in counterclockwise order, as shown by the green arrow in Figure 1.

Slicing Algorithm Based on Reverse Ray Traci
STL (stereolithography) is one of the main d turing, including ascii format and binary format. to discretize the three-dimensional surface into tri triangle tolerance, where the three vertices of the wise order, as shown by the red arrow in Figure 1, are stored in counterclockwise order, as shown by

Reverse Ray Tracing Algorithm
The light of the reverse ray tracing algorithm era, which is different from the object lighting. A value at the intersection of the light and the mode sponding voxel. The algorithm is mainly used in the process of tracking, it needs to iterate along the light until the light intensity is less than the set va In the 3D model slicing, we only need to consider the model, which has nothing to do with informati the refraction and reflection of the light are not When the light intersects the model, the correspon wise white. In order to ensure the accuracy of con tialized according to the requirements for contour The positional relationship between the STL point x can be expressed by formula (1).

Reverse Ray Tracing Algorithm
The light of the reverse ray tracing algorithm is emitted from the location of the camera, which is different from the object lighting. After that, the light intensity and color value at the intersection of the light and the model are tracked and mapped to the corresponding voxel. The algorithm is mainly used in model rendering and other aspects. In the process of tracking, it needs to iterate along the refraction or reflection direction of the light until the light intensity is less than the set value or projected into the environment. In the 3D model slicing, we only need to consider whether the corresponding voxel is in the model, which has nothing to do with information such as color and texture. Therefore, the refraction and reflection of the light are not considered in the calculation process. When the light intersects the model, the corresponding voxel (pixel) is set to black, otherwise white. In order to ensure the accuracy of contour extraction, the field of view is initialized according to the requirements for contour accuracy during the forming process.
The positional relationship between the STL triangle patch and the space coordinate point x can be expressed by Formula (1).
The ray r(d) emitted from the camera position is: where n is the direction vector of the light, and c is the camera position coordinate. When the ray is projected onto the cross-section plane and the projection of the three vertices of the triangular patch satisfies the Formula (3), it means that the ray directed to the pixel point from the viewpoint intersects with the three-dimensional patch. Traverse all the pixels in the field of view in turn to get the binary image of the model at the specified height: where p 1 , p 2 , p 3 is the projection of the three vertices of the triangular facet on the cross-sectional plane, and c is the projection of the light on the cross-sectional plane.

Fast Extraction of the Slice Contour
The electron beam additive manufacturing process is similar to the arc welding technology, but its energy input is higher, and the rapid cooling and heating process in the forming process is more obvious. In order to reduce the stress concentration caused by uneven temperature distribution, current common solutions include using an electron gun to scan and preheat the substrate and partition filling. In the partition filling scheme, the feedback signal for determining whether to partition comes from the model feature recognition. The thin-wall features are filled with parallel lines, and the solid features are filled with partitions and variable angle scan lines. In order to ensure the continuity of the molding process, it is necessary to calculate the filling and scanning methods and slice them before the next layer is processed. The GPU parallel slicing algorithm provides the possibility for a stable and reliable implementation of this method.
According to the visibility judgment result of the triangular patches at each pixel, the template buffer technology is used to render the visible grid as white and the invisible grid as black. It traverses all the pixels in the field of view in turn, and outputs a binary image of the cross-section of the three-dimensional model. Specific steps are as follows: (1) Load the STL file, obtain the bounding box information (length, width, and height) of the 3D model, initialize the field of view according to the length and width of the model, and enable the write function of the template cache; (2) Specify the slice height, and fill the template buffer with unsigned integer data 0, which means that the entire field of view does not need to be drawn; (3) Select the ray emitted from the viewpoint to intersect with all grids in the field of view. When the ray intersects with the forward grid, the value of the template buffer increases by 1, indicating that the pixel needs to be drawn; when the ray intersects with the reverse grid, the value of the stencil buffer decreases by 1, indicating that the pixel does not need to be drawn; (4) After the traversal is completed, the fragments with the value 1 or 2 in the buffer are rendered, and the fragments with the value 0 are discarded.
The Stanford bunny shown in Figure 2 is used as the verification model, the layer thickness is set to 0.2 mm, and the pixel sampling accuracy is 0.1 mm. The accuracy can be set according to the requirements of the forming process. By updating the stencil buffer, color buffer and depth buffer data, the model section is finally stored in the frame buffer in the form of a binary image, and the output is shown in Figure 3.

Fast Extraction of the Slice Contour
The electron beam additive manufacturing process is similar to the arc welding nology, but its energy input is higher, and the rapid cooling and heating process forming process is more obvious. In order to reduce the stress concentration caus uneven temperature distribution, current common solutions include using an ele gun to scan and preheat the substrate and partition filling. In the partition filling sch the feedback signal for determining whether to partition comes from the model fe recognition. The thin-wall features are filled with parallel lines, and the solid featur filled with partitions and variable angle scan lines. In order to ensure the continuity molding process, it is necessary to calculate the filling and scanning methods and them before the next layer is processed. The GPU parallel slicing algorithm provid possibility for a stable and reliable implementation of this method.
According to the visibility judgment result of the triangular patches at each pix template buffer technology is used to render the visible grid as white and the inv grid as black. It traverses all the pixels in the field of view in turn, and outputs a b image of the cross-section of the three-dimensional model. Specific steps are as follo (1) Load the STL file, obtain the bounding box information (length, width, and h of the 3D model, initialize the field of view according to the length and width model, and enable the write function of the template cache; (2) Specify the slice height, and fill the template buffer with unsigned integer d which means that the entire field of view does not need to be drawn; (3) Select the ray emitted from the viewpoint to intersect with all grids in the fi view. When the ray intersects with the forward grid, the value of the template b increases by 1, indicating that the pixel needs to be drawn; when the ray inte with the reverse grid, the value of the stencil buffer decreases by 1, indicatin the pixel does not need to be drawn; (4) After the traversal is completed, the fragments with the value 1 or 2 in the buff rendered, and the fragments with the value 0 are discarded.
The Stanford bunny shown in Figure 2 is used as the verification model, the thickness is set to 0.2 mm, and the pixel sampling accuracy is 0.1 mm. The accurac be set according to the requirements of the forming process. By updating the stencil b color buffer and depth buffer data, the model section is finally stored in the frame b in the form of a binary image, and the output is shown in Figure 3.

Marching Square Contour Extraction Algorithm
Taking the slice shown on the right in Figure 3 as an example, the MS (Marching Square) algorithm is used to calculate all closed contour coordinates. Convert the image data into a two-dimensional grid according to the RGB value of the sampling point coordinates, and mark the color (0, 0, 0) and (255, 255, 255)

Marching Square Contour Extraction Algorithm
Taking the slice shown on the right in Figure

Marching Square Contour Extraction Algorithm
Taking the slice shown on the right in Figure 3 as an example, the MS (Ma Square) algorithm is used to calculate all closed contour coordinates. Convert the data into a two-dimensional grid according to the RGB value of the sampling poin dinates, and mark the color (0, 0, 0) and (255, 255, 255) The above algorithm is programmed in Python, and the slice data of the Stanford bunny is shown in Figure 5. The above algorithm is programmed in Python, and the slice data of the Stanford bunny is shown in Figure 5.

Slice Data Fitting Based on the NURBS Basis Function
The contour generated by STL model slicing is composed of a large number of microsegment straight lines, and the angle between the small lines is determined by the complexity of the model and the discretization accuracy. During the forming process, the forming speed will be reduced at the inflection point of the line segment to ensure the contour accuracy, but it will increase the quality of the metal fed into the molten pool per unit time, and the formation of metal overaccumulation at the inflection point. This phenomenon becomes more and more serious with the decrease of the included angle, as shown in Figure 6. It is found through experiments that when the straight line included angle is greater than 140°, the over-stacking phenomenon is significantly improved. Therefore, the starting point of a small straight line with an included angle of 140° is used as the dividing point to divide the contour data into a straight-line part and a curved part. After removing the adjacent points, repeated points and internal points of the same straight line, the NURBS curve is used to fit the curve part to reduce the number of starts and stops of the motor to ensure a constant linear speed.

Slice Data Fitting Based on the NURBS Basis Function
The contour generated by STL model slicing is composed of a large number of microsegment straight lines, and the angle between the small lines is determined by the complexity of the model and the discretization accuracy. During the forming process, the forming speed will be reduced at the inflection point of the line segment to ensure the contour accuracy, but it will increase the quality of the metal fed into the molten pool per unit time, and the formation of metal overaccumulation at the inflection point. This phenomenon becomes more and more serious with the decrease of the included angle, as shown in Figure 6. It is found through experiments that when the straight line included angle is greater than 140 • , the over-stacking phenomenon is significantly improved. Therefore, the starting point of a small straight line with an included angle of 140 • is used as the dividing point to divide the contour data into a straight-line part and a curved part. After removing the adjacent points, repeated points and internal points of the same straight line, the NURBS curve is used to fit the curve part to reduce the number of starts and stops of the motor to ensure a constant linear speed. The above algorithm is programmed in Python, and the slice data of the Stanford bunny is shown in Figure 5.

Slice Data Fitting Based on the NURBS Basis Function
The contour generated by STL model slicing is composed of a large number of microsegment straight lines, and the angle between the small lines is determined by the complexity of the model and the discretization accuracy. During the forming process, the forming speed will be reduced at the inflection point of the line segment to ensure the contour accuracy, but it will increase the quality of the metal fed into the molten pool per unit time, and the formation of metal overaccumulation at the inflection point. This phenomenon becomes more and more serious with the decrease of the included angle, as shown in Figure 6. It is found through experiments that when the straight line included angle is greater than 140°, the over-stacking phenomenon is significantly improved. Therefore, the starting point of a small straight line with an included angle of 140° is used as the dividing point to divide the contour data into a straight-line part and a curved part. After removing the adjacent points, repeated points and internal points of the same straight line, the NURBS curve is used to fit the curve part to reduce the number of starts and stops of the motor to ensure a constant linear speed.  The BSPLINE interpolation function of SINUMERIK 840D SL can smoothly connect discrete coordinate points through control points and weight factors, and use a speed servo to ensure that the linear velocity is constant during the forming process. Suppose the contour coordinate point generated by the slice is {V k }, k = 0, 1, . . . , n, the node vector is U = {u 0 , u 1 , . . . , u m }, the node corresponding to any coordinate point V k is u k . Therefore, the n + 1 linear equations can be constructed based on n coordinate points as shown in (5).
where the control point C i is the quantity to be determined, and the value range of the node value u k belongs to [0, 1]. Additive manufacturing is mainly used to manufacture parts that cannot be processed or are difficult to process by conventional methods. Most of its models contain complex curves and surfaces, resulting in a high proportion of C 0 continuous sharp points or large curvature transition data points in the slice data. Therefore, the coordinate points are classified before fitting, and then the centripetal parameterization method is used to parameterize the curve [22].
To ensure that the tangents of the curve on both sides of the dividing point are collinear, the first-order derivative vectors at the endpoints are set to F 0 and F n , respectively. The third-order spline curve is used for coordinate point fitting, and the repetition of the curve at the end point is three. u j+d = u j , j = 1, 2, · · · , n − p where u 0 = . . . = u 3 = 0, u n+3 = . . . = u n+6 = 1. Under the above conditions, the equation of the end point of the curve and the first-order derivative equation controlling the direction of the curve are as shown in (8).
Except for the endpoints, the repeatability of each internal node is 1. From the nature of the cubic spline curve, it can be seen that there are at most 3 non-zero basis functions for the node u j , so the n − 1 equations excluding the endpoints can be expressed by (9) where, k = 1, 2, . . . , n − 1, a k = N k,3 (u k ), a k = N k,3 (u k ), a k = N k,3 (u k ). The linear equations with a coefficient of 2 can be solved by (1-3).
0 0 0 · · · a n−2 b n−2 c n−2 0 0 0 · · · 0 a n−1 b n−1 There are no continuous sharp points and large curvature transition segments of C 0 in the slice data of the 118th layer. The data is divided into 5 curve parts with a critical angle of 140 • , and the fitting effect is shown in Figure 7.
There are no continuous sharp points and large curvature transition segmen in the slice data of the 118th layer. The data is divided into 5 curve parts with a angle of 140°, and the fitting effect is shown in Figure 7.

Contour Partition and Scan Filling Strategy
In the forming process of large parts, the temperature gradient is particularly at both ends of the large scan line [23]. The EBAM forming part is a compact blan final part and often requires subsequent finishing processing. Excessive deformat cause the entire part to be scrapped. Therefore, the traditional linear scanning m difficult to apply to this forming process. The research of Lee et al. [24,25] shows temperature gradient and stress concentration can be reduced by partitioning an ning sequence planning, thereby controlling the deformation of the part within a able range.

The Smallest Enclosing Rectangle of Contour Data
Initializing the position of the filling pattern according to the short side leng minimum circumscribed rectangle of the slice contour can greatly reduce the nu calculations. Suppose the initial envelope of a certain contour data is {[x0_min, y0_min y0_max]}, then the minimum value of Equation (11) is the minimum envelope recta quired. π π π , , 10 / 2 , 10 / , 0 A hexagon with side length d is used as the pattern to be filled, and the sh and long side of the envelope rectangle are respectively L1 and L2. If round(L/d) odd number, then L/d + 1 hexagons will be uniformly distributed from the centro of L1 at a distance 1.732d; if round(L/d) + 1 is an even number, then L/d + 2 hexag be uniformly distributed from the centroid point of L1 at a distance 1.732d; The c point coordinates of the hexagon in the L2 direction are updated according to th mosaic rule of the polygon.

Partition Filling and Scanning Strategy
The offset and intersection operation between the hexagon and the contour realized by the polygon clipping algorithm [26]. Before forming, randomly select a onal area represented by a centroid point as the first forming area, and read the y/(mm) Figure 7. NURBS fitting effect of slice data.

Contour Partition and Scan Filling Strategy
In the forming process of large parts, the temperature gradient is particularly obvious at both ends of the large scan line [23]. The EBAM forming part is a compact blank of the final part and often requires subsequent finishing processing. Excessive deformation may cause the entire part to be scrapped. Therefore, the traditional linear scanning method is difficult to apply to this forming process. The research of Lee et al. [24,25] shows that the temperature gradient and stress concentration can be reduced by partitioning and scanning sequence planning, thereby controlling the deformation of the part within a reasonable range.

The Smallest Enclosing Rectangle of Contour Data
Initializing the position of the filling pattern according to the short side length of the minimum circumscribed rectangle of the slice contour can greatly reduce the number of calculations. Suppose the initial envelope of a certain contour data is {[x 0_min , y 0_min ], [x 0_max , y 0_max ]}, then the minimum value of Equation (11) is the minimum envelope rectangle required.
A hexagon with side length d is used as the pattern to be filled, and the short side and long side of the envelope rectangle are respectively L 1 and L 2 . If round(L/d) + 1 is an odd number, then L/d + 1 hexagons will be uniformly distributed from the centroid point of L 1 at a distance 1.732d; if round(L/d) + 1 is an even number, then L/d + 2 hexagons will be uniformly distributed from the centroid point of L 1 at a distance 1.732d; The centroid point coordinates of the hexagon in the L 2 direction are updated according to the plane mosaic rule of the polygon.

Partition Filling and Scanning Strategy
The offset and intersection operation between the hexagon and the contour curve is realized by the polygon clipping algorithm [26]. Before forming, randomly select a hexagonal area represented by a centroid point as the first forming area, and read the coordinates of the centroid point from the memory to ensure that the Euclidean distance between this coordinate and all processed centroids is the smallest. According to this algorithm, the hexagonal partition of the Stanford bunny is shown in Figure 8. this coordinate and all processed centroids is the smallest. According to this algori the hexagonal partition of the Stanford bunny is shown in Figure 8.

Slicing Efficiency
Use python as the slicing kernel to load vertex data in parallel. The computer h ware configuration is as follows: the graphics card is Intel(R)UHD Graphics 630, and GPU memory is 128 Mb. Use δ as the triangular tolerance to output 11 different siz binary STL models Q, and the slicing efficiency is shown in Figure 9.  The efficiency of the GPU slicing algorithm during the entire test was significa higher than that of Cura. The slicing efficiency of commercial software Magics is the h est, and the CPU utilization rate of the stable slicing process is kept at 29.45%, bu process will be stuck during the operation. As the number of triangular patches incre the time to establish the topological relationship between Cura and Magics will grad increase, which is one of the reasons why the slicing time changes approximately e nentially. The GPU slicing algorithm does not need to establish a topological relation and only needs to traverse the voxels at the specified height. As the number of grid creases, the parallel computing causes the GPU utilization to gradually increase, u 93%, so the last model slicing only takes 89.99 s.

Analysis of Curve Fitting Error
The linear and spline basis functions are used to fit the contour coordinates. Th ting effect is shown in Figure 10. The blue curve is the slice contour of the high-prec

Slicing Efficiency
Use python as the slicing kernel to load vertex data in parallel. The computer hardware configuration is as follows: the graphics card is Intel(R)UHD Graphics 630, and the GPU memory is 128 Mb. Use δ as the triangular tolerance to output 11 different sizes of binary STL models Q, and the slicing efficiency is shown in Figure 9. Where δ(mm) ∈ [1, 0.4 this coordinate and all processed centroids is the smallest. According to this algorithm, the hexagonal partition of the Stanford bunny is shown in Figure 8.

Slicing Efficiency
Use python as the slicing kernel to load vertex data in parallel. The computer hardware configuration is as follows: the graphics card is Intel(R)UHD Graphics 630, and the GPU memory is 128 Mb. Use δ as the triangular tolerance to output 11 different sizes of binary STL models Q, and the slicing efficiency is shown in Figure 9.  The efficiency of the GPU slicing algorithm during the entire test was significantly higher than that of Cura. The slicing efficiency of commercial software Magics is the highest, and the CPU utilization rate of the stable slicing process is kept at 29.45%, but the process will be stuck during the operation. As the number of triangular patches increases, the time to establish the topological relationship between Cura and Magics will gradually increase, which is one of the reasons why the slicing time changes approximately exponentially. The GPU slicing algorithm does not need to establish a topological relationship and only needs to traverse the voxels at the specified height. As the number of grids increases, the parallel computing causes the GPU utilization to gradually increase, up to 93%, so the last model slicing only takes 89.99 s.

Analysis of Curve Fitting Error
The linear and spline basis functions are used to fit the contour coordinates. The fitting effect is shown in Figure 10. The blue curve is the slice contour of the high-precision The efficiency of the GPU slicing algorithm during the entire test was significantly higher than that of Cura. The slicing efficiency of commercial software Magics is the highest, and the CPU utilization rate of the stable slicing process is kept at 29.45%, but the process will be stuck during the operation. As the number of triangular patches increases, the time to establish the topological relationship between Cura and Magics will gradually increase, which is one of the reasons why the slicing time changes approximately exponentially. The GPU slicing algorithm does not need to establish a topological relationship and only needs to traverse the voxels at the specified height. As the number of grids increases, the parallel computing causes the GPU utilization to gradually increase, up to 93%, so the last model slicing only takes 89.99 s.

Analysis of Curve Fitting Error
The linear and spline basis functions are used to fit the contour coordinates. The fitting effect is shown in Figure 10. The blue curve is the slice contour of the high-precision model, and it is used here instead of the original contour. The red curve is the slice contour of the medium precision model. The NURBS curve can approach the blue contour line to restore the original data according to the extension trend of the original data. model, and it is used here instead of the original contour. The red cu of the medium precision model. The NURBS curve can approach t restore the original data according to the extension trend of the or Taking the centroid of the enveloping rectangle of the conto point, the polar diameter changes of the three curves are calculate distribution of the fitting data and the slice data. The results are sh error range between the slice data of the medium-precision mod the high-precision model is (−0.2125, 0.1137) mm, and the error r and the slice data of the high-precision model is (−0.0810, 0.0955) m of the contour data is reduced by 34.2% after fitting. Figure 11. Approximation error of sliced data and fitted data.

Conclusions
Aiming at the problem of excessive metal accumulation at th Taking the centroid of the enveloping rectangle of the contour data as the extreme point, the polar diameter changes of the three curves are calculated to represent the error distribution of the fitting data and the slice data. The results are shown in Figure 11. The error range between the slice data of the medium-precision model and the slice data of the high-precision model is (−0.2125, 0.1137) mm, and the error range of the fitted data and the slice data of the high-precision model is (−0.0810, 0.0955) mm. Therefore, the error of the contour data is reduced by 34.2% after fitting.
Materials 2021, 14, x 10 model, and it is used here instead of the original contour. The red curve is the slice co of the medium precision model. The NURBS curve can approach the blue contour li restore the original data according to the extension trend of the original data. Taking the centroid of the enveloping rectangle of the contour data as the ext point, the polar diameter changes of the three curves are calculated to represent the distribution of the fitting data and the slice data. The results are shown in Figure 11 error range between the slice data of the medium-precision model and the slice da the high-precision model is (−0.2125, 0.1137) mm, and the error range of the fitted and the slice data of the high-precision model is (−0.0810, 0.0955) mm. Therefore, the of the contour data is reduced by 34.2% after fitting.

Conclusions
Aiming at the problem of excessive metal accumulation at the inflection point i forming of large parts, NURBS basis functions are used to fit the contour data to ens constant forming line speed. The results show that when the triangle tolerance is on segmental fitting of the slice data through the spline basis function can reduce the co sion error of the STL file by 34.2%, and at the same time reduce the over-stacking nomenon of the inflection point of the straight line. Aiming at the problem of war and deformation caused by too long scanning line length, a partition scanning strate proposed. Planning the scan sequence according to the centroid distance of the par pattern can significantly reduce the length of the scan line in the model, and increas molding time interval of adjacent regions at the same time. Aiming at the dynamic ad

Conclusions
Aiming at the problem of excessive metal accumulation at the inflection point in the forming of large parts, NURBS basis functions are used to fit the contour data to ensure a constant forming line speed. The results show that when the triangle tolerance is one, the segmental fitting of the slice data through the spline basis function can reduce the conversion error of the STL file by 34.2%, and at the same time reduce the over-stacking phenomenon of the inflection point of the straight line. Aiming at the problem of warpage and deformation caused by too long scanning line length, a partition scanning strategy is proposed. Planning the scan sequence according to the centroid distance of the partition pattern can significantly reduce the length of the scan line in the model, and increase the molding time interval of adjacent regions at the same time. Aiming at the dynamic adjustment of the layer thickness of large parts during the forming process, a slicing algorithm based on the reverse ray tracing algorithm is proposed. This algorithm has a high slicing efficiency and can calculate slices and partition filling data in the printing gap. By comparing it with other similar algorithms, it is found that when there are a large number of triangular patches, using the GPU slicing algorithm to load voxel information in parallel can significantly reduce the calculation time. The research results in this paper can provide new ideas for the dynamic adjustment of layer thickness and deformation control in the forming process of large parts.

Institutional Review Board Statement: Not applicable.
Informed Consent Statement: Not applicable.

Data Availability Statement:
The data presented in this study are available on request from the corresponding author.

Conflicts of Interest:
The authors declare no conflict of interest.