Geant4-11
Public Member Functions | Protected Attributes | Private Member Functions
G4KDNode_Base Class Referenceabstract

#include <G4KDNode.hh>

Inheritance diagram for G4KDNode_Base:
G4KDNode< PointT > G4KDNodeCopy< PointCopyT >

Public Member Functions

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

Protected Attributes

size_t fAxis
 
G4KDNode_BasefLeft
 
G4KDNode_BasefParent
 
G4KDNode_BasefRight
 
int fSide
 
G4KDTreefTree
 

Private Member Functions

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

Detailed Description

Definition at line 61 of file G4KDNode.hh.

Constructor & Destructor Documentation

◆ G4KDNode_Base() [1/2]

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

References fAxis, G4KDTree::fDim, fParent, fSide, and fTree.

◆ ~G4KDNode_Base()

G4KDNode_Base::~G4KDNode_Base ( )
virtual

Definition at line 102 of file G4KDNode.cc.

103{
104}

◆ G4KDNode_Base() [2/2]

G4KDNode_Base::G4KDNode_Base ( const G4KDNode_Base right)
private

Definition at line 81 of file G4KDNode.cc.

81 :
82 fTree(0),
83 fLeft(0), fRight(0), fParent(0)
84{
85 fSide = 0;
86 fAxis = 0;
87}

References fAxis, and fSide.

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;}

References 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

References fTree, and G4KDTree::GetDim().

◆ GetLeft()

G4KDNode_Base * G4KDNode_Base::GetLeft ( )
inline

Definition at line 81 of file G4KDNode.hh.

81{return fLeft;}

References fLeft.

Referenced by G4KDTree::__Clear_Rec().

◆ GetParent()

G4KDNode_Base * G4KDNode_Base::GetParent ( )
inline

Definition at line 80 of file G4KDNode.hh.

80{return fParent;}

References fParent.

◆ GetRight()

G4KDNode_Base * G4KDNode_Base::GetRight ( )
inline

Definition at line 82 of file G4KDNode.hh.

82{return fRight;}

References fRight.

Referenced by G4KDTree::__Clear_Rec().

◆ GetTree()

G4KDTree * G4KDNode_Base::GetTree ( ) const
inline

Definition at line 74 of file G4KDNode.hh.

74{return fTree;}

References 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)

References fAxis, FindParent(), fLeft, fParent, fRight, fSide, fTree, and G4KDTree::GetDim().

◆ Insert() [3/3]

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

Referenced by G4KDTree::Build().

◆ IsValid()

virtual bool G4KDNode_Base::IsValid ( void  ) const
inlinevirtual

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

Definition at line 71 of file G4KDNode.hh.

71{ return true; }

◆ operator=()

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

Definition at line 90 of file G4KDNode.cc.

91{
92 if (this == &right) return *this;
93 fTree = right.fTree;
94 fLeft = right.fLeft;
95 fRight = right.fRight;
96 fParent = right.fParent;
97 fSide = right.fSide;
98 fAxis = right.fAxis;
99 return *this;
100}

References fAxis, fLeft, fParent, fRight, fSide, and fTree.

◆ 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

References fLeft, fRight, G4endl, and Print().

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

References fLeft, fParent, fRight, fSide, fTree, and PullSubTree().

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

References fLeft, fRight, and RetrieveNodeList().

Referenced by RetrieveNodeList().

◆ SetTree()

void G4KDNode_Base::SetTree ( G4KDTree tree)
inline

Definition at line 75 of file G4KDNode.hh.

75{fTree = tree;}

References fTree.

Field Documentation

◆ fAxis

size_t G4KDNode_Base::fAxis
protected

◆ fLeft

G4KDNode_Base* G4KDNode_Base::fLeft
protected

◆ fParent

G4KDNode_Base * G4KDNode_Base::fParent
protected

◆ fRight

G4KDNode_Base * G4KDNode_Base::fRight
protected

◆ fSide

int G4KDNode_Base::fSide
protected

◆ fTree

G4KDTree* G4KDNode_Base::fTree
protected

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