The proposed LIMOFilling is composed of four parts as shown in the
Figure 3. Hole-detection occurs in the pre-processing stage, where all boundaries
of all holes in the input model
are completely collected and marked; a complex hole is decomposed into several simple holes. The holes are filled by layer-to-layer strategy during mesh-generation. The layer-to-layer strategy is a cyclic process in which the ear-clipping score is calculated in each cycle. An ear-clipping score between adjacent boundary-edges of the hole was computed to provide the position of the inserted discrete points of outermost layer of the hole which the new mesh
is generated, where the planar proxies
are updated is where the new mesh is generated. In the part of surface-fitting, the newly added mesh is adjusted locally. The generated triangles
in each layer are fitted to an implicit surface, built from the existing vertices. Their normal vectors in the neighborhood of the hole-boundary act as constraints. Sharp-feature-recovery is achieved by a global adjustment for the complete newly generated mesh in the area of the hole. The planar proxies
and the normal vectors of the triangular plane are used as a condition to constrain the adjustment.
3.1. Hole Detection
Manifold meshes are stored in a half-edge data structure because of the speed, simplicity, and high efficiency of this system. An edge is represented as two half-edges with opposite directions thus avoiding the need to distinguish the direction of polygon edges in the data structure [
32]. The half-edge data structure can represent any arbitrary manifold directional polygon mesh, where the half-edges of the polygon face are consistently oriented along the counterclockwise direction. Moreover, the manifold mesh topology is maintained providing easy access for mutual searches among vertices, edges, and faces. A boundary-edge connected to previous boundary-edge is in turn connected to the next-edge along the hole border. Thus, the boundary-edges of a hole can be easily found by using the starting-vertex and ending-vertex properties of a half-edge and the boundary-edge judgment. The entire border of a hole can be collected through the boundary half-edge extension.
The boundary-edges of a hole are collected by the boundary half-edge extension directly in simple hole-detection. The method is a cyclical process, an unmarked boundary half-edge is randomly selected as the starting-vertex in the hole-detection, and this half-edge is marked. Boundary half-edges include not only the hole-boundary-edges but also the model border-edges, see
Figure 4.
As seen in the diagram, the starting half-edge
HE1 is a boundary half-edge from the starting-vertex
FV1 to the ending-vertex
TV1, the boundary half-edge extension finds a half-edge starting from the ending-vertex
TV1 of the current half-edge as the extension half-edge, and
TV1 is the starting-vertex
FV2 of the extension half-edge. However, there are five half-edges starting from the vertex
FV2, i.e.,
HEa, HEb, HEc, HEd, and
HE2, as shown in
Figure 4. However, there is only one half-edge among the five edges:
HE2, is the boundary half-edge. Thus, the border of the hole is extended from
HE1 to
HE2, and
HE2 is marked. All the boundaries of simple holes are collected by direct the boundary half-edge extension in this way.
The direct boundary half-edge extension can extend the boundary of a simple hole quickly and accurately because usually only one boundary half-edge starts from the end of a previous boundary half-edge. The presence of non-manifold vertices in a complex hole however, means that a boundary half-edge is not unique, and more than one candidate edge qualifies as a boundary-edge, unlike the situation of simple holes. A complex hole consisting of three simple holes via connected by a non-manifold vertex
, is shown in
Figure 5. When the boundary half-edge extension encounters a non-manifold vertex, there is no longer only one boundary half-edge available for extension. Therefore, the problem becomes how to select an optimal extended half-edge from several candidates that satisfy the extension condition.
Hole-detection expectations clarify the direction of optimal boundary half-edge selection. A complex hole was decomposed into two or more simple holes to avoid potential problems that arise when filling complex holes directly. A complex hole consisting of three simple holes (purple, bule and yellow) via connected by a non-manifold vertex
, shown in
Figure 5, where
is the boundary vertices of purple hole,
is the boundary vertices of blue hole and
is the boundary vertices of yellow hole. Among the complex hole,
HE1 and
HE2 belong to the same purple simple hole, while
HE3 and
HE4 belong to the yellow and blue simple hole. Choosing the boundary half-edge of the same hole as the extended half-edge can open a breakthrough for solving optimal boundary half-edge selection. To select optimal half-edge, a fast and robust algorithm was designed that accurately finds the optimal extended half-edge from several candidate half-edges.
The proposed method selects the extended half-edge by judging the intersection between the auxiliary segments and the triangular surfaces around the non-manifold vertex that are closely connected with the complex hole. The auxiliary segments are constructed by connecting the starting vertex of the current half-edge to the ending vertex of all the boundary half-edges to be selected without actually adding any edge to the mesh. There are as many auxiliary segments as there are candidate half-edges. It was inferred from extensive experiments and engineering experience that, among many candidates, only a half-edge that belongs to the same simple hole as the current half-edge determines an auxiliary segment which does not intersect any triangular surface, because this auxiliary segment and its projection always lie inside this simple hole, as illustrated in
Figure 5. In the figure, Sg2 intersects the triangle
and the triangle
in the triangular plane, and Sg3 coincides with an edge
of the triangle
, which also considered as a case where the segment intersects the triangle. An exception is when the angle between
HE1 and
HE2 facing the simple hole is greater than 180°, the auxiliary segment will be outside the hole. However, the triangles connected to the exceptional non-manifold vertex are often abnormal triangles, such as spikes or degenerate triangles. To avoid anomalies, a spike and degenerate surfaces removal algorithm [
33] is used during pre-processing the mesh in the proposed method.
It has to emphasize that the intersection judgment is on the triangular plane. Since the mesh is three-dimensional, the adjacent triangles do not necessarily lie strictly on one plane where there is a change in elevation. Therefore, each auxiliary segment is projected separately onto a defined plane to determine whether the segment intersects the triangle in that plane or not. To project the auxiliary segment, a local spatial coordinate system is constructed, which takes the triangular plane to be detected as the base plane. The coordinate system takes the non-manifold vertex
as the origin, the normal
n of the candidate triangular plane as the
z-axis, and the plane where the triangle is located constitutes the
plane. The coordinate axis vectors of the local coordinate system are
,
, and
, which can be expressed as follows:
A projection rotation matrix
is formed by these three vectors, which is defined as
The two endpoints of the auxiliary segment are projected into the local coordinate system by the following equation:
where
is the coordinates of the origin of the local coordinate system under the global coordinate system, and
is the coordinates of the point
in the global coordinate system under the local coordinate system.
A complex hole was decomposed into multiple simple holes and collected the boundary half-edges of all simple holes by the boundary half-edge extension as previously discussed in this section. The intersection judgment of auxiliary segments and triangular surfaces is the basis for decomposing the complex holes. The segments must be projected onto the triangular plane for intersection judgment; thus, a local spatial coordinate system was constructed and the collected hole-boundary half-edges are used as hole information for mesh generation.
3.2. Mesh Generation
Mesh generation is a part of hole-repairing and a layer-to-layer framework is proposed to fill large holes. The main idea is to refine the scope of local information when filling large holes. Specifically, it is not immediately going to the next layer after generating mesh in the current layer, but perform implicit surface fitting to the newly generated mesh of the current layer and surface fitting as detailed in
Section 3.3. Mesh generation consists of two steps, discrete vertices insertion and triangulation. Many common discrete point insertion algorithms select edges randomly and are not robust for arbitrary angles [
5]. In addition, ear-clipping triangulation does not guarantee the uniformity of the mesh. The algorithm was improved by introducing the ear-selection idea of ear-clipping triangulation [
21] into the discrete vertices insertion and defining the priority of triangulation. The boundary set of each simple hole as collected in
Section 3.1 is used in mesh generation to uniformly generate a new mesh in the hole-area.
The insertion of discrete vertices and triangulation are the main two steps of mesh-generation. The traditional methods of inserting discrete points in the hole-region, such as [
34], is to randomly select a point
from the set of hole-boundary vertices
, and calculate the location of the inserted point by the angle
θ formed by the two neighboring edges associated with
and the average length
of the two edges. Although this method inserts the discrete vertices required for hole-repairing in the hole-region, the edge-selection is random. Moreover, convex (
θ > 180°) and concave (
θ < 180°) angles are handled differently by those methods, so additional judgment on θ is required, which increases the complexity of the algorithm, and does not guarantee the uniform insertion of discrete points.
The vertex insertion method was improved to eliminate the randomness of edge-selection, reduce the complexity, and make the algorithm robust to arbitrary angles by introducing the ear-selection idea of ear-clipping triangulation in the proposed edge-selection method. We calculate the ear-clipping score of each ear on the edge of the hole, and select the two edges where the ear with the smallest ear-clipping score is located. The middle vertex is
, and the adjacent two vertices are
and
. Each ear is visited only once, and after being visited the ears are not calculated in another loop. The next smallest ear is selected for calculation next time. The position coordinates of the inserted vertex of the current ear constraint are calculated by the following equation:
where
,
and
is the coordinate of the vertex
,
and inserted vertex, respectively,
,
. The distance between the later inserted vertex and all the first inserted vertices are compared. If the distance is less than
, then merge these two vertices and take the midpoint of these two vertices as the new vertex.
is the average of the boundary-edge set
of the hole, calculated by the following equation:
A layer of discrete vertices in the hole-area is inserted when each ear has been visited. The next layer of vertices is inserted based on the new set of hole-boundary-edges formed after the previous layer of discrete vertices is inserted and triangulated.
It is not triangulate the insertion vertices by simply ear-clipping [
21] even though it has the lowest triangulation complexity and by far the simplest triangulation method. A priority of triangulation must be defined because the position of the insertion vertex is determined by associated boundary-edge and the repair of the whole hole is layer-to-layer. The triangle formed by the added vertex and the associated boundary vertices is given priority when triangulating the discrete vertices and whether the discrete vertices can form triangles between the vertices must be considered. Only those triangles close to equilateral triangles can be accepted. The length of the ear-clipping line (the line connecting the two endpoints of the ear) was calculated, if it is less than
then it directly forms a triangle with the two edges of the ear. Otherwise, a vertex is inserted according to Equation (4), and merge the vertices whose distance is less than
. The two vertices of the boundary-edge associated with the insertion point form a new triangle, in which a boundary-edge in the original mesh can only be visited once. All newly inserted vertices have to be assessed in relation to the definition. A layer of vertices inserted and triangulated is displayed in
Figure 6.
In
Figure 6, the green border is the boundary of the origin hole. The hole-boundary of the next layer is formed by a layer of inserted and triangulated vertices, as indicated by the blue line. The proposed method does not distinguish between concave and convex angles when selecting edges. As illustrated, the proposed mesh generation method guarantees the uniformity of the inserted vertices, and generates regular triangular surfaces.
Planar proxies for the original mesh are extracted before filling the holes; the aim is to sense the structure of the model. Two or more adjacent triangular surfaces can be approximated to some extent by a simple plane
φ [
35,
36,
37], called a planar proxy. The planar proxies of the model are obtained by the region-growing method. The local tangent plane and flatness score of each triangular surface
t is estimated by selecting a linear-least-squares fitting to the planes on a point set that is chosen as a subset of the mesh vertices in the local neighborhood. The latter is set as the set of triangular faces
t in a noiseless dataset and as a larger combined neighborhood in a noisy dataset. Immediately afterwards, the current region is iteratively grown, operating on one region at a time, always selecting the triangle with the lowest flatness score not being used for the growth of a particular region, as the cell for region growth. A planar proxy was obtained by the region growing method. Each region grows on the surface of adjacent triangles, one triangle at a time. The angle between the normal vector of this triangle (the line perpendicular to the plane of the triangle) was computed, the normal vector of the seed plane (the line perpendicular to the seed plane) and the Euclidean distance between them. If both metrics are simultaneously smaller than a given threshold, then this triangle is accepted as a unit of region growth. Notably, the seed plane is not recalculated during the growth of a region. After an iteration is completed, if the total area of the resulting set of faces is less than the threshold area, the region is rejected; otherwise, each triangle can be detected as a planar proxy. After growing the area for the whole model, adjacent faces that are approximately co-planar are merged into a plane. The planar proxies are represented by the set of triangles
,
,……,
that belong to the same planar proxy, implying that the model extracts a total of
k planar proxies, with
m, n, ......, q triangles belong to different planar proxies. One triangle belongs to only one planar proxy, and there are triangles that do not belong to any planar proxy.
The meshes in hole-region were generated by layer-to-layer for filling large holes and introduce the ear-selection idea in ear-clipping triangulation in the vertices insertion process to improve the algorithm, as well as to define the priority of triangulation to ensure the uniformity of the inserted vertices. Planar proxies are extracted before mesh generation to obtain a sense of the structure. Generated mesh surfaces are fitted to ensure a smooth transition between the old and new meshes and to repair the highly curved holes.
3.3. Surface Fitting
To ensure a smooth-transition between the old and new meshes and to repair the highly curved holes, surface-fitting is performed after mesh generated. An implicit surface is constructed for surface-fitting and the position of the newly generated mesh is adjusted based on the implicit surface. An implicit surface was constructed based on the radial basis function. It has high order continuity for multiple scattered data point interpolation, and contains only one independent variable representing distance so that complex surfaces with arbitrary topologies can be obtained. There are many expressions for radial basis functions in practical surface reconstruction; Carr et al. give a list of the expressions and a detailed analysis of their applicability [
38]. The proposed implicit surface method is a fit to a function containing three variables, so the multiple reconciliation function
is used. The surface-fitting is another part of hole-repairing.
The surface representation is defined as finding a surface
to approximately represent the surface M for multiple points of the surface M that differ in space [
39]. An implicit surface can be defined as: finding a function
such that any point of the surface
satisfies
. The function
is said to implicitly define the surface
. Suppose there is a discrete vertex set
in the space, and each point of the set has corresponding constraint set
. For the discrete vertices in the space, if a function
can be constructed so that each discrete vertex satisfies
, then these n discrete vertices can also define an implicit surface
. The surface over the set of discrete points with constraint values c = 0.
Work in [
38] and [
39] of constructing implicit surfaces based on radial basis functions is useful for repair of simple structures and small size holes. However, when a hole is large, relying only on the vertices of the hole edges as constraint vertices cannot accurately describe the structure of the hole-area. Nevertheless, the implicit surface constraint weakens as the distance from the edge of the hole increases, as the center of the hole might be too far from the constraint vertices. Thus, surface-fitting was performed in a layer-to-layer framework introduced in
Section 3.2. The implicit surface of the current layer is constructed by a set of collaborative constraint vertices, which composed by the hole-boundary vertices and the discrete points inserted in the current layer and the surface can be expressed as:
where
is a constraint vertex, and
is the weight of each sampling vertex.
is the residual function whose role is to maintain the affine invariance of the input points, which is defined as
where
x,
y, and
z are the three-dimensional coordinates of the spatial vertex and
is the function coefficient.
is the radial basis function chosen to construct the implicit surface, which takes the form of
when interpolating the sampling vertices in three-dimensional space.
Furthermore, the selection principle of constraint vertices and the method for solving implicit surfaces assume that for a constraint vertex , if that satisfies , the point is on the surface, and undoubtedly considered the surface constraint vertex. Otherwise, the vertex is not on the surface (where, if , the vertex is inside the surface; if , the vertex is outside the surface), which is said to be a non-surface constraint vertex. Since the implicit surfaces are constructed by layer to layer, the insertion point of current layer is selected as the constraint vertex in each loop. Moreover, any vertex that deviates from each surface constraint vertex by a 0.5 directional length, is selected as the non-surface constraint vertex. If the constraint is given as , to solve for the four coefficients of residual function and the weight , two conditions need to be satisfied:
(1) The interpolation constraint, expressed as
(2) The energy orthogonality, denoted as
where,
j = 1, 2, 3, ......,
n. Let
, the system of linear equations can be obtained from Equations (8) and (9), that expressed as
In Equation (10), the matrix on the left side of the equal sign is a positive definite matrix, yielding a unique solution
. Substituting the solution of the equation into the definition formula Equation (6), the implicit surface equation can be solved as
Further, the newly generated mesh is fitted to the implicit surface by adjusting the position of the triangles. A method was introduced for adjusting triangles. The triangle is adjusted by three vertices gradually approaching the implicit surface along the gradient direction, which is expressed as
Additionally, calculate the first-order partial derivative of Equation (11), the following equation is obtained:
A triangle vertex that finally reaches a point on that implicit surface is called the mapping point of the vertex. The coordinates of the mapping point on the implicit surface can be calculated by the following equation:
where
is the coordinate of vertex
before position adjustment, and
is the 3D coordinate of mapping point
, which is also the coordinate of
after adjustment. The adjustment distance was also calculated; if the distance is less than the minimum threshold, it was considered that
originally belongs to a vertex on the implicit surface, and does not need to adjust the position. Otherwise, the vertex position needs to change. Newton’s method is used to perform the vertices position adjustment; this is an iterative merit-seeking method that allows a certain function to approach the target vertex as fast as possible from the negative gradient direction of the vector [
40].
The newly generated mesh satisfies the requirement of smooth transition between the old and new meshes after fitting all the inserted vertices to the implicit surface. The set of planar proxies
is updated by assigning triangles to each planar proxy or not to any planar proxy, which according to the deviation between the normal vectors of the adjusted triangle and the planar proxy.
Figure 7 shows the hole-repairing result of the hole in
Figure 6.
The proposed method in
Figure 7c has advantages over the two typical hole-filling methods shown in
Figure 7a,b. The non-negligible drawback of the method without inserting any vertices (
Figure 7a) is that the resulting triangles shape is usually narrow, with a considerable impact on the recovery of the feature structure. The discrete vertices inserted by layer-to-layer, as in
Figure 7c, are more evenly distributed within the hole-area than those inserted by the one-time hole-filling method, which are more concentrated in the center of the hole. Moreover, the one-time hole-filling method produces degenerated triangles whose shapes are approximately a line, as indicated by the red box in
Figure 7b. The proposed approach however, eliminates the possibility of creating degenerate triangles at the algorithmic level, thus yielding only regular triangles, as shown in
Figure 7c.
The newly generated meshes were fitted by constructing an implicit surface based on radial basis function. The newly generated mesh is adjusted based on the implicit surface. Surface fitting smooths the transition between old and new mesh; subsequently, the highly curved holes can be repaired in the feature recovery process. The sharp features of a hole however, cannot be recovered by implicit surface fitting, thus structural information from the planar proxies is applied in feature recovery.
3.4. Feature Recovery
The planar proxies were introduced to recover the sharp features of the mesh after implicit surface fitting by adjusting the positions of the triangles.
Figure 8 shows the planar proxies of the sharp features and their restored models. The triangular faces in the same plane proxy have similar normal directions, and this rule is followed to continuously update the plane proxies during mesh generation. The overlay of the planar proxies before and after the hole-filling as shown in
Figure 8c,f, precisely presenting the recovered sharp features. Position adjustment in the feature recovery process is different from that in surface fitting as normal triangle vector information and planar proxies are considered in the proposed feature recovery method. Specifically, on the basis of grid-based mean filtering, the joint constraints were constructed using the normal triangle vectors around the triangle to be adjusted and the normal planar proxy containing the triangle [
41]. The proposed feature recovery method is an iterative optimization process.
For a triangular surface
with normal vector
, the set of triangular surfaces in the one-loop neighborhood of
is
, and the corresponding set of normal vectors is
. Weighting each triangle within a one-ring neighborhood of the triangle
by the following equation:
where
is the cosine of the angle between the normal of
and neighboring triangle
, which when expressed as
,
.
is the cosine of the angle between
and the planar proxy
to which
belongs, and if
does not belong to any planar proxy, the value
. The smaller the deviation of the normal of the triangle from the normal of
, the larger the weight, and vice versa when the deviation of the normal of the triangle is bigger from the normal of
, the smaller the weight. The position of each vertex
in the triangle surface
is adjusted by the following equation:
where
is the adjusted coordinate of vertex
in
,
j is the current number of iterations, and
is the center of gravity coordinate of
before position adjustment. After updating the coordinates of the three vertices of the triangular surface, the center of gravity coordinate is updated accordingly. In addition, the normal of the triangular surface after the position adjustment is recalculated by the following equation:
If
, stop the iteration, otherwise the position optimization is continued, where
is the vertex coordinate after the last loop adjustment.
The features were recovered by triangles adjustment constrained by triangles normal vector information and planar proxies. This information is works by weighting different triangles vertices to obtain the structural features of the holes. Notably, if a triangle does not belong to any planar proxy, then it is only considered in relation to the triangle and with the surrounding triangles. A series of experiments were designed to investigate the hole-filling ability of the proposed method.