3D Mesh Intersection

Mesh intersection computes the exact common volume shared by two polygonal models. Its potential, is applied to 3D data processing, computational geometry, and computer graphics. Namely, it enables precise extraction of overlapping geometries. That is how it ensures that only the regions where meshes occupy the same space are retained.

Please note: when referring to mesh intersection, one might mean either a subtype of Boolean operations (as in this case) or mesh collision detection. If you are interested in the Boolean meaning, this section is for you. If you are looking for collision detection, here is another guide for you.

Mesh intersection is fundamental for combining complex shapes and refining models across a variety of domains. To name a few:

  • In CAD and engineering, Mesh intersection verifies how components fit together by isolating mating surfaces.
  • As for additive manufacturing and 3D printing, mesh intersection operations check for hidden overlaps between parts in a build tray to prevent fused prints or weak joints.
  • Regarding scientific visualization and simulation, mesh intersection identifies intersecting volumes for structure interactions or medical imaging analyses.

All in all, by focusing computation only on shared volumes, this manipulation enhances both accuracy and performance across modeling and design.

Mesh Intersection Algorithms

Given the importance of mesh intersection, it is no surprise that there exist multiple approaches and mesh intersection algorithms. These ones come to mind first:

  1. Exact-Arithmetic & B-Rep. Building a precise boundary representation via rational arithmetic or robust predicates. Then face–face slicing via CSG (constructive solid geometry) is performed:
  • Strengths. Watertight results are guaranteed. Degeneracies are handled without failures.
  • Cons. Higher memory footprint is inevitable. It is a slower and more complex option to implement for intersecting meshes.

 

  1. Floating-Point and Tolerance-Based CSG. Employing floating-point arithmetic with user-tunable epsilon thresholds to clip one object by the planes of another and classify fragments.
  • Strengths. In general, it is faster and simpler than the previous one. As such, it is well-suited regarding most objects.
  • Cons. It can produce cracks, slivers, or non-manifold edges if tolerances are not tuned carefully.

 

  1. BSP-Tree CSG. Recursively subdividing space with splitting planes and classifying entire model fragments as inside or outside before reassembling the intersected region.
  • Strengths. Very fast when it comes to complex and static scenes, as well as multi-mesh combinations.
  • Cons. Here, trees can become unbalanced. Also, memory and storage overhead for fragment data can be high.

 

  1. Voxel and Grid-Based Methods. Rasterizing each object into a 3D occupancy grid, computing the Boolean on the grid cells, then extracting the intersected surface with an iso-surfacing algorithm.
  • Strengths. It is intrinsically robust to degeneracies. On top of that, it is trivially parallelizable.
  • Cons. Surface fidelity suffers unless using very fine grids, which greatly increases memory use.

Finally, let’s discuss what fuels our engine. As far as MeshLib is involved, our capability to find intersections between meshes for computer graphics and similar tasks is based on the Simulation of Simplicity (SoS) paradigm. Rather than handling every degeneracy explicitly, SoS treats input geometry as if it were in ‘general position.’ No two vertices coincide exactly, no edges overlap, and no zero-length distances exist.

Internally, every comparison and intersection test uses symbolic perturbations to break ties and avoid special-case logic. As a result, we behave as though no degenerate cases can occur.

Hence, MeshLib’s toolbox delivers:

  • Solid robustness. We do not crash or yield invalid topology on messy models.
  • Consistent performance. Inner loops remain branch-light and highly optimized.
  • Straightforward implementation. The core routines assume only generic inputs.

Mesh to Mesh Intersection

It is a moment to take a step back for a second. Again, the mesh intersection formula looks as follows:

A B = { x 3 | x A x B }

The operation itself generates a new mesh representing exactly the volume (or surface) shared by two input geometries, i.e., the contact zone where meshes intersect.

This intersected object can be used as a standalone object. Alternatively, the output can be incorporated into more complex workflows.

