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: Real-time Geometric Processing},
    author={Sajovic, {\v{Z}}iga and {et al.}},
    organization={XLAB d.o.o.},
    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.8.9.tar.gz (879.4 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.8.9-cp313-cp313-win_amd64.whl (23.6 MB view details)

Uploaded CPython 3.13Windows x86-64

trueform-0.8.9-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (68.1 MB view details)

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

trueform-0.8.9-cp313-cp313-macosx_11_0_arm64.whl (41.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

trueform-0.8.9-cp312-cp312-win_amd64.whl (23.6 MB view details)

Uploaded CPython 3.12Windows x86-64

trueform-0.8.9-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (68.1 MB view details)

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

trueform-0.8.9-cp312-cp312-macosx_11_0_arm64.whl (41.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

trueform-0.8.9-cp311-cp311-win_amd64.whl (23.6 MB view details)

Uploaded CPython 3.11Windows x86-64

trueform-0.8.9-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (68.1 MB view details)

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

trueform-0.8.9-cp311-cp311-macosx_11_0_arm64.whl (41.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for trueform-0.8.9.tar.gz
Algorithm Hash digest
SHA256 58460ddfcd3b2200986bf99e60f4a5082072768439b3669fb2384e98e51d43a0
MD5 94459da52040335adcc71fa35ae424af
BLAKE2b-256 a0e48762bb029a09316a31451e29fb187cb4afde9f4bced5551719ca3c837c77

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.8.9-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 23.6 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.8.9-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 1d14a328472aeb27935369c4e0f5fb17ed36efd5a6986294b7114ac56958e416
MD5 503973de559576a15b0054cc758b7c36
BLAKE2b-256 d4704c312c83dbe85ab3650e75dc2e7a64221f01d1a94df6ac4b94effe94833e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.8.9-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6a6fcce0834b2e3d0b75c092d34c7398970f61f222d24952995828787ceff53b
MD5 47e66a08f7121205f69898eb0f463a49
BLAKE2b-256 4070bc4ff6f95daddccaec8341222d8b86125376bb6cc2dc02e5b36bf8867b4d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.8.9-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 304d9045caf50a8925cfd7aaecd40e505fb82b9c7acbe6890aedbb2e996ea412
MD5 62ff892d97384ce87d0b2fb7da0f2ef6
BLAKE2b-256 8032697a46115b70256c5061a6c2f34dabc4829ec7080346569fd5312f51c6b1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.8.9-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 23.6 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.8.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 df462c03bfdc70dd36d4e772534fdb2a0d88856a2b2a19fbbf89b26394ec17d5
MD5 019330f2986a7f18ac853dfe7da08b96
BLAKE2b-256 3283ca7696a790198cca8786e45c72776837d6bfd97735f66037b4beef21822d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.8.9-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4e9a89cc215768119560c1202001556bef144113951c1f30f2ba39e21c9bd351
MD5 c8f8af1b5bfb437b44a35d2fb3886b3c
BLAKE2b-256 aa9418077a28462bc92c19b942c3d134d6b97b21e97603962aa9a22b70b13796

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.8.9-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b2b6008742a46f627395984eb7d94477c60ed57e44af9f3f7a2592a2eb30d0c6
MD5 bebe1a33d06e9d37590b10b5a2f28f11
BLAKE2b-256 e8bd95f34b75109229b995269af776b3437a7001854014b90e56a7c3cfbdcbc9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.8.9-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 23.6 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.8.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4e5002ceb4e463ec7f85406def239e2d9b0e4a837bdba226b2df2828218914ea
MD5 702a90b1c7c081c055bebf2368c2cb98
BLAKE2b-256 dc2b919630d525031b31e2bf2e352d6b011b626e62ce7b5d5bc23789dc1baff7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.8.9-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 44db64cddc14f3386eab18c752973f00eff73e1420f34f0a2ec5c8aa7893c45e
MD5 606a285d32f6a1584ef6f3658e61f6a5
BLAKE2b-256 c837afce82eb3527ed114bb0976efe901a9ead2c68568cc9d557ec43120668cc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.8.9-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c34e175c15d8b5c42e516eada07df52bf0472c392b79f1325f2d341d55a44643
MD5 80986c987415324006fcbecce6866fac
BLAKE2b-256 1757fccff636652d69c6306be26ac63d932ef5e8693e68e79c6bbbcb7a1e845b

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