Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4KDMap Class Reference

#include <G4KDMap.hh>

Public Member Functions

 G4KDMap (std::size_t dimensions)
 
void Insert (G4KDNode_Base *pos)
 
void Sort ()
 
G4KDNode_BasePopOutMiddle (std::size_t dimension)
 
std::size_t GetDimension ()
 
std::size_t GetSize ()
 

Detailed Description

Definition at line 91 of file G4KDMap.hh.

Constructor & Destructor Documentation

◆ G4KDMap()

G4KDMap::G4KDMap ( std::size_t dimensions)
inline

Definition at line 94 of file G4KDMap.hh.

94 : fSortOut(dimensions, __1DSortOut(dimensions))
95 {
96 fIsSorted = false;
97// for(std::size_t i = 0 ; i < dimensions ; ++i)
98// {
99// fSortOut[i] = new __1DSortOut(i);
100// }
101 }

Member Function Documentation

◆ GetDimension()

std::size_t G4KDMap::GetDimension ( )
inline

Definition at line 107 of file G4KDMap.hh.

108 {
109 return fSortOut.size();
110 }

◆ GetSize()

std::size_t G4KDMap::GetSize ( )
inline

Definition at line 112 of file G4KDMap.hh.

113 {
114 return fMap.size();
115 }

Referenced by G4KDTree::Build().

◆ Insert()

void G4KDMap::Insert ( G4KDNode_Base * pos)

Definition at line 88 of file G4KDMap.cc.

89{
90 vector<_deq_iterator>& vit = fMap[pos];
91
92 std::size_t maxSize = fSortOut.size();
93
94 G4cout << "G4KDMap::Insert : " << maxSize << G4endl;
95
96 vit.reserve(maxSize);
97
98 for (std::size_t i = 0; i < fSortOut.size(); ++i)
99 {
100 vit[i] = fSortOut[i].Insert(pos);
101
102// if(*(vit[i]) != pos)
103// {
104// G4cout << "insert wrong iterator" << G4endl;
105// abort();
106// }
107 }
108 /*
109 std::map<G4KDNode*, std::vector<_deq_iterator> >::iterator fMap_it
110 = fMap.begin();
111
112 for( ; fMap_it != fMap.end() ; fMap_it++)
113 {
114 std::vector<_deq_iterator>& vit = fMap_it->second;
115
116 G4KDNode* tmpNode = fMap_it->first;
117
118 for(std::size_t i = 0 ; i < fSortOut.size() ; i++)
119 {
120 G4cout << "i = " << i << G4endl;
121 G4cout << "vit[i] = " << *(vit[i]) << G4endl;
122 if(*(vit[i]) != tmpNode)
123 {
124 G4cout << "!!!! Wrong iterator" << G4endl;
125 abort();
126 }
127 }
128
129 }
130 */
131
132 fIsSorted = false;
133}
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout

Referenced by G4KDTree::__InsertMap().

◆ PopOutMiddle()

G4KDNode_Base * G4KDMap::PopOutMiddle ( std::size_t dimension)

Definition at line 135 of file G4KDMap.cc.

136{
137 G4cout << "_____________" << G4endl;
138 G4cout << "G4KDMap::PopOutMiddle ( "<< dimension << " )" << G4endl;
139
140 if(!fIsSorted) Sort();
141 G4KDNode_Base* output_node = fSortOut[dimension].PopOutMiddle();
142
143 if(output_node == nullptr) return nullptr;
144
145 G4cout << "output_node : " << output_node << G4endl;
146 G4cout << "output_node : " << output_node->GetAxis() << G4endl;
147
148 auto fMap_it
149 = fMap.find(output_node);
150
151
152 if(fMap_it == fMap.end())
153 {
154 G4cout << "fMap_it == fMap.end()" << G4endl;
155 G4cout << "output_node = " << output_node << G4endl;
156 return output_node;
157 }
158
159 std::vector<_deq_iterator>& vit = fMap_it->second;
160
161 /*
162 if(fMap_it->first != output_node)
163 {
164 G4cout << "fMap_it->first ! output_node"<< G4endl;
165 G4cout << "fMap_it->first = " << fMap_it->first << G4endl;
166 abort();
167 }
168 */
169
170 for(std::size_t i = 0; i < fSortOut.size(); ++i)
171 {
172 if(i != dimension)
173 {
174 G4cout << "i = " << i << G4endl;
175
176 /*
177 // G4cout << "i = " << i << G4endl;
178 // G4cout << "vit[i] = " << *(vit[i]) << G4endl;
179 if(*(vit[i]) != output_node)
180 {
181 G4cout << "deleting wrong iterator" << G4endl;
182 abort();
183 }
184 */
185 fSortOut[i].Erase(vit[i]);
186 }
187 }
188
189 fMap.erase(fMap_it);
190
191 return output_node;
192}
void Sort()
Definition G4KDMap.cc:194
G4int GetAxis() const
Definition G4KDNode.hh:79

Referenced by G4KDTree::Build().

◆ Sort()

void G4KDMap::Sort ( )

Definition at line 194 of file G4KDMap.cc.

195{
196 for (auto & i : fSortOut)
197 {
198 i.Sort();
199 }
200
201 fIsSorted = true;
202}

Referenced by PopOutMiddle().


The documentation for this class was generated from the following files: