Skip to main content

Differentiable rasterizer for CAD Boolean operations — JAX-native B-Rep kernel with stratum-aware gradients.

Project description

BRepAX

CI PyPI License Python 3.11+

JAX-native differentiable B-Rep kernel with NURBS support.

BRepAX loads STEP files into a JAX computation graph, enabling gradient-based optimization of CAD geometry through Boolean operations. It provides stratum-aware differentiation that handles topological transitions at Boolean boundaries, and supports both analytical primitives and freeform B-spline surfaces.

Installation

pip install brepax

Quick Start

import jax.numpy as jnp
import equinox as eqx
from brepax.io.step import read_step
from brepax.brep.csg_stump import reconstruct_csg_stump, stump_to_differentiable
from brepax.metrics import surface_area, thin_wall_volume

# Load STEP file and build differentiable representation
shape = read_step("part.step")
stump = reconstruct_csg_stump(shape)
diff = stump_to_differentiable(stump)

# Compute metrics
lo, hi = jnp.array([-1.0] * 3), jnp.array([41.0, 31.0, 21.0])
vol = diff.volume(resolution=32, lo=lo, hi=hi)
area = surface_area(diff.sdf, lo=lo, hi=hi, resolution=32)
thin = thin_wall_volume(diff.sdf, 2.0, lo=lo, hi=hi, resolution=32)

# Gradient of volume w.r.t. all design parameters
grad = eqx.filter_grad(lambda d: d.volume(resolution=16, lo=lo, hi=hi))(diff)

Features

Primitives

9 geometric types with differentiable SDF interface: Plane, Cylinder, Sphere, Cone, Torus, Box, FiniteCylinder, Disk, and BSplineSurface (rational NURBS with weights).

STEP Pipeline

  • Read STEP files via OCCT (cadquery-ocp-novtk)
  • Convert all face types to primitives (100% conversion on 4,080 faces across 28 test files)
  • PMC-based CSG-Stump reconstruction (tested up to 664 faces)
  • Differentiable volume, metrics, and gradients end-to-end

Differentiable Metrics

8 metrics, all differentiable via jax.grad:

Metric Description
volume Sigmoid indicator integral
surface_area Sigmoid-derivative delta function
center_of_mass Volume-weighted position average
moment_of_inertia Inertia tensor with Richardson extrapolation
thin_wall_volume Volume below wall thickness threshold
min_wall_thickness Soft-argmax with sub-grid refinement
draft_angle_violation Surface area with insufficient draft angle
undercut_volume Surface-weighted undercut severity

Boolean Operations

Union, subtract, intersect with stratum-dispatched gradients. Analytical exact gradients for bounded primitive pairs in 3 of 4 topological configurations.

Documentation

Full documentation: lv416e.github.io/brepax

License

Apache License 2.0. See LICENSE for details.

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

brepax-0.3.0.tar.gz (304.3 kB view details)

Uploaded Source

Built Distribution

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

brepax-0.3.0-py3-none-any.whl (70.0 kB view details)

Uploaded Python 3

File details

Details for the file brepax-0.3.0.tar.gz.

File metadata

  • Download URL: brepax-0.3.0.tar.gz
  • Upload date:
  • Size: 304.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for brepax-0.3.0.tar.gz
Algorithm Hash digest
SHA256 706e4af809fbd4cff46657b468cde6df09e05d46d416f18139fa224cd900370d
MD5 9483158a68cb5352409b5d1528c2835f
BLAKE2b-256 b0030df0f17a9565d4fb473bacdef72442727778759a89da40d43834587e6020

See more details on using hashes here.

Provenance

The following attestation bundles were made for brepax-0.3.0.tar.gz:

Publisher: publish.yaml on lv416e/brepax

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file brepax-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: brepax-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 70.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for brepax-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f8c4f6b9fee643de3eb903a7a2876fa50428c638cc96563ad65b4a211dba6bf
MD5 27e926057a0f91c1c0da8e89dff3405f
BLAKE2b-256 940abe0fa81f05cf1ee49fc39aa6d7f61b534ff3d1aeae2a6a89476287840b68

See more details on using hashes here.

Provenance

The following attestation bundles were made for brepax-0.3.0-py3-none-any.whl:

Publisher: publish.yaml on lv416e/brepax

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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