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 CSG Engine},
author={Sajovic, {\v{Z}}iga and {et al.}},
organization={Polydera},
year={2025},
url={https://github.com/polydera/trueform}
}
Metadata
Release files for trueform 0.10.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| trueform-0.10.3.tar.gz | 1.4 MB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| trueform-0.10.3-cp313-cp313-win_amd64.whl | CPython 3.13 | CPython 3.13 | Windows x86-64 | Details |
| trueform-0.10.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl | CPython 3.13 | CPython 3.13 | Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 | Details |
| trueform-0.10.3-cp313-cp313-macosx_11_0_arm64.whl | CPython 3.13 | CPython 3.13 | macOS 11.0+ ARM64 | Details |
| trueform-0.10.3-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details |
| trueform-0.10.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 | Details |
| trueform-0.10.3-cp312-cp312-macosx_11_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 11.0+ ARM64 | Details |
| trueform-0.10.3-cp311-cp311-win_amd64.whl | CPython 3.11 | CPython 3.11 | Windows x86-64 | Details |
| trueform-0.10.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl | CPython 3.11 | CPython 3.11 | Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 | Details |
| trueform-0.10.3-cp311-cp311-macosx_11_0_arm64.whl | CPython 3.11 | CPython 3.11 | macOS 11.0+ ARM64 | Details |
Total release size: 375.7 MB
Release files / trueform-0.10.3.tar.gz
| Download URL | trueform-0.10.3.tar.gz |
|---|---|
| Size | 1.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
42a1e10cfe526b209e9efc6ac09963a8c3799e97b6447a5521c38ac2a4c20539
|
|
BLAKE2b-256 checksum How to use checksums |
de9d1743ef9d57cb0d779c21927ac52c338755c68522b742d46c99c4ce6056eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / trueform-0.10.3-cp313-cp313-win_amd64.whl
| Download URL | trueform-0.10.3-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 23.3 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
eee01c5791182c10ce9001ef8911792ce7216509327b074f31ba141476b615f7
|
|
BLAKE2b-256 checksum How to use checksums |
2b8bd0ced54c596968fa4f32a7147cb2aa48a19a854fea1b7ea2003e37a5793c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / trueform-0.10.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | trueform-0.10.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 59.5 MB |
| Tags | CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
7187cf5deb62a895f6db2fa9daf2e96455e27e9e3d02a64445fcabea512dfbb5
|
|
BLAKE2b-256 checksum How to use checksums |
6075020f3d80d5ff860ed77c99e855535337846a143268ae10308cf8f6f518d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / trueform-0.10.3-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | trueform-0.10.3-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 42.0 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
fa476b26f08871d2ece6de7ac20a3e552d04ce1bb27ef189c8c2347faf957281
|
|
BLAKE2b-256 checksum How to use checksums |
8bc7ef7d58770c1addecbd89cf6c5503693bc4c33635a1cf7e7e0ddbebd0c553
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / trueform-0.10.3-cp312-cp312-win_amd64.whl
| Download URL | trueform-0.10.3-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 23.3 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c845acbdaa0123b0a5740c371886597be0509fafa44991caacc84369c245d78e
|
|
BLAKE2b-256 checksum How to use checksums |
0d329c00a50ea67d190845f1d462ef15669d53e90f3002033758e5098eb3979c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / trueform-0.10.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | trueform-0.10.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 59.5 MB |
| Tags | CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
4ad6e3923da693b7e3a9ee083b26def6cbe7ead170a5ccbe738b3b5a21a87974
|
|
BLAKE2b-256 checksum How to use checksums |
606d040d17dc3d6208a18a8f37b4dad35ad00b6985d27bcfae771c7019d9bc72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / trueform-0.10.3-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | trueform-0.10.3-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 42.0 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
15eaa6b310722c9c0c1e54d65216c6d60ad97f0eb5a1ae14dd67387520248de0
|
|
BLAKE2b-256 checksum How to use checksums |
e4a9db752595ac326b09eed334c2784996e366e2ff93ead94e5d854da86fb261
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / trueform-0.10.3-cp311-cp311-win_amd64.whl
| Download URL | trueform-0.10.3-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 23.3 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
354c78299204b739b8c3406cde45adec128bb2da7d76c6fea3cd70cc2e6b8cae
|
|
BLAKE2b-256 checksum How to use checksums |
dd67f2057252d7ec3a25df02fd68645773e8daaa986cc589f4675909dc5b53e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / trueform-0.10.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | trueform-0.10.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 59.5 MB |
| Tags | CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
1fd7bb9c40b5e621101efb450b0f9e3b7a537a1c6c792bbcc2453bf1b23f4ff5
|
|
BLAKE2b-256 checksum How to use checksums |
ed63e1c716fb4a0a73680ef954e7014c0f54588600faa9bfbc5929589115b662
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / trueform-0.10.3-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | trueform-0.10.3-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 42.0 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
7eae76eea38fff52e97a5a8762f5a5e7ac067cac9032985b3a7bb33a4ec91316
|
|
BLAKE2b-256 checksum How to use checksums |
df32734fe9803be669e3a6e1bbf1a0f2ae9c59bc467cd7656665f83a4f300b53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|