![]() |
SHiP Geometry
SHiP experiment geometry implementation using GeoModel.
|
Constexpr predicates for compile-time geometry consistency checks. More...
Classes | |
| struct | Span |
| Closed interval along one axis. More... | |
| struct | Box |
| Axis-aligned box. More... | |
Typedefs | |
| using | LengthMm |
| Spellings for struct members and function parameters. | |
Functions | |
| constexpr Span | span (LengthMm centre, LengthMm half) |
| Interval of a volume with the given centre and half-length. | |
| constexpr bool | contains (Span outer, Span inner, LengthMm tol=0.0 *units::mm) |
inner lies within outer, allowing tol of slack at either end. | |
| constexpr bool | overlaps (Span a, Span b) |
| The intervals share more than a boundary. Touching ends do not overlap. | |
| constexpr Box | box (LengthMm cx, LengthMm cy, LengthMm cz, LengthMm hx, LengthMm hy, LengthMm hz) |
Box with centre (cx, cy, cz) and the given half-lengths. | |
| constexpr Box | box (LengthMm hx, LengthMm hy, LengthMm hz) |
| Box centred on the origin. | |
| constexpr bool | contains (const Box &outer, const Box &inner, LengthMm tol=0.0 *units::mm) |
| constexpr bool | overlaps (const Box &a, const Box &b) |
| Boxes overlap only if they overlap along every axis. | |
| constexpr Box | bounds (double x0, double x1, double y0, double y1, double z0, double z1) |
| Box from its bounds in mm, for writing a known region down literally. | |
| constexpr Box | intersection (const Box &a, const Box &b) |
| The region two boxes share. Only meaningful if they overlap. | |
| constexpr bool | overlapsWithin (const Box &a, const Box &b, const Box ®ion, LengthMm tol=1e-6 *units::mm) |
The boxes overlap, and only within region. | |
| constexpr Box | shrunk (const Box &b, LengthMm d) |
b with every face moved inwards by d. | |
| template<typename Range, typename Pred> | |
| constexpr std::size_t | firstFailure (const Range &range, Pred ok) |
Index of the first element of range for which ok is false, or npos. | |
| template<typename Range, typename Pred> | |
| constexpr std::size_t | firstPairFailure (const Range &range, Pred ok) |
Index i of the first neighbouring pair (range[i], range[i+1]) for which ok is false, or npos. | |
| template<std::size_t N> | |
| constexpr bool | coveredBy (const Box &inner, const std::array< Box, N > &outers) |
Whether inner lies within the union of outers. | |
Variables | |
| constexpr std::size_t | npos = std::numeric_limits<std::size_t>::max() |
| Returned by the first*() searches when every element passes. | |
Constexpr predicates for compile-time geometry consistency checks.
The geometry constants are all constexpr quantities, so containment, ordering and non-overlap can be checked with static_assert instead of building volumes in a test. The predicates are plain constexpr functions so tests can also feed them bad inputs as negative controls.
Only comparisons and +/- are used: no <cmath>, whose functions Clang does not fold in constant expressions (clang-tidy parses the tree with Clang).
Spellings for struct members and function parameters.
Constants instead use static constexpr auto x = 1.0 * units::mm; and deduce their type.
|
nodiscardconstexpr |
Box from its bounds in mm, for writing a known region down literally.
|
nodiscardconstexpr |
Box with centre (cx, cy, cz) and the given half-lengths.
Box centred on the origin.
|
nodiscardconstexpr |
|
nodiscardconstexpr |
inner lies within outer, allowing tol of slack at either end.
|
nodiscardconstexpr |
Whether inner lies within the union of outers.
Every bound of an outer box that falls inside inner cuts it into cells; each cell lies either wholly inside or wholly outside each outer box, so testing the cell centres decides coverage exactly.
|
nodiscardconstexpr |
Index of the first element of range for which ok is false, or npos.
Asserting firstFailure(...) == npos instead of a plain all-of makes the compiler print the offending index when the assertion fails.
|
nodiscardconstexpr |
Index i of the first neighbouring pair (range[i], range[i+1]) for which ok is false, or npos.
The region two boxes share. Only meaningful if they overlap.
Boxes overlap only if they overlap along every axis.
The intervals share more than a boundary. Touching ends do not overlap.
|
nodiscardconstexpr |
The boxes overlap, and only within region.
Bounds a known overlap: it fails both when the overlap is removed and when it grows.
b with every face moved inwards by d.
A box sticks out of a region by at most d exactly when shrunk(box, d) lies within it.
Interval of a volume with the given centre and half-length.
|
inlineconstexpr |
Returned by the first*() searches when every element passes.