Euler Characteristic Scheme of Globally Searching for Flaws in Surface Modeling

This paper presents a new scheme of flaw searching in surface modeling based on Euler Characteristic. This scheme can be applied to surface construction or reconstruction in computer. It is referred to as Euler Accompanying Test (EAT) algorithm in this paper. Two propositions in algebraic topology are presented, which are the foundation of the EAT algorithm. As the modeling is the first step for rendering in the animation and visualization, or computer-aided design (CAD) in related applications, the flaws can bring some serious problems in the final image or product, such as an artificial sense in animation rendering or a mistaken product in industry. To verify the EAT progressive procedure, a three-dimensional (3D) stamp model is constructed. The modeling process is accompanied by the EAT procedure. The EAT scheme is verified as the flaws in the stamp model are found and modified.


Introduction
Along with the development of surface construction and reconstruction, many researchers have realized that mesh models may be constructed initially with some flaws because of the complex geometrical and topological structures of surfaces, and the limitations of scanning technologies and modeling schemes [1]- [10]. They have put a lot of efforts into repairing the flaws and filling holes.
Although tens of researchers have been paying quite much attention to the hole filling quite a while [1]- [8], only several researchers [9] [10] focusing on the hole detecting are known, which cannot provide a method to find all the flaws in a model.
Since modeling is the first step for rendering in the animation and visualization [11]- [16], or design and even manufacturing in industry [17]- [25], flaws produced in modeling can bring some serious problems in the final image or product. For example, a character in an animation has a tiny gap in his or her armpit under right arm, which should be fitted together. This gap is often invisible. It can, however, be seen when the character raises the right arm.
Another example is a case in fashion design, in which two adjoining cloth patches are not defined to fit together mistakenly. This problem may result in the problem that the edges between the two adjoining patches will not be stitched together in the following process.
The third example is that during interacting with computer, a viewer is interested in a mesh model and tries to take a close look at some parts of the model where there is a minute hole. The hole may be invisible when it is occluded or at a low resolution, but it may be seen when it is zoomed in and turned to be illuminated. The third example will be displayed in Section 4 of this paper.
For the above reasons, this paper presents a new scheme to globally search a mesh model for and locate the flaws. This new scheme is based on Euler characteristic, and named Euler Accompanying Test (shortened as EAT).
To give the theory foundation of algebraic topology, two propositions are presented for the EAT scheme in this paper. They can bridge the gap between the surface construction in computer and the theory of algebraic topology.
With the trivial amount of computing, the EAT scheme can assist in repairing and generating a topologically-correct model that has the same algebraic topological structure as that of its fitting target surface.
In this research, we also construct a new model of 3D PAMA stamp shown in Figure 1 to display the progressive procedure of EAT scheme. The stamp model is programmed with OpenGL and VC++. There are two reasons for using a new model rather than the popular 3D models of Stanford Bunny, Skeleton Hand and Happy Buddha [26]. The first reason is that it is more efficient and tractable to search for, locate and correct a flaw during modeling than post-processing after the whole mesh model has been constructed. It is also why the new scheme is named Euler

