CGAL alternative for 3D Boolean Operations

In computational geometry and CAD modeling, selecting the right 3D boolean library is crucial for efficient and accurate operations. Two popular choices, MeshLib and CGAL, offer different strengths and weaknesses. This article compares their performance in real-world scenarios to help you make an informed decision.sculptures. Efficiency and accuracy are paramount in these applications.

In this article, we’ll compare the performance of different 3D boolean libraries under various scenarios to help you make an informed decision.

What is MeshLib?

MeshLib is an open-source 3D geometry library that allows effortless creation of powerful 3D applications and execution of advanced operations using either C++ or Python. With its user-friendly interface and extensive documentation, MeshLib boolean operations simplify complex geometric tasks for developers of all levels, making it a preferred choice across industries.

What is CGAL?

CGAL (The Computational Geometry Algorithms Library, or C GAL) is an open-source software library of computational geometry algorithms, primarily written in C++, with bindings available for Scilab, Python, and Java. It offers dual licensing, providing open-source licenses for use in open-source projects and commercial licenses for other applications. Known for its precision and efficiency, CGAL boolean operations are trusted by developers for handling complex geometric computations reliably.

MeshLib vs CGAL comparison results

Testing Setup – Windows 11, Intel Core i7-12700H processor, 32GB of RAM, NVIDIA RTX 3060m with 6GB of VRAM

For access to input and result meshes used in our tests, visit this link.

Nefertiti Case

This scenario involves large meshes (2M Triangles each) with complex topology, representing a common challenge in 3D boolean operations.

Union

Mashlib% filename%

Meshes were slightly shifted.

Mashlib% filename%

Intersection

Meshes were slightly shifted.

Mashlib% filename%

Difference A-B

Meshes were slightly shifted.

 

Mashlib% filename%

Copy

Two identical meshes.

 

MeshLib
CGAL
Nefertity – Union​
1.2 (1.4)
7.5
Nefertity – Intersection
0.7 (0.9)
6.7
Nefertity – Difference
0.9 (1.1)
7
Nefertity – Copy
7.3 (7.7)
hangs

Comments

MeshLib demonstrates significantly faster processing times compared to CGAL. For instance, MeshLib completes the union operation (U) in 1.2 units, while CGAL takes 7.5 units, indicating MeshLib’s superior efficiency in these operations.

MeshLib completes the union operation on copied meshes without any issues, whereas CGAL experiences hangs, indicating potential stability issues with CGAL in this scenario.

Dental Case

In this case, we simulate dental models (≈500K Triangles) with degeneracies and coinciding surfaces, reflecting real-world scenarios encountered in medical applications.

Mashlib% filename%

Union

Mashlib% filename%

Intersection

Mashlib% filename%

Difference A-B

MeshLib
CGAL
Dental – Union​
0.18 ( 0.21)
1.6
Dental – Intersection
0.17 ( 0.20 )
1.6
Dental – Difference A-B
0.20 ( 0.22 )
1.7

Comments

MeshLib consistently outperforms CGAL in all degenerate mesh scenarios, with faster processing times and no crashes, indicating MeshLib’s robustness in handling complex geometries.

Simple Objects Case

In this case, we compare how algorithms behave when handling complex geometries.

Mashlib% filename%

Holed, Not Intersected

Boolean Union of meshes, one with a hole aside from the intersection part.

Mashlib% filename%

Holed Intersected

Boolean Union of meshes, one with a hole into the intersection part.

Mashlib% filename%

Self-Intersections​

Boolean Union of meshes, one with self-intersections into meshes’ intersection part.

MeshLib
CGAL
Holed, Not Intersected
Yes
Yes
Holed Intersected
No*
No
Self- Intersections
No**
No

Comments

Both MeshLib and CGAL exhibit similar performance in scenarios involving holes and self-intersections, with no significant differences observed.
* MeshLib does not support the representation of non-manifold meshes and automatically converts them to a manifold form.
** The results of such operations are not well-defined, leading to a mesh with numerous inconsistencies, such as self-intersections and degeneracies.

Why choose MeshLib SDK for 3D boolean operations over CGAL?

In summary, while both MeshLib and CGAL offer robust solutions for 3D boolean operations, MeshLib demonstrates superior performance in most scenarios, with faster processing times and greater stability, particularly in handling complex or copied meshes. Developers may prefer MeshLib for its efficiency and reliability in real-world applications.

Play Video