Example0 – Getting Started

Getting Started with the Fade Delaunay Triangulation

The Delaunay triangulation library supports 2D and 2.5D, hence it comes as two separate libraries, Fade2D and Fade2.5D. They have a common code base and thus they are very similar to use. The difference is a z-coordinate and additional functionality in the 2.5D version. To facilitate your start with Fade, a collection of C++ example source codes is contained. The examples are small and well documented. They go step by step over the concepts of Fade and show how you can use the library to solve your practical problems.

2.5D Delaunay vs. 3D Delaunay

Before we start, a short clarification of 2.5D vs. 3D: 2.5D is like a function z=f(x,y): There is a unique z value per (x,y) pair and thus vertical walls or overhanging elements like in 3D are not possible. The advantage of 2.5D Delaunay compared with 3D Delaunay is, besides speed, that 2.5D Delaunay is a triangulation while 3D Delaunay is a tetrahedralization.

2D Delaunay Triangulation

2D Delaunay Triangulation

2.5D Delaunay

2.5D Delaunay Triangulation

3D Surface

Full 3D Surface

If you are new to Fade you should work through the 2D source codes (Example0 – Example6) first. The basics are described there and they apply also to 2.5D triangulations.

Compiling the examples under Windows

Fade is a lightweight library, thus you can simply unzip and start: Enter the example_2D (or example_25D) folder, open the Visual Studio solution file (*.sln) for VS2008, VS2010, VS2012, VS2013, VS2015 or VS2017 and compile. Find the executable in the x64 (or Win32) folder. It is best to start the executable in a command line window (in a Windows Explorer window, mark the address bar and type “cmd” to open a command line window at the same path)

Compiling the examples under MacOS and Linux (PC, Raspberry PI)

Use the package manager or graphical installer of your operating system to install libgmp. For Debian, Raspbian, Ubuntu the command is for example

sudo apt-get install libgmp10

Enter the examples_2D or examples25D directory and edit the contained Makefile to match your operating system:

# Choose a matching distribution below:
#DISTRO :=../lib_centos6.4_${ARCHITECTURE}
#DISTRO :=../lib_ubuntu14.04_${ARCHITECTURE}
#DISTRO :=../lib_fedora24_${ARCHITECTURE}
DISTRO :=../lib_ubuntu17.04_${ARCHITECTURE}
#DISTRO :=../lib_APPLE
#DISTRO :=../lib_raspberry_armv6l
#DISTRO :=../lib_raspberry_armv7l

Ready. Now type make to compile and start the executable in the same directory.

Note: All described example source codes are contained in the download

Example0 – HelloTriangulation

Let’s start with a hello world equivalent application: 10 lines of code triangulate 4 points and draw the result.

// An empty triangulation
Fade_2D dt;  

// 4 points
Point2 p0(0.0,0.0);
Point2 p1(1.0,0.0);
Point2 p2(0.5,2.0);
Point2 p3(0.5,0.5);

// Insert the points
dt.insert(p0);
dt.insert(p1);
dt.insert(p2);
dt.insert(p3);

// Draw as postscript graphic
dt.show("example0.ps"); 
Output, drawn by the Hello-Triangulation example

Example0 – HelloTriangulation: Four points are triangulated and drawn

The next example benchmarks the performance of Fade on your computer.

Spread the word. Share this post!

Leave A Reply

Your email address will not be published. Required fields are marked *

*

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close