Fast and exact mesh booleans, spatial queries, arrangements, registration, and remeshing on NumPy arrays. NumPy in, NumPy out.
Project description
trueform — NumPy for Geometry
Fast and exact mesh booleans, spatial queries, arrangements, registration, and remeshing on NumPy arrays. NumPy in, NumPy out.
Read the article: The STL for Geometry — What the STL philosophy of separating algorithms from data looks like when applied to geometry.
polydera.com/trueform | Documentation | ▶ Try it live
Installation
pip install trueform
Quick Tour
Primitives — typed NumPy arrays, single or batched:
import numpy as np
import trueform as tf
triangle = tf.Triangle(a=[0, 0, 0], b=[1, 0, 0], c=[0, 1, 0])
segment = tf.Segment([[0, 0, 0], [1, 1, 1]])
ray = tf.Ray(origin=[0.2, 0.2, -1], direction=[0, 0, 1])
# Add a leading dimension for batches
pts = tf.Point(np.random.rand(1000, 3).astype(np.float32))
segs = tf.Segment(start=np.random.rand(500, 3), end=np.random.rand(500, 3))
Meshes are created from NumPy arrays or read from files:
points = np.array([
[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]
], dtype=np.float32)
faces = np.array([
[0, 1, 2], [0, 2, 3], [0, 3, 1], [1, 3, 2]
], dtype=np.int32)
mesh = tf.Mesh(faces, points)
# Or read from file
mesh = tf.Mesh(*tf.read_stl("model.stl"))
Queries — same functions for any combination. Batches broadcast:
# Batch × Primitive — distance field to a plane
plane = tf.Plane(normal=[0, 0, 1], offset=0.0)
scalars = tf.distance(pts, plane) # shape (1000,)
# Batch × Form — closest point on mesh for each segment
ids, dist2s, closest = tf.neighbor_search(mesh, segs) # 3 arrays, shape (500,)
# Single × Single
dist2, pt_a, pt_b = tf.closest_metric_point_pair(triangle, segment)
if (t := tf.ray_cast(ray, triangle)) is not None:
hit_point = ray.origin + t * np.array(ray.direction)
Boolean operations:
(result_faces, result_points), labels, face_labels = tf.boolean_union(mesh0, mesh1)
# With intersection curves
(result_faces, result_points), labels, face_labels, (paths, curve_points) = tf.boolean_union(
mesh0, mesh1, return_curves=True
)
Remeshing:
# Decimate to 50%
dec_faces, dec_points = tf.decimated(mesh, 0.5)
# Isotropic remesh to uniform edge lengths
dec_mesh = tf.Mesh(dec_faces, dec_points)
mel = tf.mean_edge_length(dec_mesh)
rem_faces, rem_points = tf.isotropic_remeshed(dec_mesh, mel)
→ Full documentation covers mesh analysis, topology, isocontours, curvature, and more.
Examples
- Guided Examples — Step-by-step walkthroughs for spatial queries, topology, and booleans
- VTK Integration — Interactive VTK applications
Run examples locally:
git clone https://github.com/polydera/trueform.git
cd trueform/python/examples
pip install vtk # for interactive examples
python vtk/collision.py mesh.stl
Blender Integration
Cached meshes with automatic dirty-tracking for live preview add-ons. See Blender docs.
Benchmarks
| Operation | Input | Time | Speedup | Baseline | TrueForm |
|---|---|---|---|---|---|
| Boolean Union | 2 × 1M | 28 ms | 6× | MeshLib (int32 exact + SoS) | exact predicates, canonical topology |
| Mesh–Mesh Curves | 2 × 1M | 7 ms | 233× | CGAL Exact_predicates_inexact_constructions_kernel |
exact predicates, canonical topology |
| ICP Registration | 1M | 7.7 ms | 93× | libigl | AABB tree, random subsampling |
| Self-Intersection | 1M | 78 ms | 37× | libigl EPECK (GMP/MPFR) | exact predicates, canonical topology |
| Isocontours | 1M, 16 cuts | 3.8 ms | 38× | VTK vtkContourFilter |
exact predicates |
| Connected Components | 1M | 15 ms | 10× | CGAL | parallel union-find |
| Boundary Paths | 1M | 12 ms | 11× | CGAL | Hierholzer's algorithm |
| k-NN Query | 500K | 1.7 µs | 3× | nanoflann k-d tree | AABB tree |
| Mesh–Mesh Distance | 2 × 1M | 0.2 ms | 2× | Coal (FCL) OBBRSS |
OBBRSS tree |
| Decimation (50%) | 1M | 72 ms | 50× | CGAL edge_collapse |
parallel partitioned collapse |
| Principal Curvatures | 1M | 25 ms | 55× | libigl | parallel k-ring quadric fitting |
Apple M4 Max, 16 threads, Clang -O3. Full methodology
License
Dual-licensed: PolyForm Noncommercial 1.0.0 for noncommercial use, commercial licenses available.
Contributing
See CONTRIBUTING.md and open issues.
Citation
@software{trueform2025,
title={trueform: the STL for Geometry},
author={Sajovic, {\v{Z}}iga and {et al.}},
organization={Polydera},
year={2025},
url={https://github.com/polydera/trueform}
}
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 Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file trueform-0.9.0.tar.gz.
File metadata
- Download URL: trueform-0.9.0.tar.gz
- Upload date:
- Size: 909.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef4c1b66febcec7dbd76d0ace810715eebabdfc7e2063c47b05fc0f9e1fb2ad5
|
|
| MD5 |
72e70323cef53420ec10f07f0ee139c0
|
|
| BLAKE2b-256 |
5bb1d9f5c8ac53b2cf2b0ab9f459433eb6f48a0cf8fadab5b930deda422c28fe
|
File details
Details for the file trueform-0.9.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: trueform-0.9.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 24.2 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cefd692a77248363f81a15b45931bbf7d6c46a9b4c5d4f517b1c3facc107ba2
|
|
| MD5 |
83f1f3ef828fc9ee8acae3faf7316c19
|
|
| BLAKE2b-256 |
57f5b4d73418129935895bc6ad1789c0e401fb411b1ab2b86639a144a6c4ca7b
|
File details
Details for the file trueform-0.9.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: trueform-0.9.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 68.2 MB
- Tags: CPython 3.13, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
785e25b22e1cb8888426544152830118102f6cc921c43480c04d0f59809b3d5b
|
|
| MD5 |
79fc8b34cbea5299de1fc044fe5ce291
|
|
| BLAKE2b-256 |
d099ae231a1ae99d584ce663c1e0bf06a3cb0dabe8e3ef99089e9974a6f940af
|
File details
Details for the file trueform-0.9.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: trueform-0.9.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 42.1 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b63733285f5c30b01420b570f7f40e95ce41ff5ef54fd3a67286649d7ae25bbb
|
|
| MD5 |
63a7d362535920195ee7cb04440f6cb3
|
|
| BLAKE2b-256 |
d8149d32b9cffd6e764e85d6735abd140bb133e303726e602d28e30465b63568
|
File details
Details for the file trueform-0.9.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: trueform-0.9.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 24.2 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b707d06f8d9fc29e2e84326afe6b2fb229a49500f1a9c203b166cbd69d8e3d0
|
|
| MD5 |
73ef6acbc18ecc380ac02128870fde5b
|
|
| BLAKE2b-256 |
8f0a11a67d732b42e417d576724e8fe0d7e6cd5af735f613f9bab8d02f75890e
|
File details
Details for the file trueform-0.9.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: trueform-0.9.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 68.2 MB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31452cebf1d79e8b630008c74e1a46691abcf494f97924ac9aef7c1aa4c0c85b
|
|
| MD5 |
633581f45b9802312f63c77039bd3f6a
|
|
| BLAKE2b-256 |
31983293e16e3662dcd862e7dcf97fa6e2e894d8f1ae27f6876c0b4d60e973d4
|
File details
Details for the file trueform-0.9.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: trueform-0.9.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 42.1 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77511c5ddee6c29cbf253b94c35d7344bc185afbb6572aab43af6a485f83777a
|
|
| MD5 |
d8b2ae5436ce25d5e27664cea72ee288
|
|
| BLAKE2b-256 |
3843db0f51256b0c07f6b70f050c76618397c0631733085a7600767556c9c1f1
|
File details
Details for the file trueform-0.9.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: trueform-0.9.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 24.2 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a27d18364b31e8a7bb425149a6100b527f0beb2be3783980c3c3af496d783266
|
|
| MD5 |
1b946bf398c38f090696b1820a6cca98
|
|
| BLAKE2b-256 |
b969b471580f9b111304f159c72e8172cda76ca52ad3dc2e677403aea6283f07
|
File details
Details for the file trueform-0.9.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: trueform-0.9.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 68.2 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
225d10681727c231314edb23ed271d929cfb57d4617f9b7dba6fabd4d86ee4f3
|
|
| MD5 |
51a27e9488484c958ff9a8d8f7caffc4
|
|
| BLAKE2b-256 |
7e7d56a85776abd1a59c6e31fb7750f0324a81b1a686e8ee53a86b87e093f451
|
File details
Details for the file trueform-0.9.0-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: trueform-0.9.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 42.1 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
615633f5f79cc52c698888846e18d36ac2be8d55b95e87e911538c80cc6b7375
|
|
| MD5 |
02333557a092656af1638df52831b27c
|
|
| BLAKE2b-256 |
86b1aff20fc9352224d30f14d92e9f12b046defafde6474eb3f11344176c9998
|