You are on page 1of 128

An introduction to Geometrical Modelling and Mesh

Generation
The Gmsh Companion
Christophe Geuzaine Emilie Marchandise Jean-Francois Remacle
2
Contents
1 Introduction 7
1.1 The Design of Gmsh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.1.1 Fast and Light . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.1.2 User-friendly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2 Solid Models 13
2.1 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
2.2 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 . . . . . . . . . . . . . . . . . . 20
2.4.3 Non-manifold topologies . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.4.4 Internal representation of solid models in Gmsh . . . . . . . . . . . . 25
3
4 CONTENTS
2.5 Geometrical Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.5.1 Dierential Geometry of Curves . . . . . . . . . . . . . . . . . . . . 31
2.5.2 Dierential 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
2.6 Non-Uniform Rational b-Splines (NURBS) . . . . . . . . . . . . . . . . . . . 44
2.6.1 NURBS curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
2.6.2 NURBS surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2.7 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
2.8 Geodesics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3 Mesh Generation 57
3.1 Generalities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
3.1.1 The Euler-Poincare Formula . . . . . . . . . . . . . . . . . . . . . . . 58
3.1.2 Mesh generation procedure . . . . . . . . . . . . . . . . . . . . . . . 61
3.2 Mesh size eld and quality measures . . . . . . . . . . . . . . . . . . . . . . 63
3.2.1 Mesh size eld . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.2.2 Element quality measures . . . . . . . . . . . . . . . . . . . . . . . . 64
3.3 One Dimensional Meshing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
3.4 Delaunay and Vorono . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
3.4.1 The Vorono diagram . . . . . . . . . . . . . . . . . . . . . . . . . . 65
3.4.2 The Delaunay Triangulation . . . . . . . . . . . . . . . . . . . . . . . 68
3.4.3 Construction of Delaunay Triangulations . . . . . . . . . . . . . . . 75
3.5 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.5.1 Multiscale Laplace partitioning method . . . . . . . . . . . . . . . . 126
4.5.2 Automatic algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
4.6 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 nite element solvers [?], and then visualize and ex-
port the computational results with maximum exibility. 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 timesome 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 in-
terface (GUI) and its own scripting language.
The rst public release of Gmsh occurred in 1998. This version was Unix-only, dis-
tributed 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 Windows-
only 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 oper-
ating systems. In 2003 the full source code was released under the GNU General Public
License [?], and it was modied 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 users guide or a reference manualsee [?]
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 philosophybe 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 nite 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 documentedall features
contributing to a user-friendly experience.
In the following sections we describe the technical choices that we made to achieve
these sometimes conicting 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 Scientic 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 le), as well as the build timea 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 sacricing 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 modeeither from the command line or via the scripting language.
Achieving user-friendliness has been an important driving factor behind key tech-
nical 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 ocial Linux
distributions (most notably Debian [?]), and thus beneted 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 ne-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 o-screen
rendering [?].
Extensibility
We tried to ease the modication and addition of features by users and developers. Such
extensibility takes dierent forms for each of the four modules:
Geometry: the abstract, object-oriented geometry layer permits to write all the algo-
rithms 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 OpenCas-
cade [?]. Adding support for other engines like, e.g., Parasolid [?], can be done
simply by deriving four abstract classessee Section ??. At the scripting level users
can then transparently mix and match geometrical parts represented internally by
dierent CAD engines. For example, it is possible to extend an OpenCascade model
of an airplane with a terrain model dened 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 Sec-
tion ??), 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 ne-grained interactions are needed.
Post-processing: the post-processor can be extended with user-dened 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 in-
clude/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 le formats. Gmsh uses open or de facto standard formats
whenever possible, from standard bitmap graphics formats (JPEG, GIF, PNG) and vec-
tor 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 simu-
lations. In particular, we will adress the issues related to nite element mesh generation.
2.1 Principal characteristics of a solid modeling software
A solid modeling software may have some specic characteristics that enables to enhance
both its eciency and the productivity of the solid modeling process:
2.1.1 Feature-based modeling
Features are dened to be parametric shapes associated with attributes such as intrin-
sic 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, llets, chamfers,
bosses, and pockets to be associated with specic 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 dene 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 intelli-
gence into the design. The initial sketch of a two-dimensional prole 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 prole
is dened through assigning enough parameters to fully constrain it.
2.1.3 Parametric modeling
Parametric modeling means that parameters of the model may be modied 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 modied, all linked dimensions are updated according to specied
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 rst. 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
oating around without being attached to the feature. Consequently, careful thought and
planning of the base feature and initial additional features can have a signicant eect on
the ease of adding subsequent features and making modications.
2.1.5 Associative modeling
The associative character of solid modeling software causes modications 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 modication 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 briey 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 dened bounded closed orientable domains. All
basic primitives are dened 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 dierence can be dened. Basic primitives can be combined using boolean
operations. Three boolean operators are dened. Consider two primitives A and B.
1. The Union AB operation returns of all the points x R
3
that are either inside A
or inside B.
2. The Intersection A B operation returns of all the points x R
3
that are both
inside A and inside B.
3. The Dierence A B operation returns of all the points x R
3
that are inside A
and outside B.
Regularized boolean operators dier from the set-theoretic ones in that dangling
lower dimensional structures are eliminated, all remaining faces, edges and vertices be-
longing 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 nal 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 intersec-
tions is a complex problem. A few number of softwares enable to perform CSG computa-
tions eciently 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

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 Dierence 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 AB
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 dened 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 classication. Point/solid classication can be
done walking rst 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 classication.
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 topo-
logical invariants. On its own, topology denes a rubber model, whose position is not
xed in space. For example, a sphere and a cube are topologically equivalent, but not
geometrically.
A topological entitys shape, position, and orientation are xed in space when it is
associated with a geometric entity. This is the geometrical part of the boundary represen-
tation.
2.4 Topological Representation
Any solid can be represented unambiguously by describing its surface and topologically
orienting it so that, for any point x R
3
, 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 solid
models on a computer. In what follows, we will present the classical winged-edge data
structure. Then, well present a more sophisticated version that allow to represent non-
manifold models. Then, well present the way Gmsh stores the topology of models, with
the aim of using that information for mesh generation.
2.4.1 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 dene a list of vertices and
a list of faces storing pointers for its vertices. This representation is both convenient
and ecient for many purposes, however it proves ineective for dynamically modifying
meshes.
The winged-edge data structure has been designed to allow eective local modi-
cation 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 rst
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 dierent topologies generated through a
small variation of the geometry.
like splitting, collapsing or ipping 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 R
3
is a 2-manifold if every point x has a neighborhood that can be mapped
continuously into an open set of R
2
.
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 R
3
.
The resulting gure is non-manifold. Indeed, even if the result of those two boolean
operations is one only solid, it is impossible to dene a proper genus to the surface that
2.4. TOPOLOGICAL REPRESENTATION 21
bounds this solid. Slightly dierent 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 Weilers 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 Gmshs abstract topological data
structure. The dierent 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 eciency.
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 denes 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 innitesimally 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 23
G
1
1
G
2
1
G
1
2
G
1
4
G
1
3
G
0
3
G
0
2
G
0
4
G
0
5
G
0
1
G
1
5
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 curves 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 G
1
1
s boundary, G
1
1
consist in two signed vertices:
G
1
1
= G
0
2
+G
0
3
which means that model edge G
1
1
goes from model vertex G
0
2
to model vertex G
0
3
.
24 CHAPTER 2. SOLID MODELS
Model face G
2
1
s boundary consist in two closed edge loops that consist of respectively
four and one signed model edges:
(2.1) G
2
1
= G
1
1
+G
1
4
+G
1
3
G
1
2
, G
5
1
.
Model edge G
1
5
is periodic:
G
5
1
= G
0
5
G
0
5
= 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,
G
2
1
= G
1
1
+G
1
2
+G
1
3
G
1
4
, G
5
1

= (G
0
3
G
2
0
) + (G
0
4
G
2
3
) + (G
0
4
G
2
1
) (G
0
1
G
2
2
), G
0
5
G
0
5

= 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, G
0
i
= i.e. the boundary of a model
vertex is zero. Then, changing the sign of the boundary representation of a model face
(2.2) G
2
1
= G
1
1
+G
1
4
+G
1
3
G
1
2
, G
5
1
.
gives the same topological model face, yet with a dierent sign i.e. a dierent 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 G
3
1
consist in one closed face loop
G
3
1
= G
2
1
+G
2
2
+G
2
3
+G
2
4
+G
2
5
+G
2
6
+G
2
7
+G
2
8

with model face orientations that have to verify