Related Studies
In studies of surface construction and reconstruction in animation [13], visualization [11] [12] [14] [15] [16], and CAD [19], many modeling schemes are created to construct a composite surface with a mesh model to be approximate to a targeted object surface, which is referred to as a target surface in the rest part of this paper. The input of the construction process is usually a set of points sampled on the target surface or generated with reference to the target surface.
Among the studies, [14] presented the results of an approach for surface reconstruction from arbitrarily large point clouds of robotic maps. The authors in [15] proposed an approach to improve existing techniques of polynomial surface models. The research of [16] focused on the design of a modeling platform for a heterogeneous object (HEO) part based on a material distribution control function and hierarchical contour loop. These studies can give a clue to the broad applications of surface construction and reconstruction.
The work of [21] introduced an array-based algorithm for adaptive mesh refinement, which could generate millions of triangles. Their research of [22] proposed a local optimization method to construct triangular surface patches of high accuracy. In [24] and [25], methods of modeling surfaces composed of polygons were discussed. In [27], the authors presented a method that took an unorganized set of points to produce a surface of triangular facets. The study of [28] was the optimization of an initial triangular mesh. The research of [29] focused on automatic reconstruction of piecewise smooth surface models of triangular patches. In [30], the authors presented a method for combining a collection of range images into a single triangular mesh. The paper of [31] described a recursive bicubic B-spline patch subdivision algorithm which could generate rectangular control-point meshes. On the foundation of the study [31], the authors of [32] focused on the behavior of recursive division surfaces near extraordinary points. In [34], the authors proposed a method for refinement on B-pline surfaces with hierarchical subdivisions. The research of [35] developed the works of [31] and [32] to non-uniform recursive subdivision surfaces. It can be summarized that triangular patches were used by [27] [28] [29] [30] and quad facets were applied to subdivision surfaces [31]- [35]. Few pentagons, hexagons and others are found in surface construction and reconstruction [36]- [41]. In [37], to generate features like sharp edges and corners, the authors merged Catmull Clark [31] and NURBS (Non-Uniform Rational B-spline) patches together to produce extended subdivision surfaces. In [38] [20]. That is, the composite surface does not have the same topology as that of the target surface and cannot really represent the target surface in the mathematics and applications sense.
The papers [1] [3] made a survey on existing well-known hole-filling algorithms in 3D surface reconstruction and classified them. Researchers have proposed different methods to fill the holes in surface construction. In [2], a piecewise hole filling algorithm was presented. The study [4] used the method of positive definite Radial Basis Functions in progressively filling the holes in surface reconstruction. The authors of [5] presented a scattered point set hole-filling method to fill the holes of an incomplete surface. The paper of [6] introduced a technique to fill large holes of both texture and structure in a LiDAR scan. In the research of [7], the authors proposed a depth hole filling method to fill holes in images obtained from the Microsoft Kinect sensor. In the research of [8], the authors' argument was that for accessibility reasons or reflection problems, some parts of the object might not be scanned and could be formed as digitizing holes.
The authors of [17] mentioned that many photos contained close-up cracks in the material of the sculpture that needed to reconstruct. In the research of [19], authors mentioned that in trimming models in CAD might cause unavoidable gaps in the models. In [20], to modify a gap where neighboring B-spline surface did not match exactly, the authors presented a locally refineable subdivision scheme called T-NURCCs (Non-Uniform Rational Catmull-Clark surface with T-junctions).
With its complex geometrical and topological structures, a great number of the 3D data of points on the target surface are required to input for modeling. If the 3D data are acquired by laser-range scanning, they are unstructured point clouds and missing some information by under-sampling sometimes [9]. For these reasons, the modeling is susceptible to unexpected holes. And the knowledge of holes in the model is vital for many applications dealing with point set surfaces [9]. On the other hand, to make a composite surface hold fine local features, re-searchers of mesh model may add more sub-patches to some part of the composite surface with local refinement [32] [37] [38] [40] [41]. Along with the number of patches and sub-patches further increasing, local refinement may bring new unexpected invisible flaws into the composite surface [17] [19] [20]. As known, the consistence of global topological structure is as important as the local features for surface modeling. Holding the consistence of the global topological structure can make the model correct in the topological sense while having local features can make the model delicate. Neither of them should be ignored. Therefore, it is necessary to detect the new defects of the composite surface after local refinement.
In [9], the authors present a method of detecting holes in point set surfaces.
Their method is based on boundary probability with three criteria: angle, half-disc, and shape criteria. It is effective to extract boundary loops by repeating the process of searching for each vertex and identifying boundary points with the criteria. Their method, however, does not guarantee to find all the unexpected holes in a surface model since it is probable.
In [10], the authors present an empty disk approach for detecting the inner hole boundary of a planar point set based on Delaunay triangulation. They focus on the problem of detecting the boundary of individual inner holes in a planar point set. The limitation of their method is to detect only individual holes in a two-dimensional space, which is not appropriate for finding all the holes of a 3D model that is the issue studied in this paper. In this paper, the presented EAT algorithm is applied to testing the topological structure of a mesh model gradually and globally to find all the flaws of the model and to modify them before passing a verified model to the succeeding process. Even better, it can be used to detect new defects of the model after local refinement. In order that the code of the EAT is not left in the modeling program after verified, we adopt the strategy that a copy of the modeling program is prepared for flaw-searching, which is called the modeling companion, shown in Figure 2(a).

EAT Scheme
The EAT algorithm code is inserted in the modeling companion rather than the modeling program itself. The EAT code is running only in the modeling companion.
Each time a flaw is found in the model companion, the modeling companion is revised, and the modeling program should be revised and updated as well. Since the EAT algorithm code is running only in the model companion, the modeling program is without the EAT code in itself and thus the verified modeling program will not be slowed down by the EAT at run time.
After the model has been verified completely with the EAT scheme and all the existing flaws of model have been corrected, the verified modeling program is assembled into the rendering pipeline, shown in Figure 2(b). If some flaws are related to a modeling method, the method should be modified.
After the related modeling method has been validated, the method is integrated into CAD environments in industry or the surface reconstruction systems of animation, visualization and others, shown in Figure 2(c). And the succeeding procedures can be performed, as well.
Since fault-testing with the EAT is at the modeling stage, we will focus on the layer at the top of Figure 2(a) in this section.

