Geant4-11
Public Member Functions | Private Attributes
G4KDMap Class Reference

#include <G4KDMap.hh>

Public Member Functions

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

Private Attributes

bool fIsSorted
 
std::map< G4KDNode_Base *, std::vector< std::deque< G4KDNode_Base * >::iterator > > fMap
 
std::vector< __1DSortOutfSortOut
 

Detailed Description

Definition at line 89 of file G4KDMap.hh.

Constructor & Destructor Documentation

◆ G4KDMap()

G4KDMap::G4KDMap ( size_t  dimensions)
inline

Definition at line 92 of file G4KDMap.hh.

92 : fSortOut(dimensions, __1DSortOut(dimensions))
93 {
94 fIsSorted = false;
95// for(size_t i = 0 ; i < dimensions ; i++)
96// {
97// fSortOut[i] = new __1DSortOut(i);
98// }
99 }
std::vector< __1DSortOut > fSortOut
Definition: G4KDMap.hh:117
bool fIsSorted
Definition: G4KDMap.hh:116

References fIsSorted.

Member Function Documentation

◆ GetDimension()

size_t G4KDMap::GetDimension ( )
inline

Definition at line 105 of file G4KDMap.hh.

106 {
107 return fSortOut.size();
108 }

References fSortOut.

◆ GetSize()

size_t G4KDMap::GetSize ( )
inline

Definition at line 110 of file G4KDMap.hh.

111 {
112 return fMap.size();
113 }
std::map< G4KDNode_Base *, std::vector< std::deque< G4KDNode_Base * >::iterator > > fMap
Definition: G4KDMap.hh:118

References fMap.

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 size_t maxSize = fSortOut.size();
95
96 G4cout << "G4KDMap::Insert : " << maxSize << G4endl;
97
98 vit.reserve(maxSize);
99
100 for (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(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}
static const G4double pos
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout

References fIsSorted, fMap, fSortOut, G4cout, G4endl, and pos.

Referenced by G4KDTree::__InsertMap().

◆ PopOutMiddle()

G4KDNode_Base * G4KDMap::PopOutMiddle ( 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(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
int GetAxis() const
Definition: G4KDNode.hh:79

References fIsSorted, fMap, fSortOut, G4cout, G4endl, G4KDNode_Base::GetAxis(), and Sort().

Referenced by G4KDTree::Build().

◆ Sort()

void G4KDMap::Sort ( )

Definition at line 196 of file G4KDMap.cc.

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

References fIsSorted, and fSortOut.

Referenced by PopOutMiddle().

Field Documentation

◆ fIsSorted

bool G4KDMap::fIsSorted
private

Definition at line 116 of file G4KDMap.hh.

Referenced by G4KDMap(), Insert(), PopOutMiddle(), and Sort().

◆ fMap

std::map<G4KDNode_Base*, std::vector<std::deque<G4KDNode_Base*>::iterator> > G4KDMap::fMap
private

Definition at line 118 of file G4KDMap.hh.

Referenced by GetSize(), Insert(), and PopOutMiddle().

◆ fSortOut

std::vector<__1DSortOut> G4KDMap::fSortOut
private

Definition at line 117 of file G4KDMap.hh.

Referenced by GetDimension(), Insert(), PopOutMiddle(), and Sort().


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