Geant4  10.00.p02
G4KDNode.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: G4KDNode.hh 64057 2012-10-30 15:04:49Z gcosmo $
27 //
28 // Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
29 //
30 // WARNING : This class is released as a prototype.
31 // It might strongly evolve or even disapear in the next releases.
32 //
33 // History:
34 // -----------
35 // 10 Oct 2011 M.Karamitros created
36 //
37 // -------------------------------------------------------------------
38 
39 #ifndef G4KDNODE_HH
40 #define G4KDNODE_HH
41 
42 #include <list>
43 
44 class G4KDTree;
45 
50 class G4KDNode
51 {
52 
53 public :
54  // For root node :
55  // parent = 0, axis = 0, side = 0
56  G4KDNode(G4KDTree*, const double* /*position*/, void* /*data*/,
57  G4KDNode* /*parent*/, int axis0);
58  virtual ~G4KDNode();
59 
60  inline G4KDTree* GetTree();
61  inline void SetTree(G4KDTree*);
62 
63  inline const double* GetPosition();
64 
65  int GetDim();
66 
67  inline int GetAxis();
68  inline void* GetData();
69  inline void SetData(void*);
70  inline G4KDNode* GetParent();
71  inline G4KDNode* GetLeft();
72  inline G4KDNode* GetRight();
73 
74  G4KDNode* FindParent(const double* x0);
75  G4KDNode* Insert(const double* p, void* data);
76 
77  int Insert(G4KDNode* newNode, double* p);
78  int Insert(G4KDNode* newNode, const double& x, const double& y, const double& z);
79  int Insert(G4KDNode* newNode);
80 
81  void InactiveNode();
82  void PullSubTree();
83  void RetrieveNodeList(std::list<G4KDNode*>& node_list);
84 
85 protected :
86 
87  int SetPosition(const double* newposition);
88 
89  //°°°°°°°°°°°
90  // Members
91  //°°°°°°°°°°°
92  double* fPosition;
93  int fAxis; // axis : x, y, z ...
94  void *fData;
95  int fSide ; // left/right
96  /* fSide == 0 : Is the root node
97  * fSide == -1 : It is the left of the parent node
98  * fSide == 1 : It is the right of the parent node
99  */
100 
103  /* Left : fLeft->fPosition[axis] < this->fPosition[axis]
104  * Right : fRight->fPosition[axis] > this->fPosition[axis]
105  * Root node : fParent = 0
106  */
107 private :
108  G4KDNode(const G4KDNode& right);
109  G4KDNode& operator=(const G4KDNode& right);
110 };
111 
112 inline int G4KDNode::GetAxis()
113 {
114  return fAxis;
115 }
116 
117 inline void* G4KDNode::GetData()
118 {
119  return fData;
120 }
121 
122 inline void G4KDNode::SetData(void* data)
123 {
124  fData = data;
125 }
126 
127 inline const double* G4KDNode::GetPosition()
128 {
129  return fPosition;
130 }
131 
133 {
134  return fParent;
135 }
136 
138 {
139  return fLeft;
140 }
141 
143 {
144  return fRight;
145 }
146 
148 {
149  return fTree;
150 }
151 
152 inline void G4KDNode::SetTree(G4KDTree* tree)
153 {
154  fTree = tree;
155 }
156 
157 #endif // G4KDNODE_HH
int GetAxis()
Definition: G4KDNode.hh:112
void InactiveNode()
Definition: G4KDNode.cc:120
G4KDNode * fLeft
Definition: G4KDNode.hh:102
G4double z
Definition: TRTMaterials.hh:39
G4KDTree is used by the ITManager to locate the neareast neighbours.
Definition: G4KDTree.hh:62
int fAxis
Definition: G4KDNode.hh:93
G4KDNode * FindParent(const double *x0)
Definition: G4KDNode.cc:138
void RetrieveNodeList(std::list< G4KDNode * > &node_list)
Definition: G4KDNode.cc:240
G4KDNode * Insert(const double *p, void *data)
Definition: G4KDNode.cc:156
void * fData
Definition: G4KDNode.hh:94
double * fPosition
Definition: G4KDNode.hh:92
G4KDNode & operator=(const G4KDNode &right)
Definition: G4KDNode.cc:92
int fSide
Definition: G4KDNode.hh:95
G4KDNode * GetLeft()
Definition: G4KDNode.hh:137
G4KDTree * GetTree()
Definition: G4KDNode.hh:147
G4KDNode stores one entity in G4KDTree This class is for internal use only.
Definition: G4KDNode.hh:50
G4KDTree * fTree
Definition: G4KDNode.hh:101
G4KDNode * fParent
Definition: G4KDNode.hh:102
void * GetData()
Definition: G4KDNode.hh:117
G4KDNode * GetRight()
Definition: G4KDNode.hh:142
void SetTree(G4KDTree *)
Definition: G4KDNode.hh:152
void SetData(void *)
Definition: G4KDNode.hh:122
int SetPosition(const double *newposition)
Definition: G4KDNode.cc:125
const double * GetPosition()
Definition: G4KDNode.hh:127
virtual ~G4KDNode()
Definition: G4KDNode.cc:107
G4KDNode * fRight
Definition: G4KDNode.hh:102
G4KDNode(G4KDTree *, const double *, void *, G4KDNode *, int axis0)
Definition: G4KDNode.cc:71
void PullSubTree()
Definition: G4KDNode.cc:220
G4KDNode * GetParent()
Definition: G4KDNode.hh:132
int GetDim()
Definition: G4KDNode.cc:112