Skip to main content

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

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}
}

Metadata

Release files for trueform 0.10.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trueform 0.10.1
File Size Uploaded
trueform-0.10.1.tar.gz 1.4 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for trueform 0.10.1
File
trueform-0.10.1-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
trueform-0.10.1-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.1-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
trueform-0.10.1-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
trueform-0.10.1-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.1-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
trueform-0.10.1-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
trueform-0.10.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
trueform-0.10.1-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details

Total release size: 387.4 MB

Release files / trueform-0.10.1.tar.gz

Download URL trueform-0.10.1.tar.gz
Size 1.4 MB
Tags Source
SHA-256 checksum
How to use checksums
62911da622a7815f5bd21239543b0d65982977505210271907843a3fc878e6c9
BLAKE2b-256 checksum
How to use checksums
5c9585aa1cc69e501feaa4b59c254f9886eaeb1772140de8069d8d10d14d1d60
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.1-cp313-cp313-win_amd64.whl

Download URL trueform-0.10.1-cp313-cp313-win_amd64.whl
Size 23.8 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
34e288cf9931e98115767e4a2020d443a33c25bd6bfead5185a881759fe040a6
BLAKE2b-256 checksum
How to use checksums
c629acb3fc7e27ab87ec60af8551fa6bd5379b74a00ba0d8c92de2d1ba101338
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.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL trueform-0.10.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 61.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
7852adf624bfc3bd9d0b44a1d456d8fb6ee7b8890db27a4c9b16544e6411b3a5
BLAKE2b-256 checksum
How to use checksums
6551b203dcb974cdc598e85d1dae709a05bb9fa3287fc4a4ff3b2a0fedc490a3
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.1-cp313-cp313-macosx_11_0_arm64.whl

Download URL trueform-0.10.1-cp313-cp313-macosx_11_0_arm64.whl
Size 43.4 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3de8ad41b192b918f0f7be37779e67dfd4bea293f21632fecc63ca83ff5535f1
BLAKE2b-256 checksum
How to use checksums
d43939e910e22a9dce0c091a075f104f085b54262418dd47aa9aaa7d44e97bca
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.1-cp312-cp312-win_amd64.whl

Download URL trueform-0.10.1-cp312-cp312-win_amd64.whl
Size 23.8 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
2a96cef5f4f18577a753fedc105b5f3d75cf367eef4b2ea42f510a87a1cae369
BLAKE2b-256 checksum
How to use checksums
93182b1b06dd318c701866bfaad9615c16e50bc1e2406ae37e006f63d55b9156
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.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL trueform-0.10.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 61.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
79a8ffad42f5057799a6dd9ac71d11cffb78a8207d6cdfa5538f2c35e49b8d7f
BLAKE2b-256 checksum
How to use checksums
c0d682bc329c1fa616be45fbcb827ff3eda5b5cb18ee83c9cd007206ebb2d475
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.1-cp312-cp312-macosx_11_0_arm64.whl

Download URL trueform-0.10.1-cp312-cp312-macosx_11_0_arm64.whl
Size 43.4 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
35abdd5bea633c841b061da43c7cca99f81202c0412d0be8004b485a13ba4006
BLAKE2b-256 checksum
How to use checksums
ac5495a5ae27c84406e4161cae66f419fd5c7782ade52767a344171c074ce5aa
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.1-cp311-cp311-win_amd64.whl

Download URL trueform-0.10.1-cp311-cp311-win_amd64.whl
Size 23.8 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
78ac60f8ee9e13f3b9cc6f19cd941aee81143c57fcadc942c4cb7b407cf6f05f
BLAKE2b-256 checksum
How to use checksums
9c3e98b12b8f72956f41ae6c917b43b0cbf641adf8fdad6cf0df880b97754f66
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.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL trueform-0.10.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 61.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
88e5716fde70d2bcd62109989ec6862ab8b1c0a9b69d97e340b55eafcf03f2d3
BLAKE2b-256 checksum
How to use checksums
2cbaded88e0668bf3823f275cf53e7d628068a5e5bcf768cfea0003f08f2c123
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.1-cp311-cp311-macosx_11_0_arm64.whl

Download URL trueform-0.10.1-cp311-cp311-macosx_11_0_arm64.whl
Size 43.4 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f7c849aa5e0c1ab69c9d0dcc5cf99100bdfef0f467d40d17bb6a22dd9066321c
BLAKE2b-256 checksum
How to use checksums
329756b011e0bd03bf63d6345b65e9eb8c0c57c5d1bd685c34e8af74dc6be9cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page