Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4KDTreeResult Class Reference

#include <G4KDTreeResult.hh>

+ Inheritance diagram for G4KDTreeResult:

Public Member Functions

 G4KDTreeResult (G4KDTree *)
 
virtual ~G4KDTreeResult ()
 
void Insert (double, G4KDNode *)
 
void Clear ()
 
void Sort ()
 
size_t GetSize ()
 
size_t size ()
 
void Rewind ()
 
bool End ()
 
void Next ()
 
void * GetItemData ()
 
void * GetItem (double *&)
 
void * GetItem (double &x, double &y, double &z)
 
void * GetItemNDistanceSQ (double &)
 
void * GetItemNDistanceSQ (double *&, double &)
 
double GetDistanceSqr ()
 

Protected Attributes

G4KDTreefTree
 
std::list< ResNode >::iterator fIterator
 

Detailed Description

G4KDTreeResult enables to go through the nearest entities found by G4KDTree.

Definition at line 59 of file G4KDTreeResult.hh.

Constructor & Destructor Documentation

◆ G4KDTreeResult()

G4KDTreeResult::G4KDTreeResult ( G4KDTree tree)

Definition at line 80 of file G4KDTreeResult.cc.

80 : std::list<ResNode>()
81{
82 fTree = tree;
83}
G4KDTree * fTree

◆ ~G4KDTreeResult()

G4KDTreeResult::~G4KDTreeResult ( )
virtual

Definition at line 85 of file G4KDTreeResult.cc.

86{
87 std::list<ResNode>::erase(begin(),end());
88}

Member Function Documentation

◆ Clear()

void G4KDTreeResult::Clear ( )

Definition at line 95 of file G4KDTreeResult.cc.

96{
97 std::list<ResNode>::erase(begin(),end());
98 fIterator = std::list<ResNode>::begin();
99}
std::list< ResNode >::iterator fIterator

◆ End()

bool G4KDTreeResult::End ( )

Definition at line 121 of file G4KDTreeResult.cc.

122{
123 return (fIterator == end());
124}

◆ GetDistanceSqr()

double G4KDTreeResult::GetDistanceSqr ( )

Definition at line 164 of file G4KDTreeResult.cc.

165{
166 return (*fIterator).GetDistanceSqr();
167}

◆ GetItem() [1/2]

void * G4KDTreeResult::GetItem ( double &  x,
double &  y,
double &  z 
)

Definition at line 138 of file G4KDTreeResult.cc.

139{
140 x = (*fIterator).GetNode()->GetPosition()[0];
141 y = (*fIterator).GetNode()->GetPosition()[1];
142 z = (*fIterator).GetNode()->GetPosition()[2];
143
144 return (*fIterator).GetNode()->GetData();
145}

◆ GetItem() [2/2]

void * G4KDTreeResult::GetItem ( double *&  pos)

Definition at line 131 of file G4KDTreeResult.cc.

132{
133 if(!pos) pos = new double[fTree->GetDim()];
134 memcpy(pos, (*fIterator).GetNode()->GetPosition(), fTree->GetDim() * sizeof *pos);
135 return (*fIterator).GetNode()->GetData();
136}
int GetDim()
Definition: G4KDTree.hh:136

Referenced by GetItemNDistanceSQ().

◆ GetItemData()

void * G4KDTreeResult::GetItemData ( )

Definition at line 159 of file G4KDTreeResult.cc.

160{
161 return (*fIterator).GetNode()->GetData();
162}

◆ GetItemNDistanceSQ() [1/2]

void * G4KDTreeResult::GetItemNDistanceSQ ( double &  dist_sq)

Definition at line 147 of file G4KDTreeResult.cc.

148{
149 dist_sq = (*fIterator).GetDistanceSqr();
150 return (*fIterator).GetNode()->GetData();
151}

◆ GetItemNDistanceSQ() [2/2]

void * G4KDTreeResult::GetItemNDistanceSQ ( double *&  pos,
double &  dist_sq 
)

Definition at line 153 of file G4KDTreeResult.cc.

154{
155 dist_sq = (*fIterator).GetDistanceSqr();
156 return GetItem(pos);
157}
void * GetItem(double *&)

◆ GetSize()

size_t G4KDTreeResult::GetSize ( )

Definition at line 106 of file G4KDTreeResult.cc.

107{
108 return std::list<ResNode>::size();
109}

◆ Insert()

void G4KDTreeResult::Insert ( double  pos,
G4KDNode node 
)

Definition at line 90 of file G4KDTreeResult.cc.

91{
92 std::list<ResNode>::push_back(ResNode(pos,node));
93}

Referenced by G4KDTree::__NearestInRange().

◆ Next()

void G4KDTreeResult::Next ( )

Definition at line 126 of file G4KDTreeResult.cc.

127{
128 fIterator++;
129}

◆ Rewind()

void G4KDTreeResult::Rewind ( )

Definition at line 116 of file G4KDTreeResult.cc.

117{
118 fIterator = begin();
119}

Referenced by G4KDTree::NearestInRange().

◆ size()

size_t G4KDTreeResult::size ( )

Definition at line 111 of file G4KDTreeResult.cc.

112{
113 return std::list<ResNode>::size();
114}

◆ Sort()

void G4KDTreeResult::Sort ( )

Definition at line 101 of file G4KDTreeResult.cc.

102{
103 std::list<ResNode>::sort(CompareResNode);
104}
bool CompareResNode(const ResNode &left, const ResNode &right)

Referenced by G4KDTree::NearestInRange().

Member Data Documentation

◆ fIterator

std::list<ResNode>::iterator G4KDTreeResult::fIterator
protected

Definition at line 63 of file G4KDTreeResult.hh.

Referenced by Clear(), End(), Next(), and Rewind().

◆ fTree

G4KDTree* G4KDTreeResult::fTree
protected

Definition at line 62 of file G4KDTreeResult.hh.

Referenced by G4KDTreeResult(), and GetItem().


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