- Published: 2025-05-28
- Updated: 2025-05-28
- MeshLib Team
What is Mesh Triangulation?
Mesh triangulation is a technique that swiftly converts point clouds into triangle meshes. In many cases, this process relies on pre-existing vertex normals to guide processes. However, when normals are absent or inconsistent, they must be generated first to ensure coherence. Regardless of the starting conditions, the result must be a structured, watertight surface, as if after ear clipping, built from scattered 3D points. The same approach can also tessellate 2D outlines into planar meshes, too.
Such a method establishes the backbone of mesh processing, computational geometry, graphics pipelines, and more. These activities, in turn, fuel 3D modeling efforts, CAD, gaming, physics simulations, etc.
Mesh Triangulation Algorithms
In terms of point clouds, MeshLib processes dense 3D scans by finding a local nearest neighborhood per each point, projecting each neighborhood onto a best‑fit plane. Then our toolbox runs local Delaunay triangulations to create provisional facets. Overlapping patches are compared, so that only consensus faces are retained. This yields a sealed triangulated 3D surface. Any remaining small planar holes are closed.
How to Triangulate Mesh
Below, our team is delving into how exactly our applicable capabilities could be employed for versatile real-life tasks.
Point Clouds
Technically, ‘Points to Mesh’ executes 3D point cloud triangulation. It:
- Reads raw XYZ coordinates;
- Finds each point’s nearest neighbours;
- Projects that patch onto a best‑fit plane;
- And eventually uses local Delaunay triangulation to create a mesh from points.
Overlapping patches are compared. Again, only consensus triangles are stitched into a proofed manifold surface.
Use it for:
- Rapid 3‑D surface generation from LiDAR, photogrammetry, or structured‑light scans;
- Reverse‑engineering, where reference geometry is understandably and inevitably mandatory;
- Physics simulation and analysis (thanks to uniformly triangulated shells).
Point Cloud to Mesh (Code Examples)
from meshlib import mrmeshpy as mm
from pathlib import Path
wdir = Path(file).parent
pc = mm.loadPoints(wdir / "Nefertiti Points.ply")
nefertiti_mesh = mm.triangulatePointCloud(pc)
mm.saveMesh(nefertiti_mesh, wdir / "Nefertiti Mesh.ctm")
#include
#include
#include
#include
#include
int main()
{
// load points
auto loadRes = MR::PointsLoad::fromAnySupportedFormat( "Nefertiti Points.ply" );
if ( !loadRes.has_value() )
{
std::cerr << loadRes.error() << "\n";
return 1; // error while loading file
}
auto triangulationRes = MR::triangulatePointCloud( *loadRes );
assert( triangulationRes ); // can be nullopt only if canceled by progress callback
auto saveRes = MR::MeshSave::toAnySupportedFormat( *triangulationRes, "Nefertiti Mesh.ctm" );
if ( !saveRes.has_value() )
{
std::cerr << saveRes.error() << "\n";
return 1; // error while saving file
}
return 0;
}


Terrain
The ‘Terrain to Mesh’ routine converts terrain clouds—height samples already projected onto the XY‑plane—into a watertight surface. In this respect, MeshLib:
- Gathers the XYZ data;
- Triangulates the XY coordinates, employing the Divide-Conquer algorithm;
- Reinstates the original Z‑heights, producing an accurate, manifold, triangulated 3D surface.
Terrain triangulation will be extremely helpful when you seek capabilities for:
- DEM generation from LiDAR, satellite, or drone surveys;
- Collision‑ready landscapes in visualisations;
- Feeding erosion, flood, and visibility simulations. In this domain, an accurate, lightweight 2D‑driven height mesh is essential.
Terrain to Mesh (Code Examples)
from meshlib import mrmeshpy as mm
from pathlib import Path
wdir = Path(file).parent
colors = mm.VertColors()
lps = mm.PointsLoadSettings()
lps.colors = colors
pc = mm.loadPoints(wdir / "Terrain_scan.e57",lps)
terrain_mesh = mm.terrainTriangulation(pc.points.vec)
mss = mm.SaveSettings()
mss.colors = colors
mm.saveMesh(terrain_mesh, wdir / "Terrain Mesh.ctm",mss)
#include
#include
#include
#include
#include
#include
int main()
{
// load points
MR::VertColors colors;
MR::PointsLoadSettings pls;
pls.colors = &colors;
auto loadRes = MR::PointsLoad::fromAnySupportedFormat( "Terrain_scan.e57", pls );
if ( !loadRes.has_value() )
{
std::cerr << loadRes.error() << "\n";
return 1; // error while loading file
}
auto triangulationRes = MR::terrainTriangulation( loadRes->points.vec_ );
if ( !triangulationRes.has_value() )
{
std::cerr << triangulationRes.error() << "\n";
return 1; // error while triangulating
}
MR::SaveSettings ss;
ss.colors = &colors;
auto saveRes = MR::MeshSave::toAnySupportedFormat( *triangulationRes, "Terrain Mesh.ctm", ss );
if ( !saveRes.has_value() )
{
std::cerr << saveRes.error() << "\n";
return 1; // error while saving file
}
return 0;
}


