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.6
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.6.tar.gz | 1.7 MB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| trueform-0.10.6-cp313-cp313-win_amd64.whl | CPython 3.13 | CPython 3.13 | Windows x86-64 | Details |
| trueform-0.10.6-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.6-cp313-cp313-macosx_11_0_arm64.whl | CPython 3.13 | CPython 3.13 | macOS 11.0+ ARM64 | Details |
| trueform-0.10.6-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details |
| trueform-0.10.6-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.6-cp312-cp312-macosx_11_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 11.0+ ARM64 | Details |
| trueform-0.10.6-cp311-cp311-win_amd64.whl | CPython 3.11 | CPython 3.11 | Windows x86-64 | Details |
| trueform-0.10.6-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.6-cp311-cp311-macosx_11_0_arm64.whl | CPython 3.11 | CPython 3.11 | macOS 11.0+ ARM64 | Details |
Total release size: 399.2 MB
Release files / trueform-0.10.6.tar.gz
| Download URL | trueform-0.10.6.tar.gz |
|---|---|
| Size | 1.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e189b7f6ee267c18315b331a4a47ca013323463e229b3df72182788c068a060f
|
|
BLAKE2b-256 checksum How to use checksums |
82c2688a3638dfcd191f517af249908c4d5cdcea6d59b3cbc3f4ddd55f42b988
|
| 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.6-cp313-cp313-win_amd64.whl
| Download URL | trueform-0.10.6-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 25.6 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
532b2d9e0ff82d08093585bcf8db7f9181066cefe942cc6f7e6b3ce474e7286a
|
|
BLAKE2b-256 checksum How to use checksums |
a0ae0eb9c1f6e1c04ba826488e8d026c8da6da805c5e66073c839c4399368d6a
|
| 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.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | trueform-0.10.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 62.3 MB |
| Tags | CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
5d4da204d2d1fc0f3ab9ac04a7247ddba23595e4d611bc67480663a078c3b480
|
|
BLAKE2b-256 checksum How to use checksums |
670ec1b2cdefb3bb7ee0d041220c5489318c2a79b7a68390d71ac4548b0f7f63
|
| 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.6-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | trueform-0.10.6-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 44.6 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
d0be898baf95a5f302ad39102cf1b8d8f6bbe37367a43c9058ea2c3d5352160a
|
|
BLAKE2b-256 checksum How to use checksums |
65523c73271bea48757e764e7893ca022b9f62db72563b058eda67add7ad589c
|
| 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.6-cp312-cp312-win_amd64.whl
| Download URL | trueform-0.10.6-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 25.6 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
42d409103858c1cf679b04a1ae2df6afb668c8c719499713111a18fa220a22a8
|
|
BLAKE2b-256 checksum How to use checksums |
80517734ea4ef096e1fa6c037c192a54c29d3b57337a4609eaaf02faad5eaab7
|
| 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.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | trueform-0.10.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 62.3 MB |
| Tags | CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
e5af4e7ef4684f966f19837ff8700eaae8acfd16abeb175a695c7f4547669b3c
|
|
BLAKE2b-256 checksum How to use checksums |
b337364ac5d716a22e2527f45b52f9b31405375a63076ac72b28c7bccdc9500b
|
| 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.6-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | trueform-0.10.6-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 44.6 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
a216984c0679aeca3f5fefaf2b039d3396e33d35cfc8628b94ad4415123044ae
|
|
BLAKE2b-256 checksum How to use checksums |
8a2a1376d9f68d24aea0fb69426a72d66fc1c540fcceb16a81382b384cf21dd5
|
| 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.6-cp311-cp311-win_amd64.whl
| Download URL | trueform-0.10.6-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 25.6 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f0e2a44591aaf3350d8655ba05420a7257aaae3e20b733a480db29563dd43121
|
|
BLAKE2b-256 checksum How to use checksums |
7a8398e9d1c1d7d4d32b015e3ee1a88091028cf88df8097f61fd4655ce3190f4
|
| 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.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | trueform-0.10.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 62.3 MB |
| Tags | CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
66fe23b5f389af6bacb83d39aa2fa19dd8ac577a756d6aab7b348507975b5a6f
|
|
BLAKE2b-256 checksum How to use checksums |
fa35be5ac15f38bcf8d693d7245addbbdf027d3825c29345da048c461538e340
|
| 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.6-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | trueform-0.10.6-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 44.6 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
a01f3a246374bbe05bef31e5e4736fc6bee30a719df3e76ebe09feb3dd7325cb
|
|
BLAKE2b-256 checksum How to use checksums |
033d5db959344d1867eb74cf49e76b0807c90e50bffef31aa94e30cb030e7084
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|