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.16.tar.gz (1.2 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.16-cp313-cp313-win_amd64.whl (32.1 MB view details)

Uploaded CPython 3.13Windows x86-64

trueform-0.9.16-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (87.9 MB view details)

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

trueform-0.9.16-cp313-cp313-macosx_11_0_arm64.whl (53.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

trueform-0.9.16-cp312-cp312-win_amd64.whl (32.1 MB view details)

Uploaded CPython 3.12Windows x86-64

trueform-0.9.16-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (87.9 MB view details)

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

trueform-0.9.16-cp312-cp312-macosx_11_0_arm64.whl (53.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

trueform-0.9.16-cp311-cp311-win_amd64.whl (32.1 MB view details)

Uploaded CPython 3.11Windows x86-64

trueform-0.9.16-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (87.9 MB view details)

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

trueform-0.9.16-cp311-cp311-macosx_11_0_arm64.whl (53.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for trueform-0.9.16.tar.gz
Algorithm Hash digest
SHA256 5fe248d058a44b53f5a3d5a400b01b81549bf2e4ce732a03ebf6b8846f9a521b
MD5 22b705f9bbb7780aaeda41e843cd8842
BLAKE2b-256 db7a6d12d9f141c3be80e3d44f95f09d5554fb0a31ff4de3ed9546a89f1f10f4

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for trueform-0.9.16-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 dc69900278fb66af4bf15d9eefd8236f20721cfdc6b1d6cb816bffe442ef8b38
MD5 ebacce8f144084ea772f9658e7bdd0cc
BLAKE2b-256 0d991c5a3faef3ebdb1fa3d9dea1d0de51ede8a82220a85f59996139cf1a7ecd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.16-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 606930226cabbaf5682941ec41057af3bb75e52eacfc79926550b68ff9959219
MD5 2ee6854f7ec423c87fcbf472f05d216a
BLAKE2b-256 b0f734505e0f84a6d5532d3c838c3fa9f33db1bf23552439643e3ff927036765

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.16-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8f3f69499eae79d0f1781c4497992be6d1bc616740e10ba3ef61067d837c0ec7
MD5 4719fb5a5c6092f534f9f0d5a531304a
BLAKE2b-256 32c3c1235f43efa6c1a880b3ebcd2655b76bde9c4ed0c4ff78c8d17fbb6e4cf1

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for trueform-0.9.16-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c9cfd22c75a790c0de6a64f57a5f3190e8b4e9c73eccbfeb5bdc8ec4543218ea
MD5 a01bf6b8075af3d9384a9d306eddd9ca
BLAKE2b-256 6e8265d45884a4009f0921c9ecc2f177cf151893c7a68471d89f616f105cee19

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.16-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 044c08890eff0223a904265c3c1331b911451edf2fa19f68560b3c1782e1a576
MD5 d3077b8d204422773af5747436f8db98
BLAKE2b-256 cc58eb628c357393d0a038c7da75142ace0b2fab998a413713eac8053f90bb74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.16-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 535b60c208d70015a78eb2a8d4cecaa21bc2d2c856a8ddbf578e765a83674cc6
MD5 4b5057dc0bf568276235f5c4a7c04401
BLAKE2b-256 fe5799af9c820ebacaa82fdc10e6c1757d0df50a0cb91d1fb1524a71ba90c517

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for trueform-0.9.16-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 586dd905446f4b0437d6b53c48b36626c0a87c7e84118c2bffcb62a93ebc6f4e
MD5 fdeb31931f3ba6d303104c31cc4c7865
BLAKE2b-256 2df8277dee311ab583bd140ca0ae2b6b545d8dedb18be30c4cac7c13c60fc380

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.16-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8ec955aa2c88d2eb1f51d2840e2c051da0ce49b2dfc1920af05fb331d37d8d73
MD5 b94ab21eaa8bbedc73366d91c7d0f4f8
BLAKE2b-256 eeaf349ed6c194ec23a6c637d72e7703285a2b1c0a694f7d9e839a839d2af015

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.16-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f682fe0d7c06bbb8181ca0fb3c5bffa8d20ef5e87760cf2c6083bd73fdbd5a43
MD5 efa01b1c67c41e78aba7d45de6bfba27
BLAKE2b-256 43d5e817e0a97b72c329d9cabaeaa50cc59191a91eb83c4748849cf5f57a97a1

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