File indexing completed on 2025-01-30 10:26:05
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef VECGEOM_MANAGEMENT_GEOVISITOR_H_
0010 #define VECGEOM_MANAGEMENT_GEOVISITOR_H_
0011
0012 #include "VecGeom/base/Global.h"
0013 #include "VecGeom/volumes/PlacedVolume.h"
0014 #include "VecGeom/volumes/LogicalVolume.h"
0015 #include "VecGeom/navigation/NavStateFwd.h"
0016
0017 namespace vecgeom {
0018 inline namespace VECGEOM_IMPL_NAMESPACE {
0019
0020
0021 template <typename Container>
0022 class GeoVisitor {
0023 protected:
0024 Container &c_;
0025
0026 public:
0027 GeoVisitor(Container &c) : c_(c){};
0028
0029 virtual void apply(VPlacedVolume *, int level = 0) = 0;
0030 virtual ~GeoVisitor() {}
0031 };
0032
0033
0034
0035 template <typename Container>
0036 class GeoVisitorWithAccessToPath {
0037 protected:
0038 Container &c_;
0039
0040 public:
0041 GeoVisitorWithAccessToPath(Container &c) : c_(c){};
0042
0043 virtual void apply(NavigationState *state, int level = 0) = 0;
0044 virtual ~GeoVisitorWithAccessToPath() {}
0045 };
0046
0047
0048
0049 class GeoVisitorNavIndex {
0050
0051 public:
0052 GeoVisitorNavIndex(){};
0053
0054 virtual NavIndex_t apply(NavStatePath *state, int level, NavIndex_t mother, int dind) = 0;
0055 virtual ~GeoVisitorNavIndex() {}
0056 };
0057
0058
0059 template <typename Container>
0060 class SimpleLogicalVolumeVisitor : public GeoVisitor<Container> {
0061 public:
0062 SimpleLogicalVolumeVisitor(Container &c) : GeoVisitor<Container>(c) {}
0063 virtual void apply(VPlacedVolume *vol, int )
0064 {
0065 LogicalVolume const *lvol = vol->GetLogicalVolume();
0066 if (std::find(this->c_.begin(), this->c_.end(), lvol) == this->c_.end()) {
0067 this->c_.push_back(const_cast<LogicalVolume *>(lvol));
0068 }
0069 }
0070 virtual ~SimpleLogicalVolumeVisitor() {}
0071 };
0072
0073 template <typename Container>
0074 class SimplePlacedVolumeVisitor : public GeoVisitor<Container> {
0075 public:
0076 SimplePlacedVolumeVisitor(Container &c) : GeoVisitor<Container>(c) {}
0077 virtual void apply(VPlacedVolume *vol, int ) { this->c_.push_back(vol); }
0078 virtual ~SimplePlacedVolumeVisitor() {}
0079 };
0080
0081
0082 class GetMaxDepthVisitor {
0083 private:
0084 int maxdepth_;
0085
0086 public:
0087 GetMaxDepthVisitor() : maxdepth_(0) {}
0088 void apply(VPlacedVolume * , int level) { maxdepth_ = (level > maxdepth_) ? level : maxdepth_; }
0089 int getMaxDepth() const { return maxdepth_; }
0090 };
0091
0092
0093 class GetTotalNodeCountVisitor {
0094 private:
0095 int fTotalNodeCount;
0096
0097 public:
0098 GetTotalNodeCountVisitor() : fTotalNodeCount(0) {}
0099 void apply(VPlacedVolume *, int ) { fTotalNodeCount++; }
0100 int GetTotalNodeCount() const { return fTotalNodeCount; }
0101 };
0102
0103 }
0104 }
0105
0106 #endif