4.2.1. The Slicing Algorithm Based on Topological Relation
In this section, the initial cladding path was generated from the CAD model based on the topological relations. A series of intersection point sets were obtained using a series of equidistant parallel planes intersecting the CAD model, which was called the slicing process. It was obvious that the process of intersection between the slicing planes and the CAD model was actually to find the intersection between the edges of the triangular facets and the cross planes. After all the intersection points were calculated, they were connected in a certain order to obtain the transversal lines.
In order to reduce the number of intersection calculations and avoid additional time consumption of sorting the intersection point sets, the slicing algorithm was designed based on topological relations of the edges. The core of the slicing algorithm was to constantly search the edge list for the edge that intersected with the current slicing plane and calculate the intersection point. The basic principle of the algorithm is, firstly, to traverse the list of edges to find an edge that intersects with the current slicing plane and, then, to search for next intersected edge in the adjacent edges of this edge according to the topological relation and to keep searching along the given direction until there are no intersected edges or return to the initial edge.
To distinguish the searched edge from the unsearched edge, a Boolean variable named isSearched was declared as an identifier in the data structure of the edge. The value of the identifier for all the edges was initially set as FALSE, which indicates none of the edges have been searched, and then changed to TRUE after being searched. The identifier was greatly useful for ensuring that each edge was accessed only once, which can significantly improve the efficiency of the slicing algorithm.
In addition, there were several important variables, namely the width, direction and range of the slicing process, which needed to be determined before the slicing algorithm was executed. The direction and width of the slicing process were specified by the user according to the specific laser cladding requirements. The range of the slicing process was determined by the maximum and minimum coordinates on the slicing direction in the list of vertices. When the slicing direction was determined, the slicing algorithm automatically calculated the range of the slicing process along the slicing direction.
Take the Z direction for example, the procedure of laser cladding path generation based on topological slicing is shown in
Figure 7, where
d is the slicing width,
Z is the slicing direction and
S is the value of the slicing plane in Z direction. The value of the slicing plane was initially set as the minimum value in Z direction and incremented by the value of the slicing width
d. The slicing process started at the minimum coordinate and ended at the maximum coordinate.
Each single transversal line was generated in the following steps:
Step 1: Find an edge that intersects with the current slicing plane but isSearched is FALSE. Figure out the intersection between this edge and the slicing plane and change isSearched of this edge to TRUE.
Step 2: Find all the adjacent edges of that edge according to the topological relationship between the points, edges and facets. If the isSearched of that edge is FALSE, figure out the intersection between that unsearched edge and the slicing plane; if it is TRUE, skip it.
Step 3: End the search when an unsearched edge cannot be found. Generate the path by joining all the intersections.
This slicing algorithm had two advantages. Firstly, through this method, it only needed to traverse the list of edges once to find the first edge intersecting the first current tangent plane. In the actual slicing process, only the edges contained in the triangular facet intersecting with the current tangent plane were searched and calculated, which greatly reduced the number of intersection calculations. Secondly, the topological slicing algorithm was automatically executed in a definite search direction. The ordered intersection sequence was directly obtained, which avoids the reordering and reconnection of the intersection set and greatly improves efficiency. In this way, the cladding path, which included a set of parallel, equidistant and directed transversal lines, was obtained directly.
To illustrate this procedure further, the pseudocode of this procedure is also given in Algorithm 2.
Algorithm 2: Slicing algorithm based on topological relation. |
- 1
/*Initialization*/ - 2
Set the slicing direction Z and the initial value for d; - 3
Calculate the value of Zmin, Zmax; - 4
/*Find the initial intersection*/ - 5
forS=Zmin : Zmax - 6
if S < Zmax - 7
S = S + d; - 8
Create an Eage variable E; - 9
for i = 1:number of ListEdge - 10
if find an edge that intersects the slicing plane S - 11
Calculate for the intersection P; add P to {Pi}; - 12
Set E as the edge that contains the intersection P; - 13
end for - 14
/*Find the remaining intersection*/ - 15
label: - 16
for j = 1:6 - 17
if find an edge that intersects the slicing plane S from the surrounding edges of E - 18
calculate for the intersection P; add P to {Pi}; - 19
Set E as the edge that contains the intersection P; - 20
goto label; - 21
else - 22
end for - 23
end for - 24
/*Output*/ - 25
{Pi} is output as the set of the intersection.
|
4.2.2. Simplification of the Intersection Data
It is difficult to directly interpolate curves when a curved surface part is processed using laser cladding. In engineering practice, the polyline, which includes multiple point-to-point line segments, is usually used to approximate the real curve line. The intersection points set directly obtained by the slicing algorithm was large and dense, which could not be directly used as the laser cladding processing point set. If it is directly used, the robot program file will be too large to execute, and the robot control system has to perform the interpolation point by point with extremely low efficiency. Furthermore, a greater degree of alloying and large dilution rate will occur during the laser cladding process when the cladding point set is too dense, which would pollute the composition of coatings and destroy its performance [
22,
23]. Therefore, on the premise of processing accuracy, it is essential to simplify the intersection point set and reasonably extract the effective processing points. The arch height error method [
24] was introduced into this investigation as an effective mathematical method to optimize the discrete intersection point set.
The arch height calculation is shown in
Figure 8. Known from the previous section, the set of discrete intersection points {
Pi} was already an ordered sequence. The allowable arch height error
dε was the key parameter that affected the number and density of the final interpolation point set, which determined the accuracy and quality of the final cladding path. In this study,
dε was usually set as the allowable maximum limit value of defocusing change according to specific laser cladding requirements.
The general steps for finding interpolation points are described as the following:
Step 1: Assuming that point Pi of the sequence is selected as the starting point, calculate the distance di+1 from the point Pi+1 to the line PiPi+2.
Step 2: If di+1 > dε, it means that the defocusing change exceeds the allowable range, then add Pi+1 as the valid interpolation point to the set of interpolation points. If di+1 < dε, it means that the defocusing change is within the allowable range, then go to the next step.
Step 3: Connect the Pi and Pi+3 points and calculate the distance from the points Pi+1 and Pi+2 to the line PiPi+3 as di+1 and di+2 respectively. The maximum dmax of the collection of {di+1, di+2} represents the maximum arch height of the arc segment PiPi+3. If dmax > dε, then add Pi+2 as the valid interpolation point to the set of interpolation points. If dmax < dε, continue to search forward until the maximum dmax of the collection of {di+1, di+2, di+3, … di+n} exceeds the allowable arch height error dε, then add the point Pi+n as the valid interpolation point to the set.
Step 4: Repeat Step 1-3, while point Pi+n is selected as the new starting point.
The simplification of the intersection point set usually started with the first point P1 in intersection points set {Pi} and ended with the last point Pm. Through the above method, all the effective processing interpolation points could be found and outputted as a sequence in the original order.
4.2.3. Calculation of the Normal Vector of Cladding Point
In order to facilitate the subsequent calculation of the position and pose of the robot TCP, the normal vector of vertex in the CAD model should be estimated first. The normal vector of each vertex was estimated by adding the normal vector of all triangles in which is located the center of gravity by area [
25]. As shown in
Figure 9,
Aj denotes the area of the triangle,
nj denotes the normal vector of each triangle,
V denotes the common vertex, and
N denotes the normal vector of the common vertex
V. The normal vector
N of vertex
V can be estimated as follows:
This formula indicated that the normal vector of the triangle facet with a smaller area contributed more to the normal vector N of the common vertex V.
The normal vector of the processing interpolation point could be determined by the normal vectors of the two vertices on the edge, on which the interpolation point located. As shown in
Figure 9b,
P denotes an interpolation point,
P1 and
P2 denote two vertices on the edge containing
P, and
N,
n1 and
n2 denote the normal vectors of
P,
P1 and
P2, respectively. The normal vector
N of
P could be calculated using the following equation:
where
l1,
l2 and
l denote the length of the line segment
P1P,
PP2 and
P1P2 respectively. If the slicing plane crossed exactly one vertex, then the normal vector
N of
P was equal to the normal vector of the vertex.