Categories
Fade2D Examples

Getting Started – Example0

Get Started with 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. In addition, it demonstrates how to triangulate 2D points with just a few lines of code and how to visualize the triangulation.

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

Dimensions: 2D, 2.5D and 3D Delaunay

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
  • Fade2.5D is like Fade 2D a Delaunay triangulation but with lifted points. More precisely, the library has all functions of Fade2D plus a z-coordinate and additional algorithms from the field of land surveying. The difference between 2.5D and 3D is 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 could not be triangulated with 2.5D, for example.
  • A real 3D point cloud (e.g. a ball) can be triangulated with WOF or can be tetrahedralized with Fade3D.
2D Delaunay
2.5D Delaunay
3D Point Cloud

If you want to start with Fade2.5D it might be helpful to look at the 2D examples as well, because they cover the basics that also apply to Fade2.5D.

Example0 – HelloTriangulation

This HelloWorld-equivalent application triangulates 4 points and then it draws 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");
Example0 – HelloTriangulation: Four points are triangulated and drawn

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.

Leave a Reply

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