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

Public Member Functions

 HyperRect (int dim, const double *min, const double *max)
 
 ~HyperRect ()
 
 HyperRect (const HyperRect &rect)
 
void Extend (const double *pos)
 
bool CompareDistSqr (const double *pos, const double *bestmatch)
 
int GetDim ()
 
double * GetMin ()
 
double * GetMax ()
 

Protected Attributes

int fDim
 
double * fMin
 
double * fMax
 

Detailed Description

Definition at line 82 of file G4KDTree.cc.

Constructor & Destructor Documentation

◆ HyperRect() [1/2]

HyperRect::HyperRect ( int  dim,
const double *  min,
const double *  max 
)
inline

Definition at line 85 of file G4KDTree.cc.

86 {
87 fDim = dim;
88 fMin = new double[fDim];
89 fMax = new double[fDim];
90 size_t size = fDim * sizeof(double);
91 memcpy(fMin, min, size);
92 memcpy(fMax, max, size);
93 }
int fDim
Definition: G4KDTree.cc:155
double * fMin
Definition: G4KDTree.cc:156
double * fMax
Definition: G4KDTree.cc:156

◆ ~HyperRect()

HyperRect::~HyperRect ( )
inline

Definition at line 96 of file G4KDTree.cc.

97 {
98 delete[] fMin;
99 delete[] fMax;
100 }

◆ HyperRect() [2/2]

HyperRect::HyperRect ( const HyperRect rect)
inline

Definition at line 102 of file G4KDTree.cc.

103 {
104 fDim = rect.fDim;
105 fMin = new double[fDim];
106 fMax = new double[fDim];
107 size_t size = fDim * sizeof(double);
108 memcpy(fMin, rect.fMin, size);
109 memcpy(fMax, rect.fMax, size);
110 }

Member Function Documentation

◆ CompareDistSqr()

bool HyperRect::CompareDistSqr ( const double *  pos,
const double *  bestmatch 
)
inline

Definition at line 129 of file G4KDTree.cc.

130 {
131 double result = 0;
132
133 for (int i=0; i < fDim; i++)
134 {
135 if (pos[i] < fMin[i])
136 {
137 result += sqr(fMin[i] - pos[i]);
138 }
139 else if (pos[i] > fMax[i])
140 {
141 result += sqr(fMax[i] - pos[i]);
142 }
143
144 if(result >= *bestmatch) return false ;
145 }
146
147 return true ;
148 }
T sqr(const T &x)
Definition: templates.hh:145

Referenced by G4KDTree::__NearestToNode(), and G4KDTree::__NearestToPosition().

◆ Extend()

void HyperRect::Extend ( const double *  pos)
inline

Definition at line 112 of file G4KDTree.cc.

113 {
114 int i;
115
116 for (i=0; i < fDim; i++)
117 {
118 if (pos[i] < fMin[i])
119 {
120 fMin[i] = pos[i];
121 }
122 if (pos[i] > fMax[i])
123 {
124 fMax[i] = pos[i];
125 }
126 }
127 }

Referenced by G4KDTree::Insert().

◆ GetDim()

int HyperRect::GetDim ( )
inline

Definition at line 150 of file G4KDTree.cc.

150{return fDim;}

◆ GetMax()

double * HyperRect::GetMax ( )
inline

Definition at line 152 of file G4KDTree.cc.

152{return fMax;}

Referenced by G4KDTree::__NearestToNode(), and G4KDTree::__NearestToPosition().

◆ GetMin()

double * HyperRect::GetMin ( )
inline

Definition at line 151 of file G4KDTree.cc.

151{return fMin;}

Referenced by G4KDTree::__NearestToNode(), and G4KDTree::__NearestToPosition().

Member Data Documentation

◆ fDim

int HyperRect::fDim
protected

Definition at line 155 of file G4KDTree.cc.

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

◆ fMax

double * HyperRect::fMax
protected

Definition at line 156 of file G4KDTree.cc.

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

◆ fMin

double* HyperRect::fMin
protected

Definition at line 156 of file G4KDTree.cc.

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


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