In this section, the development of the algorithm is discussed in detail. There are two distinct activities; viz, optimized forming orientation, formability assessment using color map of wall angle and sheet thickness reduction. The detail of the development process for each algorithm is also presented.

## 2.1 Overview of the Proposed Algorithm

In this proposed algorithm, the required CAD model to be formed is given as an input in STL(ASCII) format, where the model is represented using discretized triangles and normal vectors [7–9]. First, the optimum forming orientation of a CAD model is found by evaluating the formability at two axes. To obtain this optimized orientation, designated evaluation criteria are chosen: forming angle limit, and critical area which is the total triangle area in a CAD model in which its angle is more than the forming angle limit. During the evaluation process, first the algorithm will check all the angles in the STL file are less than forming angle limit. If this criterion is being satisfied, the evaluation process will stop here, and the same evaluation process will be carried out for same CAD model in different orientation. Otherwise, the algorithm will evaluate the critical area of the CAD model by performing the summation of the area in a CAD model in which its angle is more than the angle limit.

Second, the CAD model is analyzed using the color map, to visually inspect at the potential forming errors in the CAD model, such as high forming wall angle or high thickness reduction, and decide whether or not to form the part using ISF. It is suggested to redesign the CAD model if high wall angle or high thickness reduction is seen from the color map.

The following steps summarize the overview function and working principle of the proposed algorithm.

1. Get the CAD model in STL (ASCII) format.

2. Perform the optimization of forming orientation.

3. Perform the color map plot of the CAD model for wall angle and thickness reduction.

4. Evaluate the color plot and make decision. If the wall angle and the thickness reduction are acceptable, user can proceed the ISF forming. Otherwise, user is advised to redesign the CAD model.

5. Perform the ISF forming.

The algorithm for getting the optimized forming orientation of a CAD model, and color map of wall angle, color map of sheet thickness reduction, and will be discussed in the next section.

## 2.2 Optimized Forming Orientation Algorithm

Figure 3a shows a CAD model with forming direction in Y-axis and the possible rotation combination along two axes. This CAD model can be rotated along X and Z axes, and the angle of these rotations are represented by *θ**x* and *θ**z*. Figure 3b shows the sample of CAD models with and without rotation along two axes. The optimized forming direction of this CAD model is an arbitrary combination of rotation along X and Z axes, which is currently unknown. The objective function and constraint for the optimization are given in *Eq. 1* and *Eq. 2*. Here, the design variables are *θ**x* and *θ**z* which represent the angle of rotation along X and Z axes.

$$\text{ min}f({\theta }_{x},{\theta }_{z}) (Eq.1)$$

$$s.t \left({\theta }_{x},{\theta }_{z}\right)\le 90 and \left({\theta }_{x},{\theta }_{z}\right)\ge 0 (Eq.2)$$

Since a repetitive search operation has to be involved to solve this optimization problem, a genetic-algorithm-like approach is chosen in this paper. This approach has two similar steps in normal genetic algorithm, which are repetitive of initialization of a population, selection based on fitness function.

The first step in this genetic-algorithm-like approach is initialization of population, which is illustrated in Fig. 4. There are four divisions in the design space, namely AC-AC, AC-C, C-AC, and C-C, which are the possible region to find the optimized forming orientation of a CAD model. AC is the acronym for anti-clockwise rotation, and C for clockwise rotation. In each division region, it will be populated with different CAD model at various combination of rotation along two axes (X and Z). For example, in the AC-AC region, all the CAD models will be at various combination of rotation along X and Z axes with all anti-clockwise manner. The coordinate transform formula, which is shown in *Eq. 3*, is used to perform rotation on model coordinate. To generate a new CAD model, the window file stream has to be used to write the newly rotated coordinates with normal vector into a new file.

