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. Mesh booleans, registration, remeshing — at interactive speed on million-polygon meshes. Robust to non-manifold flaps, inconsistent winding, 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 = tf.boolean_union(mesh0, mesh1)

# With intersection curves
(result_faces, result_points), 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
Boolean Union 2 × 1M 28 ms 84× CGAL Simple_cartesian<double>
Mesh–Mesh Curves 2 × 1M 7 ms 233× CGAL Simple_cartesian<double>
ICP Registration 1M 7.7 ms 93× libigl
Self-Intersection 1M 78 ms 37× libigl EPECK (GMP/MPFR)
Isocontours 1M, 16 cuts 3.8 ms 38× VTK vtkContourFilter
Connected Components 1M 15 ms 10× CGAL
Boundary Paths 1M 12 ms 11× CGAL
k-NN Query 500K 1.7 µs nanoflann k-d tree
Mesh–Mesh Distance 2 × 1M 0.2 ms Coal (FCL) OBBRSS
Decimation (50%) 1M 72 ms 50× CGAL edge_collapse
Principal Curvatures 1M 25 ms 55× libigl

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.7.0.tar.gz (747.2 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.7.0-cp313-cp313-win_amd64.whl (28.6 MB view details)

Uploaded CPython 3.13Windows x86-64

trueform-0.7.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (33.3 MB view details)

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

trueform-0.7.0-cp313-cp313-macosx_11_0_arm64.whl (21.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

trueform-0.7.0-cp312-cp312-win_amd64.whl (28.6 MB view details)

Uploaded CPython 3.12Windows x86-64

trueform-0.7.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (33.3 MB view details)

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

trueform-0.7.0-cp312-cp312-macosx_11_0_arm64.whl (21.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

trueform-0.7.0-cp311-cp311-win_amd64.whl (28.6 MB view details)

Uploaded CPython 3.11Windows x86-64

trueform-0.7.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (33.3 MB view details)

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

trueform-0.7.0-cp311-cp311-macosx_11_0_arm64.whl (21.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for trueform-0.7.0.tar.gz
Algorithm Hash digest
SHA256 8fe8a98168bfb16d6604cc2c88624c7630245294e4257ddca31af267ce50e197
MD5 d98e937f5a24f1d886d7e27f5a9a83fd
BLAKE2b-256 6f21d2a8042918bf4d5c2cceb7f6a13d61210e58faa17bbcd5d00417e27f234b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for trueform-0.7.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 11f1ab6c2dfc5cf73cc54a58036cf536d0786a7162fea042f8dc6bffdc57f940
MD5 64336f7735504b32143aadfd83ae31c8
BLAKE2b-256 df5f57b812a2efce1fd69c33bbd68074beaeab358599c1d721b2295f41d38f92

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.7.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 19b4573d8606e4030f74b455960f1c591842624d02a5cd88b4272b27023c4241
MD5 dedcff69a8ec4761d7e306cbb71dca04
BLAKE2b-256 ad0afe295564a4d288c7b1826dc68fbb1fdab71d38653dfdd94a37a7b472a17f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.7.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 77474b71229c4bcc9703e2e573a0411bd7f0ccffdd645a30972d7584171e1059
MD5 1eacc6372fad60821b1cc13425b0b8b9
BLAKE2b-256 eea184d256429683898421c444131cc0adbac530637ead74fb0670fd7d9b883c

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for trueform-0.7.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a1c88525a2d0e916af5a10f7d400a04335d03f5ed202e7572df435eba82f5781
MD5 8712d87854014a3f0b7fe4195a654eb0
BLAKE2b-256 b3ef1ffd5f377f6f54fee0de8cb7d39285b9d255b790500db9cdbf75a18336c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.7.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bc15f1fb17372208d604a72d6236e328f8b19b8508e1d82731158faf6ea9bcf5
MD5 1e3946d9247d4a2e16c87ee97ab3c68c
BLAKE2b-256 cdbf5405ae5836eded196250feffd4eda7b83415c76091112fba7940ef361cd4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.7.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 18eafbfdc2ad341e26560f078695266130925d9d5a15e77a9a58a49845037b3c
MD5 0e0ecb453b0e444d9b4ce842609185ce
BLAKE2b-256 9239865217f355642955fdb1741cb13f3ca77f8badbff64a9f291614c1194104

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for trueform-0.7.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a6314208024051b4a978817b79162539dd82689d7fecdcd920f63e94ed559155
MD5 5f2dba398a7c61508781687618ea41cb
BLAKE2b-256 8a58578c8450876c8d78d480f617cde42385a6be6ff661c0b0a20e81479e9584

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.7.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7cbaf480a6cfbf6d168858f6fbf6f38ca1ba96c3f68d4e7b6cb8682652715a02
MD5 78ccf8e728f647fe22e090df6080ac5e
BLAKE2b-256 f2da593700b8881933c4f548fa3e31c7bb0698b003a21107f8fefc41406a67ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.7.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1ad519be82e303e10ccb6417161cad6d555a07f5713166665c689f6f443ac810
MD5 2cae20b175f7721175a05b866064001b
BLAKE2b-256 3943203b313561ff5d20dd29080a853fb222e70e69e2135da3fe5151c6394081

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