# Repair of Voids in Multi-Labeled Triangular Mesh
## 4 Method
### Repair Voids  
The void repairing stage aims to fill the sets of the searched connected triangular facets according to certain repair rules, and the purpose is to form a repaired multi-labeled mesh with consistent topological relationship and no voids. To fill the triangular facets of voids, it is necessary to define the rules for repairing the voids. Similar to the model repairing method based on multi-labeled voxels, a simple way is to directly fill the voids by defining the model priorities that characterize the reliability of the model. Without loss of generality, the corresponding label is used to represent model priority. In this case, the model with a smaller label is more reliable. To obtain the repaired multi-labeled mesh, the zero labels of all the triangular facets in the voids are replaced with the corresponding max label in the triangular facets of the voids. If the searched connected triangular facet set \(S_{T,k}\) is a true void, then traverse the triangular facets and modify the zero labels as the max non-zero label in \(S_{T,k}\). After filling the voids with the material corresponding to the highest priority of the model, the repaired multi-labeled sub-meshes \(LM_{j}^{\prime}(j=1,2,\ldots,m)\) are obtained. It is worth noting that after the voids are filled, there may be some invalid triangular facets with the same pos label and neg label in the repaired meshes, as mentioned earlier. Therefore, a process should be performed to remove the invalid triangular facets. To obtain a polygonal mesh model that is convenient for traditional 3D software rendering, the repaired multi-labeled mesh \(LM_{j}^{\prime}(j=1,2,\ldots,m)\) should be converted into the triangular meshes \(M_{i}^{\prime}\) corresponding to the original meshes \(M_{i}\). The repaired multi-label sub-meshes \(LM_{j}^{\prime}(j=1,2,\ldots,m)\) are merged to form the repaired multi-label mesh \(LM^{\prime}\). There are no overlapping triangular facets and mesh vertexes because each \(LM_{j}^{\prime}\) is not connected. In addition, \(LM_{j}^{\prime}(j=1,2,\ldots,m)\) can be merged directly by traversing the triangular facets. As mentioned earlier, since the vertex array of \(LM^{\prime}\) is different from the vertex array of \(LM_{j}^{\prime}\), the new vertex indices of the triangular facets in \(LM^{\prime}\) should also be corrected. After determining the labels \(i(i=1,2,\ldots,l)\) in the multi-labeled mesh, all triangular facets \(t\) with label satisfying \(t_{pos}=i\) or \(t_{neg}=i\) are extracted, respectively, to form single-labeled meshes \(SM_{i}^{\prime}(i=1,2,\ldots,l)\). When extracting a single-labeled mesh from the multi-labeled mesh, it is also necessary to modify the vertex indices of the triangular facets according to the new vertex array. Finally, remove the labels of the triangular facets and consistent the orientations of triangular facets in \(SM_{i}^{\prime}(i=1,2,\ldots,l)\) to obtain the repaired meshes without labels \(M_{i}^{\prime}(i=1,2,\ldots,l)\). The pseudo-code of the algorithm flow for repairing voids is shown in Algorithm 3 (Repair voids). Figure 5: Three types of quasi-voids: interior boundary, exterior boundary and void: (**a**) two simple input meshes; (**b**) the boundaries of mesh 1 and mesh 2; (**c**) exterior boundary of the multi-labeled mesh; (**d**) interior boundary and void of the multi-labeled mesh. ```
Input: Multi-labeled sub-meshes \(\mathbf{LM}_{j}(j=1,2,\ldots,m)\) and voids \(\mathbf{VO}_{j,k}(j=1,2,\ldots,m,\ k=1,2,\ldots,n)\) Output: Repaired meshes without labels \(\mathbf{M}^{\prime}_{i}(i=1,2,\ldots,l)\)  Initialize an empty repaired multi-labeled mesh \(\mathbf{LM}^{\prime}\). foreach\(\mathbf{LM}_{j}(j=1,2,\ldots,m)\)do foreach\(\mathbf{VO}_{j,k}(k=1,2,\ldots,n)\)do if\(\mathbf{VO}_{j,k}\
eq\varnothing\)then  Obtain the max label \(\mathbf{L}_{max,j}\) in \(\mathbf{V}_{T,j}\). foreach\(t\in\mathbf{V}_{T,j}\)do \(t_{pos}=\mathbf{L}_{max,j}\) endfor endif endfor  After repairing, obtain repaired multi-labeled sub-mesh \(\mathbf{LM}^{\prime}_{j}\).