$$\left(\begin{array}{c}{x}^{\text{'}}\\ {y}^{\text{'}}\\ {z}^{\text{'}}\end{array}\right)=\left(\begin{array}{ccc}\text{cos}\theta & \text{sin}\theta & 0\\ -\text{sin}\theta & \text{cos}\theta & 0\\ 0& 0& 1\end{array}\right)\left(\begin{array}{c}x\\ y\\ z\end{array}\right) , xyz=old coordinate, {x}^{\text{'}}{y}^{\text{'}}{z}^{\text{'}}=new coordinate (Eq.3)$$

The following steps summarizes the function to rotate and generate a new CAD model:

1. Get a CAD model in STL (ASCII) format.

2. Use file stream to read the STL file.

3. Store all the current coordinate into a list or dictionary using a loop.

4. Get the rotation values from user.

5. Apply the coordinate transformation at X-axis and Z-axis to the coordinates.

6. Calculate the new normal vectors from the new coordinates using cross product.

7. Use file stream to write a new file in STL format with all the new coordinates and normal vectors.

The second step is to build the selection criteria to evaluate the fitness of a population based on two criteria. The first evaluation criteria is to calculate how much all the wall angle in a CAD model different from the forming angle limit. However, not all CAD models can fulfill this first evaluation criteria as it is difficult to be achieved in some complex geometries, such as freeform shape. Hence, a second evaluation criteria is required, which is the evaluation of critical area, which is the summation of the triangle area in a CAD model which more than its forming angle limit. To calculate the triangle area, *Eq. 4* is used, where and are the vectors of a triangle.

area of a triangle = 0.5 * (

) (Eq.4)

The following steps summarizes the selection criteria:

1. Get a CAD model in STL (ASCII) format.

2. Evaluate the fitness using first criteria, where it calculates how much all the wall angle in a CAD model different from the forming angle limit.

3. If there is wall angle in CAD model which is more than the forming angle limit, then use the second evaluation criteria.

Once the selection criteria are confirmed, the overall optimization process is carried out by iterative searching, which is illustrated in Fig. 5. The search approach is divided into two portions: coarse search and fine search. The purpose of coarse search is to get the searching direction and reduce the searching time. The fit population in the respective region in design space is identified through coarse search. After that, the fine search operation is carried out by populating the fit region with more population, and evaluating the population to find the optimum result.

The following steps summarize this genetic-algorithm-like search approach:

1. Make sure the input CAD model is in STL (ASCII) format.

2. Perform the coarse search to identify the search direction or region.

3. In the coarse search, perform the first evaluation. If this criteria is met, proceed to fine search with the same evaluation criteria.

4. In the coarse search, if the first criteria is not met, use the second criteria for evaluation.

5. Once the fit region is identified, perform the fine search using the same evaluation criteria.

6. The optimized orientation is the orientation in which a CAD model has the minimum critical area.

## 2.3 Formability Assessment Algorithm Using Visual Color Map

The purpose of having color map of a CAD model using wall angle and thickness reduction is to give an intuitive assessment to user about the current CAD design. To authors’ best knowledge, there is no available CAD software which can perform the mentioned color map of a CAD model.

The normal vectors in STL file is represented in *Eq. 5*, and the wall angle in respective forming direction can be obtained using *Eq. 6-Eq. 8*. On the other hand, the thickness reduction can be calculated from Sine rule, which is shown in *Eq. 9-Eq. 10*.

$$\overrightarrow{n}={n}_{x}+{n}_{y}+{n}_{z} (Eq. 5)$$

$${\theta }_{x-forming direction}={cos}^{-1}\left({n}_{x}\right)\frac{180}{\pi } (Eq. 6)$$

$${ \theta }_{y-forming direction}={cos}^{-1}\left({n}_{y}\right)\frac{180}{\pi } (Eq. 7)$$

$${ \theta }_{z-forming direction}={cos}^{-1}\left({n}_{z}\right)\frac{180}{\pi } (Eq.8)$$

$$thickness reduction=\frac{{t}_{i}-{t}_{f}}{{t}_{i}}, {t}_{i}=initial thickness, {t}_{f}=final thickness (Eq.9)$$

$${t}_{f}={t}_{i}*\text{sin}\left(90-\theta \right) (Eq.10)$$

To plot the STL file, a proper computer graphic library is required. There are some open source libraries, such as OpenGL, DirectX, and so on. In this paper, OpenTK, which is a C# version of OpenGL is chosen. For the first division range in color map, it is set to change for every 5-degree, starting from the lowest angle value (0o) to 30o. For the second division range in color map, it is set to the ratio of angle difference (wall angle limit-30o) to 5. The following steps summarizes the procedures to set the division range in color map:

1. For lowest wall angles (0o), the color is green.

2. For wall angles which are higher or equal to angle limit, the color is red.

3. For the color in between first division range, change the color from green to yellow for every 5o difference.

4. For the color in between second division range, change the color from yellow to red using the ratio of angle difference (wall angle limit-30o) to 5.

Once the color map procedure is ready, a query function is required to facilitate user in checking the forming wall angle and thickness reduction of a CAD model. To create this function, the selection mode in OpenTK has to be used instead of the normal render mode to keep track and store the model coordinates, wall angle, and thickness reduction.

The following steps summarized the proposed color map algorithm for wall angle and thickness reduction:

1. Prepare the forming CAD model and make sure it is in STL (ASCII) format.

2. Read the STL file using file stream and choose a data structure. In this case, dictionary is used.

3. Store the normal vector and coordinates of each triangle of a STL file into dictionary.

4. For color map of wall angle, the angle of each triangle in STL file has to be additionally stored into dictionary.

5. For color map of thickness reduction, the thickness reduction of each triangle in STL file has to be additionally stored into dictionary.

6. To show the color map of wall angle, loop through the dictionary and use the plot function in OpenTK in the render mode. The same step is used for color map of thickness reduction.

7. To implement the query function, use the select mode in OpenTK to keep track the wall angle and thickness reduction.

8. User can assess the formability of a CAD model now by using the wall angle and thickness reduction.