Add the CADsupport module: CAD geometries as exact TGeo solids - #15789
Merged
sawenzel merged 5 commits intoSep 12, 2026
Merged
Conversation
Collaborator
Author
sawenzel
force-pushed
the
swenzel/cad-geometry-integration
branch
3 times, most recently
from
September 12, 2026 12:02
690e0c2 to
6e1b952
Compare
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
force-pushed
the
swenzel/cad-geometry-integration
branch
from
September 12, 2026 13:21
6e1b952 to
ff6ec7b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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.