Geant4 11.1.1
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:
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 }
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
88//std::list<ResNode>()
90{
91 fTree = tree;
92}
93
95{
96 KDTR_parent::erase(begin(),end());
97 //std::list<ResNode>::erase(begin(),end());
98}
99
100void G4KDTreeResult::Insert(double dis_sq, G4KDNode_Base* node)
101{
102 //std::list<ResNode>::push_back(ResNode(dis_sq,node));
103 KDTR_parent::push_back(ResNode(dis_sq,node));
104}
105
107{
108// std::list<ResNode>::erase(begin(),end());
109// fIterator = std::list<ResNode>::begin();
110 KDTR_parent::erase(begin(),end());
111 fIterator = KDTR_parent::begin();
112}
113
115{
116 //std::list<ResNode>::sort(CompareResNode);
117 std::sort(begin(), end(), CompareResNode);
118}
119
121{
122 //return std::list<ResNode>::size();
123 return KDTR_parent::size();
124}
125
127{
128 return KDTR_parent::size();
129 //return std::list<ResNode>::size();
130}
131
133{
134 fIterator = begin();
135}
136
138{
139 return (fIterator == end());
140}
141
143{
144 ++fIterator;
145}
146
148{
149 return (*fIterator).GetDistanceSqr();
150}
151
153 return (*fIterator).GetNode();
154}
G4Allocator< G4KDTreeResult > *& aKDTreeAllocator()
bool CompareResNode(const ResNode &left, const ResNode &right)
#define KDTR_parent
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
G4KDTree * fTree
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)
#define G4ThreadLocalStatic
Definition: tls.hh:76