Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4SurfaceVoxelizer Class Reference

#include <G4SurfaceVoxelizer.hh>

Public Member Functions

void Voxelize (std::vector< G4VFacet * > &facets)
 
void DisplayVoxelLimits ()
 
void DisplayBoundaries ()
 
void DisplayListNodes () const
 
 G4SurfaceVoxelizer ()
 
 ~G4SurfaceVoxelizer ()
 
void GetCandidatesVoxel (std::vector< G4int > &voxels)
 
G4int GetCandidatesVoxelArray (const G4ThreeVector &point, std::vector< G4int > &list, G4SurfBits *crossed=0) const
 
G4int GetCandidatesVoxelArray (const std::vector< G4int > &voxels, const G4SurfBits bitmasks[], std::vector< G4int > &list, G4SurfBits *crossed=0) const
 
G4int GetCandidatesVoxelArray (const std::vector< G4int > &voxels, std::vector< G4int > &list, G4SurfBits *crossed=0) const
 
const std::vector< G4VoxelBox > & GetBoxes () const
 
const std::vector< G4double > & GetBoundary (G4int index) const
 
G4bool UpdateCurrentVoxel (const G4ThreeVector &point, const G4ThreeVector &direction, std::vector< G4int > &curVoxel) const
 
void GetVoxel (std::vector< G4int > &curVoxel, const G4ThreeVector &point) const
 
G4int GetBitsPerSlice () const
 
G4bool Contains (const G4ThreeVector &point) const
 
G4double DistanceToNext (const G4ThreeVector &point, const G4ThreeVector &direction, const std::vector< G4int > &curVoxel) const
 
G4double DistanceToFirst (const G4ThreeVector &point, const G4ThreeVector &direction) const
 
G4double DistanceToBoundingBox (const G4ThreeVector &point) const
 
G4int GetVoxelsIndex (G4int x, G4int y, G4int z) const
 
G4int GetVoxelsIndex (const std::vector< G4int > &voxels) const
 
G4int GetPointIndex (const G4ThreeVector &p) const
 
const G4SurfBitsEmpty () const
 
G4bool IsEmpty (G4int index) const
 
void SetMaxVoxels (G4int max)
 
void SetMaxVoxels (const G4ThreeVector &reductionRatio)
 
G4int GetMaxVoxels (G4ThreeVector &ratioOfReduction)
 
G4int AllocatedMemory ()
 
long long GetCountOfVoxels () const
 
long long CountVoxels (std::vector< G4double > boundaries[]) const
 
const std::vector< G4int > & GetCandidates (std::vector< G4int > &curVoxel) const
 
G4int GetVoxelBoxesSize () const
 
const G4VoxelBoxGetVoxelBox (G4int i) const
 
const std::vector< G4int > & GetVoxelBoxCandidates (G4int i) const
 
G4int GetTotalCandidates () const
 

Static Public Member Functions

template<typename T >
static G4int BinarySearch (const std::vector< T > &vec, T value)
 
static G4double MinDistanceToBox (const G4ThreeVector &aPoint, const G4ThreeVector &f)
 
static G4int SetDefaultVoxelsCount (G4int count)
 
static G4int GetDefaultVoxelsCount ()
 

Detailed Description

Definition at line 66 of file G4SurfaceVoxelizer.hh.

Constructor & Destructor Documentation

G4SurfaceVoxelizer::G4SurfaceVoxelizer ( )

Definition at line 60 of file G4SurfaceVoxelizer.cc.

61  : fBoundingBox("TessBBox", 1, 1, 1)
62 {
63  fCountOfVoxels = fNPerSlice = fTotalCandidates = 0;
64 
66 
67  SetMaxVoxels(fDefaultVoxelsCount);
68 
69  G4SolidStore::GetInstance()->DeRegister(&fBoundingBox);
70 }
static void DeRegister(G4VSolid *pSolid)
G4double GetSurfaceTolerance() const
static G4SolidStore * GetInstance()
void SetMaxVoxels(G4int max)
static G4GeometryTolerance * GetInstance()

Here is the call graph for this function:

G4SurfaceVoxelizer::~G4SurfaceVoxelizer ( )

