Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4KDNode_Base Class Referenceabstract

#include <G4KDNode.hh>

+ Inheritance 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
 

Detailed Description

Definition at line 61 of file G4KDNode.hh.

Constructor & Destructor Documentation

◆ G4KDNode_Base()

G4KDNode_Base::G4KDNode_Base ( G4KDTree tree,
G4KDNode_Base parent 
)

Definition at line 71 of file G4KDNode.cc.

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

◆ ~G4KDNode_Base()

G4KDNode_Base::~G4KDNode_Base ( )
virtual

Definition at line 102 of file G4KDNode.cc.

103{
104}

Member Function Documentation

◆ FindParent()

template<typename Position >
G4KDNode_Base * G4KDNode_Base::FindParent ( const Position &  x0)

Referenced by Insert().

◆ GetAxis()

int G4KDNode_Base::GetAxis ( ) const
inline

Definition at line 79 of file G4KDNode.hh.

79{return fAxis;}

Referenced by G4KDMap::PopOutMiddle().

◆ GetDim()

int G4KDNode_Base::GetDim ( ) const

Definition at line 111 of file G4KDNode.cc.

112{
113 if(fTree)
114 return fTree->GetDim();
115 else
116 return -1;
117}
size_t GetDim() const
Definition: G4KDTree.hh:86

◆ GetLeft()

G4KDNode_Base * G4KDNode_Base::GetLeft ( )
inline

Definition at line 81 of file G4KDNode.hh.

81{return fLeft;}

Referenced by G4KDTree::__Clear_Rec().

◆ GetParent()

G4KDNode_Base * G4KDNode_Base::GetParent ( )
inline

Definition at line 80 of file G4KDNode.hh.

80{return fParent;}

◆ GetRight()

G4KDNode_Base * G4KDNode_Base::GetRight ( )
inline

Definition at line 82 of file G4KDNode.hh.

82{return fRight;}

Referenced by G4KDTree::__Clear_Rec().

◆ GetTree()

G4KDTree * G4KDNode_Base::GetTree ( ) const
inline

Definition at line 74 of file G4KDNode.hh.

74{return fTree;}

◆ InactiveNode()

void G4KDNode_Base::InactiveNode ( )
virtual

◆ Insert() [1/3]

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

◆ Insert() [2/3]

int G4KDNode_Base::Insert ( G4KDNode_Base newNode)

Definition at line 119 of file G4KDNode.cc.

120{
121 G4KDNode_Base* aParent = FindParent(*newNode);
122 // TODO check p == aParent->pos
123 // Exception
124
125 newNode->fAxis = aParent->fAxis +1 < fTree->GetDim()? aParent->fAxis+1:0;
126 newNode->fParent = aParent ;
127
128 if((*newNode)[aParent->fAxis] > (*aParent)[aParent->fAxis])
129 {
130 aParent->fRight = newNode ;
131 newNode->fSide = 1 ;
132 }
133 else
134 {
135 aParent->fLeft = newNode ;
136 newNode->fSide = -1 ;
137 }
138
139 newNode->fRight = 0;
140 newNode->fLeft = 0;
141
142 return 0 ;
143}
G4KDNode_Base * FindParent(const Position &x0)

◆ Insert() [3/3]

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

Referenced by G4KDTree::Build().

◆ IsValid()

virtual bool G4KDNode_Base::IsValid ( ) const
inlinevirtual

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

Definition at line 71 of file G4KDNode.hh.

71{ return true; }

◆ 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 177 of file G4KDNode.cc.

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

Referenced by Print(), and G4KDTree::Print().

◆ PullSubTree()

void G4KDNode_Base::PullSubTree ( )

Definition at line 146 of file G4KDNode.cc.

147{
148 if(fParent)
149 {
150 if(fSide == -1)
151 {
152 fParent->fLeft = 0;
153 }
154 else
155 fParent->fRight = 0;
156 }
157 if(fLeft) fLeft -> PullSubTree();
158 if(fRight) fRight-> PullSubTree();
159
160 fParent = 0 ;
161 fRight = 0 ;
162 fLeft = 0 ;
163 fTree = 0 ;
164}
void PullSubTree()
Definition: G4KDNode.cc:146

Referenced by PullSubTree().

◆ RetrieveNodeList()

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

Definition at line 166 of file G4KDNode.cc.

167{
168 output.push_back(this);
169
170 if(fLeft)
171 fLeft->RetrieveNodeList(output);
172
173 if(fRight)
174 fRight->RetrieveNodeList(output);
175}
void RetrieveNodeList(std::list< G4KDNode_Base * > &node_list)
Definition: G4KDNode.cc:166

Referenced by RetrieveNodeList().

◆ SetTree()

void G4KDNode_Base::SetTree ( G4KDTree tree)
inline

Definition at line 75 of file G4KDNode.hh.

75{fTree = tree;}

Member Data Documentation

◆ fAxis

size_t G4KDNode_Base::fAxis
protected

Definition at line 108 of file G4KDNode.hh.

Referenced by G4KDNode_Base(), GetAxis(), and Insert().

◆ fLeft

G4KDNode_Base* G4KDNode_Base::fLeft
protected

Definition at line 116 of file G4KDNode.hh.

Referenced by GetLeft(), Insert(), Print(), PullSubTree(), and RetrieveNodeList().

◆ fParent

G4KDNode_Base * G4KDNode_Base::fParent
protected

Definition at line 116 of file G4KDNode.hh.

Referenced by G4KDNode_Base(), GetParent(), Insert(), and PullSubTree().

◆ fRight

G4KDNode_Base * G4KDNode_Base::fRight
protected

Definition at line 116 of file G4KDNode.hh.

Referenced by GetRight(), Insert(), Print(), PullSubTree(), and RetrieveNodeList().

◆ fSide

int G4KDNode_Base::fSide
protected

Definition at line 109 of file G4KDNode.hh.

Referenced by G4KDNode_Base(), Insert(), and PullSubTree().

◆ fTree

G4KDTree* G4KDNode_Base::fTree
protected

Definition at line 115 of file G4KDNode.hh.

Referenced by G4KDNode_Base(), GetDim(), GetTree(), InactiveNode(), Insert(), PullSubTree(), and SetTree().


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