+ All Categories
Home > Documents > An introduction to Geometrical Modelling and Mesh Generation The ...

An introduction to Geometrical Modelling and Mesh Generation The ...

Date post: 08-Dec-2016
Category:
Upload: duonghanh
View: 255 times
Download: 3 times
Share this document with a friend
128
An introduction to Geometrical Modelling and Mesh Generation The Gmsh Companion Christophe Geuzaine Emilie Marchandise Jean-Fran¸coisRemacle
Transcript
Page 1: An introduction to Geometrical Modelling and Mesh Generation The ...

An introduction to Geometrical Modelling and Mesh

Generation

The Gmsh Companion

Christophe Geuzaine Emilie Marchandise Jean-Francois Remacle

Page 2: An introduction to Geometrical Modelling and Mesh Generation The ...

2

Page 3: An introduction to Geometrical Modelling and Mesh Generation The ...

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

Page 4: An introduction to Geometrical Modelling and Mesh Generation The ...

4 CONTENTS

2.5 Geometrical Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

2.5.1 Differential Geometry of Curves . . . . . . . . . . . . . . . . . . . . 31

2.5.2 Differential Geometry of Surfaces . . . . . . . . . . . . . . . . . . . . 34

2.5.3 Classifying the parametrizations . . . . . . . . . . . . . . . . . . . . 37

2.5.4 Computing harmonic and conformal maps . . . . . . . . . . . . . . . 38

2.5.5 Examples of analytical parametrizations . . . . . . . . . . . . . . . . 41

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 field and quality measures . . . . . . . . . . . . . . . . . . . . . . 63

3.2.1 Mesh size field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

3.2.2 Element quality measures . . . . . . . . . . . . . . . . . . . . . . . . 64

3.3 One Dimensional Meshing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

3.4 Delaunay and Voronoı . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

3.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

Page 5: An introduction to Geometrical Modelling and Mesh Generation The ...

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

Page 6: An introduction to Geometrical Modelling and Mesh Generation The ...

6 CONTENTS

Page 7: An introduction to Geometrical Modelling and Mesh Generation The ...

Chapter 1

Introduction

When we started the Gmsh project in the summer of 1996, our goal was to develop afast, light and user-friendly software to easily create geometries and meshes that couldbe used in our three-dimensional finite element solvers [?], and then visualize and ex-port the computational results with maximum flexibility. At the time, no open-sourcesoftware combining a CAD engine, a mesh generator and a post-processor was available:the existing integrated tools were expensive commercial packages [?], and the freewareor shareware tools were limited to either CAD [?], two-dimensional mesh generation [?],three-dimensional mesh generation [?, ?, ?], or post-processing [?]. The need for a freeintegrated solution was conspicuous, and several projects similar in spirit to Gmsh werealso born around the same time—some of them still actively developed today [?, ?]. Gmshhowever 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 computationalsolver, and designed from the start to be driven both using a user-friendly graphical in-terface (GUI) and its own scripting language.

The first 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 [?] andthe 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, andthe 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 PublicLicense [?], and it was modified to provide native support for all major operating systems:Windows, MacOS and all Unix/X11 variants. In the summer of 2006 Gmsh underwenta 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-processinglayer has been introduced, the mesh data structures and algorithms have been rewrittenfrom scratch, and the graphics layer has also been completely overhauled.

Today Gmsh enjoys a thriving community of several hundred users and developersworldwide. It is driven by the need of researchers and engineers in academia and industry

7

Page 8: An introduction to Geometrical Modelling and Mesh Generation The ...

8 CHAPTER 1. INTRODUCTION

alike for a small, open-source pre- and post-processing solution for grid-based numericalmethods. The aim of this paper is not to be a user’s guide or a reference manual—see [?]instead. Rather, it is to present the philosophy and the original features of Gmsh whichmake it stand out from its free and commercial alternatives.

The paper is structured as follows. In Section 1.1 we outline the overall philosophyand design goals of Gmsh, as well as the main technical choices that were made in order toachieve these goals. Sections ??, ??, ?? and ?? then respectively describe the geometry,mesh, solver and post-processing modules. The paper is concluded in Section ?? withperspectives for future developments.

1.1 The Design of Gmsh

Gmsh is built around four modules: geometry, mesh, solver and post-processing. Eachmodule can be controlled either interactively using the GUI or using the scripting language.

The design of all four modules relies on a simple philosophy—be fast, light anduser-friendly.

Fast: on a standard personal computer at any given point in time Gmsh should launchinstantaneously, be able to generate a “larger than average” mesh (compared to thestandards of the finite element community; say, one million tetrahedra in 2008) inless than a minute, and be able to visualize such a mesh together with associatedpost-processing datasets at interactive speeds.

Light: the memory footprint of the application should be minimal and the source codeshould be small enough so that a single developer can understand it. Installingor running the software should not depend on any non-widely available third-partysoftware package.

User-friendly: the graphical user interface should be designed in such a way that a newuser can create simple meshes in a matter of minutes. In addition, the code shouldbe robust, portable, scriptable, extensible and thoroughly documented—all featurescontributing to a user-friendly experience.

In the following sections we describe the technical choices that we made to achievethese sometimes conflicting design objectives. Although major parts of the code have beenrewritten over the years, the overall initial architecture and design from 1996 have alwaysstayed 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 instandard C++ [?]—both the kernel and the user interface.

Page 9: An introduction to Geometrical Modelling and Mesh Generation The ...

1.1. THE DESIGN OF GMSH 9

The kernel uses BLAS [?] (through the GSL, the GNU Scientific Library [?]) formost of the basic linear algebra. To keep them easy to understand the algorithms havenot been overly optimized for speed or memory usage, yet Gmsh currently generates abouta 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 insteadof 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 singleexecutable file), as well as the build time—a statically linked, ready to use executable isproduced in a few minutes on a standard personal computer. Analogously, directly usingOpenGL instead of a more complex graphics library like Inventor [?] or VTK [?] makesGmsh lightweight, without sacrificing rendering performance (Gmsh makes extensive useof OpenGL vertex arrays).

The design of the solver and scripting interfaces follows the same strategy: the solverinterface 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 anexternal 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 softwaretools), 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 interfaceor in a non-interactive mode—either from the command line or via the scripting language.

Achieving “user-friendliness” has been an important driving factor behind key tech-nical choices. We detail some of these choices hereafter, focusing on the list of desirablefeatures 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 beingas 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 anunmanageable 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 PublicLicense [?] also helped portability, as the code was made part of several official Linuxdistributions (most notably Debian [?]), and thus benefited from their extensive automatedtesting infrastructure. Either with the graphical user interface or in batch mode, the same

Page 10: An introduction to Geometrical Modelling and Mesh Generation The ...

10 CHAPTER 1. INTRODUCTION

version of Gmsh now runs on most computers, from laptops to workstations and largeHPC clusters.

Scriptability

Gmsh is scriptable so that all input data can be parametrized, and so that Gmsh can beeasily 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 theresulting language means that full access to internal capabilities is provided, includingbidirectional access to more than 500 internal options fine-tuning the behavior of the fourmodules. The scripting language allows for example to fully parametrize all geometricalentities, to interface external solvers without modifying the source code, or to automateall post-processing operations, e.g., to create complex animations or perform off-screenrendering [?].

Extensibility

We tried to ease the modification and addition of features by users and developers. Suchextensibility takes different 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 codelevel 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 donesimply by deriving four abstract classes—see Section ??. At the scripting level userscan then transparently mix and match geometrical parts represented internally bydifferent CAD engines. For example, it is possible to extend an OpenCascade modelof an airplane with a terrain model defined in the scripting language.

Mesh: using the abstract geometrical interface it is also possible to interface additionalmeshing 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 varioussolvers without changing the source code; tailored graphical user interfaces can alsoeasily be added when more fine-grained interactions are needed.

Post-processing: the post-processor can be extended with user-defined operations throughdynamically loadable plug-ins. These plug-ins act on post-processing datasets (calledviews) in one of two ways: either destructively changing the contents of a view, orcreating one or more views based on the current view.

Page 11: An introduction to Geometrical Modelling and Mesh Generation The ...

1.1. THE DESIGN OF GMSH 11

All source code-level extensions can be enabled or disabled at compile time thanks toan 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 severalmailing lists and a wiki.

Another important feature contributing to user-friendliness is the availability ofstandard input and output file formats. Gmsh uses open or de facto standard formatswhenever 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 integrationof Gmsh with other computational tools.

Page 12: An introduction to Geometrical Modelling and Mesh Generation The ...

12 CHAPTER 1. INTRODUCTION

Page 13: An introduction to Geometrical Modelling and Mesh Generation The ...

Chapter 2

Solid Models

A solid model is a computer model of a 3D solid. It is a virtual representation of the shapeof a solid. Solid models can be simple parts (Figure 2.1, part (a)) or complex assembliesof multiple parts (Figure 2.1, part (b)).

We aim here at explaining how such solids can be described on a computer. We willprincipally 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 finite element mesh generation.

2.1 Principal characteristics of a solid modeling software

A solid modeling software may have some specific characteristics that enables to enhanceboth its efficiency and the productivity of the solid modeling process:

2.1.1 Feature-based modeling

Features are defined to be parametric shapes associated with attributes such as intrin-sic geometric parameters (length, width, depth etc), position and orientation, geometrictolerances, material properties, and references to other features.

Feature-based modelers allow operations such as creating holes, fillets, chamfers,bosses, and pockets to be associated with specific edges and faces. When the edges orfaces move because of a regeneration, the feature operation moves along with it, keepingthe original relationships.

2.1.2 Constraint-based modeling

There are two types of constraints. Dimensional constraints are used to specify distancesbetween items. Geometric constraints define positional relationships between entities in

13

Page 14: An introduction to Geometrical Modelling and Mesh Generation The ...

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 profile in constraint-basedsolid modeling does not need to be created with a great deal of accuracy. It just needs torepresent the basic geometry of the cross section. The exact size and shape of the profileis defined through assigning enough parameters to fully “constrain” it.

2.1.3 Parametric modeling

Parametric modeling means that parameters of the model may be modified to changethe geometry of the model. A dimension is a simple example of a parameter. When adimension is changed, the geometry of the part is updated. Thus, the parameter drives thegeometry. An additional feature of parametric modeling is that parameters can referenceother parameters through relations or equations. The power of this approach is thatwhen one dimension is modified, all linked dimensions are updated according to specifiedmathematical 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 asolid volume of material in which the hole occurs has been modeled. If the solid volumeis deleted, then the hole is deleted with it. This is known as a parent-child relation. The

Page 15: An introduction to Geometrical Modelling and Mesh Generation The ...

2.2. CSG REPRESENTATION OF SOLIDS 15

child (hole) cannot exist without the parent (solid volume) existing first. Parent-childrelations are critical to maintaining design intent in a part. Most solid modeling softwarerecognizes that if you delete a feature with a hole in it, you do not want the hole to remainfloating around without being attached to the feature. Consequently, careful thought andplanning of the base feature and initial additional features can have a significant effect onthe ease of adding subsequent features and making modifications.

2.1.5 Associative modeling

The associative character of solid modeling software causes modifications in one object to“ripple though” all associated objects. For instance, suppose that you change the diameterof 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 includesthat part. Similarly, changing the dimension in the part model will automatically resultin updated values of that dimension in the drawing or assembly incorporating the part.This aspect of solid model software makes the modification of parts much easier and lessprone to error.

As a result of being feature based, constraint based, parametric, history based, andassociative, modern solid modeling software captures “design intent”, not just the design.This comes about because the solid modeling software incorporates engineering knowledgeinto the solid model with features, constraints, and relationships that preserve the intendedgeometric relationships in the model.

2.2 CSG Representation of Solids

We discuss here briefly the Constructive Solid Geometry (CSG) representation of solids.CSG allow to construct complex solid through primitives, boolean operators and rigidmotions.

2.2.1 Basic Primitives

The standard CSG basic primitives are the sphere, the torus, the parallelipiped (block), thecylinder and the cone. All those primitives defined bounded closed orientable domains. Allbasic primitives are defined in the world system of coordinates. Rigid motions (rotations,translations) and scalings can be applied to re-position the primitives.

2.2.2 Regularized Boolean Operators

Each primitive divides the 3D space into two parts: the one that is inside the primitiveand the one that is outside. The closure of a primitive is the surface that separates its

Page 16: An introduction to Geometrical Modelling and Mesh Generation The ...

16 CHAPTER 2. SOLID MODELS

interior with its exterior.

It is easy to think a primitive as a set where standard boolean operations like union,intersection and difference can be defined. Basic primitives can be combined using booleanoperations. Three boolean operators are defined. Consider two primitives A and B.

1. The Union A∪B operation returns of all the points x ∈ R3 that are either inside Aor inside B.

2. The Intersection A ∩ B operation returns of all the points x ∈ R3 that are bothinside A and inside B.

3. The Difference A \ B operation returns of all the points x ∈ R3 that are inside Aand outside B.

Regularized boolean operators differ from the set-theoretic ones in that danglinglower 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 treeare simple primitives, nodes of the tree are solids, edges of the tree are boolean operationsand where the root of the tree is a solid that is the final CSG object. Figure 2.2 shows anexample of a simple CSG tree.

Most of the current commercial solid modelers enable to use CSG trees. Designingrobust 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 efficiently and, to our best knowledge, only one is open source. In Gmsh, we haveinterfaced Opencascade primitives and operators to build the solid of Figure 2.2. TheGmsh 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);

Page 17: An introduction to Geometrical Modelling and Mesh Generation The ...

2.2. CSG REPRESENTATION OF SOLIDS 17

\

Figure 2.2: Example of a CSG tree.

Page 18: An introduction to Geometrical Modelling and Mesh Generation The ...

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. TheUnion A ∪ B returns A, i.e. the closure of B has been eliminated. The Difference A \ Breturns a sphere with a hole. At some point, it can be useful to build

C = (A \B)⊕ (A ∩B)

where ⊕ is not a regularized boolean operator but that simply adds the two volumes A\Band A ∩ B in the same model. The model contains two volumes that share a commonboundary. Our aim here being to build a model that has a topology, vertices, edges andfaces that are geometrically identical should be glued together in order to defined a propertopology 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. Thisconstruction allows to test wether a point is inside or a solid, is on its surface or is outsideof it. This is usually called point/solid classification. Point/solid classification can bedone walking first downward the CSG tree in order to classify the point with respect tothe primitive that are on the leaves. Then, an upward sweep enables to apply the booleanoperations that will determine the classification.

Yet, CSG representation alone cannot represent accurately the boundaries of thesolid. CSG representation are “top-down” representations because they consider highlevel primitives and combine them to represent complex parts. It is indeed possible toimagine a “bottom-up” representation where every model entity is represented using itsboundary.

The boundary representation of a model also allows to determine whether a positionis inside, outside, or on the boundary of a volume. This distinguishes a solid modeler froma surface or wireframe modeler. The “boundary” in “boundary representation” is theboundary between solid material and empty space. This boundary is made from a closedset of surfaces.

It is common to distinguish the topological part of the boundary representation andits geometrical part.

Topology is a branch of mathematics concerned with spatial properties preserved

Page 19: An introduction to Geometrical Modelling and Mesh Generation The ...

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 defines a ”rubber” model, whose position is notfixed in space. For example, a sphere and a cube are topologically equivalent, but notgeometrically.

A topological entity’s shape, position, and orientation are fixed in space when it isassociated 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 topologicallyorienting it so that, for any point x ∈ R3, we can tell on which side of the solid this pointlies.

There exist a variety of data structures that allow to represent the topology of solidmodels on a computer. In what follows, we will present the classical winged-edge datastructure. Then, we’ll present a more sophisticated version that allow to represent non-manifold models. Then, we’ll present the way Gmsh stores the topology of models, withthe 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 datastructure. The winged-edge data structure was initially used for representing polygonalmeshes. A common way to represent a polygonal mesh is to define a list of vertices anda list of faces storing pointers for its vertices. This representation is both convenientand efficient for many purposes, however it proves ineffective for dynamically modifyingmeshes.

The winged-edge data structure has been designed to allow effective local modifi-cation of the topology. It describes the topology of objects by three tables. A face isbounded by closed loops of edges, one of which is the outside boundary (usually the firstone) and the other ones are inner holes. Each vertex stores a circularly ordered set ofadjacent 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 orientationis given by its starting and ending vertex. Clockwise and counterclockwise orientationsare given with respect of the orientation of the edge (see Figure 2.3). Operations on edges

Page 20: An introduction to Geometrical Modelling and Mesh Generation The ...

20 CHAPTER 2. SOLID MODELS

non manifold zero genus genus one

Figure 2.4: A non manifold solid(left) and two different topologies generated through asmall variation of the geometry.

like splitting, collapsing or flipping can be performed by doing local operations only.

The winged-edge data structure assumes that every edge of the model has exactlytwo adjacent faces. This restricts the topology of surfaces to be 2-manifolds. A surfaceembedded in R3 is a 2-manifold if every point x has a neighborhood that can be mappedcontinuously into an open set of R2.

2.4.2 Manifold and Non-Manifold models

A manifold model only contains manifold surfaces. The topological properties of manifoldrepresentations are well understood mathematically. Restricting our attention to manifoldsis attractive because of this mathematical theory. Yet, the result of boolean operations onmanifold solids can lead to a result that is non-manifold. Let us consider the example inFigure 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 (actually4). Any point of this edge has non neighborhood that can be mapped to a subset of R3.

The resulting figure is non-manifold. Indeed, even if the result of those two booleanoperations is one only solid, it is impossible to define a proper genus to the surface that

Page 21: An introduction to Geometrical Modelling and Mesh Generation The ...

2.4. TOPOLOGICAL REPRESENTATION 21

bounds this solid. Slightly different parameters enables to generate either a surface withgenus one or genus zero (see Figure 2.4).

2.4.3 Non-manifold topologies

Here, we describe Weiler’s radial edge non manifold topology data structure. This datastructure is more or less the one that is used in solid modelers like OpenCascade orACIS. Both those solid modelers have been interfaced in Gmsh’s abstract topological datastructure. The different entities that appear in such a topology are described below. Theintroduction 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. Fora volume the lump includes not only the points on the boundary of the volume, but alsothe points in the interior of the volume. For sheets and wires there is no interior; so theyconsist strictly of the points on the boundary. Lumps are not necessary. You could designa topological structure without them. They are sometimes included in the topologicalstructure for efficiency.

Shell

A shell is a connected set of boundary elements. For sheet bodies and wire bodies, thereis a one-to-one correspondence between lumps and shells. In other words, a sheet body orwire body with a single lump will have a single shell. For solid bodies, there can be morethan one shell per lump, when there is an interior void in the volume.

Face

A face defines a bounded region on a surface. A face may be a sheet face, in which caseit is exterior to all solid regions, or a face may bound a solid region, in which case itseparates the inside of the solid from the outside of the solid, or a face may be embeddedinside a solid region. A face may be bounded by 0, 1, or more loops of edges. Usually ifa face has multiple loops, it has holes in it, although a loop may degenerate to a singlepoint, in which case the hole is infinitesimally small. A common example of a face withtwo loops, one of which that has degenerated to a single point is a conical face (or anysurface of revolution that contains a point on the revolution axis), where the degenerateloop is at the apex of the cone.

Page 22: An introduction to Geometrical Modelling and Mesh Generation The ...

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 coedgesseparates the region that is inside the face from the region that is outside the face. Thedirection of a loop of coedges is counter clockwise with respect to an outward pointing facenormal. Multiple loops are required on a face if there are holes in the face, in a similarway as lumps may have multiple shells. Loops are closed, having no actual start or endpoint.

Wire

A wire is a set of connected free edges i.e. that do not bound faces. Wires may contain oneor 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 beinterpreted as a 1D inclusion in the volume. A wire cannot be both inside and outside avolume.

Coedge

Coedges represent the use of an edge by upper topology. The introduction of coedgesallow to represent regions that are non-manifold along an edge. If an edge is used by awire, then the edge will have a single coedge. If an edge is used by one or more faces, itwill 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 usedtwice by a face

• A spur edge is an edge that is not closed and it does not connect to another edge onone or both ends. In other words, on one or both ends it has a free vertex or a spurvertex. 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 aspur edge. It has adjacent edges at both ends. The exception to this if one or bothof the vertices lie at singularities. A spur edge may have a vertex at which thereare no adjacent edges if the vertex lies at a surface singularity. Prop edges and spuredges are mutually exclusive.