Definition at line 73 of file G4SurfaceVoxelizer.cc.

74 {
75 }

Member Function Documentation

G4int G4SurfaceVoxelizer::AllocatedMemory ( )

Definition at line 1083 of file G4SurfaceVoxelizer.cc.

1084 {
1085  G4int size = fEmpty.GetNbytes();
1086  size += fBoxes.capacity() * sizeof(G4VoxelBox);
1087  size += sizeof(G4double) * (fBoundaries[0].capacity()
1088  + fBoundaries[1].capacity() + fBoundaries[2].capacity());
1089  size += sizeof(G4int) * (fCandidatesCounts[0].capacity()
1090  + fCandidatesCounts[1].capacity() + fCandidatesCounts[2].capacity());
1091  size += fBitmasks[0].GetNbytes() + fBitmasks[1].GetNbytes()
1092  + fBitmasks[2].GetNbytes();
1093 
1094  G4int csize = fCandidates.size();
1095  for (G4int i = 0; i < csize; i++)
1096  {
1097  size += sizeof(vector<G4int>) + fCandidates[i].capacity() * sizeof(G4int);
1098  }
1099 
1100  return size;
1101 }
int G4int
Definition: G4Types.hh:78
double G4double
Definition: G4Types.hh:76
unsigned int GetNbytes() const
Definition: G4SurfBits.hh:102

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename T >
static G4int G4SurfaceVoxelizer::BinarySearch ( const std::vector< T > &  vec,
value 
)
inlinestatic

Here is the caller graph for this function:

G4bool G4SurfaceVoxelizer::Contains ( const G4ThreeVector point) const

Definition at line 926 of file G4SurfaceVoxelizer.cc.

927 {
928  for (G4int i = 0; i < 3; ++i)
929  {
930  if (point[i] < fBoundaries[i].front() || point[i] > fBoundaries[i].back())
931  return false;
932  }
933  return true;
934 }
int G4int
Definition: G4Types.hh:78
long long G4SurfaceVoxelizer::CountVoxels ( std::vector< G4double boundaries[]) const
inline

Here is the caller graph for this function:

void G4SurfaceVoxelizer::DisplayBoundaries ( )

Definition at line 281 of file G4SurfaceVoxelizer.cc.

