Real-time geometric processing on NumPy arrays. Easy to use, robust on real-world data.
Project description
trueform
Real-time geometric processing on NumPy arrays. Enriched NumPy arrays with support for vectorized spatial queries. Arrangements, booleans, registration, remeshing — at interactive speed on million-polygon meshes. Exact and robust to non-manifold flaps and pipeline artifacts. NumPy in, NumPy out.
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: Real-time Geometric Processing},
author={Sajovic, {\v{Z}}iga and {et al.}},
organization={XLAB d.o.o.},
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.8.8.tar.gz.
File metadata
- Download URL: trueform-0.8.8.tar.gz
- Upload date:
- Size: 862.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47d8eabf4772cfc843b3bebc84b4b025b78719aee8d1ec8ec92efcdb57a5a09c
|
|
| MD5 |
60c73a25c7c256b8f1ec9ea01b69487e
|
|
| BLAKE2b-256 |
c44c35e7f64d51c51c17bb94f1787f3d45a66655711143444f88220b8b6fc857
|
File details
Details for the file trueform-0.8.8-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: trueform-0.8.8-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 23.1 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 |
98293b76462520dc372966de1629a9dec29a907e544e4b88305d818b3cb8cfd8
|
|
| MD5 |
5c490b680ebf1b5575afcef5046770ac
|
|
| BLAKE2b-256 |
7633b883b630c9646cd49b0acd854cf561a4949e94b7f7b203dd6746e69f3d2b
|
File details
Details for the file trueform-0.8.8-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: trueform-0.8.8-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 67.1 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 |
bd9f6f705dcfc0f600498aa0a3d54c5dc86537ff77826e7065dd8b418d913f05
|
|
| MD5 |
d652964b76c4a27c813e418915c389b2
|
|
| BLAKE2b-256 |
07198c9b8016e0d13cfa5088d603d985b02f72c23664db17f1a96be8b41052f6
|
File details
Details for the file trueform-0.8.8-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: trueform-0.8.8-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 40.7 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 |
cef9efacfb3664c9488cf2fc2676f0578a8b3d8ce4f4a32d687a346e892119b5
|
|
| MD5 |
a01cee5343c394aa3a89595b7f1b8f41
|
|
| BLAKE2b-256 |
90c75019aef5be585b760733eb942597db407398b78933bc51490f2e85bc1509
|
File details
Details for the file trueform-0.8.8-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: trueform-0.8.8-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 23.1 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 |
dd38bc66375909259db5177d35e53e8ccf0f8e737923df5060936f69cc02b71a
|
|
| MD5 |
5d11d5c125bae0f0bc88fbabe5eb64cf
|
|
| BLAKE2b-256 |
0c7b6d72d129822639fde902dc3fe8bb1e22dbeba33a63535c154b885e2d34f0
|
File details
Details for the file trueform-0.8.8-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: trueform-0.8.8-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 67.1 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 |
7c1b4d6f1471c3f2caa91a3e85a436d4b78f7ccb08c036368cd7b75b0b124870
|
|
| MD5 |
fc0b29d91c9f546dbbf4039b744093bb
|
|
| BLAKE2b-256 |
147f0bce7c11d6f2f6b327a3978840a827235929c2fade6e7e2f080b386c824d
|
File details
Details for the file trueform-0.8.8-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: trueform-0.8.8-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 40.7 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 |
cef534d1d0a23e49055a3ca003ec6c11c5de08259a51e1c937b7c21f6c07ceac
|
|
| MD5 |
ac1154f640266548ee30bafa726f551d
|
|
| BLAKE2b-256 |
f21749f93cdfa59951fad9db2da8840a4537bba1235af3bf6cecf1e8bc203f25
|
File details
Details for the file trueform-0.8.8-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: trueform-0.8.8-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 23.1 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 |
241cbaa279173f172950782d2f7f3b525c50d384c99df461c7b0b31993146e5c
|
|
| MD5 |
d30c354d51182ec4b92299fc4094721b
|
|
| BLAKE2b-256 |
d99a78f31e61ad444cbdf338aa8d44eff00179d02cf40c25f10bad89b0461380
|
File details
Details for the file trueform-0.8.8-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: trueform-0.8.8-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 67.1 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 |
cbaeb4c40a30d34e04a21bbc9decc6e661d7d2cf51ed1fc856f361039d634d76
|
|
| MD5 |
39df0d8af132de3dc597275d178455d5
|
|
| BLAKE2b-256 |
3c19c7ab5a975cc35e9f35dc2005ebbac6c4f821d2ca7ced4b17be924df52270
|
File details
Details for the file trueform-0.8.8-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: trueform-0.8.8-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 40.7 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 |
a5802fe1bcf0d0936399fad68ed636312759431bbdb29752d0203be4fe21fe4b
|
|
| MD5 |
5ec25013fae1534470d6eb4d0089ef8f
|
|
| BLAKE2b-256 |
8c766fa2166d5d3a4ed3a3c050f6e330f22c86701d6ac188238560c221e399a2
|