Skip to main content

High-performance pre-flight validation and geometry QA engine for COMPAS framework

Project description

COMPAS Forge 🛠️

[!NOTE] An Open-Source, High-Performance Rust-Backed Geometry Verification, Robotic Swept-Collision & Preflight Assembly Clearance Engine for the COMPAS Framework

COMPAS Forge Showcase

COMPAS Forge is an open-source, high-performance geometry verification and digital fabrication preflight suite developed to bridge the gap between computational design environments (such as Rhino, Grasshopper, and Blender) and real-world physical manufacturing.

Bound to the COMPAS ecosystem, this library provides microsecond-precision topological and physical validation checks, optimizing CAD models before exporting them to robotic paths or CNC machinery.

This is an open-source, research-oriented library designed for academic collaboration. We invite researchers, roboticists, and computational designers to contribute, extend fabrication profiles, and integrate advanced geometric solvers.


Key SOTA Architectural Features

  • Zero-Copy Memory Shared FFI (Pillar 1): Directly transmutes flat contiguous C-compatible memory layouts (PyBuffer) between Python and parallel Rust threads without copy-pasting, eliminating $O(N)$ string serialization overhead.
  • Continuous Collision Detection (CCD) with Rotational Sub-Stepping (Pillar 2): Supports simultaneous translation and rotation (helical sweep toolpaths) using piecewise temporal sub-stepping, evaluating exact Time of Impact (TOI) down to 6 decimal places in microseconds.
  • Parallel Assembly Contact Solver (Pillar 3): Combines parallel R-Tree broad-phase spatial filters with a robust 2D Sutherland-Hodgman Polygon Clipper to extract exact contact areas, centroids, and normals across thousands of adjacent blocks in milliseconds.
  • Universal COMPAS 1.x / 2.x Schema Parser: Embedded dual-format JSON deserializer that natively resolves both nested arrays and string-keyed maps, solving version compatibility breaks seamlessly.
  • Transparent Plugin Acceleration (Pillar 4): Integrated with COMPAS core plugin auto-discovery. Standard queries like .is_manifold() and .is_closed() are transparently intercepted and solved by the Rust engine.

Scaling Performance Benchmark

We evaluated the performance of the transparent plugin acceleration by querying .is_closed() on dense parametric geodesic dome structures. COMPAS pure-Python execution times are compared against COMPAS Forge's Rust FFI memory shared engine:

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 lag-free real-time manipulation in CAD viewports (Rhino 8 / Grasshopper).

Performance Scaling

Installation

Standard Installation

Once released, COMPAS Forge can be installed from PyPI:

pip install compas-forge

Installation from Source

Requirements:

  • Rustc 1.96+
  • Python 3.9+
git clone https://github.com/moaminmo90/compas-forge.git
cd compas-forge
pip install -e .

Python API Usage Guide

1. Transparent COMPAS Core Acceleration

Simply install compas_forge. Native COMPAS queries are transparently routed to the Rust core under the hood:

from compas.datastructures import Mesh

mesh = Mesh.from_json("dense_model.json")

# Executed natively in Rust in microseconds!
if mesh.is_manifold() and mesh.is_closed():
    print("Mesh is valid and watertight.")

2. Rotational Continuous Collision Detection (CCD)

Evaluate continuous swept trajectories of simultaneous translations and rotations:

import compas_forge

# Pose: [x, y, z, qx, qy, qz, qw]
pose_a_start = [-2.5, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0]
pose_a_end   = [ 2.5, 0.0, 0.0, 0.0, 0.0, 0.707, 0.707] # Rotates 90 deg

result = compas_forge.check_swept_collision_zero_copy(
    mesh_a, pose_a_start, pose_a_end,
    mesh_b, pose_b_start, pose_b_end
)

if result["has_collision"]:
    print(f"Collision at Time of Impact: {result['time_of_impact']:.6f} s")

3. Assembly Contact Solver (Sutherland-Hodgman)

Extract exact contact polygons, centroids, and areas from touching blocks:

import compas_forge

blocks = {"block_0": mesh_0, "block_1": mesh_1}
contacts = compas_forge.compute_assembly_contacts_zero_copy(blocks, tolerance=0.005)

for contact in contacts:
    print(f"Contact between {contact['block_a']} and {contact['block_b']}")
    print(f"Contact Area: {contact['area_m2']} m² | Centroid: {contact['centroid']}")

CLI Usage Guide

# 1. Run general diagnostics
python -m compas_forge check my_mesh.json

# 2. Run continuous swept-collision
python -m compas_forge swept mesh_a.json -2.5,0,0,0,0,0,1 2.5,0,0,0,0,0.7,0.7 mesh_b.json 0,0,0,0,0,0,1 0,0,0,0,0,0,1

# 3. Resolve assembly contacts
python -m compas_forge contacts block_1.json block_2.json --tolerance 0.005

Examples & Reproducibility Sandbox