282 {
283  char axis[3] = {'X', 'Y', 'Z'};
284  for (G4int i = 0; i <= 2; ++i)
285  {
286  G4cout << " * " << axis[i] << " axis:" << G4endl << " | ";
287  DisplayBoundaries(fBoundaries[i]);
288  }
289 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
void G4SurfaceVoxelizer::DisplayListNodes ( ) const

Definition at line 389 of file G4SurfaceVoxelizer.cc.

390 {
391  // Prints which solids are present in the slices previously elaborated.
392 
393  char axis[3] = {'X', 'Y', 'Z'};
394  G4int size=8*sizeof(G4int)*fNPerSlice;
395  G4SurfBits bits(size);
396 
397  for (G4int j = 0; j <= 2; ++j)
398  {
399  G4cout << " * " << axis[j] << " axis:" << G4endl;
400  G4int count = fBoundaries[j].size();
401  for(G4int i=0; i < count-1; ++i)
402  {
403  G4cout << " Slice #" << i+1 << ": [" << fBoundaries[j][i]
404  << " ; " << fBoundaries[j][i+1] << "] -> ";
405  bits.set(size,(const char *)fBitmasks[j].fAllBits+i
406  *fNPerSlice*sizeof(G4int));
407  G4String result = GetCandidatesAsString(bits);
408  G4cout << "[ " << result.c_str() << "] " << G4endl;
409  }
410  }
411 }
G4double G4ParticleHPJENDLHEData::G4double result
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

void G4SurfaceVoxelizer::DisplayVoxelLimits ( )

Definition at line 154 of file G4SurfaceVoxelizer.cc.

155 {
156  // "DisplayVoxelLimits" displays the dX, dY, dZ, pX, pY and pZ for each node
157 
158  G4int numNodes = fBoxes.size();
159  G4int oldprec = G4cout.precision(16);
160  for(G4int i = 0; i < numNodes; ++i)
161  {
162  G4cout << setw(10) << setiosflags(ios::fixed) <<
163  " -> Node " << i+1 << ":\n" <<
164  "\t * [x,y,z] = " << fBoxes[i].hlen <<
165  "\t * [x,y,z] = " << fBoxes[i].pos << "\n";
166  }
167  G4cout.precision(oldprec);
168 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
G4double G4SurfaceVoxelizer::DistanceToBoundingBox ( const G4ThreeVector point) const

Definition at line 948 of file G4SurfaceVoxelizer.cc.

949 {
950  G4ThreeVector pointShifted = point - fBoundingBoxCenter;
951  G4double shift = MinDistanceToBox(pointShifted, fBoundingBoxSize);
952  return shift;
953 }
static G4double MinDistanceToBox(const G4ThreeVector &aPoint, const G4ThreeVector &f)
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4SurfaceVoxelizer::DistanceToFirst ( const G4ThreeVector point,
const G4ThreeVector direction 
) const

Definition at line 938 of file G4SurfaceVoxelizer.cc.

940 {
941  G4ThreeVector pointShifted = point - fBoundingBoxCenter;
942  G4double shift = fBoundingBox.DistanceToIn(pointShifted, direction);
943  return shift;
944 }
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
Definition: G4Box.cc:436
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

G4double G4SurfaceVoxelizer::DistanceToNext ( const G4ThreeVector point,
const G4ThreeVector direction,
const std::vector< G4int > &  curVoxel 
) const

Definition at line 983 of file G4SurfaceVoxelizer.cc.

986 {
987  G4double shift = kInfinity;
988 
989  for (G4int i = 0; i <= 2; ++i)
990  {
991  // Looking for the next voxels on the considered direction X,Y,Z axis
992  //
993  const vector<G4double> &boundary = fBoundaries[i];
994  G4int cur = curVoxel[i];
995  if(direction[i] >= 1e-10)
996  {
997  if (boundary[++cur] - point[i] < fTolerance) // make sure shift would
998  if (++cur >= (G4int) boundary.size()) // be non-zero
999  continue;
1000  }
1001  else
1002  {
1003  if(direction[i] <= -1e-10)
1004  {
1005  if (point[i] - boundary[cur] < fTolerance) // make sure shift would
1006  if (--cur < 0) // be non-zero
1007  continue;
1008  }
1009  else
1010  continue;
1011  }
1012  G4double dif = boundary[cur] - point[i];
1013  G4double distance = dif / direction[i];
1014 
1015  if (shift > distance)
1016  shift = distance;
1017  }
1018 
1019  return shift;
1020 }
static const G4double kInfinity
Definition: geomdefs.hh:42
int G4int
Definition: G4Types.hh:78
double G4double
Definition: G4Types.hh:76
const G4SurfBits& G4SurfaceVoxelizer::Empty ( ) const
inline
G4int G4SurfaceVoxelizer::GetBitsPerSlice ( ) const
inline
const std::vector<G4double>& G4SurfaceVoxelizer::GetBoundary ( G4int  index) const
inline
const std::vector<G4VoxelBox>& G4SurfaceVoxelizer::GetBoxes ( ) const
inline
const std::vector<G4int>& G4SurfaceVoxelizer::GetCandidates ( std::vector< G4int > &  curVoxel) const
inline

Here is the caller graph for this function:

void G4SurfaceVoxelizer::GetCandidatesVoxel ( std::vector< G4int > &  voxels)

Definition at line 758 of file G4SurfaceVoxelizer.cc.

759 {
760  // "GetCandidates" should compute which solids are possibly contained in
761  // the voxel defined by the three slices characterized by the passed indexes.
762 
763  G4cout << " Candidates in voxel [" << voxels[0] << " ; " << voxels[1]
764  << " ; " << voxels[2] << "]: ";
765  vector<G4int> candidates;
766  G4int count = GetCandidatesVoxelArray(voxels, candidates);
767  G4cout << "[ ";
768  for (G4int i = 0; i < count; ++i) G4cout << candidates[i];
769  G4cout << "] " << G4endl;
770 }
G4int GetCandidatesVoxelArray(const G4ThreeVector &point, std::vector< G4int > &list, G4SurfBits *crossed=0) const
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

G4int G4SurfaceVoxelizer::GetCandidatesVoxelArray ( const G4ThreeVector point,
std::vector< G4int > &  list,
G4SurfBits crossed = 0 
) const

Definition at line 792 of file G4SurfaceVoxelizer.cc.

794 {
795  // Method returning the candidates corresponding to the passed point
796 
797  list.clear();
798 
799  for (G4int i = 0; i <= 2; ++i)
800  {
801  if(point[i] < fBoundaries[i].front() || point[i] >= fBoundaries[i].back())
802  return 0;
803  }
804 
805  if (fTotalCandidates == 1)
806  {
807  list.push_back(0);
808  return 1;
809  }
810  else
811  {
812  if (fNPerSlice == 1)
813  {
814  unsigned int mask;
815  G4int slice = BinarySearch(fBoundaries[0], point.x());
816  if (!(mask = ((unsigned int *) fBitmasks[0].fAllBits)[slice]
817  )) return 0;
818  slice = BinarySearch(fBoundaries[1], point.y());
819  if (!(mask &= ((unsigned int *) fBitmasks[1].fAllBits)[slice]
820  )) return 0;
821  slice = BinarySearch(fBoundaries[2], point.z());
822  if (!(mask &= ((unsigned int *) fBitmasks[2].fAllBits)[slice]
823  )) return 0;
824  if (crossed && (!(mask &= ~((unsigned int *)crossed->fAllBits)[0])))
825  return 0;
826 
827  FindComponentsFastest(mask, list, 0);
828  }
829  else
830  {
831  unsigned int *masks[3], mask; // masks for X,Y,Z axis
832  for (G4int i = 0; i <= 2; ++i)
833  {
834  G4int slice = BinarySearch(fBoundaries[i], point[i]);
835  masks[i] = ((unsigned int *) fBitmasks[i].fAllBits) + slice*fNPerSlice;
836  }
837  unsigned int *maskCrossed =
838  crossed ? (unsigned int *)crossed->fAllBits : 0;
839 
840  for (G4int i = 0 ; i < fNPerSlice; ++i)
841  {
842  // Logic "and" of the masks along the 3 axes x, y, z:
843  // removing "if (!" and ") continue" => slightly slower
844  //
845  if (!(mask = masks[0][i])) continue;
846  if (!(mask &= masks[1][i])) continue;
847  if (!(mask &= masks[2][i])) continue;
848  if (maskCrossed && !(mask &= ~maskCrossed[i])) continue;
849 
850  FindComponentsFastest(mask, list, i);
851  }
852  }
853  }
854  return list.size();
855 }
double x() const
static ush mask[]
Definition: csz_inflate.cc:317
int G4int
Definition: G4Types.hh:78
double z() const
unsigned char * fAllBits
Definition: G4SurfBits.hh:113
static G4int BinarySearch(const std::vector< T > &vec, T value)
double y() const
for(G4int i1=0;i1< theStableOnes.GetNumberOfIsotopes(static_cast< G4int >(anE->GetZ()));i1++)

Here is the call graph for this function:

Here is the caller graph for this function:

G4int G4SurfaceVoxelizer::GetCandidatesVoxelArray ( const std::vector< G4int > &  voxels,
const G4SurfBits  bitmasks[],
std::vector< G4int > &  list,
G4SurfBits crossed = 0 
) const

Definition at line 859 of file G4SurfaceVoxelizer.cc.

863 {
864  list.clear();
865 
866  if (fTotalCandidates == 1)
867  {
868  list.push_back(0);
869  return 1;
870  }
871  else
872  {
873  if (fNPerSlice == 1)
874  {
875  unsigned int mask;
876  if (!(mask = ((unsigned int *) bitmasks[0].fAllBits)[voxels[0]]
877  )) return 0;
878  if (!(mask &= ((unsigned int *) bitmasks[1].fAllBits)[voxels[1]]
879  )) return 0;
880  if (!(mask &= ((unsigned int *) bitmasks[2].fAllBits)[voxels[2]]
881  )) return 0;
882  if (crossed && (!(mask &= ~((unsigned int *)crossed->fAllBits)[0])))
883  return 0;
884 
885  FindComponentsFastest(mask, list, 0);
886  }
887  else
888  {
889  unsigned int *masks[3], mask; // masks for X,Y,Z axis
890  for (G4int i = 0; i <= 2; ++i)
891  {
892  masks[i] = ((unsigned int *) bitmasks[i].fAllBits)
893  + voxels[i]*fNPerSlice;
894  }
895  unsigned int *maskCrossed =
896  crossed ? (unsigned int *)crossed->fAllBits : 0;
897 
898  for (G4int i = 0 ; i < fNPerSlice; ++i)
899  {
900  // Logic "and" of the masks along the 3 axes x, y, z:
901  // removing "if (!" and ") continue" => slightly slower
902  //
903  if (!(mask = masks[0][i])) continue;
904  if (!(mask &= masks[1][i])) continue;
905  if (!(mask &= masks[2][i])) continue;
906  if (maskCrossed && !(mask &= ~maskCrossed[i])) continue;
907 
908  FindComponentsFastest(mask, list, i);
909  }
910  }
911  }
912  return list.size();
913 }
static ush mask[]
Definition: csz_inflate.cc:317
int G4int
Definition: G4Types.hh:78
unsigned char * fAllBits
Definition: G4SurfBits.hh:113
for(G4int i1=0;i1< theStableOnes.GetNumberOfIsotopes(static_cast< G4int >(anE->GetZ()));i1++)

Here is the call graph for this function:

G4int G4SurfaceVoxelizer::GetCandidatesVoxelArray ( const std::vector< G4int > &  voxels,
std::vector< G4int > &  list,
G4SurfBits crossed = 0 
) const

Definition at line 917 of file G4SurfaceVoxelizer.cc.

919 {
920  // Method returning the candidates corresponding to the passed point
921 
922  return GetCandidatesVoxelArray(voxels, fBitmasks, list, crossed);
923 }
G4int GetCandidatesVoxelArray(const G4ThreeVector &point, std::vector< G4int > &list, G4SurfBits *crossed=0) const

Here is the call graph for this function:

long long G4SurfaceVoxelizer::GetCountOfVoxels ( ) const
inline

Here is the caller graph for this function:

G4int G4SurfaceVoxelizer::GetDefaultVoxelsCount ( )
static

Definition at line 1077 of file G4SurfaceVoxelizer.cc.

1078 {
1079  return fDefaultVoxelsCount;
1080 }
G4int G4SurfaceVoxelizer::GetMaxVoxels ( G4ThreeVector ratioOfReduction)
inline
G4int G4SurfaceVoxelizer::GetPointIndex ( const G4ThreeVector p) const
inline

Here is the caller graph for this function:

G4int G4SurfaceVoxelizer::GetTotalCandidates ( ) const
inline
void G4SurfaceVoxelizer::GetVoxel ( std::vector< G4int > &  curVoxel,
const G4ThreeVector point 
) const
inline

Here is the caller graph for this function:

const G4VoxelBox& G4SurfaceVoxelizer::GetVoxelBox ( G4int  i) const
inline
const std::vector<G4int>& G4SurfaceVoxelizer::GetVoxelBoxCandidates ( G4int  i) const
inline
G4int G4SurfaceVoxelizer::GetVoxelBoxesSize ( ) const
inline
G4int G4SurfaceVoxelizer::GetVoxelsIndex ( G4int  x,
G4int  y,
G4int  z 
) const
inline
G4int G4SurfaceVoxelizer::GetVoxelsIndex ( const std::vector< G4int > &  voxels) const
inline
G4bool G4SurfaceVoxelizer::IsEmpty ( G4int  index) const
inline
G4double G4SurfaceVoxelizer::MinDistanceToBox ( const G4ThreeVector aPoint,
const G4ThreeVector f 
)
static

Definition at line 957 of file G4SurfaceVoxelizer.cc.

959 {
960  // Estimates the isotropic safety from a point outside the current solid to
961  // any of its surfaces. The algorithm may be accurate or should provide a
962  // fast underestimate.
963 
964  G4double safe, safx, safy, safz;
965  safe = safx = -f.x() + std::abs(aPoint.x());
966  safy = -f.y() + std::abs(aPoint.y());
967  if ( safy > safe ) safe = safy;
968  safz = -f.z() + std::abs(aPoint.z());
969  if ( safz > safe ) safe = safz;
970  if (safe < 0.0) return 0.0; // point is inside
971  // if (!aAccurate) return safe;
972  G4double safsq = 0.0;
973  G4int count = 0;
974  if ( safx > 0 ) { safsq += safx*safx; count++; }
975  if ( safy > 0 ) { safsq += safy*safy; count++; }
976  if ( safz > 0 ) { safsq += safz*safz; count++; }
977  if (count == 1) return safe;
978  return std::sqrt(safsq);
979 }
double x() const
int G4int
Definition: G4Types.hh:78
double z() const
double y() const
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

G4int G4SurfaceVoxelizer::SetDefaultVoxelsCount ( G4int  count)
static

Definition at line 1069 of file G4SurfaceVoxelizer.cc.

1070 {
1071  G4int res = fDefaultVoxelsCount;
1072  fDefaultVoxelsCount = count;
1073  return res;
1074 }
int G4int
Definition: G4Types.hh:78
void G4SurfaceVoxelizer::SetMaxVoxels ( G4int  max)

Definition at line 1055 of file G4SurfaceVoxelizer.cc.

1056 {
1057  fMaxVoxels = max;
1058  fReductionRatio.set(0,0,0);
1059 }
void set(double x, double y, double z)
T max(const T t1, const T t2)
brief Return the largest of the two arguments

Here is the call graph for this function:

Here is the caller graph for this function:

void G4SurfaceVoxelizer::SetMaxVoxels ( const G4ThreeVector reductionRatio)

Definition at line 1062 of file G4SurfaceVoxelizer.cc.

1063 {
1064  fMaxVoxels = -1;
1065  fReductionRatio = ratioOfReduction;
1066 }
G4bool G4SurfaceVoxelizer::UpdateCurrentVoxel ( const G4ThreeVector point,
const G4ThreeVector direction,
std::vector< G4int > &  curVoxel 
) const

Definition at line 1024 of file G4SurfaceVoxelizer.cc.

1027 {
1028  for (G4int i = 0; i <= 2; ++i)
1029  {
1030  G4int index = curVoxel[i];
1031  const vector<G4double> &boundary = fBoundaries[i];
1032 
1033  if (direction[i] > 0)
1034  {
1035  if (point[i] >= boundary[++index])
1036  if (++curVoxel[i] >= (G4int) boundary.size() - 1)
1037  return false;
1038  }
1039  else
1040  {
1041  if (point[i] < boundary[index])
1042  if (--curVoxel[i] < 0)
1043  return false;
1044  }
1045 #ifdef G4SPECSDEBUG
1046  G4int indexOK = BinarySearch(boundary, point[i]);
1047  if (curVoxel[i] != indexOK)
1048  curVoxel[i] = indexOK; // put breakpoint here
1049 #endif
1050  }
1051  return true;
1052 }
int G4int
Definition: G4Types.hh:78
static G4int BinarySearch(const std::vector< T > &vec, T value)

Here is the call graph for this function:

void G4SurfaceVoxelizer::Voxelize ( std::vector< G4VFacet * > &  facets)

Definition at line 626 of file G4SurfaceVoxelizer.cc.

627 {
628  G4int maxVoxels = fMaxVoxels;
629  G4ThreeVector reductionRatio = fReductionRatio;
630 
631  G4int size = facets.size();
632  if (size < 10)
633  {
634  for (G4int i = 0; i < (G4int) facets.size(); i++)
635  {
636  if (facets[i]->GetNumberOfVertices() > 3) size++;
637  }
638  }
639 
640  if ((size >= 10 || maxVoxels > 0) && maxVoxels != 0 && maxVoxels != 1)
641  {
642 #ifdef G4SPECSDEBUG
643  G4cout << "Building voxel limits..." << G4endl;
644 #endif
645 
646  BuildVoxelLimits(facets);
647 
648 #ifdef G4SPECSDEBUG
649  G4cout << "Building boundaries..." << G4endl;
650 #endif
651 
652  BuildBoundaries();
653 
654 #ifdef G4SPECSDEBUG
655  G4cout << "Building bitmasks..." << G4endl;
656 #endif
657 
658  BuildBitmasks(fBoundaries, 0, true);
659 
660  if (maxVoxels < 0 && reductionRatio == G4ThreeVector())
661  {
662  maxVoxels = fTotalCandidates;
663  if (fTotalCandidates > 1000000) maxVoxels = 1000000;
664  }
665 
666  SetReductionRatio(maxVoxels, reductionRatio);
667 
668  fCountOfVoxels = CountVoxels(fBoundaries);
669 
670 #ifdef G4SPECSDEBUG
671  G4cout << "Total number of voxels: " << fCountOfVoxels << G4endl;
672 #endif
673 
674  BuildReduceVoxels2(fBoundaries, reductionRatio);
675 
676  fCountOfVoxels = CountVoxels(fBoundaries);
677 
678 #ifdef G4SPECSDEBUG
679  G4cout << "Total number of voxels after reduction: "
680  << fCountOfVoxels << G4endl;
681 #endif
682 
683 #ifdef G4SPECSDEBUG
684  G4cout << "Building bitmasks..." << G4endl;
685 #endif
686 
687  BuildBitmasks(fBoundaries, fBitmasks);
688 
689  G4ThreeVector reductionRatioMini;
690 
691  G4SurfBits bitmasksMini[3];
692 
693  // section for building mini voxels
694 
695  vector<G4double> miniBoundaries[3];
696 
697  for (G4int i = 0; i <= 2; ++i) { miniBoundaries[i] = fBoundaries[i]; }
698 
699  G4int voxelsCountMini = (fCountOfVoxels >= 1000)
700  ? 100 : fCountOfVoxels / 10;
701 
702  // if (voxelCountMini < 8) voxelCountMini = 8;
703  // voxelsCountMini = 1;
704 
705  SetReductionRatio(voxelsCountMini, reductionRatioMini);
706 
707 #ifdef G4SPECSDEBUG
708  G4cout << "Building reduced voxels..." << G4endl;
709 #endif
710 
711  BuildReduceVoxels(miniBoundaries, reductionRatioMini);
712 
713 #ifdef G4SPECSDEBUG
714  G4int total = CountVoxels(miniBoundaries);
715  G4cout << "Total number of mini voxels: " << total << G4endl;
716 #endif
717 
718 #ifdef G4SPECSDEBUG
719  G4cout << "Building mini bitmasks..." << G4endl;
720 #endif
721 
722  BuildBitmasks(miniBoundaries, bitmasksMini);
723 
724 #ifdef G4SPECSDEBUG
725  G4cout << "Creating Mini Voxels..." << G4endl;
726 #endif
727 
728  CreateMiniVoxels(miniBoundaries, bitmasksMini);
729 
730 #ifdef G4SPECSDEBUG
731  G4cout << "Building bounding box..." << G4endl;
732 #endif
733 
734  BuildBoundingBox();
735 
736 #ifdef G4SPECSDEBUG
737  G4cout << "Building empty..." << G4endl;
738 #endif
739 
740  BuildEmpty();
741 
742 #ifdef G4SPECSDEBUG
743  G4cout << "Deallocating unnecessary fields during runtime..." << G4endl;
744 #endif
745  // deallocate fields unnecessary during runtime
746  //
747  fBoxes.resize(0);
748  for (G4int i = 0; i < 3; i++)
749  {
750  fCandidatesCounts[i].resize(0);
751  fBitmasks[i].Clear();
752  }
753  }
754 }
void Clear()
Definition: G4SurfBits.cc:92
CLHEP::Hep3Vector G4ThreeVector
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
G4double total(Particle const *const p1, Particle const *const p2)
#define G4endl
Definition: G4ios.hh:61
long long CountVoxels(std::vector< G4double > boundaries[]) const

Here is the call graph for this function:


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