G4KDNode.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // $Id: G4KDNode.hh 64057 2012-10-30 15:04:49Z gcosmo $
00027 //
00028 // Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr) 
00029 //
00030 // WARNING : This class is released as a prototype.
00031 // It might strongly evolve or even disapear in the next releases.
00032 //
00033 // History:
00034 // -----------
00035 // 10 Oct 2011 M.Karamitros created
00036 //
00037 // -------------------------------------------------------------------
00038 
00039 #ifndef G4KDNODE_HH
00040 #define G4KDNODE_HH
00041 
00042 #include <list>
00043 
00044 class G4KDTree;
00045 
00050 class G4KDNode
00051 {
00052 
00053 public :
00054     // For root node :
00055     // parent = 0, axis = 0, side = 0
00056     G4KDNode(G4KDTree*, const double* /*position*/, void* /*data*/,
00057              G4KDNode* /*parent*/, int axis0);
00058     virtual ~G4KDNode();
00059 
00060     inline G4KDTree* GetTree();
00061     inline void SetTree(G4KDTree*);
00062 
00063     inline const double* GetPosition();
00064 
00065     int GetDim();
00066 
00067     inline int       GetAxis();
00068     inline void*     GetData();
00069     inline void      SetData(void*);
00070     inline G4KDNode* GetParent();
00071     inline G4KDNode* GetLeft();
00072     inline G4KDNode* GetRight();
00073 
00074     G4KDNode* FindParent(const double* x0);
00075     G4KDNode* Insert(const double* p, void* data);
00076 
00077     int Insert(G4KDNode* newNode, double* p);
00078     int Insert(G4KDNode* newNode, const double& x, const double& y, const double& z);
00079     int Insert(G4KDNode* newNode);
00080 
00081     void InactiveNode();
00082     void PullSubTree();
00083     void RetrieveNodeList(std::list<G4KDNode*>& node_list);
00084 
00085 protected :
00086 
00087     int SetPosition(const double* newposition);
00088 
00089     //°°°°°°°°°°°
00090     // Members
00091     //°°°°°°°°°°°
00092     double* fPosition;
00093     int fAxis;              // axis : x, y, z ...
00094     void *fData;
00095     int fSide ;             // left/right
00096     /* fSide == 0  : Is the root node
00097      * fSide == -1 : It is the left of the parent node
00098      * fSide == 1  : It is the right of the parent node
00099      */
00100 
00101     G4KDTree* fTree ;
00102     G4KDNode *fLeft, *fRight, *fParent;
00103     /* Left : fLeft->fPosition[axis] < this->fPosition[axis]
00104      * Right : fRight->fPosition[axis] > this->fPosition[axis]
00105      * Root node : fParent = 0
00106      */
00107 private :
00108     G4KDNode(const G4KDNode& right);
00109     G4KDNode& operator=(const G4KDNode& right);
00110 };
00111 
00112 inline int G4KDNode::GetAxis()
00113 {
00114     return fAxis;
00115 }
00116 
00117 inline void* G4KDNode::GetData()
00118 {
00119     return fData;
00120 }
00121 
00122 inline void  G4KDNode::SetData(void* data)
00123 {
00124     fData = data;
00125 }
00126 
00127 inline const double* G4KDNode::GetPosition()
00128 {
00129     return fPosition;
00130 }
00131 
00132 inline G4KDNode* G4KDNode::GetParent()
00133 {
00134     return fParent;
00135 }
00136 
00137 inline G4KDNode* G4KDNode::GetLeft()
00138 {
00139     return fLeft;
00140 }
00141 
00142 inline G4KDNode* G4KDNode::GetRight()
00143 {
00144     return fRight;
00145 }
00146 
00147 inline G4KDTree* G4KDNode::GetTree()
00148 {
00149     return fTree;
00150 }
00151 
00152 inline void G4KDNode::SetTree(G4KDTree* tree)
00153 {
00154     fTree = tree;
00155 }
00156 
00157 #endif // G4KDNODE_HH

Generated on Mon May 27 17:48:43 2013 for Geant4 by  doxygen 1.4.7