Three-axis NC milling simulation based on adaptive triangular mesh

Three-axis NC milling simulation based on adaptive triangular mesh

Computers & Industrial Engineering 60 (2011) 1–6 Contents lists available at ScienceDirect Computers & Industrial Engineering journal homepage: www...

1MB Sizes 0 Downloads 49 Views

Computers & Industrial Engineering 60 (2011) 1–6

Contents lists available at ScienceDirect

Computers & Industrial Engineering journal homepage: www.elsevier.com/locate/caie

Three-axis NC milling simulation based on adaptive triangular mesh Jian Mao a,*, Shiqing Liu a, Zhu Gao b a b

College of Mechanical Engineering, Shanghai University of Engineering Science, Shanghai, China Changzhou Institute of technology, Changzhou 213002, China

a r t i c l e

i n f o

Article history: Received 10 February 2009 Received in revised form 29 June 2010 Accepted 29 June 2010 Available online 3 August 2010 Keywords: NC milling Real-time simulation Level-of-detail (LOD) Adaptive Triangular mesh

a b s t r a c t NC milling simulation has become an important step in computer aided manufacturing (CAM). To achieve real-time simulation, the total number of polygons has to be reduced, which results in poor image quality. This paper presents an adaptive triangular mesh algorithm to reduce the number of polygons while image quality remains high. Binary tree is used to represent the milling surface, and the optimization of the mesh is performed dynamically in the process of simulation. In this algorithm, the resolution of triangles is automatically updated according to local surface flatness, thus greatly reducing the number of triangles at planar regions. By doing this, real-time and high quality of visual presentation is insured and the translation, rotation and zooming operations are still applicable. When machining precision is evaluated, or overcut, undercut and interference are inspected, full resolution model stored in memory is automatically loaded to ensure the accuracy and correctness of these inspections. Finally, an example is presented to illustrate the validity of proposed algorithm. Ó 2010 Elsevier Ltd. All rights reserved.

1. Introduction NC milling simulation using computer graphics techniques was proposed to prevent the overcut or interference problems in actual NC machining processes. The cutter is moving along the tool path driven by a NC program. As the cutter removing material, intersection operation based on image forms the machining result of the workpiece (Koenig & Groeller, 1998; Liu, Ong, Chen, & Nee, 2006). Traditional NC milling simulation methods are geometric simulation which only consider the geometric information of the cutter and the workpiece and ignore the cutting parameters, cutting forces and other physical factors. The geometric simulation methods can be classified into accurate approach and approximate approach (Glaeser & Gröller, 1997; Hook, 1986; Huang & Oliver, 1994, 1995; Jerard, Hussaini, Drysdale, & Schaudt, 1989; Kawashima, Itoh, Ishida, Nonaka, & Ejiri, 1991; Koenig & Groeller, 1998; Maeng, Baek, Shin, & Choi, 2004; Takafumi & Tokiichiro, 1991; Yang & Lee, 1996). In 1986, Hook (1986) developed a real-time shaded display of a solid model being milled by a cutter that follows the NC path. The workpiece and the cutter are separated into many small rectangular bars extending along the Z-axis respectively, which align the viewing direction, and each small rectangular bar corresponds to a pixel of the screen of a raster display device. A small rectangular bar and its data structure together are called a dexel (depth element). The main advantage of this approach is simple and highly efficient. Since this approach integrates the Boolean operation

* Corresponding author. Tel.: +86 21 67791413; fax: +86 21 67791176. E-mail address: [email protected] (J. Mao). 0360-8352/$ - see front matter Ó 2010 Elsevier Ltd. All rights reserved. doi:10.1016/j.cie.2010.06.016

