An introduction to Geometrical Modelling and Mesh Generation The

Transcription

An introduction to Geometrical Modelling and Mesh Generation The
An introduction to Geometrical Modelling and Mesh
Generation
The Gmsh Companion
Christophe Geuzaine
Emilie Marchandise
Jean-François Remacle
2
Contents
1 Introduction
1.1
7
The Design of Gmsh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8
1.1.1
Fast and Light . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8
1.1.2
User-friendly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9
2 Solid Models
2.1
2.2
13
Principal characteristics of a solid modeling software . . . . . . . . . . . . . 13
2.1.1
Feature-based modeling . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.1.2
Constraint-based modeling . . . . . . . . . . . . . . . . . . . . . . . 13
2.1.3
Parametric modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.1.4
History-based modeling . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.1.5
Associative modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
CSG Representation of Solids . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.2.1
Basic Primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.2.2
Regularized Boolean Operators . . . . . . . . . . . . . . . . . . . . . 15
2.2.3
The CSG tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.2.4
Gluing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.3
Boundary Representation of Solids . . . . . . . . . . . . . . . . . . . . . . . 18
2.4
Topological Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.4.1
Winged-edge data structure . . . . . . . . . . . . . . . . . . . . . . . 19
2.4.2
Manifold and Non-Manifold models
2.4.3
Non-manifold topologies . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.4.4
Internal representation of solid models in Gmsh . . . . . . . . . . . . 25
3
. . . . . . . . . . . . . . . . . . 20
4
CONTENTS
2.5
2.6
2.7
2.8
Geometrical Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.5.1
Differential Geometry of Curves
. . . . . . . . . . . . . . . . . . . . 31
2.5.2
Differential Geometry of Surfaces . . . . . . . . . . . . . . . . . . . . 34
2.5.3
Classifying the parametrizations . . . . . . . . . . . . . . . . . . . . 37
2.5.4
Computing harmonic and conformal maps . . . . . . . . . . . . . . . 38
2.5.5
Examples of analytical parametrizations . . . . . . . . . . . . . . . . 41
Non-Uniform Rational b-Splines (NURBS) . . . . . . . . . . . . . . . . . . . 44
2.6.1
NURBS curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
2.6.2
NURBS surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Surface Intersections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
2.7.1
Intersection two implicit surfaces . . . . . . . . . . . . . . . . . . . . 48
2.7.2
Intersection of a parametric surface with an implicit surface . . . . . 50
2.7.3
From parametric to implicit representations . . . . . . . . . . . . . . 51
2.7.4
Intersection of NURBS . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Geodesics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3 Mesh Generation
3.1
3.2
57
Generalities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
3.1.1
The Euler-Poincaré Formula . . . . . . . . . . . . . . . . . . . . . . . 58
3.1.2
Mesh generation procedure . . . . . . . . . . . . . . . . . . . . . . . 61
Mesh size field and quality measures . . . . . . . . . . . . . . . . . . . . . . 63
3.2.1
Mesh size field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.2.2
Element quality measures . . . . . . . . . . . . . . . . . . . . . . . . 64
3.3
One Dimensional Meshing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
3.4
Delaunay and Voronoı̈ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
3.5
3.4.1
The Voronoı̈ diagram
. . . . . . . . . . . . . . . . . . . . . . . . . . 65
3.4.2
The Delaunay Triangulation . . . . . . . . . . . . . . . . . . . . . . . 68
3.4.3
Construction of Delaunay Triangulations
. . . . . . . . . . . . . . . 75
Planar Meshing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
3.5.1
The general procedure . . . . . . . . . . . . . . . . . . . . . . . . . . 85
3.5.2
Boundary edges recovery . . . . . . . . . . . . . . . . . . . . . . . . 89
CONTENTS
5
3.5.3
Point insertion and Delaunay kernel . . . . . . . . . . . . . . . . . . 89
3.5.4
Anisotropic Delaunay meshing . . . . . . . . . . . . . . . . . . . . . 92
3.5.5
Practical implementation . . . . . . . . . . . . . . . . . . . . . . . . 93
3.6
Surface Meshing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
3.7
3-D Mesh Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
3.7.1
Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
3.7.2
Mixed Meshes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
4 Remeshing based on surface parametrization
107
4.1
Parametrization of triangulated surfaces . . . . . . . . . . . . . . . . . . . . 109
4.2
Computing discrete harmonic and conformal maps . . . . . . . . . . . . . . 112
4.3
Boundary conditions for discrete maps . . . . . . . . . . . . . . . . . . . . . 115
4.4
Issues with discrete linear mappings . . . . . . . . . . . . . . . . . . . . . . 121
4.5
Automatic remeshing with parametrizations . . . . . . . . . . . . . . . . . . 125
4.6
4.5.1
Multiscale Laplace partitioning method . . . . . . . . . . . . . . . . 126
4.5.2
Automatic algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Quality remeshing with parametrizations . . . . . . . . . . . . . . . . . . . . 126
6
CONTENTS
Chapter 1
Introduction
When we started the Gmsh project in the summer of 1996, our goal was to develop a
fast, light and user-friendly software to easily create geometries and meshes that could
be used in our three-dimensional finite element solvers [?], and then visualize and export the computational results with maximum flexibility. At the time, no open-source
software combining a CAD engine, a mesh generator and a post-processor was available:
the existing integrated tools were expensive commercial packages [?], and the freeware
or shareware tools were limited to either CAD [?], two-dimensional mesh generation [?],
three-dimensional mesh generation [?, ?, ?], or post-processing [?]. The need for a free
integrated solution was conspicuous, and several projects similar in spirit to Gmsh were
also born around the same time—some of them still actively developed today [?, ?]. Gmsh
however was unique in its design: it consisted of a very small kernel with four modules
(geometry, mesh, solver and post-processing), not tied to any particular computational
solver, and designed from the start to be driven both using a user-friendly graphical interface (GUI) and its own scripting language.
The first public release of Gmsh occurred in 1998. This version was Unix-only, distributed over the internet in binary form, with the graphics layer based on OpenGL [?] and
the user interface written in Motif [?]. After several updates and a short-lived Windowsonly fork in 2000, the whole user interface was rewritten using FLTK [?] in early 2001, and
the code, still in binary-only form, was released for Windows and a variety of Unix operating systems. In 2003 the full source code was released under the GNU General Public
License [?], and it was modified to provide native support for all major operating systems:
Windows, MacOS and all Unix/X11 variants. In the summer of 2006 Gmsh underwent
a major rewrite, which led to the release of version 2 of the software in February 2007.
About 50% of the code in version 2 is new: an abstract geometrical and post-processing
layer has been introduced, the mesh data structures and algorithms have been rewritten
from scratch, and the graphics layer has also been completely overhauled.
Today Gmsh enjoys a thriving community of several hundred users and developers
worldwide. It is driven by the need of researchers and engineers in academia and industry
7
8
CHAPTER 1. INTRODUCTION
alike for a small, open-source pre- and post-processing solution for grid-based numerical
methods. The aim of this paper is not to be a user’s guide or a reference manual—see [?]
instead. Rather, it is to present the philosophy and the original features of Gmsh which
make it stand out from its free and commercial alternatives.
The paper is structured as follows. In Section 1.1 we outline the overall philosophy
and design goals of Gmsh, as well as the main technical choices that were made in order to
achieve these goals. Sections ??, ??, ?? and ?? then respectively describe the geometry,
mesh, solver and post-processing modules. The paper is concluded in Section ?? with
perspectives for future developments.
1.1
The Design of Gmsh
Gmsh is built around four modules: geometry, mesh, solver and post-processing. Each
module can be controlled either interactively using the GUI or using the scripting language.
The design of all four modules relies on a simple philosophy—be fast, light and
user-friendly.
Fast: on a standard personal computer at any given point in time Gmsh should launch
instantaneously, be able to generate a “larger than average” mesh (compared to the
standards of the finite element community; say, one million tetrahedra in 2008) in
less than a minute, and be able to visualize such a mesh together with associated
post-processing datasets at interactive speeds.
Light: the memory footprint of the application should be minimal and the source code
should be small enough so that a single developer can understand it. Installing
or running the software should not depend on any non-widely available third-party
software package.
User-friendly: the graphical user interface should be designed in such a way that a new
user can create simple meshes in a matter of minutes. In addition, the code should
be robust, portable, scriptable, extensible and thoroughly documented—all features
contributing to a user-friendly experience.
In the following sections we describe the technical choices that we made to achieve
these sometimes conflicting design objectives. Although major parts of the code have been
rewritten over the years, the overall initial architecture and design from 1996 have always
stayed the same.
1.1.1
Fast and Light
In order to be fast and light in the sense just described above, Gmsh is entirely written in
standard C++ [?]—both the kernel and the user interface.
1.1. THE DESIGN OF GMSH
9
The kernel uses BLAS [?] (through the GSL, the GNU Scientific Library [?]) for
most of the basic linear algebra. To keep them easy to understand the algorithms have
not been overly optimized for speed or memory usage, yet Gmsh currently generates about
a million tetrahedra per minute and per 150 Mb of RAM on a standard personal computer,
which makes it powerful enough for many academic and engineering applications.
The graphical interface is built using FLTK [?] and OpenGL [?]. Using FLTK instead
of a larger or more complex widget toolkit, like for example Java, TCL/TK, GTK or QT,
allows to link Gmsh statically with the toolkit. This tremendously reduces the launch time,
memory footprint and installation complexity (installing Gmsh requires copying a single
executable file), as well as the build time—a statically linked, ready to use executable is
produced in a few minutes on a standard personal computer. Analogously, directly using
OpenGL instead of a more complex graphics library like Inventor [?] or VTK [?] makes
Gmsh lightweight, without sacrificing rendering performance (Gmsh makes extensive use
of OpenGL vertex arrays).
The design of the solver and scripting interfaces follows the same strategy: the solver
interface is written using standard Unix and TCP/IP sockets instead of, e.g., Corba [?],
and the scripting interface is built using Lex/Flex and Yacc/Bison [?] instead of using an
external scripting language like, e.g., Python.
1.1.2
User-friendly
Although Gmsh can be built as a library (which can then be linked with other software
tools), it is usually distributed as a stand-alone software, ready to be used by end users.
This stand-alone version can be run either interactively using the graphical user interface
or in a non-interactive mode—either from the command line or via the scripting language.
Achieving “user-friendliness” has been an important driving factor behind key technical choices. We detail some of these choices hereafter, focusing on the list of desirable
features given at the beginning of the section.
Robustness and Portability
To achieve robustness, i.e., working for the largest possible range of input data and being
as tolerant as possible to erroneous user input, we use robust geometrical predicates [?]
in critical portions of the algorithms, and strive to provide useful error messages when an
unmanageable exception is triggered.
In order to easily produce a native version of the code on all major operating systems,
Gmsh is written entirely in standard C++, and uses portable toolkits for its GUI (FLTK)
and graphics rendering (OpenGL). Open-sourcing Gmsh under the GNU General Public
License [?] also helped portability, as the code was made part of several official Linux
distributions (most notably Debian [?]), and thus benefited from their extensive automated
testing infrastructure. Either with the graphical user interface or in batch mode, the same
10
CHAPTER 1. INTRODUCTION
version of Gmsh now runs on most computers, from laptops to workstations and large
HPC clusters.
Scriptability
Gmsh is scriptable so that all input data can be parametrized, and so that Gmsh can be
easily inserted as a component inside a larger computational chain. As mentioned above,
scripting is implemented in Gmsh using Lex and Yacc. The tight integration with the
resulting language means that full access to internal capabilities is provided, including
bidirectional access to more than 500 internal options fine-tuning the behavior of the four
modules. The scripting language allows for example to fully parametrize all geometrical
entities, to interface external solvers without modifying the source code, or to automate
all post-processing operations, e.g., to create complex animations or perform off-screen
rendering [?].
Extensibility
We tried to ease the modification and addition of features by users and developers. Such
extensibility takes different forms for each of the four modules:
Geometry: the abstract, object-oriented geometry layer permits to write all the algorithms independently of the underlying CAD representation. At the source code
level Gmsh is thus easily extensible by adding support for additional CAD engines.
Currently two engines are interfaced: the native Gmsh CAD engine and OpenCascade [?]. Adding support for other engines like, e.g., Parasolid [?], can be done
simply by deriving four abstract classes—see Section ??. At the scripting level users
can then transparently mix and match geometrical parts represented internally by
different CAD engines. For example, it is possible to extend an OpenCascade model
of an airplane with a terrain model defined in the scripting language.
Mesh: using the abstract geometrical interface it is also possible to interface additional
meshing kernels. Currently, in addition to its own meshing algorithms (see Section ??), Gmsh is interfaced with Netgen [?] and Tetgen [?].
Solver: a socket-based communication interface allows to interface Gmsh with various
solvers without changing the source code; tailored graphical user interfaces can also
easily be added when more fine-grained interactions are needed.
Post-processing: the post-processor can be extended with user-defined operations through
dynamically loadable plug-ins. These plug-ins act on post-processing datasets (called
views) in one of two ways: either destructively changing the contents of a view, or
creating one or more views based on the current view.
1.1. THE DESIGN OF GMSH
11
All source code-level extensions can be enabled or disabled at compile time thanks to
an autoconf-based build mechanism [?], which selects which parts of the code to include/exclude.
Documentation and Open File Formats
Documentation is provided both in the source code and in the form of a reference manual,
including several hands-on tutorial examples and a comprehensive web site with several
mailing lists and a wiki.
Another important feature contributing to user-friendliness is the availability of
standard input and output file formats. Gmsh uses open or de facto standard formats
whenever possible, from standard bitmap graphics formats (JPEG, GIF, PNG) and vector formats [?] (SVG, PostScript, PDF) to mesh formats (Ideas UNV, Nastran BDF).
Combined with the open-source release of the code this greatly facilitates the integration
of Gmsh with other computational tools.
12
CHAPTER 1. INTRODUCTION
Chapter 2
Solid Models
A solid model is a computer model of a 3D solid. It is a virtual representation of the shape
of a solid. Solid models can be simple parts (Figure 2.1, part (a)) or complex assemblies
of multiple parts (Figure 2.1, part (b)).
We aim here at explaining how such solids can be described on a computer. We will
principally focus on the ability of such solid models to serve as input to numerical simulations. In particular, we will adress the issues related to finite element mesh generation.
2.1
Principal characteristics of a solid modeling software
A solid modeling software may have some specific characteristics that enables to enhance
both its efficiency and the productivity of the solid modeling process:
2.1.1
Feature-based modeling
Features are defined to be parametric shapes associated with attributes such as intrinsic geometric parameters (length, width, depth etc), position and orientation, geometric
tolerances, material properties, and references to other features.
Feature-based modelers allow operations such as creating holes, fillets, chamfers,
bosses, and pockets to be associated with specific edges and faces. When the edges or
faces move because of a regeneration, the feature operation moves along with it, keeping
the original relationships.
2.1.2
Constraint-based modeling
There are two types of constraints. Dimensional constraints are used to specify distances
between items. Geometric constraints define positional relationships between entities in
13
14
CHAPTER 2. SOLID MODELS
(a)
(b)
Figure 2.1: A simple part (a) and a complex assembly (b).
the model in terms of the geometry. Examples of geometric constraints include tangency,
parallelism, symmetry, concentricity...
Constraint-based modeling allows the engineer or designer to incorporate “intelligence” into the design. The initial sketch of a two-dimensional profile in constraint-based
solid modeling does not need to be created with a great deal of accuracy. It just needs to
represent the basic geometry of the cross section. The exact size and shape of the profile
is defined through assigning enough parameters to fully “constrain” it.
2.1.3
Parametric modeling
Parametric modeling means that parameters of the model may be modified to change
the geometry of the model. A dimension is a simple example of a parameter. When a
dimension is changed, the geometry of the part is updated. Thus, the parameter drives the
geometry. An additional feature of parametric modeling is that parameters can reference
other parameters through relations or equations. The power of this approach is that
when one dimension is modified, all linked dimensions are updated according to specified
mathematical relations, instead of having to update all related dimensions individually.
2.1.4
History-based modeling
The last aspect of solid modeling is that the order in which parts are created is critical.
This is known as history-based modeling. For example, a hole cannot be created before a
solid volume of material in which the hole occurs has been modeled. If the solid volume
is deleted, then the hole is deleted with it. This is known as a parent-child relation. The
2.2. CSG REPRESENTATION OF SOLIDS
15
child (hole) cannot exist without the parent (solid volume) existing first. Parent-child
relations are critical to maintaining design intent in a part. Most solid modeling software
recognizes that if you delete a feature with a hole in it, you do not want the hole to remain
floating around without being attached to the feature. Consequently, careful thought and
planning of the base feature and initial additional features can have a significant effect on
the ease of adding subsequent features and making modifications.
2.1.5
Associative modeling
The associative character of solid modeling software causes modifications in one object to
“ripple though” all associated objects. For instance, suppose that you change the diameter
of a hole on the engineering drawing that was created based on your original solid model.
The diameter of the hole will be automatically changed in the solid model of the part,
too. In addition, the diameter of the hole will be updated on any assembly that includes
that part. Similarly, changing the dimension in the part model will automatically result
in updated values of that dimension in the drawing or assembly incorporating the part.
This aspect of solid model software makes the modification of parts much easier and less
prone to error.
As a result of being feature based, constraint based, parametric, history based, and
associative, modern solid modeling software captures “design intent”, not just the design.
This comes about because the solid modeling software incorporates engineering knowledge
into the solid model with features, constraints, and relationships that preserve the intended
geometric relationships in the model.
2.2
CSG Representation of Solids
We discuss here briefly the Constructive Solid Geometry (CSG) representation of solids.
CSG allow to construct complex solid through primitives, boolean operators and rigid
motions.
2.2.1
Basic Primitives
The standard CSG basic primitives are the sphere, the torus, the parallelipiped (block), the
cylinder and the cone. All those primitives defined bounded closed orientable domains. All
basic primitives are defined in the world system of coordinates. Rigid motions (rotations,
translations) and scalings can be applied to re-position the primitives.
2.2.2
Regularized Boolean Operators
Each primitive divides the 3D space into two parts: the one that is inside the primitive
and the one that is outside. The closure of a primitive is the surface that separates its
16
CHAPTER 2. SOLID MODELS
interior with its exterior.
It is easy to think a primitive as a set where standard boolean operations like union,
intersection and difference can be defined. Basic primitives can be combined using boolean
operations. Three boolean operators are defined. Consider two primitives A and B.
1. The Union A ∪ B operation returns of all the points x ∈ R3 that are either inside A
or inside B.
2. The Intersection A ∩ B operation returns of all the points x ∈ R3 that are both
inside A and inside B.
3. The Difference A \ B operation returns of all the points x ∈ R3 that are inside A
and outside B.
Regularized boolean operators differ from the set-theoretic ones in that dangling
lower dimensional structures are eliminated, all remaining faces, edges and vertices belonging to the closure of the resulting volume.
2.2.3
The CSG tree
A CSG object can be easily represented in a tree structure where the leaves of the tree
are simple primitives, nodes of the tree are solids, edges of the tree are boolean operations
and where the root of the tree is a solid that is the final CSG object. Figure 2.2 shows an
example of a simple CSG tree.
Most of the current commercial solid modelers enable to use CSG trees. Designing
robust algorithms for computing both the geometry and the topology of surface intersections is a complex problem. A few number of softwares enable to perform CSG computations efficiently and, to our best knowledge, only one is open source. In Gmsh, we have
interfaced Opencascade primitives and operators to build the solid of Figure 2.2. The
Gmsh lua interface code for building this solid is
R = 1.0;
s = .7;
t = 1.3;
myModel = GModel();
myTool = GModel();
myTool:addSphere(0,0,0,R*t);
myModel:addBlock({-R,-R,-R},{R,R,R});
myModel:computeIntersection(myTool,0);
myTool2 = GModel();
myTool2:addCylinder({-2*R,0,0},{2*R,0,0},R*s);
myTool3 = GModel();
myTool3:addCylinder({0,-2*R,0},{0,2*R,0},R*s);
2.2. CSG REPRESENTATION OF SOLIDS
17
T
S
S
Figure 2.2: Example of a CSG tree.
\
18
CHAPTER 2. SOLID MODELS
myModel2 = GModel();
myModel2:addCylinder({0,0,-2*R},{0,0,2*R},R*s);
myModel2:computeUnion(myTool2,0);
myModel2:computeUnion(myTool3,0);
myModel:computeDifference(myModel2,0);
2.2.4
Gluing
Consider two spheres A and B both centered at the origin and of radiuses 2 and 1. The
Union A ∪ B returns A, i.e. the closure of B has been eliminated. The Difference A \ B
returns a sphere with a hole. At some point, it can be useful to build
C = (A \ B) ⊕ (A ∩ B)
where ⊕ is not a regularized boolean operator but that simply adds the two volumes A \ B
and A ∩ B in the same model. The model contains two volumes that share a common
boundary. Our aim here being to build a model that has a topology, vertices, edges and
faces that are geometrically identical should be glued together in order to defined a proper
topology to the model. This kind of gluing operator has to be present in any modeler.
2.3
Boundary Representation of Solids
The CSG representation of a solid is used as a method for the construction of solids. This
construction allows to test wether a point is inside or a solid, is on its surface or is outside
of it. This is usually called point/solid classification. Point/solid classification can be
done walking first downward the CSG tree in order to classify the point with respect to
the primitive that are on the leaves. Then, an upward sweep enables to apply the boolean
operations that will determine the classification.
Yet, CSG representation alone cannot represent accurately the boundaries of the
solid. CSG representation are “top-down” representations because they consider high
level primitives and combine them to represent complex parts. It is indeed possible to
imagine a “bottom-up” representation where every model entity is represented using its
boundary.
The boundary representation of a model also allows to determine whether a position
is inside, outside, or on the boundary of a volume. This distinguishes a solid modeler from
a surface or wireframe modeler. The “boundary” in “boundary representation” is the
boundary between solid material and empty space. This boundary is made from a closed
set of surfaces.
It is common to distinguish the topological part of the boundary representation and
its geometrical part.
Topology is a branch of mathematics concerned with spatial properties preserved
2.4. TOPOLOGICAL REPRESENTATION
19
Figure 2.3: Winged-edge data structure.
under deformation (stretching without tearing or gluing). These properties are the topological invariants. On its own, topology defines a ”rubber” model, whose position is not
fixed in space. For example, a sphere and a cube are topologically equivalent, but not
geometrically.
A topological entity’s shape, position, and orientation are fixed in space when it is
associated with a geometric entity. This is the geometrical part of the boundary representation.
2.4
Topological Representation
Any solid can be represented unambiguously by describing its surface and topologically
orienting it so that, for any point x ∈ R3 , we can tell on which side of the solid this point
lies.
There exist a variety of data structures that allow to represent the topology of
models on a computer. In what follows, we will present the classical winged-edge
structure. Then, we’ll present a more sophisticated version that allow to represent
manifold models. Then, we’ll present the way Gmsh stores the topology of models,
the aim of using that information for mesh generation.
2.4.1
solid
data
nonwith
Winged-edge data structure
Perhaps the oldest data structure for a boundary representation is the winged-edge data
structure. The winged-edge data structure was initially used for representing polygonal
meshes. A common way to represent a polygonal mesh is to define a list of vertices and
a list of faces storing pointers for its vertices. This representation is both convenient
and efficient for many purposes, however it proves ineffective for dynamically modifying
meshes.
The winged-edge data structure has been designed to allow effective local modification of the topology. It describes the topology of objects by three tables. A face is
bounded by closed loops of edges, one of which is the outside boundary (usually the first
one) and the other ones are inner holes. Each vertex stores a circularly ordered set of
adjacent edges. Finally, each edge stores four informations: (i) its two end vertices, (ii)
left and right faces (manifold), (iii) preceding and next edge in clockwise order and (iv)
preceding and next edge in counterclockwise order. Each edge is oriented: its orientation
is given by its starting and ending vertex. Clockwise and counterclockwise orientations
are given with respect of the orientation of the edge (see Figure 2.3). Operations on edges
20
CHAPTER 2. SOLID MODELS
non manifold
zero genus
genus one
Figure 2.4: A non manifold solid(left) and two different topologies generated through a
small variation of the geometry.
like splitting, collapsing or flipping can be performed by doing local operations only.
The winged-edge data structure assumes that every edge of the model has exactly
two adjacent faces. This restricts the topology of surfaces to be 2-manifolds. A surface
embedded in R3 is a 2-manifold if every point x has a neighborhood that can be mapped
continuously into an open set of R2 .
2.4.2
Manifold and Non-Manifold models
A manifold model only contains manifold surfaces. The topological properties of manifold
representations are well understood mathematically. Restricting our attention to manifolds
is attractive because of this mathematical theory. Yet, the result of boolean operations on
manifold solids can lead to a result that is non-manifold. Let us consider the example in
Figure 2.4 and that has been created using the following Gmsh script.
myModel = GModel();
myTool = GModel();
myTool2 = GModel();
myModel:addBlock({-1,-1,-1},{1,1,1});
myTool:addBlock({-.4,-.4,-1},{.4,.4,1});
myTool2:addBlock({.4,.4,-1},{1,1,1});
myModel:computeDifference(myTool,0);
myModel:computeDifference(myTool2,0);
This object is non-manifold: one of its edge has more than 2 adjacent surfaces (actually
4). Any point of this edge has non neighborhood that can be mapped to a subset of R3 .
The resulting figure is non-manifold. Indeed, even if the result of those two boolean
operations is one only solid, it is impossible to define a proper genus to the surface that
2.4. TOPOLOGICAL REPRESENTATION
21
bounds this solid. Slightly different parameters enables to generate either a surface with
genus one or genus zero (see Figure 2.4).
2.4.3
Non-manifold topologies
Here, we describe Weiler’s radial edge non manifold topology data structure. This data
structure is more or less the one that is used in solid modelers like OpenCascade or
ACIS. Both those solid modelers have been interfaced in Gmsh’s abstract topological data
structure. The different entities that appear in such a topology are described below. The
introduction of the notion of co-edge allow to represent non-manifold models.
Body
The body is the highest level of model object, which is composed of zero or more lumps.
Lump
A lump is a set of connected points. It may consist of volumes, sheets, and/or wires. For
a volume the lump includes not only the points on the boundary of the volume, but also
the points in the interior of the volume. For sheets and wires there is no interior; so they
consist strictly of the points on the boundary. Lumps are not necessary. You could design
a topological structure without them. They are sometimes included in the topological
structure for efficiency.
Shell
A shell is a connected set of boundary elements. For sheet bodies and wire bodies, there
is a one-to-one correspondence between lumps and shells. In other words, a sheet body or
wire body with a single lump will have a single shell. For solid bodies, there can be more
than one shell per lump, when there is an interior void in the volume.
Face
A face defines a bounded region on a surface. A face may be a sheet face, in which case
it is exterior to all solid regions, or a face may bound a solid region, in which case it
separates the inside of the solid from the outside of the solid, or a face may be embedded
inside a solid region. A face may be bounded by 0, 1, or more loops of edges. Usually if
a face has multiple loops, it has holes in it, although a loop may degenerate to a single
point, in which case the hole is infinitesimally small. A common example of a face with
two loops, one of which that has degenerated to a single point is a conical face (or any
surface of revolution that contains a point on the revolution axis), where the degenerate
loop is at the apex of the cone.
22
CHAPTER 2. SOLID MODELS
Loop
A loop consists of one or more co-edges and is used to bound a face. A loop of coedges
separates the region that is inside the face from the region that is outside the face. The
direction of a loop of coedges is counter clockwise with respect to an outward pointing face
normal. Multiple loops are required on a face if there are holes in the face, in a similar
way as lumps may have multiple shells. Loops are closed, having no actual start or end
point.
Wire
A wire is a set of connected free edges i.e. that do not bound faces. Wires may contain one
or more edges, be open or closed, have branches, and have multiple circuits. In addition,
a wire may be either outside or inside a volume. If the wire is inside a volume, it can be
interpreted as a 1D inclusion in the volume. A wire cannot be both inside and outside a
volume.
Coedge
Coedges represent the use of an edge by upper topology. The introduction of coedges
allow to represent regions that are non-manifold along an edge. If an edge is used by a
wire, then the edge will have a single coedge. If an edge is used by one or more faces, it
will have a coedge for each use by each face. Indeed, an edge can be used twice by a face,
when the face is on both sides of the edge. There are three terms for edges that are used
twice by a face
• A spur edge is an edge that is not closed and it does not connect to another edge on
one or both ends. In other words, on one or both ends it has a free vertex or a spur
vertex. Spur edges can also exist in wires.
• A prop edge is an edge that is not closed that is used twice by a face and is not a
spur edge. It has adjacent edges at both ends. The exception to this if one or both
of the vertices lie at singularities. A spur edge may have a vertex at which there
are no adjacent edges if the vertex lies at a surface singularity. Prop edges and spur
edges are mutually exclusive.
• A seam edge is a special case of a prop edge. If a prop edge runs along the parametric
boundary of a periodic surface (that is, it splits the face along parametric boundary
of a periodic surface), then it may be called a seam edge.
In general, spur, prop and seam edges are optional for the topology of a face and may be
removed by merging.
2.4. TOPOLOGICAL REPRESENTATION
G03
23
G12
G04
G05
G11
G13
G15
G21
G02
G14
G01
Figure 2.5: A simple 2D model.
Edge
An edge is either part of a wire or used to bound a face. A single edge can bound many
faces. The faces bounded by an edge are obtained from the coedges of the edge. Each
coedge represents the use of an edge by a face (or a wire). An edge has a direction: it
has a start and an end vertex. These may be the same vertex. In addition to spur, prop,
and seam edges, there are a few more terms related to edges. Edges can be categorized
according to their closure. For instance, if an edge has two distinct vertices, then the edge
is open. If the edge start and end vertices of an edge are the same, the edge is closed. If
the edge is closed and underlying curve’s start and end tangent directions are the same,
then the edge is periodic. Another special type of edge is one with zero length. Such an
edge is considered to be a degenerate edge. If a degenerated edge resides in the middle of
a face, it is an isolated vertex.
Vertex
A boundary of an edge. A Vertex corresponds to a point in 3D space.
As an illustration, let us look at the 2D model presented in Figure 2.5. This model
has 1 face, 5 edges and 5 vertices. It has 2 loops and every edge has only one use (i.e. one
co-edge).
Model edge G11 ’s boundary, ∂G11 consist in two signed vertices:
∂G11 = −G02 + G03
which means that model edge G11 goes from model vertex G02 to model vertex G03 .
24
CHAPTER 2. SOLID MODELS
Model face G21 ’s boundary consist in two closed edge loops that consist of respectively
four and one signed model edges:
∂G21 = {−G11 + G14 + G13 − G12 , G51 }.
(2.1)
Model edge G15 is periodic:
∂G51 = G05 − G05 = 0
which makes perfect sense: the boundary of a closed curve is zero. For being consistent,
the boundary of a closed edge loop has also to be zero. In other words,
∂∂G21 = {−∂G11 + ∂G12 + ∂G13 − ∂G14 , ∂G51 }
= {−(G03 − G20 ) + (G04 − G23 ) + (G04 − G21 ) − (G01 − G22 ), G05 − G05 }
= {0, 0}.
Vertices that bound model curves of a model face have to appear once positively and once
negatively. Two things have to be noted. First, ∂G0i = i.e. the boundary of a model
vertex is zero. Then, changing the sign of the boundary representation of a model face
(2.2)
− ∂G21 = −{−G11 + G14 + G13 − G12 , G51 }.
gives the same topological model face, yet with a different sign i.e. a different orientation.
Then, a model region can also be described using its boundary representation. For
example the cube of Figure 2.6 with one model region G31 consist in one closed face loop
∂G31 = {G21 + G22 + G23 + G24 + G25 + G26 + G27 + G28 }
with model face orientations that have to verify
∂∂G31 = 0.
Let us now consider the cylindrical rod of Figure 2.7. The model region G31 is
bounded by three model faces
∂G31 = G21 + G22 + G23 .
Model faces G21 and G22 are usual model faces composed of one only closed edge loop:
∂G21 = G11 and ∂G22 = −G13 .
Model face G23 is different. It is a periodic model face and it has no interior holes. In order
to be consistent with the boundary representation, its boundary representation should be
one single closed loop. In order to achieve that goal, one seam edge, G11 , has to be added
in the model. This seam edge acts like G04 which is both the starting point and the ending
point of G13 . We have then
∂G23 = G11 + G13 − G11 − G12 .
2.4. TOPOLOGICAL REPRESENTATION
25
G22
G19
G01
G15
G05
G16
G02
G06
G12
G13
G110
G18
G07
G23
G111
G03
G17
G21
G11
G08
G112
G14
G04
Figure 2.6: A cube.
The seam model edge G11 appears twice in the same face loop and effectively acts as a
seam that closes the periodic model face.
Figure 2.8, which shows one of the 76 model faces of the propeller in the parametric
space (left) and in real space (right). Three features of surface S, common in CAD
descriptions, make its meshing non-trivial:
1. S is periodic. The topology of the model face is modified in order to define its closure
properly. A seam is present two times in the closure of the model face. These two
occurrences are separated by one period in the parametric space.
2. S is trimmed: it contains four holes and one of them is crossed by the seam.
3. One of the model edges of S is degenerated. This is done for accounting of a singular
point in the parametrization of the surface. This kind of degeneracy is present in
many shapes: spheres, cones and other surfaces of revolution.
2.4.4
Internal representation of solid models in Gmsh
Gmsh never had the ambition of becoming a solid modeling platform that competes with
the few well-established, state of the art CAD engines [?, ?, ?, ?]. The native Gmsh CAD
engine thus has only a limited set of features, well suited for dealing with simple academic
geometries. Yet, over the years, Gmsh has been used by an increasing number of people
in industry, and a strong demand emerged from this user community for Gmsh to be able
mesh industrial CAD models.
26
CHAPTER 2. SOLID MODELS
G22
G13
G04
G11
G12
G23
G05
G21
Figure 2.7: A cylindrical rod.
One option for addressing this demand is to use exchange files, such as IGES (Initial
Graphics Exchange Specification), VRML (Virtual Reality Markup Language) or STEP
(STandard for the Exchange of Product model data). However, the use of such exchange
file formats has always been a cause of trouble in engineering design offices, mainly because
internal data structures of CAD systems are usually much richer than those in the exchange
formats.
Those differences between modelers can be very subtle. Consider for example skinning and lofting. Those two techniques enable to create a model entity (surface or volume)
using curve constraints which the surface passes through. Skinning and lofting are actually
the same technique in Open CASCADE that does not make a difference between them.
ACIS kernel does make a little difference, in terms of types of the inputs parameters and
way of constraints definition. Even though differences are small, a translation between
ACIS and Open CASCADE will generate modelling errors.
Another issue is the importance of modeler tolerances that are not taken into account
in exchange files. Translations always lead to the time-consuming need to “fix” most of
these exchange files before any meshing can be performed.
In Gmsh, we thus chose to deal with CAD engines differently, by providing native
access to the underlying CAD models—without translation files (a similar approach is
used in CAPRI [?]). For that, the geometry module is based on a set of abstract data
structures that enables us to represent the topology of virtually any solid model.
2.4. TOPOLOGICAL REPRESENTATION
27
Figure 2.8: Geometry of a model face in parametric space (left) and in real space (right).
Two seam edges are present in the face. The top model edge is degenerated in one point.
CAD systems are able to represent industrial geometries within the fabrication tolerance. Companies that are in the business have been largely consolidated recently: there
exist a limited number of big players in the CAD modeler market: CATIA (Dassault
Systèmes), Pro EngineerTM (Parametric Technology Corporation), NX (Siemens), AutoCAD or SolidWorks. Some smaller players exist such as Cobalt, MasterCAM, TopSolid, IronCAD or MicroStation that provide “niche” solutions. A lot of those software share the same modelling kernel. Professional modelling kernels are even fewer.
CATIA and ProEngineerTM have their own, SolidWorks, NX, MasterCAM, TopSolid
and MicroStation use Parasolid (Siemens), IronCADTM and Cobalt use ACIS (Dassault Systèmes). There is only one open source modelling kernel: Open CASCADE
(http://www.opencascade.org/). Open CASCADE is the modelling kernel of SALOME
(http://www.salome-platform.org/) that is itself open source under LGPL. Open CASCADE is also the modelling kernel used in SAMCEF Field.
We have seen that 3-D models can be defined using a Boundary Representation. In
Gmsh, only four kinds of model entities are defined:
1. Model Vertices G0i that are topological entities of dimension 0,
2. Model Edges G1i that are topological entities of dimension 1,
3. Model Faces G2i that are topological entities of dimension 2,
4. Model Regions G3i that are topological entities of dimension 3.
Those 4 entities are the only ones that are common to every modelling kernel that we
found. In fact, those are the only ones that have an associated geometry. Model entities
are topological entities, i.e., they only deal with adjacencies in the model, and we use a
28
CHAPTER 2. SOLID MODELS
bi-directional data structure [?] for representing the graph of adjacencies. In this representation, a model entity Gdi of dimension d holds one lists of upward adjacencies Gd+1
(Gdi ),
j
i.e., all its adjacent entities of dimension d + 1, and one list of downward adjacencies of
dimension d − 1, Gd−1
(Gdi ). Schematically, we have
j
G0i G1i G2i G3i .
This representation is said to be complete because any model entity is able to build its
list of adjacencies of any dimension using local operations, i.e., without having to do a
complete traversal of the adjacency graph of the model.
Each model entity Gdi has a shape, a geometry. More precisely, it is a manifold of
dimension d that is embedded in 3-D space. (Note that the overall geometric model may
itself be non-manifold: Gmsh supports non-manifold features).
The geometry of a model entity depends on the solid modeler kernel for its underlying
representation. Solid modelers provide a parametrization of the shapes, i.e., a mapping
x ∈ Rd 7→ p ∈ R3 :
1. The geometry of a model vertex G0i is simply its 3-D location xi = (xi , yi , zi ).
2. The geometry of a model edge G1i is its underlying curve Ci with its parametrization
p(t) ∈ Ci , t ∈ [t1 , t2 ].
3. The geometry of a model face G2i is its underlying surface Si with its parametrization
p(u, v) ∈ Si . Note that, for any curve Cj that is on a surface Si , mesh generation
procedures require the ability to reparametrize any point p(t) ∈ Cj on the surface
Si , i.e., to compute the mapping u = u(t) and v = v(t). Gmsh either uses a brute
force algorithm to compute the direct mapping x = x(t), y = y(t) and z = z(t) and
its inverse u = u(x, y, z) and v = v(x, y, z) (see Figure 2.9), or, when the underlying
CAD system provides it, the direct reparametrization of a point on a model face
(i.e., a function that directly computes u = u(t) and v = v(t)).
4. The geometry associated to a model region is R3 .
Solid modelers usually provide an API for the creation, manipulation, interrogation
and storage of 3-D models. To perform mesh generation only a small subset of this API has
to be interfaced—only some of the interrogation functions are necessary. In order to get
the full functionality of Gmsh, only five CAD-system dependent interrogation functions
have to be implemented for the model edge (see Figure 2.10). For example, it is mandatory
to be able to evaluate the mapping p(t) ∈ C on the curve as well as the tangent vector
t(t) = ∂t p(t). For the model face, only four functions have to be overloaded in order
to enable 2-D mesh generation (see Figure 2.11). Note that the default 2-D algorithm
does not require the computation of derivatives of the surface parametrization, so that the
function modelFace::tangent is not strictly required (a description of this 2-D algorithm
is presented in Section ??). The other 2-D algorithms available in Gmsh, as well as most
2.4. TOPOLOGICAL REPRESENTATION
29
y
S0
S
x
z
C
p(u)
v
C
u = u(x)
v = v(x)
p(x)
u
x = x(t), y = y(t), z = z(t)
u = u(t), v = v(t)
C
t1
p(t)
t2
t
Figure 2.9: Point p located on the curve C that is itself embedded in a 2D surface S 0 (left)
or a 3D surface S (right).
class modelEdge : public modelEntity{
// bi-directional data structure
modelVertex *v1, *v2;
std::list<modelFace*> faces;
public:
// pure virtual functions that have to be overloaded
// for every solid modeler
virtual std::pair<double> parRange() = 0;
virtual Point3 value(double t) = 0;
virtual Vector3 tangent(double t) = 0;
virtual Point2 reparam(modelFace *mf, double t, int dir) = 0;
virtual bool isSeam(modelFace *mf) = 0;
// other functions of the class are non pure virtual
// ...
};
Figure 2.10: A part of the model edge class description. modelEdge::parRange returns the
range for the parameter in the curve. modelEdge::value returns the 3-D point p(t) that is
located on the curve C for a given parameter t. modelEdge::tangent evaluates the tangent
vector ∂t p(t) for a given parameter t. modelEdge::reparam computes the local parameters
of the point p(t) on a model face mf that has C in its closure, modelEdge::isSeam tells if
the curve is or is not a seam of the face mf. Generally, seam edges are used to maintain
consistency of data structure for periodic surfaces.
30
CHAPTER 2. SOLID MODELS
class modelFace : public modelEntity{
// bi-directional data structure
modelRegion *r1, *r2;
std::list<modelEdge*> edges;
public:
// pure virtual functions that have to be overloaded
// for every solid modeler
virtual std::pair<double> parRange(int dir) const = 0;
virtual Point3 value(double u, double v) const = 0;
virtual std::pair<Vector3> tangent( double u, double v) const = 0;
virtual double curvature(double u, double v) const;
// other functions of the class are non pure virtual
// ...
};
Figure 2.11: A part of the model face class description. modelFace::parRange returns
the range for the parameter in the surface in direction dir. modelFace::value returns
the 3-D point p(u, v) that is located on the surface S for the given parameter couple
(u, v). modelFace::tangent the evaluates two tangent vectors ∂u p(u, v) and ∂v p(u, v).
The modelFace::curvature function computes the divergence of the unit normal vector
at (u, v). This last function is used for the definition of mesh size fields. It is not a pure
virtual function: a default implementation is available using finite differences.
2.5. GEOMETRICAL REPRESENTATION
31
of the available 2-D meshers (e.g. bamg [?] or blsurf [?]), make use of derivatives of the
parametrization.
To date, Gmsh is interfaced with Open CASCADE and ACIS. It also contains a
naive solid modeler kernel that do not provide boolean operations.
2.5
Geometrical Representation
Each model entity Gdi has a shape, a geometry. More precisely, it is a manifold of dimension
d that is embedded in 3-D space.
Solid modelers usually provide a parametrization of the shapes, i.e., a mapping
x ∈ Rd 7→ x ∈ R3 . The geometry of a model vertex G0i is simply its 3-D location
x = (x1 , x2 , x3 ).
The geometry of a model edge G1i is its underlying curve Ci with its parametrization
t ∈ [t1 , t2 ] 7→ x(t) ∈ R3 .
(2.3)
The geometry of a model face G2i is its underlying surface Si with its parametrization
(u, v) ∈ R2 7→ x(u, v) ∈ R3 .
The geometry associated to a model region is R3 .
If a curve is included within a surface, it is usually drawn on the parameter plane
(u, v) of the surface:
t ∈ [t1 , t2 ] 7→ (u, v) ∈ R2 7→ x (u(t), v(t)) ∈ R3 .
(2.4)
2.5.1
Differential Geometry of Curves
A parameterization of a curve is a bijective mapping from a 1D domain to the 3D curve.
The mapping can be defined as follows:
t ∈ R1 7→ x(t) ∈ R3 .
(2.5)
Consider a segment of curve C defined by a range of parameter t ∈ [ta , tb ], ta ≥ t1 , tb ≤ t2 .
The length of that segment can be computed as
Z
dl
C
p
with dl = dx21 + dx22 + dx23 . Using C’s parametrization (2.3), we have
Z q
Z tb q
dx21 + dx22 + dx23 =
x21,t + x22,t + x23,t dt
C
ta
tb
Z
kx,t k dt
=
ta
32
CHAPTER 2. SOLID MODELS
This can be easily extended to the computation of integral quantities over model edges:
tb
Z
Z
(2.6)
f (x1 (t), x2 (t), x3 (t)) kx,t k dt
f (x1 , x2 , x3 )dl =
C
ta
The curvilinear abscissa l(t) of a point x(t) of curve C, is the length of the segment
defined by parameter range [t1 , t], i.e. the length of the curve from the origin x(t1 ) to x(t):
Z
(2.7)
t
kx,t k dt
l(t) =
t1
We have seen before that dl = kx,t k dt.
A parametrization of C is said to be regular if kx,t k =
6 0. For regular parametrizations, the unit tangent vector is defined as
t(t) =
x,t
dx
=
.
kx,t k
dl
The normal plane at point x(t) is the plane that contains x(t) and that has t(t) as normal
vector (see Figure 2.12). The curvature of the curve at a point x can be defined as the
amplitude of the variations of the unit tangent t along the curve. The vector t,l is obviously
orthogonal to t because t’s amplitude is one along l. Recalling that
x,t · x
d 1
=−
dt kxk
kxk3
we have
t,l =
=
=
1
t,t
kx,t k
x,tt
x,t · x,tt
1
− x,t
kx,t k kx,t k
kx,t k3
x,t · x,tt
1
.
x,tt kx,t k − x,t
kx,t k
kx,t k3
Clearly, t,l · t = 0. Because we have defined the curvature as the amplitude of the
variations of the unit tangent t along the curve, we call rewrite
t,l = kt,l k
t,l
= Cn
kt,l k
with n a unit normal vector orthogonal to t and C the curvature that is the norm of tl .
Remembering that
(a · b)2
ka × bk2 = kak2 kbk2 sin2 (a, b) = kak2 kbk2 1 −
= kak2 kbk2 − (a · b)2 ,
kak2 kbk2
2.5. GEOMETRICAL REPRESENTATION
t
t1
t2
33
x3
C
n(t)
x2
1/C
t(t)
x1
x(t)
Figure 2.12: A curve C defined by the mapping x(t).
it is easy to see that
C2 =
1
1
2
2
2
=
kxt × x,tt k2
6 kx,t k kx,tt k − (x,tt · x,t )
kx,t k
kx,t k6
and we get the formula
(2.8)
C=
kxt × x,tt k
kx,t k3
.
Consider the function y = f (x) in the (x, y) plane. Its parametric representation is x(t) = t
and y(t) = f (t) or x(t) = {}. The tangent vector is x,t = {1, f 0 (t)} and x,tt = {0, f 00 (t)}.
We have therefore the classical formula
(2.9)
C=
|f 00 (t)|
.
(1 + f 0 (t)2 )3/2
It is possible to define a local system of coordinates at any point x of the curve
(t, n, b)
with b = t × n. This system of coordinates is usually called the Frenet frame. The
osculating plane of the curve at point x can be defined as the plane containing x and
normal to b. The curvature C(t) is the inverse of the radius of the osculating circle at
point x i.e. the circle which most closely approximates the curve near x:
R(t) =
1
.
C(t)
This gives an interesting intuitive interpretation of the curvature.
34
CHAPTER 2. SOLID MODELS
v
S0
x3
x,u × x,v
x,v
u
x2
θ
x1
x,u
S
x(u, v)
Figure 2.13: A surface S defined by the mapping x(u, v).
2.5.2
Differential Geometry of Surfaces
A parameterization of a surface is a bijective mapping from a suitable two-dimensional
domain S 0 to the 3D surface S (see Figure 2.13). In CAD modelers, surfaces have explicit parametrizations i.e. their parametrization is given explicitly as a continuous and
differentiable function:
(u, v) ∈ S 0 ⊂ R2 7→ x(u, v) ∈ S ⊂ R3 .
(2.10)
Such a parametrization exists if the two surfaces S and S 0 have the same topology, i.e are
both zero genus surfaces (G = 0) and have at least one boundary (NB ≥ 1)1 .
Given the parametrization x(u), let us compute fundamental properties of surfaces
such as lengths, angles, areas and curvatures. Consider a curve that is included in surface
S. It is easy to extend the integration formula (2.6) as:
Z
f (x, y, z)
p
dx2 + dy 2 + dz 2
Z
q
f (x, y, z) kx,u k2 du2 + 2 x,u · x,v du dv + kx,v k2 dv 2
C
=
C
Z
=
s
f (x, y, z)
C
Z
(2.11)
=
f (x, y, z)
du
dv
T x,u · x,u x,u · x,v
x,v · x,u x,v · x,v
du
dv
p
duT M du.
C
1
For example, a sphere has G = 0 and NB = 0 and a torus has G = 1 and NB = 0.
2.5. GEOMETRICAL REPRESENTATION
35
In (2.12), the matrix M is called the metric tensor or first fundamental form. It is
defined as follows:
x,u · x,u x,u · x,v
E F
T
(2.12)
M = x,u x,u =
=
x,v · x,u x,v · x,v
F G
The metric tensor is a symmetric definite positive second order tensor that varies smoothly
over the manifold and that has two real eigenvalues.
We have just seen that the tensor metric enables to measure curve lengths drawn
in the parametric plane. It also allows to generalizes many familiar properties of the
dot product of vectors in Euclidean space. In particular, it allows to compute the angle
between two tangent vectors to the surface as well as areas. Any tangent vector at a point
of the parametric surface can be written in the form
t = ax,u + bx,v
with a, b ∈ R. Let us consider two tangent vectors
t1 = a1 x,u + b1 x,v and t2 = a2 x,u + b2 x,v .
Coordinates a = (a1 , a2 ) and b = (b1 , b2 ) are called covariant coordinates of t1 and t2 .
We have
t1 · t2 = a1 a2 x,u · x,u + (a1 b2 + a2 b1 )x,u · x,v + b1 b2 x,v · x,v = aT Mb,
which gives us the angle θ between the two tangent vectors (see Fig.2.13):
T
a Mb
(2.13)
θ = arccos
t1 t2
Consider a small rectangle du dv at a point on the parametric plane. Its area on the 3D
surface is given by:
√
(2.14)
s = kx,u du × x,v dvk = du dv det M.
Note again that the value of the area only depends on the tensor metric M.
The last important fundamental quantity related to the shape of surfaces is the
curvature. Let us first define the unit surface normal n that is orthogonal to both tangent
vectors:
(2.15)
n=
x,u × x,v
x,u × x,v
x,u × x,v
= √
=√
.
kx,u × x,v k
EG − F 2
det M
The three vectors (x,u , x,v , n) form at each point of the surface a local system of coordinates
usually called the local frame. It is easy to orthonormalize the local frame, i.e. by choosing
t1 =
x,u
, t2 = n × t1
kx,u k
36
CHAPTER 2. SOLID MODELS
so that vectors (t1 , t2 , n) form an orthonormal system of coordinates usually called the
Darboux frame. To study the curvature of the surface at a point x, one can examine the
variations of the unit normal n around x. In particular, one can derivate n in the direction
specified by the tangent vectors at x: this is called the Weingarten map. Note that n,u
and n,v are both tangent vectors because n is a unit vector:
v,u
∂ v
v
(v · v,u )
=
−
∂u kvk
kvk kvk3
Applying that formula to Equation (2.15) (an after tedious calculations), we obtain the
Weingarten equations that express the derivatives of the normal to a surface using derivatives of the position vector x
n,u =
M F − LG
LF − M E
x,u +
x,v
EG − F 2
EG − F 2
n,v =
NF − MG
MF − NE
x,u +
x,v
2
EG − F
EG − F 2
where the scalars e, f and g are defined as:
L = n · x,uu , M = n · x,uv and N = n · x,vv .
Those scalars define the curvature tensor or second fundamental tensor of the surface
denoted M2 :
(2.16)
M2 =
L
M
M
N
The curvature tensor is a tensor, and like for any tensor, some invariants can be defined
that are independent of the system of coordinates. In other words, invariants are intrinsic
measures of the curvature, i.e., their value depends only on how distances are measured on
the surface, not on the way it is embedded in space. The principal curvatures κ1 and κ2
are the two eigenvalues of M2 . They are the largest and smallest values of the curvature
at a point. The mean curvature κ̄ = κ1 + κ2 is proportional to the trace of the curvature
tensor and κ̄ is therefore an invariant of the tensor. It is easy to see that
(2.17)
1
κ̄ = ∇ · n = trace
2
M2
M
=
LG − 2M F + N E
.
2 (EG − F 2 )
The Gaussian curvature κ of a point on a surface is the square root of the product of the
principal curvatures, κ1 and κ2 , of the given point. Its value can be computed as
(2.18)
κ=
det M2
LN − M 2
=
.
det M
EG − F 2
2.5. GEOMETRICAL REPRESENTATION
2.5.3
37
Classifying the parametrizations
By studying how the surface lengths, angles and areas vary during the mapping (and
hence how the metric tensor and associated eigenvalues vary) (2.10) we can classify the
parametrizations (mappings) by looking at the eigenvalues λ1 and λ2 of the metric tensor
M (2.12):
• A mapping is called isometric or length-preserving if the length of any arc is preserved. Such a mapping is called an isometry and exist only in very special cases.
For example, the mapping of a cylinder into the plane that transforms cylindrical
coordinates into cartesian coordinates
is isometric. The following relation holdq:
1 0
x(u) is isometric ⇐⇒ M =
⇐⇒ λ1 = λ2 = 1.
0 1
• A mapping is conformal or angle-preserving if the angle of intersection of every
pair of intersecting curves is the same on the parametric plane and on the surface.
For example, the stereographic and Mercator projections are conformal maps from
the sphere to the plane. Thefollowing
relation holds:
η 0
⇐⇒ λ1 /λ2 = 1
x(u) is conformal ⇐⇒ M =
0 η
• A mapping is equiareal if the areas are conserved by the mapping. For example,
the Lambert projection is an equiareal mapping from the sphere to the plane. We
have the relation:
x(u) is equiareal ⇐⇒ det M = 1
⇐⇒ λ1 λ2 = 1.
Isometric mappings are optimal because they introduce no distorsion. Every isometric mapping is conformal and equiareal, and every conformal and equiareal mapping
is isometric, so that the following equivalence holds:
isometric ⇐⇒ conformal + equiareal.
We can thus view an isometric mapping as ideal, in the sense that it preserves just
about everything we could ask for: angles, areas, and lengths. However, as is well known,
isometric mappings only exist in very special cases of developable surfaces , i.e. surfaces
with zero Gaussian curvature (planes, cylinders and cones). Many approaches to surface
parameterization therefore attempt to find a mapping which either
• is conformal, i.e., has no distortion in angles, or
• is equiareal, i.e., has no distortion in areas, or
• minimizes some combination of angle distortion and area distortion.
38
2.5.4
CHAPTER 2. SOLID MODELS
Computing harmonic and conformal maps
One possible mapping can be found by minimizing the area functional A(x) that is the
area of the mapping x(u). This area functional can be computed by combining equations
of the area (2.14) and the metric tensor (2.12):
Z p
Z
k x,u × x,v k dudv =
(2.19)
A(x) =
EG − F 2 dudv,
S0
S0
where E, D and G are the coefficients of the metric tensor M.
As can be seen, this area functional is in general complicated to compute. A lof
of approaches in numerical approximation of minimal surface do not minimize the area
functional directly. Instead, they try to minimize the following functional called Dirichlet
enery ED (x):
Z
Z
Z
1
1
1
2
2
2
(2.20)
ED (x) =
k∇xk dudv =
x,u + x,v dudv =
(E + G) dudv
2 S0
2 S0
2 S0
The map that minimizes the Dirichlet energy is called a harmonic map since the variational derivative of the Dirichlet functional (Euler equation) corresponds to the Laplacian:
(2.21)
∇2 x = x,uu + x,vv .
One should note that since the mapping is a bijective function, the following Laplacian
equation also minimizes the Dirichet energy:
Z
1
2
(2.22)
∇ u = 0 ↔ min ED (u) = min
k∇uk2 ds.
u
u 2 S
The area functional A(x) and the Dirichlet energy ED (x) have the following relation:
Z √
Z
Z p
1
2
(2.23)
A(x) =
EG − F dudv ≤
EGdudv ≤
(E + G)dudv = ED (x)
2 S0
S0
S0
It is simple to verify that the first inequality becomes an equality if F = 0, i.e. if x,u · x,v
is zero everywhere, while the second does if E = G, i.e if kx,u k = kx,v k. It follows that
the the minimum possible value of the Dirichlet energy is attained when there is no shape
distorsion anywhere, the resulting mapping is then called conformal
mapping since
E 0
the corresponding mesh metric is then given by : M =
. If we only fix the
0 E
shape of the boundary of a parametric domain, but not the map from the boundary to
the surface, a conformal parameterization always exists for smooth surfaces and smooth
domain boundaries. As the conformal mapping also minimizes the Dirichlet energy, we
have the following implication for the mappings:
conformal =⇒ harmonic.
2.5. GEOMETRICAL REPRESENTATION
39
How far from conformality is the mapping u(x) that is the solution of the two
Laplace equations (2.22) that minimize the Dirichlet energy ED (u)?
∇2 u = 0
and ∇2 v = 0.
It actually all depends on the boundary conditions of those equations. If we fix with
appropriate Dirichlet boundary conditions the map u(x) on the boundary ∂S of the domain
S to a fixed boundary in the parametric space (a circle, a squatre, etc.), full conformality
may be impossible, but minimizing the Dirichlet energy will move us closer to a conformal
map, i.e. will reduce the distortion of shape. If on the other hand, we only fix the shape
of the boundary of a parametric domain (any planar curve), but not the map from the
boundary to the surface, a conformal parameterization always exists for smooth surfaces
and smooth domain boundaries. However, fixing the shape will introduce a coupling
between the u and the v mapping coordinates that is not straighforward to implement.
It is therefore convenient to minimize another energy, the least square conformal
energy ELSCM as defined by Levy et al. [?]:
Z
1
(2.24)
ELSCM =
k∇u⊥ − ∇vk2 ds,
S 2
where ⊥ denotes a counterclockwise 90◦ rotation on S (on the plane defined by the two
vectors ∇u = u,x and ∇v = v,x ) (see fig.2.14). Minimizing this energy is then equivalent
to asking that the gradient of u and the gradient of v be as orthogonal as possible in the
parametrization, which is the necessary condition for a conformal (angle preserving) map.
Equation (2.24) can be simplified and rewritten as follows:
S0
S
n
∇v
iso-v
u(x)
∇u
iso-u
iso-v
iso-u
z
y
x
∇u⊥ = n × ∇u
Figure 2.14: Definitions for a conformal mapping. ∇u⊥ denotes the counterclockwise 90◦
rotation of the gradient ∇u for a 3D surface.
Z
1 ⊥
∇u · ∇u⊥ + ∇v · ∇v − 2∇u⊥ · ∇v ds,
2
ZS 1
=
(∇u)2 + (∇v)2 − 2 (n × ∇u) · ∇v ds.
S 2
ELSCM (u) =
(2.25)
40
CHAPTER 2. SOLID MODELS
Recalling the idenity that a a ”dot” and a ”cross” can be interchanged without changing
the result, we can finally write the least square conformal energy as follows:
Z
(2.26)
1
(∇u)2 + (∇v)2 − n · (∇u × ∇v) ds.
S 2
= ED (u) − A(u).
ELSCM (u) =
It follows from (2.26) that the conformal energy is then simply defined as the dirichlet
functional ED (u) minus the area functional A(u).
Figure 2.15 shows two examples of mappings u(x) of a 3D surface S. The top figures
shows the harmonic map that is computed by minimizing the Dirichlet energy ED (u) and
the bottom figures show a conformal map that is obtained by minimizing the least square
conformal energy ELSCM (u). The iso-u and iso-v values that are visible on the 3D surface
show that the conformality is also almost achieved for the harmonic map except near the
fixed boundaries.
S
S
uharm (x)
iso-v
iso-u
S0
S
uconf (x)
iso-v
iso-u
Figure 2.15: Example of harmonic (top) and conformal map (bottom) for the mapping
of a surface S that have been computed respectively by minimizing the Dirichlet energy
ED (u) and the least square conformal energy ELSCM (u). The iso-u and iso-v values are
visible on the 3D surfaces and it can be shown that the conformality is almost achieved
for the harmonic map except near the fixed boundaries.
2.5. GEOMETRICAL REPRESENTATION
2.5.5
41
Examples of analytical parametrizations
We have just shown how to compute parametrizations u(x) by minimizing some functionals. However, for some simple surfaces S such as cylinders and spheres, an analytical
parametrization can be derived.
Cylindrical coordinates
A first simple example of such an analytical parameterization are cylindrical coordinates.
Imagine an open cylinder (without bottom and top) being cut open along its side and
unrolled in the plane. This gives a rectangle and there exists a natural bijective mapping
between the points in this rectangle and the points on the surface of the cylinder. This
mapping is a parameterization of the cylinder surface and very handy, because it allows us
to capture the cylinder by using only two coordinates u = φ and v = h in the parameter
domain instead of the three coordinates x, y, and z in space (see Fig.2.16). The mapping
is given by:
(2.27)
x(φ, h) = (sin φ, cos φ, h)
S
S0
h
φ
x(φ, h)
(φ, h)
(x, y, z)
φ
h
Figure 2.16: Mapping with cylindrical coordinates.
The metric tensor relative to that parametrization is then
1 0
(2.28)
M=
.
0 1
This parametrization is isometric and hence equiareal and conformal.
Spherical coordinates
Another simple example is the parametrization of a sphere of radius R using spherical
coordinates u = φ and v = η (see Fig.2.17). The mapping is given by:
  

x
R cos θ sin φ
x(φ, η) =  y  =  R sin θ sin φ  .
z
R cos φ
42
CHAPTER 2. SOLID MODELS
x3
er
eθ
φ
x3
x1
eφ
x2
θ
x2
x1
Figure 2.17: Spherical coordinates.
We have

x,φ



R cos θ cos φ
−R sin θ sin φ
=  R sin θ cos φ  , x,θ =  R cos θ sin φ 
−R sin φ
0
and the metric tensor relative to that parametrization is
(2.29)
M = R2
1
0
0 sin2 φ
.
This parametrization is neither isometric, neither equiareal, neither conformal.
Stereographic projection
A third well-known example is the stereographic projection (see an example in Fig.2.18).
The mapping from the surface of the sphere S to the parameter domain can be constructed
as follows. For any point x = (x, y, z) on the sphere, consider the ray that connects another
point s on the sphere. The corresponding parameter point u is the intersection π(x) of
that ray with a plane S 0 perpendicular to the z axis. The parametrization is then defined
for every point on the sphere, except at the point s.
In Fig. 2.18, we have chosen for the stereographic projection that s is the South Pole
and that the z-plane is the z = R plane. The parametrization and inverse parametrizations
u(x) and x(u)) can then be computed as the intersection of vector s − p with the plane
2.5. GEOMETRICAL REPRESENTATION
v
x
43
y
S0
π(x)
u
x = (x, y, z)
u(x) = π(x)
S
s
Figure 2.18: Stereographic projection.
z = R:
u(x) =
x(u) =
2R
2R
x,
y ,
R+z R+z
4R2
u, v, R(4R2 − u2 + v 2 ) .
2
2
2
u + v + 4R
The metric tensor M for the stereographic projection is then given by:
(2.30)
M=
λ 0
0 λ
.
with
λ(u, v) =
4R2
2
u + v 2 + 4R2
.
Those two eigenvalues are equal: the stereographic mapping is therefore conformal. This
means that any infinitesimally small angle measured in the map is exactly the same as
if measured on the corresponding point on the surface of the sphere. The mapping is
neither isometric nor area-preserving: that is, it preserves neither distances nor the areas
of figures.
To illustrate this projection, 2.19 shows the World Ocean in stereographic coordinates u(x) = π(x). The outside loop surrounding the domain is the stereographic
projection of the Antarctica. The radius of the Earth is chosen arbitrarily to R = 1. No
seam is required to define the overall domain and no singular point exists in the domain
of interest.
44
CHAPTER 2. SOLID MODELS
Figure 2.19: The World Ocean in stereographic coordinates.
2.6
Non-Uniform Rational b-Splines (NURBS)
Non-uniform rational B-splines (NURBS) are a family of parametric curves and surfaces.
NURBS representations offer great flexibility and precision for handling both analytic and
free-form shapes.
NURBS curves and surfaces are useful for at least two reasons:
• They are invariant under affine as well as perspective transformations: operations
like rotations and translations can be applied to NURBS curves and surfaces by
applying them to their control points.
• They offer one common mathematical form for both standard analytical shapes (e.g.,
conics) and free-form shapes.
2.6.1
NURBS curves
A NURBS curve C is a parametric curve with a parametrization
t ∈ [ta , tb ] 7→ x(t) ∈ R3 .
2.6. NON-UNIFORM RATIONAL B-SPLINES (NURBS)
45
Control points
The geometry of a NURBS curve C is defined through a set of nc = n + 1 control points
or poles pi , i = 0, . . . , n. A point x on the curve is computed by taking a weighted sum
of some of the control points pi :
(2.31)
x(t) =
n
X
Nid (t) pi
i=0
where the Nid (t) are some shape functions of degree d.
Knots
In (2.31), the value of x(t) for a parameter t is only influenced by a finite number of control
points. Typically, for a NURBS of degree d, the maximum number of control points that
influences the NURBS for any parameter t is d + 1.
The knot vector T = {t0 , . . . , tk } is a sequence of parameter values t that determines
where and how the control points affect the NURBS curve. For a non-periodic NURBS,
the number of knots is equal to
k + 1 = nc + (d + 1)
⇒
k = n + (d + 1).
We have of course that t0 = ta and tk = tb .
The knot vector divides the parametric space in intervals. For a curve of degree
d, every shape function Nid of any control point is only nonzero in d + 1 intervals of the
parameter space. Shape function overlap in parameter intervals. The number of overlaps
correspond to the number of control points that influence the NURBS shape in this interval
(so the name control points).
Shape functions are polynomials of degree d that go smoothly to zero at boundaries
of the interval, the smoothness being determined by the degree of the polynomial.
Knots can have the same value. This has impact on continuity of the resulting
curve or its higher derivatives. For instance, it allows to lower the continuity of the curve,
leading possibly to the creation of corners in an otherwise smooth NURBS curve.
A number of coinciding knots is sometimes referred to as a knot with a certain
multiplicity. The multiplicity of a knot is limited to the degree of the curve; since a higher
multiplicity would split the curve into disjoint parts and it would leave control points
unused.
The knot vector usually starts with a knot that has multiplicity equal to the order.
This makes sense, since this activates the control points that have influence on the first
knot span. Similarly, the knot vector usually ends with a knot of that multiplicity. Curves
with such knot vectors start and end in a control point.
46
CHAPTER 2. SOLID MODELS
The individual knot values are not meaningful by themselves; only the ratios of the
difference between the knot values matter. Hence, the knot vectors T = {0, 0, 1, 2, 3, 3} and
T = {0, 0, 2, 4, 6, 6} produce the same curve. The positions of the knot values influences
the mapping of parameter space to curve space.
Consider a cubic NURBS with nc = 7 control points.
• A knot vector T = {0, 0, 0, 0, 1, 2, 3, 4, 4, 4, 4} is the standard B-spline knot vector.
This knot vector is of size 7+3+1 = 11 and defines 10 knot spans: (0,0), (0,0), (0,0),
(0,1), (1,2), (2,3), (3,4),(4,4),(4,4) and (4,4). Shape function N13 defines the influence
of control point p1 on the curve. The number of parameter intervals required for
defining a proper 3rd order curve is d + 1 = 4 which means that N13 is non zero
between t = t1 = 0 and t = t5 = 1. Shape function N23 is non zero between
t = t2 = 0 and t = t6 = 2, N33 is non zero between t = t3 = 0 and t = t7 = 3 and N43
is non zero between t = t4 = 0 and t = t8 = 4 which is the whole interval.
• A knot vector T = {0, 0, 0, 0, 1, 1, 1, 4, 4, 4, 4} defines piecewise Bézier curves. This
knot vector of size m = 11 = 7 + 3 + 1 defines 10 knot spans: (0,0), (0,0), (0,0), (0,1),
(1,1), (1,1), (1,2),(2,2),(2,2) and (2,2). N13 , N23 , N33 , are non zero between t = 0 and
t = 1 and N53 , N63 , N73 , are non zero between t = 1 and t = 4. Only N43 is non zero
on the whole interval.
B-spline Basis Functions
There are many ways to define B-spline basis functions and to demonstrate their interesting
properties. Here, we use the recursive definition since it is the most useful in practical
implementations.
The B-spline functions at order d are defined recursively using functions at degree
d − 1:
(2.32)
Nid (t) =
(t − ti )
(ti+1+d − t)
Nid−1 (t) +
N d−1 (t)
(ti+d − ti )
(ti+1+d − ti+1 ) i+1
with the degree-0 functions (first order) Ni,1 being piecewise constant functions:
(2.33)
Ni0 (t) =
1 if t ∈ [ti , ti+1 [
0 otherwise.
Those B-spline functions are positive because they are constructed recursively as positive
weighted sums of functions of lower order. They have a compact support since they are
are non-zero only in the following interval:
Nid (t) > 0, t ∈ [ti , ti+1+d [
2.6. NON-UNIFORM RATIONAL B-SPLINES (NURBS)
47
Except for the d first and d last knot points, it can be proven by induction that the
B-spline functions satisfy the partition of unity, i.e:
n
X
(2.34)
Nid (t) = 1, t ∈ [td , tn−d [.
i=0
Non Uniform Rational B-splines (NURBS)
B-splines are non uniform when the knot vector is not uniformly distributed. This defines
what could be called NUBS or non uniform B-splines.
Let us introduce a vector of positive weights W = w0 , . . . , wn that has the size of
the control points vector. The general form of a Non Uniform Rational B-spline (NURBS)
curve is
Pn
d
i=0 wi Ni (t) pi
.
(2.35)
x(t) = P
n
d
i=0 wi Ni (t)
We observe that the weights introduce new rational basis function Rid defined as:
Rid (t)
Pn
wi Nid (t)
,
= Pi=0
n
d
i=0 wi Ni (t)
and we also note that when all the weights have value wi = 1, we have a B-spline curve
since Rid (t) = Nid (t).
The main advantage of NURBS in CAD modelling is that NURBS can both represent
free shapes and conics. A full circle can be represented using points placed on vertices and
mid-edges of an equilateral triangle. Let us call s = sin(30) and c = cos(30). Consider 7
control points
P = {{2 − c, s}, {2c, 2s}, {c, s}, {0, 0}, {1, 0}, {2, 0}, {2 − c, s}},
with weights and knots
W = {1, 0.5, 1, 0.5, 1, 0.5, 1},
T = {0, 0, 0, 1/3, 1/3, 2/3, 2/3, 1, 1, 1}.
This NURBS is of degree p = 2 (order 3). It defines a complete circle that is tangent to
p0 , p2 and p4 .
2.6.2
NURBS surfaces
Recall that the geometry of a model face G2 is its underlying surface S with its parametrization x(u):
(u, v) ∈ R2 7→ x(u, v) ∈ R3 .
48
CHAPTER 2. SOLID MODELS
A B-spline surface S of order d in the u−direction and of order e in the v−direction is a
bivariate piecewise function of the form:
x(u, v) =
n X
m
X
pij Nid (u)Nje (v).
i=0 j=0
Two knot vectors
TU = {u0 , . . . , uku } and TV = {v0 , . . . , vkv }
are defined, with ku = n + (d + 1) and kv = m + (e + 1).
NURBS surfaces can also use weights wij so that the most general form of the
NURBS surface is written as
Pn Pm
d
e
i=0
j=0 wij pij Ni (u)Nj (v)
.
(2.36)
x(u, v) = Pn Pm
d
e
i=0
j=0 wij Ni (u)Nj (v)
2.7
Surface Intersections
Solid modelers allow to perform boolean operations on Boundary representations. The
algorithm for the evaluation of boolean operators on boundary representations can be
stated as:
1. Determine the intersection of all edges of one object with the edges of the other
objects and split the edges at the point of intersection
2. Determine all intersections of the edges of one solid with faces of the other solid and
split the edge, and place a vertex in the face intersected.
3. Determine all coincident vertices of the two solids. (These include the vertices created in steps 1 and 2)
4. Create intersection polygons around the coincident vertices.
5. Choose the appropriate sides of intersection polygons from each object and ”glue”
them together.
Curve-curve intersections or vertex gluing require subtle care about model tolerance.
Curve-surface intersection may
2.7.1
Intersection two implicit surfaces
Consider two implicit surfaces f (x, y, z) = 0 and g(x, y, z) = 0 and a point p on their
intersection. We wish to trace the intersection curve, beginning at p. We define a trace
direction
t = ∇f × ∇g
2.7. SURFACE INTERSECTIONS
49
that defines the tangent of the intersecting curve at point p. We have to assume here
that tangent vectors ∇f and ∇g are linearly independant, otherwise the two surfaces are
tangent to each others at point p. If the gradients vanish at p or if they are colinear, then
the intersection curve has a singularity at p.
Assume that the intersection is regular at p. Let us build a local parametrization
of the intersection at the neighborhood of p:
x(t) = p + tx(1) (0) +
(2.37)
t2 (2)
t3
x (0) + x(3) (0) + . . .
2
6
where x(m) is the m-the derivative of x with respect to t. It is then possible to build
an algorithm that traces the interface steb by step. The next point on the curve is
first approximated as x(t). Then, a Newton iteration is used to bring the point to the
intersection of f and g.
The idea here is to find derivatives x(m) using partial derivatives of f and g. Let
us call x(y) = {xp + dx, yp + dy, zp + dz} a point of the intersection that is close to
p = {xp , yp , zp } = x(0). We have
f (x, y, z) = f (xp , yp , zp ) + f,x dx + f,y dy + f,z dz + . . .
or, in a closed form
(2.38)
f (x, y, z) = f (xp , yp , zp ) +
∞
X
i,j,k=1
1
f i j k dxi dy j dz k
!i!j!k ,x y z
We look here for dx, dy and dz. Those are found using (2.37):
dx = {dx, dy, dz} = x(t) − p = tx(1) (0) +
t2 (2)
t3
x (0) + x(3) (0) + . . .
2
6
In a similar manner, if we look for a third order approximation, we have
dx2 = (x(t) − xp )2 = (x(1) )2 t2 + x(1) x(2) t3 + . . .
dx3 = (x(t) − xp )3 = (x(1) )3 t3 + . . .
dx dy = (x(t) − xp )(y(t) − yp ) = x(1) y (1) t2 + (x(2) y (1) + x(1) y (2) )
t3
+ ...
2
dx dy dz = (x(t) − xp )(y(t) − yp )(z(t) − zp ) = x(1) y (1) z (1) t3 + . . .
Since x(t) is on f , f (x + dx, y + dy, z + dz) = 0. We can introduce values of dx, dx2 , dx dy,
... into (2.38) and zero all expressions factor of tm , m = 0, 1, 2, 3. This is of course trivial
for m = 0, p being on the intersection. For m = 1, we have of course
∇f · x(1) = 0.
Higher order values for m give more complex expressions.
50
2.7.2
CHAPTER 2. SOLID MODELS
Intersection of a parametric surface with an implicit surface
In this section, we will give some hints on the way it is possible to compute the intersection
of surfaces and show how hard this problem may be. Let us consider two surfaces S1 and
S2 that have both a parametric representation and an implicit representation:
x(u1 , v1 ) = {x(u1 , v1 ), y(u1 , v1 ), z(u1 , v1 )}
(2.39)
S1 =
f1 (x, y, z) = 0.
and
(2.40)
S2 =
x(u2 , v2 ) = {x(u2 , v2 ), y(u2 , v2 ), z(u2 , v2 )}
.
f2 (x, y, z) = 0.
Let us consider the parametric plane (u, v) of S1 . The intersection of the two surfaces can
be represented as the implicit curve g(u1 , v1 ) that verifies the implicit representation of
S2 :
g(u1 , v1 ) = f2 (x(u1 , v1 ), y(u1 , v1 ), z(u1 , v1 )) = 0.
In principle, this seems simple. Yet, the topology of the intersecting curve may become
complex, even for simple surfaces. As an example, consider two cylinders
x(u1 , v1 ) = {R1 cos u1 , R1 sin u1 , v1 }, u1 ∈ [0, 2π[, v1 ∈ <
(2.41)
S1 =
f1 (x, y, z) = x2 + y 2 − R2 = 0.
(2.42)
S2 =
x(u2 , v2 ) = {u2 , R2 cos v2 , R2 sin v2 }, u2 ∈ <, v2 ∈ [0, 2π[
f2 (x, y, z) = y 2 + z 2 − r2 = 0.
We introduce the parametric representation of S1 in the implicit representation of S2 to
obtain
R12 sin2 u1 + v12 − R22 = 0
which is an implicit equation g(u1 , v1 ) = 0 that represents a curve in the parametric plane
of S1 . We obtain easily that
q
v1 = ± R22 − R12 sin2 u1 .
Imagine first that R2 > R1 . In this case, the intersection is composed of two separate
periodic curves that divide the parameter plane in 3 regions (see Figure 2.20) so that the
intersection is not simply connected. In the case R2 > R1 , the intersection is composed
of two closed curves in the parameter plane that dig two holes so that the intersecting
surface is simply connected, yet with two holes. The case R2 = R1 is the more complicated.
There, two singular points are present in the intersection, where the curve is “non locally
manifold” i.e. a branching exists. For removing such singularity, it is useful in practice to
introduce a new model vertex that separates the parts of the intersecting curve that are
adjacent to this model vertex (see Figure 2.21). Solving numerically surface intersections is
a hard problem because the topology of the intersecting curves may become complicated:
2.7. SURFACE INTERSECTIONS
51
Figure 2.20: Intersection of two cylinders S1 and S2 . Figures show the intersection in the
parameter plane of S1 for R2 > R1 (left), R2 = R1 (center) and R2 < R1 (right).
the intersecting curve may non be connected, singular points may appear and the solution
of g(u1 , v1 ) may be complex. Building a robust code for doing such intersections takes
time and experience so that few solid modelling kernels have survived the 1990’s.
Another way of proceeding is to use homogeneous coordinates. We transform the
equations as
f1 (x, y, z, w) = x2 + y 2 − w2 R2 = 0,
f2 (x, y, z, w) = y 2 + z 2 − w2 r2 = 0,
those having a singularity at the origin w = 0.
f1 (x, y, z, w) = x2 + y 2 − w2 R2 = 0,
2.7.3
From parametric to implicit representations
Let us see how this parametric surface can be transformed into an algebraic surface i.e.
an implicit surface f (x, y, z) = 0 whose equation is formed by polynomials. An algebraic
surface of degree d is of the form
X
f (x, y, z) =
aijk xi y j z k = 0.
i+j+k≤d
An algebraic surface at order d has (d + 1)(d + 2)(d + 3)/6 coefficients aijk .
For sake of simplicity, let us first consider the following bilinear surface:
x(u, v) = a0 + a1 u + a2 v + a3 uv
y(u, v) = b0 + b1 u + b2 v + b3 uv
z(u, v) = c0 + c1 u + c2 v + c3 uv
52
CHAPTER 2. SOLID MODELS
Figure 2.21: Intersection of two cylinders S1 and S2 with R2 6= R1 (left) and R2 = R1
(right).
that we can rewrite as:
(a0 − x) + a1 u + a2 v + a3 uv = 0
(b0 − y) + b1 u + b2 v + b3 uv = 0
(c0 − z) + c1 u + c2 v + c3 uv = 0.
Our aim is to express those equations as an implicit function f (x, y, z) = 0. Here, we use
Sylvester’s Diadic Expansion that consist in considering all the individual monomials of
a polynomial as independant variables. Here, we have 3 equations and 4 “independant
variables” 1, u, v and uv.
Those equations can be multiplied either by u or v to form a set of 6 equations with
6 “independant variables”. Assume that we multiply those equations by u, we obtain









1
(a0 − x)
a1
a2 a3 0 0
 u
(b0 − y)
b1
b2 b3 0 0 


(c0 − z)
c1
c2 c3 0 0 
 v

0
(a0 − x) 0 a1 a2 a3 
  uv

0
(b0 − y) 0 b1 b2 b3  u2
0
(c0 − z) 0 c1 c2 c3
u2 v




 = 0.



Note here that the trick was to find the right set of monomials so that the number of
equations is exactly equal to the number of independant variables.
This system has no trivial solution if its determinant f (x, y, z) is zero. This is the
implicit version of the surface, which is indeed a quadratic surface. More precisely, it is a
hyperbolic paraboloid.
2.8. GEODESICS
53
Consider now the case of a bivariate surface
Px (u, v) = f1 (a | um , v n ) − x = 0
Py (u, v) = f2 (b | um , v n ) − y = 0
Pz (u, v) = f3 (c | um , v n ) − z = 0.
We look for the conditions under which those 3 equations can be satisfied simultaneously.
The strategy is analogous to what has been done for bilinear surfaces: our goal is still to
arrive at a number of auxiliary equations, deduced from the parametric surface equations,
equal to the number of “independant variables”. Yet, that method can introduce linearly
independant equations which cause the resultant to vanish identically.
A complete development of the method is presented in [?]. The result are twofold:
• A bivariate surface of degree n in u and m in v is equivalent to an algebraic surface
of degree d = 2mn,
• A rationale bivariate surface of degree n in u and m in v is also equivalent to an
algebraic surface of degree d = 2mn.
This means that it is in general possible to represent any NURBS as an implicit surface.
Yet, the most common NURBS surfaces are cubic. Those can be represented as an implicit
surface of order 18! This would require the computation of (d + 1)(d + 2)(d + 3)/6 = 1330
terms.
2.7.4
Intersection of NURBS
The intersection of two cubic NURBS can then be seen as the intersection of an algebraic
surfaces S1 of degree 18 with a bicubic parametric surface S2 .
The intersection verifies
x(u1 , v1 ) = {P
Pz (u, v)}
Px (u, v), Py (u, v),
i
j
f (x, y, z) = i+j+k≤18 aijk x y z k = 0.
(2.43)
where Px , Py and Pz are bicubic polynomials in u and v. We can then compute the
intersection in the (u, v) plane as
X
aijk Px (u, v)i Py (u, v)j Pz (u, v)k = 0
i+j+k≤18
that is an algebraic planar curve of degree 3 × 18 = 54!
2.8
Geodesics
Consider a surface S and two points with coordinates u1 and u2 on the parameter plane
of S. There exists an infinity of paths (curves) on the surface that connect u1 and
54
CHAPTER 2. SOLID MODELS
u2 . In cartesian coordinates, the straight line is the shortest path between two points.
Geodesics are the generalization of straight lines to metric spaces. Consider a curve
u(t) = {u(t), v(t)}, with u(t1 ) = u1 and u(t2 ) = u2 , that is drawn on the parametric
plane of S. Its length l is a functional
Z p
Z t2 q
T
l(u, u,t ) =
du M du =
uT,t M(u) u,t dt.
C
t1
In order to minimize l, we use the calculus of variations and put to zero the first
variation of the functional for all admissible variations of u.
Consider the following functional T :
Z t2
F (t, y, y 0 )dt
l=
t1
with y 0 = y,t . Using integration by parts, i.e.
Z x2
Z
f g 0 dx = −
x1
x2
x1
f 0 gdx + f g|xx21
we have
t2
∂F
∂F 0
δl =
δy + 0 δy dx
∂y
∂y
t1
Z t2 d ∂F
∂F t2
∂F
=
−
δydt +
δy
∂y
dt ∂y 0
∂y 0 t1
t1
Z t2 d ∂F
∂F
−
δydt = 0
=
∂y
dx ∂y 0
t1
Z
because δy = 0 on both t = t1 and t = t2 . With arbitrary variations δy, one lemma of the
calculus of variations ensures that the quantity
∂F
d ∂F
−
=0
∂y
dt ∂y 0
has to be zero to ensure the extremality of the functional. This is the famous EulerLagrange equation. Here, for geodesics,
q
F = uT,t M(u) u,t
Consider for example an isometric mapping, i.e. M is the identity. We have
q
F = u2,t + v,t2 .
The Euler-Lagrange equations are written as
−
d
(2u,t ) = 0 ,
dt
−
d
(2v,t ) = 0
dt
2.8. GEODESICS
55
that have the simple solution that both u and v are linear in t which means that the
geodesic is the straight line.
Consider now the stereographic projection, i.e. a conformal mapping. We have
4R2
F =
.
u2 + v 2 + 4R2
A COMPLETER ...
56
CHAPTER 2. SOLID MODELS
Chapter 3
Mesh Generation
3.1
Generalities
The goal of a finite element analysis is to solve a set of partial differential equations over
a geometrical domain G. The most common way to describe G is to use a boundary-based
scheme where the geometric domain is represented as a set of topological types together
with adjacencies. This has already be described in the sections of Chapter 2.
The mesh M is a discrete version of the domain. In some sense, it is similar to what
we’ve defined for the geometric model: it consists of
• A collection of mesh entities Mid of controlled size and distribution;
• Topological relationships or adjacencies forming the graph of the mesh.
We have
1. Mesh Vertices Mi0 that are topological entities of dimension 0,
2. Mesh Edges Mi1 that are topological entities of dimension 1,
3. Mesh Faces Mi2 that are topological entities of dimension 2,
4. Mesh Regions Mi3 that are topological entities of dimension 3.
What differs is that mesh entities are more numerous than model entities but have
limited complexity.
Mesh entities are topologically equivalent to the unit d-dimensional sphere S d =
{x ∈ Rd ; kxk2 < 1}: they are made of one part, they are simply connected (a manifold is
said to be simply connected if every closed curve can be smoothly shrunk to a point) and
they have no holes.
57
58
CHAPTER 3. MESH GENERATION
Mesh entities have simple shapes: they are are lines in 1D, triangles and quadrangles
in 2D and tetrahedra, hexahedra and prisms in 3D.
Any mesh entity Mid is a piece of the discretization of a geometric entity Gqj , d ≤ q
(a mesh entity must have dimensionality less than or equal to the geometry it is associated
with). We call this association a classification of a mesh entity to a geometrical entity and
we note it as Mid @ Gqj [?, ?, ?].
Simulation attributes like boundary conditions or material properties are naturally
related to model entities and not to mesh entities. In mesh generation and mesh enrichment procedures, the classification information is critical for ensuring that the mesh is
constructed so that it improves the geometric approximation of the domain when it is is
refined. It is therefore necessary to maintain the classification of mesh entities through all
our algorithms.
A mesh M is composed of a collection of mesh entities together with their adjacencies.
Any mesh entity bounds and/or is bounded by other ones of higher and/or lower dimension.
This adjacency information represents the graph of a mesh.
It is interesting at this point to gather some statistics about the average number of
adjacencies per entity that occurs in usual three dimensional tetrahedral and hexahedral
meshes.
3.1.1
The Euler-Poincaré Formula
The Euler-Poincaré formula describes the relationship of the number of vertices, the number of edges and the number of faces of the cellular decomposition (a mesh) of a manifold.
It has been generalized to include potholes and holes that penetrate the solid. To state
the Euler-Poincaré formula, we need the following definitions:
• #V is the number of vertices in the cellular decomposition,
• #E is the number of edges in the cellular decomposition,
• #F is the number of faces in the cellular decomposition,
• G is the number of holes that penetrate the solid, usually referred to as genus in
topology,
• H is the number of shells. A shell is an internal void of a solid. A shell is bounded
by a 2-manifold surface, which can have its own genus value. Note that the solid
itself is counted as a shell. Therefore, the value for #S is at least 1.
• L is the number of loops. All outer and inner loops of faces are counted. The
Euler-Poincaré formula is
#V − #E + #F − (L − #F ) − 2(S − H) = 0.
3.1. GENERALITIES
59
Consider a cube. It has eight vertices (#V = 8), 12 edges (#E = 12) and six faces
(#F = 6), no holes and one shell (S = 1); but #L = #F since each face has only one
outer loop. Therefore, we have
#V − #E + #F − (L − #F ) − 2(S − H) = 8 − 12 + 6 − (6 − 6) − 2(1 − 0) = 0.
Consider now M, a 2D mesh of a domain Ω. The Euler-Poincaré relation gives the
following relation between those quantities:
#V − #E + #F − χ(M) = 0
where χ(Ω) is the Euler-Poincaré characteristic of the surface. The Euler-Poincaré characteristic of different surfaces is given in the following bullet list:
• for the sphere, χ = 2 (#V − #E + #F = 2 − 4 + 4),
• for the torus, χ = 0 (#V − #E + #F = 4 − 8 + 4),
• for the disk, χ = 1,
• for the Klein bootle, χ = 1.
Another form of the Euler-Poincaré relation, more useful for general domains is given by:
(3.1)
χ(M) = #V − #E + #F = 2 − 2G − NB
where,
• NB is the number of boundaries (1 for the plane or 0 for a torus or a sphere),
• G is the genus of the surface. The genus is the largest number of nonintersecting
simple closed curves that can be drawn on the surface without separating it. Roughly
speaking, it is the number of handles in a surface.
From Eq. 3.1, it is then easy to compute the genus G of a given mesh M:
(3.2)
G(M) =
−χ(M) − NB + 2
2
Property 3.1.1 We consider a mesh of a 2D domain that is isomorphic to a disk. Then,
the following relations holds
(3.3)
#F − 2(#V − 1) + #Vb = 0
(3.4)
#E − 3(#V − 1) + #Vb = 0
where #Vb is the number of vertices on b.
60
CHAPTER 3. MESH GENERATION
This is an important relation that gives a relation between the number of triangles
and the number of vertices in the triangular mesh of a “disk-like” surface. In order to
proove this, let us first remark that relations (3.3) and (3.4) are true for one triangle alone:
#F = 1, #V = #Vb = 3.
Swapping an edge of the mesh does not modify #V , #E, #F or #Vb . All triangulations with #N given are therefore equivalent: edge swaps allow to transform any given
triangulation to any other.
Inserting a point inside a triangle adds one vertex, 2 triangles and 3 edges to the
mesh, leaving #Vb unchanged:
(#F + 2) − 2((#V + 1) − 1) + #Vb = #F − 2(#V − 1) + #Vb = 0
(#E + 3) − 3((#V + 1) − 1) + #Vb = #E − 3(#V − 1) + #Vb = 0.
Inserting a point on the domain boundary b adds one vertex, one triangles and two edges
to the mesh. Relations (3.3) and (3.4) are still true:
(#F + 1) − 2((#V + 1) − 1) + (#Vb + 1) = #F − 2(#V − 1) + #Vb = 0
(#E + 2) − 3((#V + 1) − 1) + (#Vb + 1) = #E − 3(#V − 1) + #Vb = 0.
Property 3.1.2 We consider a mesh of a 3D domain that is isomorphic to a sphere. The
following relation holds
#E − #R = #V + #Vb − 3
where #Vb is the number of vertices on the boundary.
Note that this relation is true for one tetrahedron only, as well as for any other 3D element.
In a 3D tetrahedral mesh, there exist no relation between the number of tetrahedra
and the number of nodes, as it exists in 2D. As an example, it is possible to define
the following “face swap” transformation: 2 tets that have a face in common can be
transformed in 3 tets without changing the number of vertices. Yet one additional edge
has to be added to the mesh in order to verify the relation, verifying the Euler-Poincaré
formula.
Asymptotically, the 3D Euler-Poincaré gives:
#V − #E + #F − #R ' 0.
In the following Tables 3.1 and 3.2, we present some statistics about 3-D meshes.
Those are “asymptotically” correct for sufficiently large meshes but are patently wrong
for coarse meshes. The average number of mesh entities in tetrahedral and hexahedral
meshes are presented in Table 3.1.
A second interesting set of statistics concerns the average number of mesh entities
of dimension d adjacent to a mesh entity of dimension q. We call this N d (M q ). These
statistics are represented in Table 3.2.
3.1. GENERALITIES
61
Tetrahedral Mesh M
#R = 6#V
#F = 12#V
#E = 7#V
Hexahedral Mesh M
#R = #V
#F = 3#V
#E = 3#V
Table 3.1: Relation between number of entities in a mesh.
Tetrahedral
d
3
N 3 (M d ) 1
N 2 (M d ) 4
N 1 (M d ) 6
N 0 (M d ) 4
Mesh M
2 1 0
2 5 23
1 5 35
3 1 14
3 2 1
Hexahedral
d
3
N 3 (M d ) 1
N 2 (M d ) 6
N 1 (M d ) 12
N 0 (M d ) 8
Mesh M
2 1
2 4
1 4
4 1
4 2
0
8
12
6
1
Table 3.2: Average number of adjacencies per entity
We read these tables as follow: most of the tetrahedron meshes will contain, when
they are sufficiently big, 6 times more tetrahedron than vertices. Every edge is connected,
on average, to 5 tetrahedron.
The information contained in these two tables are important when designing mesh
data structures or when choosing one finite element interpolation scheme. In a tetrahedral
mesh for example, it is important to figure out that there are 12 times more faces than
vertices and that any scheme that imposes to store in memory the faces of the mesh will be
expensive. Moreover, building finite element interpolations on tetrahedral meshes based
on any other entity than vertices will generate large number of degrees of freedom.
3.1.2
Mesh generation procedure
Usual mesh generation procedures work as follows
• Curves are discretized first i.e. are subdivided into line elements,
• Then, surfaces are triangulated using the discretization of the curves as boundaries,
• Finally, regions are tetrahedralized using surface meshes.
Some authors have proposed an alternative procedure that consist in building the 3D
mesh at first [?, ?]. This kind or approach is not used in Gmsh and will not be discussed
here. Figure 3.1 illustrate this three steps procedure.
At the end, some pre- and post-processing steps can be plugged in the general mesh
generation ”three steps” flow.
• High order curvilinear meshed are usually build starting from a valid 3D straight
sided mesh.
62
CHAPTER 3. MESH GENERATION
Figure 3.1: Example of a 3D meshing procedure in Gmsh. From top, 1D meshing procedure, surface meshing and volume meshing.
3.2. MESH SIZE FIELD AND QUALITY MEASURES
63
• Quadrilateral meshes generation procedures usually use a valid triangulation as their
starting point.
• Boundary layer meshes are often build using an extrusion of the triangulation.
All the stages of those mesh generation procedures are presented in the next sections of
the chapter.
3.2
Mesh size field and quality measures
The aim of mesh generation is twofold
1. Generating elements of the right size,
2. Generating elements of the right shape.
For addressing those aims, we have to clarify what is right for an element, both in terms
of size and shape.
3.2.1
Mesh size field
A mesh size field is a tool that aims at controlling the mesh size. We define the mesh
size function δ(x, y, z) as a function the defines at every point of the domain a target size
for the elements at the point. Recall that one of the two aims of the mesh generation
procedure is to be able to build a mesh that complies with this mesh size field. Note that
δ may me a tensor valued function. In this case, the mesh size field may be used to control
directional sizes of the mesh and therefore enables to build anisotropic meshes.
The present ways of defining such a mesh size field in Gmsh are:
1. mesh sizes prescribed at model vertices and interpolated linearly on model edges;
2. prescribed mesh gradings on model edges (geometrical progressions, ...);
3. mesh sizes defined on another mesh (a background mesh) of the domain;
4. mesh sizes that adapt to the principal curvature of model entities.
These size fields can then be acted on by functionals that may depend, for example, on
the distance to model entities or on user-prescribed analytical functions; and when several
size fields are provided, Gmsh uses the minimum of all fields. Thanks to that mechanism,
Gmsh allows for a mesh size field defined on a given model entity to extend in higher
dimensional entities. For example, using a distance function, a refinement based on the
curvature of a model edge can extend on any surface adjacent to it.
64
CHAPTER 3. MESH GENERATION
Let us now consider an edge e of the mesh. We define the adimensional length of
the edge with respect to the size field δ as
Z
(3.5)
le =
e
1
dl.
δ(x, y, z)
We can now define a more precise criterion regarding to the mesh size: we aim at
generating a mesh for which each mesh edge e is of size close to le = 1,
3.2.2
Element quality measures
To quickly evaluate the adequation between the mesh and the prescribed mesh size field,
we defined an efficiency index τ [?] as
ne
(3.6)
τ = exp
1 X
τe
ne
!
e=1
1
− 1 if le ≥ 1. The efficiency index ranges in τ ∈ [0, 1]
le
and should be as close as possible to τ = 1.
with τe = le − 1 if le < 1 and τe =
For measuring the quality of elements, various element shape measures are available
in the literature [?, ?]. Here, we choose a measure based on the element radii ratio, i.e.
the ratio between the inscribed and the circumcircles.
If K is a triangle, we have the following formula
γK = 4
sin â sin b̂ sin ĉ
sin â + sin b̂ + sin ĉ
,
â, b̂ and ĉ being the three inner angles of the triangle. With this definition, the equilateral
triangle has a γK = 1 and degenerated (zero surface) triangles have a γK = 0.
For a tetrahedron, we have the following formula:
γK =
4
X
i=1
√
6 6 Vk
!
a(fi )
,
max l(ei )
i=1,...,6
with VK the volume of K, a(fi ) the area of the ith face of K and l(ei ) the dimensional
length of the ith edge of K. This quality measurement lies in the interval [0, 1], an element
with γK = 0 being a sliver (zero volume).
3.3. ONE DIMENSIONAL MESHING
3.3
65
One Dimensional Meshing
Let us consider a point p(t) on a curve C, t ∈ [t1 , t2 ]. The number of subdivisions N of
the curve is its adimensional length:
Z t2
1
(3.7)
k∂t p(t)kdt = N.
t1 δ(x, y, z)
The N + 1 mesh points on the curve are located at coordinates {T0 , . . . , TN }, where
Ti is computed with the following rule:
Z
Ti
(3.8)
t1
1
k∂t p(t)kdt = i.
δ(x, y, z)
With this choice, each subdivision of the curve is exactly of adimensional size 1, and the
1-D mesh exactly satisfies the size field δ. In Gmsh, (3.8) is evaluated with a recursive
numerical integration rule.
3.4
3.4.1
Delaunay and Voronoı̈
The Voronoı̈ diagram
Let p1 and p2 be two points of R2 . The mediator M(p1 , p2 ) is the locus of all the points
which are equidistant to p1 and p2 :
M(p1 , p2 ) = {p ∈ R2 , d(p, p1 ) = d(p, p2 )}
where d(., .) is the euclidian distance between two points of R2 , i.e.
(3.9)
d2 (p1 , p2 ) = (p2 − p1 ) · (p2 − p1 ).
The equation of the mediator can be found out using this definition
(p1 − p) · (p1 − p) = (p2 − p) · (p2 − p)
or




1
=0
(p1 − p2 ) · 
p
−
(p
+
p
)
1
2


2
|
{z
}
pm
This shows that the mediator is the orthogonal bissector of the straight edge linking the
two points. The mediator separates the plane into two regions. The first region contains
all the points that are closer to p1 , the second one contains the ones that are closer to p2 .
Any point of R2 /M can be associated to one of those two points.
66
CHAPTER 3. MESH GENERATION
p2
pm
p
M
Figure 3.2: The mediator.
p1
3.4. DELAUNAY AND VORONOÏ
67
pj
vI
pk
pi
C(pi )
Figure 3.3: The Voronoı̈ diagram. The Voronoı̈ cell C(pi ) relative to vertex pi is colored.
Let us consider a set of N points S = {p1 , . . . , pN }. More specifically, we assume
that the points are in general position, by which we mean no four points are cocircular.
The Voronoı̈ cell C(pi ) associated to point pi is the locus of points of R2 that are closer
to pi than any other point pj , j = 1, . . . , N , i 6= j.
The Voronoı̈ cell is constructed as follow. Consider all mediators M(pi , pj ). Each
of those mediators define a half plane. The Voronoı̈ diagram is the part of the space
that is always closer to pi , i.e. that always associate pi to the point p, for all possible
mediators.(see Figure 3.3). The set of all Voronoı̈ cells is called the Voronoı̈ diagram of S
(see Figure 3.3).
Let us present some remarkable properties of the Voronoı̈ diagram.
Property 3.4.1 Voronoı̈ cells are convex polytopes.
By definition, each Voronoi region C(pi ) is the intersection of open half planes containing
vertex pi . Therefore, C(pi ) is open and convex. Different Voronoı̈ regions are disjoint.
Voronoı̈ cells are polygons in 2D, polyhedra in 3D and d-polytopes in dD. Voronoı̈ cells
are either closed or open. They can only be open for points that are located on the convex
hull of the 2D domain. A point pi of S lies on the convex hull of S if and only if its
Voronoı̈ cell C(pi ) is unbounded.
68
CHAPTER 3. MESH GENERATION
Figure 3.4: Two triangulations of S, both containing nt = 13 triangles defined by a total
of N = 12 points with Nh = 9 points that lie on the convex hull of S.
Property 3.4.2 Voronoı̈ points vI are always located at intersection of 3 mediators.
Property 3.4.2 is only true if there exist no quadruplets of points in S that are cocircular.
If such a set exists, it may happen that a vertex of the Voronoı̈ is at the the intersection of
more than 3 mediators. Consider the example of Figure 3.3 where vi is at the intersecion
of C(pi ), C(pj ) and C(pk ). Voronoı̈ point vI is located at the center of the unique circle
passing through pi , pj and pk .
3.4.2
The Delaunay Triangulation
We first define what is a triangulation of S: it is a planar subdivision whose bounded faces
are triangles and whose vertices are the points pi of S. Note that all triangulations do not
cover the same subset of R2 . In what follows, we consider that the domain to triangulate
is the convex hull of S.
Even with the same domain to cover, several triangulations are possible (see Figure
3.4). Yet, every triangulation has the same number of triangles and edges!
Property 3.4.3 Let S be a set of N points in the plane, not all collinear, and let Nh
denote the number of points in S that lie on the convex hull of S. Then any triangulation
of S has nt (N, Nh ) = 2N − 2 − Nh triangles and ne (N, Nh ) = 3N − 3 − Nh edges.
3.4. DELAUNAY AND VORONOÏ
69
Proof Consider first that all the points in S are in the convex hull: N = Nh . A triangulation consist simply in triangles tI (p1 , pi , pi+1 ), i = 2, . . . , N − 1. The number of triangle
is therefore nt = N − 2 which is consistent with the formula. The number of edges in the
triangulation is calculated as follows: Nh = N edges on the convex hull and N − 3 internal
edges wich gives ne = N + N − 3 = 2N − 3 which is again consistent with the proposition.
The rest of the proof works using a recurrence argument. Assume that formulas are
true for N . Let us now consider one new vertex pN +1 that lies inside the convex hull.
This new vertex lies inside one of the existing triangles, say tI (pi , pj , pk ). We remove tI
and replace it by three new triangles tJ (pi , pj , pN +1 ), tJ (pj , pk , pN +1 ), tJ (pk , pi , pN +1 ).
We have therefore nt (Nh , Nh ) = Nh − 2 and nt (N + 1, Nh ) = nt (N, Nh ) + 2 which gives
nt (N, Nh ) = Nh − 2 + 2(N − Nh ) = 2N − 2 − Nh . Similarly, three new edges have been
added in the process. Then, ne (Nh , Nh ) = 2Nh − 3 and ne (N + 1, Nh ) = ne (N, Nh ) + 3
which gives ne (N, Nh ) = 2Nh − 3 + 3(N − Nh ) = 3N − 3 − Nh .
Consider a triangulation T with nt triangles. This triangulation has 3nt internal
angles. Consider the vector of angles A(T ) = (α1 , . . . , α3nt ) sorted by increasing values.
We can define such a vector for any triangulation of the convex hull of the domain. Each
of those vectors has the same length and it is therefore possible to compare them, e.g.
lexicographically. We say that one given triangulation T is angle-optimal if A(T ) ≤ A(T 0 ),
∀T 0 . According to that criterion, left triangulation of Figure 3.4 is better than the right
one.
Angle-optimal triangulations have interesting interpolation properties and it is therefore useful to find methods that allow to construct such triangulations.
For a given set of points, the (unique) angle-optimal triangulation is the triangulation
that has the highest minimal angle. Let us see now how to build such a triangulation.
Consider now the edge e(p4 , p6 ) of Figure 3.5. This edge is surrounded by two
triangles t1 (p4 , p6 , p1 ) and t2 (p4 , p6 , p2 ) . An edge swap is a local mesh modification
operator that consist in changing locally the triangulation by replacing edge e(p4 , p6 ) by
e0 (p1 , p2 ). Triangles t1 (p4 , p6 , p1 ) and t2 (p4 , p6 , p2 ) are replaced by t01 (p1 , p2 , p4 ) and
t02 (p1 , p2 , p6 ). Figure 3.5 illustrate the edge swap operation.
It is indeed possible to use the edge swap operator in order to build angle-optimal
triangulation. In that purpose, we can simply decide to swap edge e if
min (α1 , . . . , α6 ) < min (α10 , . . . , α60 ).
Such an edge is said invalid. Given a finite set of points, there is a finite number of
possible triangulations. When the angle criterion is applied, every edge swap produce a
new triangulation that is better than the actual one. Therefore, building the angle-optimal
triangulation consist in looping over all the edges of the mesh and swap them until the
optimal configuration is attained i.e. when no invalid edges remain in the triangulation.
Figure 3.6 illustrate that procedure.
Yet, computing angles is a costly operation and it is possible to use a simpler and
cheaper rule to verify the validity of an edge.
70
CHAPTER 3. MESH GENERATION
3.4. DELAUNAY AND VORONOÏ
71
Figure 3.6: Building an angle-optimal triangulation using swaps.
Property 3.4.4 Let C be a circle, l a line intersecting C in points p4 and p6 and p1 , and
p2 , p3 and p5 points lying on the same side of l . Suppose that p2 and p3 lie on C, that
p5 lies inside C, and that p1 lies outside C. Then (see Fig. 3.7):
α1 < α2 = α3 < α5 .
Property 3.4.5 [Lawson’s Criterion] Consider an edge e with its two neighboring triangles t1 and t2 . Consider the circumcircle C of triangle t1 and point p that belongs to t2
but not to t1 . Edge e is invalid if p ∈ C.
Property 3.4.5 has been demonstrated by Sibson in [?]. Consider Figure 3.8. The proof
consist in demonstrating that α0 > α if p1 ∈ C. The demonstration make use of property
3.4.4 (Thalès’s Theorem).
Note that, when two neighboring triangles separated by an edge e form a concave
quadrilateral, edge e is always valid.
Procedure described in Figure 3.6 allow to build angle-optimal triangulations. Yet,
it can be shown that such an algorithm is slow in practice.
There exists a much faster manner to build angle optimal triangulations of S that
is based on the Voronoı̈ diagram. This triangulation DT (S) is called the Delaunay triangulation and its construction works as follows.
First recall that each Voronoı̈ cell C(pi ) is associated to one only point pI of S.
Consider a Voronoı̈ point vI that at the meeting point of 3 Voronoı̈ cells C(pi ),
C(pj ), C(pk ). Because of the Voronoı̈ property, point v is at the circumcenter of triangle
tI (pi , pj , pk ). Triangle tI ∈ DT (S) is one of the triangles of the Delaunay triangulation.
The resulting figure is a triangulation (see Figure 3.9).
Property 3.4.6 Let S be a set of points in the plane.
72
CHAPTER 3. MESH GENERATION
p1
p2
α1
α2
p5
p3
α3
α5
l
p4
p6
C
Figure 3.7: Theorem of Thalès
p2
C0
α0
e0
e
p4
α
C
p6
p1
Figure 3.8: Lawson’s criterion
3.4. DELAUNAY AND VORONOÏ
Figure 3.9: The Voronoı̈ diagram and its associated Delaunay triangulation
73
74
CHAPTER 3. MESH GENERATION
p2
C(t)
v0
v
p3
lc
t
p1
a
b
la
lb
c
Figure 3.10: Illustration of why property (i) of 3.4.6 is true.
(i) Three points pi , pj and pk ∈ S are vertices of the same triangle tI of the Delaunay
triangulation if and only if the circumcircle C(tI ) contains no point of S in its
interior.
(ii) Two points pi and pj ∈ S form an edge eI of the Delaunay triangulation if and
only if there is a closed disc C that contains pi and pj on its boundary and does not
contain any other point of S.
Proof Property (i) of 3.4.6, also called the incircle property, is a simple consequences of
the properties of construction of the Voronoı̈ diagram. Figure 3.12 show one triangle t
and its circumcenter v. If a point like a exist in S, triangle t is cannot be in the Delaunay
triangulation because point a is closer to v that at least one of the three points p1 p2 or
p3 . Therefore, as it is drawn in the Figure, mediator la crosses another mediator at point
v0 inside the triangle, which is impossible.
Property 3.4.7 Let S be a set of points in the plane in general position. A triangulation
T of S is angle-optimal if and only if T is the Delaunay triangulation of S.
Proof We shall prove that the angle-optimal triangulation is the Delaunay triangulation by contradiction. So assume T is a legal triangulation of S that is not a Delaunay
triangulation. By Property (ii) of 3.4.6, this means that there is a triangle t(pi , pj , pk )
such that the circumcircle C(t) contains a point pl ∈ S in its interior. Let e(pi , pj ) be
the edge of t0 (pi , pj , pl ) such that the triangle t0 does not intersect t. Of all such pairs
3.4. DELAUNAY AND VORONOÏ
75
pi+1
C(Ti, pi+1)
pi+1
C(Ti, pi+1)
Figure 3.11: Delaunay triangulation Ti (left). The Delaunay cavity Cp (Ti , pi+1 ) is represented in both middle (pi+1 is inside Ti ) and right (pi+1 is outside Ti ) figures.
(pi , pj , pk , pl ) in T , choose the one that maximizes the angle pi , pl , pj . Now look at the
triangle t00 (pi , pj , pm ) adjacent to t along e. Since T is angle-optimal, e is legal. By Property 3.4.5, this implies that pm does not lie in the interior of C(t). The circumcircle C(t00 )
contains the part of C(t) that is separated from t by e. Consequently, pl ∈ C(t00 ) Assume
that e0 (pj , pm ) is the edge of t00 such that triangle t000 (pj , pm , pl ) does not intersect t00 . But
now angle pj , pl , pm > angle pi , pl , pj by Thalès’s Theorem, contradicting the definition
of the pair (pi , pj , pk , pl ).
Note that the unicity of the Delaunay triangulation is only guaranteed when there
exists no quadruplets of points in the set S that are cocircular, i.e. for points in general
position. When S is not in general position, some of the Delaunay triangulations may not
be angle-optimal.
3.4.3
Construction of Delaunay Triangulations
There are two categories of algorithms that allow to create Delaunay triangulations.
Incremental Construction of Delaunay Triangulations: the Delaunay kernel
We consider a triangulation Ti and a point pi+1 inside Ti . The cavity C(Ti , pi+1 ) associated
to Ti and pi+1 is the set of all the triangles for which their circumsphere contains pi+1 .
We consider a triangulation Ti and a point pi+1 outside Ti . The cavity Cp (Ti , pi+1 )
associated to Ti and pi+1 is the set of all the triangles for which their circumsphere contains
pi+1 completed by all triangles that can be formed by joining all the edges of Ti visible by
pi+1 .
76
CHAPTER 3. MESH GENERATION
pi+1
B(Ti, pi+1)
pi+1
B(Ti, pi+1)
Figure 3.12: Delaunay triangulation Ti+1 In the left Figure, pi+1 is inside Ti and, in the
right Figure, pi+1 is outside Ti .
Property 3.4.8 The cavity Cp (Ti , pi+1 ) is star shaped and pi+1 belong to its Haddad
kernel.
A polygon is star-shaped with respect to pi+1 if, for each point pk , k = 1 . . . , Nc
of the polygon the edge e(pi+1 , pk ) lies entirely within the polygon. The set of all points
pi+1 with the described property is called the kernel of the polygon, or its Haddad Kernel.
Figure ?? illustrate what we call a star shaped cavity. A convex polygons is star
shaped, but the inverse is not true. Thanks to property 3.4.8, it is quite easy to build
a triangulation of the cavity, simply by adding Nc triangles. This set of new triangles is
called the ball B(Ti , pi+1 ).
Let us assume that we have build the Delaunay Triangulation Ti with the first i
points of the set S.
It is possible to build iteratively the delaunay triangulation Ti+1 , i.e. using Ti and
pi+1 . We define the Delaunay kernel as the following procedure
Ti+1 = Ti − C(Ti , pi+1 ) + B(Ti , pi+1 )
that consist in removing from the triangulation elements of C(Ti , pi+1 ) that violate the
incircle property (i) of 3.4.6 and subsequently to triangulate the cavity with the ball
B(Ti , pi+1 ) Figure 3.12 illustrates the Delaunay kernel.
Property 3.4.9 if Ti is the Delaunay triangulation of the convex hull of the i first points
of a set S, then Ti+1 , the triangulation constructed using the Delaunay kernel is a Delaunay
triangulation
3.4. DELAUNAY AND VORONOÏ
77
Recursive Construction of Delaunay Triangulations: Divide and Conquer
There exists a “Divide and Conquer” type of algorithm for triangulating a known set of
points. It allows a O(N log N ) complexity. Divide and conquer (DC) is an important
algorithm design paradigm. It works by recursively breaking down a problem into two or
more sub-problems of the same (or related) type, until these become simple enough to be
solved directly. The solutions to the sub-problems are then combined to give a solution to
the original problem.
The Divide and Conquer algorithm for triangulations in two dimensions is due to
Lee and Schachter which was improved by Guibas and Stolfi and later by Dwyer. In this
algorithm, one recursively draws a line to split the vertices into two sets. The Delaunay
triangulation is computed for each set, and then the two sets are merged along the splitting
line
Algorithm 1 DelDC(PointIndex left, PointIndex right)
1: n = right - left + 1
2: if n = 2 then
3:
InsertInDList (left,right)
4: else if n = 3 then
5:
InsertInDList (left,right)
6:
InsertInDList (left,left+1)
7:
InsertInDList (left+1,right)
8: else if n > 3 then
9:
middle = (left + right) 1
10:
DelDC ( left, middle )
11:
DelDC ( middle+1, right )
12:
DelMerge ( left, middle , right )
13: end if
Algorithm 1 gives the pseudo code of the Divide and Conquer Delaunay triangulator
of Gmsh.
The set of points is assumed to be sorted lexicographically, i.e. points are sorted
form left to right and from bottom to top. Points are subsequently numbered using their
lexicographic index (PointIndex). Figure 3.13 shows a set
S = {p1 , p2 , . . . , p9 }
of 9 points sorted lexicographically.
A doubly linked circular list is assigned to every point pi of the set S. This data
structure contains every point pj that is connected through a mesh edge to point pi . Data
are stored in the list in the counter-clockwise sense, as it is pictured in Figure 3.14. The
list is doubly-linked i.e. it is possible to advance forward and backward.
Four functions have to be implemented in order to use the doubly-linked lists.
Function InsertInDList(i,j) adds edge (i,j) in the triangulation i.e. inserts point
78
CHAPTER 3. MESH GENERATION
p7
S
p5
p3
p1
p9
p4
p6
p2
p8
Figure 3.13: A set of points sorted lexicographically
p5
p3
p4
p6
p2
p6
p5
p3
p2
Figure 3.14: The doubly-linked circular list associated to point p4 .
3.4. DELAUNAY AND VORONOÏ
79
j in the list of adjacencies of i and inserts i in the list of adjacencies of j. Function DeleteInDList(i,j) deletes edge (i,j) from the triangulation. Functions k =
Predecessor(j) and k = Successor(i,j) respectively computes the predecessor and
the successor k to point j in the adjacency list of i.
The DelDC function (see algorithm 1) builds a Delaunay triangulation for the subset
of points
Ssubset = {plef t , plef t+1 , . . . , pright }.
Three trivial cases are treated:
• If the number of points n = right − lef t + 1 in Ssubset is less that n = 2, the
triangulation contains no edge;
• If n = 2, one edge is added in the triangulation;
• If n = 3, three edges are created that form one triangle.
If n > 3, the middle point of Ssubset is computed. The DelDC function is called twice
recursively with ranges of half the initial size: DelDC(left,middle) and DelDC(middle+1,right).
When those two function calls are terminated, both sets of points going from left to
middle and from middle+1 to right are Delaunay triangulations. A procedure that we
call DelMerge enables to merge the two disconnected Delaunay triangulations to form a
unique Delaunay triangulation of the whole range going from left to right
The first part of the DelDC procedure is illustrated graphically at Figure ??. The
set of points is first split in two subsets S1 and S2 (part (a) of Figure ??). Then, each
part is split again, giving four subsest S11 , S12 , S21 and S22 (part (b) of Figure ??). The
recursion stops when sub-sets of points have at most three points. At this point, every
subset can be processed trivially (part (c) of Figure ??).
The second part of the DelDC procedure is illustrated graphically at Figure 3.16. Delaunay triangulations DT (S11 ) and DT (S12 ) are merged as well as DT (S21 ) and DT (S22 ),
forming two Delaunay triangulations DT (S1 ) and DT (S2 ) (part (a) of Figure 3.16). Then
DT (S1 ) and DT (S2 ) are merged to form the final result DT (S) (part (b) of Figure 3.16).
Let us now describe the most complex part of the algorithm, i.e. the DelMerge
procedure. We will illustrate it using DT (S1 ) and DT (S2 ). The DelMerge procedure
stars by computing the lower common tangent (LCT) and the upper common tangent
(UCT) of the union of both triangulations (Figure 3.17).
Edges U CT and LCT are edges of the Delaunay triangulation of the union of the two
sets because they belong to the convex hull and Delaunay triangulations are triangulations
of the convex hull. The merging process MergeDC aims at filling the empty gap between
the two triangulations DT (S1 ) and DT (S2 ),
The MergeDC procedure starts from the LCT with its two points l and r. Even though
triangles surrounding those two points are part of respectively DT (S1 ) and DT (S2 ), they
may not be part of DT (S).
80
CHAPTER 3. MESH GENERATION
p7
p7
S1
S2
S11
S12
S21
p5
p3
p5
p3
p1
S22
p1
p9
p9
p4
p4
p6
p6
p2
p2
p8
p8
(a)
(b)
p7
S11
S12
S22
S21
p5
p3
p1
p9
p4
p6
p2
p8
(c)
Figure 3.15: Illustration of the Divide and Conquer procedure.
3.4. DELAUNAY AND VORONOÏ
81
p7
S1
p7
S2
p5
p3
S
p5
p3
p1
p9
p1
p4
p9
p6
p4
p6
p2
p8
p2
p8
(a)
(b)
Figure 3.16: Illustration of the DelMerge procedure of the Divide and Conquer procedure.
This procedure merges the two left triangulations DT (S1) and DT (S2) to form the final
result DT (S).
ur
U CT
ul,l2
r2
l1
r1
ll,l
LCT
lr,r
Figure 3.17: Computation of both lower common tangent (LCT) and the upper common
tangent (UCT) of the union of both triangulations. Point indices like l,ll or l1 refer to the
notations of algorithm 2
82
CHAPTER 3. MESH GENERATION
ur
U CT
ul,l2
r2
l1
r1
ll,l
lr,r
Figure 3.18: One step of the merging procedure.
Consider point r in Figure 3.17. Edge (r,r1) is the one the is the Predecessor of
LCT in r’s adjacency list and edge (r,r2) is the one the is the Predecessor of (r,r1) in r’s
adjacency list. We apply Lawson’s criterion to edge (r,r1), i.e. look if point r2 lies inside
the circumcircle of triangle (l,r,r1). If it is not the case, then triangle (l,r,r1) cannot be
excluded regarding to DT (S2 ).
Similarly, consider point l in Figure 3.17. Edge (l,l1) is the one the is the Successor
of LCT in l’s adjacency list and edge (l,l2) is the one the is the Successor of (l,l1) in l’s
adjacency list. We apply Lawson’s criterion to edge (l,l1), i.e. look if point l2 lies inside
the circum circle of triangle (l,l,l1). If it is not the case, then triangle (r,l,l1) cannot be
excluded regarding to DT (S1 ).
Among the two possible new edges (r,l1) and (l,r2) that may be added to the triangulation, edge (r,l1) is chosen because it satisfies the incircle property (see Figure 3.18).
In the particular case of Figure 3.17, the process can be continued two times (see
Figure 3.4.3).
At the next step (Figure 3.20, part (a)), it is clear that edge (r,r1) cannot be part of
the triangulation because triangle (l,r,r1) has its circumcircle that contains r2. Note that
Lawson’s criterion is symmetric, which means that, if the circumcircle of triangle (l,r,r1)
contains r2, then the circumcircle of triangle (l,r,r2) contains r1. At this point, we simply
replace edge (r,r1) by edge (l,r2) and continue the process.
3.4. DELAUNAY AND VORONOÏ
83
ur,l1
l1
ul,l2
ur=r1
r2
l
l
r
ul,l1
r2
ll
lr
r
ll
lr
Figure 3.19: Two steps of the merging procedure.
ur,r1
ur,r1
l
ul,l1
l
ul,l1
r2
r
r
ll
ll
lr
(a)
lr
(b)
Figure 3.20: Three steps of the merging procedure.
84
CHAPTER 3. MESH GENERATION
Algorithm 2 MergeDC(PointIndex left, PointIndex mid, PointIndex right)
1: [ll,lr] = LowerCommonTangent(left, mid, right) , l = ll, r = lr
2: [ul,ur] = UpperCommonTangent(left, mid, right)
3: while l 6= ul or r 6= ur do
4:
b = false
5:
InsertInDList (l,r)
6:
r1 = Predecessor (r,l)
7:
while true do
8:
r2 = Predecessor(r, r1)
9:
if not InCirlce (l,r,r1,r2) then
10:
break
11:
else
12:
DeleteFromList (r,r1), r2=r1
13:
end if
14:
end while
15:
l1 = Successor (l,r)
16:
while true do
17:
l2 = Successor(l, l1)
18:
if not InCirlce (r,l,l1,l2) then
19:
break
20:
else
21:
DeleteFromList (l,l1), l2=l1
22:
end if
23:
end while
24:
if b or InCircle(l,r,r1,l1) then
25:
r = r1
26:
else
27:
l = l1
28:
end if
29: end while
30: InsertInDList (l,r)
An implementation of that algorithm is provided in Gmsh. Source code can be found
in gmsh/Mesh/DivideAndConquer.cpp.
3.5
Planar Meshing
This sections deals with the following issue: how to generate a well shaped triangulation
that respects a size criterion δ(x) on a planar domain S.
3.5. PLANAR MESHING
85
6
0.15
7
10
24
17
0.125
16
19
20
15
21
20
11
9
18
0.1
23
18
25
22
19
0.075
4
0.05
0.025
0
2
13
3
5
14
1
-0.075
16
15
2
1
17
-0.05
-0.025
8
3
12
9
8
14
10
11
7
6
4
13
0
0.025
12
5
0.05
0.075
Figure 3.21: A simple 2D model (conge.geo).
3.5.1
The general procedure
Let us start by defining a simple planar surface in Gmsh (Figure 3.21). This model is
contained in the Gmsh distribution and is called conge.geo. This model is composed of
two planar surfaces, 20 model edges and 25 model vertices. We consider a uniform size
field δ = 0.005. The first step for doing the mesh is to discretize (or mesh) the edges of the
model. This operation is done computing the primitive (3.8) for every edge of the model.
The result is presented in Figure 3.22. Then, each of the two model faces is triangulated.
At first, all the mesh vertices that bounds the model face are considered. Four extra
mesh vertices are added to the list. These four vertices are the corners of a rectangle that
encompasses the model surfaces (Figure 3.24).
The convex hull of the domain is then triangulated using any convenient (and fast)
algorithm. In Gmsh, we use the divide and conquer approach that is presented in §3.4
(Figure 3.24).
Triangulating the set of points using the pre-cited algorithm produces a Delaunay
triangulation of the convex hull of the point set, i.e. the rectangle bounded by the additional four points. Yet, there is no guarantee that all the edges of the 1D mesh are present
in the triangulation. The Delaunay triangulation only deals with points and triangles, not
86
CHAPTER 3. MESH GENERATION
0.15
0.125
0.1
0.075
0.05
0.025
0
-0.075
-0.05
-0.025
0
0.025
0.05
0.075
Figure 3.22: The 1D mesh of model conge.geo.
with edges.
Some of the mesh edges that discretize the model edges may not be in the triangulation. There exists one condition that ensure that all the edges of the 1D mesh will be
present in the initial Delaunay triangulation. Consider an edge with points p1 and p2 .
This edge will be present in the Delaunay triangulation if the circle centered at 21 (p2 + p1 )
of diameter kp2 − p1 k does not contain any other point of the set than p1 and p2 . In
practice, it is possible to refine the 1D mesh in order to fullfill this circle criterion.
It is also possible to recover the missing 1D edges using edge swaps. In our first
simple case, all edges of the 1D mesh are indeed present in the Delaunay triangulations
and nothing has to be done. We will present in a further discussion examples where edge
recovery has been applied as well as the edge recovery algorithm. Note that, when an edge
has to be recovered, the resulting triangulation is not anymore a Delaunay triangulation.
This kind of triangulation is sometimes called a constrained Delaunay triangulation.
Another issue that may occur during the definition of initial mesh concerns possible
self-intersections of 1D mesh edges. We assume here that model edges of the geometry
do not self intersect. However, this does not guarantee that, even if the model edges G1j
that constitute the boundaries of the domain are non intersecting, the corresponding 1D
meshes do not self intersect. Figure 3.23 shows two model edges that are very close to
3.5. PLANAR MESHING
87
Figure 3.23: A geometry with two islands that are very close to each other. The first
image shows the initial 1D mesh that respects mesh size field. The second image shows
the first iteration of the recovery algorithm. The third image shows the final mesh that
was possible to realize after 2 recovery iterations
each other. Yet, even the geometry is itself not self-intersecting, the first 1D generated
mesh intersects itself. This can be been considered as a critical issue: modifying the mesh
size field by hand locally cannot be considered when several thousand of boundaries are
to be involved. It is therefore mandatory to define a systematic recovery procedure. Such
an algorithm illustrated in Figure 3.23 works as follow:
1. A Delaunay mesh that contains all points of the 1D mesh is initially constructed
using a divide and conquer algorithm [?].
2. Missing edges are recovered using edge swaps [?]. If a mesh edge ei that belongs to
the 1D mesh is to be swapped for recovering edge ej , then the mesh edges ei and ej
that both belong to the 1D mesh intersect.
3. All intersecting edges ek are split in 2 segments and the new point is snapped onto
the geometry. Then, we go back to the first step until the list of intersecting edges
is empty.
If an intersecting edge is smaller than the geometrical tolerance, then an error message is
thrown claiming that the geometry is self intersecting.
Triangles that are outside the domain have to be removed form the triangulation.
This can be done simply by choosing one triangle that contains one of the four corners
and to walk through its edge-neighbors, recursively, stopping the process when crossing
an edge that belongs to the boundary of the domain. The element that is on the other
side of this edge is inside the domain. Then, we walk again through the neighbors allow
to get all element that are inside the domain(Figure 3.25).
Points are inserted in the domain in order to refine the triangulation. The way
points are inserted is the key point of the method. Different algorithms are available in
Gmsh. We will present them in forthcoming sections.(Figure 3.25).
88
CHAPTER 3. MESH GENERATION
Figure 3.24: The first and second stages of the 2D meshing procedure for the model
conge.geo.
3.5. PLANAR MESHING
89
0.15
0.15
0.125
0.125
0.1
0.1
0.075
0.075
0.05
0.05
0.025
0.025
0
-0.075
0
-0.05
-0.025
0
0.025
0.05
0.075
-0.075
-0.05
-0.025
0
0.025
0.05
0.075
Figure 3.25: The fourth and fifth stages of the 2D meshing procedure for the model
conge.geo.
3.5.2
Boundary edges recovery
Triangulating the set of points using a Delaunay-based procedure produces a Delaunay
triangulation of the convex hull of the set. Yet, there is no guarantee that all the edges of
the 1D mesh are present in the triangulation. As an example, let us consider the initial
mesh of Figure 3.26. The boundaries of this U-shaped domain were discretized using a
prescribed spacing. The Delaunay triangulation of this set of points does not contain the
mesh edge with nodes 3 and 4.
Figure 3.27 presents the edge recovery procedure that enables to enforce the presence
of any edge Mi1 in the mesh. The procedure works as follows:
• A cavity containing triangles that are crossed by the edge to recover is set up first
(grey triangles in the first Figure).
• Internal edges of the cavity are counted. Here, we count initially 7 internal edges
that are all crossed by Mi1 .
• Edges of the cavity MISSING SENTENCE ...
3.5.3
Point insertion and Delaunay kernel
Assume that an initial mesh that matches the 1D boundary is available. New points have
now to be insterted in the mesh in order to build triangles that have both a good sizes
90
CHAPTER 3. MESH GENERATION
2
3
6
7
56
48
57
55
47
58
54
46
53
59
45
52
60
51
44
61
50
43
62
49
42
4
5
63
41
1
64
72
71
70
69
68
67
66
65
8
Y
Z
X
Figure 3.26: Initial Delaunay mesh based for the U model 2Drecovery.geo.
Figure 3.27: Boundary edge recovery procedure that recovers all the edges of the 1D
discretization procedure using swaps.
3.5. PLANAR MESHING
91
and shapes. There exist a bunch of point insertion techniques that are described in the
litterature.
One first idea would be for example to insert a new vertex in the middle of the longest
edge with points p1 and p2 (using, of course, its adimensional length). This is the default
surface meshing algorithm of Gmsh. We are aware that this point insertion algorithm has
a fundamental flaw. There is indeed no guarantee that there exist no point in the mesh
that is closer to the middle point than p1 and p2 . This point insertion algorithm may then
generate a new edge that is indeed too short and that will have to be removed afterwards
through edge collapsing.
A variant of the previous technique is used in BAMG [?]. It consist in saturating
the edges of the mesh with points, using e.g. the 1D technique described in §3.3. A bucket
tree datastructure is used to remove points that are too close. Thanks to that filtering
operation, no point removal has to be performed afterwards.
An optimal point insertion procedure should be able to insert points that will not
have to be removed afterwards. In other words, one should not insert points that are too
close to other points. An alternative to edge splitting would be insert the new point at the
circumcenter of the largest triangle [?]. We could define the adimensional size of a triangle
t(a, b, c) as the ratio between its circumradius and the mesh size at its circumcenter. The
circumcenter C of a planar triangle t can be computed as follows:
(ax − Cx )2 + (ay − Cy )2 = (bx − Cx )2 + (by − Cy )2
(ax − Cx )2 + (ay − Cy )2 = (cx − Cx )2 + (cy − Cy )2 .
This leads to the system:
1 b2x − a2x + b2y − a2y
Cx
(bx − ax ) (by − ay )
=
.
(cx − ax ) (cy − ay )
Cy
2 c2x − a2x + c2y − a2y
Circumradius Rt and inner radius rt of a triangle t are nicely related as
Rt = kC − ak =
kb − akkc − akka − bk
1
.
2rt kb − ak + kc − ak + ka − bk
The adimensional size lt of triangle t is computed as
(3.10)
lt =
√
3
Rt
.
δ(C)
√
The 3 factor in (3.10) is explained by the
√ fact that the circumradius of an equilateral
triangle with edges of size 1 being Rt = 1/ 3.
Triangles are sorted with respect to this adimensional length. A new point is inserted
at C and the Bowyer-Watson algorithm is used to locally recreate a new Delaunay triangulation with the additional point. The algorithm stops when lt < lmax with lmax ≥ 1. It
is indeed NOT a good idea to take lmax > 1. Imagine that triangle t has an adimensional
92
CHAPTER 3. MESH GENERATION
Figure 3.28: Illustration of the Bowyer-Watson algorithm with a point insertion scheme
based on the circumcenter of the largest triangle
length of lt = 1.1. Inserting a new point at its circumcenter would generate edges that are
about two times smaller than the existing ones that are of size 1.1. We define a range of
acceptable sizes [lmin , lmax ] in a way that splitting a large triangle edge lt > lmax would
not generate a triangle that is too small i.e. for which lt < lmin . This can be translated
in lmax = 2lmin . An usual choice for the acceptable range is to center it around 1 i.e.
lmax + lmin = 2. This gives [lmin , lmax ] = [2/3, 4/3]. Figure 3.28 gives an example of the
Bowyer and Watson algorithm with a point insertion based on the circumcenter of the
largest triangle. Points on the final mesh are nicely distributed so that only a very light
optimization (laplace smoothing) is necessary for obtaining the final mesh.
All point insertion algorithms that we have described before do not converge to a
mesh that is composed of a majority of equilateral triangles. Frontal methods have the
advantage of generating nicely shaped triangles. Yet, those latter methods are less robust
and slower than Delaunay meshers. It is possible to build a hybrid method that uses the
Bowyer and Watson algorithm that guarantees always to play with a valid mesh but where
points are inserted in a “frontal fashion”. Such a frontal-delaunay method should remain
fast, which means that a point that is inserted should never be removed afterwards.
3.5.4
Anisotropic Delaunay meshing
The Delaunay kernel as it has been explained in §3.4 can be extended so that distances
and angles are measured with respect to a given metric (see (2.12))
M=
E F
F G
.
3.5. PLANAR MESHING
93
Consider first the case of a spatially constant metric. The The circumcenter C of a planar
triangle t with respect to the metric M can be computed as follows:
E(ax − Cx )2 + G(ay − Cy )2 + 2F (ax − Cx )(ay − Cy ) =
E(bx − Cx )2 + G(by − Cy )2 + 2F (bx − Cx )(by − Cy )
E(ax − Cx )2 + G(ay − Cy )2 + 2F (ax − Cx )(ay − Cy ) =
E(cx − Cx )2 + G(cy − Cy )2 + 2F (cx − Cx )(cy − Cy )
This leads to the system:
E(bx − ax ) + F (by − ay ) G(by − ay ) + F (bx − ax )
Cx
=
G(cx − ax ) + F (cy − ay ) G(cy − ay ) + F (cy − ay )
Cy
1 E(b2x − a2x ) + G(b2y − a2y ) + 2F (bx by − ax ay )
(3.11)
.
2 E(c2x − a2x ) + G(c2y − a2y ) + 2F (cx cy − ax ay )
The circumradius Rt is computed as
Rt2 = E(Cx − ax )2 + G(Cy − ay )2 + 2F (Cx − ax )(Cy − ay ).
Bowyer and Watson and Lawson’s algorithms can be applied straight away using those new
formulas for cicumcenter and circumradius and the change in a Delaunay code is minimal.
Yet, most of the metrics we consider are not uniform i.e. those metrics vary in space. The
problem gets tricky because, in a Riemannian space (i.e. a space with a smooth metric),
the notion of distance involves the computation of geodesics. The mediator of two points
is not a line anymore and the Voronoi diagram is composed of curvilinear cells. Delaunay
meshes in a general Riemannian sense are curvilinear. This is indeed a nice topic that has
been tackled in [?]. Yet, it does not lead to practical applications.
It is indeed possible to use a metric that is constant locally i.e. to work on the so
called tangent plane at a given point x. This is the usual way of dealing with anisotropic
Delaunay meshing. The choice of the point at which the metric is computed is quite
important. We can still choose to compute the metric at the circumcenter of the triangle.
Yet, the position of the circumcenter depends on the metric itself, leading to a nonlinear
version of problem (3.11), i.e. where E, F and G all depend on Cx and Cy . In Gmsh,
we perform 2 or 3 fixed point iterations of (3.11). This gives usually a sufficiently precise
location of the circumcenter.
3.5.5
Practical implementation
To our opinion, the most important aspect of a practical implementation of a Bowyer and
Watson algorithm is its lightness. The algorithm should use the fewest possible amount of
memory (especially in 3D, but also in 2D). The procedure should of course be reasonably
fast but this is less important.
Recall now the definition of the Delaunay kernel. We consider a triangulation Ti
and a point pi+1 outside Ti . The cavity Cp (Ti , pi+1 ) associated to Ti and pi+1 is the set
94
CHAPTER 3. MESH GENERATION
of all the triangles for which their circumsphere contains pi+1 completed by all triangles
that can be formed by joining all the edges of Ti visible by pi+1 . We define the Delaunay
kernel as the following procedure
Ti+1 = Ti − C(Ti , pi+1 ) + B(Ti , pi+1 )
that consist in removing from the triangulation elements of C(Ti , pi+1 ) that violate the
incircle property (i) of 3.4.6 and subsequently to triangulate the cavity with the ball
B(Ti , pi+1 ). Figure 3.12 illustrates the Delaunay kernel.
The following datastructure is used in Gmsh for computing the Delaunay kernel.
class MTri3
{
bool deleted;
double adimensional_size;
MVertex *v[3];
MTri3 *neigh[3];
// ...
};
A point insertion procedure typically inserts and removes triangles from a set. On
the other side, it is usually interesting to store the triangles in a datastructure that allows
to have access to the largest one. Binary trees allow to add and remove elements in
logarithmic time. In our implementation, we have decided to add a deleted tag to every
triangle that tells if it is deleted. It is only when a traversal of the tree is performed that
tagged triangles are truly deleted (it is then a constant time operation).
The adimensional size of the triangle is also computed by the constructor of the
class MTri3 and stored. The three vertices of the triangle are also stored as well as its
three neighbors. A binary tree std::set<MTri3*,compareTri3Ptr> with a comparison
function compareTri3Ptr that compares two MTri3* with respect to their adimensional
size is created. The worst triangle is the one on the top of the tree, which means that the
Bowyer and Watson algorithm can be written as
while (1){
MTri3 *worst = *AllTris.begin();
if (worst->isDeleted()){
delete worst;
AllTris.erase(AllTris.begin());
}
else{
if (worst->getAdimensionalSize() < LMAX) break;
insertAPoint(AllTris, worst);
}
};
3.6. SURFACE MESHING
95
Let’s now be more clear about function insertAPoint. The aim of this function is to break
triangle worst. We can either choose to add the new point pi+1 on its circumcenter, to
put it somewhere on a Voronoi edge or to use any fancy point insertion policy. The first
task of the algorithm is to compute the Delaunay cavity Cp (Ti , pi+1 ). This task can be
done recursively:
void computeCavity(std::list<edgeXface> &closure,
std::list<MTri3*> &cavity,
double p[2], MTri3 *t)
{
t->setDeleted(true);
cavity.push_back(t);
for (int i = 0; i < 3; i++){
MTri3 *neigh = t->getNeigh(i) ;
if (!neigh)
closure.push_back(edgeXface(t, i));
else if (!neigh->isDeleted()){
if(inCircumCircle(neigh, p))
computeCavity(closure, cavity, p, neigh);
else
closure.push_back(edgeXface(t, i));
}
}
}
In our algorithm, not only the cavity is computed but also its closure i.e. a list of edges of
triangles that form the “shell” of the cavity. This shell will be used for both creating the
new triangles and reconnecting the new triangles with their neighbors on the other side of
the shell.
3.6
Surface Meshing
Curved surface shapes designed by CAD systems are usually defined by parametric surfaces, for example, NURBS [?]. Let us consider a model face G2i with its underlying
geometry, in this case a surface S ∈ R3 with its parametrization p~(u, v) ∈ S, where the
domain of definition of the parameters (u, v) is defined by a series of boundary curves. An
example of such a surface is given in Figure 3.29, which shows one of the 76 model faces
of the propeller in the parametric space (left) and in real space (right). Three features of
surface S, common in CAD descriptions, make its meshing non-trivial:
1. S is periodic. The topology of the model face is modified in order to define its closure
properly. A seam is present two times in the closure of the model face. These two
occurrences are separated by one period in the parametric space.
96
CHAPTER 3. MESH GENERATION
2. S is trimmed: it contains four holes and one of them is crossed by the seam.
3. One of the model edges of S is degenerated. This is done for accounting of a singular
point in the parametrization of the surface. This kind of degeneracy is present in
many shapes: spheres, cones and other surfaces of revolution.
Figure 3.29: Geometry of a model face in parametric space (left) and in real space (right).
Two seam edges are present in the face. The top model edge is degenerated in one point.
Techniques for generating finite element meshes on curved surfaces are of two kind:
1. techniques for which the surface mesh is generated directly in the real 3-D space;
2. techniques for which the surface mesh is generated in the parametric space.
The principal advantage of doing the surface mesh in the 3-D space directly is that no
interface to the solid modeler is required. Such algorithms have been used for building meshes from STL (stereolithography) data files [?], from medical imaging [?] or to
adapt/modify existing meshes [?]. The main drawback of such algorithms is their relative
lack of robustness.
The second alternative can be applied only if a parametrization of the surfaces is
available. If it is the case, doing the mesh in the parametric space is usually advantageous
because all the meshing procedures can be applied in the parametric plane. This allows
mesh operators to be highly robust—we will detail that argument later.
Yet, all surfaces do not always have a parametrization that conserves angles and
lengths. Consequently, only 2-D algorithms that allow to build anisotropic meshes in the
plane can be considered as good candidates for doing surface meshing. Figure 3.30 presents
the surface mesh of the model face of Figure 3.29, both in the parametric space and in
the real space. The mesh in the real space is isotropic and uniform while the one in the
3.6. SURFACE MESHING
97
Figure 3.30: Mesh of a model face drawn in the parametric space (left) and in the real
space (right).
parametric space is highly anisotropic and non uniform. To solve this problem, George and
Borouchaki [?] have proposed the use of a metric derived from the first fundamental form
of the surface (2.12). The metric field is a second order tensor field that has the form, at
any point of the parametric space, of a 2×2 matrix. The metric is used to define angles and
distances in parametric space (see Sec. 2.5.2). With their Delaunay approach, the ”empty
circle” property, effectively becomes an ”empty ellipse” property. An equivalent “metricbased” advancing front surface mesh generation algorithms is presented by Cuilliere in
[?]. A more exotic metric-based approach based on packing ellipses has been devised by
Yamada et al. [?] and has been used more recently by Lo and Wang in [?].
In addition to a Delaunay implementation similar to [?] and a frontal-Delaunay
meshing technique inspired by [?], Gmsh provides an original surface meshing strategy
based on the concept of local mesh modifications [?, ?, ?]. The main advantage of the new
approach, compared to the other ones based on the Delaunay criterion, is that it does not
require the computation of derivatives of the parametrization. For that reason, the new
approach remains robust even when the parametrization is singular.
Surface meshing algorithm based on local mesh modifications This surface
meshing algorithm works as follows. First, an initial mesh containing all the mesh points
of the curves bounding the face is built in the parametric space using a divide and conquer
strategy [?]. Then, all the edges of the 1-D discretization are recovered using swaps [?].
Finally, local mesh modifications are applied:
1. Each edge that is too long is split;
2. Each edge that is too short is removed using an edge collapse operator;
3. Edges for which a better configuration is obtained by swapping are swapped;
0
H
98
h
CHAPTER 3. MESH GENERATION
Fig. 1. Shallow water notations for water depth H with a time-independent bathymetry h. Notice that the relative elevation η is usually several
orders of magnitude smaller than the unperturbed depth.
e1
e3 e4
e5 e6
e2
y
e1
e2
e3
e4
Fig. 2. Local mesh modifications. Edge split (top), edge collapse (middle) and edge swap (bottom). The zone depicted in bold represents the
cavity that is modified by the local mesh modification.
Figure 3.31: Illustration of local mesh modifications.
4. Vertices are re-located optimally.
More precisely, here is how these four local mesh modifications procedures are applied in Gmsh:
Edge Splitting: An edge is considered too long when its adimensional length is greater
than le > 1.4. When split, the two new edges will have a minimal size of 0.7. In
order to converge to a stable configuration, an edge of size le = 0.7 should not be
considered as a short edge.
Edge Collapsing: An edge is considered to be short when its adimensional length is
smaller than le < 0.7. An edge cannot be collapsed if one of the remaining triangles
after the collapse is inverted in the parametric space.
Edge Swapping: An edge is swapped if min (γe1 , γe2 ) < min (γe3 , γe4 ) (see Figure 3.31),
unless
1. it is classified on a model edge;
2. the two adjacent triangles e1 and e2 form a concave quadrilateral in the parametric space;
3. the angle between the triangles normals is greater than a threshold, typically
30 degrees.
Vertex Re-positioning: Each vertex is moved optimally inside the cavity made of all
its surrounding triangles. The optimal position is chosen in order to maximize the
worst element quality [?].
3.7. 3-D MESH GENERATION
99
For each of these local mesh modification procedures, the opportunity of doing a
mesh modification is evaluated in the real space, i.e., in (x, y, z), while the validity of
a mesh modification is evaluated in the parametric space (u, v). Therefore, Gmsh mesh
generators always retain both real and parametric coordinates of any mesh vertex. To
ensure robustness, all the elementary geometrical predicates make use of robust algorithmic
[?].
In practice, this algorithm converges in about 6-8 iterations and produces anisotropic
meshes in the parametric space without computing derivatives of the mapping.
Let us illustrate the algorithm on an example. We have meshed the model face of
Figure 3.30 using an analytical size field
δ(x, y, z) = δ0 [1 + cos(π(x + y − z)/L)] + where L is a characteristic size of the domain and δ0 < L. Figure 3.32 shows the mesh
in the parametric space at different stages of the algorithm. Note that the derivatives of
the parametrization of the underlying surface are not defined at the singular point so that
any algorithm that requires to compute such derivatives would be in trouble in this case.
3.7
3-D Mesh Generation
Once a surface triangulation is available, an automatic mesh generation procedure does
not usually require an interface to a CAD system. Indeed, Gmsh interfaces several open
source 3-D tetrahedral mesh generation kernels [?, ?] in addition to its own Delaunay
refinement algorithm. These algorithms are standard [?, ?] and will not be explained
here. We focus on two other issues instead:
1. the way Gmsh interfaces multiple mesh generation algorithms;
2. the way Gmsh optimizes the quality of 3-D meshes.
Note that there is a third issue concerning the way Gmsh handles mixed structured/unstructured
grids, and that this issues is addressed in Section 3.7.2.
Mesh Algorithm Interfaces
Gmsh is able to deal with most of the standard finite element shapes: lines, triangles,
quadrangles, tetrahedra, hexahedra, prisms and pyramids. The internal mesh data structures are designed to minimize the memory footprint without compromising flexibility:
in addition to a integer tag and a partition/visualisation index, any element only holds
its ordered list of vertices. With that simple design, Gmsh can load about 12 million
tetrahedra per Gigabyte of memory (28 bytes per tetrahedron, 44 bytes per mesh vertex),
including graphics representation, i.e., OpenGL vertex arrays [?].
100
CHAPTER 3. MESH GENERATION
initial
iter. 1
iter. 5
final
iter. 3
Figure 3.32: Illustration of the surface meshing algorithm based on local mesh modifications. The images correspond to the initial mesh containing boundary vertices, the mesh
after 1, 3, 5 and 8 iterations. At iteration 8, the algorithm has converged. The size field
efficiency τ = 0.89 can be considered as excellent: 90 % of the elements have a radii ratio
γK greater that 0.9.
3.7. 3-D MESH GENERATION
101
When “in house” meshing routines are used, Gmsh derives (in the object oriented
sense) enriched data structures specifically tailored for each meshing algorithm. Those
derived structures contain just the right extra information necessary: the parametric coordinates of a vertex for parametric 2-D meshing algorithms, the neighbors of a tetrahedron
for the 3-D Delaunay algorithm, etc. With this approach the footprint of a tetrahedron is
for example extended to 84 bytes, and the 3-D Delaunay algorithm implemented in Gmsh,
using a classical Bowyer-Watson algorithm [?], is able to build about 7 million tetrahedron
per Gigabyte of memory (including overhead like the data structures of the CAD engine).
When a third party mesh generator is invoked, Gmsh needs of course to allocate the
appropriate structures required by that specific software. But thankfully, while transferring the data from the third party algorithm into Gmsh, only the minimal internal data
structures need to be allocated (i.e., 28 byte per tetrahedron in the 3-D case mentioned
above). This greatly reduces the overhead incurred by interfacing external algorithms.
Tetrahedral Mesh Improvement
Tetrahedral mesh improvement is usually required to produce 3-D meshes suitable for gridbased numerical methods [?]. Unfortunately, mesh optimization procedures have a lot to
do with “black magic”: even if the ingredients required to construct a mesh optimization
procedure are well known (essentially swapping and smoothing), there is no known “best
recipe”, i.e., no known optimal way of combining those smoothing and swapping operators.
Gmsh implements its own mesh optimization procedure to enhance tetrahedral mesh
quality by means of edge- and face-swappings and vertex relocations, and also interfaces
third party mesh optimizers—in particular the open-source optimizer from Netgen [?].
Interestingly, applying optimization routines one after the other enables to produce better
meshes than applying mesh optimizers separately. Figure 3.33 shows the distribution of
elemental qualities on the mesh of a toroidal domain containing about 600,000 tetrahedra
(the mesh was generated in about 30 seconds with the “in house” 3-D Delaunay algorithm).
The unoptimized mesh contains quite a few ill shaped elements: more than 5000 elements
have an aspect ratio γK below 0.2 and the worst shaped element has an aspect ratio of
10−3 . After one pass of the Gmsh mesh optimizer, which takes about 12 seconds, all slivers
have disappeared and the worst element has an aspect ratio of 0.32. The distribution of
element quality is enhanced, with a clear right shift of the distribution. Applying the
Netgen optimizer after the Gmsh optimizer, additional improvement can be observed: the
worst elemental quality is now 0.41 and another shift to the right has occurred. However,
the application of the Netgen optimizer also dramatically reduced the number of elements
in the mesh, and this second optimization pass took more than 200 seconds—about 15
times more than for the Gmsh optimizer. Transferring the mesh in Netgen format also
doubled the memory usage.
102
CHAPTER 3. MESH GENERATION
25000
no optimization
gmsh optimization
both netgen and gmsh optimizations
20000
15000
#Elements
10000
5000
0
0
0.2
0.4
0.6
Element Quality
0.8
1
Figure 3.33: Distribution of γK in a mesh of about 600, 000 tetrahedra.
3.7.1
Examples
One of the objectives of this section is to demonstrate that Gmsh is able build meshes
that can be used by the finite element community. The various examples shown below
can all be downloaded from the Gmsh web site. They come from different sources: native
Gmsh CAD models, CAD models found on the web, or CAD models that were proposed
by industrial and academic partners. The formats considered are IGES, STEP, BREP and
Gmsh. Various size fields have been used, uniform or not. Both 2-D and 3-D statistics
are provided.
Table 3.3 presents details for some of the models (see Figure 3.34) used in the Gmsh
2-D test suite. Mesh size field are defined in a variety of ways: analytic, uniform, size
fields driven by distance functions (attractors), boundary layers, size fields related to the
curvature of surfaces, or size fields interpolated using sizes that are defined on model
vertices. Table 3.4 gives statistics for the 2-D meshes generated with the surface meshing
algorithm presented in Section 3.6. In the case of planar surfaces and uniform meshes this
algorithm is about three times slower than the 2-D anisotropic Delaunay mesh generator
implemented in Gmsh. However, when multiple size fields are involved and/or when the
surfaces are very complex, this new approach becomes competitive in terms of CPU time—
and is much more robust than the anisotropic Delaunay mesher. With the caveat that
the performance and robustness of mesh generation algorithms are highly dependent on
their implementation, we believe this shows evidence that the new algorithm proposed in
Section 3.6 is a viable alternative to classical Frontal or Delaunay approaches.
Table 3.5 presents some statistics for 3-D meshes. The first example can serve as
reference: it is a unit cube that is meshed uniformly with about one million tetrahedra.
3.7. 3-D MESH GENERATION
103
gmsh
zylkopf
cylhead
fuse
frog
world ocean
Figure 3.34: Some images of surface meshes.
cube
gmsh
frog
frogadapt
linkrods
zylkopf
cylhead
fuse
block
senzor
world ocean
media
type
GMSH
GMSH
IGES
IGES
STEP
STEP
BREP
STEP
STEP
GMSH
GMSH
GMSH
nR
1
0
1
1
1
1
1
1
1
8
0
1274
nF
6
1
475
475
37
137
1054
249
533
90
1
8398
nE
12
35
950
950
108
404
2485
723
1586
200
4245
5779
nV
8
23
477
477
74
270
1445
476
1048
146
145291
3894
δ
uniform
attractor
uniform
analytic
analytic
at vertices
uniform
curvature
uniform
at vertices
boundary layer
uniform
Table 3.3: Statistics on the models that are considered: nR ,nF ,nE and nV are respectively
the number of model regions, of model faces, of model edges and of model vertices in the
model. δ is the size field.
104
CHAPTER 3. MESH GENERATION
block
linkrods
frogadapt
senzor
media
(W. Scholz, T.U. Wien)
Figure 3.35: Some images of volume meshes.
3.7. 3-D MESH GENERATION
gmsh
linkrods
zylkopf
cylhead
fuse
block
senzor
ocean
np
28041
55959
32806
84014
23485
19694
19876
1152011
ne
55922
119922
65668
188150
47038
55530
40002
2255212
105
γK > 0.9
83.5%
84.2%
86.0%
77.5%
76.0%
76.0%
84.6%
89.0%
minK γK
0.287
0.385
0.105
0.050
0.010
0.021
0.546
0.211
avgK γK
0.946
0.946
0.947
0.915
0.919
0.923
0.947
0.950
l√2
99.0%
98.9%
98.5%
95.5%
97.3%
96.8%
98.4%
99.1%
τ
0.891
0.893
0.860
0.892
0.886
0.895
0.896
0.901
cpu
10
61
8
45
11
20
11
729
Table 3.4: Surface mesh generation statistics. Here, np are ne are the number of points
and triangles in the surface mesh, γK > 0.9 states for the percentage of triangles that
have a quality measure γK greater that 0.9, minK γK is the worst element quality in the
surface mesh and avgK γK is the average elemental quality. The quantity l√2 states for
√
√
the percentage of edges that have an adimensional length in the range 1/ 2 < le < 2.
The factor τ is the efficiency index defined in Equation (3.6). The last column gives the
cpu time (in seconds) for performing the surface mesh generation.
cube
linkrods
block
senzor
frogadapt
media
np
195,671
341,297
48,897
143,799
403,947
164,517
ne
1,098,530
1,836,634
221,090
805,392
2,381,969
890,756
minK γK
0.235
0.347
0.012
0.222
0.172
0.071
avgK γK
0.717
0.756
0.660
0.765
0.691
0.696
cpu(mesh)
49 sec.
111 sec.
12 sec.
35 sec.
126 sec.
55 sec.
cpu(opti)
36 sec.
117 sec.
14 sec.
27 sec.
180 sec.
31 sec.
Table 3.5: Volume mesh generation statistics. Here, np are ne are the number of points
and tetrahedron in the volume mesh, minK γK is the worst element quality in the volume
mesh and avgK γK is the average elemental quality. The last two columns give mesh
generation and mesh optimization timings.
Some of the examples have complex mesh size fields (linkrods or frogadapt). One has small
features in the geometry (block). Some have multiple volumes (media or senzor). Complex
mesh size fields such as the ones of linkrods or frogadapt make the mesh generation process
slower of about 20%. This overhead is essentially due to the evaluation of the mesh size
field. Mesh with strong size variations or with small geometric features require more
optimization. The performance figures mentioned in Section 3.7 hold even for models
with a large number of model regions: the model called “media”, created in the native
Gmsh CAD format, involves over 1000 model regions and was meshed using the 3-D
Delaunay algorithm in less than one minute. All timings were measured on a standard
MacBook Pro with a CPU clocked at 2.0 GHz.
106
CHAPTER 3. MESH GENERATION
boundary layer
sweep
sweep (detail)
(R. V. Sabariego, Univ. of Liège)
Figure 3.36: Some images of hybrid volume meshes.
3.7.2
Mixed Meshes
In addition to unstructured meshes, Gmsh enables the generation of simple structured
meshes in 1-D, 2-D and 3-D, and allows to couple these with unstructured meshes. Structured technologies include transfinite and elliptic meshes as well as a variety of sweeping
techniques.
For example, to build a boundary layer mesh from a set of source surfaces (see
Figure 3.36), Gmsh
1. creates the topology of the boundary layer by sweeping zero-height volumes from all
the source surfaces. (In addition to the boundary layer volumes, this creates a set
of new boundary layer points, curves and surfaces. These new points, curves and
surfaces will only acquire a concrete representation during the meshing process.)
2. meshes the source surfaces and computes (unique) normals at the mesh vertices;
3. sweeps the boundary layer points along the normals, and remeshes all the nonboundary-layer curves connected to these points, and then meshes the boundary
layer curves by sweeping along the normals;
4. meshes the non-source surfaces, then the boundary layer surfaces (again by sweeping
along the normals), and finally the volumes.
Once all the structured parts are meshed, the remaining parts are meshed using the
unstructured algorithms, resulting in conforming mixed meshes.
Chapter 4
Remeshing based on surface
parametrization
There are two kind of applications for which it might be desirable to remesh a 3D surface
(see Fig. 4.1).
Figure 4.1: Examples of geometries for which a remeshing procedure is desirable. Left
figure show an example of oversampled triangluation resulting from a mesh segmentation
of a human pelvis and right figure shows the straightforward meshing of a CAD geometry
of a maxi-cosi.
The first application concerns medical geometries that are often described only by
a triangulation (in stereolitography STL format). This triangulation is the result of a
segmentation procedure from the CT scan or MRI dicom-images. Those triangulations
can be oversampled and have triangles of poor quality with small elementary angles. Those
low quality meshes are not suitable for finite element simulations since the quality of the
mesh will impact both on the accuracy and efficiency of the numerical method [?, ?]. In
107
108
CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION
this case, it is desirable to build a high quality mesh from those low quality meshes before
performing any numerical simulation.
The other application is about CAD models. CAD models are often made of a
huge amount of patches that have no physical significance and a straightforward meshing
of those patches gives often meshes that are not suitable for finite element simulations.
Indeed, as most surface mesh algorithms mesh model faces individually, mesh points are
generated on the bounding edges of those patches and if thin CAD patches exist in the
model they will result in the creation of small distorted triangles with very small angles
- even if the bounding edges of these thin patches (Fig.4.2). Those low quality elements
present in the surface mesh will often hinder the convergence of the FE simulations on those
surface meshes. Besides, they also prevent the generation of quality volumetric meshes
for three-dimensinal finite element computations (CFD, structure mechanics, etc.). An
efficient manner to build a high quality mesh for those CAD models is then to build from
the initial CAD mesh a cross-patch parametrization that enables the remeshing of merged
patches.
Figure 4.2: Example of 2 patches of a CAD geometry (left) for which the mesh (right)
contains triangles of poor quality.
There are mainly two approaches for surface remeshing: mesh adaptation strategies [?, ?, ?] and parametrization techniques [?, ?, ?, ?, ?, ?]. Mesh adaptation strategies
use local mesh modifications in order both to improve the quality of the input surface mesh
and to adapt the mesh to a given mesh size criterion. In parametrization techniques, the
input mesh serves as a support for building a continuous parametrization of the surface.
(In the case of CAD geometries, the initial mesh can be created using any off the shelf
surface mesher for meshing the individual patches.) Surface parametrization techniques
originate mainly from the computer graphics community: they have been used extensively
for applying textures onto surfaces [?, ?] and have become a very useful and efficient tool
for many mesh processing applications [?, ?, ?, ?, ?]. In the context of remeshing procedures, the initial surface is parametrized onto a surface in R2 , the surface is meshed
using any standard planar mesh generation procedure and the new triangulation is then
mapped back to the original surface [?, ?].
The existing methods for discrete parametrization can be classified as follows: linear,
4.1. PARAMETRIZATION OF TRIANGULATED SURFACES
109
non-linear and hybrid methods. Non-linear methods based on discrete or differentialgeometric non-linear distortion measure [?, ?, ?] offer strong guarantees on the absence of
triangle folding and flipping at the cost of a generally higher computational effort. Some
authors have also suggested hybrid techniques that linearize those non-linear measures at
the cost of only a few linear solvers [?, ?]. Linear methods require only the resolution of
a single linear system. Most methods require to map the vertex of the patch boundary to
a given polygon (usually convex ) in the parametric plane. This is for example the case of
the discrete harmonic map introduced by Eck [?] or the more robust convex combination
map of Floater [?] Some authors suggested also extension to free boundaries by pinning
down only two vertices. This is the case for example in the least square conformal maps
(LSCM) introduced by levy et al. [?] and the discrete conformal parametrizations (DCP)
of Desbrun et al. [?]. These mapping could achieve lower angle distortion than previous
results. However, as the quality of the parametrization can depend signification the choice
of the constraint vertices, Mullen et al. [?] suggested to spread the constraints throughout
the mesh by constraining that the barycenter of the mapping must be at (0, 0) and that
the moment of inertia of the boundary must be unit. In [?], those spread constraints are
taken into account through recourse to spectral theory.
4.1
Parametrization of triangulated surfaces
We consider that the only available representation of a surface S is a conforming triangulated mesh ST in 3D , i.e. the set of K triangles Tj that intersect only at N common
vertices pi and E common edges eij :
M = ST = {T1 , ..., TK }.
The discrete parametrization aims at computing the discrete mapping u(x) that
maps every triangle of the three dimensional surface S to another triangle of S 0 that has
a well known parametrization.
(4.1)
x ∈ ST ⊂ R3 7→ u(x) ∈ ST0 ⊂ R2
Such a parametrization exists if the two surfaces ST and ST 0 have the same topology, that
is have the same genus G and the same number of boundaries NB 1 . As we have seen, the
genus of a triangulated surface G(ST ) can be computed from the Euler-Poincaré formula
(Eqs. (3.1) and (3.2)):
−N + E − K + 2 − NB
.
2
where N, E, K are respectively the number of vertices, edges and triangles of the triangulation ST .
(4.2)
G(ST ) =
For example, let us consider Figure 4.3 that shows the triangulated Tutankhamun
mask. This triangulated surface is diffeomorphic to the unit disk i.e. it is possible to
1
For example, a sphere has a genus G = 0 and NB = 0, a disk has G = 0 but NB = 1 and a torus has
G = 1 and NB = 0
110
CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION
ST0
ST
u(x)
x(u)
y
v
R3
R2
u
x
z
Figure 4.3: Discrete parametrization of the Tutankhamun mask.
find a transformation u(x) that maps S onto S 0 = {u : |u| ≤ 1}. Each vertex pi has its
coordinates xi on ST and ui on ST 0 . Consider for example one triangle Tj composed of
three vertices p1 , p2 and p3 . This triangle can itself be parametrized using standard linear
shape functions (see Figure 4.4):
x(ξ) = (1 − ξ − η)x1 + ξx2 + ηx3 .
(4.3)
Similarly, we can also parametrize the triangle in S 0 :
u(ξ) = (1 − ξ − η)u1 + ξu2 + ηu3 .
(4.4)
The mapping that is interesting to us is x(u) (see Figure 4.4).
It is easy to compute (ξ, η) as a function of u using
u2 − u1 u3 − u1
ξ
u − u1 =
v2 − v1 v3 − v1
η
|
{z
} | {z }
u,ξ
ξ
which gives
ξ(u) = (u,ξ )−1 (u − u1 ) = (ξ,u ) (u − u1 ).
(4.5)
and therefore
x(u) = x(ξ(u)).
The derivatives of the mapping x(u)

x,u = x,ξ ξ,u
x2 − x1

= y2 − y1
z2 − z1
v3 − v1
−(u3 − u1 )
x3 − x1
−(v2 − v1 )
u2 − u1
y3 − y1 
(u2 − u1 )(v3 − v1 ) − (v2 − v1 )(u3 − u1 )
z 3 − z1

4.1. PARAMETRIZATION OF TRIANGULATED SURFACES
Tj ∈ ST
111
u3
x2
x(u)
Tj ∈ ST0
x3
u2
η
x(ξ)
x1
ξ(u)
u1
ξ
Figure 4.4: Unit triangle in local coordinates and the mappings u(x), x(ξ) and u(ξ).
allow to compute the metric tensor Mu = (x,u )T x,u of the mapping u(x) on the surface
ST .
The curvature tensor is indeed more complicated to compute for such a piecewise
linear mapping. The usual way of computing the curvature is to use a normal smoothing
procedure that is similar to the one used in the Gouraud shading technique. The basic
principle behind the method is as follows: An estimate to the surface normal of each
vertex in a 3D model is found by averaging the surface normals of triangles which meet
at each vertex. Consider again triangle Tj of Figure 4.4. The Gouraud normal smoothing
procedure allows to obtain three normal vectors n1 , n2 and n3 at the three vertices. We
assume that the unit normal vector n(x) can be computed using linear shape functions
n(ξ) =
(1 − ξ − η)n1 + ξn2 + ηn3
.
|(1 − ξ − η)n1 + ξn2 + ηn3 |
A last issue related to discrete parametrizations is the way to compute efficiently x(u)
(see Fig.4.4). This operation requires two steps. First, one has to find the triangle in the
parametric plane that contains u. This can be done efficiently using the octree technique
described in §??. Then, it is possible to compute the mapping ξ(u) using (4.5) and next
to compute the mapping x(ξ), i.e. interpolating the x coordinates using linear shape
functions.
We will now explain how to compute efficiently different types of discrete mappings
by restricting ourselves to the parametrization of non-closed triangulated surfaces, i.e
surfaces that are homeomorphic to a unit disk. Surfaces that are not of this kind will be
dealt with later on.
112
4.2
CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION
Computing discrete harmonic and conformal maps
The first type of mapping we will consider is the harmonic mapping since it is the easiest
mapping to compute approximately. This type of mapping minimizes the Dirichlet enery
(see Eq. (2.22)):
Z
Z
1
1
2
(4.6)
ED (u) =
k∇uk ds =
(∇u)2 + (∇v)2 ds.
2 ST
2 ST
The strong formulation corresponding to this minimization problem is given by:
∇2 u = 0,
(4.7)
∇2 v = 0
on ST
with appropriate Dirichlet and Neumann boundary conditions on the NB boundaries of
SD , denoted ∂ST i , i = 1, ..., NB :
(4.8)
u = uD (x),
on ∂ST 1 ,
∂u
= 0,
∂n
on (∂ST − ∂ST 1 ).
This means that if one can compute numerically the solution to those two PDE equations
(4.7), the solutions u(x) a and v(u) define the discrete harmonic mapping u(x).
The second type of mapping to be considered is the conformal mapping that mimimizes the least square conformal energy (see Eqs.(2.24) and (2.25)):
Z
1
ELSCM (u) =
k∇u⊥ − ∇vk2 ds
2
ZST 1
(4.9)
=
(∇u)2 + (∇v)2 − n · (∇u × ∇v) ds.
ST 2
= ED (u) − A(u),
where A(u) is the area functional defined in (2.19).
One efficient way to compute numerically those two quadratic minimization problems is to use finite elements. We denote by the functional J either the Derichlet energy
ED (u) or the least-square conformal energy ELSCM (u) to be minimized. The minimization
problem reads as follows: find u∗ such that
(4.10)
∂u
u∗ = arg min J(u), with U(S) = {u ∈ H 1 (S), u = uD (x), or
= 0 on ∂ST i }.
∂n
u∈U(S)
In what follows, we will first derive the finite element formulation for the conformal map
(J = ELSCM ). We assume the following finite expansions for u:
X
X
(4.11)
uh (x) =
ui φi (x) +
uD (xi )φi (x)
i∈I
i∈J
where I denotes the set of i = 1, ..., N nodes of ST that do not belong to the Dirichlet
boundary, J denotes the set of nodes of ST that belong to the Dirichlet boundary (see Fig.
4.2. COMPUTING DISCRETE HARMONIC AND CONFORMAL MAPS
113
nodes of I
nodes of J
Figure 4.5: Sets of I = 12 nodes defined in the first order FE expansion for a triangular
surface mesh ST made of K = 13 triangles and N = 12 vertices.
4.5 for an example for linear finite elements) and the φi ’s are the nodal shape functions
associated to the nodes of the mesh. We assume here that nodal shape function φi is equal
to 1 on vertex xi and 0 on any other vertex: φi (xj ) = δij .
Thanks to the finite element expansion (4.11), functional J defining for example the
least square conformal energy Eq. (4.9) can be rewritten as:
(4.12)
Z
Z
XX
1 XX
ui uj
∇φi · ∇φj ds +
ui uD (xj )
∇φi · ∇φj ds+
2
S
S
T
T
i∈I j∈I
i∈I j∈J
Z
Z
XX
1 XX
vi vj
∇φi · ∇φj ds +
vi vD (xj )
∇φi · ∇φj ds+
2
ST
ST
i∈I j∈I
i∈I j∈J
Z
Z
XX
XX
uD (xi )uD (xj )
∇φi · ∇φj ds +
vD (xi )vD (xj )
∇φi · ∇φj ds−
J(u1 , . . . , uI ) =
ST
i∈I j∈J
XX
i∈I j∈J
XX
i∈I j∈J
Z
n · (∇φi × ∇φj ) ds −
ui vj
ST
XX
Z
n · (∇φi × ∇φj ) ds −
ST
n · (∇φi × ∇φj ) ds−
uD (xi )vj
i∈I j∈J
Z
ui vD (xi )
ST
i∈I j∈J
XX
i∈I j∈J
ST
Z
n · (∇φi × ∇φj ) ds.
uD (xi )vD (xi )
ST
In order to minimize this functional J, we can simply cancel the derivative of J with
114
CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION
respect to uk (the same derivation can be done with respect to vk ):
Z
X Z
X
∂J
=
uj
∇φk · ∇φj ds +
uD (xj )
∇φk · ∇φj ds −
∂uk
ST
ST
j∈I
j∈J
|
{z
}
{z
}
|
Akj
(4.13)
X
Akj
Z
vj
ST
j∈I
|
X
Z
vD (xj )
n · (∇φk × ∇φj ) ds
n · (∇φk × ∇φj ) ds −
ST
j∈I
{z
}
|
{z
}
Ckj
Ckj
= 0 , ∀k ∈ I.
In this equations the elementary matrixes Akj of triangle Ti can be computed as follows:
Z 1 Z 1−ξ
Z
p
Tk
ξ,η
∇ξ,η φk M−1
∇φk · ∇φj ds =
(4.14)
Akj =
ξ ∇ φj det Mξ dξdη,
0
Ti
0
where Mξ is the metric tensor of the mapping x(ξ) (see Fig.4.4 and Eq.(4.3)).
The combination of the equations (4.13) for the uk and vk derivatives gives us a
linear system of 2I equations that can be written as follows:
0
A
−C
U
,
=
(4.15)
0
−CT
A
V
|
{z
}
LC
where A is a symmetric positive definite matrix and C is an antisymmetric matrix that
are both build by assembling the elementary matrices Akj and Ckj , and the vectors U
and V denote respectively the vector of unknowns uk and vk . The resulting matrix LC is
then symmetrix definite positive such that the linear system LC U = 0 can be efficiently
solved using a direct sparse symmetric-positive-definite solver such as TAUCS. The linear
system of equations is then the discrete version of the minimization problem (4.10) that
can now be rewritten as:
1
(4.16)
U∗ = arg min UT LC U
2
U
As the Dirichlet energy is related to the least square conformal energy, the linear
system resulting from the finite element formulation for the harmonic map can be derived
from Eq. (4.15), by vanishing the off-diagonal matrixes of LC :
A 0
U
0
(4.17)
=
,
0 A
V
0
|
{z
}
LD
which makes the system of equations uncoupled: AU = 0, AV = 0. This finite element
harmonic map can be is quite similar to the discrete harmonic map introduced first by
Eck et al. [?]
ENFORCING INSENSITIVITY TO SAMPLING IIREGULARITY ... SEE MULLEN
2008 AND ALSO benchmark/geo/spherehalf.geo
4.3. BOUNDARY CONDITIONS FOR DISCRETE MAPS
4.3
115
Boundary conditions for discrete maps
It is necessary to impose appropriate boundary conditions to guarantee that the discrete
minimization problem has a unique solution and that this unique solution defines a oneto-one mapping (and hence avoids the degenerate solution u =constant).
We first consider the Dirichlet boundary conditions that are often used for the
Laplacian harmonic map:
(4.18)
u = uD (x)
on ∂ST i .
This boundary condition allows to map one of the boundaries of ST (∂ST 1 ) to a fixed
boundary in the parametric space (a circle, a square, an ellipse, the projection of ∂S
on its mean plane etc.). The fixed boundaries that are considered are convex polygons
since the continuous harmonic map is proven to be one-to-one if the mapped surface S 0
is convex. This result is called the Radò-Kneser-Choquet (RKC) theorem [?, ?] and it
strongly depends on the fact that the solution of the Laplace equation obeys a strong
maximum principle: u(x) attains its maximum on the boundary ∂S of the domain. This
means that there exists only one single iso-curve u = u0 in S and that this iso-curve goes
continuously from one point of the boundary to another. If another iso-curve u = u0
existed, it should be closed inside S, violating the maximum principle. This is also true
for the iso-curve v = v0 . Consider the surface S of Figure 4.6a with one single boundary
(NB = 1) that is mapped to a unit circle with appropriate Dirichlet boundary conditions.
Surface S 0 is convex so that any vertical line u = u0 intersects ∂S 0 at most two times.
This is also true for any horizontal line v = v0 . This means that any coordinate u = u0
(u0 ∈] − 1, 1[) appears also exactly two times on the boundary ∂S. The two points of
∂S for which u = u0 are designated as VA and VB while the two points for which v = v0
are designated as VC and VD . Note that those points appear interleaved while running
through ∂S (VA appears either after VD or after VC but never after VB ). This means that
there exists one point in S for which u = u0 and v = v0 .
S
S0
VC
VB
u = u0
u(x)
v = v0
∂S
VA
VD
v = v0
u = u0
∂S 0
Figure 4.6: Iso-values of coordinates u and v on a surface S for which the mapping u(x)
is computed as the solutions of the Laplace equation with Dirichlet boundary conditions
that map ∂S on the unit circle ∂S 0 .
116
CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION
Figure 4.7 illustrates the Dirichlet boundary conditions that map the boundary of the
triangulation of the Toutankhamon mask ∂ST 1 to a unit circle. This boundary condition
can be implemented by choosing arbitrarily a starting vertex Ms0 on the boundary ∂ST 1 .
Then, the curvilinear abscissa li of point Mi0 = xi along the curve can computed for
all vertices along the curve of total length L. The mapping of the boundary nodes (the
position (ui , vi )) of Mi0 in can then be written as:
2πli (xi )
2πli (xi )
, vD (xi ) = sin
.
(4.19)
uD (xi ) = cos
L
L
Figure 4.7: Dirichlet boundary conditions: mapping the boundary of the Toutankhamon
mask ∂ST 1 to a unit circle.
Instead of fixing all the boundary nodes ∂S1 to a convex polygon, one might fix two
(u, v) coordinates, thus pinning down two vertices in the parameter plane with Dirichlet
boundary conditions. Indeed, for least square conformal maps, the mapping (4.15) has full
rank only when the number of pinned vertices is greater or equal to 2 [?]. Pinning down
two vertices will set the translation, rotation and scale of the solution when solving the
linear system LC U = 0 and will lead to what is called a free-boundary parametrization.
It was independendty found by the authors of the LSCM [?] and the DCP [?] that picking
two boundary vertices the farthest from each other seems to give good results in general.
However, the quality of the conformal parametrization depend drastically on the choice of
these constraint vertices. Indeed, global distortion can ensue and a degradation of conformality can be observed around the pinned vertices. Figure 4.8 compares a LSCM with
two pinned vertices with a less distorted LSCM that spreads the constraints throughout
the mesh (we call this approach the constrained LSCM or CLSCM)
How can we define a less distorted least square conformal map (CLSCM) without
pinning down two vertices ? The idea is to add the two following constraints to the minimization problem that that set the translation, rotation and scale of the solution: (i) the
barycenter of the solution must be at zero and (ii) the moment of inertia of the boundary
∂ST 1 must be unit. Those constraints can be taken into account through recourse to
spectral theory. This idea was derived also by Mullen et al. [?] and named after spectral
conformal parametrization. In what follows, we try to present the spectral conformal
map in a more comprehensive manner than the way it is presented in [?].
The constrained least square conformal map corresponds to the following discrete
constrained minimization problem. Find U∗ such that
(4.20)
1
U∗ = arg min UT LC U,
2
U
subject to UT E = 0, UT BU = 1.
The first constraint in (4.20) UT E = 0 states that the barycenter of the solution must be
at zero. Indeed, as E denotes the 2I × 2 matrix that is such that Ei1 = 1, i = 1, ..., I and
4.3. BOUNDARY CONDITIONS FOR DISCRETE MAPS
a)
b)
117
c)
Figure 4.8: Initial triangulation ST of a boudda statue a) that has been parametrized by
computing b) the LSCM with two constrained vertices shown in red c) the constrained
LSCM solved with a spectral method.
Ei2 = 1, i = I + 1, ..., 2I (the other entries of E being zero):

1
 ..
 .

 1
E=
 0

 ..
 .
0

0
.. 
. 

0 
,
1 

.. 
. 
1
P
P
UT E = 0 is equivalent to Ii=0 U = 0 and Ii=0 V = 0. In in (4.20), the second constraint
UT BU = 1 indicates that the moment of inertia of the boundary must be unit, the B
matrix being a 2I × 2I diagonal matrix with 1 at each diagonal element corresponding
to boundary vertices and 0 everywhere else. There are two different ways to solve this
constrained minimization problem. The first method tries to find the optimum of the
following Lagrangian function L (U, µ) with Lagrange multipliers µi ≥ 0:
(4.21)
1
L (U, λµ) = UT LC U − µ(UT E) − λ(UT BU − 1).
2
The second method is based on spectral theory that shows that the solution of the constrained minimization problem Eq. (4.20) is the generalized eigenvector U∗ associated to
the smallest non-zero eigenvalue of the matrix LC , i.e the vector satisfying
(4.22)
LC U = λBU,
where λ is the smallest non-zero eigenvalue of LC . This generalized eigenvector U∗ is
called the Fiedler vector of LC . We now show that optimizing (4.21) is equivalent to
finding the Fiedler vector U∗ (4.22). Indeed, for the discrete optimization problem, the
118
CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION
solution must satisfy:
(4.23)
(4.24)
(4.25)
∂L
∂U
∂L
∂µ
∂L
∂λ
= 0 ⇐⇒ LC U − µE − λBU = 0
= 0 ⇐⇒ UT E = 0
= 0 ⇐⇒ UT BU = 1
That is, (LC − λB) U = µE . Premultiplying Eq.4.23 by ET gives:
(4.26)
ET LC U − λET BU = µET E = µD,
where D is a 2 × 2 diagonal matrix with value I at both diagonal entries. But we have
that ET BU = 0 (combination of the two constraints (4.24) and (4.25)) and also that
ET LC = 0 (because the matrix LC is a block matrix
Laplacian matrixes A
P composed of P
and antisymmetric matrices C that are such that j Akj = 0 and j Ckj = 0). Thus we
have µ = 0 and hence,
(4.27)
(LC − λB) U = 0,
with U being the generalized eigenvector of the eigenvalue problem (4.22). The matrix LC
is positive semi-definite with smallest eigenvalue λ1 = 0 and corresponding eigenvector E
being the kernel vector (since we have that LC E = 0). Clearly E is not a solution to the
problem since it does not satisfy the constraint that the barycenter of the solution must
be at zero. Since the LC matrix is positive definite positive, then it can be shown that the
next smallest eigenvalue λ2 is positive. The eigenvector associated with this eigenvalue
(also called Fiedler vector) satisfies the constraint UT E = 0 because it is orthogonal to
the first eigenvector E. It also satisfies the constraint UT BU = 1 by proper scaling, and
thus is the solution of the constrained minimization problem (4.20).
From a numerical point of view, there exists very efficient eigensolvers that find the
Fiedler vector U∗ of the sparse generalized eigenvalue problem we need to solve (4.22).
Those methods usually proceed through Choleski decomposition (to turn the problem
into a conventional eigenvalue problem) and Lanczos iterations, particulary fast in our
case since we deal with sparse matrices. Softwares libraries such as Slepc [?] or Arpack [?]
provide all those methods for solving efficiently the generalized eigenproblem. It is however interesting to transform the minimization problem (finding the Fiedler vector that
corresponds to the smallest eigenvalue λ) (4.22) into a maximisation problem (finding the
vector corresponding to the largest eigenvalue λ̃ = 1/λ of the eigenvalue problem (4.22)
in which the left and right hand side have been switched):
(4.28)
BU = λ̃LC U,
since this transformation makes the eigen solver more robust. As in Mullen et al. [?], we
also found that robustness to large triangulations with extremely degenerated triangles
could be improved by adding Id (with Id being the identity matrix) to LC in order to
4.3. BOUNDARY CONDITIONS FOR DISCRETE MAPS
119
ensure that numerical inaccuracies in the coefficients of the conformal matrix LC will not
alter the positive semi-definiteness of the matrix (we have used = 1.e−8 ). Finally, a last
interesting transformation consists in removing the kernel of LC through the following
modified generalized eigenvalue problem:
(4.29)
(B − Be ) U = λ̃LC U,
with Be =
1
(BEET BT ).
IB
The vector U∗ we are looking for is the eigenvector corresponding to the largest eigenvalue
λ̃. In (4.29), IB is the number of boundary nodes and the Be matrix is now a non-diagonal
matrix with value 1 for every matrix entry (i, j) and (i + I, j + I) (where i and j are the
indexes of the IB boundary nodes) and value 0 for all other entries. As this matrix Be
reduces the sparsity of the eigenvalue problem, we suggest to compute it with a reduced
boundary matrix B̃ that takes into account a limited number of nodes on the boundary
max that are distributed uniformly along the boundary (usually we take I max = 50). To
IB
B
illustrate this, consider the very simple triangulation ST on Fig.4.9 with N = 5 nodes and
IB = 4 boundary nodes. For this triangulation in Fig.4.9, the matrices Be and B̃e (with
1
2
3
4
5
Figure 4.9: Simple triangulation ST with 3 triangles, N = 5 vertices (I = 5 finite element
nodes for linear finite elements) and IB = 4 boundary nodes.
max = 2 = {1, 5}) are given by:
IB

1
Be =
4
L
0
0
L
,


with L = 



1
B̃e =
2
L̃
0
0
L̃
,


with L̃ = 


1
1
0
1
1
1
1
0
1
1
0
0
0
0
0
1
1
0
1
1
1
1
0
1
1

1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1











So far, we have discussed Dirichlet boundary conditions and have introduced constrained LSCM in order to avoid to pin down two vertices for the LSCM. Another type of
120
CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION
boundary conditions to be considered are natural boundaries, also called zero Neumann
boundary conditions:
∂u
= 0,
∂n
(4.30)
on ∂ST i
From an implementation point of view, those boundaries conditions correspond to a ”do
noting BC” since the Neumann boundary condition is already taken into account in the
minimization problem (4.10). Consider for example a surface ST that has two boundaries denoted ∂ST 1 and ∂ST 2 (see Fig.4.10a)). Suppose now, we compute the discrete
ST B
∂ST 2
∂ST 1
a)
ST A
b)
Figure 4.10: Triangulation ST A with two holes on which a discrete harmonic map u(x)
is computed as solutions of the Laplace equations α∇2 u = 0, α∇2 v = 0 with boundary
conditions that map ∂ST 1 on the unit circle. The bottom a) figure shows the iso-u and
iso-v values for the mapping (α = 1) of the surface ST that excludes the interior disk and
for which zero Neumann boundary conditions are applied on ∂ST 2 . The bottom c) figure
shows the iso-u and iso-v values for the mapping of ST that also includes the interior disk,
and for which α = 1 inside ST A and α = 1.e−8 (small value) inside ST B .
Laplacian map by solving (4.17) with Dirichlet boundary conditions (4.19) on ∂ST 1 and
zero Neumann boundary conditions on ∂ST 2 . The iso-u and iso-v values of this mapping are shown in Fig. 4.10b). Figures 4.10a) and b) show that imposing Neumann
boundary conditions on ∂ST 1 is equivalent to the resolution of a Laplace problem on the
whole domain ST = ST A + ST B while defining a small diffusivity constant α (solving
α∇2 u = 0, α∇2 v = 0) inside the hole ST B (Figure 4.6b). This means that this problem
also obeys the same maximum principle as the one with constant diffusivity, which means
4.4. ISSUES WITH DISCRETE LINEAR MAPPINGS
121
that the mapping remains one-to-one even when considering holes in the domain. However, as can be seen clearly in Fig.4.10 the conformality is deteriorated near the Neumann
boundary ∂ST (compare Figs. 4.10a with Fig. 4.6 that shows the Laplacian mapping for
the whole surface ST with a constant diffusivity parameter α = 1). That is the reason for
which it might be desirable for surfaces ST that have several interior boundaries ∂ST i to
mesh the surface ST B bounded by those boundaries and to compute the mapping
P for extended surface S˜T that includes those newly defined mesh surfaces [?] S˜T = ST ∪ i ST Bi .
4.4
Issues with discrete linear mappings
A very important aspect when computing the parametrization is to obtain bijective (oneto-one) maps, where each point of the parametric domain corresponds to exactly one
point of the mesh. One can make a difference between global bijectivity and local bijectivity. The latter requires only that the maps of any sufficiently small region of the
mesh is bijective. If the discrete convex combination map is guaranteed to be bijective, non-bijective parametrizations might occur when computing the discrete harmonic
or conformal map as the solution of linear systems. Figure 4.11 shows two examples of
non-bijective parametrizations. The top figure shows a discrete harmonic map for which
the local bijectivity condition is violated. Indeed, the mapping of adjacent mesh triangles
intersect and the parametrization contains triangle flips. The bottom figure 4.11 shows a
parametrization with a global domain overlap (global bijectivity violated). A well as the
issues of bijectively, there exists an additional important numerical issue that concerns
all type of mappings and that rarely mentionned in the litterature. This issue exists for
triangulations with large geometrical aspect ratio for which the mapping often contains
clustered triangles with numerically undistinguisable node coordinates. We now discuss
those three different issues and present different algorithms to get rid of those issues and
to guarantee bijectivity.
The first issue concerns triangle flipping and is illustrated on the top of Fig.4.11.
In this figure, looking at the triangles normals in the parametric space, one can see that
one triangle have been reversed (the normal of the face is flipped). Indeed, in contrast to
the continuous harmonic map, it was shown in [?, ?] that the discrete harmonic map is not
always one-to-one. To illustrate this, the next example introduced by Floater [?] shows
that the discrete harmonic map is not guaranteed to be one-to-one. Consider a coarse
triangulation (Figure 4.12) made of three triangles ST = {(1, 2, 3), (1, 3, 4), (1, 4, 2)} and
let x1 = (r, 0, 1) for some real value r > 0 and x2 = (1, 1, 0), x3 = (0, 0, 0), x4 = (1, −1, 0).
The three boundary vertices x1 , x2 and x3 are mapped onto the boundary of the unit disk
(Figures 4.12b and c) and the vertex x1 should be mapped inside the triangle (u2 , u3 , u4 ) to
ensure a one-to-one mapping. However, numerical methods for solving Laplace equation
may not provide solutions that obey to a discrete maximum principle, especially when
meshes are distorted [?]—which can lead to discrete harmonic maps which are not one-toone (Figure 4.12c). One possible way to enforce the discrete harmonic to be one-to-one [?]
is to implement a local cavity check algorithm that locally modifies mesh cavities in which
122
CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION
v
uharm (x)
u
v
uconf (x)
u
Figure 4.11: Non-bijective parametrizations might occur when computing the discrete
harmonic or conformal map as the solution of linear systems: (top) a parametrization
which contains triangle flips and (bottom) a parametrization with a global overlap of
triangles.
a)
b)
c)
Figure 4.12: a) Triangulation for which the discrete harmonic mapping is not guaranteed
to be one-to-one: x1 = (r, 0, 1) for r > 0 and x2 = (1, 1, 0), x3 = (0, 0, 0), x4 = (1, −1, 0).
b) Case r = 1.5: the mapping is one-to-one , c) Case r = 3.5 : the mapping is not
one-to-one. The point u1 does not even lie within the unit disk.
flipping occurs. This algorithm goes as follows:
1. Compute harmonic map using finite elements;
2. For every interior vertex Vi of the parameter plane, check if each of its neighboring
triangles (defining a cavity) is oriented properly2 ;
2
This is simply implemented by comparing normal orientations of the triangles in the parametric space
4.4. ISSUES WITH DISCRETE LINEAR MAPPINGS
123
3. If elements are reversed, move the vertex at the center of gravity of the kernel of the
polygon P surrounding the point (see Figure 4.13).
In order to find the kernel of a star-shaped polygon, different algorithms have been proposed in the literature[?, ?]. In this work, as the polygons have a small number of vertices
we have implemented a simple quadratic algorithm. It should be noted that the situation
presented in Fig. 4.13a) does occur very rarely and only occurs for very poor quality initial
stl files. The local cavity check algorithm enables most of the time to repair the triangle
v5
v5
v5
v5
T3
T2
v4
v4
v4
T3
T4
T4
T2
v1
T1
v1
v2
v3
T1
v2
v6
v3
a)
v1
v2
v3
b)
c)
Figure 4.13: Vertex v1 with four neighboring triangles T1 = (v1 , v2 , v3 ), T2 = (v1 , v3 , v4 ),
T3 = (v1 , v4 , v5 ), T4 = (v1 , v5 , v2 ) defining the polygon P = (v2 , v3 , v4 , v5 ). a) Triangle
T3 (in red) is not well oriented and overlaps the triangles T2 and T4 . b) The vertex v1
is moved and placed inside the kernel of the polygon P (yellow area), c) Now, all four
triangles become well oriented without overlapping and hence the discrete mapping is
guaranteed to be one-to-one for this cavity.
flips. However, in some cases of very low quality input meshes it might fail. In those cases
in which the algorithm fails, we suggest to switch to a guaranteed one-to-one mapping
introduced by Floater [?, ?, ?]: the convex combination map. One possible definition
of the convex combination maps is the barycentric mapping [?, ?] that asks every interior
vertex ui be the barycenter of its neighbors:
(4.31)
ui =
di
X
λk uj ,
k=1
di
X
λk = 1,
k=1
where di denotes the number of vertices that are neighbors to node i. The resulting system
of equations is also uncoupled as in (4.17):
(4.32)
DU = 0,
DV = 0,
the matrix D being now the assembly of the following elementary matrices Dkj for every
triangle Ti :


