Geant4-11
G4OctreeFinder.hh
Go to the documentation of this file.
1// ********************************************************************
2// * License and Disclaimer *
3// * *
4// * The Geant4 software is copyright of the Copyright Holders of *
5// * the Geant4 Collaboration. It is provided under the terms and *
6// * conditions of the Geant4 Software License, included in the file *
7// * LICENSE and available at http://cern.ch/geant4/license . These *
8// * include a list of copyright holders. *
9// * *
10// * Neither the authors of this software system, nor their employing *
11// * institutes,nor the agencies providing financial support for this *
12// * work make any representation or warranty, express or implied, *
13// * regarding this software system or assume any liability for its *
14// * use. Please see the license in the file LICENSE and URL above *
15// * for the full disclaimer and the limitation of liability. *
16// * *
17// * This code implementation is the result of the scientific and *
18// * technical work of the GEANT4 collaboration. *
19// * By using, copying, modifying or distributing the software (or *
20// * any work based on the software) you agree to acknowledge its *
21// * use in resulting scientific publications, and indicate your *
22// * acceptance of all terms of the Geant4 Software license. *
23// ********************************************************************
24//
25//
26//
27
28#ifndef G4OctreeFinder_hh
29#define G4OctreeFinder_hh 1
30#include "globals.hh"
31#include <map>
32#include "G4Octree.hh"
33#include "G4Track.hh"
34#include "G4ITType.hh"
35#include "G4memory.hh"
36#include "G4TrackList.hh"
37#include "G4IRTUtils.hh"
38
39#undef DEBUG
40//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42{
43public:
44 G4VFinder() = default;
45 virtual ~G4VFinder() = default;
46 virtual void Clear() = 0;
47 virtual void SetVerboseLevel(G4int level) = 0;
48 virtual G4int GetVerboseLevel() = 0;
49 virtual G4ITType GetITType() = 0;
50};
51//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52
53#ifndef _Extractor_
54#define _Extractor_
55template<typename CONTAINER>
57{
58public:
59 const G4ThreeVector operator () (typename CONTAINER::iterator it)
60 {
61 return (*it)->GetPosition();
62 }
63 std::function<G4bool(const std::pair<typename CONTAINER::iterator,G4double>,
64 const std::pair<typename CONTAINER::iterator,G4double>)>
65 compareInterval = [](const std::pair<typename CONTAINER::iterator,G4double>& iter1,
66 const std::pair<typename CONTAINER::iterator,G4double>& iter2)
67 -> G4bool
68 {
69 return (std::get<1>(iter1) < std::get<1>(iter2));
70 };
71
72};
73#endif
74template<class T,typename CONTAINER>
76{
77 using Octree = G4Octree<typename CONTAINER::iterator,
79 using OctreeHandle = G4shared_ptr<Octree>;
80 using TreeMap = std::map<int, OctreeHandle>;
81
82private:
91public:
93
96
99
100 ~G4OctreeFinder() override;
101 void Clear() override;
102
103 void SetVerboseLevel(G4int level) override
104 {
105 fVerbose = level;
106 }
107
109 {
110 return fVerbose;
111 }
112
114 {
115 return T::ITType();
116 }
117 void BuildTreeMap(const std::map<G4int,CONTAINER*>& listMap);
118 void FindNearestInRange(const G4Track& track,
119 const int& key,
120 G4double R,
121 std::vector<std::pair<typename
122 CONTAINER::iterator,G4double>>& result,
123 G4bool isSort = false) const;
124
125 void FindNearest(const G4Track& track,
126 const int& key,
127 G4double R,
128 std::vector<std::pair<typename
129 CONTAINER::iterator,G4double>>& result,
130 G4bool isSort = false) const;
131
133 const G4int& key,
134 G4double R,
135 std::vector<std::pair<typename
136 CONTAINER::iterator,G4double>>& result,
137 G4bool isSort = false) const;
138
139 void FindNearestInRange(const G4ThreeVector& /*from this point*/,
140 G4double R,
141 std::vector<std::pair<
142 typename CONTAINER::iterator,G4double> >&
143 result,
144 G4bool isSorted) const;
145};
146
147#include "G4OctreeFinder.icc"
148#endif
G4double(* function)(G4double)
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
std::function< G4bool(const std::pair< typename CONTAINER::iterator, G4double >, const std::pair< typename CONTAINER::iterator, G4double >)> compareInterval
const G4ThreeVector operator()(typename CONTAINER::iterator it)
G4shared_ptr< Octree > OctreeHandle
void FindNearestInRange(const G4ThreeVector &position, const G4int &key, G4double R, std::vector< std::pair< typename CONTAINER::iterator, G4double > > &result, G4bool isSort=false) const
void BuildTreeMap(const std::map< G4int, CONTAINER * > &listMap)
G4ITType GetITType() override
Extractor< CONTAINER > fExtractor
void SetOctreeUsed(G4bool used)
static G4OctreeFinder * Instance()
void FindNearestInRange(const G4Track &track, const int &key, G4double R, std::vector< std::pair< typename CONTAINER::iterator, G4double > > &result, G4bool isSort=false) const
G4bool IsOctreeUsed() const
OctreeHandle fTree
static G4ThreadLocal G4OctreeFinder * fInstance
G4int GetVerboseLevel() override
void FindNearest(const G4Track &track, const int &key, G4double R, std::vector< std::pair< typename CONTAINER::iterator, G4double > > &result, G4bool isSort=false) const
void SetVerboseLevel(G4int level) override
void FindNearestInRange(const G4ThreeVector &, G4double R, std::vector< std::pair< typename CONTAINER::iterator, G4double > > &result, G4bool isSorted) const
~G4OctreeFinder() override
void SetOctreeBuilt(G4bool used)
std::map< int, OctreeHandle > TreeMap
G4bool IsOctreeBuilt() const
void Clear() override
virtual G4ITType GetITType()=0
virtual ~G4VFinder()=default
virtual void SetVerboseLevel(G4int level)=0
virtual void Clear()=0
G4VFinder()=default
virtual G4int GetVerboseLevel()=0
#define G4ThreadLocal
Definition: tls.hh:77