Metadata-Version: 2.2
Name: trueform
Version: 0.4.0
Summary: Real-time geometric processing on NumPy arrays. Easy to use, robust on real-world data.
Keywords: mesh,geometry,computational-geometry,mesh-processing,mesh-boolean,collision-detection,point-cloud,csg,numpy
Author: XLAB
Author-Email: Ziga Sajovic <info@polydera.com>
License: # PolyForm Noncommercial License 1.0.0
         
         <https://polyformproject.org/licenses/noncommercial/1.0.0>
         
         ## Acceptance
         
         In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
         
         ## Copyright License
         
         The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose.  However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
         
         ## Distribution License
         
         The licensor grants you an additional copyright license to distribute copies of the software.  Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
         
         ## Notices
         
         You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software.  For example:
         
         > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
         
         ## Changes and New Works License
         
         The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
         
         ## Patent License
         
         The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
         
         ## Noncommercial Purposes
         
         Any noncommercial purpose is a permitted purpose.
         
         ## Personal Uses
         
         Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
         
         ## Noncommercial Organizations
         
         Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
         
         ## Fair Use
         
         You may have "fair use" rights for the software under the law. These terms do not limit them.
         
         ## No Other Rights
         
         These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else.  These terms do not imply any other licenses.
         
         ## Patent Defense
         
         If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
         
         ## Violations
         
         The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice.  Otherwise, all your licenses end immediately.
         
         ## No Liability
         
         ***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
         
         ## Definitions
         
         The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
         
         **You** refers to the individual or entity agreeing to these terms.
         
         **Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization.  **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise.  Control can be direct or indirect.
         
         **Your licenses** are all the licenses granted to you for the software under these terms.
         
         **Use** means anything you do with the software requiring one of your licenses.
         
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: Other/Proprietary License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Scientific/Engineering :: Visualization
Project-URL: Homepage, https://trueform.polydera.com
Project-URL: Documentation, https://trueform.polydera.com
Project-URL: Repository, https://github.com/polydera/trueform
Project-URL: Issues, https://github.com/polydera/trueform/issues
Requires-Python: >=3.9
Requires-Dist: numpy>=1.23
Description-Content-Type: text/markdown

# trueform

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

Spatial queries, mesh booleans, isocontours, topology — at interactive speed on million-polygon meshes. Robust to non-manifold flaps, inconsistent winding, and pipeline artifacts. NumPy in, NumPy out.

**[Documentation](https://trueform.polydera.com/py/getting-started)** | **[Live Examples](https://trueform.polydera.com/live-examples/boolean)**

## Installation

```bash
pip install trueform
```

## Quick Tour

```python
import numpy as np
import trueform as tf

# NumPy arrays in
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.read_stl("model.stl")
```

**Boolean operations:**

```python
(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
)
```

**Spatial queries:**

```python
static_mesh = tf.Mesh(faces0, points0)
dynamic_mesh = tf.Mesh(faces1, points1)
dynamic_mesh.transformation = rotation_matrix

does_intersect = tf.intersects(static_mesh, dynamic_mesh)
distance = tf.distance(static_mesh, dynamic_mesh)
(id0, id1), (dist2, pt0, pt1) = tf.neighbor_search(static_mesh, dynamic_mesh)
neighbors = tf.neighbor_search(dynamic_mesh, static_mesh.points[0], k=10)
for idx, dist2, pt in neighbors:
    pass
```

→ [Full documentation](https://trueform.polydera.com/py/modules) covers mesh analysis, topology, isocontours, curvature, and more.

## Examples

- **[Guided Examples](https://trueform.polydera.com/py/examples)** — Step-by-step walkthroughs for spatial queries, topology, and booleans
- **[VTK Integration](https://trueform.polydera.com/py/examples/vtk-integration)** — Interactive VTK applications

Run examples locally:

```bash
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](https://trueform.polydera.com/py/blender).

## 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>` |
| 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 | **3×** | nanoflann k-d tree |
| Mesh–Mesh Distance | 2 × 1M | 0.2 ms | **2×** | Coal (FCL) `OBBRSS` |
| Principal Curvatures | 1M | 25 ms | **55×** | libigl |

Apple M4 Max, 16 threads, Clang `-O3`. [Full methodology](https://trueform.polydera.com/py/benchmarks)

## License

Dual-licensed: [PolyForm Noncommercial 1.0.0](https://github.com/polydera/trueform/blob/main/LICENSE.noncommercial) for noncommercial use, [commercial licenses](mailto:info@polydera.com) available.

## Contributing

See [CONTRIBUTING.md](https://github.com/polydera/trueform/blob/main/CONTRIBUTING.md) and [open issues](https://github.com/polydera/trueform/issues).

## Citation

```bibtex
@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}
}
```
