COMPAS Forge: A high-performance Rust extension for geometry validation, mesh repair, and assembly clearance

Hi everyone,

I’d like to share an open-source project I’ve been developing for the COMPAS ecosystem: COMPAS Forge.

While working on computational design, digital fabrication, and robotic assembly workflows, I frequently encountered geometry issues—such as non-manifold boundaries, duplicate vertices, inconsistent face orientations, and assembly clearance problems—that could propagate downstream into robotic planning, fabrication pipelines, or simulation tools.

To simplify these verification steps and make them easier to integrate into Python workflows, I started developing COMPAS Forge: a Rust-backed geometry verification and fabrication preflight library with a Python interface.

The goal is not to replace existing COMPAS functionality, but rather to complement the ecosystem with native-performance tools for geometry validation, repair, and manufacturing-oriented preflight checks.

Current Features

  • High-performance Rust backend exposed to Python using PyO3 and Maturin

  • Geometry and topology validation

  • Detection of non-manifold and boundary edges

  • Duplicate vertex detection

  • Automatic mesh repair (vertex welding and face orientation correction)

  • Assembly collision and clearance checking

  • Interactive HTML reports with an embedded Three.js viewer

  • Python API for integration into COMPAS, Rhino, Grasshopper, and Blender workflows

  • Command-line interface for batch processing

Technology Stack

The project currently uses several Rust libraries, including:

  • simd-json for efficient JSON parsing

  • Rayon for parallel topology analysis

  • rstar for broad-phase spatial indexing

  • parry3d-f64 for exact geometric distance and intersection queries

  • Three.js for interactive HTML visualization

The computationally intensive algorithms run natively in Rust while remaining accessible through a straightforward Python API.

Installation

pip install compas-forge

Project Links

The GitHub repository includes installation instructions, Python API examples, CLI usage, implementation details, and documentation.

I’d really appreciate any feedback or suggestions from the community.

Thank you for reading.

— Mohammad Amin Moradi

1 Like

Wow!!! This is so cool! I will look into it in more detail soon, but what I saw so far looks great!

We will organize a COMPAS Dev Exchange meetup in October (tentatively 15th, but it’s not yet defined), and if you’re interested, it would be great if you can present COMPAS Forge

Let me know what you think!

Cheers!

Gonzalo

1 Like

Hi Gonzalo,

Thank you very much for your kind words and the invitation!

I’d be delighted to present COMPAS Forge at the COMPAS Dev Exchange. It would be a great opportunity to introduce the project, demonstrate its current capabilities, and receive valuable feedback from the community.

Please let me know once the date and format are confirmed, and I’ll be happy to prepare a short presentation and live demonstration.

COMPAS Forge is still in its early stages (v0.1.0), so I’m especially interested in feedback, suggestions, and discussions about possible integrations with the broader COMPAS ecosystem. I’m looking forward to learning from the community and improving the project accordingly.

Thanks again, and I’m looking forward to hearing more about the event.

Cheers,

Mohammad Amin

Hi everyone,

I’m excited to share a major update! We have just released **v0.1.1** of COMPAS Forge, focusing heavily on **zero-copy in-memory shared execution** and **deep, native integration with the core COMPAS plugin system**.

After diving deeper into the COMPAS architecture, the goal was to make this library a “transparent accelerator”—seamlessly speeding up core operations without requiring users to rewrite their existing scripts.

Here is a quick overview of what is new in the **v0.1.1** release:

1. Transparent COMPAS Core Acceleration

COMPAS Forge is now registered as a first-class plugin provider for COMPAS core classes via native entry points and `_all_plugins_` metadata. Once installed, native queries on `Mesh` objects are transparently routed to our Rust engine under the hood:

```python
from compas.datastructures import Mesh
mesh = Mesh.from_json(“complex_model.json”)

Executed natively in parallel Rust in microseconds, completely behind the scenes!

manifold_status = mesh.is_manifold()
closed_status = mesh.is_closed()
```

2. Rotational Continuous Collision Detection (CCD)

To support robotic simulation involving simultaneous translations and rotations (helical toolpaths), we implemented a **Piecewise Temporal Sub-stepping Solver** in Rust utilizing `parry3d-f64` and `glam` math types. It interpolates poses using SLERP/LERP across tight intervals, solving the exact Time of Impact (TOI) down to 6 decimal places in microseconds.

3. Parallel Masonry Assembly Contact Solver

Designed for discrete block structures (such as voussoir arches), this solver combines an R-Tree broad-phase filter with a parallelized, robust 2D **Sutherland-Hodgman Polygon Clipper** in Rust. It extracts exact contact polygons, areas, centroids, and normals across adjacent blocks in milliseconds.

4. Universal COMPAS 1.x / 2.x JSON Parser

We embedded a dual-format JSON deserializer in Rust to resolve both nested array formats (1.x) and string-keyed map structures (2.x), preventing potential API breaks across versions and enabling smooth interactive WebGL rerders on our diagnostic dashboard.


Empirical Scaling Performance Benchmark

We set up a scaling benchmark querying `.is_closed()` on dense parametric geodesic dome structures of increasing complexity. Here are the execution times of **Pure Python (COMPAS default)** compared against **COMPAS Forge (Rust buffers FFI)**:

Mesh Facets (Count) Pure Python (ms) Rust Forge FFI (ms) Speedup Factor
**400** 0.476 ms 0.031 ms **15.35x**
**1,600** 1.975 ms 0.070 ms **28.41x**
**3,600** 4.169 ms 0.129 ms **32.29x**
**6,400** 7.576 ms 0.215 ms **35.27x**
**10,000** 11.240 ms 0.362 ms **31.06x**
**22,500** 27.878 ms 0.737 ms **37.85x**
**40,000** 49.254 ms 1.173 ms **41.99x**

At **40,000 facets**, pure-Python COMPAS takes **~49 ms** to resolve watertightness, dropping the viewport frame rate below the interactive threshold (~20 FPS). COMPAS Forge processes the same geometry in **1.17 ms (~850 Hz)**, enabling real-time, lag-free manipulation inside CAD viewports (Rhino 8 / Grasshopper).


Trying It Out

We have added a clean `/examples` directory to the repository so you can easily test these features:
* `example_zero_copy_healing.py` (In-memory mesh repair & rebirth)
* `example_continuous_collision.py` (Rotational CCD)
* `example_assembly_contacts.py` (Masonry contact solver)

You can upgrade and run them using:
```bash
pip install compas-forge --upgrade
python examples/example_zero_copy_healing.py
```

I would love to get your feedback on these updates.

Thank you,

1 Like

Amazing! I will give them a try soon! I’m especially interested in integrating the Rotational CCD in compas fab 2

Cheers!

1 Like