## C++ examples of Fade2D

Fade2D contains a collection of small, **self-contained C++ examples**. Each example demonstrates step by step for a certain topic how to **apply the library practically**.

For example, the goal of this very first example is to show you how to **compile** C++ source code with Fade2D and how to **create and draw a triangulation**. Find the other examples here:

- C++ Examples for 2D triangulations and Voronoi diagrams
- C++ Examples for 2.5D triangulations and meshing algorithms

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

## Point clouds: 2D and 2.5D vs. 3D

Before we jump into the source code, here’s a short clarification about the dimensions:

**Fade2D**is a classic**2D Delaunay triangulation**software for the xy-plane. It offers constraint edges, zones, boolean operations and more.**Fade2.5D**is like Fade 2D a Delaunay triangulation but for lifted points. More precisely, the library has**all functions**of Fade2D plus- a
**z-coordinate**and **additional algorithms**from the field of

**Fade3D**is a Delaunay triangulation for 3D point clouds. But it is more precise to call it a 3D tetrahedralization because it creates**tetrahedra**, not triangles. If you want triangles instead you can use WOF to reconstruct the surface of a 3D point cloud.

“Thedifference between 2.5D and 3Dis that a 2.5D point cloud describes a surface f(x,y), i.e. each coordinate pair (x,y) has only one z-coordinate. This is ideal for terrain data and other height fields, but a simple sphere is not 2.5D, for example.”

## Example0: HelloTriangulation

The first C++ code example is equivalent to HelloWorld:

- It creates a
`Fade_2D`

object and 4 points. - Then it inserts the points.
- Afterwards it draws the resulting triangulation.

// 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");

“

If you want to use Fade“2.5Dit might be helpful to look at the 2D examples as well, because they cover the basics that also apply to Fade2.5D.

## Compiling under Windows

- Unzip and enter the
`examples_xx`

folder - Afterwards open the Visual Studio solution file (*.sln) for VS20xx and compile.
- Then find the executable in the x64 (or Win32) folder and finally start it in a command line window.

“It is best to start the executables in a command line window. Hint: In a Windows Explorer window mark the address bar and type “cmd” to open a command line window at the same path.”

## Compiling under MacOS and Linux

- Make sure you have gmp installed. For instance (Debian):
`sudo apt-get install libgmp10`

- Afterwards enter the
`examples_xx`

directory - Then open the contained Makefile and uncomment
**only**your OS version

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

- Type
`make`

- Finally start the executable in the same directory

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