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 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 nanoflann k-d tree AABB tree
Mesh–Mesh Distance 2 × 1M 0.2 ms 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}
}

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trueform-0.9.14.tar.gz (1.1 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

trueform-0.9.14-cp313-cp313-win_amd64.whl (28.9 MB view details)

Uploaded CPython 3.13Windows x86-64

trueform-0.9.14-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (78.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

trueform-0.9.14-cp313-cp313-macosx_11_0_arm64.whl (47.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

trueform-0.9.14-cp312-cp312-win_amd64.whl (28.9 MB view details)

Uploaded CPython 3.12Windows x86-64

trueform-0.9.14-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (78.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

trueform-0.9.14-cp312-cp312-macosx_11_0_arm64.whl (47.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

trueform-0.9.14-cp311-cp311-win_amd64.whl (28.9 MB view details)

Uploaded CPython 3.11Windows x86-64

trueform-0.9.14-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (78.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

trueform-0.9.14-cp311-cp311-macosx_11_0_arm64.whl (47.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file trueform-0.9.14.tar.gz.

File metadata

  • Download URL: trueform-0.9.14.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for trueform-0.9.14.tar.gz
Algorithm Hash digest
SHA256 c9eef3b0030cd8293b9fc241d2f2be8112fcbe4c338f7022634b8d62a6542b4e
MD5 88f18880d68526353bdcea2a0dc522ea
BLAKE2b-256 26b81d760597aac06dcbf320231ca043ec9df0cebe2d0bbd8407b9021d69a349

See more details on using hashes here.

File details

Details for the file trueform-0.9.14-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: trueform-0.9.14-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 28.9 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for trueform-0.9.14-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 10919fc2c10b0df9a464cf038e002d357077b2aa8d0f1e7afd796b28aded6f00
MD5 7e1cda64f0e1ceb8d9bbfff9070ac651
BLAKE2b-256 179ab9a160bf8399a2cce279683c137e2791931ed8d4b9be3c8cb44a254f683b

See more details on using hashes here.

File details

Details for the file trueform-0.9.14-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for trueform-0.9.14-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a97dedfcd0d05218ffbecf71cf66e20015a4c8039a90c2800f24f6c2d0e00bd9
MD5 98a262f0c31507b88bec32d677d633a7
BLAKE2b-256 21700283d9acdec7daf59ae5e7e7854e610854ce5cc706473c09233f3ee5fca2

See more details on using hashes here.

File details

Details for the file trueform-0.9.14-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for trueform-0.9.14-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5c6525eb38e999b3f1820b4a21c1bf7f5a4567662c620bc21a77ffe39aba2b30
MD5 b527da283009c080ddc955e5d0614f0b
BLAKE2b-256 66a0f3932c3510f11f8b098a1e577ae23b90faab84cece986e123414fa5b1aa0

See more details on using hashes here.

File details

Details for the file trueform-0.9.14-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: trueform-0.9.14-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 28.9 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for trueform-0.9.14-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2859940956e35102755ad5c434df32ff4f14b9d6845f526f3519fa0060a3788d
MD5 61f51c0e8b0b4ef9caad050436d40f7a
BLAKE2b-256 3c93a38bc0de92761a081c8c08fdb19511d42fc0b3357973d95641df3749fb65

See more details on using hashes here.

File details

Details for the file trueform-0.9.14-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for trueform-0.9.14-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 641695be995c994c7ddb05cb414052f2200d2034c4f47611698fb647cc350418
MD5 2b39b2c9d3a62e5b994aac0587615fe7
BLAKE2b-256 697116edb5761f35ac886b22552407312c97a60b79c0a01c85ee8058e1aaa4e3

See more details on using hashes here.

File details

Details for the file trueform-0.9.14-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for trueform-0.9.14-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 818b422ece5d2197d7205cd94602bd05cc166244f7b3eeaee64a797e2527ef7e
MD5 6320d6be44e7a35e5acd17ba10521c44
BLAKE2b-256 6517e8491ef9e9f863dfef287c42d4c87894de986d150b022390fcb8c5628044

See more details on using hashes here.

File details

Details for the file trueform-0.9.14-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: trueform-0.9.14-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 28.9 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for trueform-0.9.14-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 342eb1a75447401ad56a7dfd2fbe731d480f1928382344ca65f0d49763b55502
MD5 4f1afbef5e5671d3b1dbdb9de2e0b70b
BLAKE2b-256 7296c63ff4c3fbd91eee07c5d96c407416d5850bbaba45d9954b8d162a342bae

See more details on using hashes here.

File details

Details for the file trueform-0.9.14-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for trueform-0.9.14-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f63dd657fa9b6efa87c46151c2f371fc3c11e9463f653ee4cc67b537ac52e82f
MD5 1694cda930ce88221cb1ee5605b086a1
BLAKE2b-256 f20d2d4e52118a87414be013a49f52d09fbf0fa95653bcc8d101a9a0f9ed4b50

See more details on using hashes here.

File details

Details for the file trueform-0.9.14-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for trueform-0.9.14-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ae4906b76391ffe3f14a4422a260de14c5d45a50a2be56163f12ccb78d23b982
MD5 21170785d969a776f05cc296a6b76430
BLAKE2b-256 34583814eaf891babb87994673087a5e73ed6fb33f686fec558d5d8d89f61db3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page