and display into one step, a high update rate can be obtained in the milling simulation. However, the machining result of this approach has no continuity, and cannot be zoomed in or out. Moreover, it is an image-based approach, the machined workpiece cannot be rotated at any arbitrary angle for viewing. These limitations severely restrict its application in the manufacturing and engineering area. Huang and Oliver (1994) extended this method to overcome those problems. They proposed a contour display approach that can achieve a dynamic viewing transformation of the workpiece. However, the resulting rendered image is coarse, and the gap between adjacent contours is apparent when the workpiece is enlarged. Jerard et al. (1989) proposed an algorithm for simulation and verification of NC machining programs which can be applicable to both three and five axis machining. This paper proposes a three-axis NC milling simulation method using adaptive triangular mesh, which presents our efforts in eliminating the disadvantages while keeping the advantages mentioned above. A binary tree method is used to represent the milling surface. The concrete features of the proposed algorithm are described in the next section.

2. Adaptive triangular mesh simulation method In dexel representation, the surface of a workpiece is divided into many identical small-size bars called dexel. The upper surface of the dexel is divided into two triangles along diagonal line of rectangle, and all these triangles form a mesh representing the machining surface of a workpiece. During the NC milling simulation, the heights of the vertices of a dexel are updated along the

2

J. Mao et al. / Computers & Industrial Engineering 60 (2011) 1–6

tool path, and the rendering of the machined surface is refreshed. This approach is computationally expensive and requires advanced 3D graphics acceleration cards to accelerate the rendering. If the workpiece is very large or the grid size is very small, even modern 3D graphics acceleration cards cannot render the workpiece in real-time. Level-of-detail (LOD) representation is introduced here to efficiently solve the above issue. The basic idea of LOD algorithm is to use multi-resolution triangle mesh to represent the upper surface of a workpiece. LOD algorithms are basically classified into two types, irregular triangle LOD (Garland & Heckbert, 1992; Hoppe, DeRose, Duchamp, McDonald, & Stuetzle, 1993; Low & Tan, 1997; Paul & Charles, 1993) and regular triangle LOD (Lindstrom et al., 1996; Duchaineauy et al., 1997). The algorithm of (Lindstrom et al., 1996) is one of regular LODs that can generate a required LOD mesh efficiently and dynamically. However, there are few explorations of LOD management used in NC milling simulation. Lee and Lee (2002) proposed a local mesh decimation algorithm for view-independent three-axis NC milling simulation. This algorithm can reduce the number of polygons, but it has some drawbacks. At the initial stage, it uses the dexel representation; however, after an overall cutting of the upper surface, the mesh becomes irregular. Liu et al. (2006) developed an approach to reduce the number of polygons without much loss in image quality using regular mesh LOD. Their algorithm can automatically adjust the polygon density to approximate the milling surface according to its changes in real-time, and numerical inspections of any area of the machined surface can be performed with full resolution. Compared with the algorithm proposed in this paper, it is somewhat complicated. The generation of a moderate-sized irregular mesh requires extensive computational effort. Since multi-resolution irregular mesh representations are non-uniform in nature, the intersection between a cutter and a workpiece is difficult to be handled efficiently due to a lack of a spatial organization of the mesh polygons, such that they cannot have high performance for real-time simulation. The proposed approach called adaptive triangular mesh method is used for NC milling simulation which can satisfy all the above criteria. The triangle resolution of different regions varies with the flatness of different regions during the milling simulation, which can greatly reduce the number of triangles at planar regions. Variant triangle resolution speeds up the 3D graphic rendering, while keep the feature of high quality of visualization. Some key features of the algorithm include: flexibility and efficiency resulting from a regular mesh representation, localized polygon densities, and a continuous LOD. It uses a binary tree to present the upper surface of a workpiece, which can control the triangle density of any area of a workpiece to reduce the total number of triangles. Therefore, the image qualities almost are not affected. During the process of simulation, the workpiece can be moved, rotated and zoomed, because the 3D rendering is completely based on polygon mesh. When the inspections of machining error, overcut, undercut and interference are performed, the full resolution model in memory is automatically loaded to perform necessary computation to ensure the accuracy and reliability of measurements and inspections. These features are not possessed by most of commercial NC milling simulation software.

