Skip to content

Add the CADsupport module: CAD geometries as exact TGeo solids - #15789

Merged
sawenzel merged 5 commits into
AliceO2Group:devfrom
sawenzel:swenzel/cad-geometry-integration
Sep 12, 2026
Merged

sawenzel merged 5 commits into
AliceO2Group:devfrom
sawenzel:swenzel/cad-geometry-integration

Conversation

@sawenzel

Copy link
Copy Markdown
Collaborator

This work advances the CAD→TGeo system, and the Geant simulation of it, in several important ways:

(a) Exact representation of CAD parts, through a solid recognition pipeline built on OpenCascade and two new high-performance TGeo solids: O2FlatCSG and O2BVHSurfaceSolid. The mesh (O2Tessellated) remains the fallback.

(b) A TGeo→STEP exporter, which closes the round trip and gives every converted part a known answer to test against.

(c) The converter now feeds the existing JSON integration of external modules with exact solids, and carries the source media and the field settings across the conversion.

(d) Performance improvements in O2Tessellated (BVH ray pruning)

(e) Extensive test cases, a validation suite and a tutorial.

@sawenzel
sawenzel requested review from a team and shahor02 as code owners September 12, 2026 09:35
@sawenzel

sawenzel commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator Author

The system allows to study ALICE3 R&D (IRIS + oTOF) from CAD with almost zero C++ to the hit level.

alice3

@sawenzel
sawenzel force-pushed the swenzel/cad-geometry-integration branch 3 times, most recently from 690e0c2 to 6e1b952 Compare September 12, 2026 12:02
sawenzel and others added 5 commits September 12, 2026 15:16
This adds the module Detectors/CADSupport with O2BVHSurfaceSolid, an exact representation of a CAD
solid.

- O2BVHSurfaceSolid holds a CAD solid as trimmed surfaces in a BVH and loads it from a
  surfaces_*.bin sidecar.
- O2BVHAssembly answers navigation queries over a set of these solids.
- CADGeometryUtils lives in the module under namespace o2::cad, and ExternalModule and
  ExternalDetector link O2::CADSupport.
- O2Tessellated's ray queries prune on hit, which speeds up every tessellated geometry in o2-sim.
- O2Tessellated gains GetPointsOnSegments, covered by the new test testO2Tessellated.
- O2OverlapCheck sorts pairs of placed solids into disjoint, touching and interpenetrating by
  overlap depth.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This adds O2FlatCSG, a flat CSG solid that represents a CAD part as cells of halfspaces.

- O2FlatCSG stores its halfspaces and cells in flat POD arrays and accelerates queries with a BVH
  over sub-cell boxes.
- O2SurfaceSolidIO reads and writes the flatcsg_*.bin sidecar.
- A #pragma read rule closes every O2FlatCSG read from a file, so a reader gets the accelerated
  shape.
- O2SolidHarness reports a shape whose sub-cell boxes could not be rebuilt.
- O2OverlapCheck requires a boundary point of an O2FlatCSG to flip containment.
- testFlatCSG covers the solid and o2-bench-cadsupport-xray times transport through it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This adds O2_TGeoToCAD.py, which writes a TGeo geometry out as a STEP file.

- O2_TGeoToCAD.py walks the TGeoVolume DAG and writes one STEP file that keeps the XCAF assembly
  tree.
- A logical volume becomes one definition, referenced from every node that places it.
- --carve-mothers subtracts the placed daughters from a mother solid for a CAD-facing export.
- --media-json records the source media, so converting the STEP back rebuilds them verbatim.
- The wrapper o2-tgeo-to-cad is installed into bin and runs the script from
  $O2_ROOT/share/CADSupport/tools.
- --self-test covers the mapping.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This upgrades O2_CADtoTGeo.py to carry every CAD solid in the most exact representation that
accepts it, and installs it as o2-cad-to-tgeo.

- --csg recognises ROOT CSG primitives and booleans, and emits an O2FlatCSG for a part that
  decomposes into cells.
- --exact-surfaces emits an O2BVHSurfaceSolid from trimmed CAD surfaces, and --recognize-surfaces
  recovers planes, cylinders, cones and spheres stored as NURBS.
- --mesh carries the remaining parts as a triangle mesh.
- --media-json rebuilds the original media of geometry exported by o2-tgeo-to-cad, and --in-field
  takes tracking parameters from the live field.
- The cadsupport package holds the recognition, decomposition and emission stages, covered by
  --self-test.
- examples/ ships Bagger.step and as1-oc-214.stp with their material tables, and validation/ holds
  the oracle gate, the closure test and the demo.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This adds the module's documentation: a README, a tutorial and six reference documents.

- README.md is the entry point and the option reference for both converters, the install route and
  the validation tools.
- doc/tutorial/index.html walks through the whole route on the shipped Bagger.step model.
- doc/reference/ describes the two solids and their sidecar formats, the CSG pipeline, the
  tolerance policy, the navigation harness and the deferred work.
- doc/known-issues.md and doc/ideas.md record the module's open defects and the proposals for it.
- The CAD conversion material that lived in scripts/geometry is now carried by the module.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sawenzel
sawenzel force-pushed the swenzel/cad-geometry-integration branch from 6e1b952 to ff6ec7b Compare September 12, 2026 13:21
@sawenzel
sawenzel merged commit da7faae into AliceO2Group:dev Sep 12, 2026
9 of 11 checks passed
@sawenzel
sawenzel deleted the swenzel/cad-geometry-integration branch September 12, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant