Geant4  10.02.p03
G4KDNode_Base Class Referenceabstract

#include <G4KDNode.hh>

Inheritance diagram for G4KDNode_Base:
Collaboration diagram for G4KDNode_Base:

Public Member Functions

 G4KDNode_Base (G4KDTree *, G4KDNode_Base *)
 
virtual ~G4KDNode_Base ()
 
virtual double operator[] (size_t) const =0
 
virtual void InactiveNode ()
 
virtual bool IsValid () const
 
G4KDTreeGetTree () const
 
void SetTree (G4KDTree *tree)
 
int GetDim () const
 
int GetAxis () const
 
G4KDNode_BaseGetParent ()
 
G4KDNode_BaseGetLeft ()
 
G4KDNode_BaseGetRight ()
 
template<typename Position >
G4KDNode_BaseFindParent (const Position &x0)
 
template<typename PointT >
G4KDNode_BaseInsert (PointT *point)
 
template<typename PointT >
G4KDNode_BaseInsert (const PointT &point)
 
int Insert (G4KDNode_Base *newNode)
 
void PullSubTree ()
 
void RetrieveNodeList (std::list< G4KDNode_Base *> &node_list)
 
void Print (std::ostream &out, int level=0) const
 

Protected Attributes

size_t fAxis
 
int fSide
 
G4KDTreefTree
 
G4KDNode_BasefLeft
 
G4KDNode_BasefRight
 
G4KDNode_BasefParent
 

Private Member Functions

 G4KDNode_Base (const G4KDNode_Base &right)
 
G4KDNode_Baseoperator= (const G4KDNode_Base &right)
 

Detailed Description

Definition at line 63 of file G4KDNode.hh.

Constructor & Destructor Documentation

◆ G4KDNode_Base() [1/2]

G4KDNode_Base::G4KDNode_Base ( G4KDTree tree,
G4KDNode_Base parent 
)

Definition at line 72 of file G4KDNode.cc.

73  :
74  fTree(tree),
75  fLeft(0), fRight(0), fParent(parent)
76 {
77  fSide = 0;
78  fAxis = fParent == 0? 0 : fParent->fAxis +1 < fTree->fDim? fParent->fAxis+1:0;
79 }
G4KDNode_Base * fLeft
Definition: G4KDNode.hh:116
size_t fDim
Definition: G4KDTree.hh:270
size_t fAxis
Definition: G4KDNode.hh:108
G4KDNode_Base * fParent
Definition: G4KDNode.hh:116
G4KDTree * fTree
Definition: G4KDNode.hh:115
G4KDNode_Base * fRight
Definition: G4KDNode.hh:116

◆ ~G4KDNode_Base()

G4KDNode_Base::~G4KDNode_Base ( )
virtual

Definition at line 103 of file G4KDNode.cc.

104 {
105 }

◆ G4KDNode_Base() [2/2]

G4KDNode_Base::G4KDNode_Base ( const G4KDNode_Base right)
private

Definition at line 82 of file G4KDNode.cc.

82  :
83  fTree(0),
84  fLeft(0), fRight(0), fParent(0)
85 {
86  fSide = 0;
87  fAxis = 0;
88 }
G4KDNode_Base * fLeft
Definition: G4KDNode.hh:116
size_t fAxis
Definition: G4KDNode.hh:108
G4KDNode_Base * fParent
Definition: G4KDNode.hh:116
G4KDTree * fTree
Definition: G4KDNode.hh:115
G4KDNode_Base * fRight
Definition: G4KDNode.hh:116

Member Function Documentation

◆ FindParent()

template<typename Position >
G4KDNode_Base* G4KDNode_Base::FindParent ( const Position &  x0)
Here is the caller graph for this function:

◆ GetAxis()

int G4KDNode_Base::GetAxis ( ) const
inline

Definition at line 81 of file G4KDNode.hh.

81 {return fAxis;}
size_t fAxis
Definition: G4KDNode.hh:108
Here is the caller graph for this function:

◆ GetDim()

int G4KDNode_Base::GetDim ( ) const

Definition at line 112 of file G4KDNode.cc.

113 {
114  if(fTree)
115  return fTree->GetDim();
116  else
117  return -1;
118 }
size_t GetDim() const
Definition: G4KDTree.hh:88
G4KDTree * fTree
Definition: G4KDNode.hh:115
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetLeft()

G4KDNode_Base* G4KDNode_Base::GetLeft ( )
inline

Definition at line 83 of file G4KDNode.hh.

83 {return fLeft;}
G4KDNode_Base * fLeft
Definition: G4KDNode.hh:116
Here is the caller graph for this function:

◆ GetParent()

G4KDNode_Base* G4KDNode_Base::GetParent ( )
inline

Definition at line 82 of file G4KDNode.hh.

82 {return fParent;}
G4KDNode_Base * fParent
Definition: G4KDNode.hh:116

◆ GetRight()

G4KDNode_Base* G4KDNode_Base::GetRight ( )
inline

Definition at line 84 of file G4KDNode.hh.

84 {return fRight;}
G4KDNode_Base * fRight
Definition: G4KDNode.hh:116
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTree()

G4KDTree* G4KDNode_Base::GetTree ( ) const
inline

Definition at line 76 of file G4KDNode.hh.

76 {return fTree;}
G4KDTree * fTree
Definition: G4KDNode.hh:115

◆ InactiveNode()

void G4KDNode_Base::InactiveNode ( )
virtual

Reimplemented in G4KDNodeCopy< PointCopyT >, and G4KDNode< PointT >.

Definition at line 107 of file G4KDNode.cc.

108 {
110 }
G4KDTree * fTree
Definition: G4KDNode.hh:115
void NoticeNodeDeactivation()
Definition: G4KDTree.hh:82
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Insert() [1/3]

template<typename PointT >
G4KDNode_Base* G4KDNode_Base::Insert ( PointT *  point)
Here is the caller graph for this function:

◆ Insert() [2/3]

template<typename PointT >
G4KDNode_Base* G4KDNode_Base::Insert ( const PointT &  point)

◆ Insert() [3/3]

int G4KDNode_Base::Insert ( G4KDNode_Base newNode)

Definition at line 120 of file G4KDNode.cc.

121 {
122  G4KDNode_Base* aParent = FindParent(*newNode);
123  // TODO check p == aParent->pos
124  // Exception
125 
126  newNode->fAxis = aParent->fAxis +1 < fTree->GetDim()? aParent->fAxis+1:0;
127  newNode->fParent = aParent ;
128 
129  if((*newNode)[aParent->fAxis] > (*aParent)[aParent->fAxis])
130  {
131  aParent->fRight = newNode ;
132  newNode->fSide = 1 ;
133  }
134  else
135  {
136  aParent->fLeft = newNode ;
137  newNode->fSide = -1 ;
138  }
139 
140  newNode->fRight = 0;
141  newNode->fLeft = 0;
142 
143  return 0 ;
144 }
G4KDNode_Base * fLeft
Definition: G4KDNode.hh:116
size_t GetDim() const
Definition: G4KDTree.hh:88
size_t fAxis
Definition: G4KDNode.hh:108
G4KDNode_Base * FindParent(const Position &x0)
G4KDNode_Base * fParent
Definition: G4KDNode.hh:116
G4KDTree * fTree
Definition: G4KDNode.hh:115
G4KDNode_Base * fRight
Definition: G4KDNode.hh:116
Here is the call graph for this function:

◆ IsValid()

virtual bool G4KDNode_Base::IsValid ( void  ) const
inlinevirtual

Reimplemented in G4KDNodeCopy< PointCopyT >, and G4KDNode< PointT >.

Definition at line 73 of file G4KDNode.hh.

73 { return true; }

◆ operator=()

G4KDNode_Base & G4KDNode_Base::operator= ( const G4KDNode_Base right)
private

Definition at line 91 of file G4KDNode.cc.

92 {
93  if (this == &right) return *this;
94  fTree = right.fTree;
95  fLeft = right.fLeft;
96  fRight = right.fRight;
97  fParent = right.fParent;
98  fSide = right.fSide;
99  fAxis = right.fAxis;
100  return *this;
101 }
G4KDNode_Base * fLeft
Definition: G4KDNode.hh:116
size_t fAxis
Definition: G4KDNode.hh:108
G4KDNode_Base * fParent
Definition: G4KDNode.hh:116
G4KDTree * fTree
Definition: G4KDNode.hh:115
G4KDNode_Base * fRight
Definition: G4KDNode.hh:116

◆ operator[]()

virtual double G4KDNode_Base::operator[] ( size_t  ) const
pure virtual

◆ Print()

void G4KDNode_Base::Print ( std::ostream &  out,
int  level = 0 
) const

Definition at line 178 of file G4KDNode.cc.

179 {
180  // Print node level
181  out << G4endl;
182  for (int i=0; i<level; i++) // Indent to level
183  {
184  out << " ";
185  }
186  out << level;
187 
188  // Print children
189  if(fLeft)
190  {
191  fLeft->Print(out, level + 1);
192  }
193  if(fRight)
194  {
195  fRight->Print(out, level + 1);
196  }
197 }
G4KDNode_Base * fLeft
Definition: G4KDNode.hh:116
void Print(std::ostream &out, int level=0) const
Definition: G4KDNode.cc:178
#define G4endl
Definition: G4ios.hh:61
G4KDNode_Base * fRight
Definition: G4KDNode.hh:116
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PullSubTree()

void G4KDNode_Base::PullSubTree ( )

Definition at line 147 of file G4KDNode.cc.

148 {
149  if(fParent)
150  {
151  if(fSide == -1)
152  {
153  fParent->fLeft = 0;
154  }
155  else
156  fParent->fRight = 0;
157  }
158  if(fLeft) fLeft -> PullSubTree();
159  if(fRight) fRight-> PullSubTree();
160 
161  fParent = 0 ;
162  fRight = 0 ;
163  fLeft = 0 ;
164  fTree = 0 ;
165 }
G4KDNode_Base * fLeft
Definition: G4KDNode.hh:116
G4KDNode_Base * fParent
Definition: G4KDNode.hh:116
void PullSubTree()
Definition: G4KDNode.cc:147
G4KDTree * fTree
Definition: G4KDNode.hh:115
G4KDNode_Base * fRight
Definition: G4KDNode.hh:116
Here is the caller graph for this function:

◆ RetrieveNodeList()

void G4KDNode_Base::RetrieveNodeList ( std::list< G4KDNode_Base *> &  node_list)

Definition at line 167 of file G4KDNode.cc.

168 {
169  output.push_back(this);
170 
171  if(fLeft)
172  fLeft->RetrieveNodeList(output);
173 
174  if(fRight)
175  fRight->RetrieveNodeList(output);
176 }
G4KDNode_Base * fLeft
Definition: G4KDNode.hh:116
void RetrieveNodeList(std::list< G4KDNode_Base *> &node_list)
Definition: G4KDNode.cc:167
G4KDNode_Base * fRight
Definition: G4KDNode.hh:116
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetTree()

void G4KDNode_Base::SetTree ( G4KDTree tree)
inline

Definition at line 77 of file G4KDNode.hh.

77 {fTree = tree;}
G4KDTree * fTree
Definition: G4KDNode.hh:115
Here is the call graph for this function:

Member Data Documentation

◆ fAxis

size_t G4KDNode_Base::fAxis
protected

Definition at line 108 of file G4KDNode.hh.

◆ fLeft

G4KDNode_Base* G4KDNode_Base::fLeft
protected

Definition at line 116 of file G4KDNode.hh.

◆ fParent

G4KDNode_Base * G4KDNode_Base::fParent
protected

Definition at line 116 of file G4KDNode.hh.

◆ fRight

G4KDNode_Base * G4KDNode_Base::fRight
protected

Definition at line 116 of file G4KDNode.hh.

◆ fSide

int G4KDNode_Base::fSide
protected

Definition at line 109 of file G4KDNode.hh.

◆ fTree

G4KDTree* G4KDNode_Base::fTree
protected

Definition at line 115 of file G4KDNode.hh.


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