In practical terms, the following functions are employed for mesh intersection operations:

  • cutMesh. Cuts the input object along the supplied contours. This creates new edge loops and fragments the model to prepare matching boundaries for Boolean operations (in this case, intersection).
  • boolean. Executes the specified Boolean operation (e.g. intersection) on two meshes, clipping, classifying, and stitching fragments into the final intersected mesh.

3D Mesh Intersection in C++ and Python: Code Examples

				
					import meshlib.mrmeshpy as mrmeshpy

# create first sphere with radius of 1 unit
sphere1 = mrmeshpy.makeUVSphere(1.0, 64, 64)

# create second sphere by cloning the first sphere and moving it in X direction
sphere2 = mrmeshpy.copyMesh(sphere1)
xf = mrmeshpy.AffineXf3f.translation(mrmeshpy.Vector3f(0.7, 0.0, 0.0))
sphere2.transform(xf)

# perform Intersection operation
result = mrmeshpy.boolean(sphere1, sphere2, mrmeshpy.BooleanOperation.Intersection)
if not result.valid():
    print(result.errorString)
else:
    # save result to STL file
    mrmeshpy.saveMesh(result.mesh, "out_boolean.stl")
				
			
Before
Two overlapping 3D meshes before intersection operation
After
3D mesh generated from the intersection of two input models

Mesh Intersection with MeshLib: Executed Step by Step With The Single Boolean Function

In one’s actual practice, the sequence of steps—all taken via our single Boolean function, will look like:

  • Preparing input meshes, i.e., loading or creating the two meshes you wish to intersect.
  • Aligning Mesh B to Mesh A’s space. That is, applying a rigid transform so that both meshes share a common coordinate frame.
  • Using our functions to swiftly retrieve the raw intersection vertices and edges for inspection.
  • Generating cut contours.
  • Cutting each object along contours and invoking the result with the prepared contours to split both meshes along matching edge loops.
  • Executing the intersection. Calling the boolean function with the two cut meshes and to perform clipping, fragment classification, and stitching into the final intersected mesh.
  • Retrieving and validating the result.

Daily, countless teams all over the world apply MeshLib, across:

  • Engineering to detect and quantify interferences or mating surfaces between mechanical parts during design reviews.
  • Physics engines to generate precise collision meshes and contact volumes.
  • Simulation and analysis to identify and obtain overlapping regions when assessing various structure interactions.
  • Rendering to create complex cut-away views, dynamic clipping effects, or Boolean-based scene composition.
  • 3D printing and manufacturing to trim models to build-plate boundaries, merge assemblies at overlapping interfaces, or generate supports only where meshes intersect.
  • Medical imaging to locate common volumes between anatomical scans for volume measurement and surgical planning.

MeshLib Library for 3D Mesh Intersection

As a 3D processing library, MeshLib excels when it comes to mesh intersection. To substantiate this claim, we highlight how we compare with other 3D processing altern

Mesh Intersection Case # 1. Nefertiti Mesh

In this benchmark, two 3D models, each containing roughly two million triangles and intricate topological details, are used.

Intersection
Mesh intersection of Nefertiti model – benchmark case with high triangle count
Case
MeshLib 2.4.0.85
MCut
Manifold
CinoLib + RobustMesh
CGAL
Rhino 3D
Libigl
Trimesh-Manifold
Trimesh-Blender
Nefertiti – Intersection
0.7 (0.9)
46
1.0 (2.5)
8.1
6.7
54
43.6
2.9
36

Notes:

  • All results are in seconds.
  • Red numbers indicate the operation ran but produced an incorrect result.
  • The number in parentheses adds the one-time geometric setup to the per-call time. For example, 0.7 (0.9) means each subsequent call takes 0.7 s, while the first call takes 0.9 s (0.7 s + 0.2 s one-off preparation).

Mesh Intersection Case #2. Dental Mesh

Here, two dental models (around 500 K triangles in each) with degeneracies and coinciding surfaces. This test reflects real-world medical scenarios. Same notes apply.

Intersection
Mesh intersection of dental models – medical mesh intersection test
Case
MeshLib 2.4.0.85
MCut
Manifold
CinoLib + RobustMesh
CGAL
Rhino 3D
Libigl
Trimesh-Manifold
Trimesh-Blender
Dental Intersection
0.17 (0.20)
Fail
0.21 (0.52)
0.7
1.6
15
5.1
0.5
4.5