Lines
This counter meshing command transforms 2D contours into a watertight mesh from lines. After detecting self‑intersections and closing gaps, MeshLib applies Polygon Triangulation. The resulting triangulated surface is ideal for terrain models, architectural footprints, sheet‑metal layouts, logos, or profile extrusions. Also, it can be useful before offsetting, 2D Boolean ops, texturing, or sculpting.
Lines to Mesh (Code Examples)
from meshlib import mrmeshpy as mm
from pathlib import Path
wdir = Path(file).parent
dm = mm.loadDistanceMapFromImage(wdir / "logo.jpg") # load image
pl2 = mm.distanceMapTo2DIsoPolyline(dm, 210) # make iso lines from image
logo_mesh = mm.PlanarTriangulation.triangulateContours(pl2.contours()) # triangulate isolines
mm.saveMesh(logo_mesh, wdir / "Logo Mesh.ctm")
#include
#include
#include
#include
#include
#include
#include
int main()
{
// load image as distance map
auto imageLoadRes = MR::ImageLoad::fromAnySupportedFormat( "logo.jpg" );
if ( !imageLoadRes.has_value() )
{
std::cerr << imageLoadRes.error() << "\n";
return 1; // error while loading file
}
auto dmRes = MR::convertImageToDistanceMap( *imageLoadRes );
if ( !dmRes.has_value() )
{
std::cerr << dmRes.error() << "\n";
return 1; // error while converting image to distance map
}
auto pl2 = MR::distanceMapTo2DIsoPolyline( *dmRes, 210.0f );
auto triangulationRes = MR::PlanarTriangulation::triangulateContours( pl2.contours() );
auto saveRes = MR::MeshSave::toAnySupportedFormat( triangulationRes, "Logo Mesh.ctms" );
if ( !saveRes.has_value() )
{
std::cerr << saveRes.error() << "\n";
return 1; // error while saving file
}
return 0;
}


3D Triangulation Library—MeshLib
Being a 3D data processing library, MeshLib holds comprehensive triangulation capabilities.
Video Guide on Mesh Triangulation with MeshLib:
Our Triangulation Performance
Wrapping up, our modern and evolving open source 3D mesh triangulation library, accelerates large‑scale surface generation by breaking the problem into thousands of tiny, local Delaunay triangulations. They get solved them in parallel. Then, we retain only the triangles that pass strict majority‑vote and manifold checks.
In practice, we can easily convert a 300K point scan to a watertight, manifold model, fixing its normals in roughly 0.5 seconds on a 14‑core machine, 24 concurrent threads—much faster than many popular open‑source tools—while preserving surface fidelity for downstream editing, simulation, or 3D printing.
Access our performance benchmark by clicking on the link
In addition to that, the MeshLib library promises:
- Mesh repair via triangulation. Our toolbox supports filling holes by triangulating them. This is a part of our broader mesh repair functionality that also encompasses detecting and fixing tunnels on surfaces to ensure topological correctness;
- Integration with other important mesh operations. Triangulation in MeshLib is integrated with other mesh processing tasks. These cover simplification, deformation, and segmentation. All is ready for a smooth workflow in 3D mesh processing.
Available APIs for Work
Being a native C++ option, MeshLib also goes with C, C#, and Python APIs.
Speaking of versions, we are fully compatible with C++ environments, with Python, mind the versions:
- Windows: ver. 3.8-3.13.
- macOS: ver. 3.8-3.13 (the only exception here is 3.8 for macOS x64).
- Linux: ver. 3.8-3.13 for distributions supporting manylinux_2_31+.
What our customers say
Gal Cohen
CTO, customed.ai

Mariusz Hermansdorfer
Head of Computational Design at Henning Larsen Architechts

HeonJae Cho, DDS, MSD, PhD
Chief Executive Officer, 3DONS INC

Ruedger Rubbert
Chief Technology Officer, Brius Technologies Inc








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.
