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

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.2
File Size Uploaded
trueform-0.10.2.tar.gz 1.4 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for trueform 0.10.2
File
trueform-0.10.2-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
trueform-0.10.2-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.2-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
trueform-0.10.2-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
trueform-0.10.2-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.2-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
trueform-0.10.2-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
trueform-0.10.2-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.2-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details

Total release size: 375.6 MB

Release files / trueform-0.10.2.tar.gz

Download URL trueform-0.10.2.tar.gz
Size 1.4 MB
Tags Source
SHA-256 checksum
How to use checksums
2cd7ec6fb6440c2a6f54d499e7a714c939c7336acd1f1f9f06651054b01e65f8
BLAKE2b-256 checksum
How to use checksums
b6db6557d76a2556fbe2956240ead5f6048f13be01da1281ce1502f7b4373b15
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.2-cp313-cp313-win_amd64.whl

Download URL trueform-0.10.2-cp313-cp313-win_amd64.whl
Size 23.3 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
ebf31dc1419f84727e2a88dddc0a30d7d6049566b6c1086af4b82950d5bacd0b
BLAKE2b-256 checksum
How to use checksums
453643c93cad87e72a641b079781decfe0f4767764fbf36fa44acae36f1a9e81
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.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL trueform-0.10.2-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
25929ee1dddbf28ddcb6df5543752ecc0f015086fed019b7a555bea6da5a7328
BLAKE2b-256 checksum
How to use checksums
fce077b0c65f2261e2586b616dbb8931574de79c3f1c807a992e4b911cceb42e
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.2-cp313-cp313-macosx_11_0_arm64.whl

Download URL trueform-0.10.2-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
051fecc3dcc0bd1a91e387527d5407b3c23930d22eb6a3d8ce07355d2b53d756
BLAKE2b-256 checksum
How to use checksums
662b16b7b01ccd4370476bc36dcb493d8706d68e48caab516637efa7b65dc9ae
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.2-cp312-cp312-win_amd64.whl

Download URL trueform-0.10.2-cp312-cp312-win_amd64.whl
Size 23.3 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
4e43f7b4a287759fabb75600eb491e6edbbfae9d0bb8d18b709c7dd49dea1c2a
BLAKE2b-256 checksum
How to use checksums
a173a5f0e327e72ff0d7688ca357f3124db767344f7c486ecb5351b98da0facf
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.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL trueform-0.10.2-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
08f7627c31bf158694a561ef3164605ad35ba516a1ce119f61d4c51286ac6e1d
BLAKE2b-256 checksum
How to use checksums
12a97fcbc7d81acf122d5102fb3f354c27addccf5d146b21c0184f0cd8d00534
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.2-cp312-cp312-macosx_11_0_arm64.whl

Download URL trueform-0.10.2-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
e6c6edaf1cb04917d109866de18a4c4dba51fd4610dee7e6180fc238bff6d22b
BLAKE2b-256 checksum
How to use checksums
5d8abc4c8c8d9557f4fc731936d98ca230cd824804a342c116f45d2e110bbd42
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.2-cp311-cp311-win_amd64.whl

Download URL trueform-0.10.2-cp311-cp311-win_amd64.whl
Size 23.3 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
1090a6e8fbbd97085ef697904c8cf9dd2ccb1740f4e8740e2c6d02fe6ab07ab9
BLAKE2b-256 checksum
How to use checksums
b3f4ce20f925036b1e43558860fed34f79f5720cb6c7f123726ec176be88e0af
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.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL trueform-0.10.2-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
ac7ec0367e2b08bf65df7a5c31985e3e5ca3b3306399c86d696e58664cfa5be5
BLAKE2b-256 checksum
How to use checksums
199b0bbdfd6503750eb17d2c02b37d244025787c1dad096b9ee5b05827758ce8
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.2-cp311-cp311-macosx_11_0_arm64.whl

Download URL trueform-0.10.2-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
ab9f4a2838812499475e67b1b9c48e639d22c3d20d508e0073c21af6d4a59236
BLAKE2b-256 checksum
How to use checksums
f4dbe0e36e260f05980c38f50679f0f7908d3d549bbbe3e25d4dfd00b5444d2f
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