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10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/electromagnetic/dna/management/src/G4KDMap.cc (Version 11.3.0) and /processes/electromagnetic/dna/management/src/G4KDMap.cc (Version 3.2)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 #include "G4KDMap.hh"                             
 27 #include "globals.hh"                             
 28 #include "G4KDNode.hh"                            
 29 #include <algorithm>                              
 30                                                   
 31 using namespace std;                              
 32                                                   
 33 using _deq_iterator = std::deque<G4KDNode_Base    
 34                                                   
 35 G4bool __1DSortOut::sortOutNDim::operator()(G4    
 36                                             G4    
 37 {                                                 
 38   return (*lhs)[fDimension] < (*rhs)[fDimensio    
 39 }                                                 
 40                                                   
 41 __1DSortOut::__1DSortOut(std::size_t dimension    
 42     fSortOutNDim(dimension)                       
 43 {                                                 
 44 }                                                 
 45                                                   
 46 __1DSortOut::__1DSortOut(const __1DSortOut& ri    
 47 = default;                                        
 48                                                   
 49 G4int __1DSortOut::GetDimension()                 
 50 {                                                 
 51   return (G4int)fSortOutNDim.fDimension;          
 52 }                                                 
 53                                                   
 54 G4KDNode_Base* __1DSortOut::GetMidle(std::size    
 55 {                                                 
 56   std::size_t contSize = fContainer.size();       
 57   main_middle = (std::size_t) ceil(contSize /     
 58   return fContainer[main_middle];                 
 59 }                                                 
 60                                                   
 61 _deq_iterator __1DSortOut::Insert(G4KDNode_Bas    
 62 {                                                 
 63   return fContainer.insert(fContainer.end(), p    
 64 }                                                 
 65                                                   
 66 G4KDNode_Base* __1DSortOut::PopOutMiddle()        
 67 {                                                 
 68   std::size_t middle;                             
 69   G4KDNode_Base* pos = GetMidle(middle);          
 70   auto deq_pos = fContainer.begin() + middle;     
 71                                                   
 72   if(deq_pos == fContainer.end()) return nullp    
 73                                                   
 74   fContainer.erase(deq_pos);                      
 75   return pos;                                     
 76 }                                                 
 77                                                   
 78 void __1DSortOut::Sort()                          
 79 {                                                 
 80   sort(fContainer.begin(), fContainer.end(), f    
 81 }                                                 
 82                                                   
 83 void __1DSortOut::Erase(_deq_iterator& deq_pos    
 84 {                                                 
 85   fContainer.erase(deq_pos);                      
 86 }                                                 
 87                                                   
 88 void G4KDMap::Insert(G4KDNode_Base* pos)          
 89 {                                                 
 90   vector<_deq_iterator>& vit = fMap[pos];         
 91                                                   
 92   std::size_t maxSize = fSortOut.size();          
 93                                                   
 94   G4cout << "G4KDMap::Insert : " << maxSize <<    
 95                                                   
 96   vit.reserve(maxSize);                           
 97                                                   
 98   for (std::size_t i = 0; i < fSortOut.size();    
 99   {                                               
100     vit[i] = fSortOut[i].Insert(pos);             
101                                                   
102 //    if(*(vit[i]) != pos)                        
103 //    {                                           
104 //      G4cout << "insert wrong iterator" << G    
105 //      abort();                                  
106 //    }                                           
107   }                                               
108   /*                                              
109    std::map<G4KDNode*, std::vector<_deq_iterat    
110    = fMap.begin();                                
111                                                   
112    for( ; fMap_it != fMap.end() ; fMap_it++)      
113    {                                              
114    std::vector<_deq_iterator>&  vit = fMap_it-    
115                                                   
116    G4KDNode* tmpNode = fMap_it->first;            
117                                                   
118    for(std::size_t i = 0 ; i < fSortOut.size()    
119    {                                              
120    G4cout << "i = " << i << G4endl;               
121    G4cout << "vit[i] = " << *(vit[i]) << G4end    
122    if(*(vit[i]) != tmpNode)                       
123    {                                              
124    G4cout << "!!!! Wrong iterator" << G4endl;     
125    abort();                                       
126    }                                              
127    }                                              
128                                                   
129    }                                              
130    */                                             
131                                                   
132   fIsSorted = false;                              
133 }                                                 
134                                                   
135 G4KDNode_Base* G4KDMap::PopOutMiddle(std::size    
136 {                                                 
137   G4cout << "_____________" << G4endl;            
138   G4cout << "G4KDMap::PopOutMiddle ( "<< dimen    
139                                                   
140   if(!fIsSorted) Sort();                          
141   G4KDNode_Base* output_node = fSortOut[dimens    
142                                                   
143   if(output_node == nullptr) return nullptr;      
144                                                   
145   G4cout << "output_node : " << output_node <<    
146   G4cout << "output_node : " << output_node->G    
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()" << G4en    
155      G4cout << "output_node = " << output_node    
156      return output_node;                          
157    }                                              
158                                                   
159   std::vector<_deq_iterator>& vit = fMap_it->s    
160                                                   
161   /*                                              
162    if(fMap_it->first != output_node)              
163    {                                              
164    G4cout << "fMap_it->first ! output_node"<<     
165    G4cout << "fMap_it->first = " << fMap_it->f    
166    abort();                                       
167    }                                              
168    */                                             
169                                                   
170   for(std::size_t i = 0; i < fSortOut.size();     
171   {                                               
172     if(i != dimension)                            
173     {                                             
174       G4cout << "i = " << i << G4endl;            
175                                                   
176       /*                                          
177        // G4cout << "i = " << i << G4endl;        
178        // G4cout << "vit[i] = " << *(vit[i]) <    
179        if(*(vit[i]) != output_node)               
180        {                                          
181        G4cout << "deleting wrong iterator" <<     
182        abort();                                   
183        }                                          
184        */                                         
185       fSortOut[i].Erase(vit[i]);                  
186     }                                             
187   }                                               
188                                                   
189   fMap.erase(fMap_it);                            
190                                                   
191   return output_node;                             
192 }                                                 
193                                                   
194 void G4KDMap::Sort()                              
195 {                                                 
196   for (auto & i : fSortOut)                       
197   {                                               
198     i.Sort();                                     
199   }                                               
200                                                   
201   fIsSorted = true;                               
202 }                                                 
203