tion. The simulation results can be improved by improving discretization precision, but the rendering speed is slow; on the contrary, the rendering speed can be improved through reducing the discretization precision, but the simulation results are poor. Though the adaptive triangular mesh method can reduce the number of triangles to improve the rendering speed, this process needs the additional calculation. Therefore, the trade-off point should be found. The basic steps of the proposed algorithm are as follows: (1) Discretization of workpiece The surface of workpiece is divided into great many squares with the highest resolution. Those squares constitute an initial mesh. The highest resolution refers to the smallest size of squares, and each square may split into two triangles during the rendering stage. (2) Grouping of vertices To reduce computational complexity, every certain number of squares with highest resolution mentioned above, along x and y directions, are grouped to form a larger square (see Fig. 1). Also, these squares are divided into two triangles along diagonal line. (3) Splitting of triangles All the heights of initial vertices situated on the tool swept volume are updated when the workpiece is machining. Moreover, the triangles intersecting with tool swept volume are splitted into smaller triangles until the precisions meet with the requirements. By this means, the densities vary with the degree of undulation of regions to achieve self-adaptability. (4) Rendering of triangles The triangles generated in Step (3) forming an adaptive mesh are rendered. In this algorithm the density of vertices in initial mesh is high. Hence, the initial mesh cannot be rendered directly, otherwise the real-time performance cannot be guaranteed in simulation. 3.2. Discretization of workpiece and grouping of vertices As shown in Fig. 1, the discretization of workpiece is to divide the upper surface of a workpiece into many little squares with dashed lines. It would be better if the number of squares along x and y axes fulfill 2n, where n is a positive integer, because the computation is efficient to replace multiplication and division operations with shift operations in a program. The vertices of little squares are called initial vertices, and their heights will change during a milling simulation. The initial vertex set is described as:

V 0 ¼ fv ij jv ij ¼ ðxij ; yij ; zij Þg;

NC milling simulation should not depend on the part model. The simulation starts from the definition of workpiece and cutter, and ends up with the completion of machining. Hence, the G codes and related cutting parameters are stipulated before simulation. The traditional dexel simulation method uses uniform discretiza-

j 2 ½0; N

ð1Þ

where M and N are the total numbers of little squares along x and y directions respectively.

The extended mesh boundary

C O2 D

3. The adaptive triangular mesh method based on binary tree 3.1. The overview of algorithm

i 2 ½0; M;

O1 y

B

A

L O

x

The boundary of workpiece

Fig. 1. Discretization and division of workpiece.

L

3

J. Mao et al. / Computers & Industrial Engineering 60 (2011) 1–6

The total number of vertices is (M + 1)  (N + 1). All the little squares form an initial mesh, each square can be split into a couple of triangles for later rendering. The initial vertices are divided into many groups, the size of each group is L  L vertices along x and y axes. The vertices of each group form a larger square region, that is, this region is constituted by (L  1)  (L  1) little square, and this region can be divided into two triangles along the diagonal line for later processing and computation. For those vertices near boundary, if there are not enough vertices to construct a L  L square region, some virtual vertices are added to construct a complete region. For those regions, special operations are needed when rendered. The extended mesh boundary is created after adding the virtual vertices as shown in Fig. 1.

judgment criteria must be established. The splitting process is implemented by traversing the binary trees and geometric error of nodes.

3.3. Splitting of triangles and binary tree

leftZ þ rightZ Dh ¼ centerZ  2

The bold solid lines in Fig. 1 divide the initial mesh into small regions. Each region includes several initial vertices and can be divided into two triangles along the diagonal. Those two triangles are neighbors. The left and right children are created if current triangle splits. The grandchildren are also created if left and right children split, too. This split process can be continued until the resolution of triangles meet a certain precision criterion. The relation of all triangles can be presented by a binary tree. Fig. 2 shows a triangular binary tree. Apparently, it is quick to achieve the expected precision in comparatively flat region, i.e., less triangles are used to present flat region, which results in a smaller number of triangles. While in rough region, much more triangles are required to split to present the details of the machining surface. Fig. 3 shows the neighbor relationships of current triangle. As for data structure, the neighbors are linked each other by pointers. Therefore, the left, right or base neighbors can be found momentarily. When the milling cutter machines from point O1 to O2 as shown in Fig. 1, only A, B, C and D regions intersect with the cutter. If the base triangles of those regions intersect with the cutter and the geometric error exceeds the expectative value, then the splitting operation is carried out. Moreover, the neighbor relationships of triangles are modified in splitting process. To determine whether the base triangles and children triangles need to be split and how many times they need to be split, the

