Skip to main content

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

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.11.tar.gz (1.1 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.11-cp313-cp313-win_amd64.whl (27.0 MB view details)

Uploaded CPython 3.13Windows x86-64

trueform-0.9.11-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (71.7 MB view details)

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

trueform-0.9.11-cp313-cp313-macosx_11_0_arm64.whl (43.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

trueform-0.9.11-cp312-cp312-win_amd64.whl (27.0 MB view details)

Uploaded CPython 3.12Windows x86-64

trueform-0.9.11-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (71.7 MB view details)

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

trueform-0.9.11-cp312-cp312-macosx_11_0_arm64.whl (43.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

trueform-0.9.11-cp311-cp311-win_amd64.whl (27.0 MB view details)

Uploaded CPython 3.11Windows x86-64

trueform-0.9.11-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (71.7 MB view details)

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

trueform-0.9.11-cp311-cp311-macosx_11_0_arm64.whl (43.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: trueform-0.9.11.tar.gz
  • Upload date:
  • Size: 1.1 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.11.tar.gz
Algorithm Hash digest
SHA256 9417076b3d260fc7c25cba991a78904a7779bb157e02b71dbfa6851eaeb972c3
MD5 7e0b6e0d5471d5c2b551acf1b0eb3957
BLAKE2b-256 8748254cca0121ee94ecfc9510963a0e20ad2e4483459677a110736f423cda69

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.11-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 27.0 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.11-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 1155c2673a34b1be5edc988ec9fe5a841696f1d8cb333f51aca99e407d5fb450
MD5 8a9d6393d5f39d9c3d8a81ece0896970
BLAKE2b-256 6999c6a45bb4bea3a213b176de1903ca02b3a52eb0e2632e476c6c54d6633489

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.11-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8b13ce0fa060868af8a06cf039a9bcd3ecfa78e86a8e5f4eadf8e9911980cc3b
MD5 ee101932e55614f873e5a8234dc6bfca
BLAKE2b-256 8ef4bd05b4d943800e3663801cd7b5c71b542c9a682aefa96788a5f5391c9dc8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.11-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0d314f5f5db77ca1b3722e46d43aa127423682ca04d88344f8c9538c9c56c19a
MD5 0c89cb2a199fbf86ce0a0780dcdbafca
BLAKE2b-256 bef3545461f4aaba37377b5282c6e6e6d53736d68446f77579ac09eefc4430e1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.11-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 27.0 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.11-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 33d8ddf0345d1f1f4d075b15cb6a104e8e207d81be85a783da46906adb69837e
MD5 c513d3491b93265a9c885e0fc778fe48
BLAKE2b-256 889d5c36cf4b906e91d2485c7b82d06892bc8a94526c126fcc5ffc0ea1e54a57

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.11-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ea41a1f8af3af081b43c05dc86f1d5793b4b4650d9512e42b81962e105001f79
MD5 77389d33a2691e103007aac87040cdd4
BLAKE2b-256 e28124bb843f473fe8fedcc00de7caf25682748b28afa6c56bb573494c95b73d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.11-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 02377400feb0337dbc6bb517404c5b83ef634ad063eec528e27af6460b43d763
MD5 26ea3c156ac7cfc6be269f29ebd814fd
BLAKE2b-256 887a38d26fa4da78084f1b029dc6cd25ed4cd7ac4a840d5110a70006c500111e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.11-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 27.0 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.11-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7a1f518d5dc8a0963a540f8fb217e091d34eb07cecc326226f03db42d48be038
MD5 78ecf90a43bae3b2f4b9288c149bb7f3
BLAKE2b-256 d63878462580054241bdca044baad7a7db734e20f565244a714e29d00fe8b288

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.11-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0a95bc98361fd0238690abce43f86313139f0aeba4ff5f906c9130bf31d1a2a5
MD5 cec6f243903c2892119774572c6ec1d0
BLAKE2b-256 54039ef8879e22f66ba4ff6706c53db8ffe8e5d97f2c397e445460734c03eda3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.11-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 242f9764802335a931ec8ca07aaee359ec859eb5ae64ba982b9ca29dd8504e7f
MD5 8e14ccbd3338fca2c6e080c42adae562
BLAKE2b-256 5f92d3af25cd587c035fcf072f346a944bed2a7ccd3d04120461c932413b81d3

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