We provide ready-to-run educational scripts inside the examples/ directory to demonstrate and replicate our SOTA algorithms instantly:

  1. Zero-Copy Mesh Healing (examples/example_zero_copy_healing.py): Repairs 1,000s of vertex duplicates and face normal directions in-memory and reconstructs a healthy COMPAS Mesh in milliseconds.
  2. Rotational Sweep Collision (examples/example_continuous_collision.py): Runs continuous swept collision detection on two moving, rotating objects.
  3. Voussoir Arch Assembly Solver (examples/example_assembly_contacts.py): Synthesizes a 30-block voussoir arch and solves 29 contact interfaces with centroids and normal vectors in milliseconds.

To run any example:

python examples/example_zero_copy_healing.py

To regenerate the scaling benchmark chart:

python generate_benchmarks.py

Mathematical Formulations & Algorithms

1. Mesh Volume via Gauss's Divergence Theorem

$$ V = \frac{1}{6} \sum_i \mathbf{p}_0 \cdot \left(\mathbf{p}_1 \times \mathbf{p}_2\right) $$

2. Best-Fit Newell Plane & Planarity Deviation

$$ n_x = \sum_{i=0}^{N-1} (y_i - y_{i+1})(z_i + z_{i+1}) $$ $$ n_y = \sum_{i=0}^{N-1} (z_i - z_{i+1})(x_i + x_{i+1}) $$ $$ n_z = \sum_{i=0}^{N-1} (x_i - x_{i+1})(y_i + y_{i+1}) $$

The maximum perpendicular distance $d_{max}$ of any vertex $\mathbf{v}i$ to the centroid plane $\mathbf{c}$ is evaluated as: $$ d{max} = \max_i \left|(\mathbf{v}_i - \mathbf{c}) \cdot \mathbf{n}\right| $$

3. Topological Invariants (Euler & Genus)

$$ \chi = V - E + F $$ $$ g = \frac{2 - \chi}{2} $$


Author


License

Licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

compas_forge-0.3.0-cp313-cp313-win_amd64.whl (6.3 MB view details)

Uploaded CPython 3.13Windows x86-64