Level 0 Level 1

Root node

Left child

Right child

3.4. Geometric error Taken the primal triangle DABE as an example in Fig. 4, the triangle is DABE before splitting. After splitting the left child DBEF and right child DAEF are created. The geometric error is Dh1 in this splitting which denotes the change of height value in point F. In the case which Dh1 is small enough, the original surface can be fitted well in this position even without splitting the triangle. The geometric error can be defined as following (Lindstrom et al., 1996).

ð2Þ

where centerZ is the height value of midpoint of bevel edge. leftZ and rightZ are the height value of end points of bevel edge. Notably, the following two equations are obtained in Fig. 4.

leftzA þ rightzC Dh5 ¼ centerzE  2

ð3Þ

leftzB þ rightzD Dh6 ¼ centerzE  2

ð4Þ

Generally, Dh5 is not equal toDh6. If a triangle is big, the maximal geometric error may not happen in the midpoint of bevel edge. It may happen in the midpoint of bevel of a little triangle generated by splitting. Therefore, the geometric error of primal triangle cannot be taken as the maximal geometric error, otherwise the error may be too big. To get the maximal geometric error, the binary tree as shown in Fig. 5 must be traversed to some levels. The error value of each node in a binary tree is the maximal error value of the current triangle and its underside triangles. In Fig. 5a the values near the nodes are the geometric errors of current node. The values in the brackets are the maximal geometric errors of current nodes and children nodes. As shown in Fig. 5, suppose the allowed geometric error is 0.2, and all the geometric errors of nodes in the binary tree are traversed, the maximal geometric error is 0.6. Fig. 5b shows the triangle after splitting. The thick solid line is created to eliminate crack. Only the node whose maximal geometric error is larger than the expected value needs to be split.

Level 2 Level 3 Fig. 2. Binary tree of triangles.

D Δh4

E

Left neighbor

Δh3

Right neighbor

Δh5,

C

F

Left child Right child Current triangle Left vertex

A

Δh6

Right vertex Center vertex Base neighbor

Δh1

Δh2

B Fig. 3. The relationships of binary tree in current triangle.

Fig. 4. The geometric error in triangle splitting.

4

J. Mao et al. / Computers & Industrial Engineering 60 (2011) 1–6

0.1(0.6) Level 0 Level 1 Level 2

Root node

0.2(0.4)

0.6(0.6)

0.4

0.2

0.1

0.2(0.4)

0.3

0.6(0.6)

0.3 0.4 0.1(0.6)

Level 3 (a) The geometric errors of nodes in a binary tree

(b) The triangle after splitting according to maximal geometric errors

Fig. 5. The binary tree with geometric errors.

3.5. Crack eliminating When a triangle is split as shown in Fig. 6, the crack comes forth in adjacent region because of the different levels of triangles. Since the levels of the left and right neighbors are higher than those of current nodes, while the base neighbor is of the same level as current nodes, the following rules can be employed to eliminate the cracks. (1) If the current node is a part of the diamond, then the current node and base neighbor are split. (2) If the current node is in the mesh boundary, then only the current node is split. (3) If the current node is not a part of diamond, then the base neighbor is split compulsorily. The compulsory splitting is a process of recursion until there exists a node which is a part of diamond or in the mesh boundary. The process is as follows. The current node is checked whether it is a part of the diamond. If no, then the base neighbor of current node is split and the splitting operation continues. The same check is applied to the base neighbor. The previous processes are iterated until the return condition is satisfied. Fig. 7 shows the process of compulsory splitting of the nodes. The gray triangle in left corner is to be split. The base neighbor is split recursively. By doing this, the two down triangles form a diamond shape. Therefore, the recursion is ended and each node is split.

