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 84× CGAL Simple_cartesian<double> exact predicates, canonical topology
Mesh–Mesh Curves 2 × 1M 7 ms 233× CGAL Simple_cartesian<double> 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.1.tar.gz (854.4 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.1-cp313-cp313-win_amd64.whl (24.2 MB view details)

Uploaded CPython 3.13Windows x86-64

trueform-0.8.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (71.2 MB view details)

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

trueform-0.8.1-cp313-cp313-macosx_11_0_arm64.whl (43.5 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

trueform-0.8.1-cp312-cp312-win_amd64.whl (24.2 MB view details)

Uploaded CPython 3.12Windows x86-64

trueform-0.8.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (71.2 MB view details)

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

trueform-0.8.1-cp312-cp312-macosx_11_0_arm64.whl (43.5 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

trueform-0.8.1-cp311-cp311-win_amd64.whl (24.2 MB view details)

Uploaded CPython 3.11Windows x86-64

trueform-0.8.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (71.2 MB view details)

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

trueform-0.8.1-cp311-cp311-macosx_11_0_arm64.whl (43.5 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: trueform-0.8.1.tar.gz
  • Upload date:
  • Size: 854.4 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.1.tar.gz
Algorithm Hash digest
SHA256 87b46c9cffd7ce0334ec1c979a99199bcd90b039ca58170bdf0cf7a6b37cae23
MD5 05517bd1d7777c8f1da0bb9a29b3fcde
BLAKE2b-256 fac76301316630980be57abd50b2c4a48894fbf98a0bb16351c199deb1b96e48

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.8.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 24.2 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.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 40b6eff9bfd33fa667772b9e5a41daa9bce9e8f14941cedd85f1d877f7c7f82d
MD5 93f39dabe51b91eb7823b386c0114eeb
BLAKE2b-256 0a24abdd4dcb3a1202bd0ed913f3f43659c4c986c661c8f7b9975f74d30b8f02

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.8.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b5f8f5ec3c772820899eeb5c68c89cc9dd6ceffe7cffdcc2aeaa29b4bd80accb
MD5 558c84983260b3236539266908d7c0ad
BLAKE2b-256 47dc11032accadf7f574bd9742e8f27c57101345ec2a221cb976a35b3da41dfd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.8.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 25445f5927acf4d5df856cb1a76a5d221900ae6b4c71a8d93c7bfa3db86fea10
MD5 23bfda2ea5f92728ec90d7ad3d8653c5
BLAKE2b-256 754fd8d2f3e0cbe225e7708669d7da91de0004e315db15fc865ea440e96f4427

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.8.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 24.2 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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 86d53e6c1bbdea2b60a07518c5c8ead6f6faf8d75794e006ad22cd1dbc6b4fdd
MD5 06e4ed277d9ca852276841946c7d7f28
BLAKE2b-256 e099c5f35c741b6746ba3dca82f6286388f5ede03432d230ffd8d622df3c7356

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.8.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6ba645e2be68ba3df7e1cf272155df1f1162fa7a23fab8af14c505008db147ef
MD5 0e5daca2e7857f4f55f6bfc21a678f32
BLAKE2b-256 0f9bdff6136bbe876220c395640556859fe50b7fa00565629bb2402e99468d74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.8.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6c633dc46c573bec32da392b387ce81d31045502e3971122ba3b76055c91889a
MD5 b983f1a30400a9a38e7376b29afad9b8
BLAKE2b-256 0ec452683afd0477b3b806f44352d1d31c5f96435414fd906b7c02b5ae91eaaa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trueform-0.8.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 24.2 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.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 77b014446f50419d2fb928c229ed4a0a1b8965afcc73c89c5e2894dd9de9835e
MD5 d0e258ba3f0fdc7ec25f8a616e521508
BLAKE2b-256 c752c5cbc87aefd9841be388e9148cd80dfef4bdc21cf8c65eb49fbb7e8a0429

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.8.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e23a45f38a50c3a410798b4e6edacb94e2f53737b9891bcf345f5ee18f5c2363
MD5 06ae26b91d0165d15ab4ac68390a66bc
BLAKE2b-256 34094d99f0179129b0f295423a9a1d3b27af27b553ee66c7888920b875bcd85d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trueform-0.8.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 55e1222e3c5ed15f52a8502a1f93cb9a38e65e7b1af4471d781211615682f811
MD5 f3134e6ec044b2bbee911700e42958b2
BLAKE2b-256 70c5f121b1b029bba448f273cd755bdd4a26e9da267db5ad2949d7706931366f

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