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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

trueform-0.9.12-cp313-cp313-win_amd64.whl (28.1 MB view details)

Uploaded CPython 3.13Windows x86-64

trueform-0.9.12-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (75.6 MB view details)

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

trueform-0.9.12-cp313-cp313-macosx_11_0_arm64.whl (45.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

trueform-0.9.12-cp312-cp312-win_amd64.whl (28.1 MB view details)

Uploaded CPython 3.12Windows x86-64

trueform-0.9.12-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (75.6 MB view details)

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

trueform-0.9.12-cp312-cp312-macosx_11_0_arm64.whl (45.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

trueform-0.9.12-cp311-cp311-win_amd64.whl (28.1 MB view details)

Uploaded CPython 3.11Windows x86-64

trueform-0.9.12-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (75.6 MB view details)

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

trueform-0.9.12-cp311-cp311-macosx_11_0_arm64.whl (45.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: trueform-0.9.12-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 28.1 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.12-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 178f74953bab2c2943a594263e0d56d0036e111fc2c25759f31a05928945cad5
MD5 5e40a2f5e0b16943805161baa691abe2
BLAKE2b-256 fd13cf752e330e0c9d1246a5ab1dea8e273a97ea2070af34193ab1834aad37a7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.12-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0adbaec5bc4539d633e28d5c3bf80e8f95557d0c4c7c8ea99d4c4134de4f1363
MD5 6e246482d9a7581da32e329f392b9095
BLAKE2b-256 8b3978ef2157e5343f560b4feeb0d8ce0aae8de80db06d84403ab14b90e794a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.12-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d2b3ada9d3de0a9b64963cb5a55d82546c3aa109bd7bc3df889ddc87039aaaef
MD5 2950fbd08e4eb466198026f44b0d54dd
BLAKE2b-256 533a7ee7fa01c2938f1eb9f682089792ce7be328c648195746d93b204e546a3f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.12-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 28.1 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.12-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 61f8c91d17f5ebd7fdf85a3bb53e9d8db98c2207ad8ff794562d6b90272262b4
MD5 1045634a2338393345ea2759c78d29d1
BLAKE2b-256 47c3cea8e7cbb9ee25345e4c3cb8fc7516fce5f33eecc40cef34f28765530a48

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.12-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9c078d559040cda3f9ef2f1de59932f54c44127fe7a00872885ed9c04231e722
MD5 924589957d6e5cbb8b39ed4215b42eec
BLAKE2b-256 2e3da5918a9f68fd127b6142e7f3a867323d62f4695badab9956a2f706e6202a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.12-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8e2cda116a89aac1b240409544c0baecd95624650fa1487faaa32ef3646bdf52
MD5 5e244bd16d8910dd6ed799a6e1e776fb
BLAKE2b-256 9c8ecb6b9bef51a7b0da8e3b138f30d9e8b6e61c558ceb315cf0bc75e87748ed

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.12-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 28.1 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.12-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b408165fcf0300ae96a322cd13f1877daee324cc9f4ebc00823346d77af6cd1f
MD5 b520e43d3e46d93c54f05632f0cb7af6
BLAKE2b-256 bd59acd02f2b591cfdd057c28247f625e18b4bbc0176097de23d936cee6fc8ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.12-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0a5c33177423ffd7b17ccd4863cf2a7295d9a3ad0b9a803d5ff9e7b362e8eb6f
MD5 2401fb6190f788c65b51badbc9e112af
BLAKE2b-256 af1d7445b22c1727f8696246e78f66065e29895ca2138233fcf122aff77a2e0c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.12-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0e7524f02dd2e0bbdaab2c84621aa1abf35884f25a5571685853f82b80a69c18
MD5 4d8a777a7b3777ba32991e4151c42cfc
BLAKE2b-256 869bb7aa2ddc6fd701581ad976dc0f46817d8776c4fb34f17db74663b69bfd6f

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