Categories
Fade2D Examples

C++ Examples – Getting Started (0)

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…Continue readingC++ Examples – Getting Started (0)

Categories
Fade2D Examples

2D Delaunay Triangulation Benchmark – Example1

Fade2D is a numerically robust and extremely fast C++ Delaunay triangulation library. Certainly you can verify that on your own hardware with the below Delaunay triangulation benchmark. You can find this code in examples2D/ex1_benchmark.cpp. Benchmark Code Step 1 in the above code creates an empty Fade_2D object and makes two important performance settings: Fade_2D::setFastMode(bool b)…Continue reading2D Delaunay Triangulation Benchmark – Example1

Categories
Fade2D Examples

Access Triangulation Elements and draw Postscript – Example2

This article has two goals: First, it shows how you can access the elements of a triangulation. Second, it shows how you can draw them. Because development is much easier when you can visualize your work. Preparing a triangulation Let’s prepare and draw a simple triangulation for this demo: In Step 1 we fill the…Continue readingAccess Triangulation Elements and draw Postscript – Example2

Categories
Fade2D Examples

Constraint Edges – Example3

When you triangulate just the vertices of a polygon, it is not guaranteed that its edges are edges of the resulting Delaunay triagulation. But you can enforce edges in a triangulation as demonstrated in the below example where constraint edges are inserted into a 2D triangulation. Similarly you can insert breaklines into 2.5D triangle meshes,…Continue readingConstraint Edges – Example3

Categories
Fade2D Examples

Polygons and Zones – Example4

This is the right example if you want to triangulate polygons or perform polygon clipping. In Fade, a Zone2 object defines a specific area of a triangulation. It allows you to combine shapes using the Boolean set operations union, difference, symmetric difference and intersection. The result is again a zone whose area and boundary can…Continue readingPolygons and Zones – Example4

Categories
Fade2D Examples

Polygon Clipping, Boolean Operations – Example5

Polygon Clipping, Boolean Set Operations Fade provides polygon clipping and functions to combine shapes 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 C++ source code for the polygon clipping demo in examples_2D/ex5_booleanOps.cpp in the Fade download. Creating two…Continue readingPolygon Clipping, Boolean Operations – Example5

Categories
Fade2D Examples

Practical Boolean Operations on Polygons with Holes – Example 6

Boolean operations on Polygons with Holes can be difficult to implement. Thus the present example examples_2D/ex6_booleanOps2.cpp consists of ready-made C++ source code that handles arbitrary shapes (convex or non-convex, with or without holes). So feel free to use it in your project. You might also want to check the previous Example5. For example, it demonstrates…Continue readingPractical Boolean Operations on Polygons with Holes – Example 6

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…Continue readingAdvanced Delaunay Meshing – Example 7

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…Continue readingExporting a Triangulation – Example 8

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…Continue readingRandom Polygons, Surfaces and more – Example 9

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…Continue readingProgress Bar Mechanism – Example 10

Categories
Fade2D Examples

Saving and Loading a Triangulation – Ex. 11

Manually saving and loading a triangulation is difficult. 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 file “examples_2D/ex11_save_and_load.cpp” provides simple demo source code for…Continue readingSaving and Loading a Triangulation – Ex. 11

Categories
Fade2D Examples

Voronoi Diagram 2D in C++, Example 12

This is a fast C++ Voronoi diagram example. The Voronoi diagram (Wikipedia) divides the plane into convex regions around the input points such that each region is closest to one point. There is an incredible number of applications for the Voronoi diagram so many scientists and engineers are familiar with this basic concept. A C++…Continue readingVoronoi Diagram 2D in C++, Example 12

Categories
Fade2.5D Examples

2.5D Terrain Triangulation and Point Cloud Simplification

2.5D Delaunay triangulations (TIN – Triangulated Irregular Networks) are like a 2D Delaunay triangulation, but with elevated points. This article first describes the simple triangulation of point clouds from LiDAR scans and surface metrology data. It then demonstrates their optional simplification using adaptive and grid-based clustering methods. Finally, it shows how to re-export the triangle-mesh…Continue reading2.5D Terrain Triangulation and Point Cloud Simplification

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 large edges at the boundary of a triangulation and we…Continue readingValleys and Ridges, Smoothing, Mesh-Improvements

Categories
Fade2.5D Examples

Breaklines, ISO Contours and the Cookie Cutter

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 results in…Continue readingBreaklines, ISO Contours and the Cookie Cutter

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. But 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. The Segment Checker is fast and robust against degenerate and glancing intersections.…Continue readingSegment Checker for 2D and 2.5D Segment Intersections

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…Continue readingCut and Fill Volumes in C++