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.5.tar.gz (929.1 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.5-cp313-cp313-win_amd64.whl (24.4 MB view details)

Uploaded CPython 3.13Windows x86-64

trueform-0.9.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (68.3 MB view details)

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

trueform-0.9.5-cp313-cp313-macosx_11_0_arm64.whl (42.2 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

trueform-0.9.5-cp312-cp312-win_amd64.whl (24.4 MB view details)

Uploaded CPython 3.12Windows x86-64

trueform-0.9.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (68.3 MB view details)

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

trueform-0.9.5-cp312-cp312-macosx_11_0_arm64.whl (42.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

trueform-0.9.5-cp311-cp311-win_amd64.whl (24.4 MB view details)

Uploaded CPython 3.11Windows x86-64

trueform-0.9.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (68.3 MB view details)

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

trueform-0.9.5-cp311-cp311-macosx_11_0_arm64.whl (42.2 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: trueform-0.9.5.tar.gz
  • Upload date:
  • Size: 929.1 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.5.tar.gz
Algorithm Hash digest
SHA256 7d312ff000a2583887987302c697c002eb2836f7ec1e103efa29fd33f5c34d81
MD5 481d5a812cbf5c658c0690495ff7bb91
BLAKE2b-256 ef5a64c876a7f2bf4f8f1e80439d3473fe3650f5ad9f3fd160631ee14cc33b5a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.5-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 24.4 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.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 0b3dfcb9e849123def2a1640c556f8a171a83ee957346d2062160772d339353e
MD5 017caf556489145044bfc3b3338f31b7
BLAKE2b-256 ce113c988eefb542bc86b89ec361c35ef8ecd84750066abf444cdc2b6ed94f8f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b56932acd26949000a595b8f5fedfd0fdcc89a3e47209e834d2327eab131fbd7
MD5 471160917df08910aac9b40319d41fc1
BLAKE2b-256 48c55acfe252e75b779323ab18ab86c6854bdacccb9d1c9d7af2fc6b563d4c2d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8afeef4efb94c9d45d6755d9cf43045b9ffb0f86d2a419e92c6c09f711063d08
MD5 f4d2865ebfc75cf16166d4ffe9aa925e
BLAKE2b-256 c39f74971afc9978645af2321dc7727fc4cecd5847396a73c3ae1ac3b8863591

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.5-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 24.4 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.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 17dc2515f2a5d273eb75a8f9a4e6927769e2736c412a2ac87d7939b73ea75f57
MD5 c8ed4751fbae90f9ab92d152a3556f69
BLAKE2b-256 37e50394a862607efd34b15f6430c9986dc039308600f2022c466e63447561d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c86ae582a6d8ec5b3073058208e5d0bd83eaf626028105b5112546d825e01703
MD5 c02f25f13c842b0ba340cb96eb979eee
BLAKE2b-256 081d049cda6f0860552a6c66c350542cadf4685bb2758127a26dc5a26b735cb1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f881997992f86dd75e69eea719cf7c535383462629b28a1c619a1d7656ac85fc
MD5 495dea9df14127bcf1ca6986eaaac28f
BLAKE2b-256 7c183c822cedbb308994872bd6f440f5af099b7e9538fc060e8c7f2ea0a6b561

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.5-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 24.4 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.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 dd91d2c24a773b5c65dc5f106a81571bb2ebd0c0d002b64e3a9c8f4b697ffc4d
MD5 e294eed39e77d3eee128ae9119322fe4
BLAKE2b-256 0ecdc3e81013ea45d45498f9fad47aeed81257f7b7c8a4d8b3ab775bea2521d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c46aa96bd1a3d67c78c6c51353cede57b54502bfd8c0d124f6bd90b039107ace
MD5 2d0eb243607be92d9d0380bb97247774
BLAKE2b-256 f2cafc54456bddf7a470a506a472eb3a4b622c4eb48a26d42c9b76f637d32110

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 52a77c7b9da7dcd1204074adea34d2f0058457e7041badf19dc6cf7b6347241a
MD5 1d8ab681b6e6f001fca98992936e9b88
BLAKE2b-256 6242ad4eedd7375ae752c24496d38aa32cde7887a66e2f682ae7dc8769b1ae30

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