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

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.8
File Size Uploaded Provenance Actions
trueform-0.10.8.tar.gz 1.9 MB Without provenance Details for trueform-0.10.8.tar.gz

Built distributions (wheels)

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

Total release size: 487.4 MB

Release files / trueform-0.10.8.tar.gz

Download URL trueform-0.10.8.tar.gz
Size 1.9 MB
Tags Source
SHA-256 checksum
How to use checksums
66703609793cc02d790b13bd4d6e200717785024d72f23ab164c40cb22d67a1a
BLAKE2b-256 checksum
How to use checksums
27ced22d6dcc67a9485471e700b30a54bcae95243f476eb30cacd5e883a881c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / trueform-0.10.8-cp313-cp313-win_amd64.whl

Download URL trueform-0.10.8-cp313-cp313-win_amd64.whl
Size 30.1 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
13a1ca4e8ac31e3ad41463babdd85cdea86fad27d71265a072d3fa2e83698c16
BLAKE2b-256 checksum
How to use checksums
15b224bbf1b38243036b2304c56daf37563ad4767dc2b95398729e424f799b0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / trueform-0.10.8-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL trueform-0.10.8-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 77.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
def032389117b5199255b19842761e0b7abbfb4c6fe971e316993ca5652f897e
BLAKE2b-256 checksum
How to use checksums
3dde8e01965854cb09d4541c0061a9ba0bf045a990b0658e5535c6ecbca7a0c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / trueform-0.10.8-cp313-cp313-macosx_11_0_arm64.whl

Download URL trueform-0.10.8-cp313-cp313-macosx_11_0_arm64.whl
Size 54.0 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
42d07389b13e553c1460abf7c540bef13a7cb114962e882d1d8184d9fc531dd1
BLAKE2b-256 checksum
How to use checksums
740519df2d965ebce509ba78251cdc7b4fcd4ae9312399520a20cb60473056ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / trueform-0.10.8-cp312-cp312-win_amd64.whl

Download URL trueform-0.10.8-cp312-cp312-win_amd64.whl
Size 30.1 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
ca2b31a9338f61cb2db391e266de78e061fe60c39bc9b6ebbe1df37808797bd6
BLAKE2b-256 checksum
How to use checksums
8dc4bb9a9db563b90e5cc736363b1568fc2f4330b754c2963b31e67393acc961
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / trueform-0.10.8-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL trueform-0.10.8-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 77.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
9d828d8754cf8ed560175d6a4d3ed86dffdab2a412d4fb36ec3d884d6c0c91a4
BLAKE2b-256 checksum
How to use checksums
eb22652f4c1bce4cf87aaa3591b1cc79bae27992ac89c77fcf0cea15e8a13401
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / trueform-0.10.8-cp312-cp312-macosx_11_0_arm64.whl

Download URL trueform-0.10.8-cp312-cp312-macosx_11_0_arm64.whl
Size 54.0 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
26f2bb281e655c6dad0b464163abf5dd5e3709bd6587d4f217e2b2130a98b061
BLAKE2b-256 checksum
How to use checksums
21d96816df2389191834e3828a5be6af30a30756abd335923dfadf598b2ed5b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / trueform-0.10.8-cp311-cp311-win_amd64.whl

Download URL trueform-0.10.8-cp311-cp311-win_amd64.whl
Size 30.1 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
12e8064e51a3262d8048d10d6b96ba5ed1e67daf4e78922223b083fb4a5b4e07
BLAKE2b-256 checksum
How to use checksums
8237daf3c66553a2a28b62407199df4f6c03d5fb322767473676c7bde673b974
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / trueform-0.10.8-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL trueform-0.10.8-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 77.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
874434dc233fa99f60d075578216ef3a54eab9bc7700190d52e7faaf543060f9
BLAKE2b-256 checksum
How to use checksums
84809192a8ddc567892e750077db205a9f01c19f0df01ca881be98f955e65e57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / trueform-0.10.8-cp311-cp311-macosx_11_0_arm64.whl

Download URL trueform-0.10.8-cp311-cp311-macosx_11_0_arm64.whl
Size 54.0 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
be1bc2caae2e99c58bed128f18a7e541c1c07bad21bfa498438ab458fd0634d6
BLAKE2b-256 checksum
How to use checksums
6396ba2a68eb0bef0a24d0abe2c0f98059cdc97cde100a1fbad4fb6e38847e46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for trueform 0.10.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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