# Research on the Intelligent Construction of the Rebar Project Based on BIM
## 4 The Program Calculates How the Rebar Model Is Generated
### Additional Stirrup Generation  
The number of additional stirrups is generated according to the number of longitudinal bars, as shown in Figure 7. By finding the relationship between the number of additional stirrups and the number of longitudinal bars, and considering the least cost direction, this program develops a calculation method, so that the program can automatically calculate the form and size of the additional stirrups through the number of longitudinal bars input by the user according to quantity and automatically arrange it in the structural column. Figure 6: Schematic diagram of the stirrup height coordinate calculations. In Figure 7, from left to right, stirrups are organized in accordance with one-by-one and one-by-one arrangement: additional stirrups hooping two longitudinal bars, additional stirrups hooping three longitudinal bars, and additional stirrups hooping four longitudinal bars. It can be seen that the number of the remaining longitudinal bars after removing the three longitudinal bars is divided by three, which is the number of additional stirrups that hoop the two longitudinal bars, and divided by four, which is the number of additional stirrups that hoop the three longitudinal bars. The number, divided by five, is the number of additional stirrups that hoop the four longitudinal bars. First declare three variables of int-type \(N_{strirup4}\), \(N_{stirrup3}\), and \(N_{stirrup2}\), which respectively represent the number of additional stirrups that hoop four longitudinal bars, the number of additional stirrups that hoop three longitudinal bars, and the number of additional stirrups that hoop two longitudinal bars. Use the int-type variable \(N_{lon}\) to represent the number of longitudinal bars; then, the number of additional stirrups can be calculated:  
\[N_{stirrup4}=\frac{(a-3)}{5}\hskip 28.452756 ptN_{stirrup3}=\frac{(a-3)}{4} \hskip 28.452756 ptN_{stirrup2}=\frac{(a-3)}{3} \tag{14}\]  
In fact, it can be found that, when \((N_{lon}-3)\) is a multiple of three, such as 6, 9, and 12, the additional stirrups are all in the form of hooping two longitudinal bars. When \((N_{lon}-3)\) is a multiple of four, such as 7, 11, and 15, the additional stirrups are all in the form of three longitudinal bars. When \((N_{lon}-3)\) is a multiple of five, such as 8, 13, and 18, the additional stirrups are all in the form of four longitudinal bars. Then, when the number of longitudinal bars is 10 or 14, that is, \((N_{lon}-3)\) is not a multiple of three, four, or five, it is necessary to combine different additional stirrup forms. Calculate the number of additional stirrups that hoop the four longitudinal bars: \(N_{stirrup4}=(a-3)/5\). Then, calculate the number of remaining longitudinal bars \(N_{remainLo}\):  
\[N_{remainLo}=N_{lon}-3-\left(5\times N_{stirrup4}\right) \tag{15}\]  
Determine whether the number of remaining longitudinal bars meets the form of additional stirrups for hooping three longitudinal bars; if not, judge whether it meets the form of additional stirrups for hooping two longitudinal bars. By calculating the coordinates of the four corners of the additional stirrups, connecting the coordinates of the four corners to generate a wireframe, and then generating the additional stirrups through the wireframe path, the calculation of the corner coordinates of the X-axis and Z-axis directions of the additional stirrups is different from that of the stirrups. The following describes the calculation of the corner coordinates of the additional stirrups in the b direction of the structural column. As shown in Figure 8 below, after the coordinates of corner point 1 and corner point 2 are calculated, the coordinates of the two symmetrical corners only need to invert the Y-axis coordinates of corner 1 and corner 2. Figure 7: Additional stirrup arrangement rules.