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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/G4KDNode.cc (Version 11.3.0) and /processes/electromagnetic/dna/management/src/G4KDNode.cc (Version 10.4.p3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
                                                   >>  26 // $Id$
 26 //                                                 27 //
 27 // Author: Mathieu Karamitros (kara (AT) cenbg     28 // Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr) 
 28 //                                                 29 //
 29 // History:                                        30 // History:
 30 // -----------                                     31 // -----------
 31 // 10 Oct 2011 M.Karamitros created                32 // 10 Oct 2011 M.Karamitros created
 32 //                                                 33 //
 33 // -------------------------------------------     34 // -------------------------------------------------------------------
 34                                                    35 
 35 #include "globals.hh"                              36 #include "globals.hh"
 36 #include "G4KDNode.hh"                             37 #include "G4KDNode.hh"
 37 #include "G4KDTree.hh"                             38 #include "G4KDTree.hh"
 38 #include <ostream>                                 39 #include <ostream>
 39                                                    40 
 40 //********************************************     41 //*********************************************
 41                                                    42 
 42 //____________________________________________     43 //______________________________________________________________________
 43 // Node functions                                  44 // Node functions
 44                                                    45 
 45 //void* GetData(G4KDNode* node)                    46 //void* GetData(G4KDNode* node)
 46 //{                                                47 //{
 47 //  return node->GetData() ;                       48 //  return node->GetData() ;
 48 //}                                                49 //}
 49 //                                                 50 //
 50 //const double* GetNodePosition(G4KDNode* node     51 //const double* GetNodePosition(G4KDNode* node)
 51 //{                                                52 //{
 52 //  return node->GetPosition() ;                   53 //  return node->GetPosition() ;
 53 //}                                                54 //}
 54                                                    55 
 55 //____________________________________________     56 //______________________________________________________________________
 56                                                    57 
 57 void InactiveNode(G4KDNode_Base* node)             58 void InactiveNode(G4KDNode_Base* node)
 58 {                                                  59 {
 59   if(node == nullptr) return;                      60   if(node == nullptr) return;
 60 //  if(node->IsValid())                            61 //  if(node->IsValid())
 61   node->InactiveNode();                            62   node->InactiveNode();
 62 }                                                  63 }
 63                                                    64 
 64 void Free(G4KDNode_Base*& node)                    65 void Free(G4KDNode_Base*& node)
 65 {                                                  66 {
 66   delete node;                                 <<  67   if(node) delete node;
 67   node = nullptr;                                  68   node = nullptr;
 68 }                                                  69 }
 69                                                    70 
 70 //____________________________________________     71 //______________________________________________________________________
 71 G4KDNode_Base::G4KDNode_Base(G4KDTree* tree,       72 G4KDNode_Base::G4KDNode_Base(G4KDTree* tree,
 72     G4KDNode_Base* parent):                        73     G4KDNode_Base* parent):
 73                 fTree(tree),                       74                 fTree(tree),
 74                  fParent(parent)               <<  75                 fLeft(0), fRight(0), fParent(parent)
 75 {                                                  76 {
 76   fSide = 0;                                       77   fSide = 0;
 77   fAxis = fParent == nullptr? 0 : fParent->fAx <<  78   fAxis = fParent == 0? 0 : fParent->fAxis +1 < fTree->fDim? fParent->fAxis+1:0;
 78 }                                                  79 }
 79                                                    80 
 80 // Copy constructor should not be used             81 // Copy constructor should not be used
 81 G4KDNode_Base::G4KDNode_Base(const G4KDNode_Ba <<  82 G4KDNode_Base::G4KDNode_Base(const G4KDNode_Base& ):
                                                   >>  83                 fTree(0),
                                                   >>  84                 fLeft(0), fRight(0), fParent(0)
 82 {                                                  85 {
 83   fSide = 0;                                       86   fSide = 0;
 84   fAxis = 0;                                       87   fAxis = 0;
 85 }                                                  88 }
 86                                                    89 
 87 // Assignement should not be used                  90 // Assignement should not be used
 88 G4KDNode_Base& G4KDNode_Base::operator=(const      91 G4KDNode_Base& G4KDNode_Base::operator=(const G4KDNode_Base& right)
 89 {                                                  92 {
 90   if (this == &right) return *this;                93   if (this == &right) return *this;
 91   fTree = right.fTree;                             94   fTree = right.fTree;
 92   fLeft = right.fLeft;                             95   fLeft = right.fLeft;
 93   fRight = right.fRight;                           96   fRight = right.fRight;
 94   fParent = right.fParent;                         97   fParent = right.fParent;
 95   fSide = right.fSide;                             98   fSide = right.fSide;
 96   fAxis = right.fAxis;                             99   fAxis = right.fAxis;
 97   return *this;                                   100   return *this;
 98 }                                                 101 }
 99                                                   102 
100 G4KDNode_Base::~G4KDNode_Base()                   103 G4KDNode_Base::~G4KDNode_Base()
101 = default;                                     << 104 {
                                                   >> 105 }
102                                                   106 
103 void G4KDNode_Base::InactiveNode()                107 void G4KDNode_Base::InactiveNode()
104 {                                                 108 {
105   fTree->NoticeNodeDeactivation();                109   fTree->NoticeNodeDeactivation();
106 }                                                 110 }
107                                                   111 
108 G4int G4KDNode_Base::GetDim() const            << 112 int G4KDNode_Base::GetDim() const
109 {                                                 113 {
110   if(fTree != nullptr) return (G4int)fTree->Ge << 114   if(fTree)
111   return -1;                                   << 115     return fTree->GetDim();
                                                   >> 116   else
                                                   >> 117     return -1;
112 }                                                 118 }
113                                                   119 
114 G4int G4KDNode_Base::Insert(G4KDNode_Base* new << 120 int G4KDNode_Base::Insert(G4KDNode_Base* newNode)
115 {                                                 121 {
116   G4KDNode_Base* aParent = FindParent(*newNode    122   G4KDNode_Base* aParent = FindParent(*newNode);
117   // TODO check p == aParent->pos                 123   // TODO check p == aParent->pos
118   // Exception                                    124   // Exception
119                                                   125 
120   newNode->fAxis = aParent->fAxis +1 < fTree->    126   newNode->fAxis = aParent->fAxis +1 < fTree->GetDim()? aParent->fAxis+1:0;
121   newNode->fParent = aParent ;                    127   newNode->fParent = aParent ;
122                                                   128 
123   if((*newNode)[aParent->fAxis] > (*aParent)[a    129   if((*newNode)[aParent->fAxis] > (*aParent)[aParent->fAxis])
124   {                                               130   {
125     aParent->fRight = newNode ;                   131     aParent->fRight = newNode ;
126     newNode->fSide = 1 ;                          132     newNode->fSide = 1 ;
127   }                                               133   }
128   else                                            134   else
129   {                                               135   {
130     aParent->fLeft = newNode ;                    136     aParent->fLeft = newNode ;
131     newNode->fSide = -1 ;                         137     newNode->fSide = -1 ;
132   }                                               138   }
133                                                   139 
134   newNode->fRight = nullptr;                   << 140   newNode->fRight = 0;
135   newNode->fLeft = nullptr;                    << 141   newNode->fLeft = 0;
136                                                   142 
137   return 0 ;                                      143   return 0 ;
138 }                                                 144 }
139                                                   145 
140                                                   146 
141 void G4KDNode_Base::PullSubTree()                 147 void G4KDNode_Base::PullSubTree()
142 {                                                 148 {
143   if(fParent != nullptr)                       << 149   if(fParent)
144   {                                               150   {
145     if(fSide == -1)                               151     if(fSide == -1)
146     {                                             152     {
147       fParent->fLeft = nullptr;                << 153       fParent->fLeft = 0;
148     }                                             154     }
149     else                                          155     else
150       fParent->fRight = nullptr;               << 156       fParent->fRight = 0;
151   }                                               157   }
152   if(fLeft != nullptr) fLeft -> PullSubTree(); << 158   if(fLeft) fLeft -> PullSubTree();
153   if(fRight != nullptr) fRight-> PullSubTree() << 159   if(fRight) fRight-> PullSubTree();
154                                                   160 
155   fParent  = nullptr ;                         << 161   fParent  = 0 ;
156   fRight   = nullptr ;                         << 162   fRight   = 0 ;
157   fLeft    = nullptr ;                         << 163   fLeft    = 0 ;
158   fTree    = nullptr ;                         << 164   fTree    = 0 ;
159 }                                                 165 }
160                                                   166 
161 void G4KDNode_Base::RetrieveNodeList(std::list    167 void G4KDNode_Base::RetrieveNodeList(std::list<G4KDNode_Base *>& output)
162 {                                                 168 {
163   output.push_back(this);                         169   output.push_back(this);
164                                                   170 
165   if(fLeft != nullptr)                         << 171   if(fLeft)
166     fLeft->RetrieveNodeList(output);              172     fLeft->RetrieveNodeList(output);
167                                                   173 
168   if(fRight != nullptr)                        << 174   if(fRight)
169     fRight->RetrieveNodeList(output);             175     fRight->RetrieveNodeList(output);
170 }                                                 176 }
171                                                   177 
172 void G4KDNode_Base::Print(std::ostream& out, i    178 void G4KDNode_Base::Print(std::ostream& out, int level) const
173 {                                                 179 {
174   // Print node level                             180   // Print node level
175   out << G4endl;                                  181   out << G4endl;
176   for (G4int i=0; i<level; ++i)         // Ind << 182   for (int i=0; i<level; i++)         // Indent to level
177   {                                               183   {
178     out << "  ";                                  184     out << "  ";
179   }                                               185   }
180   out << level;                                   186   out << level;
181                                                   187 
182   // Print children                               188   // Print children
183   if(fLeft != nullptr)                         << 189   if(fLeft)
184   {                                               190   {
185     fLeft->Print(out, level + 1);                 191     fLeft->Print(out, level + 1);
186   }                                               192   }
187   if(fRight != nullptr)                        << 193   if(fRight)
188   {                                               194   {
189     fRight->Print(out, level + 1);                195     fRight->Print(out, level + 1);
190   }                                               196   }
191 }                                                 197 }
192                                                   198