## 5 Applying Volume to the Fractal Structures
### The CAD Method  
Two objectives are defined for this method: (1) to generate the fractal structures using CAD techniques and (2) to unite the fractal structures with the CAD shell. The advantage over the geometric computational method is that the union of geometric components (to create fractals or to unite fractals to the shell) is computed automatically. Furthermore, trimming the fractals (when they intersect the shell) is not necessarily required in this approach as it is possible to create the fractals without surface intersection, unite them with the CAD shell, and then trim the unwanted parts (using a CAD component tool which is the negative of the CAD shell, as a trimming tool). Figure 9: Stitched surface meshes: (**a**) hemisphere–cylinder stitch and (**b**) cylinder–cylinder stitch. In this work, the OpenSCAD software is used [23] together with the Matlab library MatSCAD [24]. The following steps are used to achieve the fractal structures' construction and their union with the CAD shell:  
**st3.1. **: A SCAD structure is initialized as the workspace, and the CAD shell is imported. **st3.2. **: The length \(H_{ij}\) of each branch \(B\) of the fractal structure (data arranged in tables such as, e.g., Tables 4 or 5) is computed using Equation (16). The initial point \(P_{init}\) of each branch is also found in the fractal data. If a surface mesh is provided, the following must be considered:  
**a**. For thin shells (thickness in the order of the radii of the cylinders composing the fractals), even if the fractals are trimmed due to surface intersection, trimming with a CAD tool is recommended (see step st3.5). **b**. For thick shells (thickness in the order of at least two times the cylinder radii), no CAD tool trimming is required. **st3.3. **: For each branch, a cylinder CYL\({}_{ij}\) is created in CAD with height \(H_{ij,i}\), and radius \(R\) (given in Step#0). **st3.4. **: Each cylinder CYL\({}_{ij}\) is generated at the origin of the world coordinate system. Therefore, to position the branch correctly, each cylinder is rotated using the angles \(\psi\) and \(\varphi\) (Equation (17)) and then translated using \(P_{init}\). The cylinder is then united with the rest of the CAD structures (other cylinders within the fractals and the shell). **st3.5. **: A CAD trimming tool, which is the negative of the shell, is used on every generated cylinder (assuming it is needed). In Sections 6.1-6.3, there are case studies showing the results of applying the CAD method to generate internal fractal structures on predefined CAD shells. Following the steps st3.1-st3.5 finalizes step#4 in the general algorithm. In pseudocode, the CAD method is described below (Algorithm 4). ```
1. Inputs: CAD shell \(S\), \(n\) fractal structures defined according to Table 5 (trimmed), or Table 4 (untrimmed) with given radii \(R_{i}\), optional: intersection surface mesh \(\alpha\)
2. Import the CAD shell S into the workspace (**st3.1**)
3. if the fractal structures are trimmed (represented as in Table 5), then  if the CAD shell is thin, then goto 4 else if the CAD shell is thick, then goto 5 if the fractal structures are not trimmed (e.g., Table 4), then goto 4
4. for every fractal (\(1\ldots n\)) structure, do  for every branch in the fractal structure, do
5. generate the CAD cylinder shape (**st3.2-st3.3**)
6. position the cylinder in the correct point and orientation and unite it with the rest of the CAD structure (**st3.3**)
7. trim the CAD structure with the CAD tool (negative to the outer shell surface) end for
8. for every fractal (\(1\ldots n\)) structure, do  for every branch in the fractal structure, do
9. generate the CAD cylinder shape (**st3.2-st3.3**)
10. position the cylinder in the correct point and orientation and unite it with the rest of the CAD structure (**st3.3**)
11. end for end for
12. Outputs: CAD part in STL file format, with fractals as internal structures. Table 6 presents a broad comparison between the geometric and the CAD methods for tree-like fractal generation.