Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4KDTree::HyperRect Class Reference

#include <G4KDTree.hh>

Public Member Functions

 HyperRect (std::size_t dim)
 
template<typename Position >
void SetMinMax (const Position &min, const Position &max)
 
 ~HyperRect ()
 
 HyperRect (const HyperRect &rect)
 
template<typename Position >
void Extend (const Position &pos)
 
template<typename Position >
G4bool CompareDistSqr (const Position &pos, const G4double *bestmatch)
 
std::size_t GetDim ()
 
G4doubleGetMin ()
 
G4doubleGetMax ()
 

Protected Attributes

std::size_t fDim
 
G4doublefMin
 
G4doublefMax
 

Detailed Description

Definition at line 129 of file G4KDTree.hh.

Constructor & Destructor Documentation

◆ HyperRect() [1/2]

G4KDTree::HyperRect::HyperRect ( std::size_t  dim)
inline

Definition at line 132 of file G4KDTree.hh.

133 : fDim(dim)
134 , fMin(new G4double[fDim])
135 , fMax(new G4double[fDim])
136 {}
double G4double
Definition: G4Types.hh:83
std::size_t fDim
Definition: G4KDTree.hh:212
G4double * fMax
Definition: G4KDTree.hh:213
G4double * fMin
Definition: G4KDTree.hh:213

◆ ~HyperRect()

G4KDTree::HyperRect::~HyperRect ( )
inline

Definition at line 148 of file G4KDTree.hh.

149 {
150 delete[] fMin;
151 delete[] fMax;
152 }

◆ HyperRect() [2/2]

G4KDTree::HyperRect::HyperRect ( const HyperRect rect)
inline

Definition at line 154 of file G4KDTree.hh.

155 {
156 fDim = rect.fDim;
157 fMin = new G4double[fDim];
158 fMax = new G4double[fDim];
159
160 for(std::size_t i = 0; i < fDim; ++i)
161 {
162 fMin[i] = rect.fMin[i];
163 fMax[i] = rect.fMax[i];
164 }
165 }

Member Function Documentation

◆ CompareDistSqr()

template<typename Position >
G4bool G4KDTree::HyperRect::CompareDistSqr ( const Position &  pos,
const G4double bestmatch 
)
inline

Definition at line 184 of file G4KDTree.hh.

185 {
186 G4double result = 0;
187
188 for(G4int i = 0; i < (G4int)fDim; ++i)
189 {
190 if(pos[i] < fMin[i])
191 {
192 result += sqr(fMin[i] - pos[i]);
193 }
194 else if(pos[i] > fMax[i])
195 {
196 result += sqr(fMax[i] - pos[i]);
197 }
198
199 if(result >= *bestmatch){
200 return false;
201 }
202 }
203
204 return true;
205 }
int G4int
Definition: G4Types.hh:85
T sqr(const T &x)
Definition: templates.hh:128

◆ Extend()

template<typename Position >
void G4KDTree::HyperRect::Extend ( const Position &  pos)
inline

Definition at line 168 of file G4KDTree.hh.

169 {
170 for(G4int i = 0; i < (G4int)fDim; ++i)
171 {
172 if(pos[i] < fMin[i])
173 {
174 fMin[i] = pos[i];
175 }
176 if(pos[i] > fMax[i])
177 {
178 fMax[i] = pos[i];
179 }
180 }
181 }

Referenced by G4KDTree::Build().

◆ GetDim()

std::size_t G4KDTree::HyperRect::GetDim ( )
inline

Definition at line 207 of file G4KDTree.hh.

207{ return fDim; }

◆ GetMax()

G4double * G4KDTree::HyperRect::GetMax ( )
inline

Definition at line 209 of file G4KDTree.hh.

209{ return fMax; }

◆ GetMin()

G4double * G4KDTree::HyperRect::GetMin ( )
inline

Definition at line 208 of file G4KDTree.hh.

208{ return fMin; }

◆ SetMinMax()

template<typename Position >
void G4KDTree::HyperRect::SetMinMax ( const Position &  min,
const Position &  max 
)
inline

Definition at line 139 of file G4KDTree.hh.

140 {
141 for(G4int i = 0; i < (G4int)fDim; ++i)
142 {
143 fMin[i] = min[i];
144 fMax[i] = max[i];
145 }
146 }
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments

Referenced by G4KDTree::Build().

Member Data Documentation

◆ fDim

std::size_t G4KDTree::HyperRect::fDim
protected

Definition at line 212 of file G4KDTree.hh.

Referenced by CompareDistSqr(), Extend(), GetDim(), HyperRect(), and SetMinMax().

◆ fMax

G4double * G4KDTree::HyperRect::fMax
protected

Definition at line 213 of file G4KDTree.hh.

Referenced by CompareDistSqr(), Extend(), GetMax(), HyperRect(), SetMinMax(), and ~HyperRect().

◆ fMin

G4double* G4KDTree::HyperRect::fMin
protected

Definition at line 213 of file G4KDTree.hh.

Referenced by CompareDistSqr(), Extend(), GetMin(), HyperRect(), SetMinMax(), and ~HyperRect().


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