File indexing completed on 2025-09-18 09:24:49
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include "geocel/BoundingBox.hh"
0010 #include "orange/surf/PlaneAligned.hh"
0011
0012 #include "BoundingZone.hh"
0013
0014 namespace celeritas
0015 {
0016 namespace orangeinp
0017 {
0018 namespace detail
0019 {
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 class NegatedSurfaceClipper
0036 {
0037 public:
0038
0039 explicit inline NegatedSurfaceClipper(BoundingZone* bz);
0040
0041 inline NegatedSurfaceClipper(BBox* interior, BBox* exterior);
0042
0043
0044 template<Axis T>
0045 CELER_FORCEINLINE void operator()(PlaneAligned<T> const& s)
0046 {
0047 return this->clip_impl(T, s.position());
0048 }
0049
0050
0051 template<class S>
0052 CELER_FORCEINLINE void operator()(S const&)
0053 {
0054 return this->invalidate();
0055 }
0056
0057 private:
0058 BBox* interior_{nullptr};
0059 BBox* exterior_{nullptr};
0060
0061
0062 inline void clip_impl(Axis ax, real_type pos);
0063
0064
0065 inline void invalidate();
0066 };
0067
0068
0069
0070
0071
0072 NegatedSurfaceClipper::NegatedSurfaceClipper(BoundingZone* bz)
0073 : interior_{&bz->interior}, exterior_{&bz->exterior}
0074 {
0075 CELER_EXPECT(bz && interior_ && exterior_);
0076 }
0077
0078
0079
0080
0081
0082 NegatedSurfaceClipper::NegatedSurfaceClipper(BBox* interior, BBox* exterior)
0083 : interior_{interior}, exterior_{exterior}
0084 {
0085 CELER_EXPECT(interior_ || exterior_);
0086 }
0087
0088
0089
0090
0091
0092 void NegatedSurfaceClipper::clip_impl(Axis ax, real_type pos)
0093 {
0094 if (interior_)
0095 {
0096 interior_->shrink(Bound::lo, ax, pos);
0097 }
0098 if (exterior_)
0099 {
0100 exterior_->shrink(Bound::lo, ax, pos);
0101 }
0102 }
0103
0104
0105
0106
0107
0108 void NegatedSurfaceClipper::invalidate()
0109 {
0110 if (interior_)
0111 {
0112 *interior_ = {};
0113 }
0114 }
0115
0116
0117 }
0118 }
0119 }