3.6. Mesh rendering As shown in Fig. 5 the subsequent traversal is applied from the root node of binary tree to left and right children. When the maximal geometric error is bigger than the expected value, then this node is split to generate the left and right children. Thereafter, the nodes of those two children continue to split until the maximal geometric error of current node is smaller than expected value or they are leaf nodes. Then the nodes are back tracked according to the traversal sequence of binary tree. And the other nodes are continued to be traversed, but the splitting process should follow the previous crack eliminating approach. The splitting triangles are queued and render in sequence.

Fig. 7. The compulsory splitting of nodes.

However, when the nodes at the workpiece boundary are rendered, special operation is required. As shown in Fig. 8, the black continuous thick lines are the workpiece boundary and solidcum-broken gray lines are the extended boundary. To ensure the size of workpiece is unchangeable, the triangles which are at the boundary or out of the boundary are also need special operation. For those triangles located at the most right or most topside square regions. The rendering strategies are as follows: (1) When the triangle is totally within the workpiece boundary, then the triangle is rendered wholly. (2) When the triangle is out of the workpiece boundary, then the triangle is not rendered. (3) When some part of the triangle is at the workpiece boundary and some is out of the workpiece boundary, the vertices in the workpiece and boundary are linked to construct a polygon, and then this polygon is rendered anticlockwise. For example, only some part of DABC is in the workpiece in Fig. 8, the nodes of A, B, E and D construct a polygon. Then the polygon is rendered. 4. Simulation results An example of ellipsoidal surface is used to illustrate the proposed algorithm. Fig. 9 shows the wire frame and Fig. 10 shows

A

N2

N1

N2

D N1

N3

C E

N3

B Fig. 6. The crack in the adjacent region (gray region).

Fig. 8. Triangle rendering at workpiece boundary.

5

J. Mao et al. / Computers & Industrial Engineering 60 (2011) 1–6

( a ) 3D vi e w

(b) Top view Fig. 9. Wire frame of the adaptive mesh.

The black curve in Fig. 12 shows how the frame rate varies as the simulation proceeds. The frame rate of approximately 37 fps is sustained eventually by analyzing the trend of the curve. The variation of the computation time and the number of triangles 1000 Total time Rendering time Evaluation time 100

Time (ms)

the 3D rendering image. As shown in Fig. 9, the density of triangles is thick at the brim of ellipsoidal surface because of big fluctuations, while the density of triangles is rare at the smooth surface. The personal computer used for this simulation was equipped with an Intel Pentium 4 Willamette 3.60 GHz processor, an ATI RADEON X600 graphics controller and a 1 GB memory stick. The initial resolution of the mesh is 512  512 units. The radius of the ball-end milling cutter is six units and the geometric error is 0.01 unit. The NC milling program had a total of 8806 blocks of tool movement commands. All the data are sampled at No. 7000 block of tool movement commands except for special declaration. Although the workpiece can be rotated and moved at any time, the workpiece is completely fixed during the milling operation to get test data. The number of triangles is first examined as a function of the geometric error. Fig. 11 shows the variation of evaluation and rendering times as the geometric error increases. The curve is also drawn on a logarithmic scale (vertical axis). Evaluation time is the total times that include the evaluating times of geometric error of binary tree and splitting times. It can be seen that the evaluation time is only a small fraction of the rendering time. Therefore, how to reduce the rendering time is an important process.

10

1 0.000 0.004 0.008 0.012 0.016 0.020 0.024 0.028 0.032 0.036 0.040

Threshold(Geometric error) Fig. 11. Rendering times and evaluation times and their sum times. 70

The proposed method The method in [2]

Frame rate (frame/sec.)

60

50

40

30

20 0

1000

2000

3000

4000

5000

Step No. Fig. 10. 3D rendering result.

Fig. 12. The comparison of frame rate.

6000

7000

6

J. Mao et al. / Computers & Industrial Engineering 60 (2011) 1–6

