Skip to main content

Fast and exact mesh booleans, spatial queries, arrangements, registration, and remeshing on NumPy arrays. NumPy in, NumPy out.

Project description

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}
}

Project details


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.6.tar.gz (938.6 kB 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.6-cp313-cp313-win_amd64.whl (24.5 MB view details)

Uploaded CPython 3.13Windows x86-64

trueform-0.9.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (68.9 MB view details)

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

trueform-0.9.6-cp313-cp313-macosx_11_0_arm64.whl (42.8 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

trueform-0.9.6-cp312-cp312-win_amd64.whl (24.5 MB view details)

Uploaded CPython 3.12Windows x86-64

trueform-0.9.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (68.9 MB view details)

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

trueform-0.9.6-cp312-cp312-macosx_11_0_arm64.whl (42.8 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

trueform-0.9.6-cp311-cp311-win_amd64.whl (24.5 MB view details)

Uploaded CPython 3.11Windows x86-64

trueform-0.9.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (68.9 MB view details)

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

trueform-0.9.6-cp311-cp311-macosx_11_0_arm64.whl (42.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for trueform-0.9.6.tar.gz
Algorithm Hash digest
SHA256 f2b221f7adf2ce62300c85dbf24da10c4e8550c115210813e08965dabf0f2cc1
MD5 3c169c147a50980f47592be224640143
BLAKE2b-256 74f6fe69b8803638676309513e62edd27adcba3e19bec357534de7a11175976a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.6-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 24.5 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.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 44c1d09ca30997716dfcef40bea80920273e11e8999eedd737376054be431318
MD5 022c9104d3fe9629af90e1c5d4eef112
BLAKE2b-256 779d1e8c89d0ec4893e1a4acb9c3969265daedad6cfc6160349325393a9a0aee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8af5f858bd9b4bf5e319e03118a4f8367545626b38498b2de27cbe0287591085
MD5 ebc7732dfcb59677a0e1dc96837a8f28
BLAKE2b-256 bf9e975d01c52ea633be080e866907f115bf148b35804d7694f9dc76dd4abaae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 07e4956bff2c32c992534e7fa974d9cd4db2f61fd3a902cce8c0ac81d404cf4e
MD5 e6b3c55e6e61c9f73452fb13062ca0b6
BLAKE2b-256 0292ed9a719b6a6b33f31dc903adfa128faf3c93045a2adc837030b3c064f196

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.6-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 24.5 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.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8bf72d96aed024229b64abf9c475239163dce4e7be9604eb7e4a51e6e6e3c1a1
MD5 6459ec37ea691d0153dbcbf7dd184d8e
BLAKE2b-256 1de2bc1f1f3b0ad1d7ec2289b041c24dce8e68b77420024c43519aa5f62873bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 65f378d2f14470bc80a7bf54b7205c216b0d087c75d22eaeec10c27bc0bb2a9f
MD5 cd79a8977fb8ba7b62575464397f636b
BLAKE2b-256 92ac08c16578440b129e463ab877c21afb7aad6dc38332b7bf29ade47edb2ad4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3a1a785eaa13b6af82f3b6b4ab7b5a59e35503215fe5458ccabef69c9e730a8b
MD5 f5ebd43561b08edbeb2f7804ade2fff3
BLAKE2b-256 1caf2a32505de978d3ce2bba420315ddab773f4269df200aaf59af2190bf1202

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.6-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 24.5 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.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a26be19360a62c73e90f7202984c17fffa44d718e4012132d4f4fce1cc1be711
MD5 3934c86458e346c0e4866540f42e8856
BLAKE2b-256 24491c2bf12bb22d15a8f75cf4666f3737d8ea5159d674a2c5de3cc726399cca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9f3bc1e6a11e750ecbefc81efc06d651e74300c48648a8086ea468c2db1562b4
MD5 f1089b80132af6ceeefdc34e8e29b226
BLAKE2b-256 edb918970bf6ec1860dbb36592e59edc873139c45b50af8829259cd1bb8a0691

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b8c4cd3bdc3b3539a12a06839a7dcb8920b9b8b402cd95c19fcf7e32bf874936
MD5 8037f266541f1917b3408193162609ee
BLAKE2b-256 99a03bfd2183baa0b249808b0fbc2ab1bfb80cfad1818f5eb00385ab4d6578bf

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 Pingdom Monitoring Sentry Error logging StatusPage Status page