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

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

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.7
File Size Uploaded
trueform-0.10.7.tar.gz 1.8 MB Details

Built distributions (wheels)

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

Total release size: 427.7 MB

Release files / trueform-0.10.7.tar.gz

Download URL trueform-0.10.7.tar.gz
Size 1.8 MB
Tags Source
SHA-256 checksum
How to use checksums
15f1f4e4a3be29f2dd4659edb99c9463238062cdecb27ba20df75d496e94cf05
BLAKE2b-256 checksum
How to use checksums
f51b664913b445e5b26b06706cfd3cbce7f2abe2c3427d1647d6a60355e42845
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.7-cp313-cp313-win_amd64.whl

Download URL trueform-0.10.7-cp313-cp313-win_amd64.whl
Size 26.6 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
932a41cc5a59c3222f453e6311ba84ed1db8cd7297228ff5f47a8f9d0dfd00b9
BLAKE2b-256 checksum
How to use checksums
03c5fdbdd92a4fbd5ceeb76d09a8916dd949a4e99241cf336dc22961dff9cc05
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.7-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL trueform-0.10.7-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 67.6 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
d4023834268c5ac18219c6dac3df53b5533702873417ec6c411f3862bec06d80
BLAKE2b-256 checksum
How to use checksums
97d4217bef5336a1f12b83ce123a9b60fd1a8121de5a78063442ef2b8076a5e5
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.7-cp313-cp313-macosx_11_0_arm64.whl

Download URL trueform-0.10.7-cp313-cp313-macosx_11_0_arm64.whl
Size 47.8 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1c78201c8edacbfd1630ee5863f648906c1c474f97ab16a06c842e22755806dd
BLAKE2b-256 checksum
How to use checksums
a26b9c855a9f8599d980fe730f3117f4c8f73fb61f06cc1db3e3b7bbdc1bfb50
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.7-cp312-cp312-win_amd64.whl

Download URL trueform-0.10.7-cp312-cp312-win_amd64.whl
Size 26.6 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
61c2e7957de5acea73f133e69232d41d41592c29011cff73c4448c0e618f7c63
BLAKE2b-256 checksum
How to use checksums
078945ccf62b90f9c2eb7d7111690424956322940672cdc7538fff3020fcf65c
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.7-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL trueform-0.10.7-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 67.6 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
d206af0d5b9cd747104364a51752d7ef38da7fa4ffc900f59abd22e9ba4bef8e
BLAKE2b-256 checksum
How to use checksums
34b3de50d0eb68a1ce69516118187f9a05d832a73ca2c26daf5e4dc2a4e26f60
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.7-cp312-cp312-macosx_11_0_arm64.whl

Download URL trueform-0.10.7-cp312-cp312-macosx_11_0_arm64.whl
Size 47.8 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9d16231e4b451774a9eda040f38865626ffae1d55af7ba51658e670101f976f3
BLAKE2b-256 checksum
How to use checksums
de0f75b71b4c2c91a0c8115c78b365a8d3b8f6fb897c548ccc7c541cd8587278
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.7-cp311-cp311-win_amd64.whl

Download URL trueform-0.10.7-cp311-cp311-win_amd64.whl
Size 26.6 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
d2db5773ab254c8809b79bb62ac780055bfb3355451ec43591ff7c60b3beff5d
BLAKE2b-256 checksum
How to use checksums
9a3b4d652f066e170c8a3c6e9a5dff258a04a80faf39e410e9e73f8fea04c24e
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.7-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL trueform-0.10.7-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 67.6 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
3d51fd1a51801f366c196704b4eff2ecf240192f38ff557b6e56e72e41ec0dc9
BLAKE2b-256 checksum
How to use checksums
f2b3acc45f39eebc9f25d52a286e657bf73ea7541460270ddf4c8c6bd6eb4267
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.7-cp311-cp311-macosx_11_0_arm64.whl

Download URL trueform-0.10.7-cp311-cp311-macosx_11_0_arm64.whl
Size 47.8 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5b62ec3e79e3ef38ffcce13f2a4f2401b5b7230d0e91d49a4df8cf65744599a8
BLAKE2b-256 checksum
How to use checksums
e5a0fe14891c152c56acca11d6e31f601c5bba01ce0212b687c39e4827b7a94a
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