File indexing completed on 2025-02-23 09:21:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 #ifndef MOLECULAR_OCTREE_NODE_HH
0028 #define MOLECULAR_OCTREE_NODE_HH
0029
0030 #include "G4ThreeVector.hh"
0031 #include "globals.hh"
0032
0033 #include <array>
0034 #include <vector>
0035
0036 class G4VPhysicalVolume;
0037
0038
0039
0040 class OctreeNode
0041 {
0042 public:
0043
0044 OctreeNode(const G4ThreeVector&, const G4ThreeVector&, G4int, OctreeNode* parent = nullptr);
0045
0046 ~OctreeNode();
0047
0048 inline G4bool HasChildren() const { return (fChildren[0] != nullptr); }
0049
0050 inline OctreeNode* GetParent() const { return fParent; };
0051
0052 inline const auto& GetHalfLengths() const { return fHalfLengths; };
0053
0054 inline G4double GetHalfLengthsMag() const { return fHalfLengthsMag; };
0055
0056 inline const G4ThreeVector& GetPosition() const { return fPosition; };
0057
0058 inline const auto& GetChildren() const { return fChildren; };
0059
0060 const std::vector<G4VPhysicalVolume*> SearchOctree(const G4ThreeVector&,
0061 G4double _rad = 0) const;
0062
0063 void SearchOctree(const G4ThreeVector& pos, std::vector<G4VPhysicalVolume*>& out,
0064 G4double _rad = 0) const;
0065
0066 const std::vector<G4VPhysicalVolume*> SearchOctree(const G4ThreeVector&) const;
0067
0068 G4int GetNumberOfTerminalNodes();
0069
0070 void AddPhysicalVolume(G4VPhysicalVolume*);
0071
0072 std::vector<G4VPhysicalVolume*> GetContents() const;
0073
0074 inline G4int GetMaxContents() const { return fMaxContents; };
0075
0076 protected:
0077 void Split();
0078
0079 const OctreeNode* GetChildFromPosition(G4ThreeVector const&) const;
0080
0081 OctreeNode* GetChildFromPosition(G4ThreeVector const& pos);
0082
0083 private:
0084 G4ThreeVector fPosition, fHalfLengths;
0085 G4int fMaxContents;
0086
0087 std::vector<G4VPhysicalVolume*> fContents;
0088
0089 OctreeNode* fParent;
0090
0091
0092
0093
0094
0095
0096
0097 std::array<OctreeNode*, 8> fChildren;
0098 G4double fHalfLengthsMag;
0099 };
0100
0101
0102
0103 #endif