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.13.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.13-cp313-cp313-win_amd64.whl (28.9 MB view details)

Uploaded CPython 3.13Windows x86-64

trueform-0.9.13-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (78.4 MB view details)

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

trueform-0.9.13-cp313-cp313-macosx_11_0_arm64.whl (47.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

trueform-0.9.13-cp312-cp312-win_amd64.whl (28.9 MB view details)

Uploaded CPython 3.12Windows x86-64

trueform-0.9.13-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (78.4 MB view details)

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

trueform-0.9.13-cp312-cp312-macosx_11_0_arm64.whl (47.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

trueform-0.9.13-cp311-cp311-win_amd64.whl (28.9 MB view details)

Uploaded CPython 3.11Windows x86-64

trueform-0.9.13-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (78.4 MB view details)

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

trueform-0.9.13-cp311-cp311-macosx_11_0_arm64.whl (47.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: trueform-0.9.13.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.13.tar.gz
Algorithm Hash digest
SHA256 115fa87fc3b4b4a50e96a54b30329a006e8f16f9b3a9d31ed36e1d341ed27434
MD5 9762a95ab9e3e1ffb4e744f434165ddb
BLAKE2b-256 69be18e33c1be1e7a4dab68023a71c441a0994097abc0653d6151f87132272fe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.13-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 28.9 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.13-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 3828e723e104e6bbea663cccf0d97f197396df782e48530cee994e6f65f5e8b0
MD5 f9f360aa02b01d9c27bc95c9df4f7d4e
BLAKE2b-256 35a699a7f19bcafbc31bf76407cd3d2073d70b4d9cccf895c38d16d59912665d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.13-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 41d513de7fbccc512b15739dcaaf627cfc61d3db3e4698bd1265b4c6a9215247
MD5 2234e490adbcb89fc5ee6dcafdc3c812
BLAKE2b-256 247ed941a9336cae09d0576a9a8553c20ec3e7645c9349c15b3b8b99fe6ef47c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.13-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ef84c66a53f18531b5ac298cf0b55f5854926f5e7d60d994a326544acd2994dd
MD5 9be565319b236cc135993f31d8882b87
BLAKE2b-256 d8bb6792b898f8c3405e5f84ec9c84e3e928688a338116ec8722e45a5233cad1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.13-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 28.9 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.13-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 24795482eae5e100f288e72c0c8a64260c91c4f268e05f8cb9381bf57315ad70
MD5 fae9bc3a6a78e489f696dba5051b79d4
BLAKE2b-256 b5224932f840dea553c7c5399fcd1aebb3f898f24dafe1317a941cb5c2122b38

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.13-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f9b754fe50c2ac77a77e5fab33980b74e4aad1c925a30d5555444d7596acf685
MD5 882064f45689eaf0dac04643a4c183eb
BLAKE2b-256 3819945df582eba860236e78197061c2ce77b117c43affea939946cc83bd55eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.13-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2631354c34e0bb787ee51f8ad20005fd13c6c102d137c8d4464972d55ae52dbf
MD5 e96af784ad65d4ce82d1b07cdfc229d5
BLAKE2b-256 c036e5cbfb8675e7b62b3844067c7cb8fe8de6cd9c56df54b6b47bccddd60023

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.9.13-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 28.9 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.13-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ab0403eeacfc4b0aef30dd18290e9102ad80d031cc6fd8c44d49c2e0979b5214
MD5 5720829bbe9bf279e0d3e8a90ac83037
BLAKE2b-256 f640379755a4f57db2608703ac6a37ff15b8d168c643859da37748b25a51ede5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.13-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0118b4299dbd254fc6722cd8c3e02b70f1cc841f1c6b22c7b3f22a8ad7b2ca91
MD5 79abc8e2a3ef3861617774ad7de81e4e
BLAKE2b-256 a9293e1c92c7d5d58bda82df3e8d9ed65a95b0b71c6cad034a79426641bbe285

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.9.13-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 707d098d25e4903eb9985a6361b0795073b6670c45c2c0d857b1d861bd7a2cdf
MD5 7ecb9427ddc17cf1b4d90cc40fcd257b
BLAKE2b-256 2d7651516e733aa03738a9159baf18b8047da31da92d58e5e5f991bdf2b6b9c1

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