Geant4-11
Public Member Functions | Protected Attributes | Private Member Functions | Static Private Attributes
G4KDNode< PointT > Class Template Reference

#include <G4KDNode.hh>

Inheritance diagram for G4KDNode< PointT >:
G4KDNode_Base

Public Member Functions

template<typename Position >
G4KDNode_BaseFindParent (const Position &x0)
 
 G4KDNode (G4KDTree *, PointT *, G4KDNode_Base *)
 
int GetAxis () const
 
int GetDim () const
 
G4KDNode_BaseGetLeft ()
 
G4KDNode_BaseGetParent ()
 
PointT * GetPoint ()
 
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
 
void operator delete (void *)
 
void * operator new (size_t)
 
virtual double operator[] (size_t i) const
 
void Print (std::ostream &out, int level=0) const
 
void PullSubTree ()
 
void RetrieveNodeList (std::list< G4KDNode_Base * > &node_list)
 
void SetTree (G4KDTree *tree)
 
 ~G4KDNode ()
 
virtual ~G4KDNode ()
 
 ~G4KDNode ()
 
 ~G4KDNode ()
 
 ~G4KDNode ()
 

Protected Attributes

size_t fAxis
 
G4KDNode_BasefLeft
 
G4KDNode_BasefParent
 
PointT * fPoint
 
G4KDNode_BasefRight
 
int fSide
 
G4KDTreefTree
 
bool fValid
 

Private Member Functions

 G4KDNode (const G4KDNode< PointT > &right)
 
G4KDNodeoperator= (const G4KDNode< PointT > &right)
 

Static Private Attributes

static G4ThreadLocal G4Allocator< G4KDNode< PointT > > * fgAllocator = 0
 

Detailed Description

template<typename PointT>
class G4KDNode< PointT >

G4KDNode stores one entity in G4KDTree This class is for internal use only

Definition at line 132 of file G4KDNode.hh.

Constructor & Destructor Documentation

◆ G4KDNode() [1/2]

template<typename PointT >
G4KDNode< PointT >::G4KDNode ( G4KDTree ,
PointT *  ,
G4KDNode_Base  
)

◆ ~G4KDNode() [1/5]

template<typename PointT >
virtual G4KDNode< PointT >::~G4KDNode ( )
virtual

◆ G4KDNode() [2/2]

template<typename PointT >
G4KDNode< PointT >::G4KDNode ( const G4KDNode< PointT > &  right)
private

◆ ~G4KDNode() [2/5]

◆ ~G4KDNode() [3/5]

Definition at line 59 of file G4IT.cc.

59 {
60 fPoint->SetNode(nullptr);
61}
PointT * fPoint
Definition: G4KDNode.hh:167

◆ ~G4KDNode() [4/5]

◆ ~G4KDNode() [5/5]

Definition at line 70 of file G4Molecule.cc.

70 {
71 fPoint->SetNode(nullptr);
72}

Member Function Documentation

◆ FindParent()

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

Referenced by G4KDNode_Base::Insert().

◆ GetAxis()

int G4KDNode_Base::GetAxis ( ) const
inlineinherited

Definition at line 79 of file G4KDNode.hh.

79{return fAxis;}
size_t fAxis
Definition: G4KDNode.hh:108

References G4KDNode_Base::fAxis.

Referenced by G4KDMap::PopOutMiddle().

◆ GetDim()

int G4KDNode_Base::GetDim ( ) const
inherited

Definition at line 111 of file G4KDNode.cc.

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

References G4KDNode_Base::fTree, and G4KDTree::GetDim().

◆ GetLeft()

G4KDNode_Base * G4KDNode_Base::GetLeft ( )
inlineinherited

Definition at line 81 of file G4KDNode.hh.

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

References G4KDNode_Base::fLeft.

Referenced by G4KDTree::__Clear_Rec().

◆ GetParent()

G4KDNode_Base * G4KDNode_Base::GetParent ( )
inlineinherited

Definition at line 80 of file G4KDNode.hh.

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

References G4KDNode_Base::fParent.

◆ GetPoint()

template<typename PointT >
PointT * G4KDNode< PointT >::GetPoint ( )
inline

Definition at line 144 of file G4KDNode.hh.

145 {
146 return fPoint;
147 }

References G4KDNode< PointT >::fPoint.

Referenced by G4KDTreeResult::GetItem().

◆ GetRight()

G4KDNode_Base * G4KDNode_Base::GetRight ( )
inlineinherited

Definition at line 82 of file G4KDNode.hh.

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

References G4KDNode_Base::fRight.

Referenced by G4KDTree::__Clear_Rec().

◆ GetTree()

G4KDTree * G4KDNode_Base::GetTree ( ) const
inlineinherited

Definition at line 74 of file G4KDNode.hh.

74{return fTree;}

References G4KDNode_Base::fTree.

◆ InactiveNode()

