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
PyVista Integration
Booleans, intersection curves, repairs, and isocontours on PyVista meshes through a .trueform accessor. pip install pyvista-trueform — see pyvista-trueform.
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.4
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.4.tar.gz | 1.6 MB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| trueform-0.10.4-cp313-cp313-win_amd64.whl | CPython 3.13 | CPython 3.13 | Windows x86-64 | Details |
| trueform-0.10.4-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.4-cp313-cp313-macosx_11_0_arm64.whl | CPython 3.13 | CPython 3.13 | macOS 11.0+ ARM64 | Details |
| trueform-0.10.4-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details |
| trueform-0.10.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 | Details |
| trueform-0.10.4-cp312-cp312-macosx_11_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 11.0+ ARM64 | Details |
| trueform-0.10.4-cp311-cp311-win_amd64.whl | CPython 3.11 | CPython 3.11 | Windows x86-64 | Details |
| trueform-0.10.4-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.4-cp311-cp311-macosx_11_0_arm64.whl | CPython 3.11 | CPython 3.11 | macOS 11.0+ ARM64 | Details |
Total release size: 393.8 MB
Release files / trueform-0.10.4.tar.gz
| Download URL | trueform-0.10.4.tar.gz |
|---|---|
| Size | 1.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ef393cbea9e5632f359353887dce46ec77f49dcdafd82a7f027045e43cd31b5e
|
|
BLAKE2b-256 checksum How to use checksums |
8d0851ec88a308173a2c909250e868ca2a6edde870635660530c164c8d481d62
|
| 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.4-cp313-cp313-win_amd64.whl
| Download URL | trueform-0.10.4-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 25.0 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
47e61fee65987f19e67ddacfdbfa3cf7cba94cf129e82e645fd20559ae5bcbe5
|
|
BLAKE2b-256 checksum How to use checksums |
1b750eb8cfa092e0c08852b3712d8226650993895d5235f95f9db1c7c41d5038
|
| 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.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | trueform-0.10.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 61.7 MB |
| Tags | CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
e3d9a989341fcd01c1a92ba4a54ea73df84c3406b76fcb45bd91a4d3abe0a811
|
|
BLAKE2b-256 checksum How to use checksums |
fd841a9fc82e1faf72ba34e0d4b8163096b146258523cb24ac091f26a0d104ae
|
| 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.4-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | trueform-0.10.4-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 44.0 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
fbf947630d20db8937357369a7d4ee619dffd49e83b57ac7aa5060941ffd6cdc
|
|
BLAKE2b-256 checksum How to use checksums |
75229aadf06c874151f8b103ab6b0c7d2331c635a30ef18a8ca49d23feac9e5b
|
| 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.4-cp312-cp312-win_amd64.whl
| Download URL | trueform-0.10.4-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 25.0 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
1785b9513ee6841c78851a4e40498f431276d9879ac74117532c59a38a53d8b8
|
|
BLAKE2b-256 checksum How to use checksums |
b752bb9984eb0b3e0f33f93aecb0f67df93d683892471e223d1f6774d4612fa2
|
| 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.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | trueform-0.10.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 61.7 MB |
| Tags | CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
ba90bf4e3769496a88f6f69b08d4707626777efecd02c1d41f30f2aa2fcce2ec
|
|
BLAKE2b-256 checksum How to use checksums |
3161b95c18e1f3bec1c5331e90ec8630b3e8888d5a1991140850870a8acbe446
|
| 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.4-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | trueform-0.10.4-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 44.0 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ce9cfb86e733f143385d9845307a9c3515cea35c746bc2c49a5184852c051742
|
|
BLAKE2b-256 checksum How to use checksums |
1b21aba533884fc6b14bd0d275dcabdb24accf7bf80bbdc4533cbceff826df52
|
| 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.4-cp311-cp311-win_amd64.whl
| Download URL | trueform-0.10.4-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 25.0 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
99b7780375e5c2111b2afe7a07f60bf9fcb124e6839119b315c45d11fc76b98c
|
|
BLAKE2b-256 checksum How to use checksums |
0184ccc0540efe4696a8e1fd0378f5e02ada47c65ab72c9ddba5ee4cb1488a85
|
| 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.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | trueform-0.10.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 61.7 MB |
| Tags | CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
fe2f4f7a11ac957455d448fc96b66730ab6b80635536cc0e4d956b9aec8a8c30
|
|
BLAKE2b-256 checksum How to use checksums |
48e32969ca612328400f40dc50b90ab681925ca4ba4680e633eb99eb6368922f
|
| 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.4-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | trueform-0.10.4-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 44.0 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
aa4b4d7239f64772ac65e28f60335f9c3603bf93d98d51a8da16cfb62dc85ac3
|
|
BLAKE2b-256 checksum How to use checksums |
f2eba63a1fb6a86b913aa2d55e8775e164ec379fb3632a33a98dab11faade54d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|