Propositions in Algebraic Topology
The EAT algorithm is the core of the EAT scheme. It is based on the following Definition 1, Proposition 1 and Proposition 2.
where v n is the total number of vertices of M, e n is the total number of edges of M, and f n is the total number of triangle facets of M [42].
It is obvious that the invariant of Euler characteristic is independent of the meshing of a surface. It can be shown in Figure 3. If two triangle facets with a common edge are replaced with a quad facet and f n is referred to as the total number of facets in identity (1), as shown in Figure 3(a) and Figure 3(b), the identity (1) is still held. This deduction is based on the fact that the latter facet (no matter planar or curve) is homotopic to the former two triangle facets glued together. If each pair of three triangle facets has a common edge, these three triangle facets are replaced with a pentagon facet, and the identity (1) is also held, shown in Figure 3(c) and Figure 3(d). Let us take the idea a step further. If each pair of four triangle facets has a common edge, these four triangle facets are replaced with a hexagon facet, and the identity (1) is held, too, shown in Figure  3(e) and Figure 3(f).
With the algebraic topologies of surfaces [42] [43], the following two propositions are obvious. As the rigorous proofs of Proposition 1 and Proposition 2 are lengthy and require the homotopy theory, we do not give the proofs of Proposition 1 and Proposition 2, and readers can refer to the homotopy theory [42] [43]. Before the exploration of EAT algorithm, we have to define three sets of vertices, edges and facets of a tested model, which most of modeling methods in surface construction and reconstruction apply to surface modeling. Here we re-organize them in a three-layer data structure, and register every vertex, edge and facet in Vertex list, Edge list and Facet list, respectively, in order to compute the Euler characteristic of the model at different modeling stages.

Three-Layer Data Structure
In surface modeling, the input is a set of points, which may be sampled on a target surface by sensors or scanned the outward surface of an object by a scanner.
The set of points can be organized as the set of original vertices, 0 V . Each element of 0 V has three fields ( ) , , x y z , which are three coordinates in an orthogonal coordinate system, respectively. According to the spatial relationships of vertices and the order of the facets' being drawn, we construct a three-layer data structure for the modeling companion accompanied with the EAT.
The data structure is shown in Figure 4. At the top abstract layer is Body

EAT Algorithm
The EAT algorithm includes two different function parts. One function part is named the EAT testing algorithm (EAT-TA), shown in Figure 5. It is used to register a new facet, and its new vertices and new edges in Facet list, Vertex list and Edge list, respectively, and to increment each of their counters. Its code is embedded just after every facet modeling code in the model companion.
The other function part is called the EAT statistic algorithm (EAT-SA), also shown in Figure 5  To do exactly counting of the numbers of facets, edges and vertices of a tested surface model, the EAT-TA has to scan and traverse the model. As the modeling in surface construction and reconstruction is a dynamic and progressive process, the EAT-TA can take advantage of this process through each facet modeling accompanied by the EAT testing. Figure 6 shows the calling site of EAT-TA and related operations in the model companion. As shown, a call of the EAT-TA is usually made just after the tested facet modeling. Figure 7 shows the pseudocode of EAT-TA, which can be easily translated into VC++ language or other computer languages.  Figure 7. That is, a new vertex or new edge has to be registered first and then their counters increment. For an old vertex or old edge, it is not registered again, but its counter increments.

2) EAT Statistic Algorithm (EAT-SA)
The EAT-SA is for statistic computing of the numbers of vertices, edges, and facets. Figure 8 shows the pseudocode of EAT-SA, which can be also translated easily into VC++ or other computer languages.
The EAT-SA can be put at the end of the modeling companion for the    When considering that there are numerous facets in a complicated surface model, there may exist a large number of defects in the whole unverified model [9]. In the progressive test way, a large problem of numerous defects can be divided into smaller ones with several defects. It is easier to conquer each of smaller sub-problems by correcting one of them at a time than the larger repair problem of the complex surface model as a whole in one step.