template<typename PointT >
virtual void G4KDNode< PointT >::InactiveNode ( )
inlinevirtual

Reimplemented from G4KDNode_Base.

Definition at line 155 of file G4KDNode.hh.

156 {
157 fValid = false;
159 }
virtual void InactiveNode()
Definition: G4KDNode.cc:106
bool fValid
Definition: G4KDNode.hh:168

References G4KDNode< PointT >::fValid, and G4KDNode_Base::InactiveNode().

◆ Insert() [1/3]

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

◆ Insert() [2/3]

int G4KDNode_Base::Insert ( G4KDNode_Base newNode)
inherited

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 G4KDNode_Base::fAxis, G4KDNode_Base::FindParent(), G4KDNode_Base::fLeft, G4KDNode_Base::fParent, G4KDNode_Base::fRight, G4KDNode_Base::fSide, G4KDNode_Base::fTree, and G4KDTree::GetDim().

◆ Insert() [3/3]

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

Referenced by G4KDTree::Build().

◆ IsValid()

template<typename PointT >
virtual bool G4KDNode< PointT >::IsValid ( void  ) const
inlinevirtual

Reimplemented from G4KDNode_Base.

Definition at line 161 of file G4KDNode.hh.

162 {
163 return fValid;
164 }

References G4KDNode< PointT >::fValid.

◆ operator delete()

template<typename PointT >
void G4KDNode< PointT >::operator delete ( void *  aNode)

Definition at line 189 of file G4KDNode.hh.

190 {
192 }
void FreeSingle(Type *anElement)
Definition: G4Allocator.hh:206
static G4ThreadLocal G4Allocator< G4KDNode< PointT > > * fgAllocator
Definition: G4KDNode.hh:174

◆ operator new()

template<typename PointT >
void * G4KDNode< PointT >::operator new ( size_t  )

Definition at line 182 of file G4KDNode.hh.

183 {
185 return (void *) fgAllocator->MallocSingle();
186 }
Type * MallocSingle()
Definition: G4Allocator.hh:196

References G4Allocator< Type >::MallocSingle().

◆ operator=()

template<typename PointT >
G4KDNode & G4KDNode< PointT >::operator= ( const G4KDNode< PointT > &  right)
private

◆ operator[]()

template<typename PointT >
virtual double G4KDNode< PointT >::operator[] ( size_t  i) const
inlinevirtual

Implements G4KDNode_Base.

Definition at line 149 of file G4KDNode.hh.

150 {
151 if(fPoint == 0) abort();
152 return (*fPoint)[i];
153 }

References G4KDNode< PointT >::fPoint.

◆ Print()

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

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 G4KDNode_Base::fLeft, G4KDNode_Base::fRight, G4endl, and G4KDNode_Base::Print().

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

◆ PullSubTree()

void G4KDNode_Base::PullSubTree ( )
inherited

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 G4KDNode_Base::fLeft, G4KDNode_Base::fParent, G4KDNode_Base::fRight, G4KDNode_Base::fSide, G4KDNode_Base::fTree, and G4KDNode_Base::PullSubTree().

Referenced by G4KDNode_Base::PullSubTree().

◆ RetrieveNodeList()

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

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 G4KDNode_Base::fLeft, G4KDNode_Base::fRight, and G4KDNode_Base::RetrieveNodeList().

Referenced by G4KDNode_Base::RetrieveNodeList().

◆ SetTree()

void G4KDNode_Base::SetTree ( G4KDTree tree)
inlineinherited

Definition at line 75 of file G4KDNode.hh.

75{fTree = tree;}

References G4KDNode_Base::fTree.

Field Documentation

◆ fAxis

size_t G4KDNode_Base::fAxis
protectedinherited

◆ fgAllocator

template<typename PointT >
G4ThreadLocal G4Allocator< G4KDNode< PointT > > * G4KDNode< PointT >::fgAllocator = 0
staticprivate

Definition at line 174 of file G4KDNode.hh.

◆ fLeft

G4KDNode_Base* G4KDNode_Base::fLeft
protectedinherited

◆ fParent

G4KDNode_Base * G4KDNode_Base::fParent
protectedinherited

◆ fPoint

template<typename PointT >
PointT* G4KDNode< PointT >::fPoint
protected

Definition at line 167 of file G4KDNode.hh.

Referenced by G4KDNode< PointT >::GetPoint(), and G4KDNode< PointT >::operator[]().

◆ fRight

G4KDNode_Base * G4KDNode_Base::fRight
protectedinherited

◆ fSide

int G4KDNode_Base::fSide
protectedinherited

◆ fTree

G4KDTree* G4KDNode_Base::fTree
protectedinherited

◆ fValid

template<typename PointT >
bool G4KDNode< PointT >::fValid
protected

Definition at line 168 of file G4KDNode.hh.

Referenced by G4KDNode< PointT >::InactiveNode(), and G4KDNode< PointT >::IsValid().


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