• A seam edge is a special case of a prop edge. If a prop edge runs along the parametricboundary of a periodic surface (that is, it splits the face along parametric boundaryof 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 beremoved by merging.

Page 23: An introduction to Geometrical Modelling and Mesh Generation The ...

2.4. TOPOLOGICAL REPRESENTATION 23

G11

G21

G12

G14

G13

G03

G02

G04

G05

G01

G15

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 manyfaces. The faces bounded by an edge are obtained from the coedges of the edge. Eachcoedge represents the use of an edge by a face (or a wire). An edge has a direction: ithas 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 categorizedaccording to their closure. For instance, if an edge has two distinct vertices, then the edgeis open. If the edge start and end vertices of an edge are the same, the edge is closed. Ifthe edge is closed and underlying curve’s start and end tangent directions are the same,then the edge is periodic. Another special type of edge is one with zero length. Such anedge is considered to be a degenerate edge. If a degenerated edge resides in the middle ofa 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 modelhas 1 face, 5 edges and 5 vertices. It has 2 loops and every edge has only one use (i.e. oneco-edge).

Model edge G11’s boundary, ∂G1

1 consist in two signed vertices:

∂G11 = −G0

2 +G03

which means that model edge G11 goes from model vertex G0

2 to model vertex G03.

Page 24: An introduction to Geometrical Modelling and Mesh Generation The ...

24 CHAPTER 2. SOLID MODELS

Model face G21’s boundary consist in two closed edge loops that consist of respectively

four and one signed model edges:

(2.1) ∂G21 = −G1

1 +G14 +G1

3 −G12, G

51.

Model edge G15 is periodic:

∂G51 = G0

5 −G05 = 0

which makes perfect sense: the boundary of a closed curve is zero. For being consistent,the boundary of a closed edge loop has also to be zero. In other words,

∂∂G21 = −∂G1

1 + ∂G12 + ∂G1

3 − ∂G14, ∂G

51

= −(G03 −G2

0) + (G04 −G2

3) + (G04 −G2

1)− (G01 −G2

2), G05 −G0

5= 0, 0.

Vertices that bound model curves of a model face have to appear once positively and oncenegatively. Two things have to be noted. First, ∂G0

i = i.e. the boundary of a modelvertex is zero. Then, changing the sign of the boundary representation of a model face

(2.2) − ∂G21 = −−G1

1 +G14 +G1

3 −G12, G

51.

gives the same topological model face, yet with a different sign i.e. a different orientation.

Then, a model region can also be described using its boundary representation. Forexample the cube of Figure 2.6 with one model region G3

1 consist in one closed face loop

∂G31 = G2

1 +G22 +G2

3 +G24 +G2

5 +G26 +G2

7 +G28

with model face orientations that have to verify

∂∂G31 = 0.

Let us now consider the cylindrical rod of Figure 2.7. The model region G31 is

bounded by three model faces

∂G31 = G2

1 +G22 +G2

3.

Model faces G21 and G2

2 are usual model faces composed of one only closed edge loop:

∂G21 = G1

1 and ∂G22 = −G1

3.

Model face G23 is different. It is a periodic model face and it has no interior holes. In order

to be consistent with the boundary representation, its boundary representation should beone single closed loop. In order to achieve that goal, one seam edge, G1

1, has to be addedin the model. This seam edge acts like G0

4 which is both the starting point and the endingpoint of G1

3. We have then

∂G23 = G1

1 +G13 −G1

1 −G12.

Page 25: An introduction to Geometrical Modelling and Mesh Generation The ...

2.4. TOPOLOGICAL REPRESENTATION 25

G16

G19

G18

G12

G15

G07

G110

G111

G112

G04G0

3

G01

G05 G0

6

G08

G11

G21

G14

G13

G02

G22

G23

G17

Figure 2.6: A cube.

The seam model edge G11 appears twice in the same face loop and effectively acts as a

seam that closes the periodic model face.

Figure 2.8, which shows one of the 76 model faces of the propeller in the parametricspace (left) and in real space (right). Three features of surface S, common in CADdescriptions, make its meshing non-trivial:

1. S is periodic. The topology of the model face is modified in order to define its closureproperly. A seam is present two times in the closure of the model face. These twooccurrences are separated by one period in the parametric space.

2. S is trimmed: it contains four holes and one of them is crossed by the seam.

3. One of the model edges of S is degenerated. This is done for accounting of a singularpoint in the parametrization of the surface. This kind of degeneracy is present inmany 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 withthe few well-established, state of the art CAD engines [?, ?, ?, ?]. The native Gmsh CADengine thus has only a limited set of features, well suited for dealing with simple academicgeometries. Yet, over the years, Gmsh has been used by an increasing number of peoplein industry, and a strong demand emerged from this user community for Gmsh to be ablemesh industrial CAD models.

Page 26: An introduction to Geometrical Modelling and Mesh Generation The ...

26 CHAPTER 2. SOLID MODELS

G04

G05

G11

G12

G21

G22

G23

G13

Figure 2.7: A cylindrical rod.

One option for addressing this demand is to use exchange files, such as IGES (InitialGraphics Exchange Specification), VRML (Virtual Reality Markup Language) or STEP(STandard for the Exchange of Product model data). However, the use of such exchangefile formats has always been a cause of trouble in engineering design offices, mainly becauseinternal data structures of CAD systems are usually much richer than those in the exchangeformats.

Those differences 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 actuallythe same technique in Open CASCADE that does not make a difference between them.ACIS kernel does make a little difference, in terms of types of the inputs parameters andway of constraints definition. Even though differences are small, a translation betweenACIS and Open CASCADE will generate modelling errors.

Another issue is the importance of modeler tolerances that are not taken into accountin exchange files. Translations always lead to the time-consuming need to “fix” most ofthese exchange files before any meshing can be performed.

In Gmsh, we thus chose to deal with CAD engines differently, by providing nativeaccess to the underlying CAD models—without translation files (a similar approach isused in CAPRI [?]). For that, the geometry module is based on a set of abstract datastructures that enables us to represent the topology of virtually any solid model.

Page 27: An introduction to Geometrical Modelling and Mesh Generation The ...

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: thereexist a limited number of big players in the CAD modeler market: CATIA (DassaultSystemes), 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, TopSolidand MicroStation use Parasolid (Siemens), IronCADTM and Cobalt use ACIS (Das-sault Systemes). 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 defined using a Boundary Representation. InGmsh, only four kinds of model entities are defined:

1. Model Vertices G0i that are topological entities of dimension 0,

2. Model Edges G1i that are topological entities of dimension 1,

3. Model Faces G2i that are topological entities of dimension 2,

4. Model Regions G3i that are topological entities of dimension 3.

Those 4 entities are the only ones that are common to every modelling kernel that wefound. In fact, those are the only ones that have an associated geometry. Model entitiesare topological entities, i.e., they only deal with adjacencies in the model, and we use a

Page 28: An introduction to Geometrical Modelling and Mesh Generation The ...

28 CHAPTER 2. SOLID MODELS

bi-directional data structure [?] for representing the graph of adjacencies. In this represen-tation, a model entity Gdi of dimension d holds one lists of upward adjacencies Gd+1

j (Gdi ),i.e., all its adjacent entities of dimension d + 1, and one list of downward adjacencies ofdimension d− 1, Gd−1j (Gdi ). Schematically, we have

G0i G1

i G2i G3

i .

This representation is said to be complete because any model entity is able to build itslist of adjacencies of any dimension using local operations, i.e., without having to do acomplete traversal of the adjacency graph of the model.

Each model entity Gdi has a shape, a geometry. More precisely, it is a manifold ofdimension d that is embedded in 3-D space. (Note that the overall geometric model mayitself be non-manifold: Gmsh supports non-manifold features).

The geometry of a model entity depends on the solid modeler kernel for its underlyingrepresentation. Solid modelers provide a parametrization of the shapes, i.e., a mappingx ∈ Rd 7→ p ∈ R3:

1. The geometry of a model vertex G0i is simply its 3-D location xi = (xi, yi, zi).

2. The geometry of a model edge G1i is its underlying curve Ci with its parametrization

p(t) ∈ Ci, t ∈ [t1, t2].

3. The geometry of a model face G2i is its underlying surface Si with its parametrization

p(u, v) ∈ Si. Note that, for any curve Cj that is on a surface Si, mesh generationprocedures require the ability to reparametrize any point p(t) ∈ Cj on the surfaceSi, i.e., to compute the mapping u = u(t) and v = v(t). Gmsh either uses a bruteforce algorithm to compute the direct mapping x = x(t), y = y(t) and z = z(t) andits inverse u = u(x, y, z) and v = v(x, y, z) (see Figure 2.9), or, when the underlyingCAD system provides it, the direct reparametrization of a point on a model face(i.e., a function that directly computes u = u(t) and v = v(t)).

4. The geometry associated to a model region is R3.

Solid modelers usually provide an API for the creation, manipulation, interrogationand storage of 3-D models. To perform mesh generation only a small subset of this API hasto be interfaced—only some of the interrogation functions are necessary. In order to getthe full functionality of Gmsh, only five CAD-system dependent interrogation functionshave to be implemented for the model edge (see Figure 2.10). For example, it is mandatoryto be able to evaluate the mapping p(t) ∈ C on the curve as well as the tangent vectort(t) = ∂tp(t). For the model face, only four functions have to be overloaded in orderto enable 2-D mesh generation (see Figure 2.11). Note that the default 2-D algorithmdoes not require the computation of derivatives of the surface parametrization, so that thefunction modelFace::tangent is not strictly required (a description of this 2-D algorithmis presented in Section ??). The other 2-D algorithms available in Gmsh, as well as most

Page 29: An introduction to Geometrical Modelling and Mesh Generation The ...

2.4. TOPOLOGICAL REPRESENTATION 29

p(x)p(u)u = u(x)v = v(x)

t1 tt2

z

y

x

x = x(t), y = y(t), z = z(t)u = u(t), v = v(t)

S

v

u

S ′

C C

Cp(t)

Figure 2.9: Point p located on the curve C that is itself embedded in a 2D surface S ′ (left)or a 3D surface S (right).

class modelEdge : public modelEntity

// bi-directional data structure

modelVertex *v1, *v2;

std::list<modelFace*> faces;

public:

// pure virtual functions that have to be overloaded

// for every solid modeler

virtual std::pair<double> parRange() = 0;

virtual Point3 value(double t) = 0;

virtual Vector3 tangent(double t) = 0;

virtual Point2 reparam(modelFace *mf, double t, int dir) = 0;

virtual bool isSeam(modelFace *mf) = 0;

// other functions of the class are non pure virtual

// ...

;

Figure 2.10: A part of the model edge class description. modelEdge::parRange returns therange for the parameter in the curve. modelEdge::value returns the 3-D point p(t) that islocated on the curve C for a given parameter t. modelEdge::tangent evaluates the tangentvector ∂tp(t) for a given parameter t. modelEdge::reparam computes the local parametersof the point p(t) on a model face mf that has C in its closure, modelEdge::isSeam tells ifthe curve is or is not a seam of the face mf. Generally, seam edges are used to maintainconsistency of data structure for periodic surfaces.

Page 30: An introduction to Geometrical Modelling and Mesh Generation The ...

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 returnsthe range for the parameter in the surface in direction dir. modelFace::value returnsthe 3-D point p(u, v) that is located on the surface S for the given parameter couple(u, v). modelFace::tangent the evaluates two tangent vectors ∂up(u, v) and ∂vp(u, v).The modelFace::curvature function computes the divergence of the unit normal vectorat (u, v). This last function is used for the definition of mesh size fields. It is not a purevirtual function: a default implementation is available using finite differences.

Page 31: An introduction to Geometrical Modelling and Mesh Generation The ...

2.5. GEOMETRICAL REPRESENTATION 31

of the available 2-D meshers (e.g. bamg [?] or blsurf [?]), make use of derivatives of theparametrization.

To date, Gmsh is interfaced with Open CASCADE and ACIS. It also contains anaive solid modeler kernel that do not provide boolean operations.

2.5 Geometrical Representation

Each model entity Gdi has a shape, a geometry. More precisely, it is a manifold of dimensiond that is embedded in 3-D space.

Solid modelers usually provide a parametrization of the shapes, i.e., a mappingx ∈ Rd 7→ x ∈ R3. The geometry of a model vertex G0

i is simply its 3-D locationx = (x1, x2, x3).

The geometry of a model edge G1i is its underlying curve Ci with its parametrization

(2.3) t ∈ [t1, t2] 7→ x(t) ∈ R3.

The geometry of a model face G2i is its underlying surface Si with its parametrization

(u, v) ∈ R2 7→ x(u, v) ∈ R3.

The geometry associated to a model region is R3.

If a curve is included within a surface, it is usually drawn on the parameter plane(u, v) of the surface:

(2.4) t ∈ [t1, t2] 7→ (u, v) ∈ R2 7→ x (u(t), v(t)) ∈ R3.

2.5.1 Differential Geometry of Curves

A parameterization of a curve is a bijective mapping from a 1D domain to the 3D curve.The mapping can be defined as follows:

(2.5) t ∈ R1 7→ x(t) ∈ R3.

Consider a segment of curve C defined by a range of parameter t ∈ [ta, tb], ta ≥ t1, tb ≤ t2.The length of that segment can be computed as∫

Cdl

with dl =√dx21 + dx22 + dx23. Using C’s parametrization (2.3), we have∫

C

√dx21 + dx22 + dx23 =

∫ tb

ta

√x21,t + x22,t + x23,t dt

=

∫ tb

ta

‖x,t‖ dt

Page 32: An introduction to Geometrical Modelling and Mesh Generation The ...

32 CHAPTER 2. SOLID MODELS

This can be easily extended to the computation of integral quantities over model edges:∫Cf(x1, x2, x3)dl =

∫ tb

ta

f(x1(t), x2(t), x3(t)) ‖x,t‖ dt(2.6)

The curvilinear abscissa l(t) of a point x(t) of curve C, is the length of the segmentdefined by parameter range [t1, t], i.e. the length of the curve from the origin x(t1) to x(t):

l(t) =

∫ t

t1

‖x,t‖ dt(2.7)

We have seen before that dl = ‖x,t‖ dt.

A parametrization of C is said to be regular if ‖x,t‖ 6= 0. For regular parametriza-tions, the unit tangent vector is defined 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 normalvector (see Figure 2.12). The curvature of the curve at a point x can be defined as theamplitude of the variations of the unit tangent t along the curve. The vector t,l is obviouslyorthogonal to t because t’s 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,tx,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 defined the curvature as the amplitude of thevariations 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 tl.Remembering that

‖a× b‖2 = ‖a‖2‖b‖2 sin2(a,b) = ‖a‖2‖b‖2(

1− (a · b)2

‖a‖2‖b‖2

)= ‖a‖2‖b‖2 − (a · b)2,

Page 33: An introduction to Geometrical Modelling and Mesh Generation The ...

2.5. GEOMETRICAL REPRESENTATION 33

t

x(t)

t(t)

n(t) C

x2

x3

x1

t2t1

1/C

Figure 2.12: A curve C defined by the mapping x(t).

it is easy to see that

C2 =1

‖x,t‖6(‖x,t‖2‖x,tt‖2 − (x,tt · x,t)2

)=

1

‖x,t‖6‖xt × x,tt‖2

and we get the formula

(2.8) C =‖xt × x,tt‖‖x,t‖3

.

Consider the function y = f(x) in the (x, y) plane. Its parametric representation is x(t) = tand 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 define a local system of coordinates at any point x of the curve

(t,n,b)

with b = t × n. This system of coordinates is usually called the Frenet frame. Theosculating plane of the curve at point x can be defined as the plane containing x andnormal to b. The curvature C(t) is the inverse of the radius of the osculating circle atpoint 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.

Page 34: An introduction to Geometrical Modelling and Mesh Generation The ...

34 CHAPTER 2. SOLID MODELS

S

x2

x1

x3

S ′

x(u, v)

v

u

θ

x,v

x,u

x,u × x,v

Figure 2.13: A surface S defined by the mapping x(u, v).

2.5.2 Differential Geometry of Surfaces

A parameterization of a surface is a bijective mapping from a suitable two-dimensionaldomain S ′ to the 3D surface S (see Figure 2.13). In CAD modelers, surfaces have ex-plicit parametrizations i.e. their parametrization is given explicitly as a continuous anddifferentiable function:

(2.10) (u, v) ∈ S ′ ⊂ R2 7→ x(u, v) ∈ S ⊂ R3.

Such a parametrization exists if the two surfaces S and S ′ have the same topology, i.e areboth zero genus surfaces (G = 0) and have at least one boundary (NB ≥ 1)1.

Given the parametrization x(u), let us compute fundamental properties of surfacessuch as lengths, angles, areas and curvatures. Consider a curve that is included in surfaceS. It is easy to extend the integration formula (2.6) as:

∫C

f(x, y, z)√dx2 + dy2 + dz2

=

∫Cf(x, y, z)

√‖x,u‖2 du2 + 2 x,u · x,vdu dv + ‖x,v‖2 dv2

=

∫Cf(x, y, z)

√[dudv

]T [x,u · x,u x,u · x,vx,v · x,u x,v · x,v

] [dudv

]=

∫Cf(x, y, z)

√duTM du.(2.11)

1For example, a sphere has G = 0 and NB = 0 and a torus has G = 1 and NB = 0.

Page 35: An introduction to Geometrical Modelling and Mesh Generation The ...

2.5. GEOMETRICAL REPRESENTATION 35

In (2.12), the matrix M is called the metric tensor or first fundamental form. It isdefined as follows:

(2.12) M = xT,ux,u =

[x,u · x,u x,u · x,vx,v · x,u x,v · x,v

]=

[E FF G

]The metric tensor is a symmetric definite positive second order tensor that varies smoothlyover the manifold and that has two real eigenvalues.

We have just seen that the tensor metric enables to measure curve lengths drawnin the parametric plane. It also allows to generalizes many familiar properties of thedot product of vectors in Euclidean space. In particular, it allows to compute the anglebetween two tangent vectors to the surface as well as areas. Any tangent vector at a pointof the parametric surface can be written in the form

t = ax,u + bx,v

with a, b ∈ R. Let us consider two tangent vectors

t1 = a1x,u + b1x,v and t2 = a2x,u + b2x,v.

Coordinates a = (a1, a2) and b = (b1, b2) are called covariant coordinates of t1 and t2.We have

t1 · t2 = a1a2x,u · x,u + (a1b2 + a2b1)x,u · x,v + b1b2x,v · x,v = aTMb,

which gives us the angle θ between the two tangent vectors (see Fig.2.13):

(2.13) θ = arccos

(aTMb

t1t2

)Consider a small rectangle du dv at a point on the parametric plane. Its area on the 3Dsurface is given by:

(2.14) s = ‖x,udu× x,vdv‖ = 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 thecurvature. Let us first define the unit surface normal n that is orthogonal to both tangentvectors:

(2.15) n =x,u × x,v‖x,u × x,v‖

=x,u × x,v√

det M=

x,u × x,v√EG− F 2

.

The three vectors (x,u,x,v,n) form at each point of the surface a local system of coordinatesusually called the local frame. It is easy to orthonormalize the local frame, i.e. by choosing

t1 =x,u‖x,u‖

, t2 = n× t1

Page 36: An introduction to Geometrical Modelling and Mesh Generation The ...

36 CHAPTER 2. SOLID MODELS

so that vectors (t1, t2,n) form an orthonormal system of coordinates usually called theDarboux frame. To study the curvature of the surface at a point x, one can examine thevariations of the unit normal n around x. In particular, one can derivate n in the directionspecified by the tangent vectors at x: this is called the Weingarten map. Note that n,uand 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 theWeingarten equations that express the derivatives of the normal to a surface using deriva-tives of the position vector x

n,u =MF − LGEG− F 2

x,u +LF −ME

EG− F 2x,v

n,v =NF −MG

EG− F 2x,u +

MF −NEEG− F 2

x,v

where the scalars e, f and g are defined as:

L = n · x,uu, M = n · x,uv and N = n · x,vv.

Those scalars define the curvature tensor or second fundamental tensor of the surfacedenoted M2:

(2.16) M2 =

[L MM N

]The curvature tensor is a tensor, and like for any tensor, some invariants can be definedthat are independent of the system of coordinates. In other words, invariants are intrinsicmeasures of the curvature, i.e., their value depends only on how distances are measured onthe surface, not on the way it is embedded in space. The principal curvatures κ1 and κ2are the two eigenvalues of M2. They are the largest and smallest values of the curvatureat a point. The mean curvature κ = κ1 + κ2 is proportional to the trace of the curvaturetensor and κ is therefore an invariant of the tensor. It is easy to see that

(2.17) κ = ∇ · n =1

2trace

(M2

M

)=LG− 2MF +NE

2 (EG− F 2).

The Gaussian curvature κ of a point on a surface is the square root of the product of theprincipal curvatures, κ1 and κ2, of the given point. Its value can be computed as

(2.18) κ =det M2

det M=LN −M2

EG− F 2.

Page 37: An introduction to Geometrical Modelling and Mesh Generation The ...

2.5. GEOMETRICAL REPRESENTATION 37

2.5.3 Classifying the parametrizations

By studying how the surface lengths, angles and areas vary during the mapping (andhence how the metric tensor and associated eigenvalues vary) (2.10) we can classify theparametrizations (mappings) by looking at the eigenvalues λ1 and λ2 of the metric tensorM (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 cylindricalcoordinates into cartesian coordinates is isometric. The following relation holdq:

x(u) is isometric ⇐⇒M =

[1 00 1

]⇐⇒ λ1 = λ2 = 1.

• A mapping is conformal or angle-preserving if the angle of intersection of everypair of intersecting curves is the same on the parametric plane and on the surface.For example, the stereographic and Mercator projections are conformal maps fromthe sphere to the plane. The following relation holds:

x(u) is conformal ⇐⇒M =

[η 00 η

]⇐⇒ λ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. Wehave 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 mappingis 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 justabout 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. surfaceswith zero Gaussian curvature (planes, cylinders and cones). Many approaches to surfaceparameterization therefore attempt to find a mapping which either

• is conformal, i.e., has no distortion in angles, or

• is equiareal, i.e., has no distortion in areas, or

• minimizes some combination of angle distortion and area distortion.

Page 38: An introduction to Geometrical Modelling and Mesh Generation The ...

38 CHAPTER 2. SOLID MODELS

2.5.4 Computing harmonic and conformal maps

One possible mapping can be found by minimizing the area functional A(x) that is thearea of the mapping x(u). This area functional can be computed by combining equationsof the area (2.14) and the metric tensor (2.12):

(2.19) A(x) =

∫S′‖ x,u × x,v‖ dudv =

∫S′

√EG− F 2dudv,

where E,D and G are the coefficients of the metric tensor M.

As can be seen, this area functional is in general complicated to compute. A lofof approaches in numerical approximation of minimal surface do not minimize the areafunctional directly. Instead, they try to minimize the following functional called Dirichletenery ED(x):

(2.20) ED(x) =1

2

∫S′‖∇x‖2dudv =

1

2

∫S′

(x2,u + x2

,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) ∇2x = x,uu + x,vv.

One should note that since the mapping is a bijective function, the following Laplacianequation also minimizes the Dirichet energy:

(2.22) ∇2u = 0↔ minuED(u) = min

u

1

2

∫S‖∇u‖2ds.

The area functional A(x) and the Dirichlet energy ED(x) have the following relation:

(2.23) A(x) =

∫S′

√EG− F 2dudv ≤

∫S′

√EGdudv ≤ 1

2

∫S′

(E +G)dudv = ED(x)

It is simple to verify that the first inequality becomes an equality if F = 0, i.e. if x,u · x,vis zero everywhere, while the second does if E = G, i.e if ‖x,u‖ = ‖x,v‖. It follows thatthe the minimum possible value of the Dirichlet energy is attained when there is no shapedistorsion anywhere, the resulting mapping is then called conformal mapping since

the corresponding mesh metric is then given by : M =

[E 00 E

]. If we only fix the

shape of the boundary of a parametric domain, but not the map from the boundary tothe surface, a conformal parameterization always exists for smooth surfaces and smoothdomain boundaries. As the conformal mapping also minimizes the Dirichlet energy, wehave the following implication for the mappings:

conformal =⇒ harmonic.

Page 39: An introduction to Geometrical Modelling and Mesh Generation The ...

2.5. GEOMETRICAL REPRESENTATION 39

How far from conformality is the mapping u(x) that is the solution of the twoLaplace equations (2.22) that minimize the Dirichlet energy ED(u)?

∇2u = 0 and ∇2v = 0.

It actually all depends on the boundary conditions of those equations. If we fix withappropriate Dirichlet boundary conditions the map u(x) on the boundary ∂S of the domainS to a fixed boundary in the parametric space (a circle, a squatre, etc.), full conformalitymay be impossible, but minimizing the Dirichlet energy will move us closer to a conformalmap, i.e. will reduce the distortion of shape. If on the other hand, we only fix the shapeof the boundary of a parametric domain (any planar curve), but not the map from theboundary to the surface, a conformal parameterization always exists for smooth surfacesand smooth domain boundaries. However, fixing the shape will introduce a couplingbetween the u and the v mapping coordinates that is not straighforward to implement.

It is therefore convenient to minimize another energy, the least square conformalenergy ELSCM as defined by Levy et al. [?]:

(2.24) ELSCM =

∫S

1

2‖∇u⊥ −∇v‖2ds,

where ⊥ denotes a counterclockwise 90 rotation on S (on the plane defined by the twovectors ∇u = u,x and ∇v = v,x) (see fig.2.14). Minimizing this energy is then equivalentto asking that the gradient of u and the gradient of v be as orthogonal as possible in theparametrization, which is the necessary condition for a conformal (angle preserving) map.Equation (2.24) can be simplified and rewritten as follows:

n

∇u∇v

iso-viso-u

S

u(x)

iso-u

iso-v

S ′

zy

x∇u⊥ = n×∇u

Figure 2.14: Definitions for a conformal mapping. ∇u⊥ denotes the counterclockwise 90

rotation of the gradient ∇u for a 3D surface.

ELSCM(u) =

∫S

1

2

(∇u⊥ · ∇u⊥ +∇v · ∇v − 2∇u⊥ · ∇v

)ds,

=

∫S

1

2

((∇u)2 + (∇v)2 − 2 (n×∇u) · ∇v

)ds.

(2.25)

Page 40: An introduction to Geometrical Modelling and Mesh Generation The ...

40 CHAPTER 2. SOLID MODELS

Recalling the idenity that a a ”dot” and a ”cross” can be interchanged without changingthe result, we can finally write the least square conformal energy as follows:

ELSCM(u) =

∫S

1

2

((∇u)2 + (∇v)2

)− n · (∇u×∇v) ds.(2.26)

= ED(u)−A(u).

It follows from (2.26) that the conformal energy is then simply defined as the dirichletfunctional ED(u) minus the area functional A(u).

Figure 2.15 shows two examples of mappings u(x) of a 3D surface S. The top figuresshows the harmonic map that is computed by minimizing the Dirichlet energy ED(u) andthe bottom figures show a conformal map that is obtained by minimizing the least squareconformal energy ELSCM (u). The iso-u and iso-v values that are visible on the 3D surfaceshow that the conformality is also almost achieved for the harmonic map except near thefixed boundaries.

uharm(x)iso-v

iso-u

S S

iso-v

iso-u

S ′S

uconf (x)

Figure 2.15: Example of harmonic (top) and conformal map (bottom) for the mappingof a surface S that have been computed respectively by minimizing the Dirichlet energyED(u) and the least square conformal energy ELSCM (u). The iso-u and iso-v values arevisible on the 3D surfaces and it can be shown that the conformality is almost achievedfor the harmonic map except near the fixed boundaries.

Page 41: An introduction to Geometrical Modelling and Mesh Generation The ...

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 S such as cylinders and spheres, an analyticalparametrization can be derived.

Cylindrical coordinates

A first simple example of such an analytical parameterization are cylindrical coordinates.Imagine an open cylinder (without bottom and top) being cut open along its side andunrolled in the plane. This gives a rectangle and there exists a natural bijective mappingbetween the points in this rectangle and the points on the surface of the cylinder. Thismapping is a parameterization of the cylinder surface and very handy, because it allows usto capture the cylinder by using only two coordinates u = φ and v = h in the parameterdomain instead of the three coordinates x, y, and z in space (see Fig.2.16). The mappingis 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 00 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 sphericalcoordinates u = φ and v = η (see Fig.2.17). The mapping is given by:

x(φ, η) =

xyz

=

R cos θ sinφR sin θ sinφR cosφ

.

Page 42: An introduction to Geometrical Modelling and Mesh Generation The ...

42 CHAPTER 2. SOLID MODELS

x3

er

φ

θ

x1

x2

x3

x1

x2

Figure 2.17: Spherical coordinates.

We have

x,φ =

R cos θ cosφR sin θ cosφ−R sinφ

, x,θ =

−R sin θ sinφR cos θ sinφ

0

and the metric tensor relative to that parametrization is

(2.29) M = R2

[1 00 sin2 φ

].

This parametrization is neither isometric, neither equiareal, neither conformal.

Stereographic projection

A third well-known example is the stereographic projection (see an example in Fig.2.18).The mapping from the surface of the sphere S to the parameter domain can be constructedas follows. For any point x = (x,y, z) on the sphere, consider the ray that connects anotherpoint s on the sphere. The corresponding parameter point u is the intersection π(x) ofthat ray with a plane S ′ perpendicular to the z axis. The parametrization is then definedfor 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 Poleand that the z-plane is the z = R plane. The parametrization and inverse parametrizationsu(x) and x(u)) can then be computed as the intersection of vector s − p with the plane

Page 43: An introduction to Geometrical Modelling and Mesh Generation The ...

2.5. GEOMETRICAL REPRESENTATION 43

u(x) = π(x)

S ′

x = (x, y, z)

π(x)u

yv

x

s

S

Figure 2.18: Stereographic projection.

z = R:

u(x) =

2R

R+ zx,

2R

R+ zy

,

x(u) =4R2

u2 + v2 + 4R2

u, v,R(4R2 − u2 + v2)

.

The metric tensor M for the stereographic projection is then given by:

(2.30) M =

[λ 00 λ

].

with

λ(u, v) =

(4R2

u2 + v2 + 4R2

).

Those two eigenvalues are equal: the stereographic mapping is therefore conformal. Thismeans that any infinitesimally small angle measured in the map is exactly the same asif measured on the corresponding point on the surface of the sphere. The mapping isneither isometric nor area-preserving: that is, it preserves neither distances nor the areasof figures.

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 stereographicprojection of the Antarctica. The radius of the Earth is chosen arbitrarily to R = 1. Noseam is required to define the overall domain and no singular point exists in the domainof interest.

Page 44: An introduction to Geometrical Modelling and Mesh Generation The ...

44 CHAPTER 2. SOLID MODELS

Figure 2.19: The World Ocean in stereographic coordinates.

2.6 Non-Uniform Rational b-Splines (NURBS)

Non-uniform rational B-splines (NURBS) are a family of parametric curves and surfaces.NURBS representations offer great flexibility and precision for handling both analytic andfree-form shapes.

NURBS curves and surfaces are useful for at least two reasons:

• They are invariant under affine as well as perspective transformations: operationslike rotations and translations can be applied to NURBS curves and surfaces byapplying them to their control points.

• They offer one common mathematical form for both standard analytical shapes (e.g.,conics) and free-form shapes.

2.6.1 NURBS curves

A NURBS curve C is a parametric curve with a parametrization

t ∈ [ta, tb] 7→ x(t) ∈ R3.

Page 45: An introduction to Geometrical Modelling and Mesh Generation The ...

2.6. NON-UNIFORM RATIONAL B-SPLINES (NURBS) 45

Control points

The geometry of a NURBS curve C is defined through a set of nc = n + 1 control pointsor poles pi, i = 0, . . . , n. A point x on the curve is computed by taking a weighted sumof some of the control points pi:

(2.31) x(t) =

n∑i=0

Ndi (t) pi

where the Ndi (t) are some shape functions of degree d.

Knots

In (2.31), the value of x(t) for a parameter t is only influenced by a finite number of controlpoints. Typically, for a NURBS of degree d, the maximum number of control points thatinfluences the NURBS for any parameter t is d+ 1.

The knot vector T = t0, . . . , tk is a sequence of parameter values t that determineswhere and how the control points affect the NURBS curve. For a non-periodic NURBS,the number of knots is equal to

k + 1 = nc + (d+ 1) ⇒ k = n+ (d+ 1).

We have of course that t0 = ta and tk = tb.

The knot vector divides the parametric space in intervals. For a curve of degreed, every shape function Nd

i of any control point is only nonzero in d + 1 intervals of theparameter space. Shape function overlap in parameter intervals. The number of overlapscorrespond to the number of control points that influence the NURBS shape in this interval(so the name control points).

Shape functions are polynomials of degree d that go smoothly to zero at boundariesof 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 resultingcurve 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 certainmultiplicity. The multiplicity of a knot is limited to the degree of the curve; since a highermultiplicity would split the curve into disjoint parts and it would leave control pointsunused.

The knot vector usually starts with a knot that has multiplicity equal to the order.This makes sense, since this activates the control points that have influence on the firstknot span. Similarly, the knot vector usually ends with a knot of that multiplicity. Curveswith such knot vectors start and end in a control point.

Page 46: An introduction to Geometrical Modelling and Mesh Generation The ...

46 CHAPTER 2. SOLID MODELS

The individual knot values are not meaningful by themselves; only the ratios of thedifference between the knot values matter. Hence, the knot vectors T = 0, 0, 1, 2, 3, 3 andT = 0, 0, 2, 4, 6, 6 produce the same curve. The positions of the knot values influencesthe mapping of parameter space to curve space.

Consider a cubic NURBS with nc = 7 control points.

• A knot vector T = 0, 0, 0, 0, 1, 2, 3, 4, 4, 4, 4 is the standard B-spline knot vector.This knot vector is of size 7+3+1 = 11 and defines 10 knot spans: (0,0), (0,0), (0,0),(0,1), (1,2), (2,3), (3,4),(4,4),(4,4) and (4,4). Shape function N3

1 defines the influenceof control point p1 on the curve. The number of parameter intervals required fordefining a proper 3rd order curve is d + 1 = 4 which means that N3

1 is non zerobetween t = t1 = 0 and t = t5 = 1. Shape function N3

2 is non zero betweent = t2 = 0 and t = t6 = 2, N3

3 is non zero between t = t3 = 0 and t = t7 = 3 and N34

is non zero between t = t4 = 0 and t = t8 = 4 which is the whole interval.

• A knot vector T = 0, 0, 0, 0, 1, 1, 1, 4, 4, 4, 4 defines piecewise Bezier curves. Thisknot vector of size m = 11 = 7+3+1 defines 10 knot spans: (0,0), (0,0), (0,0), (0,1),(1,1), (1,1), (1,2),(2,2),(2,2) and (2,2). N3

1 , N32 , N3

3 , are non zero between t = 0 andt = 1 and N3

5 , N36 , N3

7 , are non zero between t = 1 and t = 4. Only N34 is non zero

on the whole interval.

B-spline Basis Functions

There are many ways to define B-spline basis functions and to demonstrate their interestingproperties. Here, we use the recursive definition since it is the most useful in practicalimplementations.

The B-spline functions at order d are defined recursively using functions at degreed− 1:

(2.32) Ndi (t) =

(t− ti)(ti+d − ti)

Nd−1i (t) +

(ti+1+d − t)(ti+1+d − ti+1)

Nd−1i+1 (t)

with the degree-0 functions (first order) Ni,1 being piecewise constant functions:

(2.33) N0i (t) =

1 if t ∈ [ti, ti+1[0 otherwise.

Those B-spline functions are positive because they are constructed recursively as positiveweighted sums of functions of lower order. They have a compact support since they areare non-zero only in the following interval:

Ndi (t) > 0, t ∈ [ti, ti+1+d[

Page 47: An introduction to Geometrical Modelling and Mesh Generation The ...

2.6. NON-UNIFORM RATIONAL B-SPLINES (NURBS) 47

Except for the d first and d last knot points, it can be proven by induction that theB-spline functions satisfy the partition of unity, i.e:

(2.34)n∑i=0

Ndi (t) = 1, t ∈ [td, tn−d[.

Non Uniform Rational B-splines (NURBS)

B-splines are non uniform when the knot vector is not uniformly distributed. This defineswhat could be called NUBS or non uniform B-splines.

Let us introduce a vector of positive weights W = w0, . . . , wn that has the size ofthe control points vector. The general form of a Non Uniform Rational B-spline (NURBS)curve is

(2.35) x(t) =

∑ni=0wiN

di (t) pi∑n

i=0wiNdi (t)

.

We observe that the weights introduce new rational basis function Rdi defined as:

Rdi (t) =

∑ni=0wiN

di (t)∑n

i=0wiNdi (t)

,

and we also note that when all the weights have value wi = 1, we have a B-spline curvesince Rdi (t) = Nd

i (t).

The main advantage of NURBS in CAD modelling is that NURBS can both representfree shapes and conics. A full circle can be represented using points placed on vertices andmid-edges of an equilateral triangle. Let us call s = sin(30) and c = cos(30). Consider 7control points

P = 2− c, s, 2c, 2s, c, s, 0, 0, 1, 0, 2, 0, 2− c, s,

with weights and knots

W = 1, 0.5, 1, 0.5, 1, 0.5, 1, T = 0, 0, 0, 1/3, 1/3, 2/3, 2/3, 1, 1, 1.

This NURBS is of degree p = 2 (order 3). It defines a complete circle that is tangent top0, p2 and p4.

2.6.2 NURBS surfaces

Recall that the geometry of a model faceG2 is its underlying surface S with its parametriza-tion x(u):

(u, v) ∈ R2 7→ x(u, v) ∈ R3.

Page 48: An introduction to Geometrical Modelling and Mesh Generation The ...

48 CHAPTER 2. SOLID MODELS

A B-spline surface S of order d in the u−direction and of order e in the v−direction is abivariate piecewise function of the form:

x(u, v) =n∑i=0

m∑j=0

pijNdi (u)N e

j (v).

Two knot vectors

TU = u0, . . . , uku and TV = v0, . . . , vkv

are defined, with ku = n+ (d+ 1) and kv = m+ (e+ 1).

NURBS surfaces can also use weights wij so that the most general form of theNURBS surface is written as

(2.36) x(u, v) =

∑ni=0

∑mj=0wijpijN

di (u)N e

j (v)∑ni=0

∑mj=0wijN

di (u)N e

j (v).

2.7 Surface Intersections

Solid modelers allow to perform boolean operations on Boundary representations. Thealgorithm for the evaluation of boolean operators on boundary representations can bestated as:

1. Determine the intersection of all edges of one object with the edges of the otherobjects 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 andsplit 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 theirintersection. We wish to trace the intersection curve, beginning at p. We define a tracedirection

t = ∇f ×∇g

Page 49: An introduction to Geometrical Modelling and Mesh Generation The ...

2.7. SURFACE INTERSECTIONS 49

that defines the tangent of the intersecting curve at point p. We have to assume herethat tangent vectors ∇f and ∇g are linearly independant, otherwise the two surfaces aretangent to each others at point p. If the gradients vanish at p or if they are colinear, thenthe intersection curve has a singularity at p.

Assume that the intersection is regular at p. Let us build a local parametrizationof the intersection at the neighborhood of p:

(2.37) x(t) = p + tx(1)(0) +t2

2x(2)(0) +

t3

6x(3)(0) + . . .

where x(m) is the m-the derivative of x with respect to t. It is then possible to buildan algorithm that traces the interface steb by step. The next point on the curve isfirst approximated as x(t). Then, a Newton iteration is used to bring the point to theintersection of f and g.

The idea here is to find derivatives x(m) using partial derivatives of f and g. Letus call x(y) = xp + dx, yp + dy, zp + dz a point of the intersection that is close top = xp, yp, zp = x(0). We have

f(x, y, z) = f(xp, yp, zp) + f,xdx+ f,ydy + f,zdz + . . .

or, in a closed form

(2.38) f(x, y, z) = f(xp, yp, zp) +∞∑

i,j,k=1

1

!i!j!kf,xiyjzkdx

idyjdzk

We look here for dx, dy and dz. Those are found using (2.37):

dx = dx, dy, dz = x(t)− p = tx(1)(0) +t2

2x(2)(0) +

t3

6x(3)(0) + . . .

In a similar manner, if we look for a third order approximation, we have

dx2 = (x(t)− xp)2 = (x(1))2t2 + x(1)x(2)t3 + . . .

dx3 = (x(t)− xp)3 = (x(1))3t3 + . . .

dx dy = (x(t)− xp)(y(t)− yp) = x(1)y(1)t2 + (x(2)y(1) + x(1)y(2))t3

2+ . . .

dx dy dz = (x(t)− xp)(y(t)− yp)(z(t)− zp) = x(1)y(1)z(1)t3 + . . .

Since x(t) is on f , f(x+dx, y+dy, z+dz) = 0. We can introduce values of dx, dx2, dx dy,... into (2.38) and zero all expressions factor of tm, m = 0, 1, 2, 3. This is of course trivialfor 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.

Page 50: An introduction to Geometrical Modelling and Mesh Generation The ...

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 intersectionof surfaces and show how hard this problem may be. Let us consider two surfaces S1 andS2 that have both a parametric representation and an implicit representation:

(2.39) S1 =

x(u1, v1) = x(u1, v1), y(u1, v1), z(u1, v1)f1(x, y, z) = 0.

and

(2.40) S2 =

x(u2, v2) = x(u2, v2), y(u2, v2), z(u2, v2)f2(x, y, z) = 0.

.

Let us consider the parametric plane (u, v) of S1. The intersection of the two surfaces canbe represented as the implicit curve g(u1, v1) that verifies the implicit representation ofS2:

g(u1, v1) = f2(x(u1, v1), y(u1, v1), z(u1, v1)) = 0.

In principle, this seems simple. Yet, the topology of the intersecting curve may becomecomplex, even for simple surfaces. As an example, consider two cylinders

(2.41) S1 =

x(u1, v1) = R1 cosu1, R1 sinu1, v1, u1 ∈ [0, 2π[, v1 ∈ <f1(x, y, z) = x2 + y2 −R2 = 0.

(2.42) S2 =

x(u2, v2) = u2, R2 cos v2, R2 sin v2, u2 ∈ <, v2 ∈ [0, 2π[f2(x, y, z) = y2 + z2 − r2 = 0.

We introduce the parametric representation of S1 in the implicit representation of S2 toobtain

R21 sin2 u1 + v21 −R2

2 = 0

which is an implicit equation g(u1, v1) = 0 that represents a curve in the parametric planeof S1. We obtain easily that

v1 = ±√R2

2 −R21 sin2 u1.

Imagine first that R2 > R1. In this case, the intersection is composed of two separateperiodic curves that divide the parameter plane in 3 regions (see Figure 2.20) so that theintersection is not simply connected. In the case R2 > R1, the intersection is composedof two closed curves in the parameter plane that dig two holes so that the intersectingsurface is simply connected, yet with two holes. The case R2 = R1 is the more complicated.There, two singular points are present in the intersection, where the curve is “non locallymanifold” i.e. a branching exists. For removing such singularity, it is useful in practice tointroduce a new model vertex that separates the parts of the intersecting curve that areadjacent to this model vertex (see Figure 2.21). Solving numerically surface intersections isa hard problem because the topology of the intersecting curves may become complicated:

Page 51: An introduction to Geometrical Modelling and Mesh Generation The ...

2.7. SURFACE INTERSECTIONS 51

Figure 2.20: Intersection of two cylinders S1 and S2. Figures show the intersection in theparameter plane of S1 for R2 > R1 (left), R2 = R1 (center) and R2 < R1 (right).

the intersecting curve may non be connected, singular points may appear and the solutionof g(u1, v1) may be complex. Building a robust code for doing such intersections takestime and experience so that few solid modelling kernels have survived the 1990’s.

Another way of proceeding is to use homogeneous coordinates. We transform theequations as

f1(x, y, z, w) = x2 + y2 − w2R2 = 0,

f2(x, y, z, w) = y2 + z2 − w2r2 = 0,

those having a singularity at the origin w = 0.

f1(x, y, z, w) = x2 + y2 − w2R2 = 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 algebraicsurface of degree d is of the form

f(x, y, z) =∑

i+j+k≤daijkx

iyjzk = 0.

An algebraic surface at order d has (d+ 1)(d+ 2)(d+ 3)/6 coefficients aijk.

For sake of simplicity, let us first consider the following bilinear surface:

x(u, v) = a0 + a1u+ a2v + a3uv

y(u, v) = b0 + b1u+ b2v + b3uv

z(u, v) = c0 + c1u+ c2v + c3uv

Page 52: An introduction to Geometrical Modelling and Mesh Generation The ...

52 CHAPTER 2. SOLID MODELS

Figure 2.21: Intersection of two cylinders S1 and S2 with R2 6= R1 (left) and R2 = R1

(right).

that we can rewrite as:

(a0 − x) + a1u+ a2v + a3uv = 0

(b0 − y) + b1u+ b2v + b3uv = 0

(c0 − z) + c1u+ c2v + c3uv = 0.

Our aim is to express those equations as an implicit function f(x, y, z) = 0. Here, we useSylvester’s Diadic Expansion that consist in considering all the individual monomials ofa polynomial as independant variables. Here, we have 3 equations and 4 “independantvariables” 1, u, v and uv.

Those equations can be multiplied either by u or v to form a set of 6 equations with6 “independant variables”. Assume that we multiply those equations by u, we obtain

(a0 − x) a1 a2 a3 0 0(b0 − y) b1 b2 b3 0 0(c0 − z) c1 c2 c3 0 0

0 (a0 − x) 0 a1 a2 a30 (b0 − y) 0 b1 b2 b30 (c0 − z) 0 c1 c2 c3

1uvuvu2

u2v

= 0.

Note here that the trick was to find the right set of monomials so that the number ofequations 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 theimplicit version of the surface, which is indeed a quadratic surface. More precisely, it is ahyperbolic paraboloid.

Page 53: An introduction to Geometrical Modelling and Mesh Generation The ...

2.8. GEODESICS 53

Consider now the case of a bivariate surface

Px(u, v) = f1(a | um, vn)− x = 0

Py(u, v) = f2(b | um, vn)− y = 0

Pz(u, v) = f3(c | um, vn)− z = 0.

We look for the conditions under which those 3 equations can be satisfied simultaneously.The strategy is analogous to what has been done for bilinear surfaces: our goal is still toarrive at a number of auxiliary equations, deduced from the parametric surface equations,equal to the number of “independant variables”. Yet, that method can introduce linearlyindependant 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 surfaceof degree d = 2mn,

• A rationale bivariate surface of degree n in u and m in v is also equivalent to analgebraic 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 implicitsurface of order 18! This would require the computation of (d+ 1)(d+ 2)(d+ 3)/6 = 1330terms.

2.7.4 Intersection of NURBS

The intersection of two cubic NURBS can then be seen as the intersection of an algebraicsurfaces S1 of degree 18 with a bicubic parametric surface S2.

The intersection verifies

(2.43)x(u1, v1) = Px(u, v), Py(u, v), Pz(u, v)f(x, y, z) =

∑i+j+k≤18 aijkx

iyjzk = 0.

where Px, Py and Pz are bicubic polynomials in u and v. We can then compute theintersection in the (u, v) plane as∑

i+j+k≤18aijkPx(u, v)iPy(u, v)jPz(u, v)k = 0

that is an algebraic planar curve of degree 3× 18 = 54!

2.8 Geodesics

Consider a surface S and two points with coordinates u1 and u2 on the parameter planeof S. There exists an infinity of paths (curves) on the surface that connect u1 and

Page 54: An introduction to Geometrical Modelling and Mesh Generation The ...

54 CHAPTER 2. SOLID MODELS

u2. In cartesian coordinates, the straight line is the shortest path between two points.Geodesics are the generalization of straight lines to metric spaces. Consider a curveu(t) = u(t), v(t), with u(t1) = u1 and u(t2) = u2, that is drawn on the parametricplane of S. Its length l is a functional

l(u,u,t) =

∫C

√duTM du =

∫ t2

t1

√uT,tM(u) u,t dt.

In order to minimize l, we use the calculus of variations and put to zero the firstvariation of the functional for all admissible variations of u.

Consider the following functional T :

l =

∫ t2

t1

F (t, y, y′)dt

with y′ = y,t. Using integration by parts, i.e.∫ x2

x1

fg′dx = −∫ x2

x1

f ′gdx+ fg|x2x1

we have

δl =

∫ t2

t1

(∂F

∂yδy +

∂F

∂y′δy′)dx

=

∫ t2

t1

(∂F

∂y− d

dt

(∂F

∂y′

))δydt+

∂F

∂y′δy

∣∣∣∣t2t1

=

∫ t2

t1

(∂F

∂y− d

dx

(∂F

∂y′

))δydt = 0

because δy = 0 on both t = t1 and t = t2. With arbitrary variations δy, one lemma of thecalculus 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 =√

uT,tM(u) u,t

Consider for example an isometric mapping, i.e. M is the identity. We have

F =√u2,t + v2,t.

The Euler-Lagrange equations are written as

− d

dt(2u,t) = 0 , − d

dt(2v,t) = 0

Page 55: An introduction to Geometrical Modelling and Mesh Generation The ...

2.8. GEODESICS 55

that have the simple solution that both u and v are linear in t which means that thegeodesic is the straight line.

Consider now the stereographic projection, i.e. a conformal mapping. We have

F =

(4R2

u2 + v2 + 4R2

).

A COMPLETER ...

Page 56: An introduction to Geometrical Modelling and Mesh Generation The ...

56 CHAPTER 2. SOLID MODELS

Page 57: An introduction to Geometrical Modelling and Mesh Generation The ...

Chapter 3

Mesh Generation

3.1 Generalities

The goal of a finite element analysis is to solve a set of partial differential equations overa geometrical domain G. The most common way to describe G is to use a boundary-basedscheme where the geometric domain is represented as a set of topological types togetherwith 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 whatwe’ve defined for the geometric model: it consists of

• A collection of mesh entities Mdi of controlled size and distribution;

• Topological relationships or adjacencies forming the graph of the mesh.

We have

1. Mesh Vertices M0i that are topological entities of dimension 0,

2. Mesh Edges M1i that are topological entities of dimension 1,

3. Mesh Faces M2i that are topological entities of dimension 2,

4. Mesh Regions M3i that are topological entities of dimension 3.

What differs is that mesh entities are more numerous than model entities but havelimited complexity.

Mesh entities are topologically equivalent to the unit d-dimensional sphere Sd =x ∈ Rd; ‖x‖2 < 1: they are made of one part, they are simply connected (a manifold issaid to be simply connected if every closed curve can be smoothly shrunk to a point) andthey have no holes.

57

Page 58: An introduction to Geometrical Modelling and Mesh Generation The ...

58 CHAPTER 3. MESH GENERATION

Mesh entities have simple shapes: they are are lines in 1D, triangles and quadranglesin 2D and tetrahedra, hexahedra and prisms in 3D.

Any mesh entity Mdi is a piece of the discretization of a geometric entity Gqj , d ≤ q

(a mesh entity must have dimensionality less than or equal to the geometry it is associatedwith). We call this association a classification of a mesh entity to a geometrical entity andwe note it as Md

i @ Gqj [?, ?, ?].

Simulation attributes like boundary conditions or material properties are naturallyrelated to model entities and not to mesh entities. In mesh generation and mesh enrich-ment procedures, the classification information is critical for ensuring that the mesh isconstructed so that it improves the geometric approximation of the domain when it is isrefined. It is therefore necessary to maintain the classification of mesh entities through allour algorithms.

A mesh M is composed of a collection of mesh entities together with their adjacencies.Any mesh entity bounds and/or is bounded by other ones of higher and/or lower dimension.This adjacency information represents the graph of a mesh.

It is interesting at this point to gather some statistics about the average number ofadjacencies per entity that occurs in usual three dimensional tetrahedral and hexahedralmeshes.

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 statethe Euler-Poincare formula, we need the following definitions:

• #V is the number of vertices in the cellular decomposition,

• #E is the number of edges in the cellular decomposition,

• #F is the number of faces in the cellular decomposition,

• G is the number of holes that penetrate the solid, usually referred to as genus intopology,

• H is the number of shells. A shell is an internal void of a solid. A shell is boundedby a 2-manifold surface, which can have its own genus value. Note that the soliditself 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. TheEuler-Poincare formula is

#V −#E + #F − (L−#F )− 2(S −H) = 0.

Page 59: An introduction to Geometrical Modelling and Mesh Generation The ...

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 oneouter 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 thefollowing relation between those quantities:

#V −#E + #F − χ(M) = 0

where χ(Ω) is the Euler-Poincare characteristic of the surface. The Euler-Poincare char-acteristic of different surfaces is given in the following bullet list:

• for the sphere, χ = 2 (#V −#E + #F = 2− 4 + 4),

• for the torus, χ = 0 (#V −#E + #F = 4− 8 + 4),

• for the disk, χ = 1,

• for the Klein bootle, χ = 1.

Another form of the Euler-Poincare relation, more useful for general domains is given by:

(3.1) χ(M) = #V −#E + #F = 2− 2G−NB

where,

• NB is the number of boundaries (1 for the plane or 0 for a torus or a sphere),

• G is the genus of the surface. The genus is the largest number of nonintersectingsimple closed curves that can be drawn on the surface without separating it. Roughlyspeaking, it is the number of handles in a surface.

From Eq. 3.1, it is then easy to compute the genus G of a given mesh M:

(3.2) G(M) =−χ(M)−NB + 2

2

Property 3.1.1 We consider a mesh of a 2D domain that is isomorphic to a disk. Then,the following relations holds

#F − 2(#V − 1) + #Vb = 0(3.3)

#E − 3(#V − 1) + #Vb = 0(3.4)

where #Vb is the number of vertices on b.

Page 60: An introduction to Geometrical Modelling and Mesh Generation The ...

60 CHAPTER 3. MESH GENERATION

This is an important relation that gives a relation between the number of trianglesand the number of vertices in the triangular mesh of a “disk-like” surface. In order toproove this, let us first remark that relations (3.3) and (3.4) are true for one triangle alone:#F = 1, #V = #Vb = 3.

Swapping an edge of the mesh does not modify #V , #E, #F or #Vb. All triangu-lations with #N given are therefore equivalent: edge swaps allow to transform any giventriangulation to any other.

Inserting a point inside a triangle adds one vertex, 2 triangles and 3 edges to themesh, leaving #Vb unchanged:

(#F + 2)− 2((#V + 1)− 1) + #Vb = #F − 2(#V − 1) + #Vb = 0

(#E + 3)− 3((#V + 1)− 1) + #Vb = #E − 3(#V − 1) + #Vb = 0.

Inserting a point on the domain boundary b adds one vertex, one triangles and two edgesto the mesh. Relations (3.3) and (3.4) are still true:

(#F + 1)− 2((#V + 1)− 1) + (#Vb + 1) = #F − 2(#V − 1) + #Vb = 0

(#E + 2)− 3((#V + 1)− 1) + (#Vb + 1) = #E − 3(#V − 1) + #Vb = 0.

Property 3.1.2 We consider a mesh of a 3D domain that is isomorphic to a sphere. Thefollowing relation holds

#E −#R = #V + #Vb − 3

where #Vb is the number of vertices on the boundary.

Note that this relation is true for one tetrahedron only, as well as for any other 3D element.

In a 3D tetrahedral mesh, there exist no relation between the number of tetrahedraand the number of nodes, as it exists in 2D. As an example, it is possible to definethe following “face swap” transformation: 2 tets that have a face in common can betransformed in 3 tets without changing the number of vertices. Yet one additional edgehas to be added to the mesh in order to verify the relation, verifying the Euler-Poincareformula.

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 sufficiently large meshes but are patently wrongfor coarse meshes. The average number of mesh entities in tetrahedral and hexahedralmeshes are presented in Table 3.1.

A second interesting set of statistics concerns the average number of mesh entitiesof dimension d adjacent to a mesh entity of dimension q. We call this Nd(M q). Thesestatistics are represented in Table 3.2.

Page 61: An introduction to Geometrical Modelling and Mesh Generation The ...

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 Md 3 2 1 0

N3(Md) 1 2 5 23N2(Md) 4 1 5 35N1(Md) 6 3 1 14N0(Md) 4 3 2 1

d 3 2 1 0N3(Md) 1 2 4 8N2(Md) 6 1 4 12N1(Md) 12 4 1 6N0(Md) 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, whenthey are sufficiently big, 6 times more tetrahedron than vertices. Every edge is connected,on average, to 5 tetrahedron.

The information contained in these two tables are important when designing meshdata structures or when choosing one finite element interpolation scheme. In a tetrahedralmesh for example, it is important to figure out that there are 12 times more faces thanvertices and that any scheme that imposes to store in memory the faces of the mesh will beexpensive. Moreover, building finite element interpolations on tetrahedral meshes basedon any other entity than vertices will generate large number of degrees of freedom.

3.1.2 Mesh generation procedure

Usual mesh generation procedures work as follows

• Curves are discretized first i.e. are subdivided into line elements,

• Then, surfaces are triangulated using the discretization of the curves as boundaries,

• Finally, regions are tetrahedralized using surface meshes.

Some authors have proposed an alternative procedure that consist in building the 3Dmesh at first [?, ?]. This kind or approach is not used in Gmsh and will not be discussedhere. Figure 3.1 illustrate this three steps procedure.

At the end, some pre- and post-processing steps can be plugged in the general meshgeneration ”three steps” flow.

• High order curvilinear meshed are usually build starting from a valid 3D straightsided mesh.

Page 62: An introduction to Geometrical Modelling and Mesh Generation The ...

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.

Page 63: An introduction to Geometrical Modelling and Mesh Generation The ...

3.2. MESH SIZE FIELD AND QUALITY MEASURES 63

• Quadrilateral meshes generation procedures usually use a valid triangulation as theirstarting 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 ofthe chapter.

3.2 Mesh size field and quality measures

The aim of mesh generation is twofold

1. Generating elements of the right size,

2. Generating elements of the right shape.

For addressing those aims, we have to clarify what is right for an element, both in termsof size and shape.

3.2.1 Mesh size field

A mesh size field is a tool that aims at controlling the mesh size. We define the meshsize function δ(x, y, z) as a function the defines at every point of the domain a target sizefor the elements at the point. Recall that one of the two aims of the mesh generationprocedure is to be able to build a mesh that complies with this mesh size field. Note thatδ may me a tensor valued function. In this case, the mesh size field may be used to controldirectional sizes of the mesh and therefore enables to build anisotropic meshes.

The present ways of defining such a mesh size field in Gmsh are:

1. mesh sizes prescribed at model vertices and interpolated linearly on model edges;

2. prescribed mesh gradings on model edges (geometrical progressions, ...);

3. mesh sizes defined on another mesh (a background mesh) of the domain;

4. mesh sizes that adapt to the principal curvature of model entities.

These size fields can then be acted on by functionals that may depend, for example, onthe distance to model entities or on user-prescribed analytical functions; and when severalsize fields are provided, Gmsh uses the minimum of all fields. Thanks to that mechanism,Gmsh allows for a mesh size field defined on a given model entity to extend in higherdimensional entities. For example, using a distance function, a refinement based on thecurvature of a model edge can extend on any surface adjacent to it.

Page 64: An introduction to Geometrical Modelling and Mesh Generation The ...

64 CHAPTER 3. MESH GENERATION

Let us now consider an edge e of the mesh. We define the adimensional length ofthe edge with respect to the size field δ as

(3.5) le =

∫e

1

δ(x, y, z)dl.

We can now define a more precise criterion regarding to the mesh size: we aim atgenerating a mesh for which each mesh edge e is of size close to le = 1,

3.2.2 Element quality measures

To quickly evaluate the adequation between the mesh and the prescribed mesh size field,we defined an efficiency index τ [?] as

(3.6) τ = exp

(1

ne

ne∑e=1

τe

)

with τe = le− 1 if le < 1 and τe =1

le− 1 if le ≥ 1. The efficiency 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 availablein 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 = 4sin 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 definition, the equilateraltriangle has a γK = 1 and degenerated (zero surface) triangles have a γK = 0.

For a tetrahedron, we have the following formula:

γK =6√

6Vk(4∑i=1

a(fi)

)maxi=1,...,6

l(ei)

,

with VK the volume of K, a(fi) the area of the ith face of K and l(ei) the dimensionallength of the ith edge of K. This quality measurement lies in the interval [0, 1], an elementwith γK = 0 being a sliver (zero volume).

Page 65: An introduction to Geometrical Modelling and Mesh Generation The ...

3.3. ONE DIMENSIONAL MESHING 65

3.3 One Dimensional Meshing

Let us consider a point p(t) on a curve C, t ∈ [t1, t2]. The number of subdivisions N ofthe curve is its adimensional length:

(3.7)

∫ t2

t1

1

δ(x, y, z)‖∂tp(t)‖dt = N.

The N + 1 mesh points on the curve are located at coordinates T0, . . . , TN, whereTi is computed with the following rule:

(3.8)

∫ Ti

t1

1

δ(x, y, z)‖∂tp(t)‖dt = i.

With this choice, each subdivision of the curve is exactly of adimensional size 1, and the1-D mesh exactly satisfies the size field δ. In Gmsh, (3.8) is evaluated with a recursivenumerical integration rule.

3.4 Delaunay and Voronoı

3.4.1 The Voronoı diagram

Let p1 and p2 be two points of R2. The mediatorM(p1,p2) is the locus of all the pointswhich are equidistant to p1 and p2:

M(p1,p2) = p ∈ R2, d(p,p1) = d(p,p2)

where d(., .) is the euclidian distance between two points of R2, i.e.

(3.9) d2(p1,p2) = (p2 − p1) · (p2 − p1).

The equation of the mediator can be found out using this definition

(p1 − p) · (p1 − p) = (p2 − p) · (p2 − p)

or

(p1 − p2) ·

p− 1

2(p1 + p2)︸ ︷︷ ︸

pm

= 0

This shows that the mediator is the orthogonal bissector of the straight edge linking thetwo points. The mediator separates the plane into two regions. The first region containsall the points that are closer to p1, the second one contains the ones that are closer to p2.Any point of R2/M can be associated to one of those two points.

Page 66: An introduction to Geometrical Modelling and Mesh Generation The ...

66 CHAPTER 3. MESH GENERATION

pmp1

M

p2

p

Figure 3.2: The mediator.

Page 67: An introduction to Geometrical Modelling and Mesh Generation The ...

3.4. DELAUNAY AND VORONOI 67

pi

pj

pk

vI

C(pi)

Figure 3.3: The Voronoı diagram. The Voronoı cell C(pi) relative to vertex pi is colored.

Let us consider a set of N points S = p1, . . . ,pN. More specifically, we assumethat the points are in general position, by which we mean no four points are cocircular.The Voronoı cell C(pi) associated to point pi is the locus of points of R2 that are closerto pi than any other point pj , j = 1, . . . , N , i 6= j.

The Voronoı cell is constructed as follow. Consider all mediators M(pi,pj). Eachof those mediators define a half plane. The Voronoı diagram is the part of the spacethat is always closer to pi, i.e. that always associate pi to the point p, for all possiblemediators.(see Figure 3.3). The set of all Voronoı cells is called the Voronoı diagram of S(see Figure 3.3).

Let us present some remarkable properties of the Voronoı diagram.

Property 3.4.1 Voronoı cells are convex polytopes.

By definition, each Voronoi region C(pi) is the intersection of open half planes containingvertex pi. Therefore, C(pi) is open and convex. Different Voronoı regions are disjoint.Voronoı cells are polygons in 2D, polyhedra in 3D and d-polytopes in dD. Voronoı cellsare either closed or open. They can only be open for points that are located on the convexhull of the 2D domain. A point pi of S lies on the convex hull of S if and only if itsVoronoı cell C(pi) is unbounded.

Page 68: An introduction to Geometrical Modelling and Mesh Generation The ...

68 CHAPTER 3. MESH GENERATION

Figure 3.4: Two triangulations of S, both containing nt = 13 triangles defined by a totalof N = 12 points with Nh = 9 points that lie on the convex hull of S.

Property 3.4.2 Voronoı points vI are always located at intersection of 3 mediators.

Property 3.4.2 is only true if there exist no quadruplets of points in S that are cocircular.If such a set exists, it may happen that a vertex of the Voronoı is at the the intersection ofmore than 3 mediators. Consider the example of Figure 3.3 where vi is at the intersecionof C(pi), C(pj) and C(pk). Voronoı point vI is located at the center of the unique circlepassing through pi, pj and pk.

3.4.2 The Delaunay Triangulation

We first define what is a triangulation of S: it is a planar subdivision whose bounded facesare triangles and whose vertices are the points pi of S. Note that all triangulations do notcover the same subset of R2. In what follows, we consider that the domain to triangulateis the convex hull of S.

Even with the same domain to cover, several triangulations are possible (see Figure3.4). Yet, every triangulation has the same number of triangles and edges!

Property 3.4.3 Let S be a set of N points in the plane, not all collinear, and let Nh

denote the number of points in S that lie on the convex hull of S. Then any triangulationof S has nt(N,Nh) = 2N − 2−Nh triangles and ne(N,Nh) = 3N − 3−Nh edges.

Page 69: An introduction to Geometrical Modelling and Mesh Generation The ...

3.4. DELAUNAY AND VORONOI 69

Proof Consider first that all the points in S are in the convex hull: N = Nh. A triangu-lation consist simply in triangles tI(p1,pi,pi+1), i = 2, . . . , N −1. The number of triangleis therefore nt = N − 2 which is consistent with the formula. The number of edges in thetriangulation is calculated as follows: Nh = N edges on the convex hull and N−3 internaledges wich gives ne = N +N − 3 = 2N − 3 which is again consistent with the proposition.

The rest of the proof works using a recurrence argument. Assume that formulas aretrue for N . Let us now consider one new vertex pN+1 that lies inside the convex hull.This new vertex lies inside one of the existing triangles, say tI(pi,pj ,pk). We remove tIand replace it by three new triangles tJ(pi,pj ,pN+1), tJ(pj ,pk,pN+1), tJ(pk,pi,pN+1).We have therefore nt(Nh, Nh) = Nh − 2 and nt(N + 1, Nh) = nt(N,Nh) + 2 which givesnt(N,Nh) = Nh − 2 + 2(N − Nh) = 2N − 2 − Nh. Similarly, three new edges have beenadded in the process. Then, ne(Nh, Nh) = 2Nh − 3 and ne(N + 1, Nh) = ne(N,Nh) + 3which gives ne(N,Nh) = 2Nh − 3 + 3(N −Nh) = 3N − 3−Nh.

Consider a triangulation T with nt triangles. This triangulation has 3nt internalangles. Consider the vector of angles A(T ) = (α1, . . . , α3nt) sorted by increasing values.We can define such a vector for any triangulation of the convex hull of the domain. Eachof 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 rightone.

Angle-optimal triangulations have interesting interpolation properties and it is there-fore useful to find methods that allow to construct such triangulations.

For a given set of points, the (unique) angle-optimal triangulation is the triangulationthat has the highest minimal angle. Let us see now how to build such a triangulation.

Consider now the edge e(p4,p6) of Figure 3.5. This edge is surrounded by twotriangles t1(p4,p6,p1) and t2(p4,p6,p2) . An edge swap is a local mesh modificationoperator that consist in changing locally the triangulation by replacing edge e(p4,p6) bye′(p1,p2). Triangles t1(p4,p6,p1) and t2(p4,p6,p2) are replaced by t′1(p1,p2,p4) andt′2(p1,p2,p6). Figure 3.5 illustrate the edge swap operation.

It is indeed possible to use the edge swap operator in order to build angle-optimaltriangulation. 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 finite set of points, there is a finite number ofpossible triangulations. When the angle criterion is applied, every edge swap produce anew triangulation that is better than the actual one. Therefore, building the angle-optimaltriangulation consist in looping over all the edges of the mesh and swap them until theoptimal configuration is attained i.e. when no invalid edges remain in the triangulation.Figure 3.6 illustrate that procedure.

Yet, computing angles is a costly operation and it is possible to use a simpler andcheaper rule to verify the validity of an edge.

Page 70: An introduction to Geometrical Modelling and Mesh Generation The ...

70 CHAPTER 3. MESH GENERATION

t2α5

α6

t1

p2

p4

p6

p1

e

α1

α2

α3

α4

α3α′5

t1

e′

p2

p4

p6

p1

α1α′2

α′6

α′3

t′2

Figure 3.5: Edge swap.

Page 71: An introduction to Geometrical Modelling and Mesh Generation The ...

3.4. DELAUNAY AND VORONOI 71

Figure 3.6: Building an angle-optimal triangulation using swaps.

Property 3.4.4 Let C be a circle, l a line intersecting C in points p4 and p6 and p1, andp2, p3 and p5 points lying on the same side of l . Suppose that p2 and p3 lie on C, thatp5 lies inside C, and that p1 lies outside C. Then (see Fig. 3.7):

α1 < α2 = α3 < α5.

Property 3.4.5 [Lawson’s Criterion] Consider an edge e with its two neighboring trian-gles t1 and t2. Consider the circumcircle C of triangle t1 and point p that belongs to t2but not to t1. Edge e is invalid if p ∈ C.

Property 3.4.5 has been demonstrated by Sibson in [?]. Consider Figure 3.8. The proofconsist in demonstrating that α′ > α if p1 ∈ C. The demonstration make use of property3.4.4 (Thales’s Theorem).

Note that, when two neighboring triangles separated by an edge e form a concavequadrilateral, edge e is always valid.

Procedure described in Figure 3.6 allow to build angle-optimal triangulations. Yet,it can be shown that such an algorithm is slow in practice.

There exists a much faster manner to build angle optimal triangulations of S thatis based on the Voronoı diagram. This triangulation DT (S) is called the Delaunay trian-gulation and its construction works as follows.

First recall that each Voronoı cell C(pi) is associated to one only point pI of S.

Consider a Voronoı point vI that at the meeting point of 3 Voronoı cells C(pi),C(pj), C(pk). Because of the Voronoı property, point v is at the circumcenter of triangletI(pi,pj ,pk). Triangle tI ∈ DT (S) is one of the triangles of the Delaunay triangulation.

The resulting figure is a triangulation (see Figure 3.9).

Property 3.4.6 Let S be a set of points in the plane.

Page 72: An introduction to Geometrical Modelling and Mesh Generation The ...

72 CHAPTER 3. MESH GENERATION

p6

p3p5

α2

α3α5

p1 p2

p4

α1

C

l

Figure 3.7: Theorem of Thales

C ′

α′

α

C

p2

p4

p6

p1

e

e′

Figure 3.8: Lawson’s criterion

Page 73: An introduction to Geometrical Modelling and Mesh Generation The ...

3.4. DELAUNAY AND VORONOI 73

Figure 3.9: The Voronoı diagram and its associated Delaunay triangulation

Page 74: An introduction to Geometrical Modelling and Mesh Generation The ...

74 CHAPTER 3. MESH GENERATION

v′

p3

C(t)

la

lc

lbbc

v

t

ap1

p2

Figure 3.10: Illustration of why property (i) of 3.4.6 is true.

(i) Three points pi , pj and pk ∈ S are vertices of the same triangle tI of the Delaunaytriangulation if and only if the circumcircle C(tI) contains no point of S in itsinterior.

(ii) Two points pi and pj ∈ S form an edge eI of the Delaunay triangulation if andonly if there is a closed disc C that contains pi and pj on its boundary and does notcontain any other point of S.

Proof Property (i) of 3.4.6, also called the incircle property, is a simple consequences ofthe properties of construction of the Voronoı diagram. Figure 3.12 show one triangle tand its circumcenter v. If a point like a exist in S, triangle t is cannot be in the Delaunaytriangulation because point a is closer to v that at least one of the three points p1 p2 orp3. Therefore, as it is drawn in the Figure, mediator la crosses another mediator at pointv′ inside the triangle, which is impossible.

Property 3.4.7 Let S be a set of points in the plane in general position. A triangulationT of S is angle-optimal if and only if T is the Delaunay triangulation of S.

Proof We shall prove that the angle-optimal triangulation is the Delaunay triangula-tion by contradiction. So assume T is a legal triangulation of S that is not a Delaunaytriangulation. By Property (ii) of 3.4.6, this means that there is a triangle t(pi,pj ,pk)such that the circumcircle C(t) contains a point pl ∈ S in its interior. Let e(pi,pj) bethe edge of t′(pi,pj ,pl) such that the triangle t′ does not intersect t. Of all such pairs

Page 75: An introduction to Geometrical Modelling and Mesh Generation The ...

3.4. DELAUNAY AND VORONOI 75

C(Ti,pi+1)

pi+1

pi+1

C(Ti,pi+1)

Figure 3.11: Delaunay triangulation Ti (left). The Delaunay cavity Cp(Ti,pi+1) is repre-sented in both middle (pi+1 is inside Ti) and right (pi+1 is outside Ti) figures.

(pi,pj ,pk,pl) in T , choose the one that maximizes the angle pi,pl,pj . Now look at thetriangle t′′(pi,pj ,pm) adjacent to t along e. Since T is angle-optimal, e is legal. By Prop-erty 3.4.5, this implies that pm 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, pl ∈ C(t′′) Assumethat e′(pj ,pm) is the edge of t′′ such that triangle t′′′(pj ,pm,pl) does not intersect t′′. Butnow angle pj ,pl,pm > angle pi,pl,pj by Thales’s Theorem, contradicting the definitionof the pair (pi,pj ,pk,pl).

Note that the unicity of the Delaunay triangulation is only guaranteed when thereexists no quadruplets of points in the set S that are cocircular, i.e. for points in generalposition. When S is not in general position, some of the Delaunay triangulations may notbe angle-optimal.

3.4.3 Construction of Delaunay Triangulations

There are two categories of algorithms that allow to create Delaunay triangulations.

Incremental Construction of Delaunay Triangulations: the Delaunay kernel

We consider a triangulation Ti and a point pi+1 inside Ti. The cavity C(Ti,pi+1) associatedto Ti and pi+1 is the set of all the triangles for which their circumsphere contains pi+1.

We consider a triangulation Ti and a point pi+1 outside Ti. The cavity Cp(Ti,pi+1)associated to Ti and pi+1 is the set of all the triangles for which their circumsphere containspi+1 completed by all triangles that can be formed by joining all the edges of Ti visible bypi+1.

Page 76: An introduction to Geometrical Modelling and Mesh Generation The ...

76 CHAPTER 3. MESH GENERATION

B(Ti,pi+1)

pi+1

B(Ti,pi+1)

pi+1

Figure 3.12: Delaunay triangulation Ti+1 In the left Figure, pi+1 is inside Ti and, in theright Figure, pi+1 is outside Ti.

Property 3.4.8 The cavity Cp(Ti,pi+1) is star shaped and pi+1 belong to its Haddadkernel.

A polygon is star-shaped with respect to pi+1 if, for each point pk, k = 1 . . . , Nc

of the polygon the edge e(pi+1,pk) lies entirely within the polygon. The set of all pointspi+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 starshaped, but the inverse is not true. Thanks to property 3.4.8, it is quite easy to builda triangulation of the cavity, simply by adding Nc triangles. This set of new triangles iscalled the ball B(Ti,pi+1).

Let us assume that we have build the Delaunay Triangulation Ti with the first ipoints of the set S.

It is possible to build iteratively the delaunay triangulation Ti+1, i.e. using Ti andpi+1. We define the Delaunay kernel as the following procedure

Ti+1 = Ti − C(Ti,pi+1) + B(Ti,pi+1)

that consist in removing from the triangulation elements of C(Ti,pi+1) that violate theincircle property (i) of 3.4.6 and subsequently to triangulate the cavity with the ballB(Ti,pi+1) Figure 3.12 illustrates the Delaunay kernel.

Property 3.4.9 if Ti is the Delaunay triangulation of the convex hull of the i first pointsof a set S, then Ti+1, the triangulation constructed using the Delaunay kernel is a Delaunaytriangulation

Page 77: An introduction to Geometrical Modelling and Mesh Generation The ...

3.4. DELAUNAY AND VORONOI 77

Recursive Construction of Delaunay Triangulations: Divide and Conquer

There exists a “Divide and Conquer” type of algorithm for triangulating a known set ofpoints. It allows a O(N logN) complexity. Divide and conquer (DC) is an importantalgorithm design paradigm. It works by recursively breaking down a problem into two ormore sub-problems of the same (or related) type, until these become simple enough to besolved directly. The solutions to the sub-problems are then combined to give a solution tothe original problem.

The Divide and Conquer algorithm for triangulations in two dimensions is due toLee and Schachter which was improved by Guibas and Stolfi and later by Dwyer. In thisalgorithm, one recursively draws a line to split the vertices into two sets. The Delaunaytriangulation is computed for each set, and then the two sets are merged along the splittingline

Algorithm 1 DelDC(PointIndex left, PointIndex right)

1: n = right - left + 12: if n = 2 then3: InsertInDList (left,right)4: else if n = 3 then5: InsertInDList (left,right)6: InsertInDList (left,left+1)7: InsertInDList (left+1,right)8: else if n > 3 then9: 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 triangulatorof Gmsh.

The set of points is assumed to be sorted lexicographically, i.e. points are sortedform left to right and from bottom to top. Points are subsequently numbered using theirlexicographic index (PointIndex). Figure 3.13 shows a set

S = p1,p2, . . . ,p9

of 9 points sorted lexicographically.

A doubly linked circular list is assigned to every point pi of the set S. This datastructure contains every point pj that is connected through a mesh edge to point pi. Dataare stored in the list in the counter-clockwise sense, as it is pictured in Figure 3.14. Thelist 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

Page 78: An introduction to Geometrical Modelling and Mesh Generation The ...

78 CHAPTER 3. MESH GENERATION

S

p1

p2

p3

p4

p5

p6

p7

p8

p9

Figure 3.13: A set of points sorted lexicographically

p2

p6

p6 p5 p3

p2

p3

p4

p5

Figure 3.14: The doubly-linked circular list associated to point p4.

Page 79: An introduction to Geometrical Modelling and Mesh Generation The ...

3.4. DELAUNAY AND VORONOI 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 andthe successor k to point j in the adjacency list of i.

The DelDC function (see algorithm 1) builds a Delaunay triangulation for the subsetof points

Ssubset = pleft,pleft+1, . . . ,pright.

Three trivial cases are treated:

• If the number of points n = right − left + 1 in Ssubset is less that n = 2, thetriangulation contains no edge;

• If n = 2, one edge is added in the triangulation;

• If n = 3, three edges are created that form one triangle.

If n > 3, the middle point of Ssubset is computed. The DelDC function is called twicerecursively 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 tomiddle and from middle+1 to right are Delaunay triangulations. A procedure that wecall DelMerge enables to merge the two disconnected Delaunay triangulations to form aunique Delaunay triangulation of the whole range going from left to right

The first part of the DelDC procedure is illustrated graphically at Figure ??. Theset of points is first split in two subsets S1 and S2 (part (a) of Figure ??). Then, eachpart is split again, giving four subsest S11, S12, S21 and S22 (part (b) of Figure ??). Therecursion stops when sub-sets of points have at most three points. At this point, everysubset 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 (S11) and DT (S12) are merged as well as DT (S21) and DT (S22),forming two Delaunay triangulations DT (S1) and DT (S2) (part (a) of Figure 3.16). ThenDT (S1) and DT (S2) are merged to form the final result DT (S) (part (b) of Figure 3.16).

Let us now describe the most complex part of the algorithm, i.e. the DelMerge

procedure. We will illustrate it using DT (S1) and DT (S2). The DelMerge procedurestars 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 twosets because they belong to the convex hull and Delaunay triangulations are triangulationsof the convex hull. The merging process MergeDC aims at filling the empty gap betweenthe two triangulations DT (S1) and DT (S2),

The MergeDC procedure starts from the LCT with its two points l and r. Even thoughtriangles surrounding those two points are part of respectively DT (S1) and DT (S2), theymay not be part of DT (S).

Page 80: An introduction to Geometrical Modelling and Mesh Generation The ...

80 CHAPTER 3. MESH GENERATION

S2

p2

p3

p4

p5

p6

p7

p8

p9

S1

p1

S22

p4

p5

p6

p7

p8

p9

S11 S12 S21

p1

p2

p3

(a) (b)

S21

p8

p7

p5

p1

p2

p4

S11 S22S12

p3

p9

p6

(c)

Figure 3.15: Illustration of the Divide and Conquer procedure.

Page 81: An introduction to Geometrical Modelling and Mesh Generation The ...

3.4. DELAUNAY AND VORONOI 81

S2

p9

p6

p8

p7

p5

p1

p2

p4

S1

p3 S

p3

p9

p6

p8

p7

p5

p1

p2

p4

(a) (b)

Figure 3.16: Illustration of the DelMerge procedure of the Divide and Conquer procedure.This procedure merges the two left triangulations DT (S1) and DT (S2) to form the finalresult DT (S).

r2

lr,r

UCT

ll,lLCT

ul,l2

l1r1

ur

Figure 3.17: Computation of both lower common tangent (LCT) and the upper commontangent (UCT) of the union of both triangulations. Point indices like l,ll or l1 refer to thenotations of algorithm 2

Page 82: An introduction to Geometrical Modelling and Mesh Generation The ...

82 CHAPTER 3. MESH GENERATION

UCT

ul,l2

ur

r2

r1l1

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 ofLCT in r’s adjacency list and edge (r,r2) is the one the is the Predecessor of (r,r1) in r’sadjacency list. We apply Lawson’s criterion to edge (r,r1), i.e. look if point r2 lies insidethe circumcircle of triangle (l,r,r1). If it is not the case, then triangle (l,r,r1) cannot beexcluded regarding to DT (S2).

Similarly, consider point l in Figure 3.17. Edge (l,l1) is the one the is the Successor

of LCT in l’s adjacency list and edge (l,l2) is the one the is the Successor of (l,l1) in l’sadjacency list. We apply Lawson’s criterion to edge (l,l1), i.e. look if point l2 lies insidethe circum circle of triangle (l,l,l1). If it is not the case, then triangle (r,l,l1) cannot beexcluded regarding to DT (S1).

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 satisfies the incircle property (see Figure 3.18).

In the particular case of Figure 3.17, the process can be continued two times (seeFigure 3.4.3).

At the next step (Figure 3.20, part (a)), it is clear that edge (r,r1) cannot be part ofthe triangulation because triangle (l,r,r1) has its circumcircle that contains r2. Note thatLawson’s criterion is symmetric, which means that, if the circumcircle of triangle (l,r,r1)contains r2, then the circumcircle of triangle (l,r,r2) contains r1. At this point, we simplyreplace edge (r,r1) by edge (l,r2) and continue the process.

Page 83: An introduction to Geometrical Modelling and Mesh Generation The ...

3.4. DELAUNAY AND VORONOI 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.

Page 84: An introduction to Geometrical Modelling and Mesh Generation The ...

84 CHAPTER 3. MESH GENERATION

Algorithm 2 MergeDC(PointIndex left, PointIndex mid, PointIndex right)

1: [ll,lr] = LowerCommonTangent(left, mid, right) , l = ll, r = lr2: [ul,ur] = UpperCommonTangent(left, mid, right)3: while l 6= ul or r 6= ur do4: b = false5: InsertInDList (l,r)6: r1 = Predecessor (r,l)7: while true do8: r2 = Predecessor(r, r1)9: if not InCirlce (l,r,r1,r2) then

10: break11: else12: DeleteFromList (r,r1), r2=r113: end if14: end while15: l1 = Successor (l,r)16: while true do17: l2 = Successor(l, l1)18: if not InCirlce (r,l,l1,l2) then19: break20: else21: DeleteFromList (l,l1), l2=l122: end if23: end while24: if b or InCircle(l,r,r1,l1) then25: r = r126: else27: l = l128: end if29: end while30: InsertInDList (l,r)

An implementation of that algorithm is provided in Gmsh. Source code can be foundin gmsh/Mesh/DivideAndConquer.cpp.

3.5 Planar Meshing

This sections deals with the following issue: how to generate a well shaped triangulationthat respects a size criterion δ(x) on a planar domain S.

Page 85: An introduction to Geometrical Modelling and Mesh Generation The ...

3.5. PLANAR MESHING 85

-0.075 -0.05 -0.025 0 0.025 0.05 0.0750

0.025

0.05

0.075

0.1

0.125

0.15

17

12 83

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

32 16

1

21

Figure 3.21: A simple 2D model (conge.geo).

3.5.1 The general procedure

Let us start by defining a simple planar surface in Gmsh (Figure 3.21). This model iscontained in the Gmsh distribution and is called conge.geo. This model is composed oftwo planar surfaces, 20 model edges and 25 model vertices. We consider a uniform sizefield δ = 0.005. The first step for doing the mesh is to discretize (or mesh) the edges of themodel. This operation is done computing the primitive (3.8) for every edge of the model.The result is presented in Figure 3.22. Then, each of the two model faces is triangulated.

At first, all the mesh vertices that bounds the model face are considered. Four extramesh vertices are added to the list. These four vertices are the corners of a rectangle thatencompasses 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 Delaunaytriangulation 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 presentin the triangulation. The Delaunay triangulation only deals with points and triangles, not

Page 86: An introduction to Geometrical Modelling and Mesh Generation The ...

86 CHAPTER 3. MESH GENERATION

00.075

0.05

-0.05

0.075

-0.025

0.15

-0.075 0.050.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 bepresent in the initial Delaunay triangulation. Consider an edge with points p1 and p2.This edge will be present in the Delaunay triangulation if the circle centered at 1

2(p2 +p1)of diameter ‖p2 − p1‖ does not contain any other point of the set than p1 and p2. Inpractice, it is possible to refine the 1D mesh in order to fullfill this circle criterion.

It is also possible to recover the missing 1D edges using edge swaps. In our firstsimple case, all edges of the 1D mesh are indeed present in the Delaunay triangulationsand nothing has to be done. We will present in a further discussion examples where edgerecovery has been applied as well as the edge recovery algorithm. Note that, when an edgehas to be recovered, the resulting triangulation is not anymore a Delaunay triangulation.This kind of triangulation is sometimes called a constrained Delaunay triangulation.

Another issue that may occur during the definition of initial mesh concerns possibleself-intersections of 1D mesh edges. We assume here that model edges of the geometrydo not self intersect. However, this does not guarantee that, even if the model edges G1

j

that constitute the boundaries of the domain are non intersecting, the corresponding 1Dmeshes do not self intersect. Figure 3.23 shows two model edges that are very close to

Page 87: An introduction to Geometrical Modelling and Mesh Generation The ...

3.5. PLANAR MESHING 87

Figure 3.23: A geometry with two islands that are very close to each other. The firstimage shows the initial 1D mesh that respects mesh size field. The second image showsthe first iteration of the recovery algorithm. The third image shows the final mesh thatwas possible to realize after 2 recovery iterations

each other. Yet, even the geometry is itself not self-intersecting, the first 1D generatedmesh intersects itself. This can be been considered as a critical issue: modifying the meshsize field by hand locally cannot be considered when several thousand of boundaries areto be involved. It is therefore mandatory to define a systematic recovery procedure. Suchan algorithm illustrated in Figure 3.23 works as follow:

1. A Delaunay mesh that contains all points of the 1D mesh is initially constructedusing a divide and conquer algorithm [?].

2. Missing edges are recovered using edge swaps [?]. If a mesh edge ei that belongs tothe 1D mesh is to be swapped for recovering edge ej , then the mesh edges ei and ejthat both belong to the 1D mesh intersect.

3. All intersecting edges ek are split in 2 segments and the new point is snapped ontothe geometry. Then, we go back to the first step until the list of intersecting edgesis empty.

If an intersecting edge is smaller than the geometrical tolerance, then an error message isthrown 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 cornersand to walk through its edge-neighbors, recursively, stopping the process when crossingan edge that belongs to the boundary of the domain. The element that is on the otherside of this edge is inside the domain. Then, we walk again through the neighbors allowto get all element that are inside the domain(Figure 3.25).

Points are inserted in the domain in order to refine the triangulation. The waypoints are inserted is the key point of the method. Different algorithms are available inGmsh. We will present them in forthcoming sections.(Figure 3.25).

Page 88: An introduction to Geometrical Modelling and Mesh Generation The ...

88 CHAPTER 3. MESH GENERATION

Figure 3.24: The first and second stages of the 2D meshing procedure for the modelconge.geo.

Page 89: An introduction to Geometrical Modelling and Mesh Generation The ...

3.5. PLANAR MESHING 89

0.05-0.075 0.0750-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.0750-0.05

0.125

0

0.15

Figure 3.25: The fourth and fifth stages of the 2D meshing procedure for the modelconge.geo.

3.5.2 Boundary edges recovery

Triangulating the set of points using a Delaunay-based procedure produces a Delaunaytriangulation of the convex hull of the set. Yet, there is no guarantee that all the edges ofthe 1D mesh are present in the triangulation. As an example, let us consider the initialmesh of Figure 3.26. The boundaries of this U-shaped domain were discretized using aprescribed spacing. The Delaunay triangulation of this set of points does not contain themesh edge with nodes 3 and 4.

Figure 3.27 presents the edge recovery procedure that enables to enforce the presenceof any edge M1

i in the mesh. The procedure works as follows:

• A cavity containing triangles that are crossed by the edge to recover is set up first(grey triangles in the first Figure).

• Internal edges of the cavity are counted. Here, we count initially 7 internal edgesthat are all crossed by M1

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 havenow to be insterted in the mesh in order to build triangles that have both a good sizes

Page 90: An introduction to Geometrical Modelling and Mesh Generation The ...

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

6569

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 1Ddiscretization procedure using swaps.

Page 91: An introduction to Geometrical Modelling and Mesh Generation The ...

3.5. PLANAR MESHING 91

and shapes. There exist a bunch of point insertion techniques that are described in thelitterature.

One first idea would be for example to insert a new vertex in the middle of the longestedge with points p1 and p2 (using, of course, its adimensional length). This is the defaultsurface meshing algorithm of Gmsh. We are aware that this point insertion algorithm hasa fundamental flaw. There is indeed no guarantee that there exist no point in the meshthat is closer to the middle point than p1 and p2. This point insertion algorithm may thengenerate a new edge that is indeed too short and that will have to be removed afterwardsthrough edge collapsing.

A variant of the previous technique is used in BAMG [?]. It consist in saturatingthe edges of the mesh with points, using e.g. the 1D technique described in §3.3. A buckettree datastructure is used to remove points that are too close. Thanks to that filteringoperation, no point removal has to be performed afterwards.

An optimal point insertion procedure should be able to insert points that will nothave to be removed afterwards. In other words, one should not insert points that are tooclose to other points. An alternative to edge splitting would be insert the new point at thecircumcenter of the largest triangle [?]. We could define the adimensional size of a trianglet(a,b, c) as the ratio between its circumradius and the mesh size at its circumcenter. Thecircumcenter C of a planar triangle t can be computed as follows:

(ax − Cx)2 + (ay − Cy)2 = (bx − Cx)2 + (by − Cy)2

(ax − Cx)2 + (ay − Cy)2 = (cx − Cx)2 + (cy − Cy)2.

This leads to the system:[(bx − ax) (by − ay)(cx − ax) (cy − ay)

] [CxCy

]=

1

2

[b2x − a2x + b2y − a2yc2x − a2x + c2y − a2y

].

Circumradius Rt and inner radius rt of a triangle t are nicely related as

Rt = ‖C− a‖ =1

2rt

‖b− a‖‖c− a‖‖a− b‖‖b− a‖+ ‖c− a‖+ ‖a− b‖

.

The adimensional size lt of triangle t is computed as

(3.10) lt =√

3Rtδ(C)

.

The√

3 factor in (3.10) is explained by the fact that the circumradius of an equilateraltriangle with edges of size 1 being Rt = 1/

√3.

Triangles are sorted with respect to this adimensional length. A new point is insertedat C and the Bowyer-Watson algorithm is used to locally recreate a new Delaunay trian-gulation with the additional point. The algorithm stops when lt < lmax with lmax ≥ 1. Itis indeed NOT a good idea to take lmax > 1. Imagine that triangle t has an adimensional

Page 92: An introduction to Geometrical Modelling and Mesh Generation The ...

92 CHAPTER 3. MESH GENERATION

Figure 3.28: Illustration of the Bowyer-Watson algorithm with a point insertion schemebased on the circumcenter of the largest triangle

length of lt = 1.1. Inserting a new point at its circumcenter would generate edges that areabout two times smaller than the existing ones that are of size 1.1. We define a range ofacceptable sizes [lmin, lmax] in a way that splitting a large triangle edge lt > lmax wouldnot generate a triangle that is too small i.e. for which lt < lmin. This can be translatedin lmax = 2lmin. An usual choice for the acceptable range is to center it around 1 i.e.lmax + lmin = 2. This gives [lmin, lmax] = [2/3, 4/3]. Figure 3.28 gives an example of theBowyer and Watson algorithm with a point insertion based on the circumcenter of thelargest triangle. Points on the final mesh are nicely distributed so that only a very lightoptimization (laplace smoothing) is necessary for obtaining the final mesh.

All point insertion algorithms that we have described before do not converge to amesh that is composed of a majority of equilateral triangles. Frontal methods have theadvantage of generating nicely shaped triangles. Yet, those latter methods are less robustand slower than Delaunay meshers. It is possible to build a hybrid method that uses theBowyer and Watson algorithm that guarantees always to play with a valid mesh but wherepoints are inserted in a “frontal fashion”. Such a frontal-delaunay method should remainfast, 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 distancesand angles are measured with respect to a given metric (see (2.12))

M =

[E FF G

].

Page 93: An introduction to Geometrical Modelling and Mesh Generation The ...

3.5. PLANAR MESHING 93

Consider first the case of a spatially constant metric. The The circumcenter C of a planartriangle t with respect to the metric M can be computed as follows:

E(ax − Cx)2 +G(ay − Cy)2 + 2F (ax − Cx)(ay − Cy) =

E(bx − Cx)2 +G(by − Cy)2 + 2F (bx − Cx)(by − Cy)E(ax − Cx)2 +G(ay − Cy)2 + 2F (ax − Cx)(ay − Cy) =

E(cx − Cx)2 +G(cy − Cy)2 + 2F (cx − Cx)(cy − Cy)

This leads to the system:[E(bx − ax) + F (by − ay) G(by − ay) + F (bx − ax)G(cx − ax) + F (cy − ay) G(cy − ay) + F (cy − ay)

] [CxCy

]=

1

2

[E(b2x − a2x) +G(b2y − a2y) + 2F (bxby − axay)E(c2x − a2x) +G(c2y − a2y) + 2F (cxcy − axay)

].(3.11)

The circumradius Rt is computed as

R2t = E(Cx − ax)2 +G(Cy − ay)2 + 2F (Cx − ax)(Cy − ay).

Bowyer and Watson and Lawson’s algorithms can be applied straight away using those newformulas 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. Theproblem 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 pointsis not a line anymore and the Voronoi diagram is composed of curvilinear cells. Delaunaymeshes in a general Riemannian sense are curvilinear. This is indeed a nice topic that hasbeen 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 socalled tangent plane at a given point x. This is the usual way of dealing with anisotropicDelaunay meshing. The choice of the point at which the metric is computed is quiteimportant. 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 nonlinearversion of problem (3.11), i.e. where E, F and G all depend on Cx and Cy. In Gmsh,we perform 2 or 3 fixed point iterations of (3.11). This gives usually a sufficiently preciselocation of the circumcenter.

3.5.5 Practical implementation

To our opinion, the most important aspect of a practical implementation of a Bowyer andWatson algorithm is its lightness. The algorithm should use the fewest possible amount ofmemory (especially in 3D, but also in 2D). The procedure should of course be reasonablyfast but this is less important.

Recall now the definition of the Delaunay kernel. We consider a triangulation Tiand a point pi+1 outside Ti. The cavity Cp(Ti,pi+1) associated to Ti and pi+1 is the set

Page 94: An introduction to Geometrical Modelling and Mesh Generation The ...

94 CHAPTER 3. MESH GENERATION

of all the triangles for which their circumsphere contains pi+1 completed by all trianglesthat can be formed by joining all the edges of Ti visible by pi+1. We define the Delaunaykernel as the following procedure

Ti+1 = Ti − C(Ti,pi+1) + B(Ti,pi+1)

that consist in removing from the triangulation elements of C(Ti,pi+1) that violate theincircle property (i) of 3.4.6 and subsequently to triangulate the cavity with the ballB(Ti,pi+1). Figure 3.12 illustrates the Delaunay kernel.

The following datastructure is used in Gmsh for computing the Delaunay kernel.

class MTri3

bool deleted;

double adimensional_size;

MVertex *v[3];

MTri3 *neigh[3];

// ...

;

A point insertion procedure typically inserts and removes triangles from a set. Onthe other side, it is usually interesting to store the triangles in a datastructure that allowsto have access to the largest one. Binary trees allow to add and remove elements inlogarithmic time. In our implementation, we have decided to add a deleted tag to everytriangle that tells if it is deleted. It is only when a traversal of the tree is performed thattagged triangles are truly deleted (it is then a constant time operation).

The adimensional size of the triangle is also computed by the constructor of theclass MTri3 and stored. The three vertices of the triangle are also stored as well as itsthree neighbors. A binary tree std::set<MTri3*,compareTri3Ptr> with a comparisonfunction compareTri3Ptr that compares two MTri3* with respect to their adimensionalsize is created. The worst triangle is the one on the top of the tree, which means that theBowyer 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);

;

Page 95: An introduction to Geometrical Modelling and Mesh Generation The ...

3.6. SURFACE MESHING 95

Let’s now be more clear about function insertAPoint. The aim of this function is to breaktriangle worst. We can either choose to add the new point pi+1 on its circumcenter, toput it somewhere on a Voronoi edge or to use any fancy point insertion policy. The firsttask of the algorithm is to compute the Delaunay cavity Cp(Ti,pi+1). This task can bedone 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 oftriangles that form the “shell” of the cavity. This shell will be used for both creating thenew triangles and reconnecting the new triangles with their neighbors on the other side ofthe shell.

3.6 Surface Meshing

Curved surface shapes designed by CAD systems are usually defined by parametric sur-faces, for example, NURBS [?]. Let us consider a model face G2

i with its underlyinggeometry, in this case a surface S ∈ R3 with its parametrization ~p(u, v) ∈ S, where thedomain of definition of the parameters (u, v) is defined by a series of boundary curves. Anexample of such a surface is given in Figure 3.29, which shows one of the 76 model facesof the propeller in the parametric space (left) and in real space (right). Three features ofsurface S, common in CAD descriptions, make its meshing non-trivial:

1. S is periodic. The topology of the model face is modified in order to define its closureproperly. A seam is present two times in the closure of the model face. These twooccurrences are separated by one period in the parametric space.

Page 96: An introduction to Geometrical Modelling and Mesh Generation The ...

96 CHAPTER 3. MESH GENERATION

2. S is trimmed: it contains four holes and one of them is crossed by the seam.

3. One of the model edges of S is degenerated. This is done for accounting of a singularpoint in the parametrization of the surface. This kind of degeneracy is present inmany shapes: spheres, cones and other surfaces of revolution.

Figure 3.29: Geometry of a model face in parametric space (left) and in real space (right).Two seam edges are present in the face. The top model edge is degenerated in one point.

Techniques for generating finite element meshes on curved surfaces are of two kind:

1. techniques for which the surface mesh is generated directly in the real 3-D space;

2. techniques for which the surface mesh is generated in the parametric space.

The principal advantage of doing the surface mesh in the 3-D space directly is that nointerface to the solid modeler is required. Such algorithms have been used for build-ing meshes from STL (stereolithography) data files [?], from medical imaging [?] or toadapt/modify existing meshes [?]. The main drawback of such algorithms is their relativelack of robustness.

The second alternative can be applied only if a parametrization of the surfaces isavailable. If it is the case, doing the mesh in the parametric space is usually advantageousbecause all the meshing procedures can be applied in the parametric plane. This allowsmesh operators to be highly robust—we will detail that argument later.

Yet, all surfaces do not always have a parametrization that conserves angles andlengths. Consequently, only 2-D algorithms that allow to build anisotropic meshes in theplane can be considered as good candidates for doing surface meshing. Figure 3.30 presentsthe surface mesh of the model face of Figure 3.29, both in the parametric space and inthe real space. The mesh in the real space is isotropic and uniform while the one in the

Page 97: An introduction to Geometrical Modelling and Mesh Generation The ...

3.6. SURFACE MESHING 97

Figure 3.30: Mesh of a model face drawn in the parametric space (left) and in the realspace (right).

parametric space is highly anisotropic and non uniform. To solve this problem, George andBorouchaki [?] have proposed the use of a metric derived from the first fundamental formof the surface (2.12). The metric field is a second order tensor field that has the form, atany point of the parametric space, of a 2×2 matrix. The metric is used to define angles anddistances in parametric space (see Sec. 2.5.2). With their Delaunay approach, the ”emptycircle” property, effectively 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 byYamada et al. [?] and has been used more recently by Lo and Wang in [?].

In addition to a Delaunay implementation similar to [?] and a frontal-Delaunaymeshing technique inspired by [?], Gmsh provides an original surface meshing strategybased on the concept of local mesh modifications [?, ?, ?]. The main advantage of the newapproach, compared to the other ones based on the Delaunay criterion, is that it does notrequire the computation of derivatives of the parametrization. For that reason, the newapproach remains robust even when the parametrization is singular.

Surface meshing algorithm based on local mesh modifications This surfacemeshing algorithm works as follows. First, an initial mesh containing all the mesh pointsof the curves bounding the face is built in the parametric space using a divide and conquerstrategy [?]. Then, all the edges of the 1-D discretization are recovered using swaps [?].Finally, local mesh modifications are applied:

1. Each edge that is too long is split;

2. Each edge that is too short is removed using an edge collapse operator;

3. Edges for which a better configuration is obtained by swapping are swapped;

Page 98: An introduction to Geometrical Modelling and Mesh Generation The ...

98 CHAPTER 3. MESH GENERATION

11

H

!

h

ez

0

Fig. 1. Shallow water notations for water depthH with a time-independent bathymetry h. Notice that the relative elevation ! is usually severalorders of magnitude smaller than the unperturbed depth.

e1

e6e5

e4e3

e2

y

e4

e1 e2

e3

Fig. 2. Local mesh modifications. Edge split (top), edge collapse (middle) and edge swap (bottom). The zone depicted in bold represents the

cavity that is modified by the local mesh modification.

Figure 3.31: Illustration of local mesh modifications.

4. Vertices are re-located optimally.

More precisely, here is how these four local mesh modifications procedures are ap-plied in Gmsh:

Edge Splitting: An edge is considered too long when its adimensional length is greaterthan le > 1.4. When split, the two new edges will have a minimal size of 0.7. Inorder to converge to a stable configuration, an edge of size le = 0.7 should not beconsidered as a short edge.

Edge Collapsing: An edge is considered to be short when its adimensional length issmaller than le < 0.7. An edge cannot be collapsed if one of the remaining trianglesafter the collapse is inverted in the parametric space.

Edge Swapping: An edge is swapped if min (γe1 , γe2) < min (γe3 , γe4) (see Figure 3.31),unless

1. it is classified on a model edge;

2. the two adjacent triangles e1 and e2 form a concave quadrilateral in the para-metric space;

3. the angle between the triangles normals is greater than a threshold, typically30 degrees.

Vertex Re-positioning: Each vertex is moved optimally inside the cavity made of allits surrounding triangles. The optimal position is chosen in order to maximize theworst element quality [?].

Page 99: An introduction to Geometrical Modelling and Mesh Generation The ...

3.7. 3-D MESH GENERATION 99

For each of these local mesh modification procedures, the opportunity of doing amesh modification is evaluated in the real space, i.e., in (x, y, z), while the validity ofa mesh modification is evaluated in the parametric space (u, v). Therefore, Gmsh meshgenerators always retain both real and parametric coordinates of any mesh vertex. Toensure robustness, all the elementary geometrical predicates make use of robust algorithmic[?].

In practice, this algorithm converges in about 6-8 iterations and produces anisotropicmeshes in the parametric space without computing derivatives of the mapping.

Let us illustrate the algorithm on an example. We have meshed the model face ofFigure 3.30 using an analytical size field

δ(x, y, z) = δ0[1 + cos(π(x+ y − z)/L)] + ε

where L is a characteristic size of the domain and ε δ0 < L. Figure 3.32 shows the meshin the parametric space at different stages of the algorithm. Note that the derivatives ofthe parametrization of the underlying surface are not defined at the singular point so thatany 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 doesnot usually require an interface to a CAD system. Indeed, Gmsh interfaces several opensource 3-D tetrahedral mesh generation kernels [?, ?] in addition to its own Delaunayrefinement algorithm. These algorithms are standard [?, ?] and will not be explainedhere. 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/unstructuredgrids, and that this issues is addressed in Section 3.7.2.

Mesh Algorithm Interfaces

Gmsh is able to deal with most of the standard finite element shapes: lines, triangles,quadrangles, tetrahedra, hexahedra, prisms and pyramids. The internal mesh data struc-tures are designed to minimize the memory footprint without compromising flexibility:in addition to a integer tag and a partition/visualisation index, any element only holdsits ordered list of vertices. With that simple design, Gmsh can load about 12 milliontetrahedra per Gigabyte of memory (28 bytes per tetrahedron, 44 bytes per mesh vertex),including graphics representation, i.e., OpenGL vertex arrays [?].

Page 100: An introduction to Geometrical Modelling and Mesh Generation The ...

100 CHAPTER 3. MESH GENERATION

initial iter. 1 iter. 3

iter. 5 final

Figure 3.32: Illustration of the surface meshing algorithm based on local mesh modifica-tions. The images correspond to the initial mesh containing boundary vertices, the meshafter 1, 3, 5 and 8 iterations. At iteration 8, the algorithm has converged. The size fieldefficiency τ = 0.89 can be considered as excellent: 90 % of the elements have a radii ratioγK greater that 0.9.

Page 101: An introduction to Geometrical Modelling and Mesh Generation The ...

3.7. 3-D MESH GENERATION 101

When “in house” meshing routines are used, Gmsh derives (in the object orientedsense) enriched data structures specifically tailored for each meshing algorithm. Thosederived 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 tetrahedronfor the 3-D Delaunay algorithm, etc. With this approach the footprint of a tetrahedron isfor 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 tetrahedronper 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 theappropriate structures required by that specific software. But thankfully, while transfer-ring the data from the third party algorithm into Gmsh, only the minimal internal datastructures need to be allocated (i.e., 28 byte per tetrahedron in the 3-D case mentionedabove). 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 todo with “black magic”: even if the ingredients required to construct a mesh optimizationprocedure are well known (essentially swapping and smoothing), there is no known “bestrecipe”, i.e., no known optimal way of combining those smoothing and swapping operators.

Gmsh implements its own mesh optimization procedure to enhance tetrahedral meshquality by means of edge- and face-swappings and vertex relocations, and also interfacesthird party mesh optimizers—in particular the open-source optimizer from Netgen [?].Interestingly, applying optimization routines one after the other enables to produce bettermeshes than applying mesh optimizers separately. Figure 3.33 shows the distribution ofelemental 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 elementshave an aspect ratio γK below 0.2 and the worst shaped element has an aspect ratio of10−3. After one pass of the Gmsh mesh optimizer, which takes about 12 seconds, all slivershave disappeared and the worst element has an aspect ratio of 0.32. The distribution ofelement quality is enhanced, with a clear right shift of the distribution. Applying theNetgen optimizer after the Gmsh optimizer, additional improvement can be observed: theworst 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 elementsin the mesh, and this second optimization pass took more than 200 seconds—about 15times more than for the Gmsh optimizer. Transferring the mesh in Netgen format alsodoubled the memory usage.

Page 102: An introduction to Geometrical Modelling and Mesh Generation The ...

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 optimizationgmsh 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 meshesthat can be used by the finite element community. The various examples shown belowcan all be downloaded from the Gmsh web site. They come from different sources: nativeGmsh CAD models, CAD models found on the web, or CAD models that were proposedby industrial and academic partners. The formats considered are IGES, STEP, BREP andGmsh. Various size fields have been used, uniform or not. Both 2-D and 3-D statisticsare provided.

Table 3.3 presents details for some of the models (see Figure 3.34) used in the Gmsh2-D test suite. Mesh size field are defined in a variety of ways: analytic, uniform, sizefields driven by distance functions (attractors), boundary layers, size fields related to thecurvature of surfaces, or size fields interpolated using sizes that are defined on modelvertices. Table 3.4 gives statistics for the 2-D meshes generated with the surface meshingalgorithm presented in Section 3.6. In the case of planar surfaces and uniform meshes thisalgorithm is about three times slower than the 2-D anisotropic Delaunay mesh generatorimplemented in Gmsh. However, when multiple size fields are involved and/or when thesurfaces 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 thatthe performance and robustness of mesh generation algorithms are highly dependent ontheir implementation, we believe this shows evidence that the new algorithm proposed inSection 3.6 is a viable alternative to classical Frontal or Delaunay approaches.

Table 3.5 presents some statistics for 3-D meshes. The first example can serve asreference: it is a unit cube that is meshed uniformly with about one million tetrahedra.

Page 103: An introduction to Geometrical Modelling and Mesh Generation The ...

3.7. 3-D MESH GENERATION 103

gmsh zylkopf cylhead

fuse frog world ocean

Figure 3.34: Some images of surface meshes.

type nR nF nE nV δ

cube GMSH 1 6 12 8 uniformgmsh GMSH 0 1 35 23 attractorfrog IGES 1 475 950 477 uniform

frogadapt IGES 1 475 950 477 analyticlinkrods STEP 1 37 108 74 analyticzylkopf STEP 1 137 404 270 at verticescylhead BREP 1 1054 2485 1445 uniform

fuse STEP 1 249 723 476 curvatureblock STEP 1 533 1586 1048 uniformsenzor GMSH 8 90 200 146 at vertices

world ocean GMSH 0 1 4245 145291 boundary layermedia GMSH 1274 8398 5779 3894 uniform

Table 3.3: Statistics on the models that are considered: nR,nF ,nE and nV are respectivelythe number of model regions, of model faces, of model edges and of model vertices in themodel. δ is the size field.

Page 104: An introduction to Geometrical Modelling and Mesh Generation The ...

104 CHAPTER 3. MESH GENERATION

block linkrods senzor

frogadapt media(W. Scholz, T.U. Wien)

Figure 3.35: Some images of volume meshes.

Page 105: An introduction to Geometrical Modelling and Mesh Generation The ...

3.7. 3-D MESH GENERATION 105

np ne γK > 0.9 minK γK avgKγK l√2 τ cpu

gmsh 28041 55922 83.5% 0.287 0.946 99.0% 0.891 10linkrods 55959 119922 84.2% 0.385 0.946 98.9% 0.893 61zylkopf 32806 65668 86.0% 0.105 0.947 98.5% 0.860 8cylhead 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 11block 19694 55530 76.0% 0.021 0.923 96.8% 0.895 20senzor 19876 40002 84.6% 0.546 0.947 98.4% 0.896 11ocean 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 pointsand triangles in the surface mesh, γK > 0.9 states for the percentage of triangles thathave a quality measure γK greater that 0.9, minK γK is the worst element quality in thesurface mesh and avgKγK is the average elemental quality. The quantity l√2 states for

the percentage of edges that have an adimensional length in the range 1/√

2 < le <√

2.The factor τ is the efficiency index defined in Equation (3.6). The last column gives thecpu time (in seconds) for performing the surface mesh generation.

np ne minK γK avgKγ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 pointsand tetrahedron in the volume mesh, minK γK is the worst element quality in the volumemesh and avgKγK is the average elemental quality. The last two columns give meshgeneration and mesh optimization timings.

Some of the examples have complex mesh size fields (linkrods or frogadapt). One has smallfeatures in the geometry (block). Some have multiple volumes (media or senzor). Complexmesh size fields such as the ones of linkrods or frogadapt make the mesh generation processslower of about 20%. This overhead is essentially due to the evaluation of the mesh sizefield. Mesh with strong size variations or with small geometric features require moreoptimization. The performance figures mentioned in Section 3.7 hold even for modelswith a large number of model regions: the model called “media”, created in the nativeGmsh CAD format, involves over 1000 model regions and was meshed using the 3-DDelaunay algorithm in less than one minute. All timings were measured on a standardMacBook Pro with a CPU clocked at 2.0 GHz.

Page 106: An introduction to Geometrical Modelling and Mesh Generation The ...

106 CHAPTER 3. MESH GENERATION

boundary layer sweep sweep (detail)(R. V. Sabariego, Univ. of Liege)

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 structuredmeshes in 1-D, 2-D and 3-D, and allows to couple these with unstructured meshes. Struc-tured technologies include transfinite and elliptic meshes as well as a variety of sweepingtechniques.

For example, to build a boundary layer mesh from a set of source surfaces (seeFigure 3.36), Gmsh

1. creates the topology of the boundary layer by sweeping zero-height volumes from allthe source surfaces. (In addition to the boundary layer volumes, this creates a setof new boundary layer points, curves and surfaces. These new points, curves andsurfaces 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 boundarylayer curves by sweeping along the normals;

4. meshes the non-source surfaces, then the boundary layer surfaces (again by sweepingalong the normals), and finally the volumes.

Once all the structured parts are meshed, the remaining parts are meshed using theunstructured algorithms, resulting in conforming mixed meshes.

Page 107: An introduction to Geometrical Modelling and Mesh Generation The ...

Chapter 4

Remeshing based on surfaceparametrization

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. Leftfigure show an example of oversampled triangluation resulting from a mesh segmentationof a human pelvis and right figure shows the straightforward meshing of a CAD geometryof a maxi-cosi.

The first application concerns medical geometries that are often described only bya triangulation (in stereolitography STL format). This triangulation is the result of asegmentation procedure from the CT scan or MRI dicom-images. Those triangulationscan be oversampled and have triangles of poor quality with small elementary angles. Thoselow quality meshes are not suitable for finite element simulations since the quality of themesh will impact both on the accuracy and efficiency of the numerical method [?, ?]. In

107

Page 108: An introduction to Geometrical Modelling and Mesh Generation The ...

108 CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION

this case, it is desirable to build a high quality mesh from those low quality meshes beforeperforming any numerical simulation.

The other application is about CAD models. CAD models are often made of ahuge amount of patches that have no physical significance and a straightforward meshingof those patches gives often meshes that are not suitable for finite element simulations.Indeed, as most surface mesh algorithms mesh model faces individually, mesh points aregenerated on the bounding edges of those patches and if thin CAD patches exist in themodel 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 elementspresent in the surface mesh will often hinder the convergence of the FE simulations on thosesurface meshes. Besides, they also prevent the generation of quality volumetric meshesfor three-dimensinal finite element computations (CFD, structure mechanics, etc.). Anefficient manner to build a high quality mesh for those CAD models is then to build fromthe initial CAD mesh a cross-patch parametrization that enables the remeshing of mergedpatches.

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 strategiesuse local mesh modifications in order both to improve the quality of the input surface meshand to adapt the mesh to a given mesh size criterion. In parametrization techniques, theinput mesh serves as a support for building a continuous parametrization of the surface.(In the case of CAD geometries, the initial mesh can be created using any off the shelfsurface mesher for meshing the individual patches.) Surface parametrization techniquesoriginate mainly from the computer graphics community: they have been used extensivelyfor applying textures onto surfaces [?, ?] and have become a very useful and efficient toolfor many mesh processing applications [?, ?, ?, ?, ?]. In the context of remeshing pro-cedures, the initial surface is parametrized onto a surface in R2, the surface is meshedusing any standard planar mesh generation procedure and the new triangulation is thenmapped back to the original surface [?, ?].

The existing methods for discrete parametrization can be classified as follows: linear,

Page 109: An introduction to Geometrical Modelling and Mesh Generation The ...

4.1. PARAMETRIZATION OF TRIANGULATED SURFACES 109

non-linear and hybrid methods. Non-linear methods based on discrete or differential-geometric non-linear distortion measure [?, ?, ?] offer strong guarantees on the absence oftriangle folding and flipping at the cost of a generally higher computational effort. Someauthors have also suggested hybrid techniques that linearize those non-linear measures atthe cost of only a few linear solvers [?, ?]. Linear methods require only the resolution ofa single linear system. Most methods require to map the vertex of the patch boundary toa given polygon (usually convex ) in the parametric plane. This is for example the case ofthe discrete harmonic map introduced by Eck [?] or the more robust convex combinationmap of Floater [?] Some authors suggested also extension to free boundaries by pinningdown 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 previousresults. However, as the quality of the parametrization can depend signification the choiceof the constraint vertices, Mullen et al. [?] suggested to spread the constraints throughoutthe mesh by constraining that the barycenter of the mapping must be at (0, 0) and thatthe moment of inertia of the boundary must be unit. In [?], those spread constraints aretaken into account through recourse to spectral theory.

4.1 Parametrization of triangulated surfaces

We consider that the only available representation of a surface S is a conforming trian-gulated mesh ST in 3D , i.e. the set of K triangles Tj that intersect only at N commonvertices pi and E common edges eij :

M = ST = T1, ..., TK.

The discrete parametrization aims at computing the discrete mapping u(x) thatmaps every triangle of the three dimensional surface S to another triangle of S ′ that hasa well known parametrization.

(4.1) x ∈ ST ⊂ R3 7→ u(x) ∈ S ′T ⊂ R2

Such a parametrization exists if the two surfaces ST and ST ′ have the same topology, thatis have the same genus G and the same number of boundaries NB

1. As we have seen, thegenus of a triangulated surface G(ST ) can be computed from the Euler-Poincare formula(Eqs. (3.1) and (3.2)):

(4.2) G(ST ) =−N + E −K + 2−NB

2.

where N,E,K are respectively the number of vertices, edges and triangles of the triangu-lation ST .

For example, let us consider Figure 4.3 that shows the triangulated Tutankhamunmask. This triangulated surface is diffeomorphic to the unit disk i.e. it is possible to

1 For example, a sphere has a genus G = 0 and NB = 0, a disk has G = 0 but NB = 1 and a torus hasG = 1 and NB = 0

Page 110: An introduction to Geometrical Modelling and Mesh Generation The ...

110 CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION

R2

u

v

R3

y

S ′TSTu(x)

x(u)

xz

Figure 4.3: Discrete parametrization of the Tutankhamun mask.

find a transformation u(x) that maps S onto S ′ = u : |u| ≤ 1. Each vertex pi has itscoordinates xi on ST and ui on ST ′. Consider for example one triangle Tj composed ofthree vertices p1, p2 and p3. This triangle can itself be parametrized using standard linearshape functions (see Figure 4.4):

(4.3) x(ξ) = (1− ξ − η)x1 + ξx2 + ηx3.

Similarly, we can also parametrize the triangle in S ′:

(4.4) u(ξ) = (1− ξ − η)u1 + ξu2 + ηu3.

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− u1 =

[u2 − u1 u3 − u1v2 − v1 v3 − v1

]︸ ︷︷ ︸

u,ξ

(ξη

)︸ ︷︷ ︸

ξ

which gives

(4.5) ξ(u) = (u,ξ)−1 (u− u1) = (ξ,u) (u− u1).

and thereforex(u) = x(ξ(u)).

The derivatives of the mapping x(u)

x,u = x,ξ ξ,u =

x2 − x1 x3 − x1y2 − y1 y3 − y1z2 − z1 z3 − z1

[

v3 − v1 −(u3 − u1)−(v2 − v1) u2 − u1

](u2 − u1)(v3 − v1)− (v2 − v1)(u3 − u1)

Page 111: An introduction to Geometrical Modelling and Mesh Generation The ...

4.1. PARAMETRIZATION OF TRIANGULATED SURFACES 111

Tj ∈ S ′T

u1

u2

u3

ξ(u)

x(u)Tj ∈ ST

ξ

η

x2

x3

x1

x(ξ)

Figure 4.4: Unit triangle in local coordinates and the mappings u(x),x(ξ) and u(ξ).

allow to compute the metric tensor Mu = (x,u)T x,u of the mapping u(x) on the surfaceST .

The curvature tensor is indeed more complicated to compute for such a piecewiselinear mapping. The usual way of computing the curvature is to use a normal smoothingprocedure that is similar to the one used in the Gouraud shading technique. The basicprinciple behind the method is as follows: An estimate to the surface normal of eachvertex in a 3D model is found by averaging the surface normals of triangles which meetat each vertex. Consider again triangle Tj of Figure 4.4. The Gouraud normal smoothingprocedure allows to obtain three normal vectors n1, n2 and n3 at the three vertices. Weassume that the unit normal vector n(x) can be computed using linear shape functions

n(ξ) =(1− ξ − η)n1 + ξn2 + ηn3

|(1− ξ − η)n1 + ξn2 + ηn3|.

A last issue related to discrete parametrizations is the way to compute efficiently x(u)(see Fig.4.4). This operation requires two steps. First, one has to find the triangle in theparametric plane that contains u. This can be done efficiently using the octree techniquedescribed in §??. Then, it is possible to compute the mapping ξ(u) using (4.5) and nextto compute the mapping x(ξ), i.e. interpolating the x coordinates using linear shapefunctions.

We will now explain how to compute efficiently different types of discrete mappingsby restricting ourselves to the parametrization of non-closed triangulated surfaces, i.esurfaces that are homeomorphic to a unit disk. Surfaces that are not of this kind will bedealt with later on.

Page 112: An introduction to Geometrical Modelling and Mesh Generation The ...

112 CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION

4.2 Computing discrete harmonic and conformal maps

The first type of mapping we will consider is the harmonic mapping since it is the easiestmapping to compute approximately. This type of mapping minimizes the Dirichlet enery(see Eq. (2.22)):

(4.6) ED(u) =1

2

∫ST‖∇u‖2ds =

1

2

∫ST

(∇u)2 + (∇v)2 ds.

The strong formulation corresponding to this minimization problem is given by:

(4.7) ∇2u = 0, ∇2v = 0 on ST

with appropriate Dirichlet and Neumann boundary conditions on the NB boundaries ofSD, denoted ∂ST i, i = 1, ..., NB:

(4.8) u = uD(x), on ∂ST 1,∂u

∂n= 0, on (∂ST − ∂ST 1).

This means that if one can compute numerically the solution to those two PDE equations(4.7), the solutions u(x) a and v(u) define the discrete harmonic mapping u(x).

The second type of mapping to be considered is the conformal mapping that mim-imizes the least square conformal energy (see Eqs.(2.24) and (2.25)):

ELSCM(u) =

∫ST

1

2‖∇u⊥ −∇v‖2ds

=

∫ST

1

2

((∇u)2 + (∇v)2

)− n · (∇u×∇v) ds.

= ED(u)−A(u),

(4.9)

where A(u) is the area functional defined in (2.19).

One efficient way to compute numerically those two quadratic minimization prob-lems is to use finite elements. We denote by the functional J either the Derichlet energyED(u) or the least-square conformal energy ELSCM(u) to be minimized. The minimizationproblem reads as follows: find u∗ such that(4.10)

u∗ = arg minu∈U(S)

J(u), with U(S) = u ∈ H1(S), u = uD(x), or∂u

∂n= 0 on ∂ST i.

In what follows, we will first derive the finite element formulation for the conformal map(J = ELSCM). We assume the following finite expansions for u:

(4.11) uh(x) =∑i∈I

uiφi(x) +∑i∈J

uD(xi)φi(x)

where I denotes the set of i = 1, ..., N nodes of ST that do not belong to the Dirichletboundary, J denotes the set of nodes of ST that belong to the Dirichlet boundary (see Fig.

Page 113: An introduction to Geometrical Modelling and Mesh Generation The ...

4.2. COMPUTING DISCRETE HARMONIC AND CONFORMAL MAPS 113

nodes of J

nodes of I

Figure 4.5: Sets of I = 12 nodes defined in the first order FE expansion for a triangularsurface mesh ST made of K = 13 triangles and N = 12 vertices.

4.5 for an example for linear finite elements) and the φi’s are the nodal shape functionsassociated to the nodes of the mesh. We assume here that nodal shape function φi is equalto 1 on vertex xi and 0 on any other vertex: φi(xj) = δij .

Thanks to the finite element expansion (4.11), functional J defining for example theleast square conformal energy Eq. (4.9) can be rewritten as:

J(u1, . . . ,uI) =1

2

∑i∈I

∑j∈I

uiuj

∫ST∇φi · ∇φj ds+

∑i∈I

∑j∈J

uiuD(xj)

∫ST∇φi · ∇φj ds+

1

2

∑i∈I

∑j∈I

vivj

∫ST∇φi · ∇φj ds+

∑i∈I

∑j∈J

vivD(xj)

∫ST∇φi · ∇φj ds+

∑i∈I

∑j∈J

uD(xi)uD(xj)

∫ST∇φi · ∇φj ds+

∑i∈I

∑j∈J

vD(xi)vD(xj)

∫ST∇φi · ∇φj ds−

∑i∈I

∑j∈J

uivj

∫ST

n · (∇φi ×∇φj) ds−∑i∈I

∑j∈J

uD(xi)vj

∫ST

n · (∇φi ×∇φj) ds−

∑i∈I

∑j∈J

uivD(xi)

∫ST

n · (∇φi ×∇φj) ds−∑i∈I

∑j∈J

uD(xi)vD(xi)

∫ST

n · (∇φi ×∇φj) ds.

(4.12)

In order to minimize this functional J , we can simply cancel the derivative of J with

Page 114: An introduction to Geometrical Modelling and Mesh Generation The ...

114 CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION

respect to uk (the same derivation can be done with respect to vk):

∂J

∂uk=∑j∈I

uj

∫ST∇φk · ∇φj ds︸ ︷︷ ︸

Akj

+∑j∈J

uD(xj)

∫ST∇φk · ∇φj ds︸ ︷︷ ︸

Akj

∑j∈I

vj

∫ST

n · (∇φk ×∇φj) ds︸ ︷︷ ︸Ckj

−∑j∈I

vD(xj)

∫ST

n · (∇φk ×∇φj) ds︸ ︷︷ ︸Ckj

= 0 , ∀k ∈ I.

(4.13)

In this equations the elementary matrixes Akj of triangle Ti can be computed as follows:

(4.14) ATkkj =

∫Ti

∇φk · ∇φjds =

∫ 1

0

∫ 1−ξ

0∇ξ,ηφk M−1

ξ ∇ξ,ηφj

√det Mξ dξdη,

where Mξ is the metric tensor of the mapping x(ξ) (see Fig.4.4 and Eq.(4.3)).

The combination of the equations (4.13) for the uk and vk derivatives gives us alinear system of 2I equations that can be written as follows:

(4.15)

(A −C−CT A

)︸ ︷︷ ︸

LC

(UV

)=

(00

),

where A is a symmetric positive definite matrix and C is an antisymmetric matrix thatare both build by assembling the elementary matrices Akj and Ckj , and the vectors Uand V denote respectively the vector of unknowns uk and vk. The resulting matrix LC isthen symmetrix definite positive such that the linear system LCU = 0 can be efficientlysolved using a direct sparse symmetric-positive-definite solver such as TAUCS. The linearsystem of equations is then the discrete version of the minimization problem (4.10) thatcan now be rewritten as:

(4.16) U∗ = arg minU

1

2UTLCU

As the Dirichlet energy is related to the least square conformal energy, the linearsystem resulting from the finite element formulation for the harmonic map can be derivedfrom Eq. (4.15), by vanishing the off-diagonal matrixes of LC:

(4.17)

(A 00 A

)︸ ︷︷ ︸

LD

(UV

)=

(00

),

which makes the system of equations uncoupled: AU = 0, AV = 0. This finite elementharmonic map can be is quite similar to the discrete harmonic map introduced first byEck et al. [?]

ENFORCING INSENSITIVITY TO SAMPLING IIREGULARITY ... SEE MULLEN2008 AND ALSO benchmark/geo/spherehalf.geo

Page 115: An introduction to Geometrical Modelling and Mesh Generation The ...

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 discreteminimization problem has a unique solution and that this unique solution defines a one-to-one mapping (and hence avoids the degenerate solution u =constant).

We first consider the Dirichlet boundary conditions that are often used for theLaplacian harmonic map:

(4.18) u = uD(x) on ∂ST i.

This boundary condition allows to map one of the boundaries of ST (∂ST 1) to a fixedboundary in the parametric space (a circle, a square, an ellipse, the projection of ∂Son its mean plane etc.). The fixed boundaries that are considered are convex polygonssince the continuous harmonic map is proven to be one-to-one if the mapped surface S ′is convex. This result is called the Rado-Kneser-Choquet (RKC) theorem [?, ?] and itstrongly depends on the fact that the solution of the Laplace equation obeys a strongmaximum principle: u(x) attains its maximum on the boundary ∂S of the domain. Thismeans that there exists only one single iso-curve u = u0 in S and that this iso-curve goescontinuously from one point of the boundary to another. If another iso-curve u = u0existed, it should be closed inside S, violating the maximum principle. This is also truefor the iso-curve v = v0. Consider the surface S of Figure 4.6a with one single boundary(NB = 1) that is mapped to a unit circle with appropriate Dirichlet boundary conditions.Surface S ′ is convex so that any vertical line u = u0 intersects ∂S ′ at most two times.This is also true for any horizontal line v = v0. This means that any coordinate u = u0(u0 ∈] − 1, 1[) appears also exactly two times on the boundary ∂S. The two points of∂S for which u = u0 are designated as VA and VB while the two points for which v = v0are designated as VC and VD. Note that those points appear interleaved while runningthrough ∂S (VA appears either after VD or after VC but never after VB). This means thatthere exists one point in S for which u = u0 and v = v0.

S S ′

u(x)

u = u0

VA

v = v0

∂S

∂S ′

u = u0

VCVB

VDv = v0

Figure 4.6: Iso-values of coordinates u and v on a surface S for which the mapping u(x)is computed as the solutions of the Laplace equation with Dirichlet boundary conditionsthat map ∂S on the unit circle ∂S ′.

Page 116: An introduction to Geometrical Modelling and Mesh Generation The ...

116 CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION

Figure 4.7 illustrates the Dirichlet boundary conditions that map the boundary of thetriangulation of the Toutankhamon mask ∂ST 1 to a unit circle. This boundary conditioncan be implemented by choosing arbitrarily a starting vertex M0

s on the boundary ∂ST 1.Then, the curvilinear abscissa li of point M0

i = xi along the curve can computed forall vertices along the curve of total length L. The mapping of the boundary nodes (theposition (ui, vi)) of M0

i in can then be written as:

(4.19) uD(xi) = cos

(2πli(xi)

L

), vD(xi) = sin

(2πli(xi)

L

).

Figure 4.7: Dirichlet boundary conditions: mapping the boundary of the Toutankhamonmask ∂ST 1 to a unit circle.

Instead of fixing all the boundary nodes ∂S1 to a convex polygon, one might fix two(u, v) coordinates, thus pinning down two vertices in the parameter plane with Dirichletboundary conditions. Indeed, for least square conformal maps, the mapping (4.15) has fullrank only when the number of pinned vertices is greater or equal to 2 [?]. Pinning downtwo vertices will set the translation, rotation and scale of the solution when solving thelinear system LCU = 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 pickingtwo 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 ofthese 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 withtwo pinned vertices with a less distorted LSCM that spreads the constraints throughoutthe mesh (we call this approach the constrained LSCM or CLSCM)

How can we define a less distorted least square conformal map (CLSCM) withoutpinning 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) thebarycenter of the solution must be at zero and (ii) the moment of inertia of the boundary∂ST 1 must be unit. Those constraints can be taken into account through recourse tospectral theory. This idea was derived also by Mullen et al. [?] and named after spectralconformal parametrization. In what follows, we try to present the spectral conformalmap in a more comprehensive manner than the way it is presented in [?].

The constrained least square conformal map corresponds to the following discreteconstrained minimization problem. Find U∗ such that

(4.20) U∗ = arg minU

1

2UTLCU, subject to UTE = 0,UTBU = 1.

The first constraint in (4.20) UTE = 0 states that the barycenter of the solution must beat zero. Indeed, as E denotes the 2I × 2 matrix that is such that Ei1 = 1, i = 1, ..., I and

Page 117: An introduction to Geometrical Modelling and Mesh Generation The ...

4.3. BOUNDARY CONDITIONS FOR DISCRETE MAPS 117

a) b) c)

Figure 4.8: Initial triangulation ST of a boudda statue a) that has been parametrized bycomputing b) the LSCM with two constrained vertices shown in red c) the constrainedLSCM solved with a spectral method.

Ei2 = 1, i = I + 1, ..., 2I (the other entries of E being zero):

E =

1 0...

...1 00 1...

...0 1

,

UTE = 0 is equivalent to∑I

i=0 U = 0 and∑I

i=0 V = 0. In in (4.20), the second constraintUTBU = 1 indicates that the moment of inertia of the boundary must be unit, the Bmatrix being a 2I × 2I diagonal matrix with 1 at each diagonal element correspondingto boundary vertices and 0 everywhere else. There are two different ways to solve thisconstrained minimization problem. The first method tries to find the optimum of thefollowing Lagrangian function L (U,µ) with Lagrange multipliers µi ≥ 0:

(4.21) L (U, λµ) =1

2UTLCU− µ(UTE)− λ(UTBU− 1).

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 tothe smallest non-zero eigenvalue of the matrix LC, i.e the vector satisfying

(4.22) LCU = λBU,

where λ is the smallest non-zero eigenvalue of LC. This generalized eigenvector U∗ iscalled the Fiedler vector of LC. We now show that optimizing (4.21) is equivalent tofinding the Fiedler vector U∗ (4.22). Indeed, for the discrete optimization problem, the

Page 118: An introduction to Geometrical Modelling and Mesh Generation The ...

118 CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION

solution must satisfy:

∂L∂U

= 0⇐⇒ LCU− µE− λBU = 0(4.23)

∂L∂µ

= 0⇐⇒ UTE = 0(4.24)

∂L∂λ

= 0⇐⇒ UTBU = 1(4.25)

That is, (LC − λB) U = µE . Premultiplying Eq.4.23 by ET gives:

(4.26) ETLCU− λETBU = µETE = µD,

where D is a 2 × 2 diagonal matrix with value I at both diagonal entries. But we havethat ETBU = 0 (combination of the two constraints (4.24) and (4.25)) and also thatETLC = 0 (because the matrix LC is a block matrix composed of Laplacian matrixes Aand antisymmetric matrices C that are such that

∑j Akj = 0 and

∑j Ckj = 0). Thus we

have µ = 0 and hence,

(4.27) (LC − λB) U = 0,

with U being the generalized eigenvector of the eigenvalue problem (4.22). The matrix LC

is positive semi-definite with smallest eigenvalue λ1 = 0 and corresponding eigenvector Ebeing the kernel vector (since we have that LCE = 0). Clearly E is not a solution to theproblem since it does not satisfy the constraint that the barycenter of the solution mustbe at zero. Since the LC matrix is positive definite positive, then it can be shown that thenext smallest eigenvalue λ2 is positive. The eigenvector associated with this eigenvalue(also called Fiedler vector) satisfies the constraint UTE = 0 because it is orthogonal tothe first eigenvector E. It also satisfies the constraint UTBU = 1 by proper scaling, andthus is the solution of the constrained minimization problem (4.20).

From a numerical point of view, there exists very efficient eigensolvers that find theFiedler vector U∗ of the sparse generalized eigenvalue problem we need to solve (4.22).Those methods usually proceed through Choleski decomposition (to turn the probleminto a conventional eigenvalue problem) and Lanczos iterations, particulary fast in ourcase since we deal with sparse matrices. Softwares libraries such as Slepc [?] or Arpack [?]provide all those methods for solving efficiently the generalized eigenproblem. It is how-ever interesting to transform the minimization problem (finding the Fiedler vector thatcorresponds to the smallest eigenvalue λ) (4.22) into a maximisation problem (finding thevector 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 = λLCU,

since this transformation makes the eigen solver more robust. As in Mullen et al. [?], wealso found that robustness to large triangulations with extremely degenerated trianglescould be improved by adding εId (with Id being the identity matrix) to LC in order to

Page 119: An introduction to Geometrical Modelling and Mesh Generation The ...

4.3. BOUNDARY CONDITIONS FOR DISCRETE MAPS 119

ensure that numerical inaccuracies in the coefficients of the conformal matrix LC will notalter the positive semi-definiteness of the matrix (we have used ε = 1.e−8). Finally, a lastinteresting transformation consists in removing the kernel of LC through the followingmodified generalized eigenvalue problem:

(4.29) (B−Be) U = λLCU, with Be =1

IB(BEETBT).

The vector U∗ we are looking for is the eigenvector corresponding to the largest eigenvalueλ. In (4.29), IB is the number of boundary nodes and the Be matrix is now a non-diagonalmatrix with value 1 for every matrix entry (i, j) and (i+ I, j + I) (where i and j are theindexes of the IB boundary nodes) and value 0 for all other entries. As this matrix Be

reduces the sparsity of the eigenvalue problem, we suggest to compute it with a reducedboundary matrix B that takes into account a limited number of nodes on the boundaryImaxB that are distributed uniformly along the boundary (usually we take Imax

B = 50). Toillustrate this, consider the very simple triangulation ST on Fig.4.9 with N = 5 nodes andIB = 4 boundary nodes. For this triangulation in Fig.4.9, the matrices Be and Be (with

2

1

3 4

5

Figure 4.9: Simple triangulation ST with 3 triangles, N = 5 vertices (I = 5 finite elementnodes for linear finite elements) and IB = 4 boundary nodes.

ImaxB = 2 = 1, 5) are given by:

Be =1

4

(L 00 L

), with L =

1 1 0 1 11 1 0 1 10 0 0 0 01 1 0 1 11 1 0 1 1

Be =1

2

(L 0

0 L

), with L =

1 0 0 0 10 0 0 0 00 0 0 0 00 0 0 0 01 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

Page 120: An introduction to Geometrical Modelling and Mesh Generation The ...

120 CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION

boundary conditions to be considered are natural boundaries, also called zero Neumannboundary conditions:

(4.30)∂u

∂n= 0, on ∂ST i

From an implementation point of view, those boundaries conditions correspond to a ”donoting BC” since the Neumann boundary condition is already taken into account in theminimization problem (4.10). Consider for example a surface ST that has two bound-aries denoted ∂ST 1 and ∂ST 2 (see Fig.4.10a)). Suppose now, we compute the discrete

∂ST 1

∂ST 2

ST A

ST B

a) b)

Figure 4.10: Triangulation ST A with two holes on which a discrete harmonic map u(x)is computed as solutions of the Laplace equations α∇2u = 0, α∇2v = 0 with boundaryconditions that map ∂ST 1 on the unit circle. The bottom a) figure shows the iso-u andiso-v values for the mapping (α = 1) of the surface ST that excludes the interior disk andfor which zero Neumann boundary conditions are applied on ∂ST 2. The bottom c) figureshows the iso-u and iso-v values for the mapping of ST that also includes the interior disk,and for which α = 1 inside ST A and α = 1.e−8 (small value) inside ST B.

Laplacian map by solving (4.17) with Dirichlet boundary conditions (4.19) on ∂ST 1 andzero Neumann boundary conditions on ∂ST 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 Neumannboundary conditions on ∂ST 1 is equivalent to the resolution of a Laplace problem on thewhole domain ST = ST A + ST B while defining a small diffusivity constant α (solvingα∇2u = 0, α∇2v = 0) inside the hole ST B (Figure 4.6b). This means that this problemalso obeys the same maximum principle as the one with constant diffusivity, which means

Page 121: An introduction to Geometrical Modelling and Mesh Generation The ...

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 Neumannboundary ∂ST (compare Figs. 4.10a with Fig. 4.6 that shows the Laplacian mapping forthe whole surface ST with a constant diffusivity parameter α = 1). That is the reason forwhich it might be desirable for surfaces ST that have several interior boundaries ∂ST i tomesh the surface ST B bounded by those boundaries and to compute the mapping for ex-tended surface ST that includes those newly defined mesh surfaces [?] ST = ST ∪

∑i ST 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 onepoint of the mesh. One can make a difference between global bijectivity and local bi-jectivity. The latter requires only that the maps of any sufficiently small region of themesh is bijective. If the discrete convex combination map is guaranteed to be bijec-tive, non-bijective parametrizations might occur when computing the discrete harmonicor conformal map as the solution of linear systems. Figure 4.11 shows two examples ofnon-bijective parametrizations. The top figure shows a discrete harmonic map for whichthe local bijectivity condition is violated. Indeed, the mapping of adjacent mesh trianglesintersect and the parametrization contains triangle flips. The bottom figure 4.11 shows aparametrization with a global domain overlap (global bijectivity violated). A well as theissues of bijectively, there exists an additional important numerical issue that concernsall type of mappings and that rarely mentionned in the litterature. This issue exists fortriangulations with large geometrical aspect ratio for which the mapping often containsclustered triangles with numerically undistinguisable node coordinates. We now discussthose three different issues and present different algorithms to get rid of those issues andto guarantee bijectivity.

The first issue concerns triangle flipping and is illustrated on the top of Fig.4.11.In this figure, looking at the triangles normals in the parametric space, one can see thatone triangle have been reversed (the normal of the face is flipped). Indeed, in contrast tothe continuous harmonic map, it was shown in [?, ?] that the discrete harmonic map is notalways one-to-one. To illustrate this, the next example introduced by Floater [?] showsthat the discrete harmonic map is not guaranteed to be one-to-one. Consider a coarsetriangulation (Figure 4.12) made of three triangles ST = (1, 2, 3), (1, 3, 4), (1, 4, 2) andlet x1 = (r, 0, 1) for some real value r > 0 and x2 = (1, 1, 0),x3 = (0, 0, 0),x4 = (1,−1, 0).The three boundary vertices x1,x2 and x3 are mapped onto the boundary of the unit disk(Figures 4.12b and c) and the vertex x1 should be mapped inside the triangle (u2,u3,u4) toensure a one-to-one mapping. However, numerical methods for solving Laplace equationmay not provide solutions that obey to a discrete maximum principle, especially whenmeshes 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 modifies mesh cavities in which

Page 122: An introduction to Geometrical Modelling and Mesh Generation The ...

122 CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION

u

v

uharm(x)

v

uconf(x)

u

Figure 4.11: Non-bijective parametrizations might occur when computing the discreteharmonic or conformal map as the solution of linear systems: (top) a parametrizationwhich contains triangle flips and (bottom) a parametrization with a global overlap oftriangles.

a) b) c)

Figure 4.12: a) Triangulation for which the discrete harmonic mapping is not guaranteedto be one-to-one: x1 = (r, 0, 1) for r > 0 and x2 = (1, 1, 0),x3 = (0, 0, 0),x4 = (1,−1, 0).b) Case r = 1.5: the mapping is one-to-one , c) Case r = 3.5 : the mapping is notone-to-one. The point u1 does not even lie within the unit disk.

