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.15.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.15-cp313-cp313-win_amd64.whl (32.1 MB view details)

Uploaded CPython 3.13Windows x86-64

trueform-0.9.15-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (87.7 MB view details)

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

trueform-0.9.15-cp313-cp313-macosx_11_0_arm64.whl (53.2 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

trueform-0.9.15-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (87.7 MB view details)

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

trueform-0.9.15-cp312-cp312-macosx_11_0_arm64.whl (53.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

trueform-0.9.15-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (87.7 MB view details)

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

trueform-0.9.15-cp311-cp311-macosx_11_0_arm64.whl (53.2 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: trueform-0.9.15.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.15.tar.gz
Algorithm Hash digest
SHA256 d2e95b056306127117ecbdb96f78fb9b4d3efae979f3827f391f7da0615428d3
MD5 ad30c0989c1a4b3169e60e14840b68a8
BLAKE2b-256 cf9f722bd6a00a29bd105353de8b4db26b7661b3e4520e32c8b6c0951a707c2c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.15-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.15-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a1ac03386d67a116714598ab19349b576260984f18af8c735afb4741f45431ea
MD5 f246473f4636fdedd925a40bcb40469f
BLAKE2b-256 682535b184a11213eb787e0ad6fbdb1c977aaf923921fdbfb4fa47a99cf4e66a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.15-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fbdda2450b2a60fd87e69f558e0ffaee742ff6dea11e5244391b9958bde139fd
MD5 fbf6b98167327ce1f705771bb6b5ec2e
BLAKE2b-256 fb5437a9d91368beb759d7369b6c8bf7c83aab86bb5f3fb5877d171da63718a5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.15-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 754f64ad9708d0d3840c49c54bbc153a0d18e4f5cbefd359d9857cd4803d6af7
MD5 56efaea9e120c3a8a35c27375b43fa07
BLAKE2b-256 8254a018e4075a1497f586a8f0c6cc9e5e9112a58b5620d4c098c46bb26b2fc1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.15-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.15-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ba1d53d4f8076e84a8eb4affbc3204c3e46b012cc3f63dc4ae426dba64af7ae2
MD5 1381058c05212693fb2066c43b307b25
BLAKE2b-256 b3eac4434bb5ce131dacacc2ab8f6433a1fb00a9e2004a89d4c1d1fcaa922427

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.15-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1a41126c04992f7ac328ffbaf509dff57a94e828180afa611ee4bbbe94f1c6ac
MD5 d6d109290d2c143bcacddbcca60f7b70
BLAKE2b-256 b2327d33669a6eb98b084a437bd44508befebe15799984ac128393c044cd599e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.15-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f675c842219c31c0b80033f48e36f66676c8c3f3f25217a1d5c35405b7ab65e0
MD5 6ab557d0670905afc7c9c2341b7786e0
BLAKE2b-256 29d1084152b6902859c9ea8be399d21147c716fb7bb47ac090022e9cdbfd801f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.15-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.15-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a4094a7abf0d824eb83185a8e55b502041928dc49bc0d8d16e12f5460c608465
MD5 88737752e26eba66b4ee563475dae19b
BLAKE2b-256 f0d44cbf6c5fec332235cce7ba062c5012ce01e91e13ffbac4b8251a90174a1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.15-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3d9e0ba89eff988e76a6f8154e6e90bc2181015e216e21e7b0b003b302089d79
MD5 7822dff8b39ad375f5b2424c8459a988
BLAKE2b-256 991efd00e93e7629c24e632ff48fcf823f154f9497182fcd61d7193642569651

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.15-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e9868c9d47386e5fc4b91f476defcf6d994498c33cfa7e2051cff168bbbff6b0
MD5 e2cf3669413315479a0785eaccc03878
BLAKE2b-256 4a858437fb0d4a4c1d24b45b816be958276018f895ef74902bc97096783c060f

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