STL is a data format for representing outer surface models. Its principle is to break down the surface of a 3D object into a large number of triangular facets. Each triangular facet stores the coordinates of three vertices and a face normal vector (pointing to the outside of the model). Curved surfaces are not represented using analytical equations; instead, they are approximated and fitted using a massive number of small triangles. Unlike parametric solid CAD data formats, STL only stores the surface, not the internal solid; it lacks units, colors, materials, textures, CAD feature history, assembly trees, and other information.
The data in an STL file must be a closed manifold mesh; otherwise, it cannot be used for subsequent 3D printing or finite element computation. At the same time, the vertices in STL data are stored redundantly, meaning there are no “edges,” no “face ownership,” no sharp angle features, and no concept of inside versus outside. This imposes certain limitations on setting boundary conditions for subsequent finite element analysis, requiring the construction of curved surfaces or sharp edges through parameterization.
STL has a vast range of use cases. For example, in 3D printing and additive manufacturing, STL is the de facto standard exchange format. 3D scanners (laser or structured light) output point clouds that are reconstructed into triangular meshes, which can be used for part replication, cultural heritage digitization, and shape inspection. In addition, it is widely used in geometric inspection, model repair, and visual preview.
Mesh Generation Algorithms
STL surface mesh data cannot be directly used for finite element computation; it needs to be remeshed into high-quality volumetric meshes. There are two common classical methods: the Direct Method and the Surface Classfication Method. The main difference between these two methods is whether facet clustering is performed on the STL data. The Direct Method has a simpler workflow, performs no sharp-edge recognition, and does not repair geometric defects, but it has more stringent requirements for the watertightness of the STL data. The Surface Classfication Method supports more flexible human-computer graphic interaction operations while simultaneously splitting multiple geometric faces to support more complex models.
Direct Method
The Direct Method involves building a single closed shell directly based on the STL surface mesh. The steps are as follows:
1.Read STL data and build the enclosure topology.
- Vertex merging (removing duplicate vertices): Each triangle in an STL file stores its vertices independently, resulting in a large number of duplicate coordinate points. Coincident vertices are merged based on a floating-point tolerance to establish a global vertex list.
- Build edge-triangle adjacency relationships: Iterate through all triangles, extract each edge, and record how many triangular facets share each edge.
- Topology checking: Identify boundary edges (belonging to only 1 triangle) and internal edges (belonging to 2 triangles); detect non-manifold edges (≥ 3 triangles sharing a single edge); check if the shell is closed: if isolated boundary edges exist, determine that the shell surface is not closed.
- Facet normal consistency check: Iterate through the facets and attempt to unify the outward normals. If the normals in the STL file are disorganized, it may lead to errors in subsequent mesh generation.
- Build shell topology: Assemble the complete boundary triangular facet data structure for subsequent meshing algorithms (such as the Advancing Front method) to read boundaries.
2.Perform 1D edge meshing, 2D surface meshing, and 3D volumetric meshing respectively. For 3D volumetric meshing, the classical Advancing Front method or parallel tetrahedral Delaunay method can be used. 3.Mesh optimization. Optimize the overall mesh by inspecting element quality. Element quality optimization removes flat “thin elements” and improves the convergence of finite element computation.
Facet Classification Method
In many practical applications, we hope to generate a topology similar to a CAD model to make it easier to set up finite element boundary and other conditions later. In this case, the Facet Classification Method can be used to combine all facets into multiple geometric faces, effectively generating discrete B-Rep data. This process also handles complex or defective STL data better. The steps for the Facet Classification Method are as follows:
1.Read STL data and directly build the shell topology.
- Classify triangular facets based on normal angles: If the normal angle between adjacent triangles - namely the dihedral angle - is less than a threshold, they are grouped into the same smooth surface; if it exceeds the threshold, it is determined to be a sharp edge, used to capture corners.
- Determine and store the correspondence between edges and triangular facets.
- Perform classification and grouping on a large number of discrete STL triangular facets based on the surface triangular mesh’s adjacency relationships, dihedral angles, curvature, and non-manifold markers. Triangles belonging to the same smooth geometric surface are categorized into one group, and the dividing boundaries (edges, non-manifold edges) are marked, outputting a set of connected facet regions.
2.Build discrete solid. Based on the categorized facets, reconstruct geometric solids (faces, lines, points) to transform the discrete triangular mesh into a geometric model resembling a B-Rep. The method is to create a B-Rep geometric entity for each cluster. If high-order elements need to be created, the discrete surface can also be fitted into a UV-parameterized surface, upgrading the pure surface mesh into geometric faces or lines that can be recognized and manipulated by CAD modules. 3.Combine all outer surfaces into a closed surface loop to define a closed shell. Typically, the first surface loop is used as the outer closed shell; all subsequent incoming surface loops are internal cavities (holes), which are excavated from the outer domain. A 3D solid domain is then built on the basis of this shell to serve subsequent 3D volumetric meshing. 4.Perform 1D edge meshing, 2D surface meshing, and 3D volumetric meshing respectively. (Same as the Direct Method) 5.Mesh optimization. (Same as the Direct Method)
Conclusion
This article introduced two classical methods for generating finite element meshes from STL models. Because STL data lacks topological data compared to CAD models like B-Rep, it brings more challenges to mesh generation. In practical engineering, one often encounters defective STL files - such as those that are insufficiently airtight, contain holes, non-manifold edges, self-intersections, or inverted facet normals - which further increase the difficulty of meshing and place high demands on the robustness of the mesher.
The algorithms introduced in this text can also be used to repair STL files to reduce various issues that arise during subsequent meshing. Furthermore, these algorithms can also be applied to finite element meshing for other surface models such as OBJ, 3MF, OFF, and PLY.