Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4KDTreeResult.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
28//
29// History:
30// -----------
31// 10 Oct 2011 M.Karamitros created
32//
33// -------------------------------------------------------------------
34
35#include "G4KDTreeResult.hh"
36
37using namespace std;
38
40{
42 return _instance;
43}
44
45struct ResNode
46{
47public:
48 ResNode():fNode(nullptr),fDistanceSqr(0){}
49 ResNode(double distsqr, G4KDNode_Base* node):
50 fNode(node),fDistanceSqr(distsqr)
51 {}
52
53 ResNode(const ResNode& right)
54 {
55 fNode = right.fNode;
57 }
59 {
60 if(this == &rhs) return *this;
61 fNode = rhs.fNode;
63 return *this;
64 }
65 ~ResNode()= default;
66
67 G4bool operator<(const ResNode& right) const
68 {
69 return (fDistanceSqr < right.fDistanceSqr);
70 }
71
73 double GetDistanceSqr() { return fDistanceSqr;}
74
75protected:
78};
79
80// comparison
81bool CompareResNode(const ResNode& left,
82 const ResNode& right)
83{
84 return left < right;
85}
86
91
93{
94 KDTR_parent::erase(begin(),end());
95 //std::list<ResNode>::erase(begin(),end());
96}
97
98void G4KDTreeResult::Insert(double dis_sq, G4KDNode_Base* node)
99{
100 //std::list<ResNode>::push_back(ResNode(dis_sq,node));
101 KDTR_parent::push_back(ResNode(dis_sq,node));
102}
103
105{
106// std::list<ResNode>::erase(begin(),end());
107// fIterator = std::list<ResNode>::begin();
108 KDTR_parent::erase(begin(),end());
109 fIterator = KDTR_parent::begin();
110}
111
113{
114 //std::list<ResNode>::sort(CompareResNode);
115 std::sort(begin(), end(), CompareResNode);
116}
117
119{
120 //return std::list<ResNode>::size();
121 return KDTR_parent::size();
122}
123
125{
126 return KDTR_parent::size();
127 //return std::list<ResNode>::size();
128}
129
131{
132 fIterator = begin();
133}
134
136{
137 return (fIterator == end());
138}
139
141{
142 ++fIterator;
143}
144
146{
147 return (*fIterator).GetDistanceSqr();
148}
149
151 return (*fIterator).GetNode();
152}
G4Allocator< G4KDTreeResult > *& aKDTreeAllocator()
bool CompareResNode(const ResNode &left, const ResNode &right)
bool G4bool
Definition G4Types.hh:86
G4KDTreeResult(G4KDTree *)
G4KDNode_Base * GetNode() const
size_t size() const
double GetDistanceSqr() const
size_t GetSize() const
virtual ~G4KDTreeResult()
void Insert(double, G4KDNode_Base *)
KDTR_parent::iterator fIterator
G4KDNode_Base * fNode
G4KDNode_Base * GetNode()
double GetDistanceSqr()
double fDistanceSqr
ResNode(const ResNode &right)
G4bool operator<(const ResNode &right) const
ResNode(double distsqr, G4KDNode_Base *node)
ResNode & operator=(const ResNode &rhs)
~ResNode()=default
#define G4ThreadLocalStatic
Definition tls.hh:76