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.8.tar.gz (1.0 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.8-cp313-cp313-win_amd64.whl (25.4 MB view details)

Uploaded CPython 3.13Windows x86-64

trueform-0.9.8-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.8-cp313-cp313-macosx_11_0_arm64.whl (42.2 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

trueform-0.9.8-cp312-cp312-win_amd64.whl (25.4 MB view details)

Uploaded CPython 3.12Windows x86-64

trueform-0.9.8-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.8-cp312-cp312-macosx_11_0_arm64.whl (42.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

trueform-0.9.8-cp311-cp311-win_amd64.whl (25.4 MB view details)

Uploaded CPython 3.11Windows x86-64

trueform-0.9.8-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.8-cp311-cp311-macosx_11_0_arm64.whl (40.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for trueform-0.9.8.tar.gz
Algorithm Hash digest
SHA256 6439cbd7ed169a58e79b44c585f61a047c03d4cba98c78efc3f38cca03e730be
MD5 1123f7a05a739af9f8dc917655c0b714
BLAKE2b-256 b9bf3d970f61f24c87c3ee9b09de5f04e620424432c8dc9031850e600a904d21

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.8-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 25.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.8-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 863cd55fb945497e53a77589feab37f4ec8bb267ec80221c12c229062fe38f8b
MD5 ce11d62a59a900cae5df55f6c06806d9
BLAKE2b-256 d3b433626686986e3b70e95f50881b04ac35901cfdccbdf8117a3ca3f5310587

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.8-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e46aaed77edebf9fc479067c01ea46253749803ac8c8ef51ac4743cf6b43bd04
MD5 0682b041553c731a4e58733799b8e125
BLAKE2b-256 fb245840aedefdf9ca5d47e50d3ebe653cb32621b187e2526676508cde9ed647

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.8-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6f58804c835d1a3d7022bcee382e127b2f31a3e32f70906c209c5ed70520c086
MD5 9bce685f0cb506e2c2f441e0aa4b6274
BLAKE2b-256 8a367a28f704811ac41889deaa02313b3836c839f0edba7a14eb78bd8591acaa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.8-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 25.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.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 25f9ac41ad415eb3f95a897198a6e3c10b136939bad18fe37022451c7dacf419
MD5 2d7f84448ca5d3b33b9f1f188614eb11
BLAKE2b-256 b39a02d93780f158c0aa1d5db4ff771b5f2ff92b6d95adae334d0d08ee3b6c9b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.8-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 62ae99812a8ed17b53959ecce595bcd5bab5c1965d494a09cb1be7e7acd176bd
MD5 9b03430f0ab850a1efda95bea23f8d48
BLAKE2b-256 43461787dc7e2737064f080f179f6839925153c981782ecd4f3dc866c2dbae22

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 53dccd13c1acd65831eb1deb2aa311b47935e158af2a251b22f0f5af8b3dabef
MD5 d64b8aa8ed08b412b3c25339c26e9409
BLAKE2b-256 6538bb01ab581cd8ac6494fb29d117d1fafb6db53e75f92c046fe9379bc7d990

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.8-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 25.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.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c98fad094af81db44764d7a009704702f5010a0e01b6f3b553b72a9357f1b5f7
MD5 18e66cba1ac03ec99040ec86a50813e6
BLAKE2b-256 3fb330f0ace000f58505593ad29d91251313236486f65499beb21d30184b9a1a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.8-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a4b9cc2886b64dbdbfc464fccf628e3935399b95215b1476c34b1f52bbf9548f
MD5 0cdc0b656066a80bf27598c63ac2e2e6
BLAKE2b-256 ed8febd7800c4b306031a1fa2126482a75c7b19557a19d1d56968f243d957a32

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c73a464184ac6d53789430d198e9631ebae93c46985c15b07468a5d38b3a463c
MD5 1877ed20d63e510254f91439a1a04c2b
BLAKE2b-256 745ea8357c2c0ea63c098a19947f301370510466a9edf3649ce956ddab8d814d

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