# Analytic Form Fitting in Poor Triangular Meshes
## 3 Methodology
### Extraction of Subset \(S\) Based on Fitting Quality  
The dihedral angle-based extraction presents limitations when the input triangle set presents \(C^{1}\) or higher continuity at border \(\partial S\). The extraction of the \(g()\) support subset \(S\) depends on the quality of the \(g()\) fitting and on the type \(\widetilde{\mathscr{S}}\) of the analytical form as follows. **Input:**  
1. \(M(\mathcal{T},\mathbf{P})\): Triangle (two-manifold) set with geometry \(\mathbf{P}\) and topology \(\mathcal{T}\). 2. \(t_{\mathrm{s}}\): selected seed triangle from \(\mathcal{T}\). 3. \(\widetilde{\mathscr{S}}\): type of analytic form (selected by the user from the options cylinder, sphere, cone). **Output:**  
1. \(S\): Largest connected subset of \(M\), formed by triangles from \(M\), containing \(t_{\mathrm{s}}\) and fitting the analytical form of type \(\widetilde{\mathscr{S}}\). 2. \(g()\): The parameters to define the analytic form that fits \(S\). Figure 13 presents a diagram with the general structure of the fitting-based extraction algorithm. The quality of \(g()\) and the extent of the \(S\) support subset impact on each other at every iteration. The algorithm in Figure 13 assumes the existence of an initial set \(S\), its border triangles \(B(S)\) (in \(M-S\)) and an initial estimation for the analytic form \(g()\). This basic \(S\) is formed by the seed triangle (marked by the user) and its neighbor triangles in \(M\). The initial form \(g()\) is estimated as per Section 3.2. \(B(S)\) contains the triangles in \(M-S\) that encircle \(S\). In Figure 13, the process/box \"select candidate triangle from \(B(S)\)\" selects a triangle in \(M-S\) adjacent to the border triangles of current \(S\) to be screened for its belonging to the currently fitted analytic form \(g()\). Figure 14 addresses this task. Its discussion appears after explaining the main algorithm of Figure 13.  
In Figure 13, \(B(S)\) denotes a set of triangles which encircle \(S\), in \(M-S\), and represent an opportunity to expand \(S\) (i.e., they do not differ from \(g()\)). The algorithm acts as long as \(B(S)\) is not empty. A triangle \(t\) from the \(B(S)\) border set is chosen (Figure 14, discussed later). If \(t\) strongly fits \(g()\), it is accepted in \(S\). If \(t\) does not fit \(g()\) in a clear manner, the validity of \(S\) is examined. If \(S\) is a \"mature\" set (\(w()\to 0\), Figure 15, discussed below), \(g()\) it is supposed to be reliable and \(t\) is rejected. If the set \(S\) is \"immature\" (\(w()\to 1\), \(t\) is re-assessed: if its distance to \(g()\) is large, it is rejected. If it is near \(g()\), it is accepted in \(S\). If \(t\) is accepted in \(S\), then it is removed from \(B(S)\) and its neighbors in \(M-S\) are included in \(B(S)\). Additionally, \(g()\) is re-computed against the new, augmented \(S\). If a triangle \(t\) is rejected, it is removed from \(B(S)\). In this case, obviously, its neighbors in \(M-S\) will not be considered to expand \(S\). Figure 13: Algorithm for simultaneous fitting of \(g()\) and extraction of \(g()\) support subset \(S\). We use a \(w():R^{+}\rightarrow[0,1]\) heuristic function (Figure 15) as a measure of the immaturity of \(S\). Let \(u=N_{S}/N_{T}\) be the ratio between the instant size of \(S\) and a threshold number of triangles \(N_{T}\), which is considered the size of a \"mature\" \(S\). The function \(w(u)\) satisfies:  
* \(w(0)\ =1\) (\(S\) is immature, has few triangles). * \(w(u)\ =0\) for all \(u\geq 1.0\) (\(S\) is mature, has many triangles). * \(w(u)\) is monotonically decreasing in \(\mathbb{R}^{+}\)  
Figure 14 presents an expansion of the process/box \"select candidate triangle from \(B(S)\) \" in Figure 13, as follows: (1) A triangle \(t\) of the triangle border of \(S\) (\(B(S)\)) is selected. (2) The neighbors of triangle \(t\) outside \(S\) are determined, forming set \(N_{t}\). (3) From the set \(N_{t}\), triangles are eliminated whose dihedral angle with \(t\) is large (i.e., form sharp edges with \(t\)).