flipping occurs. This algorithm goes as follows:

1. Compute harmonic map using finite elements;

2. For every interior vertex Vi of the parameter plane, check if each of its neighboringtriangles (defining a cavity) is oriented properly2;

2This is simply implemented by comparing normal orientations of the triangles in the parametric space

Page 123: An introduction to Geometrical Modelling and Mesh Generation The ...

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 thepolygon P surrounding the point (see Figure 4.13).

In order to find the kernel of a star-shaped polygon, different algorithms have been pro-posed in the literature[?, ?]. In this work, as the polygons have a small number of verticeswe have implemented a simple quadratic algorithm. It should be noted that the situationpresented in Fig. 4.13a) does occur very rarely and only occurs for very poor quality initialstl files. The local cavity check algorithm enables most of the time to repair the triangle

v2

v3

v5

v4

v1

T1

T4T2

T3

v2

v3

v5

v4

v5

v1

v6v2

v3

v5

v4

v1T1

T2

T3

T4

a) b) c)

Figure 4.13: Vertex v1 with four neighboring triangles T1 = (v1, v2, v3), T2 = (v1, v3, v4),T3 = (v1, v4, v5), T4 = (v1, v5, v2) defining the polygon P = (v2, v3, v4, v5). a) TriangleT3 (in red) is not well oriented and overlaps the triangles T2 and T4 . b) The vertex v1is moved and placed inside the kernel of the polygon P (yellow area), c) Now, all fourtriangles become well oriented without overlapping and hence the discrete mapping isguaranteed to be one-to-one for this cavity.

