# Voxel-Based Digital Twin Framework for Earthwork Construction
## 3 Methodology
### Earthwork Virtual Model Construction
#### 3.3.3. Voxel-Based As-Planned/As-Built Model Development  
The proposed method uses voxel-based representation for the design model and the as-built model. The design model represents the volume between the target model and the ground model. To voxelize a design model or an as-built model, the voxelization process is used. Voxelization converts the geometrical models into cubes, where each cube can be assigned different properties and semantics. The voxelization process of the earthwork model is explained in detail in our previous article [25]. The method uses a three-step procedure, as follows: (1) solid extraction between the target and ground models, (2) conversion of the solid model into a mesh model, and (3) voxel generation inside the mesh. The process is depicted for an excavation example in Figure 5.  
The solid was extracted in the first step using the ground and target surfaces. The triangles of the TIN surfaces were utilized to extract the solid that represents the homogenous volumetric details of the cut or fill, providing clear boundaries with topological information. The extracted solids were converted into meshes. The conversion of the design model into meshes retains surface discontinuities and topology, ensuring that geometric fidelity is preserved. The meshes were composed of several triangular facets. The generated meshes were used as inputs for the voxelization algorithm to create a voxel-based as-planned model. The final step involved the creation of voxels inside the cut-and-fill mesh. Voxel creation inside the mesh consisted of the following steps: (i) creation of a bounding box around the design mesh, (ii) voxel size definition, (iii) voxel grid definition and voxel generation in the bounding box, and (iv) ray casting for voxel occupancy detection and classification. An axis-aligned bounding box (AABB) was created around the selected cut or fill mesh to define a simple enclosed boundary. It is calculated by iterating all the vertices, specifically, the minimum and maximum values (xmin, ymin, zmin, and xmax, ymax, zmax) of the design mesh, which define their coordinates in the Cartesian system. The design models are generally available in surface-based representation and are directly used for voxelization. However, the as-built models are collected through sensing techniques such as cameras or laser scanners. The available dataset is a point cloud, which is then processed to develop a surface model. The surface-based model was utilized as input for the voxelization. The AABB enclosed the extent of the geometry, and voxels were created in alignment with the AABB, ensuring that the exact geometry was voxelized. Voxel size selection is a critical factor for realistic simulations, as it is directly correlated with site geotechnical conditions, volumetric accuracy and computation, equipment bucket size, and their interactions during the simulation. Depending on the geotechnical conditions of the site, granular materials, such as sand or gravel, can be represented by large voxels, whereas fine materials, such as clay or silt, require smaller voxels to capture realistic site conditions. This method uses actual site condition data from geotechnical investigations and laboratory testing data, and the voxel size is selected based on the condition and material type. After the material is identified, its standard size can be used for voxel size selection. To ensure computational efficiency, a scaling factor is applied to the size of the geotechnical material. The voxel size is calculated as follows:  
\[Voxel\;size\;for\;material\;type=\Delta_{material}=material\;size\;\times\;scaling\;factor \tag{6}\]  
The voxel size is constrained by the allowable error that occurs when the voxels surpass the design surface boundary or the as-built surface boundary (the as-built surface obtained after the point cloud is converted into a surface). Smaller voxels provide greater accuracy; however, they require additional computation for model creation and simulation.