3d processing library
Project description
Welcome to the MeshLib!
3D scanning is becoming more and more ubiquitous. Robotic automation, self-driving cars and multitude of other industrial, medical and scientific applications require advanced computer vision to deliver the levels of automation customers expect these days. The great rise of AI gave another boost to computer vision and the need to utilize 3D data to make machines smarter. Not only are tasks at hand becoming more complex, but the size of data grows exponentially.
There is a multitude of general purpose libraries which deal with 3D data. Some stem from popular CAD packages, some are open source. The commercial ones tend to be quite expensive while open source are free though tend to be limited in functionality provided. Also those libraries value generality above other features to allow maximum number of applications, but with the growing amounts of 3D data, performance is critical as it never has been. Some of it can be addressed by using the scale of a commercial cloud, last generation CPU or GPU but underlying complexity of data representation makes it very hard and laborsome.
The goal which we set when designing MeshLib was to value simplicity and performance while providing a wide gamut of useful computational algorithms. The library also supports the most important data structures today’s sensors can produce - pointcloud, mesh, volume and more. For example, mesh is represented by half-edge data structure and cannot be made non-manifold. Some applications may require non-manifoldness, but most practical scans can be represented as manifoldness meshes without an issue.
Some useful links
-
MeshInspector is a free application based on MeshLib
-
MeshInspector online web-browser version (simple email sign-in is required)
Major features
This list is not full and updating each day
Math basics
- Math primitives and operations support (Vectors 2D, 3D, 4D; Lines; Planes; Bounding Boxes; Matrices; Affine transformations; Quaternions; Histograms; etc.)
3D data handling, creation, modification
- 3D data various representations support: Mesh, Voxel and Point Cloud.
- Data creation
- Mesh creation by given vertices and triangles,
- Surface primitives (e.g. tor, cube, sphere, etc).
- Representation conversions
- Triangulation of a Point Cloud to Mesh,
- Mesh to Cloud Point conversion,
- Mesh to Voxel conversion,
- Voxel To Mesh conversion.
- Deformations
- Laplassian deformation,
- Freeform deformation,
- Relax, mesh smoothing,
- Position Verts Smoothly, arrangement of vertices in accordance with the gradient along the neighbors.
- Offsets
- Mesh offset,
- Mesh partial offset.
- Resolution
- Breaking a mesh into smaller triangles (increasing the resolution)
- Mesh decimation (decreasing the number of triangles, decreasing the resolution) with a specified error relative to the old mesh.
- Cutting a contour on a surface. The mesh is modified so that the resulting contour contains new edges cut through triangles at the specified points.
- Splitting
- Splitting mesh into sub-meshes (components)
3D data operations
- Boolean operations (union, intersection, difference) on 3D objects bounded by meshes. MeshLib has two independent modes:
- Boolean ops on meshes via intermediate conversion into voxel representation. This mode requires closed meshes without holes on input and much memory for high accuracy but tolerate for various input mesh degenerations and self-intersections.
- Direct Boolean ops on meshes using robust predicates, producing exact accurate result and keeping original mesh elements as is if they are not intersected. This mode supports for open meshes with holes as long as the boundary of the mesh is not intersected.
- According to our user reports, MeshLib direct Boolean operations are significatly faster even compared to the latest published approaches, e.g. Interactive and Robust Mesh Booleans
- Construction of Convex Hull of a point cloud or a mesh.
3D Data problems fixing
- Fixing holes in mesh
- Holes stitching (removing two holes by stitching their boundaries)
- Hole filling,
- Holes fixing metrics
- Basic set of triangulation metrics,
- Extended set of triangulation metrics,
- Custom triangulation metrics.
- Delaunay triangulation optimization, changing triangles without changing vertices, according to Delaunay criterion,
- Tunnels fixing,
- Multiple edges detection
- Degenerate triangles fixing,
- Undercuts fixing, via voxels,
- Surface self-intersections fixing
- Guaranteed fix via voxels,
- Fix via Relax (mesh smoothing).
Functions on 3D data
- BVH hierarchies (AABB trees) for meshes and polylines to accelerate all other operations
- Projection
- Projecting a point onto a mesh - closest point queries
- Intersection
- Intersection of a ray with a mesh (ray tracing),
- Intersection of a plane with a mesh, result is a contour,
- Finding a contour representing intersection of two meshes, meshes remain unchanged,
- Distance
- Distance from a point to a mesh,
- Minimal distance between two meshes,
- Mesh distance map (height map),
- 2D contour distance map.
- Segmentation
- Semi-auto voxel segmentation (volumes classification).
- Semi-auto mesh segmentation by curvature.
- Sampling
- Mesh sampling. The result is a separate thinned set of vertices, the mesh remains unchanged.
- Point cloud sampling. The result is a separate thinned set of points, the cloud remains unchanged
- Uniform cloud sampling,
- Grid cloud sampling.
- Path
- Finding a shortest path through the mesh vertices,
- Finding a geodesic shortest path on the surface, not necessarily through mesh vertices.
- Iterative Closest Points (ICP), two meshes aligning
- Point to point,
- Point to plane.
Upcoming features
We plan to add computed-tomography reconstruction in MeshLib (already present in MeshInspector). Please write us if you like to see some other features.
Python integration
Although MeshLib is written in C++, all functions are exposed to Python as well. Python code can be executed both from within a MeshLib-based C++ application (embedded mode) and from python interpreter directly, which imports MeshLib modules.
Moreover, the latest MeshLib released version can be easily installed as a Python 3.8 - 3.12 package using pip install
:
- On Windows via
py -3 -m pip install --upgrade pip
py -3 -m pip install --upgrade meshlib
- On Linuxes supporting manylinux_2_31+, including Ubuntu 20+ and Fedora 32+ via
sudo apt install python3-pip
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade meshlib
- On macOS 12.0+ via
pip install --upgrade pip
pip install --upgrade meshlib
See Python Basic Examples here or search for more complex ones on stackoverflow.com.
.NET integration
Also you can integrate MeshLib into your .NET project via NuGet. The package can be installed from .NET CLI, VisualStudio UI, or downloaded from NuGet website.
- Installation via .NET CLI
dotnet add package MeshLib
Build
Windows
MeshLib can be build on Windows using either Visual Studio 2019 or Visual Studio 2022, both of which support c++20 language standard.
git clone https://github.com/MeshInspector/MeshLib.git
cd MeshLib
git submodule update --init --recursive
cd ..
Note: following below steps will take about 40Gb of your disk space.
Preparing Third Parties
Some third parties are taken from vcpkg, while others (missing in vcpkg) are configured as git submodules.
CUDA
Windows version of MeshLib is configured to use
- CUDA v11.4 in Visual Studio 2019 and
- CUDA v12.0 in Visual Studio 2022.
Please install CUDA from the official site.
If you would like to use another version of CUDA, please modify MRCudaVersion
in MeshLib/source/platform.props
.
Vcpkg
-
Please install
vcpkg
, and integrate it into Visual Studio (note that vcpkg requires English language pack in Visual Studio, and vcpkg cannot be installed on FAT volumes, only on NTFS):git clone https://github.com/Microsoft/vcpkg.git cd vcpkg git checkout 2024.07.12 .\bootstrap-vcpkg.bat .\vcpkg integrate install (with admin rights)
More details here: vcpkg.
-
(Optional, but recommended) Install AWS CLI v2. Once installed, reopen PowerShell or CMD. This will allow you to use the vcpkg binary cache from our aws s3, which will speed up the installation process and reduce the required disk space.
-
Execute
MeshLib/thirdparty/install.bat
having previously installedvcpkg
as the current working directory (or simply addvcpkg
toPATH
environment variable). -
Open solution file
MeshLib/source/MeshLib.sln
in Visual Studio. Build it and run.
Linux
We regularly check that MeshLib can be built successfully on Ubuntu 20.04 LTS, Ubuntu 22.04 LTS (both x64 and ARM), and Fedora 37.
Install/Build dependencies. Build project. Run Test Application
Install CUDA v12.0 from official site
Use automated installation process. It takes ~40 minutes if no required packages are already installed. This approach is useful for new MR developers
Run the following in terminal:
git clone --recurse-submodules https://github.com/MeshInspector/MeshLib.git
cd MeshLib
./scripts/build_thirdparty.sh # do not select emscripten in the corresponding question
./scripts/build_source.sh # do not select emscripten in the corresponding question
# create and install package for Ubuntu
./scripts/distribution.sh
sudo apt install ./distr/meshlib-dev.deb
# create and install package for Fedora
./scripts/distribution_rpm.sh
sudo apt install ./distr/meshlib-dev.rpm
NOTE:
./scripts/install*.sh
scripts could be used as well, but apt install is preferable.
NOTE:
./scripts/install_thirdparty.sh
script copies MR files directly to/usr/local/lib
. Remove this directory manually if exists before apt install deb package.
NOTE: You could specify build type to Debug by
export MESHLIB_BUILD_TYPE=Debug
. Release is default. SetMESHLIB_KEEP_BUILD=ON
to suppress full rebuild
WASM/Emscripten
This installation was checked on Ubuntu 22.04 with Emscripten 3.1.48.
Install Emscripten (find more on Emscripten official page)
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
git pull origin # optional
./emsdk install 3.1.48 # (or another version / latest)
./emsdk activate 3.1.48
source ./emsdk_env.sh
Build
cd ~/MeshLib
./scripts/build_thirdparty.sh # select Emscripten in the corresponding question
./scripts/build_source.sh # select Emscripten in the corresponding question
NOTE: Set
MESHLIB_KEEP_BUILD=ON
to suppress full rebuild
Run
python3 -m http.server 8000 # note that server should have specific COEP and COOP policies for multithread version
# open in browser 127.0.0.1:8000
Integration
Linux Ubuntu/Fedora
You can download dev package and install it with your Linux OS package manager.
Examples of integration with cmake can be found in the ./examples
directory.
MacOS
Same as for Linux, but requires brew packages to be installed:
xargs brew install < /Library/Frameworks/MeshLib.framework/Versions/Current/requirements/macos.txt
Windows
There are two general options of integrating MeshLib into your project:
Submodule
You can have MeshLib as submodule in your repository, and inculde all MeshLib's projects to your solution.
This option requires you to install third-party libraries via vcpkg
package mananger.
NOTE: You should use
MeshLib/source/common.props
in other projects of your solution.
NOTE: You can customize props by defining
CustomMRProps.props
in directory abovecommon.props
.
NOTE: If you would like to set
_ITERATOR_DEBUG_LEVEL=1
macro, then please do it inCustomMRProps.props
together withMR_ITERATOR_DEBUG_LEVEL=1
macro.
Distribution
You can download zip-archive containing
- header files (.h),
- library archives (.lib),
- dynamic labraries (.dll)
of both MeshLib and dependant third-party libraries, and make them available during your project building and runtime execution as follows.
Project settings in Visual Studio:
C/C++ -> General -> Additional Include Directories
adddistribution\install\include;
Linker -> General -> Additional Library Directories
adddistribution\install\app\$(Configuration);
Linker -> Input -> Additional Dependencies
adddistribution\install\lib\$(Configuration)\*.lib;
- Debug Configuration:
C/C++ -> Preprocessor -> Preprocessor Defenitions
add_ITERATOR_DEBUG_LEVEL=0;
Make sure you copy all dlls from distribution\install\app\$(Configuration);
to your $(TargetDir)
NOTE: MeshLib distribution has x64 build only.
NOTE: Distribution is built with
_ITERATOR_DEBUG_LEVEL=0
macro defined in Debug configuration so you will need to setup this for your projects.
Distribution for .NET
You can download zip-archive MeshLibDotNetDist.zip containing dynamic lybraries (.dll) of both MeshLib and dependant third-party libraries, and make them available during your project building and runtime execution as follows.
- Create a new C# project in Visual Studio.
- Double-click on the project in Solution Explorer. You will see content of the
.csproj
file - Add the following lines before the
</Project>
closing tag
<PropertyGroup>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="MRDotNet">
<HintPath>path\to\distribution\$(Configuration)\MRDotNet.dll</HintPath>
</Reference>
</ItemGroup>
- Extract content of
MeshLibDotNetDist.zip
toproject\bin
directory
You could find examples of usage in this repo in examples\c-sharp-example
directory
NOTE: MeshLib distribution has x64 build only.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for meshlib-2.4.4.153-py312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e36d113671ba8a3d30a98c8ba837bfa57d8faece70cf357bcebf50c37f7f260c |
|
MD5 | b2b453d0f337fdd7cbf21f8286eba085 |
|
BLAKE2b-256 | 83ffa0b62d027060c438397d41c641a233fb882bd558eaa589f01f313f7e9834 |
Hashes for meshlib-2.4.4.153-py312-none-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8119f7e60a1a61a9f6799ca89a42f92f691836214ba218692d6aeea2172d04e9 |
|
MD5 | c4e705ff850363391fa62b95a8905243 |
|
BLAKE2b-256 | 3e16f1a0124ba69cc8aa8882da80bed2e2ce134c9e084709dce474b7eed87327 |
Hashes for meshlib-2.4.4.153-py312-none-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b15df0c5aea9f3b32544911f9ffecfb32ab6dbcb27c0fcf695712cc5e604759 |
|
MD5 | 0551a388b274781c60fd9d2aa2e8fa41 |
|
BLAKE2b-256 | d847ce3bc4c145fb6fe377f64f14a230b0014c200ff999328d9d296fd72f4b1e |
Hashes for meshlib-2.4.4.153-py312-none-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e603c237733b6ea4dc8c286f35feb1451b566c3c17467b4eb7e25994c28f6de |
|
MD5 | 55e9503065b6b733007e9af01e1d6c69 |
|
BLAKE2b-256 | 4cf8a8f22582d3c2c1f14ac434d2bef7c47d4f885da78cd2aa2c441e96c4399a |
Hashes for meshlib-2.4.4.153-py312-none-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 338dddce6f1bd1f975e2af4521ac713536e00b17f2d3967fda2656ada4d67853 |
|
MD5 | 98d6d18cf3cca47e3953d35612ff3faa |
|
BLAKE2b-256 | ab651fdf4899ad3986b4e562180a91586925bc726faa4b8071e2691dd9402111 |
Hashes for meshlib-2.4.4.153-py311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f532e6598ee0a8be3d9fa79b07c2820deec8c1ef5809fd3dca83afbbe1c26694 |
|
MD5 | 27d8eb2a6f2f87ca667c615e427ed809 |
|
BLAKE2b-256 | 4e35dcf9b68b51b89669606cab861c3cfdae43eca3fa5ebf9f24492297686435 |
Hashes for meshlib-2.4.4.153-py311-none-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6df18466e2d03fe210071f85783d9af272690161b14cd7e479e9f0c914366d4d |
|
MD5 | 1121c709a68d979dfd2e484df9b4afcc |
|
BLAKE2b-256 | 3907456247d75a9d703b70389debdec0d2730630165a8f339a880e88aaef60cc |
Hashes for meshlib-2.4.4.153-py311-none-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c894266d2e15b7fdbdebb62f2e09272a44dfd4b777b01a5574f91575ee3af2e |
|
MD5 | dc9e02d4c10f8b48db910f14135c3020 |
|
BLAKE2b-256 | e2b28d167e69243c0f8320f27838f4b304ece3051f00c197f14b02f884a7fb1e |
Hashes for meshlib-2.4.4.153-py311-none-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 246a753bf4f562311ccec565f48db604be71505f7963d84fd69282cfc17c4de3 |
|
MD5 | ccccd35a01bab03f9ebc706f2d049c6a |
|
BLAKE2b-256 | c6b76fc20774ab337e90c8ec8f2e049f8da5a2f03d2c46ee674013a18ea7cfe4 |
Hashes for meshlib-2.4.4.153-py311-none-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ace3b67e59b592a571a5ae5eb0d1e91923df5063969daa8a2b1dcbc10105be7 |
|
MD5 | bfc0789e3577d97336de9832220475e3 |
|
BLAKE2b-256 | e858dc9557958ecfa0858c7106b5a8dc41825c3d65684c990b1a0e11ae8269ba |
Hashes for meshlib-2.4.4.153-py310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4481fc60d2f26a2d698b7b81ce985386948a43972f4acaeba4b9e05138507863 |
|
MD5 | fccda08b13afff313ecdc7b474c9c5bb |
|
BLAKE2b-256 | 775c5c8b2c6c3d4d4f008154c72067888dd70d8990edba865de62f077e468db1 |
Hashes for meshlib-2.4.4.153-py310-none-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d4590ea860068516bac2e7f07f0ff9077672b427a4b8bf38e8d605c10322072 |
|
MD5 | 568f8adbb9efb2bcf72a6701ef1e9b24 |
|
BLAKE2b-256 | f529150fcbdea8d9391f473ce2e860a3d908887f1d7c16af61f3ab0fa2a73309 |
Hashes for meshlib-2.4.4.153-py310-none-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc85e7420cf1dcb65056c98b73031c00666bdb10c805b743fdda71c25274d669 |
|
MD5 | d7c81231c66eab53a605a828f9532285 |
|
BLAKE2b-256 | 8e0390d1bc4c77a6a07a229745d2c3b4072db2010f5b5e973d8d903b7273810f |
Hashes for meshlib-2.4.4.153-py310-none-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f3afc9b86554af68a6e954285407f5241cbcda763ad8713f22247fce8245f65 |
|
MD5 | aff6944fcad52ef78ab31ddad587c9be |
|
BLAKE2b-256 | 2ad0a19f4fc94c39565c9209ad788dfcb6014b295cbe6ada47c15cad9d5196c5 |
Hashes for meshlib-2.4.4.153-py310-none-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5e1a02fa1664f69f87a270b9596a8c1a7f2fb35d3bc0438a247cc80043883c0 |
|
MD5 | 3f38c2b3102c80acb976072f4138d374 |
|
BLAKE2b-256 | 150bd5407e907d63fb1486e83fd6693e4f74d50571a6a19cdb074ed50b74ce21 |
Hashes for meshlib-2.4.4.153-py39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ec31e5994eeb6130b4bf5e313dad24f60c6daa5124e30c0c7f1180344fffe5b |
|
MD5 | 281f980963be23485fef9322ea5553da |
|
BLAKE2b-256 | c953a224c7c9e4e9b1050abf8af1668ec1a78b83bbe9a5a03002816446b66e9f |
Hashes for meshlib-2.4.4.153-py39-none-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f94c4665ce5f65b95b0e78dd74a5a3275be72b38902719825008112b1aae2bc |
|
MD5 | 3c86480b8739a35436e7270f40839957 |
|
BLAKE2b-256 | 012fe66c6d5a8c0996bb148733ec7dd83e043a90b27342e9678bdef3e7f4f89e |
Hashes for meshlib-2.4.4.153-py39-none-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d458b8e23b4f7e6b33f1a1ba317b5c9890dded60093622073a33b38b2dedc0cf |
|
MD5 | 09121e0f3a3fb329e63ad36e78925dd3 |
|
BLAKE2b-256 | 28c7b32aef144721063c96e24a2f279479f7c8826d25aff0da070b1e7b5a9423 |
Hashes for meshlib-2.4.4.153-py39-none-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d9552d3c8dcc8ce05ce55c417eedf8433fe95f14fafbc56c76572bce54ef3a4 |
|
MD5 | c3316d727657406e19b0013cd620c70c |
|
BLAKE2b-256 | c64fd21bc4e84fb65087291f5689cb5e3737aed9674c68c538a58faed0886ca3 |
Hashes for meshlib-2.4.4.153-py39-none-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afbb2cc25ec1965dd647fe483d853e07772fd45b5ea51de900286a4cc1dfba46 |
|
MD5 | 49c3cdea4cebdd36630c4406c0ae7573 |
|
BLAKE2b-256 | 14637bc78cf5a1099068a46504a524fb87e522e4d269e174e8073847ebd54d77 |
Hashes for meshlib-2.4.4.153-py38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc976b97bed47b8032161cd3b9683428db2a245f5e5a46043d79ce1ed507f441 |
|
MD5 | 2ee8a3a12f97ccd691fd10fc89dd236d |
|
BLAKE2b-256 | cfd74eddd99033983cf07d3f63ad8113fbd541f576d39663b53ea20fc92e74be |
Hashes for meshlib-2.4.4.153-py38-none-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc1073e29881e9d1a795b0643c5a0fe2ba313ffeb1b37635ea68a010ac1832d4 |
|
MD5 | 582e6b97beff75258a4e192ec0e50cf3 |
|
BLAKE2b-256 | 173624e039c2ca2fc13ad56a7fb1614a3092961a873f083a7e8af37f0a8d172f |
Hashes for meshlib-2.4.4.153-py38-none-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a04003702ad0aa37d90192a1ae18828be9da220ae67bcc969254315775e041a8 |
|
MD5 | 17141894a1cda4cfa1a12b1425c49fcd |
|
BLAKE2b-256 | 5c234690a61012d709072bed55ce4c33a63d5b7ca446f25cf4e762e01b77ea4d |
Hashes for meshlib-2.4.4.153-py38-none-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab7cee6ec3452e6a5734d4cdcdf72ff06e7f0d3fc37c5de6605b28f8aa073d4b |
|
MD5 | 1b55e9d9c4293f76353cbde61b631a4c |
|
BLAKE2b-256 | 84181a1b55beaef730692671dba1ce648f08bd61e46672ef628b838cf8f0575c |
Hashes for meshlib-2.4.4.153-py38-none-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f983590fbffec6d9452f2346e93a4ae4bbc7a72a3444b56c8643c6b8784cd8d6 |
|
MD5 | 5b4d193f6dc33e33cd5d66acc26b14cc |
|
BLAKE2b-256 | d7dc91c5611aff0801fa30afc3c69158d27e4bad2d7f8c45da0a5311ae0d7c7e |