Skip to main content

Real-time geometric processing on NumPy arrays. Easy to use, robust on real-world data.

Project description

trueform

Real-time geometric processing on NumPy arrays. Enriched NumPy arrays with support for vectorized spatial queries. Arrangements, booleans, registration, remeshing — at interactive speed on million-polygon meshes. Exact and robust to non-manifold flaps and pipeline artifacts. NumPy in, NumPy out.

Documentation | Live Examples

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: Real-time Geometric Processing},
    author={Sajovic, {\v{Z}}iga and {et al.}},
    organization={XLAB d.o.o.},
    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.8.7.tar.gz (857.5 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.8.7-cp313-cp313-win_amd64.whl (24.3 MB view details)

Uploaded CPython 3.13Windows x86-64

trueform-0.8.7-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (71.4 MB view details)

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

trueform-0.8.7-cp313-cp313-macosx_11_0_arm64.whl (43.7 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

trueform-0.8.7-cp312-cp312-win_amd64.whl (24.3 MB view details)

Uploaded CPython 3.12Windows x86-64

trueform-0.8.7-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (71.4 MB view details)

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

trueform-0.8.7-cp312-cp312-macosx_11_0_arm64.whl (43.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

trueform-0.8.7-cp311-cp311-win_amd64.whl (24.3 MB view details)

Uploaded CPython 3.11Windows x86-64

trueform-0.8.7-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (71.4 MB view details)

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

trueform-0.8.7-cp311-cp311-macosx_11_0_arm64.whl (43.7 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for trueform-0.8.7.tar.gz
Algorithm Hash digest
SHA256 ea24522743c933ccdf37de00230fe543a7e3cf4fe338d8b582a4a9eead3a82e3
MD5 353ea7bca8a491fa945d63965ce56c6a
BLAKE2b-256 b90449bbd6c276d104221c8253f2d039e00ef6c796dd1e33e14276bd9c2abcd1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.8.7-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 24.3 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.8.7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a4b0a7e7d000d00abc8ef9239689d8fce828f7129c95f90483ce42699375d6d2
MD5 de7a1974eec53ad470e33ca311099ff6
BLAKE2b-256 19718cdf75f3f28b1361f730d7668447b901549ec370689de09b903fb1e60e8e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.8.7-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fc5c6278075dff8d3657be18da5dac714ba0574145be31e3653536150e00d3c7
MD5 04194acf509a224215d6b8206facd872
BLAKE2b-256 5a36205e3edc04b508bbdda65e193162c380ded7213f8fcb83564233b7c2324b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.8.7-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 650bd647dc2a54cad95a74550011f7d0519db036c572fe5298e025a9825a29ee
MD5 b11845d9540926a0e9732d579499c395
BLAKE2b-256 ad40b9f534b784c8d5e72f8264dffdf6f61f566dfc20fd36052f58d692bf9b17

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.8.7-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 24.3 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.8.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e7632e2cfb86df4211d957f2800f54b853de2f403075bccbdb142a5dd6df1ed8
MD5 43b7d679bf0972a2d5b515062a6f1c37
BLAKE2b-256 78b42cc90354aa8f2a116d75da23329b7c8b04714443e5435eda816306441530

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.8.7-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c0bc581f104b43dbda7b575c4a3780c4ad40168c2d1e1b98af9280ce78a7de0b
MD5 320afc47278cdce4083f47a2d8732233
BLAKE2b-256 e8401a909c95b17f79a3d9776c84f7cf0ff8db7268c58f333309d1957a5d7908

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.8.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 01a9a8f83906c3b8afc9f79e853e273724f4f45346dd4f17e8864b73f8c3e5d2
MD5 531783fe9bd23fd0c2756e3c463a04ec
BLAKE2b-256 4ad3c10b05a67c0e18eebe2b810955122f26afc5a806ccdaec159d14481faa30

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.8.7-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 24.3 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.8.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 815748556efe9805f4846635391ecbd26a0a49435d7d84595cef5d562f667ff8
MD5 a2bf8c23e3aed84745e5c8b17e3331b3
BLAKE2b-256 2242daa3dc43cec12608d4656f0dcef81692c02f500d1d2646b216e3583ed43a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.8.7-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cfaafcaab74438e1100a07cd5a92e01a6deb39c9b3366750828d71ffc3a17f30
MD5 2247a78bb50d8dd564ac43b450209edc
BLAKE2b-256 a8be53ecf9e00bfc1c10a3c9e3728e8e88b5ed1dbfcdffd22d13c008501b8659

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.8.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e1900e8ac8f0ace13d63704b6acde814b464b7a768ebf4da953d3a32dc9dd818
MD5 d886f62ae9c16d107299dc2adab511c5
BLAKE2b-256 94e903b0ddf97f7b57770f4790189df3241cc84c4d4376852a47dda0da114b0c

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