Progressive EAT Procedure
As known before, a surface modeling is a progressive process, and the EAT-SA can be done at different stages as well. It means that it can be used to test an unfinished model in which some facets have been constructed and others have not been.
We can set a test point and make an EAT-SA calling just after the drawing of the unfinished model. The EAT algorithm can help check whether or not the partial model has the Euler characteristic equal to that of its corresponding part of the target surface. If yes, the partial model has been verified. If not, the EAT-TA can locate the faults that are indicated to correct.
After the previous partial model has been corrected and verified, the modeling is resumed. We call the test point that has just been verified the last verified point. In the next section, some EAT applications will be presented, which can illustrate the progressive EAT procedure clearly.

EAT Applications and Results
In this section, the EAT algorithm is applied to test the stamp model, shown in Figure 1. In Sections 4.1, 4.2, and 4.3, we present three application cases that show the models with some faults tested by the EAT scheme. In Section 4.4, we will present the model companion accompanied by the progressive EAT procedure at several stages.

The First Case with a Defect Tested by EAT
In this section, we present a partial stamp model that has a tiny triangle without filling. The triangle is so small that is almost invisible.
In this case, the modeling before the last verified point has been verified, shown in Figure 9. To make the views distinct, facets in different parts are depicted with different colors, seen in the front view and side view of fill-area images of Figure 9(a) and Figure 9(b). In Figure 10, the tested results with the EAT scheme on the partial model in Figure 9 show that the number of vertices, edges, and facets of the partial model are 1658, 2938, and 1279, respectively. Its Euler characteristic is −1, which is the same as that of the corresponding compact surface with two inside holes.    triangle is too small to be identified in Figure 12(a) and Figure 12(b).
After the image with the invisible empty triangle in Figure 12 having been zoomed in and turned to be illuminated, a tiny white point appears at the joint between the green and the purple parts circled by the black rectangle of Figure   13(a). Figure 13(b) is the image in the black rectangle in Figure 13(a) that is zoomed in even closer. In Figure 13 The bottom four rows of Figure 14 show the results at the current test point. The number of vertices is 1738, the number of edges is 3090, and the number of facets is 1351. The Euler characteristic is −1, which is the same as that of the corresponding compact surface with two inside holes, −1. This partial stamp model has been modified and verified at this stage.      Figure 13 having been corrected, and its Euler characteristic of −1.

The Second Case with a Defect Tested by EAT
In this section, we present the second case with a quad that was ignored before and is tested by EAT.
The modeling before the last verified point has been verified, shown in Figure  15. Figure 15(a) is the front view of fill-area image; Figure 15(b) is the side view of fill-area image. In Figure 16, the results at the last verified point show that the number of vertices, edges, and facets of the partial model are 2189, 3963, and 1773, respectively. Its Euler characteristic is −1, which is the same as that of the corresponding compact surface with two inside holes.
After the last verified point, some facets are added to the modeling. A new current test point is set and the EAT is executed. Figure 17 shows the results at the current test point. The Euler characteristic is −2, which is different from the Euler characteristic of the corresponding compact surface with two inside holes, −1. Figure 18(a) is the front view of fill-area image of the partial model before this current test point, and Figure 18(b) is its side view of fill-area image. In Figure 18, the fault is invisible.
Let us take a closer look at the newly-added facets, shown in Figure 19. A narrow white quad appears at the joint between the green and the orange parts marked by the black rectangle of Figure 19(a). Figure 19(b) is the image circled by the black rectangle in Figure 19(a), which is zoomed in even closer. In Figure 19(b), we can see the empty quad more clearly, which looks like a narrow belt. It is so small that it can be seen only in a proper direction. That is why the quad is difficult to be found.    three edges.
The top second, third, fourth and fifth rows of Figure 20 are the information of four edge items of the filled quad, which are edge items with eIDs 4007, 4010, 4013, and 4045, respectively. Three of their edge counter (ec) values are 2. 2 of ec means each of them connects two facets. One of them is 1, which means that when this quad facet is constructed, the edge item of eID 4045 is a new edge, shown in Figure 7.
The bottom four rows of Figure 20 show the results at the current test point. The number of vertices is 2255, the number of edges is 4082, and the number of    Figure 19 is modified. The top first row is vID and vertex counter (vc) value of each vertex item of the modified quad. The top second, third, fourth and fifth rows are eID and edge counter (ec) value of each edge item of the modified quad. The bottom half is the results of numbers of vertices, edges, and facets of the partial stamp model in Figure 19 that has been corrected, and its Euler characteristic of −1.