G
3
1
= 0.
Let us now consider the cylindrical rod of Figure 2.7. The model region G
3
1
is
bounded by three model faces
G
3
1
= G
2
1
+G
2
2
+G
2
3
.
Model faces G
2
1
and G
2
2
are usual model faces composed of one only closed edge loop:
G
2
1
= G
1
1
and G
2
2
= G
1
3
.
Model face G
2
3
is dierent. 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, G
1
1
, has to be added
in the model. This seam edge acts like G
0
4
which is both the starting point and the ending
point of G
1
3
. We have then
G
2
3
= G
1
1
+G
1
3
G
1
1
G
1
2
.
2.4. TOPOLOGICAL REPRESENTATION 25
G
1
6
G
1
9
G
1
8
G
1
2
G
1
5
G
0
7
G
1
10
G
1
11
G
1
12
G
0
4
G
0
3
G
0
1
G
0
5
G
0
6
G
0
8
G
1
1
G
2
1
G
1
4
G
1
3
G
0
2
G
2
2
G
2
3
G
1
7
Figure 2.6: A cube.
The seam model edge G
1
1
appears twice in the same face loop and eectively 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 o, common in CAD
descriptions, make its meshing non-trivial:
1. o is periodic. The topology of the model face is modied in order to dene 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. o is trimmed: it contains four holes and one of them is crossed by the seam.
3. One of the model edges of o 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
G
0
4
G
0
5
G
1
1
G
1
2
G
2
1
G
2
2
G
2
3
G
1
3
Figure 2.7: A cylindrical rod.
One option for addressing this demand is to use exchange les, such as IGES (Initial
Graphics Exchange Specication), VRML (Virtual Reality Markup Language) or STEP
(STandard for the Exchange of Product model data). However, the use of such exchange
le formats has always been a cause of trouble in engineering design oces, mainly because
internal data structures of CAD systems are usually much richer than those in the exchange
formats.
Those dierences between modelers can be very subtle. Consider for example skin-
ning 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 dierence between them.
ACIS kernel does make a little dierence, in terms of types of the inputs parameters and
way of constraints denition. Even though dierences 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 les. Translations always lead to the time-consuming need to x most of
these exchange les before any meshing can be performed.
In Gmsh, we thus chose to deal with CAD engines dierently, by providing native
access to the underlying CAD modelswithout translation les (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 tol-
erance. 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`emes), Pro EngineerTM (Parametric Technology Corporation), NX (Siemens), Au-
toCAD or SolidWorks. Some smaller players exist such as Cobalt, MasterCAM, Top-
Solid, IronCAD or MicroStation that provide niche solutions. A lot of those soft-
ware 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 (Das-
sault Syst`emes). 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 CAS-
CADE is also the modelling kernel used in SAMCEF Field.
We have seen that 3-D models can be dened using a Boundary Representation. In
Gmsh, only four kinds of model entities are dened:
1. Model Vertices G
0
i
that are topological entities of dimension 0,
2. Model Edges G
1
i
that are topological entities of dimension 1,
3. Model Faces G
2
i
that are topological entities of dimension 2,
4. Model Regions G
3
i
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 represen-
tation, a model entity G
d
i
of dimension d holds one lists of upward adjacencies G
d+1
j
(G
d
i
),
i.e., all its adjacent entities of dimension d + 1, and one list of downward adjacencies of
dimension d 1, G
d1
j
(G
d
i
). Schematically, we have
G
0
i
G
1
i
G
2
i
G
3
i
.
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 G
d
i
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 R
d
p R
3
:
1. The geometry of a model vertex G
0
i
is simply its 3-D location x
i
= (x
i
, y
i
, z
i
).
2. The geometry of a model edge G
1
i
is its underlying curve (
i
with its parametrization
p(t) (
i
, t [t
1
, t
2
].
3. The geometry of a model face G
2
i
is its underlying surface o
i
with its parametrization
p(u, v) o
i
. Note that, for any curve (
j
that is on a surface o
i
, mesh generation
procedures require the ability to reparametrize any point p(t) (
j
on the surface
o
i
, 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 R
3
.
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 interfacedonly some of the interrogation functions are necessary. In order to get
the full functionality of Gmsh, only ve 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) ( 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
p(x)
p(u)
u = u(x)
v = v(x)
t
1
t t
2
z
y
x
x = x(t), y = y(t), z = z(t)
u = u(t), v = v(t)
S
v
u
S

C C
C
p(t)
Figure 2.9: Point p located on the curve ( that is itself embedded in a 2D surface o

(left)
or a 3D surface o (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 ( 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 ( 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 o 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 denition of mesh size elds. It is not a pure
virtual function: a default implementation is available using nite dierences.
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 G
d
i
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 !
d
x !
3
. The geometry of a model vertex G
0
i
is simply its 3-D location
x = (x
1
, x
2
, x
3
).
The geometry of a model edge G
1
i
is its underlying curve (
i
with its parametrization
(2.3) t [t
1
, t
2
] x(t) !
3
.
The geometry of a model face G
2
i
is its underlying surface o
i
with its parametrization
(u, v) !
2
x(u, v) !
3
.
The geometry associated to a model region is R
3
.
If a curve is included within a surface, it is usually drawn on the parameter plane
(u, v) of the surface:
(2.4) t [t
1
, t
2
] (u, v) !
2
x(u(t), v(t)) !
3
.
2.5.1 Dierential Geometry of Curves
A parameterization of a curve is a bijective mapping from a 1D domain to the 3D curve.
The mapping can be dened as follows:
(2.5) t !
1
x(t) !
3
.
Consider a segment of curve ( dened by a range of parameter t [t
a
, t
b
], t
a
t
1
, t
b
t
2
.
The length of that segment can be computed as
_
C
dl
with dl =
_
dx
2
1
+dx
2
2
+dx
2
3
. Using (s parametrization (2.3), we have
_
C
_
dx
2
1
+dx
2
2
+dx
2
3
=
_
t
b
ta
_
x
2
1,t
+x
2
2,t
+x
2
3,t
dt
=
_
t
b
ta
|x
,t
| dt
32 CHAPTER 2. SOLID MODELS
This can be easily extended to the computation of integral quantities over model edges:
_
C
f(x
1
, x
2
, x
3
)dl =
_
t
b
ta
f(x
1
(t), x
2
(t), x
3
(t)) |x
,t
| dt (2.6)
The curvilinear abscissa l(t) of a point x(t) of curve (, is the length of the segment
dened by parameter range [t
1
, t], i.e. the length of the curve from the origin x(t
1
) to x(t):
l(t) =
_
t
t
1
|x
,t
| dt (2.7)
We have seen before that dl = |x
,t
| dt.
A parametrization of ( is said to be regular if |x
,t
| , = 0. For regular parametriza-
tions, the unit tangent vector is dened as
t(t) =
x
,t
|x
,t
|
=
dx
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 dened as the
amplitude of the variations of the unit tangent t along the curve. The vector t
,l
is obviously
orthogonal to t because ts amplitude is one along l. Recalling that
d
dt
1
|x|
=
x
,t
x
|x|
3
we have
t
,l
=
1
|x
,t
|
t
,t
=
1
|x
,t
|
_
x
,tt
|x
,t
|
x
,t
x
,t
x
,tt
|x
,t
|
3
_
=
1
|x
,t
|
3
_
x
,tt
|x
,t
| x
,t
x
,t
x
,tt
|x
,t
|
_
.
Clearly, t
,l
t = 0. Because we have dened the curvature as the amplitude of the
variations of the unit tangent t along the curve, we call rewrite
t
,l
= |t
,l
|
t
,l
|t
,l
|
= Cn
with n a unit normal vector orthogonal to t and C the curvature that is the norm of t
l
.
Remembering that
|a b|
2
= |a|
2
|b|
2
sin
2
(a, b) = |a|
2
|b|
2
_
1
(a b)
2
|a|
2
|b|
2
_
= |a|
2
|b|
2
(a b)
2
,
2.5. GEOMETRICAL REPRESENTATION 33
t
x(t)
t(t)
n(t)
C
x
2
x
3
x
1
t
2
t
1
1/C
Figure 2.12: A curve ( dened by the mapping x(t).
it is easy to see that
C
2
=
1
|x
,t
|
6
_
|x
,t
|
2
|x
,tt
|
2
(x
,tt
x
,t
)
2
_
=
1
|x
,t
|
6
|x
t
x
,tt
|
2
and we get the formula
(2.8) C =
|x
t
x
,tt
|
|x
,t
|
3
.
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

(t) and x
,tt
= 0, f

(t).
We have therefore the classical formula
(2.9) C =
[f

(t)[
(1 +f

(t)
2
)
3/2
.
It is possible to dene 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 dened 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
S
x
2
x
1
x
3
S

x(u, v)
v
u

x
,v
x
,u
x
,u
x
,v
Figure 2.13: A surface o dened by the mapping x(u, v).
2.5.2 Dierential Geometry of Surfaces
A parameterization of a surface is a bijective mapping from a suitable two-dimensional
domain o

to the 3D surface o (see Figure 2.13). In CAD modelers, surfaces have ex-
plicit parametrizations i.e. their parametrization is given explicitly as a continuous and
dierentiable function:
(2.10) (u, v) o

!
2
x(u, v) o !
3
.
Such a parametrization exists if the two surfaces o and o

have the same topology, i.e are


both zero genus surfaces (G = 0) and have at least one boundary (N
B
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
o. It is easy to extend the integration formula (2.6) as:
_
C
f(x, y, z)
_
dx
2
+dy
2
+dz
2
=
_
C
f(x, y, z)
_
|x
,u
|
2
du
2
+ 2 x
,u
x
,v
du dv +|x
,v
|
2
dv
2
=
_
C
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
_
=
_
C
f(x, y, z)
_
du
T
M du. (2.11)
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 rst fundamental form. It is
dened as follows:
(2.12) M = x
T
,u
x
,u
=
_
x
,u
x
,u
x
,u
x
,v
x
,v
x
,u
x
,v
x
,v
_
=
_
E F
F G
_
The metric tensor is a symmetric denite 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 !. Let us consider two tangent vectors
t
1
= a
1
x
,u
+b
1
x
,v
and t
2
= a
2
x
,u
+b
2
x
,v
.
Coordinates a = (a
1
, a
2
) and b = (b
1
, b
2
) are called covariant coordinates of t
1
and t
2
.
We have
t
1
t
2
= a
1
a
2
x
,u
x
,u
+ (a
1
b
2
+a
2
b
1
)x
,u
x
,v
+b
1
b
2
x
,v
x
,v
= a
T
Mb,
which gives us the angle between the two tangent vectors (see Fig.2.13):
(2.13) = arccos
_
a
T
Mb
t
1
t
2
_
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 = |x
,u
du x
,v
dv| = 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 rst dene 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

det M
=
x
,u
x
,v

EGF
2
.
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
t
1
=
x
,u
|x
,u
|
, t
2
= n t
1
36 CHAPTER 2. SOLID MODELS
so that vectors (t
1
, t
2
, 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
specied 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:

u
v
|v|
=
v
,u
|v|

v
|v|
3
(v v
,u
)
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 deriva-
tives of the position vector x
n
,u
=
MF LG
EGF
2
x
,u
+
LF ME
EGF
2
x
,v
n
,v
=
NF MG
EGF
2
x
,u
+
MF NE
EGF
2
x
,v
where the scalars e, f and g are dened as:
L = n x
,uu
, M = n x
,uv
and N = n x
,vv
.
Those scalars dene the curvature tensor or second fundamental tensor of the surface
denoted M
2
:
(2.16) M
2
=
_
L M
M N
_
The curvature tensor is a tensor, and like for any tensor, some invariants can be dened
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 M
2
. 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) = n =
1
2
trace
_
M
2
M
_
=
LG2MF +NE
2 (EGF
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 M
2
det M
=
LN M2
EGF
2
.
2.5. GEOMETRICAL REPRESENTATION 37
2.5.3 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 pre-
served. 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:
x(u) is isometric M =
_
1 0
0 1
_

1
=
2
= 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. The following relation holds:
x(u) is conformal M =
_
0
0
_

1
/
2
= 1
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 iso-
metric 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 nd 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 CHAPTER 2. SOLID MODELS
2.5.4 Computing harmonic and conformal maps
One possible mapping can be found by minimizing the area functional /(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):
(2.19) /(x) =
_
S

| x
,u
x
,v
| dudv =
_
S

_
EGF
2
dudv,
where E, D and G are the coecients 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 E
D
(x):
(2.20) E
D
(x) =
1
2
_
S

|x|
2
dudv =
1
2
_
S

_
x
2
,u
+x
2
,v
_
dudv =
1
2
_
S

(E +G) dudv
The map that minimizes the Dirichlet energy is called a harmonic map since the varia-
tional 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:
(2.22)
2
u = 0 min
u
E
D
(u) = min
u
1
2
_
S
|u|
2
ds.
The area functional /(x) and the Dirichlet energy E
D
(x) have the following relation:
(2.23) /(x) =
_
S

_
EGF
2
dudv
_
S

EGdudv
1
2
_
S

(E +G)dudv = E
D
(x)
It is simple to verify that the rst 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 |x
,u
| = |x
,v
|. 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
the corresponding mesh metric is then given by : M =
_
E 0
0 E
_
. If we only x the
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 E
D
(u)?

2
u = 0 and
2
v = 0.
It actually all depends on the boundary conditions of those equations. If we x with
appropriate Dirichlet boundary conditions the map u(x) on the boundary o of the domain
o to a xed 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 x 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, xing 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 E
LSCM
as dened by Levy et al. [?]:
(2.24) E
LSCM
=
_
S
1
2
|u

v|
2
ds,
where

denotes a counterclockwise 90

rotation on o (on the plane dened by the two


vectors u = u
,x
and v = v
,x
) (see g.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 simplied and rewritten as follows:
n
u
v
iso-v
iso-u
S
u(x)
iso-u
iso-v
S

z
y
x
u

= n u
Figure 2.14: Denitions for a conformal mapping. u

denotes the counterclockwise 90

rotation of the gradient u for a 3D surface.


E
LSCM
(u) =
_
S
1
2
_
u

+v v 2u

v
_
ds,
=
_
S
1
2
_
(u)
2
+ (v)
2
2 (n u) v
_
ds.
(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 nally write the least square conformal energy as follows:
E
LSCM
(u) =
_
S
1
2
_
(u)
2
+ (v)
2
_
n (u v) ds. (2.26)
= E
D
(u) /(u).
It follows from (2.26) that the conformal energy is then simply dened as the dirichlet
functional E
D
(u) minus the area functional /(u).
Figure 2.15 shows two examples of mappings u(x) of a 3D surface o. The top gures
shows the harmonic map that is computed by minimizing the Dirichlet energy E
D
(u) and
the bottom gures show a conformal map that is obtained by minimizing the least square
conformal energy E
LSCM
(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
xed boundaries.
u
harm
(x)
iso-v
iso-u
S S
iso-v
iso-u
S

S
u
conf
(x)
Figure 2.15: Example of harmonic (top) and conformal map (bottom) for the mapping
of a surface o that have been computed respectively by minimizing the Dirichlet energy
E
D
(u) and the least square conformal energy E
LSCM
(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 xed boundaries.
2.5. GEOMETRICAL REPRESENTATION 41
2.5.5 Examples of analytical parametrizations
We have just shown how to compute parametrizations u(x) by minimizing some func-
tionals. However, for some simple surfaces o such as cylinders and spheres, an analytical
parametrization can be derived.
Cylindrical coordinates
A rst 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)
h

(x, y, z)
(, h)
h
S

x(, h)
S

Figure 2.16: Mapping with cylindrical coordinates.


The metric tensor relative to that parametrization is then
(2.28) M =
_
1 0
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(, ) =
_
_
x
y
z
_
_
=
_
_
Rcos sin
Rsin sin
Rcos
_
_
.
42 CHAPTER 2. SOLID MODELS
x
3
e
r
e

x
1
x
2
x
3
x
1
x
2
Figure 2.17: Spherical coordinates.
We have
x
,
=
_
_
Rcos cos
Rsin cos
Rsin
_
_
, x
,
=
_
_
Rsin sin
Rcos sin
0
_
_
and the metric tensor relative to that parametrization is
(2.29) M = R
2
_
1 0
0 sin
2

_
.
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 o 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 o

perpendicular to the z axis. The parametrization is then dened


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 43
u(x) = (x)
S

x = (x, y, z)
(x)
u
y v
x
s
S
Figure 2.18: Stereographic projection.
z = R:
u(x) =
_
2R
R +z
x,
2R
R +z
y
_
,
x(u) =
4R
2
u
2
+v
2
+ 4R
2
_
u, v, R(4R
2
u
2
+v
2
)
_
.
The metric tensor M for the stereographic projection is then given by:
(2.30) M =
_
0
0
_
.
with
(u, v) =
_
4R
2
u
2
+v
2
+ 4R
2
_
.
Those two eigenvalues are equal: the stereographic mapping is therefore conformal. This
means that any innitesimally 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 gures.
To illustrate this projection, 2.19 shows the World Ocean in stereographic coor-
dinates 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 dene 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 oer great exibility 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 ane 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 oer one common mathematical form for both standard analytical shapes (e.g.,
conics) and free-form shapes.
2.6.1 NURBS curves
A NURBS curve ( is a parametric curve with a parametrization
t [t
a
, t
b
] x(t) !
3
.
2.6. NON-UNIFORM RATIONAL B-SPLINES (NURBS) 45
Control points
The geometry of a NURBS curve ( is dened through a set of n
c
= n + 1 control points
or poles p
i
, i = 0, . . . , n. A point x on the curve is computed by taking a weighted sum
of some of the control points p
i
:
(2.31) x(t) =
n

i=0
N
d
i
(t) p
i
where the N
d
i
(t) are some shape functions of degree d.
Knots
In (2.31), the value of x(t) for a parameter t is only inuenced by a nite number of control
points. Typically, for a NURBS of degree d, the maximum number of control points that
inuences the NURBS for any parameter t is d + 1.
The knot vector T = t
0
, . . . , t
k
is a sequence of parameter values t that determines
where and how the control points aect the NURBS curve. For a non-periodic NURBS,
the number of knots is equal to
k + 1 = n
c
+ (d + 1) k = n + (d + 1).
We have of course that t
0
= t
a
and t
k
= t
b
.
The knot vector divides the parametric space in intervals. For a curve of degree
d, every shape function N
d
i
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 inuence 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 inuence on the rst
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
dierence 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 inuences
the mapping of parameter space to curve space.
Consider a cubic NURBS with n
c
= 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 denes 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 N
3
1
denes the inuence
of control point p
1
on the curve. The number of parameter intervals required for
dening a proper 3rd order curve is d + 1 = 4 which means that N
3
1
is non zero
between t = t
1
= 0 and t = t
5
= 1. Shape function N
3
2
is non zero between
t = t
2
= 0 and t = t
6
= 2, N
3
3
is non zero between t = t
3
= 0 and t = t
7
= 3 and N
3
4
is non zero between t = t
4
= 0 and t = t
8
= 4 which is the whole interval.
A knot vector T = 0, 0, 0, 0, 1, 1, 1, 4, 4, 4, 4 denes piecewise Bezier curves. This
knot vector of size m = 11 = 7+3+1 denes 10 knot spans: (0,0), (0,0), (0,0), (0,1),
(1,1), (1,1), (1,2),(2,2),(2,2) and (2,2). N
3
1
, N
3
2
, N
3
3
, are non zero between t = 0 and
t = 1 and N
3
5
, N
3
6
, N
3
7
, are non zero between t = 1 and t = 4. Only N
3
4
is non zero
on the whole interval.
B-spline Basis Functions
There are many ways to dene B-spline basis functions and to demonstrate their interesting
properties. Here, we use the recursive denition since it is the most useful in practical
implementations.
The B-spline functions at order d are dened recursively using functions at degree
d 1:
(2.32) N
d
i
(t) =
(t t
i
)
(t
i+d
t
i
)
N
d1
i
(t) +
(t
i+1+d
t)
(t
i+1+d
t
i+1
)
N
d1
i+1
(t)
with the degree-0 functions (rst order) N
i,1
being piecewise constant functions:
(2.33) N
0
i
(t) =
_
1 if t [t
i
, t
i+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:
N
d
i
(t) > 0, t [t
i
, t
i+1+d
[
2.6. NON-UNIFORM RATIONAL B-SPLINES (NURBS) 47
Except for the d rst and d last knot points, it can be proven by induction that the
B-spline functions satisfy the partition of unity, i.e:
(2.34)
n

i=0
N
d
i
(t) = 1, t [t
d
, t
nd
[.
Non Uniform Rational B-splines (NURBS)
B-splines are non uniform when the knot vector is not uniformly distributed. This denes
what could be called NUBS or non uniform B-splines.
Let us introduce a vector of positive weights W = w
0
, . . . , w
n
that has the size of
the control points vector. The general form of a Non Uniform Rational B-spline (NURBS)
curve is
(2.35) x(t) =

n
i=0
w
i
N
d
i
(t) p
i

n
i=0
w
i
N
d
i
(t)
.
We observe that the weights introduce new rational basis function R
d
i
dened as:
R
d
i
(t) =

n
i=0
w
i
N
d
i
(t)

n
i=0
w
i
N
d
i
(t)
,
and we also note that when all the weights have value w
i
= 1, we have a B-spline curve
since R
d
i
(t) = N
d
i
(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 denes a complete circle that is tangent to
p
0
, p
2
and p
4
.
2.6.2 NURBS surfaces
Recall that the geometry of a model face G
2
is its underlying surface o with its parametriza-
tion x(u):
(u, v) !
2
x(u, v) !
3
.
48 CHAPTER 2. SOLID MODELS
A B-spline surface o of order d in the udirection and of order e in the vdirection is a
bivariate piecewise function of the form:
x(u, v) =
n

i=0
m

j=0
p
ij
N
d
i
(u)N
e
j
(v).
Two knot vectors
T
U
= u
0
, . . . , u
ku
and T
V
= v
0
, . . . , v
kv

are dened, with k


u
= n + (d + 1) and k
v
= m+ (e + 1).
NURBS surfaces can also use weights w
ij
so that the most general form of the
NURBS surface is written as
(2.36) x(u, v) =

n
i=0

m
j=0
w
ij
p
ij
N
d
i
(u)N
e
j
(v)

n
i=0

m
j=0
w
ij
N
d
i
(u)N
e
j
(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 cre-
ated 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 dene a trace
direction
t = f g
2.7. SURFACE INTERSECTIONS 49
that denes 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:
(2.37) x(t) = p +tx
(1)
(0) +
t
2
2
x
(2)
(0) +
t
3
6
x
(3)
(0) +. . .
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
rst 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 nd derivatives x
(m)
using partial derivatives of f and g. Let
us call x(y) = x
p
+ dx, y
p
+ dy, z
p
+ dz a point of the intersection that is close to
p = x
p
, y
p
, z
p
= x(0). We have
f(x, y, z) = f(x
p
, y
p
, z
p
) +f
,x
dx +f
,y
dy +f
,z
dz +. . .
or, in a closed form
(2.38) f(x, y, z) = f(x
p
, y
p
, z
p
) +

i,j,k=1
1
!i!j!k
f
,x
i
y
j
z
kdx
i
dy
j
dz
k
We look here for dx, dy and dz. Those are found using (2.37):
dx = dx, dy, dz = x(t) p = tx
(1)
(0) +
t
2
2
x
(2)
(0) +
t
3
6
x
(3)
(0) +. . .
In a similar manner, if we look for a third order approximation, we have
dx
2
= (x(t) x
p
)
2
= (x
(1)
)
2
t
2
+x
(1)
x
(2)
t
3
+. . .
dx
3
= (x(t) x
p
)
3
= (x
(1)
)
3
t
3
+. . .
dx dy = (x(t) x
p
)(y(t) y
p
) = x
(1)
y
(1)
t
2
+ (x
(2)
y
(1)
+x
(1)
y
(2)
)
t
3
2
+. . .
dx dy dz = (x(t) x
p
)(y(t) y
p
)(z(t) z
p
) = x
(1)
y
(1)
z
(1)
t
3
+. . .
Since x(t) is on f, f(x+dx, y +dy, z +dz) = 0. We can introduce values of dx, dx
2
, dx dy,
... into (2.38) and zero all expressions factor of t
m
, 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 CHAPTER 2. SOLID MODELS
2.7.2 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 o
1
and
o
2
that have both a parametric representation and an implicit representation:
(2.39) o
1
=
_
x(u
1
, v
1
) = x(u
1
, v
1
), y(u
1
, v
1
), z(u
1
, v
1
)
f
1
(x, y, z) = 0.
and
(2.40) o
2
=
_
x(u
2
, v
2
) = x(u
2
, v
2
), y(u
2
, v
2
), z(u
2
, v
2
)
f
2
(x, y, z) = 0.
.
Let us consider the parametric plane (u, v) of o
1
. The intersection of the two surfaces can
be represented as the implicit curve g(u
1
, v
1
) that veries the implicit representation of
o
2
:
g(u
1
, v
1
) = f
2
(x(u
1
, v
1
), y(u
1
, v
1
), z(u
1
, v
1
)) = 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
(2.41) o
1
=
_
x(u
1
, v
1
) = R
1
cos u
1
, R
1
sin u
1
, v
1
, u
1
[0, 2[, v
1
1
f
1
(x, y, z) = x
2
+y
2
R
2
= 0.
(2.42) o
2
=
_
x(u
2
, v
2
) = u
2
, R
2
cos v
2
, R
2
sin v
2
, u
2
1, v
2
[0, 2[
f
2
(x, y, z) = y
2
+z
2
r
2
= 0.
We introduce the parametric representation of o
1
in the implicit representation of o
2
to
obtain
R
2
1
sin
2
u
1
+v
2
1
R
2
2
= 0
which is an implicit equation g(u
1
, v
1
) = 0 that represents a curve in the parametric plane
of o
1
. We obtain easily that
v
1
=
_
R
2
2
R
2
1
sin
2
u
1
.
Imagine rst that R
2
> R
1
. 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 R
2
> R
1
, 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 R
2
= R
1
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 o
1
and o
2
. Figures show the intersection in the
parameter plane of o
1
for R
2
> R
1
(left), R
2
= R
1
(center) and R
2
< R
1
(right).
the intersecting curve may non be connected, singular points may appear and the solution
of g(u
1
, v
1
) may be complex. Building a robust code for doing such intersections takes
time and experience so that few solid modelling kernels have survived the 1990s.
Another way of proceeding is to use homogeneous coordinates. We transform the
equations as
f
1
(x, y, z, w) = x
2
+y
2
w
2
R
2
= 0,
f
2
(x, y, z, w) = y
2
+z
2
w
2
r
2
= 0,
those having a singularity at the origin w = 0.
f
1
(x, y, z, w) = x
2
+y
2
w
2
R
2
= 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
f(x, y, z) =

i+j+kd
a
ijk
x
i
y
j
z
k
= 0.
An algebraic surface at order d has (d + 1)(d + 2)(d + 3)/6 coecients a
ijk
.
For sake of simplicity, let us rst consider the following bilinear surface:
x(u, v) = a
0
+a
1
u +a
2
v +a
3
uv
y(u, v) = b
0
+b
1
u +b
2
v +b
3
uv
z(u, v) = c
0
+c
1
u +c
2
v +c
3
uv
52 CHAPTER 2. SOLID MODELS
Figure 2.21: Intersection of two cylinders o
1
and o
2
with R
2
,= R
1
(left) and R
2
= R
1
(right).
that we can rewrite as:
(a
0
x) +a
1
u +a
2
v +a
3
uv = 0
(b
0
y) +b
1
u +b
2
v +b
3
uv = 0
(c
0
z) +c
1
u +c
2
v +c
3
uv = 0.
Our aim is to express those equations as an implicit function f(x, y, z) = 0. Here, we use
Sylvesters 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
_

_
(a
0
x) a
1
a
2
a
3
0 0
(b
0
y) b
1
b
2
b
3
0 0
(c
0
z) c
1
c
2
c
3
0 0
0 (a
0
x) 0 a
1
a
2
a
3
0 (b
0
y) 0 b
1
b
2
b
3
0 (c
0
z) 0 c
1
c
2
c
3
_

_
_

_
1
u
v
uv
u
2
u
2
v
_

_
= 0.
Note here that the trick was to nd 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
P
x
(u, v) = f
1
(a [ u
m
, v
n
) x = 0
P
y
(u, v) = f
2
(b [ u
m
, v
n
) y = 0
P
z
(u, v) = f
3
(c [ u
m
, v
n
) z = 0.
We look for the conditions under which those 3 equations can be satised 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 o
1
of degree 18 with a bicubic parametric surface o
2
.
The intersection veries
(2.43)
x(u
1
, v
1
) = P
x
(u, v), P
y
(u, v), P
z
(u, v)
f(x, y, z) =

i+j+k18
a
ijk
x
i
y
j
z
k
= 0.
where P
x
, P
y
and P
z
are bicubic polynomials in u and v. We can then compute the
intersection in the (u, v) plane as

i+j+k18
a
ijk
P
x
(u, v)
i
P
y
(u, v)
j
P
z
(u, v)
k
= 0
that is an algebraic planar curve of degree 3 18 = 54!
2.8 Geodesics
Consider a surface o and two points with coordinates u
1
and u
2
on the parameter plane
of o. There exists an innity of paths (curves) on the surface that connect u
1
and
54 CHAPTER 2. SOLID MODELS
u
2
. 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(t
1
) = u
1
and u(t
2
) = u
2
, that is drawn on the parametric
plane of o. Its length l is a functional
l(u, u
,t
) =
_
C
_
du
T
M du =
_
t
2
t
1
_
u
T
,t
M(u) u
,t
dt.
In order to minimize l, we use the calculus of variations and put to zero the rst
variation of the functional for all admissible variations of u.
Consider the following functional T:
l =
_
t
2
t
1
F(t, y, y

)dt
with y

= y
,t
. Using integration by parts, i.e.
_
x
2
x
1
fg

dx =
_
x
2
x
1
f

gdx + fg[
x
2
x
1
we have
l =
_
t
2
t
1
_
F
y
y +
F
y

_
dx
=
_
t
2
t
1
_
F
y

d
dt
_
F
y

__
ydt +
F
y

t
2
t
1
=
_
t
2
t
1
_
F
y

d
dx
_
F
y

__
ydt = 0
because y = 0 on both t = t
1
and t = t
2
. With arbitrary variations y, one lemma of the
calculus of variations ensures that the quantity
F
y

d
dt
_
F
y

_
= 0
has to be zero to ensure the extremality of the functional. This is the famous Euler-
Lagrange equation. Here, for geodesics,
F =
_
u
T
,t
M(u) u
,t
Consider for example an isometric mapping, i.e. M is the identity. We have
F =
_
u
2
,t
+v
2
,t
.
The Euler-Lagrange equations are written as

d
dt
(2u
,t
) = 0 ,
d
dt
(2v
,t
) = 0
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
F =
_
4R
2
u
2
+v
2
+ 4R
2
_
.
A COMPLETER ...
56 CHAPTER 2. SOLID MODELS
Chapter 3
Mesh Generation
3.1 Generalities
The goal of a nite element analysis is to solve a set of partial dierential 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
weve dened for the geometric model: it consists of
A collection of mesh entities M
d
i
of controlled size and distribution;
Topological relationships or adjacencies forming the graph of the mesh.
We have
1. Mesh Vertices M
0
i
that are topological entities of dimension 0,
2. Mesh Edges M
1
i
that are topological entities of dimension 1,
3. Mesh Faces M
2
i
that are topological entities of dimension 2,
4. Mesh Regions M
3
i
that are topological entities of dimension 3.
What diers 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 !
d
; |x|
2
< 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 M
d
i
is a piece of the discretization of a geometric entity G
q
j
, d q
(a mesh entity must have dimensionality less than or equal to the geometry it is associated
with). We call this association a classication of a mesh entity to a geometrical entity and
we note it as M
d
i
G
q
j
[?, ?, ?].
Simulation attributes like boundary conditions or material properties are naturally
related to model entities and not to mesh entities. In mesh generation and mesh enrich-
ment procedures, the classication information is critical for ensuring that the mesh is
constructed so that it improves the geometric approximation of the domain when it is is
rened. It is therefore necessary to maintain the classication of mesh entities through all
our algorithms.
A mesh Mis 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-Poincare Formula
The Euler-Poincare formula describes the relationship of the number of vertices, the num-
ber 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-Poincare formula, we need the following denitions:
#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-Poincare 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-Poincare relation gives the
following relation between those quantities:
#V #E + #F (M) = 0
where () is the Euler-Poincare characteristic of the surface. The Euler-Poincare char-
acteristic of dierent 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-Poincare relation, more useful for general domains is given by:
(3.1) (M) = #V #E + #F = 2 2GN
B
where,
N
B
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) N
B
+ 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
#F 2(#V 1) + #V
b
= 0 (3.3)
#E 3(#V 1) + #V
b
= 0 (3.4)
where #V
b
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 rst remark that relations (3.3) and (3.4) are true for one triangle alone:
#F = 1, #V = #V
b
= 3.
Swapping an edge of the mesh does not modify #V , #E, #F or #V
b
. All triangu-
lations 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 #V
b
unchanged:
(#F + 2) 2((#V + 1) 1) + #V
b
= #F 2(#V 1) + #V
b
= 0
(#E + 3) 3((#V + 1) 1) + #V
b
= #E 3(#V 1) + #V
b
= 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) + (#V
b
+ 1) = #F 2(#V 1) + #V
b
= 0
(#E + 2) 3((#V + 1) 1) + (#V
b
+ 1) = #E 3(#V 1) + #V
b
= 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 + #V
b
3
where #V
b
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 dene
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-Poincare
formula.
Asymptotically, the 3D Euler-Poincare 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 suciently 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 Hexahedral Mesh M
#R = 6#V
#F = 12#V
#E = 7#V
#R = #V
#F = 3#V
#E = 3#V
Table 3.1: Relation between number of entities in a mesh.
Tetrahedral Mesh M Hexahedral Mesh M
d 3 2 1 0
N
3
(M
d
) 1 2 5 23
N
2
(M
d
) 4 1 5 35
N
1
(M
d
) 6 3 1 14
N
0
(M
d
) 4 3 2 1
d 3 2 1 0
N
3
(M
d
) 1 2 4 8
N
2
(M
d
) 6 1 4 12
N
1
(M
d
) 12 4 1 6
N
0
(M
d
) 8 4 2 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 suciently 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 nite element interpolation scheme. In a tetrahedral
mesh for example, it is important to gure 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 nite 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 rst 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 rst [?, ?]. 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 ow.
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 proce-
dure, 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 eld 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 eld
A mesh size eld is a tool that aims at controlling the mesh size. We dene the mesh
size function (x, y, z) as a function the denes 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 eld. Note that
may me a tensor valued function. In this case, the mesh size eld may be used to control
directional sizes of the mesh and therefore enables to build anisotropic meshes.
The present ways of dening such a mesh size eld 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 dened on another mesh (a background mesh) of the domain;
4. mesh sizes that adapt to the principal curvature of model entities.
These size elds 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 elds are provided, Gmsh uses the minimum of all elds. Thanks to that mechanism,
Gmsh allows for a mesh size eld dened on a given model entity to extend in higher
dimensional entities. For example, using a distance function, a renement 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 dene the adimensional length of
the edge with respect to the size eld as
(3.5) l
e
=
_
e
1
(x, y, z)
dl.
We can now dene 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 l
e
= 1,
3.2.2 Element quality measures
To quickly evaluate the adequation between the mesh and the prescribed mesh size eld,
we dened an eciency index [?] as
(3.6) = exp
_
1
ne
ne

e=1

e
_
with
e
= l
e
1 if l
e
< 1 and
e
=
1
l
e
1 if l
e
1. The eciency index ranges in [0, 1]
and should be as close as possible to = 1.
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 a sin

b sin c
sin a + sin

b + sin c
,
a,

b and c being the three inner angles of the triangle. With this denition, 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
=
6

6 V
k
_
4

i=1
a(f
i
)
_
max
i=1,...,6
l(e
i
)
,
with V
K
the volume of K, a(f
i
) the area of the i
th
face of K and l(e
i
) the dimensional
length of the i
th
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 65
3.3 One Dimensional Meshing
Let us consider a point p(t) on a curve (, t [t
1
, t
2
]. The number of subdivisions N of
the curve is its adimensional length:
(3.7)
_
t
2
t
1
1
(x, y, z)
|
t
p(t)|dt = N.
The N +1 mesh points on the curve are located at coordinates T
0
, . . . , T
N
, where
T
i
is computed with the following rule:
(3.8)
_
T
i
t
1
1
(x, y, z)
|
t
p(t)|dt = i.
With this choice, each subdivision of the curve is exactly of adimensional size 1, and the
1-D mesh exactly satises the size eld . In Gmsh, (3.8) is evaluated with a recursive
numerical integration rule.
3.4 Delaunay and Vorono
3.4.1 The Vorono diagram
Let p
1
and p
2
be two points of R
2
. The mediator /(p
1
, p
2
) is the locus of all the points
which are equidistant to p
1
and p
2
:
/(p
1
, p
2
) = p R
2
, d(p, p
1
) = d(p, p
2
)
where d(., .) is the euclidian distance between two points of R
2
, i.e.
(3.9) d
2
(p
1
, p
2
) = (p
2
p
1
) (p
2
p
1
).
The equation of the mediator can be found out using this denition
(p
1
p) (p
1
p) = (p
2
p) (p
2
p)
or
(p
1
p
2
)
_

_
p
1
2
(p
1
+p
2
)
. .
pm
_

_
= 0
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 rst region contains
all the points that are closer to p
1
, the second one contains the ones that are closer to p
2
.
Any point of R
2
// can be associated to one of those two points.
66 CHAPTER 3. MESH GENERATION
p
m
p
1
M
p
2
p
Figure 3.2: The mediator.
3.4. DELAUNAY AND VORONO

I 67
p
i
p
j
p
k
v
I
C(p
i
)
Figure 3.3: The Vorono diagram. The Vorono cell ((p
i
) relative to vertex p
i
is colored.
Let us consider a set of N points o = p
1
, . . . , p
N
. More specically, we assume
that the points are in general position, by which we mean no four points are cocircular.
The Vorono cell ((p
i
) associated to point p
i
is the locus of points of R
2
that are closer
to p
i
than any other point p
j
, j = 1, . . . , N, i ,= j.
The Vorono cell is constructed as follow. Consider all mediators /(p
i
, p
j
). Each
of those mediators dene a half plane. The Vorono diagram is the part of the space
that is always closer to p
i
, i.e. that always associate p
i
to the point p, for all possible
mediators.(see Figure 3.3). The set of all Vorono cells is called the Vorono diagram of o
(see Figure 3.3).
Let us present some remarkable properties of the Vorono diagram.
Property 3.4.1 Vorono cells are convex polytopes.
By denition, each Voronoi region ((p
i
) is the intersection of open half planes containing
vertex p
i
. Therefore, ((p
i
) is open and convex. Dierent 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 p
i
of o lies on the convex hull of o if and only if its
Vorono cell ((p
i
) is unbounded.
68 CHAPTER 3. MESH GENERATION
Figure 3.4: Two triangulations of o, both containing n
t
= 13 triangles dened by a total
of N = 12 points with N
h
= 9 points that lie on the convex hull of o.
Property 3.4.2 Vorono points v
I
are always located at intersection of 3 mediators.
Property 3.4.2 is only true if there exist no quadruplets of points in o 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 v
i
is at the intersecion
of ((p
i
), ((p
j
) and ((p
k
). Vorono point v
I
is located at the center of the unique circle
passing through p
i
, p
j
and p
k
.
3.4.2 The Delaunay Triangulation
We rst dene what is a triangulation of o: it is a planar subdivision whose bounded faces
are triangles and whose vertices are the points p
i
of o. Note that all triangulations do not
cover the same subset of R
2
. In what follows, we consider that the domain to triangulate
is the convex hull of o.
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 o be a set of N points in the plane, not all collinear, and let N
h
denote the number of points in o that lie on the convex hull of o. Then any triangulation
of o has n
t
(N, N
h
) = 2N 2 N
h
triangles and n
e
(N, N
h
) = 3N 3 N
h
edges.
3.4. DELAUNAY AND VORONO

I 69
Proof Consider rst that all the points in o are in the convex hull: N = N
h
. A triangu-
lation consist simply in triangles t
I
(p
1
, p
i
, p
i+1
), i = 2, . . . , N 1. The number of triangle
is therefore n
t
= N 2 which is consistent with the formula. The number of edges in the
triangulation is calculated as follows: N
h
= N edges on the convex hull and N3 internal
edges wich gives n
e
= 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 p
N+1
that lies inside the convex hull.
This new vertex lies inside one of the existing triangles, say t
I
(p
i
, p
j
, p
k
). We remove t
I
and replace it by three new triangles t
J
(p
i
, p
j
, p
N+1
), t
J
(p
j
, p
k
, p
N+1
), t
J
(p
k
, p
i
, p
N+1
).
We have therefore n
t
(N
h
, N
h
) = N
h
2 and n
t
(N + 1, N
h
) = n
t
(N, N
h
) + 2 which gives
n
t
(N, N
h
) = N
h
2 + 2(N N
h
) = 2N 2 N
h
. Similarly, three new edges have been
added in the process. Then, n
e
(N
h
, N
h
) = 2N
h
3 and n
e
(N + 1, N
h
) = n
e
(N, N
h
) + 3
which gives n
e
(N, N
h
) = 2N
h
3 + 3(N N
h
) = 3N 3 N
h
.
Consider a triangulation T with n
t
triangles. This triangulation has 3n
t
internal
angles. Consider the vector of angles A(T ) = (
1
, . . . ,
3nt
) sorted by increasing values.
We can dene 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

),
T

. 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 there-
fore useful to nd 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(p
4
, p
6
) of Figure 3.5. This edge is surrounded by two
triangles t
1
(p
4
, p
6
, p
1
) and t
2
(p
4
, p
6
, p
2
) . An edge swap is a local mesh modication
operator that consist in changing locally the triangulation by replacing edge e(p
4
, p
6
) by
e

(p
1
, p
2
). Triangles t
1
(p
4
, p
6
, p
1
) and t
2
(p
4
, p
6
, p
2
) are replaced by t

1
(p
1
, p
2
, p
4
) and
t

2
(p
1
, p
2
, p
6
). 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 (

1
, . . . ,

6
).
Such an edge is said invalid. Given a nite set of points, there is a nite 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 conguration 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
t
2

6
t
1
p
2
p
4
p
6
p
1
e

5
t
1
e

p
2
p
4
p
6
p
1

3
t

2
Figure 3.5: Edge swap.
3.4. DELAUNAY AND VORONO

I 71
Figure 3.6: Building an angle-optimal triangulation using swaps.
Property 3.4.4 Let ( be a circle, l a line intersecting ( in points p
4
and p
6
and p
1
, and
p
2
, p
3
and p
5
points lying on the same side of l . Suppose that p
2
and p
3
lie on (, that
p
5
lies inside (, and that p
1
lies outside (. Then (see Fig. 3.7):

1
<
2
=
3
<
5
.
Property 3.4.5 [Lawsons Criterion] Consider an edge e with its two neighboring trian-
gles t
1
and t
2
. Consider the circumcircle ( of triangle t
1
and point p that belongs to t
2
but not to t
1
. Edge e is invalid if p (.
Property 3.4.5 has been demonstrated by Sibson in [?]. Consider Figure 3.8. The proof
consist in demonstrating that

> if p
1
C. The demonstration make use of property
3.4.4 (Thal`ess 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 o that
is based on the Vorono diagram. This triangulation DT(o) is called the Delaunay trian-
gulation and its construction works as follows.
First recall that each Vorono cell ((p
i
) is associated to one only point p
I
of o.
Consider a Vorono point v
I
that at the meeting point of 3 Vorono cells ((p
i
),
((p
j
), ((p
k
). Because of the Vorono property, point v is at the circumcenter of triangle
t
I
(p
i
, p
j
, p
k
). Triangle t
I
DT(o) is one of the triangles of the Delaunay triangulation.
The resulting gure is a triangulation (see Figure 3.9).
Property 3.4.6 Let o be a set of points in the plane.
72 CHAPTER 3. MESH GENERATION
p
6
p
3
p
5

5
p
1
p
2
p
4

1
C
l
Figure 3.7: Theorem of Thal`es
C

C
p
2
p
4
p
6
p
1
e
e

Figure 3.8: Lawsons criterion


3.4. DELAUNAY AND VORONO

I 73
Figure 3.9: The Vorono diagram and its associated Delaunay triangulation
74 CHAPTER 3. MESH GENERATION
v

p
3
C(t)
l
a
l
c
l
b
b
c
v
t
a
p
1
p
2
Figure 3.10: Illustration of why property (i) of 3.4.6 is true.
(i) Three points p
i
, p
j
and p
k
o are vertices of the same triangle t
I
of the Delaunay
triangulation if and only if the circumcircle C(t
I
) contains no point of o in its
interior.
(ii) Two points p
i
and p
j
o form an edge e
I
of the Delaunay triangulation if and
only if there is a closed disc C that contains p
i
and p
j
on its boundary and does not
contain any other point of o.
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 o, triangle t is cannot be in the Delaunay
triangulation because point a is closer to v that at least one of the three points p
1
p
2
or
p
3
. Therefore, as it is drawn in the Figure, mediator l
a
crosses another mediator at point
v

inside the triangle, which is impossible.


Property 3.4.7 Let o be a set of points in the plane in general position. A triangulation
T of o is angle-optimal if and only if T is the Delaunay triangulation of o.
Proof We shall prove that the angle-optimal triangulation is the Delaunay triangula-
tion by contradiction. So assume T is a legal triangulation of o that is not a Delaunay
triangulation. By Property (ii) of 3.4.6, this means that there is a triangle t(p
i
, p
j
, p
k
)
such that the circumcircle C(t) contains a point p
l
o in its interior. Let e(p
i
, p
j
) be
the edge of t

(p
i
, p
j
, p
l
) such that the triangle t

does not intersect t. Of all such pairs


3.4. DELAUNAY AND VORONO

I 75
C(T
i
, p
i+1
)
p
i+1
p
i+1
C(T
i
, p
i+1
)
Figure 3.11: Delaunay triangulation T
i
(left). The Delaunay cavity (
p
(T
i
, p
i+1
) is repre-
sented in both middle (p
i+1
is inside T
i
) and right (p
i+1
is outside T
i
) gures.
(p
i
, p
j
, p
k
, p
l
) in T , choose the one that maximizes the angle p
i
, p
l
, p
j
. Now look at the
triangle t

(p
i
, p
j
, p
m
) adjacent to t along e. Since T is angle-optimal, e is legal. By Prop-
erty 3.4.5, this implies that p
m
does not lie in the interior of C(t). The circumcircle C(t

)
contains the part of C(t) that is separated from t by e. Consequently, p
l
C(t

) Assume
that e

(p
j
, p
m
) is the edge of t

such that triangle t

(p
j
, p
m
, p
l
) does not intersect t

. But
now angle p
j
, p
l
, p
m
> angle p
i
, p
l
, p
j
by Thal`ess Theorem, contradicting the denition
of the pair (p
i
, p
j
, p
k
, p
l
).
Note that the unicity of the Delaunay triangulation is only guaranteed when there
exists no quadruplets of points in the set o that are cocircular, i.e. for points in general
position. When o 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 T
i
and a point p
i+1
inside T
i
. The cavity ((T
i
, p
i+1
) associated
to T
i
and p
i+1
is the set of all the triangles for which their circumsphere contains p
i+1
.
We consider a triangulation T
i
and a point p
i+1
outside T
i
. The cavity (
p
(T
i
, p
i+1
)
associated to T
i
and p
i+1
is the set of all the triangles for which their circumsphere contains
p
i+1
completed by all triangles that can be formed by joining all the edges of T
i
visible by
p
i+1
.
76 CHAPTER 3. MESH GENERATION
B(T
i
, p
i+1
)
p
i+1
B(T
i
, p
i+1
)
p
i+1
Figure 3.12: Delaunay triangulation T
i+1
In the left Figure, p
i+1
is inside T
i
and, in the
right Figure, p
i+1
is outside T
i
.
Property 3.4.8 The cavity (
p
(T
i
, p
i+1
) is star shaped and p
i+1
belong to its Haddad
kernel.
A polygon is star-shaped with respect to p
i+1
if, for each point p
k
, k = 1 . . . , N
c
of the polygon the edge e(p
i+1
, p
k
) lies entirely within the polygon. The set of all points
p
i+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 N
c
triangles. This set of new triangles is
called the ball B(T
i
, p
i+1
).
Let us assume that we have build the Delaunay Triangulation T
i
with the rst i
points of the set o.
It is possible to build iteratively the delaunay triangulation T
i+1
, i.e. using T
i
and
p
i+1
. We dene the Delaunay kernel as the following procedure
T
i+1
= T
i
((T
i
, p
i+1
) +B(T
i
, p
i+1
)
that consist in removing from the triangulation elements of ((T
i
, p
i+1
) that violate the
incircle property (i) of 3.4.6 and subsequently to triangulate the cavity with the ball
B(T
i
, p
i+1
) Figure 3.12 illustrates the Delaunay kernel.
Property 3.4.9 if T
i
is the Delaunay triangulation of the convex hull of the i rst points
of a set o, then T
i+1
, the triangulation constructed using the Delaunay kernel is a Delaunay
triangulation
3.4. DELAUNAY AND VORONO

I 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 Stol 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
o = p
1
, p
2
, . . . , p
9

of 9 points sorted lexicographically.


A doubly linked circular list is assigned to every point p
i
of the set o. This data
structure contains every point p
j
that is connected through a mesh edge to point p
i
. 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
S
p
1
p
2
p
3
p
4
p
5
p
6
p
7
p
8
p
9
Figure 3.13: A set of points sorted lexicographically
p
2
p
6
p
6
p
5
p
3
p
2
p
3
p
4
p
5
Figure 3.14: The doubly-linked circular list associated to point p
4
.
3.4. DELAUNAY AND VORONO

I 79
j in the list of adjacencies of i and inserts i in the list of adjacencies of j. Func-
tion 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
o
subset
= p
left
, p
left+1
, . . . , p
right
.
Three trivial cases are treated:
If the number of points n = right left + 1 in o
subset
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 o
subset
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 rst part of the DelDC procedure is illustrated graphically at Figure ??. The
set of points is rst split in two subsets o
1
and o
2
(part (a) of Figure ??). Then, each
part is split again, giving four subsest o
11
, o
12
, o
21
and o
22
(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. De-
launay triangulations DT(o
11
) and DT(o
12
) are merged as well as DT(o
21
) and DT(o
22
),
forming two Delaunay triangulations DT(o
1
) and DT(o
2
) (part (a) of Figure 3.16). Then
DT(o
1
) and DT(o
2
) are merged to form the nal result DT(o) (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(o
1
) and DT(o
2
). 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 UCT 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 lling the empty gap between
the two triangulations DT(o
1
) and DT(o
2
),
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(o
1
) and DT(o
2
), they
may not be part of DT(o).
80 CHAPTER 3. MESH GENERATION
S
2
p
2
p
3
p
4
p
5
p
6
p
7
p
8
p
9
S
1
p
1
S
22
p
4
p
5
p
6
p
7
p
8
p
9
S
11 S
12 S
21
p
1
p
2
p
3
(a) (b)
S
21
p
8
p
7
p
5
p
1
p
2
p
4
S
11 S
22
S
12
p
3
p
9
p
6
(c)
Figure 3.15: Illustration of the Divide and Conquer procedure.
3.4. DELAUNAY AND VORONO

I 81
S
2
p
9
p
6
p
8
p
7
p
5
p
1
p
2
p
4
S
1
p
3 S
p
3
p
9
p
6
p
8
p
7
p
5
p
1
p
2
p
4
(a) (b)
Figure 3.16: Illustration of the DelMerge procedure of the Divide and Conquer procedure.
This procedure merges the two left triangulations DT(o1) and DT(o2) to form the nal
result DT(o).
r2
lr,r
UCT
ll,l
LCT
ul,l2
l1
r1
ur
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
UCT
ul,l2
ur
r2
r1
l1
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 rs adjacency list and edge (r,r2) is the one the is the Predecessor of (r,r1) in rs
adjacency list. We apply Lawsons 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(o
2
).
Similarly, consider point l in Figure 3.17. Edge (l,l1) is the one the is the Successor
of LCT in ls adjacency list and edge (l,l2) is the one the is the Successor of (l,l1) in ls
adjacency list. We apply Lawsons 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(o
1
).
Among the two possible new edges (r,l1) and (l,r2) that may be added to the trian-
gulation, edge (r,l1) is chosen because it satises 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
Lawsons 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

I 83
r
ul,l2
ur,l1
r2
ll
l
l1
lr
ul,l1
ur=r1
r2
ll
lr
r
l
Figure 3.19: Two steps of the merging procedure.
r2
ul,l1
ll
lr
ur,r1
l
r
r
ul,l1
ll
lr
ur,r1
l
(a) (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 ,= ul or r ,= 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 o.
3.5. PLANAR MESHING 85
-0.075 -0.05 -0.025 0 0.025 0.05 0.075
0
0.025
0.05
0.075
0.1
0.125
0.15
17
12 8
3
18
10
6
19
20
16
4
1
13
11 9
14 2
15
5
7
19 20
15
25
13
6
5 8
23
14
11
9
24
10
22
4
17
18
7
12
3 2
16
1
21
Figure 3.21: A simple 2D model (conge.geo).
3.5.1 The general procedure
Let us start by dening 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
eld = 0.005. The rst 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 rst, 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 addi-
tional 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
0.075
0.05
-0.05
0.075
-0.025
0.15
-0.075 0.05 0.025
0.025
0.1
0.125
0
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 triangu-
lation. 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 p
1
and p
2
.
This edge will be present in the Delaunay triangulation if the circle centered at
1
2
(p
2
+p
1
)
of diameter |p
2
p
1
| does not contain any other point of the set than p
1
and p
2
. In
practice, it is possible to rene the 1D mesh in order to fullll this circle criterion.
It is also possible to recover the missing 1D edges using edge swaps. In our rst
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 denition 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 G
1
j
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 rst
image shows the initial 1D mesh that respects mesh size eld. The second image shows
the rst iteration of the recovery algorithm. The third image shows the nal mesh that
was possible to realize after 2 recovery iterations
each other. Yet, even the geometry is itself not self-intersecting, the rst 1D generated
mesh intersects itself. This can be been considered as a critical issue: modifying the mesh
size eld by hand locally cannot be considered when several thousand of boundaries are
to be involved. It is therefore mandatory to dene 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 e
i
that belongs to
the 1D mesh is to be swapped for recovering edge e
j
, then the mesh edges e
i
and e
j
that both belong to the 1D mesh intersect.
3. All intersecting edges e
k
are split in 2 segments and the new point is snapped onto
the geometry. Then, we go back to the rst 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 rene the triangulation. The way
points are inserted is the key point of the method. Dierent algorithms are available in
Gmsh. We will present them in forthcoming sections.(Figure 3.25).
88 CHAPTER 3. MESH GENERATION
Figure 3.24: The rst and second stages of the 2D meshing procedure for the model
conge.geo.
3.5. PLANAR MESHING 89
0.05 -0.075 0.075 0 -0.05
0.125
0
0.15
-0.025
0.1
0.025
0.075
0.05
0.025 -0.025
0.1
0.025
0.075
0.05
0.025 0.05 -0.075 0.075 0 -0.05
0.125
0
0.15
Figure 3.25: The fourth and fth 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 M
1
i
in the mesh. The procedure works as follows:
A cavity containing triangles that are crossed by the edge to recover is set up rst
(grey triangles in the rst Figure).
Internal edges of the cavity are counted. Here, we count initially 7 internal edges
that are all crossed by M
1
i
.
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
43
53
58
70
52
59
5
71
6
41
72
60
51
50
61
49
45
2
1
46
68
47
4
48
54
57
65 69
3
63
8
44
64
66
56
67
7
55
42
62
X
Y
Z
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 rst idea would be for example to insert a new vertex in the middle of the longest
edge with points p
1
and p
2
(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 aw. There is indeed no guarantee that there exist no point in the mesh
that is closer to the middle point than p
1
and p
2
. 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 ltering
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 dene 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:
(a
x
C
x
)
2
+ (a
y
C
y
)
2
= (b
x
C
x
)
2
+ (b
y
C
y
)
2
(a
x
C
x
)
2
+ (a
y
C
y
)
2
= (c
x
C
x
)
2
+ (c
y
C
y
)
2
.
This leads to the system:
_
(b
x
a
x
) (b
y
a
y
)
(c
x
a
x
) (c
y
a
y
)
_ _
C
x
C
y
_
=
1
2
_
b
2
x
a
2
x
+b
2
y
a
2
y
c
2
x
a
2
x
+c
2
y
a
2
y
_
.
Circumradius R
t
and inner radius r
t
of a triangle t are nicely related as
R
t
= |Ca| =
1
2r
t
|b a||c a||a b|
|b a| +|c a| +|a b|
.
The adimensional size l
t
of triangle t is computed as
(3.10) l
t
=

3
R
t
(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 R
t
= 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 trian-
gulation with the additional point. The algorithm stops when l
t
< l
max
with l
max
1. It
is indeed NOT a good idea to take l
max
> 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 l
t
= 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 dene a range of
acceptable sizes [l
min
, l
max
] in a way that splitting a large triangle edge l
t
> l
max
would
not generate a triangle that is too small i.e. for which l
t
< l
min
. This can be translated
in l
max
= 2l
min
. An usual choice for the acceptable range is to center it around 1 i.e.
l
max
+ l
min
= 2. This gives [l
min
, l
max
] = [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 nal mesh are nicely distributed so that only a very light
optimization (laplace smoothing) is necessary for obtaining the nal 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 rst 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(a
x
C
x
)
2
+G(a
y
C
y
)
2
+ 2F(a
x
C
x
)(a
y
C
y
) =
E(b
x
C
x
)
2
+G(b
y
C
y
)
2
+ 2F(b
x
C
x
)(b
y
C
y
)
E(a
x
C
x
)
2
+G(a
y
C
y
)
2
+ 2F(a
x
C
x
)(a
y
C
y
) =
E(c
x
C
x
)
2
+G(c
y
C
y
)
2
+ 2F(c
x
C
x
)(c
y
C
y
)
This leads to the system:
_
E(b
x
a
x
) +F(b
y
a
y
) G(b
y
a
y
) +F(b
x
a
x
)
G(c
x
a
x
) +F(c
y
a
y
) G(c
y
a
y
) +F(c
y
a
y
)
_ _
C
x
C
y
_
=
1
2
_
E(b
2
x
a
2
x
) +G(b
2
y
a
2
y
) + 2F(b
x
b
y
a
x
a
y
)
E(c
2
x
a
2
x
) +G(c
2
y
a
2
y
) + 2F(c
x
c
y
a
x
a
y
)
_
. (3.11)
The circumradius R
t
is computed as
R
2
t
= E(C
x
a
x
)
2
+G(C
y
a
y
)
2
+ 2F(C
x
a
x
)(C
y
a
y
).
Bowyer and Watson and Lawsons 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 C
x
and C
y
. In Gmsh,
we perform 2 or 3 xed point iterations of (3.11). This gives usually a suciently 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 denition of the Delaunay kernel. We consider a triangulation T
i
and a point p
i+1
outside T
i
. The cavity (
p
(T
i
, p
i+1
) associated to T
i
and p
i+1
is the set
94 CHAPTER 3. MESH GENERATION
of all the triangles for which their circumsphere contains p
i+1
completed by all triangles
that can be formed by joining all the edges of T
i
visible by p
i+1
. We dene the Delaunay
kernel as the following procedure
T
i+1
= T
i
((T
i
, p
i+1
) +B(T
i
, p
i+1
)
that consist in removing from the triangulation elements of ((T
i
, p
i+1
) that violate the
incircle property (i) of 3.4.6 and subsequently to triangulate the cavity with the ball
B(T
i
, p
i+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
Lets 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 p
i+1
on its circumcenter, to
put it somewhere on a Voronoi edge or to use any fancy point insertion policy. The rst
task of the algorithm is to compute the Delaunay cavity (
p
(T
i
, p
i+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 dened by parametric sur-
faces, for example, NURBS [?]. Let us consider a model face G
2
i
with its underlying
geometry, in this case a surface o R
3
with its parametrization p(u, v) o, where the
domain of denition of the parameters (u, v) is dened 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 o, common in CAD descriptions, make its meshing non-trivial:
1. o is periodic. The topology of the model face is modied in order to dene 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. o is trimmed: it contains four holes and one of them is crossed by the seam.
3. One of the model edges of o 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 nite 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 build-
ing meshes from STL (stereolithography) data les [?], 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 robustwe 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 rst fundamental form
of the surface (2.12). The metric eld is a second order tensor eld that has the form, at
any point of the parametric space, of a 22 matrix. The metric is used to dene angles and
distances in parametric space (see Sec. 2.5.2). With their Delaunay approach, the empty
circle property, eectively becomes an empty ellipse property. An equivalent metric-
based 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 modications [?, ?, ?]. 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 modications 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 modications 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 conguration is obtained by swapping are swapped;
98 CHAPTER 3. MESH GENERATION
11
H
!
h
e
z
0
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.
e
1
e
6
e
5
e
4
e
3
e
2
y
e
4
e
1
e
2
e
3
Fig. 2. Local mesh modications. Edge split (top), edge collapse (middle) and edge swap (bottom). The zone depicted in bold represents the
cavity that is modied by the local mesh modication.
Figure 3.31: Illustration of local mesh modications.
4. Vertices are re-located optimally.
More precisely, here is how these four local mesh modications procedures are ap-
plied in Gmsh:
Edge Splitting: An edge is considered too long when its adimensional length is greater
than l
e
> 1.4. When split, the two new edges will have a minimal size of 0.7. In
order to converge to a stable conguration, an edge of size l
e
= 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 l
e
< 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 (
e
1
,
e
2
) < min (
e
3
,
e
4
) (see Figure 3.31),
unless
1. it is classied on a model edge;
2. the two adjacent triangles e
1
and e
2
form a concave quadrilateral in the para-
metric 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 modication procedures, the opportunity of doing a
mesh modication is evaluated in the real space, i.e., in (x, y, z), while the validity of
a mesh modication 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 eld
(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 dierent stages of the algorithm. Note that the derivatives of
the parametrization of the underlying surface are not dened 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
renement 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 nite element shapes: lines, triangles,
quadrangles, tetrahedra, hexahedra, prisms and pyramids. The internal mesh data struc-
tures are designed to minimize the memory footprint without compromising exibility:
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. 3
iter. 5 nal
Figure 3.32: Illustration of the surface meshing algorithm based on local mesh modica-
tions. 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 eld
eciency = 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 specically tailored for each meshing algorithm. Those
derived structures contain just the right extra information necessary: the parametric co-
ordinates 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 specic software. But thankfully, while transfer-
ring 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 grid-
based 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 optimizersin 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 secondsabout 15
times more than for the Gmsh optimizer. Transferring the mesh in Netgen format also
doubled the memory usage.
102 CHAPTER 3. MESH GENERATION
0
5000
10000
15000
20000
25000
0 0.2 0.4 0.6 0.8 1
#Elements
Element Quality
no optimization
gmsh optimization
both netgen and gmsh optimizations
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 nite element community. The various examples shown below
can all be downloaded from the Gmsh web site. They come from dierent 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 elds 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 eld are dened in a variety of ways: analytic, uniform, size
elds driven by distance functions (attractors), boundary layers, size elds related to the
curvature of surfaces, or size elds interpolated using sizes that are dened 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 elds 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 rst 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.
type n
R
n
F
n
E
n
V

cube GMSH 1 6 12 8 uniform
gmsh GMSH 0 1 35 23 attractor
frog IGES 1 475 950 477 uniform
frogadapt IGES 1 475 950 477 analytic
linkrods STEP 1 37 108 74 analytic
zylkopf STEP 1 137 404 270 at vertices
cylhead BREP 1 1054 2485 1445 uniform
fuse STEP 1 249 723 476 curvature
block STEP 1 533 1586 1048 uniform
senzor GMSH 8 90 200 146 at vertices
world ocean GMSH 0 1 4245 145291 boundary layer
media GMSH 1274 8398 5779 3894 uniform
Table 3.3: Statistics on the models that are considered: n
R
,n
F
,n
E
and n
V
are respectively
the number of model regions, of model faces, of model edges and of model vertices in the
model. is the size eld.
104 CHAPTER 3. MESH GENERATION
block linkrods senzor
frogadapt media
(W. Scholz, T.U. Wien)
Figure 3.35: Some images of volume meshes.
3.7. 3-D MESH GENERATION 105
np ne
K
> 0.9 min
K

K
avg
K

K
l

2
cpu
gmsh 28041 55922 83.5% 0.287 0.946 99.0% 0.891 10
linkrods 55959 119922 84.2% 0.385 0.946 98.9% 0.893 61
zylkopf 32806 65668 86.0% 0.105 0.947 98.5% 0.860 8
cylhead 84014 188150 77.5% 0.050 0.915 95.5% 0.892 45
fuse 23485 47038 76.0% 0.010 0.919 97.3% 0.886 11
block 19694 55530 76.0% 0.021 0.923 96.8% 0.895 20
senzor 19876 40002 84.6% 0.546 0.947 98.4% 0.896 11
ocean 1152011 2255212 89.0% 0.211 0.950 99.1% 0.901 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, min
K

K
is the worst element quality in the
surface mesh and avg
K

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 < l
e
<

2.
The factor is the eciency index dened in Equation (3.6). The last column gives the
cpu time (in seconds) for performing the surface mesh generation.
np ne min
K

K
avg
K

K
cpu(mesh) cpu(opti)
cube 195,671 1,098,530 0.235 0.717 49 sec. 36 sec.
linkrods 341,297 1,836,634 0.347 0.756 111 sec. 117 sec.
block 48,897 221,090 0.012 0.660 12 sec. 14 sec.
senzor 143,799 805,392 0.222 0.765 35 sec. 27 sec.
frogadapt 403,947 2,381,969 0.172 0.691 126 sec. 180 sec.
media 164,517 890,756 0.071 0.696 55 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, min
K

K
is the worst element quality in the volume
mesh and avg
K

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 elds (linkrods or frogadapt). One has small
features in the geometry (block). Some have multiple volumes (media or senzor). Complex
mesh size elds 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
eld. Mesh with strong size variations or with small geometric features require more
optimization. The performance gures 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`ege)
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. Struc-
tured technologies include transnite 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 non-
boundary-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 nally 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
gure show an example of oversampled triangluation resulting from a mesh segmentation
of a human pelvis and right gure shows the straightforward meshing of a CAD geometry
of a maxi-cosi.
The rst 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 nite element simulations since the quality of the
mesh will impact both on the accuracy and eciency 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 signicance and a straightforward meshing
of those patches gives often meshes that are not suitable for nite 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 nite element computations (CFD, structure mechanics, etc.). An
ecient 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 strate-
gies [?, ?, ?] and parametrization techniques [?, ?, ?, ?, ?, ?]. Mesh adaptation strategies
use local mesh modications 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 o 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 ecient tool
for many mesh processing applications [?, ?, ?, ?, ?]. In the context of remeshing pro-
cedures, the initial surface is parametrized onto a surface in !
2
, 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 classied as follows: linear,
4.1. PARAMETRIZATION OF TRIANGULATED SURFACES 109
non-linear and hybrid methods. Non-linear methods based on discrete or dierential-
geometric non-linear distortion measure [?, ?, ?] oer strong guarantees on the absence of
triangle folding and ipping at the cost of a generally higher computational eort. 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 signication 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 o is a conforming trian-
gulated mesh o
T
in 3D , i.e. the set of K triangles T
j
that intersect only at N common
vertices p
i
and E common edges e
ij
:
M = o
T
= T
1
, ..., T
K
.
The discrete parametrization aims at computing the discrete mapping u(x) that
maps every triangle of the three dimensional surface o to another triangle of o

that has
a well known parametrization.
(4.1) x o
T
!
3
u(x) o

T
!
2
Such a parametrization exists if the two surfaces o
T
and o
T

have the same topology, that
is have the same genus G and the same number of boundaries N
B
1
. As we have seen, the
genus of a triangulated surface G(o
T
) can be computed from the Euler-Poincare formula
(Eqs. (3.1) and (3.2)):
(4.2) G(o
T
) =
N +E K + 2 N
B
2
.
where N, E, K are respectively the number of vertices, edges and triangles of the triangu-
lation o
T
.
For example, let us consider Figure 4.3 that shows the triangulated Tutankhamun
mask. This triangulated surface is dieomorphic 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
R
2
u
v
R
3
y
S

T
S
T
u(x)
x(u)
x
z
Figure 4.3: Discrete parametrization of the Tutankhamun mask.
nd a transformation u(x) that maps o onto o

= u : [u[ 1. Each vertex p


i
has its
coordinates x
i
on o
T
and u
i
on o
T

. Consider for example one triangle T
j
composed of
three vertices p
1
, p
2
and p
3
. This triangle can itself be parametrized using standard linear
shape functions (see Figure 4.4):
(4.3) x() = (1 )x
1
+x
2
+x
3
.
Similarly, we can also parametrize the triangle in o

:
(4.4) u() = (1 )u
1
+u
2
+u
3
.
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
u u
1
=
_
u
2
u
1
u
3
u
1
v
2
v
1
v
3
v
1
_
. .
u
,
_

_
. .

which gives
(4.5) (u) = (u
,
)
1
(u u
1
) = (
,u
) (u u
1
).
and therefore
x(u) = x((u)).
The derivatives of the mapping x(u)
x
,u
= x
,

,u
=
_
_
x
2
x
1
x
3
x
1
y
2
y
1
y
3
y
1
z
2
z
1
z
3
z
1
_
_
_
v
3
v
1
(u
3
u
1
)
(v
2
v
1
) u
2
u
1
_
(u
2
u
1
)(v
3
v
1
) (v
2
v
1
)(u
3
u
1
)
4.1. PARAMETRIZATION OF TRIANGULATED SURFACES 111
T
j
S

T
u
1
u
2
u
3
(u)
x(u)
T
j
S
T

x
2
x
3
x
1
x()
Figure 4.4: Unit triangle in local coordinates and the mappings u(x), x() and u().
allow to compute the metric tensor M
u
= (x
,u
)
T
x
,u
of the mapping u(x) on the surface
o
T
.
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 T
j
of Figure 4.4. The Gouraud normal smoothing
procedure allows to obtain three normal vectors n
1
, n
2
and n
3
at the three vertices. We
assume that the unit normal vector n(x) can be computed using linear shape functions
n() =
(1 )n
1
+n
2
+n
3
[(1 )n
1
+n
2
+n
3
[
.
A last issue related to discrete parametrizations is the way to compute eciently x(u)
(see Fig.4.4). This operation requires two steps. First, one has to nd the triangle in the
parametric plane that contains u. This can be done eciently 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 eciently dierent 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 CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION
4.2 Computing discrete harmonic and conformal maps
The rst 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)):
(4.6) E
D
(u) =
1
2
_
S
T
|u|
2
ds =
1
2
_
S
T
(u)
2
+ (v)
2
ds.
The strong formulation corresponding to this minimization problem is given by:
(4.7)
2
u = 0,
2
v = 0 on o
T
with appropriate Dirichlet and Neumann boundary conditions on the N
B
boundaries of
o
D
, denoted o
T i
, i = 1, ..., N
B
:
(4.8) u = u
D
(x), on o
T 1
,
u
n
= 0, on (o
T
o
T 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) dene the discrete harmonic mapping u(x).
The second type of mapping to be considered is the conformal mapping that mim-
imizes the least square conformal energy (see Eqs.(2.24) and (2.25)):
E
LSCM
(u) =
_
S
T
1
2
|u

v|
2
ds
=
_
S
T
1
2
_
(u)
2
+ (v)
2
_
n (u v) ds.
= E
D
(u) /(u),
(4.9)
where /(u) is the area functional dened in (2.19).
One ecient way to compute numerically those two quadratic minimization prob-
lems is to use nite elements. We denote by the functional J either the Derichlet energy
E
D
(u) or the least-square conformal energy E
LSCM
(u) to be minimized. The minimization
problem reads as follows: nd u

such that
(4.10)
u

= arg min
uU(S)
J(u), with U(o) = u H
1
(o), u = u
D
(x), or
u
n
= 0 on o
T i
.
In what follows, we will rst derive the nite element formulation for the conformal map
(J = E
LSCM
). We assume the following nite expansions for u:
(4.11) u
h
(x) =

iI
u
i

i
(x) +

iJ
u
D
(x
i
)
i
(x)
where I denotes the set of i = 1, ..., N nodes of o
T
that do not belong to the Dirichlet
boundary, J denotes the set of nodes of o
T
that belong to the Dirichlet boundary (see Fig.
4.2. COMPUTING DISCRETE HARMONIC AND CONFORMAL MAPS 113
nodes of J
nodes of I
Figure 4.5: Sets of I = 12 nodes dened in the rst order FE expansion for a triangular
surface mesh o
T
made of K = 13 triangles and N = 12 vertices.
4.5 for an example for linear nite 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 x
i
and 0 on any other vertex:
i
(x
j
) =
ij
.
Thanks to the nite element expansion (4.11), functional J dening for example the
least square conformal energy Eq. (4.9) can be rewritten as:
J(u
1
, . . . , u
I
) =
1
2

iI

jI
u
i
u
j
_
S
T

i

j
ds +

iI

jJ
u
i
u
D
(x
j
)
_
S
T

i

j
ds+
1
2

iI

jI
v
i
v
j
_
S
T

i

j
ds +

iI

jJ
v
i
v
D
(x
j
)
_
S
T

i

j
ds+

iI

jJ
u
D
(x
i
)u
D
(x
j
)
_
S
T

i

j
ds +

iI

jJ
v
D
(x
i
)v
D
(x
j
)
_
S
T

i

j
ds

iI

jJ
u
i
v
j
_
S
T
n (
i

j
) ds

iI

jJ
u
D
(x
i
)v
j
_
S
T
n (
i

j
) ds

iI

jJ
u
i
v
D
(x
i
)
_
S
T
n (
i

j
) ds

iI

jJ
u
D
(x
i
)v
D
(x
i
)
_
S
T
n (
i

j
) ds.
(4.12)
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 u
k
(the same derivation can be done with respect to v
k
):
J
u
k
=

jI
u
j
_
S
T

k

j
ds
. .
A
kj
+

jJ
u
D
(x
j
)
_
S
T

k

j
ds
. .
A
kj

jI
v
j
_
S
T
n (
k

j
) ds
. .
C
kj

jI
v
D
(x
j
)
_
S
T
n (
k

j
) ds
. .
C
kj
= 0 , k I.
(4.13)
In this equations the elementary matrixes A
kj
of triangle T
i
can be computed as follows:
(4.14) A
T
k
kj
=
_
T
i

k

j
ds =
_
1
0
_
1
0

k
M
1

j
_
det M

dd,
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 u
k
and v
k
derivatives gives us a
linear system of 2I equations that can be written as follows:
(4.15)
_
A C
C
T
A
_
. .
L
C
_
U
V
_
=
_
0
0
_
,
where A is a symmetric positive denite matrix and C is an antisymmetric matrix that
are both build by assembling the elementary matrices A
kj
and C
kj
, and the vectors U
and V denote respectively the vector of unknowns u
k
and v
k
. The resulting matrix L
C
is
then symmetrix denite positive such that the linear system L
C
U = 0 can be eciently
solved using a direct sparse symmetric-positive-denite 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:
(4.16) U

= arg min
U
1
2
U
T
L
C
U
As the Dirichlet energy is related to the least square conformal energy, the linear
system resulting from the nite element formulation for the harmonic map can be derived
from Eq. (4.15), by vanishing the o-diagonal matrixes of L
C
:
(4.17)
_
A 0
0 A
_
. .
L
D
_
U
V
_
=
_
0
0
_
,
which makes the system of equations uncoupled: AU = 0, AV = 0. This nite element
harmonic map can be is quite similar to the discrete harmonic map introduced rst 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 115
4.3 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 denes a one-
to-one mapping (and hence avoids the degenerate solution u =constant).
We rst consider the Dirichlet boundary conditions that are often used for the
Laplacian harmonic map:
(4.18) u = u
D
(x) on o
T i
.
This boundary condition allows to map one of the boundaries of o
T
(o
T 1
) to a xed
boundary in the parametric space (a circle, a square, an ellipse, the projection of o
on its mean plane etc.). The xed boundaries that are considered are convex polygons
since the continuous harmonic map is proven to be one-to-one if the mapped surface o

is convex. This result is called the Rad`o-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 o of the domain. This
means that there exists only one single iso-curve u = u
0
in o and that this iso-curve goes
continuously from one point of the boundary to another. If another iso-curve u = u
0
existed, it should be closed inside o, violating the maximum principle. This is also true
for the iso-curve v = v
0
. Consider the surface o of Figure 4.6a with one single boundary
(N
B
= 1) that is mapped to a unit circle with appropriate Dirichlet boundary conditions.
Surface o

is convex so that any vertical line u = u


0
intersects o

at most two times.


This is also true for any horizontal line v = v
0
. This means that any coordinate u = u
0
(u
0
] 1, 1[) appears also exactly two times on the boundary o. The two points of
o for which u = u
0
are designated as V
A
and V
B
while the two points for which v = v
0
are designated as V
C
and V
D
. Note that those points appear interleaved while running
through o (V
A
appears either after V
D
or after V
C
but never after V
B
). This means that
there exists one point in o for which u = u
0
and v = v
0
.
S S

u(x)
u = u
0
V
A
v = v
0
S
S

u = u
0
V
C
V
B
V
D
v = v
0
Figure 4.6: Iso-values of coordinates u and v on a surface o for which the mapping u(x)
is computed as the solutions of the Laplace equation with Dirichlet boundary conditions
that map o on the unit circle o

.
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 o
T 1
to a unit circle. This boundary condition
can be implemented by choosing arbitrarily a starting vertex M
0
s
on the boundary o
T 1
.
Then, the curvilinear abscissa l
i
of point M
0
i
= x
i
along the curve can computed for
all vertices along the curve of total length L. The mapping of the boundary nodes (the
position (u
i
, v
i
)) of M
0
i
in can then be written as:
(4.19) u
D
(x
i
) = cos
_
2l
i
(x
i
)
L
_
, v
D
(x
i
) = sin
_
2l
i
(x
i
)
L
_
.
Figure 4.7: Dirichlet boundary conditions: mapping the boundary of the Toutankhamon
mask o
T 1
to a unit circle.
Instead of xing all the boundary nodes o
1
to a convex polygon, one might x 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 L
C
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 confor-
mality 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 dene a less distorted least square conformal map (CLSCM) without
pinning down two vertices ? The idea is to add the two following constraints to the mini-
mization 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
o
T 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) U

= arg min
U
1
2
U
T
L
C
U, subject to U
T
E = 0, U
T
BU = 1.
The rst constraint in (4.20) U
T
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 E
i1
= 1, i = 1, ..., I and
4.3. BOUNDARY CONDITIONS FOR DISCRETE MAPS 117
a) b) c)
Figure 4.8: Initial triangulation o
T
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.
E
i2
= 1, i = I + 1, ..., 2I (the other entries of E being zero):
E =
_
_
_
_
_
_
_
_
_
_
1 0
.
.
.
.
.
.
1 0
0 1
.
.
.
.
.
.
0 1
_
_
_
_
_
_
_
_
_
_
,
U
T
E = 0 is equivalent to

I
i=0
U = 0 and

I
i=0
V = 0. In in (4.20), the second constraint
U
T
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 dierent ways to solve this
constrained minimization problem. The rst method tries to nd the optimum of the
following Lagrangian function /(U, ) with Lagrange multipliers
i
0:
(4.21) /(U, ) =
1
2
U
T
L
C
U(U
T
E) (U
T
BU1).
The second method is based on spectral theory that shows that the solution of the con-
strained minimization problem Eq. (4.20) is the generalized eigenvector U

associated to
the smallest non-zero eigenvalue of the matrix L
C
, i.e the vector satisfying
(4.22) L
C
U = BU,
where is the smallest non-zero eigenvalue of L
C
. This generalized eigenvector U

is
called the Fiedler vector of L
C
. We now show that optimizing (4.21) is equivalent to
nding the Fiedler vector U

(4.22). Indeed, for the discrete optimization problem, the


118 CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION
solution must satisfy:
/
U
= 0 L
C
UEBU = 0 (4.23)
/

= 0 U
T
E = 0 (4.24)
/

= 0 U
T
BU = 1 (4.25)
That is, (L
C
B) U = E . Premultiplying Eq.4.23 by E
T
gives:
(4.26) E
T
L
C
UE
T
BU = E
T
E = D,
where D is a 2 2 diagonal matrix with value I at both diagonal entries. But we have
that E
T
BU = 0 (combination of the two constraints (4.24) and (4.25)) and also that
E
T
L
C
= 0 (because the matrix L
C
is a block matrix composed of Laplacian matrixes A
and antisymmetric matrices C that are such that

j
A
kj
= 0 and

j
C
kj
= 0). Thus we
have = 0 and hence,
(4.27) (L
C
B) U = 0,
with U being the generalized eigenvector of the eigenvalue problem (4.22). The matrix L
C
is positive semi-denite with smallest eigenvalue
1
= 0 and corresponding eigenvector E
being the kernel vector (since we have that L
C
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 L
C
matrix is positive denite positive, then it can be shown that the
next smallest eigenvalue
2
is positive. The eigenvector associated with this eigenvalue
(also called Fiedler vector) satises the constraint U
T
E = 0 because it is orthogonal to
the rst eigenvector E. It also satises the constraint U
T
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 ecient eigensolvers that nd 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 eciently the generalized eigenproblem. It is how-
ever interesting to transform the minimization problem (nding the Fiedler vector that
corresponds to the smallest eigenvalue ) (4.22) into a maximisation problem (nding 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 =

L
C
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 I
d
(with I
d
being the identity matrix) to L
C
in order to
4.3. BOUNDARY CONDITIONS FOR DISCRETE MAPS 119
ensure that numerical inaccuracies in the coecients of the conformal matrix L
C
will not
alter the positive semi-deniteness of the matrix (we have used = 1.e
8
). Finally, a last
interesting transformation consists in removing the kernel of L
C
through the following
modied generalized eigenvalue problem:
(4.29) (BB
e
) U =

L
C
U, with B
e
=
1
I
B
(BEE
T
B
T
).
The vector U

we are looking for is the eigenvector corresponding to the largest eigenvalue

. In (4.29), I
B
is the number of boundary nodes and the B
e
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 I
B
boundary nodes) and value 0 for all other entries. As this matrix B
e
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
I
max
B
that are distributed uniformly along the boundary (usually we take I
max
B
= 50). To
illustrate this, consider the very simple triangulation o
T
on Fig.4.9 with N = 5 nodes and
I
B
= 4 boundary nodes. For this triangulation in Fig.4.9, the matrices B
e
and

B
e
(with
2
1
3
4
5
Figure 4.9: Simple triangulation o
T
with 3 triangles, N = 5 vertices (I = 5 nite element
nodes for linear nite elements) and I
B
= 4 boundary nodes.
I
max
B
= 2 = 1, 5) are given by:
B
e
=
1
4
_
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
_
_
_
_
_
_

B
e
=
1
2
_

L 0
0

L
_
, with

L =
_
_
_
_
_
_
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 con-
strained 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:
(4.30)
u
n
= 0, on o
T 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 o
T
that has two bound-
aries denoted o
T 1
and o
T 2
(see Fig.4.10a)). Suppose now, we compute the discrete
S
T 1
S
T 2
S
T A
S
T B
a) b)
Figure 4.10: Triangulation o
T 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 o
T 1
on the unit circle. The bottom a) gure shows the iso-u and
iso-v values for the mapping ( = 1) of the surface o
T
that excludes the interior disk and
for which zero Neumann boundary conditions are applied on o
T 2
. The bottom c) gure
shows the iso-u and iso-v values for the mapping of o
T
that also includes the interior disk,
and for which = 1 inside o
T A
and = 1.e
8
(small value) inside o
T B
.
Laplacian map by solving (4.17) with Dirichlet boundary conditions (4.19) on o
T 1
and
zero Neumann boundary conditions on o
T 2
. The iso-u and iso-v values of this map-
ping are shown in Fig. 4.10b). Figures 4.10a) and b) show that imposing Neumann
boundary conditions on o
T 1
is equivalent to the resolution of a Laplace problem on the
whole domain o
T
= o
T A
+ o
T B
while dening a small diusivity constant (solving

2
u = 0,
2
v = 0) inside the hole o
T B
(Figure 4.6b). This means that this problem
also obeys the same maximum principle as the one with constant diusivity, which means
4.4. ISSUES WITH DISCRETE LINEAR MAPPINGS 121
that the mapping remains one-to-one even when considering holes in the domain. How-
ever, as can be seen clearly in Fig.4.10 the conformality is deteriorated near the Neumann
boundary o
T
(compare Figs. 4.10a with Fig. 4.6 that shows the Laplacian mapping for
the whole surface o
T
with a constant diusivity parameter = 1). That is the reason for
which it might be desirable for surfaces o
T
that have several interior boundaries o
T i
to
mesh the surface o
T B
bounded by those boundaries and to compute the mapping for ex-
tended surface

o
T
that includes those newly dened mesh surfaces [?]

o
T
= o
T

i
o
T Bi
.
4.4 Issues with discrete linear mappings
A very important aspect when computing the parametrization is to obtain bijective (one-
to-one) maps, where each point of the parametric domain corresponds to exactly one
point of the mesh. One can make a dierence between global bijectivity and local bi-
jectivity. The latter requires only that the maps of any suciently small region of the
mesh is bijective. If the discrete convex combination map is guaranteed to be bijec-
tive, 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 gure 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 ips. The bottom gure 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 dierent issues and present dierent algorithms to get rid of those issues and
to guarantee bijectivity.
The rst issue concerns triangle ipping and is illustrated on the top of Fig.4.11.
In this gure, looking at the triangles normals in the parametric space, one can see that
one triangle have been reversed (the normal of the face is ipped). 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 o
T
= (1, 2, 3), (1, 3, 4), (1, 4, 2) and
let x
1
= (r, 0, 1) for some real value r > 0 and x
2
= (1, 1, 0), x
3
= (0, 0, 0), x
4
= (1, 1, 0).
The three boundary vertices x
1
, x
2
and x
3
are mapped onto the boundary of the unit disk
(Figures 4.12b and c) and the vertex x
1
should be mapped inside the triangle (u
2
, u
3
, u
4
) 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-to-
one (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 modies mesh cavities in which
122 CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION
u
v
u
harm
(x)
v
u
conf
(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 ips 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: x
1
= (r, 0, 1) for r > 0 and x
2
= (1, 1, 0), x
3
= (0, 0, 0), x
4
= (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 u
1
does not even lie within the unit disk.
ipping occurs. This algorithm goes as follows:
1. Compute harmonic map using nite elements;
2. For every interior vertex V
i
of the parameter plane, check if each of its neighboring
triangles (dening a cavity) is oriented properly
2
;
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 nd the kernel of a star-shaped polygon, dierent algorithms have been pro-
posed 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 les. The local cavity check algorithm enables most of the time to repair the triangle
v2
v3
v5
v4
v1
T1
T4
T2
T3
v2
v3
v5
v4
v5
v1
v6
v2
v3
v5
v4
v1
T1
T2
T3
T4
a) b) c)
Figure 4.13: Vertex v
1
with four neighboring triangles T
1
= (v
1
, v
2
, v
3
), T
2
= (v
1
, v
3
, v
4
),
T
3
= (v
1
, v
4
, v
5
), T
4
= (v
1
, v
5
, v
2
) dening the polygon P = (v
2
, v
3
, v
4
, v
5
). a) Triangle
T
3
(in red) is not well oriented and overlaps the triangles T
2
and T
4
. b) The vertex v
1
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.
ips. 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 denition
of the convex combination maps is the barycentric mapping [?, ?] that asks every interior
vertex u
i
be the barycenter of its neighbors:
(4.31) u
i
=
d
i

k=1

k
u
j
,
d
i

k=1

k
= 1,
where d
i
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 D
kj
for every
triangle T
i
:
(4.33) D
kj
=
_
_
1 0.5 0.5
0.5 1 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 v
1
in Fig.4.13c, equation (4.31) is satised. This convex com-
bination 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 o
T
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 o
T
(a) that has been remeshed using a
harmonic map (top gures) and a convex combination map (bottom gures): b) mapping
of the initial mesh onto the unit disk o
T

with iso-x and iso-v values in red, c) the deter-
minant of the mesh metric tensor M
u
that denes the area distorstion map and d) the
nal 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 algo-
rithm cannot guarantee that triangles do not overlap. To remain ecient in the context
of surface remeshing, we use an idea similar to the one suggested by Sheer et al. [?] that
checks the presence of edge folding. Edge foldings are detected by looping over the edges
of the boundary o
T 1
and by computing if there exists intersections between the edges
(see Fig. 4.15). The intersection of two edge segments (p
1
, p
2
) and (p
3
, p
4
) of parametric
equations:
p
a
= p
1
+t
a
(p
2
p
1
), p
b
= p
1
+t
b
(p
4
p
3
),
can be computed by solving for the point where p
a
= p
b
. This gives the following linear
system of equations:
(4.34)
_
x
2
x
1
x
3
x
4
y
2
y
1
y
3
y
4
__
t
a
t
b
_
=
_
x
3
x
1
y
3
y
1
_
.
4.5. AUTOMATIC REMESHING WITH PARAMETRIZATIONS 125
If t
a
[0, 1] and t
b
[0, 1], we are in the case of segment intersections. In the case of
p
4
p
1
p
2
p
3
Figure 4.15: Intersection boundary o
T 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 o
T 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
D
<
max
,
where H is the maximal distance computed on the 3D mesh o
T
of a mesh vertex to
the boundary o
T 1
and D is the equivalent diameter of the boundary o
T 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: = 2A/L
2
S
T 1
, where A is the area of the 3D surface mesh and L
S
T 1
is the arc
length of the boundary o
T 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 o
T 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 r
2
i
= 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 N
B
and the
126 CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION
v
u
u
harm
(x)
S
T 1
S
T 2
D
H
x
z
y
S

T
S
T
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 o
T 1
become exponentially close
to each other in the parametric space o
T

.
geometrical aspect ratio . Those three criteria can be summarized as follows:
i) G = 0;
ii) N
B
1; (4.36)
iii) <
max
.
In the next section, we will rst consider a disk-like surface (G = 0, N
B
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
circumscribed radius
= 4
sin a sin

b sin c
sin a + sin

b + sin c
,
a,

b, c being the three inner angles of the triangle. With this denition, 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.
Convex map
0.005
0.01
0.015
0.02
0.025
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8
F
r
e
q
u
e
n
c
y
Aspect ratio
STL mesh
Laplacian map
Conformal map
0
Convex map
0.05
0.1
0.15
0.2
0.25
0.8 0.9 1
F
r
e
q
u
e
n
c
y
Aspect ratio
STL mesh
Laplacian map
Conformal map
0
Figure 4.17: Remeshing of an teeth. Top gures show the initial STL triangulation and
new mesh based on the conformal mapping and the bottom gures show the quality
histogram obtained when remeshing the stl le with dierent mappings.
128 CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION
Acknowledgements
The authors gratefully acknowledge

Electricite de France (EDF) for their nancial 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.