Geant4 11.2.2
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[] (std::size_t) const =0
 
virtual void InactiveNode ()
 
virtual bool IsValid () const
 
G4KDTreeGetTree () const
 
void SetTree (G4KDTree *tree)
 
G4int GetDim () const
 
G4int 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)
 
G4int Insert (G4KDNode_Base *newNode)
 
void PullSubTree ()
 
void RetrieveNodeList (std::list< G4KDNode_Base * > &node_list)
 
void Print (std::ostream &out, G4int level=0) const
 

Protected Attributes

std::size_t fAxis
 
G4int fSide
 
G4KDTreefTree {nullptr}
 
G4KDNode_BasefLeft {nullptr}
 
G4KDNode_BasefRight {nullptr}
 
G4KDNode_BasefParent {nullptr}
 

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 fParent(parent)
75{
76 fSide = 0;
77 fAxis = fParent == nullptr? 0 : fParent->fAxis +1 < fTree->fDim? fParent->fAxis+1:0;
78}
G4KDNode_Base * fParent
Definition G4KDNode.hh:116
G4KDTree * fTree
Definition G4KDNode.hh:115
std::size_t fAxis
Definition G4KDNode.hh:108
std::size_t fDim
Definition G4KDTree.hh:247

◆ ~G4KDNode_Base()

G4KDNode_Base::~G4KDNode_Base ( )
virtualdefault

Member Function Documentation

◆ FindParent()

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

Referenced by Insert().

◆ GetAxis()

G4int G4KDNode_Base::GetAxis ( ) const
inline

Definition at line 79 of file G4KDNode.hh.

79{return (G4int)fAxis;}
int G4int
Definition G4Types.hh:85

Referenced by G4KDMap::PopOutMiddle().

◆ GetDim()

G4int G4KDNode_Base::GetDim ( ) const

Definition at line 108 of file G4KDNode.cc.

109{
110 if(fTree != nullptr) return (G4int)fTree->GetDim();
111 return -1;
112}
std::size_t GetDim() const
Definition G4KDTree.hh:90

◆ GetLeft()

G4KDNode_Base * G4KDNode_Base::GetLeft ( )
inline

Definition at line 81 of file G4KDNode.hh.

81{return fLeft;}
G4KDNode_Base * fLeft
Definition G4KDNode.hh:116

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;}
G4KDNode_Base * fRight
Definition G4KDNode.hh:116

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]

G4int G4KDNode_Base::Insert ( G4KDNode_Base * newNode)

Definition at line 114 of file G4KDNode.cc.

115{
116 G4KDNode_Base* aParent = FindParent(*newNode);
117 // TODO check p == aParent->pos
118 // Exception
119
120 newNode->fAxis = aParent->fAxis +1 < fTree->GetDim()? aParent->fAxis+1:0;
121 newNode->fParent = aParent ;
122
123 if((*newNode)[aParent->fAxis] > (*aParent)[aParent->fAxis])
124 {
125 aParent->fRight = newNode ;
126 newNode->fSide = 1 ;
127 }
128 else
129 {
130 aParent->fLeft = newNode ;
131 newNode->fSide = -1 ;
132 }
133
134 newNode->fRight = nullptr;
135 newNode->fLeft = nullptr;
136
137 return 0 ;
138}
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[] ( std::size_t ) const
pure virtual

◆ Print()

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

Definition at line 172 of file G4KDNode.cc.

173{
174 // Print node level
175 out << G4endl;
176 for (G4int i=0; i<level; ++i) // Indent to level
177 {
178 out << " ";
179 }
180 out << level;
181
182 // Print children
183 if(fLeft != nullptr)
184 {
185 fLeft->Print(out, level + 1);
186 }
187 if(fRight != nullptr)
188 {
189 fRight->Print(out, level + 1);
190 }
191}
#define G4endl
Definition G4ios.hh:67
void Print(std::ostream &out, G4int level=0) const
Definition G4KDNode.cc:172

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

◆ PullSubTree()

void G4KDNode_Base::PullSubTree ( )

Definition at line 141 of file G4KDNode.cc.

142{
143 if(fParent != nullptr)
144 {
145 if(fSide == -1)
146 {
147 fParent->fLeft = nullptr;
148 }
149 else
150 fParent->fRight = nullptr;
151 }
152 if(fLeft != nullptr) fLeft -> PullSubTree();
153 if(fRight != nullptr) fRight-> PullSubTree();
154
155 fParent = nullptr ;
156 fRight = nullptr ;
157 fLeft = nullptr ;
158 fTree = nullptr ;
159}
void PullSubTree()
Definition G4KDNode.cc:141

Referenced by PullSubTree().

◆ RetrieveNodeList()

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

Definition at line 161 of file G4KDNode.cc.

162{
163 output.push_back(this);
164
165 if(fLeft != nullptr)
166 fLeft->RetrieveNodeList(output);
167
168 if(fRight != nullptr)
169 fRight->RetrieveNodeList(output);
170}
void RetrieveNodeList(std::list< G4KDNode_Base * > &node_list)
Definition G4KDNode.cc:161

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

std::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 {nullptr}
protected

Definition at line 116 of file G4KDNode.hh.

116{nullptr}, *fRight{nullptr}, *fParent{nullptr};

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

◆ fParent

G4KDNode_Base * G4KDNode_Base::fParent {nullptr}
protected

Definition at line 116 of file G4KDNode.hh.

116{nullptr}, *fRight{nullptr}, *fParent{nullptr};

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

◆ fRight

G4KDNode_Base * G4KDNode_Base::fRight {nullptr}
protected

Definition at line 116 of file G4KDNode.hh.

116{nullptr}, *fRight{nullptr}, *fParent{nullptr};

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

◆ fSide

G4int G4KDNode_Base::fSide
protected

Definition at line 109 of file G4KDNode.hh.

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

◆ fTree

G4KDTree* G4KDNode_Base::fTree {nullptr}
protected

Definition at line 115 of file G4KDNode.hh.

115{nullptr};

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


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