flips. However, in some cases of very low quality input meshes it might fail. In those casesin which the algorithm fails, we suggest to switch to a guaranteed one-to-one mappingintroduced by Floater [?, ?, ?]: the convex combination map. One possible definitionof the convex combination maps is the barycentric mapping [?, ?] that asks every interiorvertex ui be the barycenter of its neighbors:

(4.31) ui =

di∑k=1

λkuj ,

di∑k=1

λk = 1,

where di denotes the number of vertices that are neighbors to node i. The resulting systemof equations is also uncoupled as in (4.17):

(4.32) DU = 0, DV = 0,

the matrix D being now the assembly of the following elementary matrices Dkj for everytriangle Ti:

(4.33) Dkj =

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 4elements surrounding node v1 in Fig.4.13c, equation (4.31) is satisfied. This convex com-bination seems attractive from a mathematical point of view and is widely used in the

Page 124: An introduction to Geometrical Modelling and Mesh Generation The ...

124 CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION

computer Graphics Community. However, in the context of surface remeshing is not usedas default mapping since the metric tensor associated with this mapping is much moredistorted than the one obtained with the harmonic mapping. This in turn impacts on thequality of the the remeshing procedure. This is illustrated in Fig. 4.14 where an initiallylow quality triangulation ST has been remeshed with a parametrization based both on theconvex combination map and Laplacian harmonic map.

