Geant4-11
Public Member Functions | Protected Attributes | Private Member Functions
G4KDTree::HyperRect Class Reference

#include <G4KDTree.hh>

Public Member Functions

template<typename Position >
bool CompareDistSqr (const Position &pos, const double *bestmatch)
 
template<typename Position >
void Extend (const Position &pos)
 
size_t GetDim ()
 
double * GetMax ()
 
double * GetMin ()
 
 HyperRect (const HyperRect &rect)
 
 HyperRect (size_t dim)
 
template<typename Position >
void SetMinMax (const Position &min, const Position &max)
 
 ~HyperRect ()
 

Protected Attributes

size_t fDim
 
double * fMax
 
double * fMin
 

Private Member Functions

HyperRectoperator= (const HyperRect &rhs)
 

Detailed Description

Definition at line 133 of file G4KDTree.hh.

Constructor & Destructor Documentation

◆ HyperRect() [1/2]

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

Definition at line 136 of file G4KDTree.hh.

137 {
138 fDim = dim;
139 fMin = new double[fDim];
140 fMax = new double[fDim];
141 }

References fDim, fMax, and fMin.

◆ ~HyperRect()

G4KDTree::HyperRect::~HyperRect ( )
inline

Definition at line 153 of file G4KDTree.hh.

154 {
155 delete[] fMin;
156 delete[] fMax;
157 }

References fMax, and fMin.

◆ HyperRect() [2/2]

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

Definition at line 159 of file G4KDTree.hh.

160 {
161 fDim = rect.fDim;
162 fMin = new double[fDim];
163 fMax = new double[fDim];
164
165 for (size_t i = 0; i < fDim; i++)
166 {
167 fMin[i] = rect.fMin[i];
168 fMax[i] = rect.fMax[i];
169 }
170 }

References fDim, fMax, and fMin.

Member Function Documentation

◆ CompareDistSqr()

template<typename Position >
bool G4KDTree::HyperRect::CompareDistSqr ( const Position &  pos,
const double *  bestmatch 
)
inline

Definition at line 189 of file G4KDTree.hh.

190 {
191 double result = 0;
192
193 for (size_t i = 0; i < fDim; i++)
194 {
195 if (pos[i] < fMin[i])
196 {
197 result += sqr(fMin[i] - pos[i]);
198 }
199 else if (pos[i] > fMax[i])
200 {
201 result += sqr(fMax[i] - pos[i]);
202 }
203
204 if (result >= *bestmatch) return false;
205 }
206
207 return true;
208 }
static const G4double pos
T sqr(const T &x)
Definition: templates.hh:128

References fDim, fMax, fMin, pos, and sqr().

◆ Extend()

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

Definition at line 173 of file G4KDTree.hh.

174 {
175 for (size_t i = 0; i < fDim; i++)
176 {
177 if (pos[i] < fMin[i])
178 {
179 fMin[i] = pos[i];
180 }
181 if (pos[i] > fMax[i])
182 {
183 fMax[i] = pos[i];
184 }
185 }
186 }

References fDim, fMax, fMin, and pos.

Referenced by G4KDTree::Build().

◆ GetDim()

size_t G4KDTree::HyperRect::GetDim ( )
inline

Definition at line 210 of file G4KDTree.hh.

211 {
212 return fDim;
213 }

References fDim.

◆ GetMax()

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

Definition at line 218 of file G4KDTree.hh.

219 {
220 return fMax;
221 }

References fMax.

◆ GetMin()

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

Definition at line 214 of file G4KDTree.hh.

215 {
216 return fMin;
217 }

References fMin.

◆ operator=()

HyperRect & G4KDTree::HyperRect::operator= ( const HyperRect rhs)
inlineprivate

Definition at line 229 of file G4KDTree.hh.

230 {
231 if (this == &rhs) return *this;
232 return *this;
233 }

◆ SetMinMax()

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

Definition at line 144 of file G4KDTree.hh.

145 {
146 for (size_t i = 0; i < fDim; i++)
147 {
148 fMin[i] = min[i];
149 fMax[i] = max[i];
150 }
151 }
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

References fDim, fMax, fMin, G4INCL::Math::max(), and G4INCL::Math::min().

Referenced by G4KDTree::Build().

Field Documentation

◆ fDim

size_t G4KDTree::HyperRect::fDim
protected

Definition at line 224 of file G4KDTree.hh.

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

◆ fMax

double * G4KDTree::HyperRect::fMax
protected

Definition at line 225 of file G4KDTree.hh.

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

◆ fMin

double* G4KDTree::HyperRect::fMin
protected

Definition at line 225 of file G4KDTree.hh.

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


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