+ All Categories
Home > Documents > Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to...

Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to...

Date post: 03-May-2018
Category:
Upload: lyque
View: 267 times
Download: 14 times
Share this document with a friend
26
Detri2 Tutorial: Generating Triangulations of Point Sets Hang Si
Transcript
Page 1: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

Detri2 Tutorial: Generating Triangulations

of Point Sets

Hang Si

Page 2: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

General Remarks• In this tutorial, we’re going to learn how to use Detri2 to

create (arbitrary) triangulations, Delaunay triangulations of 2d point sets, and to visualise the algorithms.

• learn how to create an input point set within the free program Gmsh.

• learn some basic Detri2 command line options to generate these triangulations.

• learn how to visualise the triangulations in the free program Paraview.

Page 3: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

• I assume you have already compiled Detri2 and got the executable file, like, detri2.exe in Windows, or other detri2 binary files for Linux, or Mac OSX.

• I assume you have installed both Gmsh and Paraview in your system. They are both available in the CourseSoftware directory.

• For saving output files (there will be many output files by detri2 for visualising algorithms) I also created a ``demo” directory in my Desktop.

Install these two programs

create a new directory on your Desktop

Page 4: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

The Input file of Detri2

Page 5: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

• Detri2 reads a .node file (an ASCII text file) which stores a list of 2d points. The .node file format is exactly the same as Triangle’s .node file format.

• Below is an example input file of a set of 7 points in 2d.

A ‘#’ means comments

number of points2 dimension

point index

x, y coordinates

An example input file: r7.node

Page 6: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

• Alternatively, Detri2 can read the .geo file format of Gmsh which stores a list of points and straight line segments.

• Below is an example of a .geo file.

• It is convenient to use Gmsh’s GUI to create and save a .geo file.

A point

An example input p8.geo file of Gmsh

Page 7: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

Use Gmsh to create an input file for Detri2

Page 8: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

• Below figures show how to use Gmsh’s GUI to create and save a .geo file.

first click ``Geometry”

click ``Point” to create points

Page 9: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

• Below figures show how to use Gmsh’s GUI to create and save a .geo file.

save a file (must with .geo)

once finish creating points, choose ``save as…”

Page 10: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

Use Detri2 to generate a triangulation from Gmsh’s .geo file

Page 11: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

• Let the new created .geo file and the executable detri2.exe be in the same directory, like ``demo”.

Page 12: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

• We need a command line shell to run detri2

type ``cmd” to open a command line shell

Page 13: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

• Within the ``demo” directory, run the command: ``detri2.exe -Gu -Gd point.geo”

• The above command will generate the Delaunay triangulation of the point set.

• With the option (-Gu) detri2 will save the final triangulation into a file which can be visualised by Paraview.

• With the option (-Gd) detri2 will save all the intermediate triangulations into files which can be visualised by Paraview. This helps to visualise the algorithm.

type this command

first go to the ``demo” directory

Page 14: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

• Within the ``demo” directory, run the command: ``detri2.exe -Gu -Gd point.geo”

• The above command will generate the Delaunay triangulation of the point set.

• With the option (-Gu) detri2 will save the final triangulation into a file which can be visualised by Paraview.

• With the option (-Gd) detri2 will save all the intermediate triangulations into files which can be visualised by Paraview. This helps to visualise the algorithm.

files can be visualised by Paraview

Page 15: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

Use Paraview to visualise the triangulations

Page 16: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

• Start Paraview

start ``Paraview”

Page 17: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

• Open files

click

Page 18: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

• Select ``AVS UCD Binary/ASCII Files”

select

Page 19: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

• Click the ``Apply” button.

click

Page 20: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

• It shows the first triangulation (which is only a triangle). Click the ``play” button.

click

Page 21: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

• Once it stops, it shows the last Delaunay triangulation. done!

Page 22: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

More command line options

Page 23: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

• Before you try a different option, it is better to delete all the generated .inp files for Paraview. Otherwise you may get too many files in your computer.

Page 24: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