a) b) c) d)

Figure 4.14: Poor quality initial triangulation ST (a) that has been remeshed using aharmonic map (top figures) and a convex combination map (bottom figures): b) mappingof the initial mesh onto the unit disk ST ′ with iso-x and iso-v values in red, c) the deter-minant of the mesh metric tensor Mu that defines the area distorstion map and d) thefinal mesh obtained using the 2D Delaunay algorithms.

The second issue is about overlapping of triangles. This issue might occur whencomputing linear conformal maps with open boundaries. Indeed, a linear conformal algo-rithm cannot guarantee that triangles do not overlap. To remain efficient in the contextof surface remeshing, we use an idea similar to the one suggested by Sheffer et al. [?] thatchecks the presence of edge folding. Edge foldings are detected by looping over the edgesof the boundary ∂ST 1 and by computing if there exists intersections between the edges(see Fig. 4.15). The intersection of two edge segments (p1, p2) and (p3, p4) of parametricequations:

pa = p1 + ta(p2 − p1), pb = p1 + tb(p4 − p3),

can be computed by solving for the point where pa = pb. This gives the following linearsystem of equations:

(4.34)

(x2 − x1 x3 − x4y2 − y1 y3 − y4

)(tatb

)=

(x3 − x1y3 − y1

).

Page 125: An introduction to Geometrical Modelling and Mesh Generation The ...

