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.17.tar.gz (1.2 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.17-cp313-cp313-win_amd64.whl (32.2 MB view details)

Uploaded CPython 3.13Windows x86-64

trueform-0.9.17-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (88.3 MB view details)

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

trueform-0.9.17-cp313-cp313-macosx_11_0_arm64.whl (53.5 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

trueform-0.9.17-cp312-cp312-win_amd64.whl (32.2 MB view details)

Uploaded CPython 3.12Windows x86-64

trueform-0.9.17-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (88.3 MB view details)

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

trueform-0.9.17-cp312-cp312-macosx_11_0_arm64.whl (53.5 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

trueform-0.9.17-cp311-cp311-win_amd64.whl (32.2 MB view details)

Uploaded CPython 3.11Windows x86-64

trueform-0.9.17-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (88.3 MB view details)

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

trueform-0.9.17-cp311-cp311-macosx_11_0_arm64.whl (53.5 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for trueform-0.9.17.tar.gz
Algorithm Hash digest
SHA256 0a9f552f75a1503f6d328e00889006b56358909808d98b9aa097fab57d6a221f
MD5 98cbdc914ac57f90a24535c8bb72fe58
BLAKE2b-256 5c1c06589f63239bb8492fbd4afc1f5d56e9a6a2eda98f8cb6fa478aaeddbaa9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.17-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 32.2 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for trueform-0.9.17-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 398a7c0e42947069a8dde53a554da71b7bd23ddd5d814b3adbf355ed5700075b
MD5 b525c3c8b4b6e663d222d7f60a8b5586
BLAKE2b-256 5b85731fe88298a2abc43e9c02d08d9e9fd72607ed090fbb19f73925c523a5c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.17-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d175866152761f94a9b2934bab6d4b27f8737a31b296fd878ebc7bd5d6123b2a
MD5 3c0dd604134348ec636b7e526ec9dc64
BLAKE2b-256 2e1a458b1d414975ae34ab909475605df5606227b0d882d1452ebefbeb358790

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.17-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c808bee67f1aead0715504671b71dd2c30230612ed2f6820cd4630b40c572567
MD5 1a90fa37a881a64d8b4e0ab5a60b0dc3
BLAKE2b-256 0a635a2ac4e65dc412d0d03638d83ef602084971bed2940b584ad2875dd13287

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.17-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 32.2 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for trueform-0.9.17-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 88634a0d770ea1280dca669870ef8ebc537c2ee2f1f81a7a6d4422162749043b
MD5 862488c4e68b4d48f258e9c1e7bcc17e
BLAKE2b-256 725df0709e0e7da72f5154874d5a187c830fd4072f719b50a6bc481fd6b9f0fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.17-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3815335a5064995cf1ce677336c2c7791236819e4220b7b6eb8c419960817574
MD5 091015fbee5f5a34cfec1773a755dd42
BLAKE2b-256 67d71aad592dc904839efbab171df165731f4618a1665a646160e1d00270e6e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.17-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2c5f981add87b4e0034bce800c182d3520c90af1c31434c4c4168ceb8a5deb8f
MD5 bb673156ea7b3d398d979b461386fb04
BLAKE2b-256 8e3cb9d5c91f1648ef9c6ef5b92374c94835242fba349a759bad32f950bc662e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.17-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 32.2 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for trueform-0.9.17-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ab1da06c6bda335f6ea680f9376d2b982e805287e72a212ba6067057c57ba494
MD5 9ea6592caa6521f895817277ab74fcc5
BLAKE2b-256 522916f270ee69ebcd679c311e1d8ea5518cd3897b5c794c12e7158698f0190c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.17-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1d7646e02dc4ae01aac4eadabdfd42da8e3341dd0d2b70c5c93c98327021266e
MD5 da85a64b30de2374cd32f36f379f3b99
BLAKE2b-256 0f174d7a91ed47df4c4667779a4c287879555d462bc86bb4563b2bf117cb1096

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.17-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f2741bee87cd2b0141371bc8d244abe3493f9307846121290591747220529621
MD5 1f95a3806196219401ed2ff456512254
BLAKE2b-256 7c33a2288b76a3d379fbb32cc7461164dd2778c763dcc3f6ef6fbeda2b8e7ab2

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