1
−0.5 −0.5
1
−0.5 
(4.33)
Dkj =  −0.5
−0.5 −0.5
1
One can easily see that by assembling for example the 4 elementary matrices of the 4
elements surrounding node v1 in Fig.4.13c, equation (4.31) is satisfied. This convex combination seems attractive from a mathematical point of view and is widely used in the
124
CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION
computer Graphics Community. However, in the context of surface remeshing is not used
as default mapping since the metric tensor associated with this mapping is much more
distorted than the one obtained with the harmonic mapping. This in turn impacts on the
quality of the the remeshing procedure. This is illustrated in Fig. 4.14 where an initially
low quality triangulation ST has been remeshed with a parametrization based both on the
convex combination map and Laplacian harmonic map.
a)
b)
c)
d)
Figure 4.14: Poor quality initial triangulation ST (a) that has been remeshed using a
harmonic map (top figures) and a convex combination map (bottom figures): b) mapping
of the initial mesh onto the unit disk ST 0 with iso-x and iso-v values in red, c) the determinant of the mesh metric tensor Mu that defines the area distorstion map and d) the
final mesh obtained using the 2D Delaunay algorithms.
The second issue is about overlapping of triangles. This issue might occur when
computing linear conformal maps with open boundaries. Indeed, a linear conformal algorithm cannot guarantee that triangles do not overlap. To remain efficient in the context
of surface remeshing, we use an idea similar to the one suggested by Sheffer et al. [?] that
checks the presence of edge folding. Edge foldings are detected by looping over the edges
of the boundary ∂ST 1 and by computing if there exists intersections between the edges
(see Fig. 4.15). The intersection of two edge segments (p1 , p2 ) and (p3 , p4 ) of parametric
equations:
pa = p1 + ta (p2 − p1 ), pb = p1 + tb (p4 − p3 ),
can be computed by solving for the point where pa = pb . This gives the following linear
system of equations:
x2 − x1 x3 − x4
ta
x3 − x1
(4.34)
=
.
y2 − y1 y3 − y4
tb
y3 − y1
4.5. AUTOMATIC REMESHING WITH PARAMETRIZATIONS
125
If ta ∈ [0, 1] and tb ∈ [0, 1], we are in the case of segment intersections. In the case of
p2
p4
p1
p3
Figure 4.15: Intersection boundary ∂ST 1 that is present in the case of triangle folding.
triangle folding, we suggest to switch to a harmonic mapping.
The last issue concerns indistinguishable coordinates. As shown in Fig.4.16
and explained in [?] the solution of the mapping becomes exponentially small for vertices
located away from ∂ST 1 . As a consequence, local coordinates u and v of those far away
vertices might numerically become indistinguishable. By deriving an analytical solution of
Laplacian harmonic maps for cylinders, we showed in [?] that the geometrical aspect ratio
of the surface η should be reasonable to be numerically able to distinguish the coordinates.
(4.35)
η=
H
< ηmax ,
D
where H is the maximal distance computed on the 3D mesh ST of a mesh vertex to
the boundary ∂ST 1 and D is the equivalent diameter of the boundary ∂ST 1 . As the
distance on the 3d mesh is not straightforward to compute, an upper and lower bound for
η is computed. The upper bound for η is computed by using the analytical expression for
cylinders: η = 2πA/L2∂S , where A is the area of the 3D surface mesh and L∂ST 1 is the arc
T1
length of the boundary ∂ST 1 . The lower bound is estimated by choosing for H the maximal
size of the oriented bounding box of the 3D surface mesh and for D the maximal size of
the oriented bounding box for the boundary curve ∂ST 1 . The oriented bounding boxes
are computed with the fast Oriented bounding box HYBBRID optimization algorithm
presented in [?] which combines the genetic and Nelder-Mead algorithms [?]. As we
showed in [?] that η = 4 corresponds to an area of mapped triangles of about ri2 = 10−10
(see Eq. (23) and Fig. 10c in [?]), we choose ηmax = 4 as upper limit for the geometrical
aspect ratio of the 3D surface mesh.
4.5
Automatic remeshing with parametrizations
In this chapter, we have put to the fore in the context of discrete harmonic mapping three
limitations, namely limitations on the genus G, the number of boundaries NB and the
126
CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION
ST
v
∂ST 2
H
u
harm
u
z
ST0
(x)
y
x
∂ST 1
D
Figure 4.16: Issue of numerically indistinguishable coordinates illustrated for a Laplacian
map of a cylindrical mesh. When the geometrical aspect ratio η = H/D becomes too large,
the vertices that are located far away from the boundary ∂ST 1 become exponentially close
to each other in the parametric space ST 0 .
geometrical aspect ratio η. Those three criteria can be summarized as follows:
(4.36)
i)
G = 0;
ii)
NB ≥ 1;
iii) η < ηmax .
In the next section, we will first consider a disk-like surface (G = 0, NB ≥ 1)
and present a novel max-cut partitioning algorithm for those family of surfaces. We will
then present an automatic approach for arbitrary genus surfaces that combines this novel
algorithm with a multilevel partitioning algorithm.
4.5.1
Multiscale Laplace partitioning method
WAIT FOR REVIEW PAPER GMSHREPARAM2
4.5.2
Automatic algorithm
WAIT FOR REVIEW PAPER GMSHREPARAM2
4.6
Quality remeshing with parametrizations
Figures 4.17 show the remeshing of a triangulation of a teeth of very low input quality
(see STL quality curves). The compare the quality of the remeshing procedure using
successively a Laplacian map, a conformal map and a convex combination map. The
4.6. QUALITY REMESHING WITH PARAMETRIZATIONS
127
quality of the isotropic meshes is evaluated by computing the aspect ratio of every mesh
triangle as follows [?]:
(4.37)
κ=α
inscribed radius
sin â sin b̂ sin ĉ
,
=4
circumscribed radius
sin â + sin b̂ + sin ĉ
â, b̂, ĉ being the three inner angles of the triangle. With this definition, the equilateral
triangle has κ = 1 and degenerated (zero surface) triangles have κ = 0. A can be seen
from Fig.4.17 the conformal parametrization gives rise to the highest quality mesh while
the worst is found to be the convex combination map. The Laplacian mapping has a
slightly lower quality that can be explained by a loss in conformality at the boundaries
that gives rise to a less smoother mesh metric.
0.25
STL mesh
Laplacian map
0.02 Conformal map
Convex map
0.015
Frequency
Frequency
0.025
0.01
0.1
0.05
0.005
0
STL mesh
Laplacian map
0.2 Conformal map
Convex map
0.15
0
0
0.1
0.2
0.3 0.4 0.5
Aspect ratio
0.6
0.7
0.8
0.8
0.9
Aspect ratio
1
Figure 4.17: Remeshing of an teeth. Top figures show the initial STL triangulation and
new mesh based on the conformal mapping and the bottom figures show the quality
histogram obtained when remeshing the stl file with different mappings.
128
CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION
Acknowledgements
The authors gratefully acknowledge Électricité de France (EDF) for their financial support.
We would also like to thank all persons that have contributed to the development, testing
and debugging of Gmsh. Among those, we especially thank David Colignon for being such
an indefatigable beta-tester.