4.5. AUTOMATIC REMESHING WITH PARAMETRIZATIONS 125

If ta ∈ [0, 1] and tb ∈ [0, 1], we are in the case of segment intersections. In the case of

p4

p1

p2

p3

Figure 4.15: Intersection boundary ∂ST 1 that is present in the case of triangle folding.

triangle folding, we suggest to switch to a harmonic mapping.

The last issue concerns indistinguishable coordinates. As shown in Fig.4.16and explained in [?] the solution of the mapping becomes exponentially small for verticeslocated away from ∂ST 1. As a consequence, local coordinates u and v of those far awayvertices might numerically become indistinguishable. By deriving an analytical solution ofLaplacian harmonic maps for cylinders, we showed in [?] that the geometrical aspect ratioof 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 ST of a mesh vertex tothe boundary ∂ST 1 and D is the equivalent diameter of the boundary ∂ST 1. As thedistance 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 forcylinders: η = 2πA/L2

∂ST 1, where A is the area of the 3D surface mesh and L∂ST 1

is the arc

length of the boundary ∂ST 1. The lower bound is estimated by choosing forH the maximalsize of the oriented bounding box of the 3D surface mesh and for D the maximal size ofthe oriented bounding box for the boundary curve ∂ST 1. The oriented bounding boxesare computed with the fast Oriented bounding box HYBBRID optimization algorithmpresented in [?] which combines the genetic and Nelder-Mead algorithms [?]. As weshowed in [?] that η = 4 corresponds to an area of mapped triangles of about r2i = 10−10