Guide to Boolean operations with MeshLib: including mesh intersection, over union and difference. Github link

MeshLib’s collision-detection core is implemented in tuned C++ for maximum throughput, with fully functional bindings for C, C#, and Python. So one is free to it integrate it into virtually any up-to-date stack.

  • C++ (native):

    Follow the C++ Setup Guide for installation.

  • Python:

    See the Python Setup Guide. MeshLib supports Python 3.8–3.13 on Windows, Linux distributions that provide manylinux_2_31 wheels, and macOS—except that Python 3.8 on x64 macOS is not supported.

What our customers say

Thomas Tong

Founder, Polyga

MeshLib% filename%
When we set out to develop our new Podkit scanning platform, we chose MeshInspector’s MeshLib as the foundation. That partnership let us accelerate development, ship new features faster, and get to market months sooner than we could have on our own. The MeshInspector team has been outstanding — quick answers, deep technical know-how, and genuine enthusiasm for our success. We simply wouldn’t be where we are today without their support.

Gal Cohen

CTO, customed.ai

MeshLib% filename%
“MeshLib has been a game-changer for our company, providing all the essential operations we need to handle meshes and create highly accurate personal surgical instruments (PSIs), which are our primary products. After extensive research and comparison, MeshLib stands out as the best solution on the market. Their team is exceptionally professional and knowledgeable. Collaborating with them has been an absolute pleasure—they respond to any issues we encounter promptly and always deliver effective solutions. Their commitment to customer support and technical excellence is truly unmatched.”

Mariusz Hermansdorfer

Head of Computational Design at Henning Larsen Architechts

MeshLib% filename%
“Over the past year, MeshLib has transformed my approach to design and analysis in landscape architecture and architecture projects. This powerful library excels in critical areas, such as geometry processing, interactive booleans, point cloud manipulation, and curve offsetting. These features enhance design workflows, allowing for dynamic modifications, efficient terrain modeling, stormwater flow analysis, and advanced wind flow visualiiza…..”

HeonJae Cho, DDS, MSD, PhD

Chief Executive Officer, 3DONS INC

MeshLib% filename%
“MeshLib SDK helped us achieve faster and more accurate calculation results and outperformed any other Mesh Processing library that we evaluated. For us in digital dentistry, it was a game-changer. Mesh processing operations, such as inspecting and editing the mesh to create dental devices for the treatment plan, are crucial. MeshInspector support liberated our team from technical constraints so we concentrated on creating exactly what we wanted. I highly recommend incorporating the MeshLib into your software arsenal.”

Ruedger Rubbert

Chief Technology Officer, Brius Technologies Inc

MeshLib% filename%
“With MeshInspector MeshLib we were able to automate many of our workflow processes, thanks to its advanced, modern, and efficient dental and geometry oriented algorithms, covering many of our orthodontic-related tasks: CT and intraoral scan segmentation, voxel and Boolean operations, editing, aligning, visualization, inspection, and import/export of mesh objects. We use the versatile MeshInspector MeshLib API, both in production and R&D for fast prototyping and testing of our ideas.”

Start Your Journey with MeshLib

MeshLib SDK offers multiple ways to dive in — from live technical demos to full application trials and hands-on SDK access. No complicated setups or hidden steps. Just the tools you need to start building smarter, faster, and better.

Journey with MeshLib SDK
Core Developers
MeshLib Team, official authors of MeshInspector App and MeshLib SDK, leverages over 20 years of 3D data-processing and mathematical expertise to deliver high-performance, plug-and-play algorithms that simplify even the most complex mesh workflows.
Leave a review about this post
{{ reviewsTotal }}{{ options.labels.singularReviewCountLabel }}
{{ reviewsTotal }}{{ options.labels.pluralReviewCountLabel }}
{{ options.labels.newReviewButton }}
{{ userData.canReview.message }}
Share this post on social media