The Third Case with a Defect by EAT
In this section, we present the third case with a fault that is counter-intuitive and tested by EAT.
In this case, we still use the partial model stage in Figure 15 as the last verified point. In the newly-added facets, we set a new test point and search for a problem different from the previous two.
In Figure 21, the front and side views of fill-area and wire-frame images are shown. Let us zoom in the image of Figure 21(c) and take a closer look at the right top corner of the top character, circled by the blue rectangle in Figure   22(a). Figure 22(b) and Figure 22(c) are amplified images in the blue rectangle of Figure 22(a). In Figure 22 Figure 24. Compared to the results in Figure 23, there are five vertex items in Figure 24, but four vertex items in Figure 23. The vertex item of vID 2566 is added to this pentagon facet. There are five edge items in Figure 24  In Figure 23, the number of vertices is the same as 2255 in Figure 24. Both numbers of facets in Figure 23 and Figure 24 are equal to 1826. But the number of edges, 4083, in Figure 23, is one more than 4082 in Figure 24. Therefore, the Euler characteristic, −2, in Figure 23, is one less than that −1 in Figure 24.
In Section 4.4, we will present the stamp model companion accompanied by the progressive EAT procedure at several steps until the whole model construction is finished and verified.

Testing the Stamp Model at Several Stages with EAT
In this section, we present the construction process of the stamp model accompanied by the EAT procedure. Because of the limitation of this paper length, we only display four typical stages in this process. Of course, the real construction process of the stamp model has been tested and modified at far more than four stages because it has many details of the geometrical and topological structures. The corresponding fill-area images are shown in Figure 25 In Figure 26, four rows are the results of numbers of vertices, edges, and facets of the unfinished model in Figure 25, and its Euler characteristic, respectively. We can see that the number of vertices is 1213, the number of edges is 2054, and the number of facets is 840. Its Euler characteristic is −1. This Euler characteristic is equal to one of the corresponding compact surface with two inside holes. Thus, this partial model is verified.  Figure   27(b) and Figure 27(d).

2) Testing Half Top Face
The tested results of the model in Figure 27 are shown in Figure 28. It is seen that the number of vertices is 2809, the number of edges is 5219, and the number of facets is 2410. Its Euler characteristic is 0, which is equal to that of the corresponding compact surface with one inside hole. The partial model is verified at this stage.    view, and side back view of wire-frame images, respectively. Figure 29  We can see that the number of vertices is 5769, the number of edges is 11,134, and the number of facets is 5366. Its Euler characteristic is 1, which is equal to that of the corresponding compact surface without any inside hole. The partial model is verified at this stage.

4) Testing the Whole Stamp Modeling
The whole stamp modeling is finished at this stage, shown in Figure      For the EAT algorithm, there are more application cases than the above. Since we cannot present all of them, we only explain some more features here.
We first explain the meanings of three more indicators of the EAT algorithm in applications, these being the face counter fc, edge counter ec and vertex counter vc.
As known before, during testing, the EAT scans facets of a model one facet after another without any repeated facet. The facet counter fc value of the scanned facet is equal to 1. If its fv is greater than 1, the facet has a defect that must be modified. Because an edge in a simply connected surface model can be connected to two facets at most, the edge counter ec value of the edge is smaller than or equal to 2. If the ec value is greater than 2, the edge has a defect that must be modified or the tested surface model is not simply connected. The value of a vertex counter vc in a scanned facet can be a positive integer, which means there are vc number of edges connected to the vertex item.
In addition, for the model companion, one of the important features of the EAT algorithm is that the defect of a facet can be tested, found, and immediately modified at the stage of this facet modeling. In this way, a verified model can be always provided to the succeeding process, shown in Figure 2.

Conclusions
With the algebraic topology, the EAT algorithm opens a new test window for observing and examining surface modeling in surface construction and reconstruction. It computes the Euler characteristic of a model, and examines the topologic consistence of the model by comparing the Euler characteristic of the model with that of its target surface.
The EAT algorithm consists of two functions: EAT testing algorithm (EAT-TA) and statistic algorithm (EAT-SA). Both functions are short and flexible, so they are easily inserted in a model companion program. Even better, a clean and verified model can be provided without the EAT code left after the EAT-searching.
The EAT algorithm is adaptable and can be used to test different polygon facets of various surface models in surface construction and reconstruction. The EAT algorithm is independent of the metrics of facets. A facet much smaller than most of facets in a model can be identified.
In future, the EAT algorithm will be applied to test more forms of models that may have different values of Euler characteristics and different topologic structures. It can be sure that more potential of the EAT algorithm can be revealed.