(see Eq. (23) and Fig. 10c in [?]), we choose ηmax = 4 as upper limit for the geometricalaspect 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 threelimitations, namely limitations on the genus G, the number of boundaries NB and the

Page 126: An introduction to Geometrical Modelling and Mesh Generation The ...

126 CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION

v

u

uharm(x)

∂ST 1

∂ST 2

D

H

x

zy

S ′TST

Figure 4.16: Issue of numerically indistinguishable coordinates illustrated for a Laplacianmap of a cylindrical mesh. When the geometrical aspect ratio η = H/D becomes too large,the vertices that are located far away from the boundary ∂ST 1 become exponentially closeto each other in the parametric space ST ′.

geometrical aspect ratio η. Those three criteria can be summarized as follows:

i) G = 0;

ii) NB ≥ 1;(4.36)

iii) η < ηmax.

In the next section, we will first consider a disk-like surface (G = 0, NB ≥ 1)and present a novel max-cut partitioning algorithm for those family of surfaces. We willthen present an automatic approach for arbitrary genus surfaces that combines this novelalgorithm 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 usingsuccessively a Laplacian map, a conformal map and a convex combination map. The

Page 127: An introduction to Geometrical Modelling and Mesh Generation The ...

4.6. QUALITY REMESHING WITH PARAMETRIZATIONS 127

