C++ examples of Fade2D
Fade2D contains a collection of small, self-contained C++ examples, each of which demonstrates, step by step, how to apply the library practically for a certain topic.
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. Furthermore you can 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 land surveying.
- 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, use WOF to reconstruct the surface of a 3D point cloud.
“The difference between 2.5D and 3D is that a 2.5D point cloud describes a surface f(x,y) where 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 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.“
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.
4 replies on “C++ Examples – Getting Started (0)”
Hi. This looks like a great library and would be very useful for my research. But I don’t know the first thing about C++. I have a C#/Visual Basic application in which I would like to perform constrained Delaunay triangulations. Is there any way to import this into a C# or Visual Basic project?
Hi
The easiest solution is certainly creating a small C++ application with Fade that you call from your C# or VB application. I do not program C# but if you want to create an interface I will support you as good as I can. Just give me an email in this case.
Will macOS-arm64 be supported (without using Rosetta)?
Thank you for asking. Yes, supporting arm64 makes sense. If it’s commercial, pls. get in contact so that I can assign it high priority.