• Use the sweep-line algorithm (-Ss#,#) to generate an initial triangulation, non-Delaunay (-L), where #,# defines a 2d vector which is the normal of the sweep-line.

• Command: detri2 -Ss0.5,0.5 -L -Gu points.geo

TRIANGULATIONS OF POINT SETS IN R2 9

Algorithm: LineSweep(S, s)Input: A set S of n points in R2, s is the normal of sweep line;Output: A triangulation T of S;1 sort the points in S into a sequence L := {p1, . . .pn

} along s;2 initialize T with only one triangle {p1,p2,p3};3 for i = 4 to n do4 let Q be the set of all visible edges of p

i

;5 create new triangles to T by each edge in Q and p

i

;6 endfor

Figure 10. The sweep line triangulation algorithm.

Figure 11. Construction a triangulation by a line-sweep algorithm.

newly created triangles is less than 2n � 4. Thus this line sweep algorithm constructs atriangulation in O(n log n) time.

This section introduces the Delaunay triangulation of any point set in the plane. Itis introduced by the Russian mathematician Boris Nikolaevich Delone (1890–1980) in1934 [3]. It is a triangulation with many nice properties. There are many ways to defineDelaunay triangulations. We first introduce them as duals of Voronoi diagrams, thenintroduce other equivalent definitions while showing their properties.

2. Delaunay Triangulations

2.1. Voronoi diagrams. Voronoi diagrams are named after the Russian and Ukrainianmathematician Georgy Feodosevich Voronoy (1868–1908) in 1907 [15]. Voronoi diagramsarise in nature in various situations. They are the one of the most fundamental datastructures in computational geometry.

Voronoi diagram divides the plane according to the nearest-neighbour rule: Each pointis associated with region of the plane closet to it.

Let S be a set of n points (called sites) in R2. the Voronoi region of a site p 2 S isthe set of points x 2 R2 that are as close to p as to any other site in S, that is

Vp

= {x 2 R2 | kx � pk kx � qk, 8q 2 S},

where k · k means Euclidean distance.

Page 25: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

• Use the Lawson’s flip algorithm (-l) to transform a non-Delaunay triangulation (points.1.ele) into the Delaunay triangulation.

• Command: detri2 -l -Gu points.1.eleTRIANGULATIONS OF POINT SETS IN R2 17

Figure 22. Lawson’s flip algorithm takes an arbitrary triangulation(left) as input and returns the Delaunay triangulation (right).

Figure 23. The lifted view of the Lawson’s flip algorithm which trans-forms a non-convex surface (left) in 3d into a convex one (right).

2.4.4. Termination and running time. Flipping ab to cd is likely gluing a tetrahedrona0b0c0d0 from below to a0b0c0 and a0b0d0.

The algorithm can be understood as gluing a sequence of tetrahedra. Once we gluea0b0c0d0 we cannot glue another tetrahedron right below a0b0. In other words, once weflip ab we cannot introduce ab again by some other flip. This implies that the Lawson’sedge-flip algorithm will eventually terminate when all locally non-Delaunay edges areflipped. By the Delaunay lemma, the triangulation is Delaunay. This also implies thereare at most as many flips as there are edges connecting n points, namely

�n

2

�. Each flip

takes constant time, hence the total running time is O(n2).

2.4.5. The MaxMin angle property. We illustrate an optimal property of the Delaunaytriangulation.

Theorem 2.3. Among all triangulation of a finite point set S ⇢ R2, the Delaunay

triangulation maximises the minimum angle.

Proof. A flip substitute two new triangles for two old triangles. It therefore changes sixof the angles, see Figure 24. The six old angles are:

↵1, �1, �1 + �2, ↵2, �2, �1 + �2,

Page 26: Detri2 Tutorial: Generating Triangulations of Point Sets · • In this tutorial, we’re going to learn how to use Detri2 to create (arbitrary) ... • I assume you have installed

• Use the Lawson’s flip algorithm (-l) to transform a non-Delaunay triangulation (points.1.ele) into the Delaunay triangulation, and save the lifting triangulation (-GL) as well, and save all the intermediate triangulations (-Gd).

• Command: detri2 -l -Gu -GL -Gd points.1.ele

TRIANGULATIONS OF POINT SETS IN R2 17

Figure 22. Lawson’s flip algorithm takes an arbitrary triangulation(left) as input and returns the Delaunay triangulation (right).

Figure 23. The lifted view of the Lawson’s flip algorithm which trans-forms a non-convex surface (left) in 3d into a convex one (right).

2.4.4. Termination and running time. Flipping ab to cd is likely gluing a tetrahedrona0b0c0d0 from below to a0b0c0 and a0b0d0.

The algorithm can be understood as gluing a sequence of tetrahedra. Once we gluea0b0c0d0 we cannot glue another tetrahedron right below a0b0. In other words, once weflip ab we cannot introduce ab again by some other flip. This implies that the Lawson’sedge-flip algorithm will eventually terminate when all locally non-Delaunay edges areflipped. By the Delaunay lemma, the triangulation is Delaunay. This also implies thereare at most as many flips as there are edges connecting n points, namely

�n

2

�. Each flip

takes constant time, hence the total running time is O(n2).

2.4.5. The MaxMin angle property. We illustrate an optimal property of the Delaunaytriangulation.

Theorem 2.3. Among all triangulation of a finite point set S ⇢ R2, the Delaunay

triangulation maximises the minimum angle.

Proof. A flip substitute two new triangles for two old triangles. It therefore changes sixof the angles, see Figure 24. The six old angles are:

↵1, �1, �1 + �2, ↵2, �2, �1 + �2,


Recommended