compas_forge-0.3.0-cp313-cp313-manylinux_2_34_x86_64.whl (6.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

compas_forge-0.3.0-cp313-cp313-macosx_11_0_arm64.whl (6.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

compas_forge-0.3.0-cp312-cp312-win_amd64.whl (6.3 MB view details)

Uploaded CPython 3.12Windows x86-64

compas_forge-0.3.0-cp312-cp312-manylinux_2_34_x86_64.whl (6.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

compas_forge-0.3.0-cp312-cp312-macosx_11_0_arm64.whl (6.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

compas_forge-0.3.0-cp311-cp311-win_amd64.whl (6.3 MB view details)

Uploaded CPython 3.11Windows x86-64

compas_forge-0.3.0-cp311-cp311-manylinux_2_34_x86_64.whl (6.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

compas_forge-0.3.0-cp311-cp311-macosx_11_0_arm64.whl (6.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

compas_forge-0.3.0-cp310-cp310-win_amd64.whl (6.3 MB view details)

Uploaded CPython 3.10Windows x86-64

compas_forge-0.3.0-cp310-cp310-manylinux_2_34_x86_64.whl (6.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

compas_forge-0.3.0-cp310-cp310-macosx_11_0_arm64.whl (6.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

compas_forge-0.3.0-cp39-cp39-win_amd64.whl (6.3 MB view details)

Uploaded CPython 3.9Windows x86-64

compas_forge-0.3.0-cp39-cp39-manylinux_2_34_x86_64.whl (6.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

compas_forge-0.3.0-cp39-cp39-macosx_11_0_arm64.whl (6.4 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file compas_forge-0.3.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for compas_forge-0.3.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 9c4eea8bddd3988159fb1809f46bf892c062395bc3624226ecc4e25f705cd031
MD5 6adf570dc8232975c6b91e9f66b0bb7b
BLAKE2b-256 0f9a902230cff6d911423bc67fece61f604a2176fae892f0c6644839d9d72931

See more details on using hashes here.

File details

Details for the file compas_forge-0.3.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for compas_forge-0.3.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d89fb296f5a29f04507617f416d73fe3160bb87689f2cda294bc01e89e64220d
MD5 6b89ba7de9e9251bb780f933983630f6
BLAKE2b-256 c0cf6d8cdf84892be333852b4ba1c058f81f12fe63bbbdcba28e53ad09e9bedd

See more details on using hashes here.

File details

Details for the file compas_forge-0.3.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for compas_forge-0.3.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8815e343950cc07cc27064b432101d323cf5be0fdcbfb2d4765cd4eb1576f77a
MD5 ebbac3c8782ab24d8d77b123057684fc
BLAKE2b-256 acd0b8e808c7053c68cd52cd7e4b740f2804e66c5a5713991db28226b815cc75

See more details on using hashes here.

File details

Details for the file compas_forge-0.3.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for compas_forge-0.3.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 dcddc1fe4f3c796ba2e986e9a71bc6e90e8b911116e0ec8bbb3436c10c116fdf
MD5 58a2bff17fb8650b68404d2f0bfee79a
BLAKE2b-256 02fbf46425ebd065fd073a1873283eb6ce7de15965cd387fd69556fe7d35a029

See more details on using hashes here.

File details

Details for the file compas_forge-0.3.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for compas_forge-0.3.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a96a8860fb388906254979642ce7e7ec3ae7984f2f3a5f077e1fbc4e38d7e677
MD5 47e611fe860b582f5dd3c1a184e83030
BLAKE2b-256 c11493009cea7253b52475de7368b4702b14211feb42cc27d9897aec2e496edd

See more details on using hashes here.

File details

Details for the file compas_forge-0.3.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for compas_forge-0.3.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d9737deb3507bea1c32b26623d8fa406e50223caaf0433e95610b91577c88ae3
MD5 6803dbfae37eeabe3adbb656b75adcae
BLAKE2b-256 11bb990d3dc66cab64020e9a69d27cca6d5b8bc0476cb029c5f30e5c2ab3c14f

See more details on using hashes here.

File details

Details for the file compas_forge-0.3.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for compas_forge-0.3.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c6cc9d0791471b8eaa4399ae1c87ba6d36460f4e5142f404658bc722fc11b031
MD5 5aecd9e2f0964bdfe217538facdda269
BLAKE2b-256 d1d17072be6d5ab3041e2c091ae826230532fe2bdf6182c98fe73be73a6e2ec5

See more details on using hashes here.

File details

Details for the file compas_forge-0.3.0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for compas_forge-0.3.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 fb3693d2ed2c719c9fac56dc4745624d0273e3bccdcb85b678394dfb9509dfea
MD5 0698c07ed27c3bbe87e8c6a050483be0
BLAKE2b-256 f66d9aab596a708de4fb57f96f4db022b1a31f1cba82a67ae1d4781cd8f98ec9

See more details on using hashes here.

File details

Details for the file compas_forge-0.3.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for compas_forge-0.3.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bb8c0ed5b53c5f7cba2989f466423eb8315833fadcf9a31439d197f05a62a9af
MD5 103f87d489bd3476914aa11292647f40
BLAKE2b-256 a873a667394a6ff6ccd99cd5442592645bf3c5fb2885195863dadf87757c632e

See more details on using hashes here.

File details

Details for the file compas_forge-0.3.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for compas_forge-0.3.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 9ced557fca439fd14e8fadb3fbd0915ac8d9cd985d99b6142aa49d6d1b898bd9
MD5 1be388b0ee7e8c6e14aacec4ec93cb7e
BLAKE2b-256 5730237af40e64198ead4741e70e8219caf33bdb776d3478eaa78b05cc18228f

See more details on using hashes here.

File details

Details for the file compas_forge-0.3.0-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for compas_forge-0.3.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 057422e901f42b0449f730fad3f3e7a587205a69f84114c228acc0d8423e70bb
MD5 c0539a044e03a244f4638cab14ec9577
BLAKE2b-256 ccb337b62ba9b56a9efdf54396c7d18cff647306d7d6595f2b21457dfe5baed3

See more details on using hashes here.

File details

Details for the file compas_forge-0.3.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for compas_forge-0.3.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6ecd2ee0c8b0c438d188f85317ff2ba075ff8cac6064a761888cc312e4c6fd02
MD5 6dd312bcd3bbebeab296c1ed77e4a515
BLAKE2b-256 5b59e73af7729e112d946a32f024a979a6e80253506c7b0ddd119b2a9cdc91a0

See more details on using hashes here.

File details

Details for the file compas_forge-0.3.0-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for compas_forge-0.3.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 5ed5559d6718385490f7355658b018eb606979e70c982f2dbc6a8f0fea9f2808
MD5 eb0d8692ddd6308fb29ad959c4280023
BLAKE2b-256 04501a4a853d4cffb1e08d05b1812b197871fffcd42b7f3a0b96e43f60e6c823

See more details on using hashes here.

File details

Details for the file compas_forge-0.3.0-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for compas_forge-0.3.0-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 c16a0ae45f2acfe5584e8796f6367e6f1b3a20c45cabe570f47483f94bd5fa2b
MD5 dd6a42a0ba8a6de093901968386b3654
BLAKE2b-256 9e749130569ab3bdd28fc07427217ebaf33341430ad41dd5bb0de583da970f92

See more details on using hashes here.

File details

Details for the file compas_forge-0.3.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for compas_forge-0.3.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5d0900ad76fe4d3444ac82ad63620811c56650f5bbaa3b85cdb799029f674e32
MD5 a0b4f3cfe10b12726072139eba9c4d03
BLAKE2b-256 ed926b9d8072a509f39d10fefc1d0ac81b09c774d0f061a45ce827e12ea57107

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