Skip to content

Add opt-in native box recognition to OCE conversion - #310

Closed
ghost wants to merge 2 commits into
mainfrom
unknown repository
Closed

Add opt-in native box recognition to OCE conversion#310
ghost wants to merge 2 commits into
mainfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Aug 27, 2026

Copy link
Copy Markdown

Summary

This PR adds conservative, opt-in recognition of box-shaped OCE/STEP solids during conversion to Geant4.
When nativePrimitives=True, eligible CAD bodies are converted to native Geant4 Box solids instead of TessellatedSolid. The existing tessellated conversion remains the fallback whenever the body cannot be recognised conservatively.
The feature is disabled by default:
oce2Geant4(..., nativePrimitives=False)
This is intended as a first step toward broader native primitive recognition; this PR is deliberately limited to boxes.

Recognition

Box recognition checks the OCE surface topology and reconstructs the box from the in-memory tessellated vertices.
Recognition requires six planar faces, exactly eight unique vertices, three mutually orthogonal box axes, reconstruction within a strict numerical tolerance, and a right-handed local basis.
Bodies which do not satisfy these conditions continue to use the existing tessellated representation.

Placement handling

Native reconstruction can introduce a local box centre and basis which must be composed with the original OCE placement.
The conversion applies the corresponding local transform before constructing the PhysicalVolume, with explicit checks that the resulting rotation remains orthonormal and proper.

Tests

Regression coverage includes feature-off compatibility, native box replacement while retaining tessellated fallback, solid-type/count changes, rotated-box reconstruction, and right-handed basis enforcement.
The pure reconstruction/handedness regression is separated from the platform-specific OCE integration test so it can also run on Linux.
Repository pre-commit checks pass for the modified files, and the native-box pytest targets pass locally.

Additional validation

The implementation was also exercised against an arbitrary-3D validation fixture containing 21 transformed box placements. Exact world-coordinate comparison passed for all 21 placements with a maximum discrepancy of approximately 1.3e-13 mm, and recursive Geant4 overlap validation reported zero overlaps.
These external validation checks are additional development evidence rather than part of the upstream test suite.

@gipert

gipert commented Aug 27, 2026

Copy link
Copy Markdown
Member

who are you? this looks like some AI spam to me

Repository owner closed this by deleting the head repository Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants