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…

Categories
Fade2D Examples

2D Delaunay Triangulation Benchmark – Example1

Fade2D is a very fast Delaunay triangulation library. With this C++ Delaunay benchmark code you can test its performance on your own hardware. Benchmark Code The above source code starts with a call to Fade_2D::setNumCPU(int numCPU): numCPU=0 means autodetect numCPU=1 means single-threaded (default) numCPU>1 activates multithreading Then it sets up the test sizes Finally the…

Categories
Fade2D Examples

Access And Draw Triangulation Elements – Example2

Developing geometry software is much easier when you can visualize your work.This article shows how you can access the individual geometric objects in Fade and also how you can draw them. Have a look at the code below: The vector vPoints is filled with 6 points on a circle plus the center point (Fade conveniently…

Categories
Fade2D Examples

Constraint Edges – Example3

When you triangulate the vertices of a polygon, its edges are not always contained in the Delaunay triangulation. But you can insert the edges as constraint edges. This is shown for 2D below. Similarly we can insert breaklines into 2.5D triangle meshes, see 2.5D Terrain Triangulation. Create a Delaunay triangulation This code creates an initial…

Categories
Fade2D Examples

Polygons and Zones – Example4

This is the right article if you want to triangulate polygons or carry out polygon clipping. In Fade, a zone defines a specific area of a triangulation and you can use it to combine shapes with the boolean set operations union, difference,symmetric difference and intersection. From the result zone you can easily calculate the total…

Categories
Fade2D Examples

Polygon Clipping, Boolean Operations – Example5

Polygon Clipping, Boolean Set Operations Fade provides polygon clipping and functions to combine polygons through the boolean operations: Union (A OR B) Intersection (A AND B) Difference (A NOT B) Symmetric Difference (A XOR B) You can find the demo source in examples_2D/ex5_booleanOps.cpp in the Fade download. Creating two Shapes You will notice that the…

Categories
Fade2D Examples

Practical Boolean Operations on Polygons with Holes – Example 6

The previous Example5 showed already how to create shapes i.e., Zone2 objects out of polygons and also how to carry out Boolean operations with them. Nevertheless, there might be questions about the practical implementation, especially when your polygons have holes. For this reason, the present Example6 consists of ready-made C++ source code that handles arbitrary…

Categories
Fade2D Examples

Advanced Delaunay Meshing – Example 7

The term Delaunay meshing does not mean simply creating a Delaunay mesh on points, but it is about Quality Meshing i.e., creating a Delaunay mesh with triangles that have a very specific quality. This is generally achieved by adding points, that is, by refining an existing triangulation. As always you can find the below source…

Categories
Fade2D Examples

Exporting a Triangulation – Example 8

A frequently asked question is how to export a triangulation as a list of points and indices. Up to now this could be done with the help of custom indices and it still works. But since Fade v1.84 there is an explicit solution for this task, which is also memory efficient, because it releases the…

Categories
Fade2D Examples

Random Polygons, Surfaces and more – Example 9

When coding geometry, numerical errors and unexpected geometric settings occur frequently. Thus automated software testing with random geometric data is essential. But for example creating random polygons without self-intersection is not trivial at all. Therefore the module testDataGenerators is provided to create repeatable sequences of random geometric objects for software testing and debugging. These are…

Categories
Fade2D Examples

Progress Bar Mechanism – Example 10

Fade is fast and most of the time you will not need progress updates at all. But for very large triangulations you may still want to connect your own progress bar to Fade2D’s update mechanism. Your own Progress Receiver Class Create some custom class that derives from MsgBase so that it can receive messages from…

Categories
Fade2D Examples

Saving and Loading a Triangulation

Saving and loading a triangulation is not trivial. This is especially true when there are millions of elements and it must be fast. For this reason, there are functions in Fade to support you in saving and loading a triangulation, it’s zones and constraint edges. The contained source file “examples_2D/ex11_save_and_load.cpp” provides simple demo code for…

Categories
Fade2.5D Examples

2.5D Terrain Triangulation and Point Cloud Simplification

2.5D Delaunay triangulations (TIN – Triangulated Irregular Networks) are like a classic 2D Delaunay triangulation, but with elevated points. This article describes the optional simplification of point clouds from LiDAR scans and surface metrology data using adaptive and grid-based clustering methods. Further it shows how to triangulate point clouds in a memory-efficient way and how…

Categories
Fade2.5D Examples

Valleys and Ridges, Smoothing, Mesh-Improvements

In this example, we will flip edges in an unnatural looking triangulation to better match its valleys and ridges. Further we will use Fade’s Weighted Laplacian smoothing technique to improve the quality of a noisy triangle mesh. And finally we address an annoying problem, namely bad shaped triangles at the boundary of a triangulation. We…

Categories
Fade2.5D Examples

Breakline Insertion, ISO Contours and the Cookie Cutter

Breakline insertion In the field of land surveying constraint edges are maybe better known as “breaklines”. Similarly to the 2D case you can insert them into the triangle mesh, forcing segment subdivision or not. In addition you can insert a segment with its original height or you can adjust its height to the triangulation. This…

Categories
Fade2.5D Examples

Segment Checker for 2D and 2.5D Segment Intersections

The Segment Checker computes intersections of 2D or 2.5D line segments. In contrast to 3D two line segments are considered to intersect when their 2D projections in the xy-plane intersect. In other words, even if the involved segments are at different heights. Most importantly the Segment Checker is fast and in addition it is robust…

Categories
Fade2.5D Examples

Cut and Fill Volumes in C++

Cut And Fill (Wikipedia) Earthwork volume computations for C++. The library module Cut-And-Fill takes two overlapping surfaces and computes the volume between. The result is a set of volumes where soil must be filled or where material must be digged off to turn one surface into the other one. Example Source Code – Basic Usage…