quality of the isotropic meshes is evaluated by computing the aspect ratio of every meshtriangle 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 definition, the equilateraltriangle has κ = 1 and degenerated (zero surface) triangles have κ = 0. A can be seenfrom Fig.4.17 the conformal parametrization gives rise to the highest quality mesh whilethe worst is found to be the convex combination map. The Laplacian mapping has aslightly lower quality that can be explained by a loss in conformality at the boundariesthat 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

Fre

quen

cy

Aspect ratio

STL meshLaplacian map

Conformal map

0

Convex map

0.05

0.1

0.15

0.2

0.25

0.8 0.9 1

Fre

quen

cy

Aspect ratio

STL meshLaplacian map

Conformal map

0

Figure 4.17: Remeshing of an teeth. Top figures show the initial STL triangulation andnew mesh based on the conformal mapping and the bottom figures show the qualityhistogram obtained when remeshing the stl file with different mappings.

Page 128: An introduction to Geometrical Modelling and Mesh Generation The ...

128 CHAPTER 4. REMESHING BASED ON SURFACE PARAMETRIZATION

Acknowledgements

The authors gratefully acknowledge Electricite de France (EDF) for their financial support.We would also like to thank all persons that have contributed to the development, testingand debugging of Gmsh. Among those, we especially thank David Colignon for being suchan indefatigable beta-tester.


Recommended