Geant4 11.1.1
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 90 of file G4KDMap.cc.

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

Referenced by G4KDTree::__InsertMap().

◆ PopOutMiddle()

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

Definition at line 137 of file G4KDMap.cc.

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

Referenced by G4KDTree::Build().

◆ Sort()

void G4KDMap::Sort ( )

Definition at line 196 of file G4KDMap.cc.

197{
198 for (std::size_t i = 0; i < fSortOut.size(); ++i)
199 {
200 fSortOut[i].Sort();
201 }
202
203 fIsSorted = true;
204}

Referenced by PopOutMiddle().


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