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::HyperRect ( int  dim,
const double *  min,
const double *  max 
) [inline]

Definition at line 85 of file G4KDTree.cc.

References fDim, fMax, and fMin.

00086     {
00087         fDim = dim;
00088         fMin = new double[fDim];
00089         fMax = new double[fDim];
00090         size_t size = fDim * sizeof(double);
00091         memcpy(fMin, min, size);
00092         memcpy(fMax, max, size);
00093    }

HyperRect::~HyperRect (  )  [inline]

Definition at line 96 of file G4KDTree.cc.

References fMax, and fMin.

00097     {
00098         delete[] fMin;
00099         delete[] fMax;
00100     }

HyperRect::HyperRect ( const HyperRect rect  )  [inline]

Definition at line 102 of file G4KDTree.cc.

References fDim, fMax, and fMin.

00103     {
00104         fDim = rect.fDim;
00105         fMin = new double[fDim];
00106         fMax = new double[fDim];
00107         size_t size = fDim * sizeof(double);
00108         memcpy(fMin, rect.fMin, size);
00109         memcpy(fMax, rect.fMax, size);
00110     }


Member Function Documentation

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

Definition at line 129 of file G4KDTree.cc.

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

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

00130     {
00131         double result = 0;
00132 
00133         for (int i=0; i < fDim; i++)
00134         {
00135             if (pos[i] < fMin[i])
00136             {
00137                 result += sqr(fMin[i] - pos[i]);
00138             }
00139             else if (pos[i] > fMax[i])
00140             {
00141                 result += sqr(fMax[i] - pos[i]);
00142             }
00143 
00144             if(result >= *bestmatch) return false ;
00145         }
00146 
00147         return true ;
00148     }

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

Definition at line 112 of file G4KDTree.cc.

References fDim, fMax, and fMin.

Referenced by G4KDTree::Insert().

00113     {
00114         int i;
00115 
00116         for (i=0; i < fDim; i++)
00117         {
00118             if (pos[i] < fMin[i])
00119             {
00120                 fMin[i] = pos[i];
00121             }
00122             if (pos[i] > fMax[i])
00123             {
00124                 fMax[i] = pos[i];
00125             }
00126         }
00127     }

int HyperRect::GetDim (  )  [inline]

Definition at line 150 of file G4KDTree.cc.

References fDim.

00150 {return fDim;}

double* HyperRect::GetMax (  )  [inline]

Definition at line 152 of file G4KDTree.cc.

References fMax.

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

00152 {return fMax;}

double* HyperRect::GetMin (  )  [inline]

Definition at line 151 of file G4KDTree.cc.

References fMin.

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

00151 {return fMin;}


Field Documentation

int HyperRect::fDim [protected]

Definition at line 155 of file G4KDTree.cc.

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

double * HyperRect::fMax [protected]

Definition at line 156 of file G4KDTree.cc.

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

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:
Generated on Mon May 27 17:54:03 2013 for Geant4 by  doxygen 1.4.7