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.3.tar.gz (916.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.3-cp313-cp313-win_amd64.whl (24.3 MB view details)

Uploaded CPython 3.13Windows x86-64

trueform-0.9.3-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.9.3-cp313-cp313-macosx_11_0_arm64.whl (42.1 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

trueform-0.9.3-cp312-cp312-win_amd64.whl (24.3 MB view details)

Uploaded CPython 3.12Windows x86-64

trueform-0.9.3-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.9.3-cp312-cp312-macosx_11_0_arm64.whl (42.1 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

trueform-0.9.3-cp311-cp311-win_amd64.whl (24.3 MB view details)

Uploaded CPython 3.11Windows x86-64

trueform-0.9.3-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.9.3-cp311-cp311-macosx_11_0_arm64.whl (42.1 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: trueform-0.9.3.tar.gz
  • Upload date:
  • Size: 916.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.3.tar.gz
Algorithm Hash digest
SHA256 092fee1b91eef6bb09be7c5407e67bac182a3b2f75afe7fa9c1f1f47bf1f52e2
MD5 6e4de663b3dacdb175a9b486d0ad9fae
BLAKE2b-256 5c2b8e450345b875e8e0256bc7002dfbf973a5b61bb38e7ec117f3b57471c0b2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 24.3 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.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c281b2de34cb71cd91211d156b856f43c17ec1f4d5abae5bad4d8e4f5a400883
MD5 09e04d7370138c9ced3281f37dcce96c
BLAKE2b-256 5134e227cc87b8307f1abfb16fd38dc5ad3bedb75c87b34cd91a1e0241e8aeb4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bdd6da836774504fb538a027667c10ba970172e313bba11778e581c134f42bd6
MD5 c2d0a6282ea450f15c6144500a818795
BLAKE2b-256 80a9b5b6c1fdd0d33374cc814ef2dd7a2f577165fa55a0e3f924940b4cf03985

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 99b10f318e59d10b59ade5592aa0f43dbca1318016252c73975c0e3972eae317
MD5 39adfe13409851492d79afb318a11e8d
BLAKE2b-256 4e8a21b791c9492b7e667cac036645a51cb98bd925703ab2b35843ef78a792f0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 24.3 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.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 edf73bf819163bf73c279e7cceafd5adcf088bd477d1d717013d6205ef0259c2
MD5 6f06d6efcb733554474b9bb831a79480
BLAKE2b-256 869d6c0d5c81d3e730214e50078cd9d367e5b5828d81a6b3174aaf2ef77b2620

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6b788d0220efcf72deb0e082d9c230d344184ad9c7eae5997f2fa1b645f08e4e
MD5 3bc3c52503e46746e90d454d0fe9d21b
BLAKE2b-256 60c9f2ee607514fe5c39a0e1ffee1f12920029a67d15a76c09024280a2718d99

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 35010e3288037e7e0ec9d7a71d2beb86f71b6868d5581ba348d39b34e471565c
MD5 defd6893b456210cd7a1a258e215af8b
BLAKE2b-256 eba4d860311e2a4b821c17fb652cf3e937f8e500f9521ffbad69a0be147e3ce4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 24.3 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.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4d51feb174daa401310238156e5f1053ab09fe1f64d76d4cf786d9618b2d5d02
MD5 6245f515169d49a4bc4b6cd22d6fbba8
BLAKE2b-256 622e0d5e071c63fd981b950d1e716cafd1ada340c81a5f32306a3fc22e18936b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d70c40cbbbaf61c6fbc727c3c1f7f873d034bad9bc7f9340bd2f343f497487bc
MD5 742d4099c68ec4c6382155664f74ecbb
BLAKE2b-256 e6fb14530f28f7547500080cb1680dd5d47d8be327bcab36a509306ed1141f4d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b424982c6434db00bd51f48ff166249b6d32d9ee1b89f55fde830ba9f92e68ea
MD5 0db41818fc3220867e1c8928744226ca
BLAKE2b-256 fde1e132c5590ea6f67df67f4c81a992a629b315ffe44d0edce4b763022ada4f

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