has resulted in the fluctuation of the curve. Compared with the method presented in the work of Liu et al. (2006), the performance of the method proposed in this paper is better with the same circumstance including milling the same part, the simulation result shows that two methods can produce same rendering quality, but the frame rate of the proposed method is 11 fps faster than that of Liu et al. (2006). 5. Conclusions In this paper, we propose an adaptive regular mesh algorithm to achieve high frame rates for three-axis NC milling simulation. Our approach can achieve optimization for fast rendering since the total number of triangles for rendering has been reduced significantly and the triangle density can be adjusted. It can also provide the capabilities for sustaining consistent frame rates as the direct relationship between the single threshold and the number of triangles to be rendered exists. Any area of the machined workpiece can be inspected with full resolution, such as an overcut, undercut or error assessment. Moreover, during a milling process simulation, the workpiece can be translated, rotated, zoomed in/out, or measured, which is especially important for virtual reality or augmented reality applications. In a virtual reality or augmented reality environment, the machinist will observe the milling process from different directions, and the distance between the machinist and the workpiece is always varying. References Duchaineauy, M., Wolinsky, M., Sigeti, D. E., Mill, M. C., Aldrich, C., & Weinstein, M. B. (1997). ROAMing terrain: real-time optimally adapting meshes. IEEE Visualization Proceedings, 81–88. Garland, M. & Heckbert, P. S. (1992). Surface simplification using quadric error metrics. In Proceedings of SIGGRAPH (pp. 209-216).

Glaeser, G. & Gröller, E. (1997). Efficient volume generation during the simulation of NC-milling. Technical Report at the Institute of Computer Graphics and Algorithms, Vienna University of Technology. Hook, T. V. (1986). Real time shaded NC milling display. Computer Graphics, 20(4), 15–20. Hoppe, H., DeRose, T., Duchamp, T., McDonald, J., & Stuetzle, W. (1993). Mesh optimization. In Proceedings of SIGGRAPH (pp. 19–26). New York: ACM Press. Huang, Y. & Oliver, J. H. (1994). NC milling error assessment and tool path correction. In Computer graphics proceedings (pp. 287–294). Huang, Y., & Oliver, J. H. (1995). Integrated simulation, error assessment, and tool path correction for five-axis NC milling. Journal of Manufacturing System, 14(5), 331–344. Jerard, R. B., Hussaini, S. Z., Drysdale, R. L., & Schaudt, B. (1989). Approximate methods for simulation and verification of numerically controlled machining programs. The Visual Computer, 5(6), 329–348. Kawashima, Y., Itoh, K., Ishida, T., Nonaka, S., & Ejiri, K. (1991). A flexible quantitative method for NC machining verification using a space-division based solid model. Visual Computer, 7, 149–157. Koenig, A. H., & Groeller, E. (1998). Real time simulation and visualization of NC milling processes for inhomogeneous materials on low-end graphics hardware. In Proceedings of the computer graphics international (pp. 338–349). Washington: IEEE Computer Society. Lee, S. H., & Lee, K. S. (2002). Local mesh decimation algorithm for viewindependent three-axis NC milling simulation. International Journal of Advanced Manufacturing Technology, 19, 579–586. Lindstrom, P., Koller, D., Ribarsky, W., Hodges, L. F., Fanst, N., & Turner, G. A. (1996). Real-time continuous level of detail rendering of height fields. In Proceedings of SIGGRAPH (pp. 109–118). Liu, S. Q., Ong, S. K., Chen, Y. P., & Nee, A. Y. C. (2006). Real-time, dynamic level-ofdetail management for three-axis NC milling simulation. Computer-Aided Design, 38, 378–391. Low, K. L. & Tan, T. S. (1997). Model simplification using vertex-clustering. In Proceedings of SIGGRAPH (pp. 75–81). Maeng, S. R., Baek, N., Shin, S. Y., & Choi, K. Y. (2004). A fast NC simulation method for circularly moving tools in the Z-map environment. In Proceedings of geometric modeling and processing (pp. 319–330). Washington: IEEE Computer Society. Paul, H. & Charles, H. 1993. Geometric optimization. In Proceedings of visualization (pp. 189–195). Takafumi, S., & Tokiichiro, T. (1991). NC machining with G-buffer method. In Proceedings of 18th annual conference on computer graphics and interactive techniques (pp. 207–216). New York: ACM Press. Yang, M., & Lee, E. (1996). NC verification for wire-EDM using an R-map. Computer Aided Design, 28(9), 733–740.