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

#include <G4SurfaceVoxelizer.hh>

Public Member Functions

void Voxelize (std::vector< G4VFacet * > &facets)
 
void DisplayVoxelLimits ()
 
void DisplayBoundaries ()
 
void DisplayListNodes ()
 
 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
 
G4int GetCandidates (std::vector< G4int > &curVoxel, std::vector< G4int > *&candidates, std::vector< G4int > &space) 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
 

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 ()
 

Friends

class G4VoxelCandidatesIterator
 

Detailed Description

Definition at line 68 of file G4SurfaceVoxelizer.hh.

Constructor & Destructor Documentation

◆ G4SurfaceVoxelizer()

G4SurfaceVoxelizer::G4SurfaceVoxelizer ( )

Definition at line 61 of file G4SurfaceVoxelizer.cc.

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

◆ ~G4SurfaceVoxelizer()

G4SurfaceVoxelizer::~G4SurfaceVoxelizer ( )

Definition at line 74 of file G4SurfaceVoxelizer.cc.

75{
76}

Member Function Documentation

◆ AllocatedMemory()

G4int G4SurfaceVoxelizer::AllocatedMemory ( )

Definition at line 1029 of file G4SurfaceVoxelizer.cc.

1030{
1031 G4int size = fEmpty.GetNbytes();
1032 size += fBoxes.capacity() * sizeof(G4VoxelBox);
1033 size += sizeof(G4double) * (fBoundaries[0].capacity()
1034 + fBoundaries[1].capacity() + fBoundaries[2].capacity());
1035 size += sizeof(G4int) * (fCandidatesCounts[0].capacity()
1036 + fCandidatesCounts[1].capacity() + fCandidatesCounts[2].capacity());
1037 size += fBitmasks[0].GetNbytes() + fBitmasks[1].GetNbytes()
1038 + fBitmasks[2].GetNbytes();
1039
1040 G4int csize = fCandidates.size();
1041 for (G4int i = 0; i < csize; i++)
1042 {
1043 size += sizeof(vector<G4int>) + fCandidates[i].capacity() * sizeof(G4int);
1044 }
1045
1046 return size;
1047}
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
unsigned int GetNbytes() const
Definition: G4SurfBits.hh:102

Referenced by G4TessellatedSolid::AllocatedMemory().

◆ BinarySearch()

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

◆ Contains()

G4bool G4SurfaceVoxelizer::Contains ( const G4ThreeVector point) const

Definition at line 872 of file G4SurfaceVoxelizer.cc.

873{
874 for (G4int i = 0; i < 3; ++i)
875 {
876 if (point[i] < fBoundaries[i].front() || point[i] > fBoundaries[i].back())
877 return false;
878 }
879 return true;
880}

◆ CountVoxels()

long long G4SurfaceVoxelizer::CountVoxels ( std::vector< G4double boundaries[]) const
inline

Referenced by Voxelize().

◆ DisplayBoundaries()

void G4SurfaceVoxelizer::DisplayBoundaries ( )

Definition at line 272 of file G4SurfaceVoxelizer.cc.

273{
274 char axis[3] = {'X', 'Y', 'Z'};
275 for (G4int i = 0; i <= 2; ++i)
276 {
277 G4cout << " * " << axis[i] << " axis:" << endl << " | ";
278 DisplayBoundaries(fBoundaries[i]);
279 }
280}
G4DLLIMPORT std::ostream G4cout

Referenced by DisplayBoundaries().

◆ DisplayListNodes()

void G4SurfaceVoxelizer::DisplayListNodes ( )

Definition at line 374 of file G4SurfaceVoxelizer.cc.

375{
376 // Prints which solids are present in the slices previously elaborated.
377
378 char axis[3] = {'X', 'Y', 'Z'};
379 G4int size=8*sizeof(G4int)*fNPerSlice;
380 G4SurfBits bits(size);
381
382 for (G4int j = 0; j <= 2; ++j)
383 {
384 G4cout << " * " << axis[j] << " axis:" << endl;
385 G4int count = fBoundaries[j].size();
386 for(G4int i=0; i < count-1; ++i)
387 {
388 G4cout << " Slice #" << i+1 << ": [" << fBoundaries[j][i]
389 << " ; " << fBoundaries[j][i+1] << "] -> ";
390 bits.set(size,(const char *)fBitmasks[j].fAllBits+i
391 *fNPerSlice*sizeof(G4int));
392 G4String result = GetCandidatesAsString(bits);
393 G4cout << "[ " << result.c_str() << "] " << endl;
394 }
395 }
396}

◆ DisplayVoxelLimits()

void G4SurfaceVoxelizer::DisplayVoxelLimits ( )

Definition at line 155 of file G4SurfaceVoxelizer.cc.

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

◆ DistanceToBoundingBox()

G4double G4SurfaceVoxelizer::DistanceToBoundingBox ( const G4ThreeVector point) const

Definition at line 894 of file G4SurfaceVoxelizer.cc.

895{
896 G4ThreeVector pointShifted = point - fBoundingBoxCenter;
897 G4double shift = MinDistanceToBox(pointShifted, fBoundingBoxSize);
898 return shift;
899}
static G4double MinDistanceToBox(const G4ThreeVector &aPoint, const G4ThreeVector &f)

Referenced by G4TessellatedSolid::SafetyFromOutside().

◆ DistanceToFirst()

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

Definition at line 884 of file G4SurfaceVoxelizer.cc.

886{
887 G4ThreeVector pointShifted = point - fBoundingBoxCenter;
888 G4double shift = fBoundingBox.DistanceToIn(pointShifted, direction);
889 return shift;
890}
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
Definition: G4Box.cc:556

◆ DistanceToNext()

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

Definition at line 929 of file G4SurfaceVoxelizer.cc.

932{
933 G4double shift = kInfinity;
934
935 for (G4int i = 0; i <= 2; ++i)
936 {
937 // Looking for the next voxels on the considered direction X,Y,Z axis
938 //
939 const vector<G4double> &boundary = fBoundaries[i];
940 G4int cur = curVoxel[i];
941 if(direction[i] >= 1e-10)
942 {
943 if (boundary[cur] - point[i] < fTolerance) // make sure shift would
944 if (++cur >= (G4int) boundary.size()) // be non-zero
945 continue;
946 }
947 else
948 {
949 if(direction[i] <= -1e-10)
950 {
951 if (point[i] - boundary[cur] < fTolerance) // make sure shift would
952 if (--cur < 0) // be non-zero
953 continue;
954 }
955 else
956 continue;
957 }
958 G4double dif = boundary[cur] - point[i];
959 G4double distance = dif / direction[i];
960
961 if (shift > distance)
962 shift = distance;
963 }
964
965 return shift;
966}

◆ Empty()

const G4SurfBits & G4SurfaceVoxelizer::Empty ( ) const
inline

◆ GetBitsPerSlice()

G4int G4SurfaceVoxelizer::GetBitsPerSlice ( ) const
inline

◆ GetBoundary()

const std::vector< G4double > & G4SurfaceVoxelizer::GetBoundary ( G4int  index) const
inline

◆ GetBoxes()

const std::vector< G4VoxelBox > & G4SurfaceVoxelizer::GetBoxes ( ) const
inline

◆ GetCandidates() [1/2]

const std::vector< G4int > & G4SurfaceVoxelizer::GetCandidates ( std::vector< G4int > &  curVoxel) const
inline

◆ GetCandidates() [2/2]

G4int G4SurfaceVoxelizer::GetCandidates ( std::vector< G4int > &  curVoxel,
std::vector< G4int > *&  candidates,
std::vector< G4int > &  space 
) const
inline

◆ GetCandidatesVoxel()

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

Definition at line 704 of file G4SurfaceVoxelizer.cc.

705{
706 // "GetCandidates" should compute which solids are possibly contained in
707 // the voxel defined by the three slices characterized by the passed indexes.
708
709 G4cout << " Candidates in voxel [" << voxels[0] << " ; " << voxels[1]
710 << " ; " << voxels[2] << "]: ";
711 vector<G4int> candidates;
712 G4int count = GetCandidatesVoxelArray(voxels, candidates);
713 G4cout << "[ ";
714 for (G4int i = 0; i < count; ++i) G4cout << candidates[i];
715 G4cout << "] " << endl;
716}
G4int GetCandidatesVoxelArray(const G4ThreeVector &point, std::vector< G4int > &list, G4SurfBits *crossed=0) const

◆ GetCandidatesVoxelArray() [1/3]

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

Definition at line 738 of file G4SurfaceVoxelizer.cc.

740{
741 // Method returning the candidates corresponding to the passed point
742
743 list.clear();
744
745 for (G4int i = 0; i <= 2; ++i)
746 {
747 if(point[i] < fBoundaries[i].front() || point[i] >= fBoundaries[i].back())
748 return 0;
749 }
750
751 if (fTotalCandidates == 1)
752 {
753 list.push_back(0);
754 return 1;
755 }
756 else
757 {
758 if (fNPerSlice == 1)
759 {
760 unsigned int mask;
761 G4int slice = BinarySearch(fBoundaries[0], point.x());
762 if (!(mask = ((unsigned int *) fBitmasks[0].fAllBits)[slice]
763 )) return 0;
764 slice = BinarySearch(fBoundaries[1], point.y());
765 if (!(mask &= ((unsigned int *) fBitmasks[1].fAllBits)[slice]
766 )) return 0;
767 slice = BinarySearch(fBoundaries[2], point.z());
768 if (!(mask &= ((unsigned int *) fBitmasks[2].fAllBits)[slice]
769 )) return 0;
770 if (crossed && (!(mask &= ~((unsigned int *)crossed->fAllBits)[0])))
771 return 0;
772
773 FindComponentsFastest(mask, list, 0);
774 }
775 else
776 {
777 unsigned int *masks[3], mask; // masks for X,Y,Z axis
778 for (G4int i = 0; i <= 2; ++i)
779 {
780 G4int slice = BinarySearch(fBoundaries[i], point[i]);
781 masks[i] = ((unsigned int *) fBitmasks[i].fAllBits) + slice*fNPerSlice;
782 }
783 unsigned int *maskCrossed =
784 crossed ? (unsigned int *)crossed->fAllBits : 0;
785
786 for (G4int i = 0 ; i < fNPerSlice; ++i)
787 {
788 // Logic "and" of the masks along the 3 axes x, y, z:
789 // removing "if (!" and ") continue" => slightly slower
790 //
791 if (!(mask = masks[0][i])) continue;
792 if (!(mask &= masks[1][i])) continue;
793 if (!(mask &= masks[2][i])) continue;
794 if (maskCrossed && !(mask &= ~maskCrossed[i])) continue;
795
796 FindComponentsFastest(mask, list, i);
797 }
798 }
799 }
800 return list.size();
801}
double z() const
double x() const
double y() const
unsigned char * fAllBits
Definition: G4SurfBits.hh:113
static G4int BinarySearch(const std::vector< T > &vec, T value)

Referenced by GetCandidatesVoxel(), and GetCandidatesVoxelArray().

◆ GetCandidatesVoxelArray() [2/3]

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

Definition at line 805 of file G4SurfaceVoxelizer.cc.

809{
810 list.clear();
811
812 if (fTotalCandidates == 1)
813 {
814 list.push_back(0);
815 return 1;
816 }
817 else
818 {
819 if (fNPerSlice == 1)
820 {
821 unsigned int mask;
822 if (!(mask = ((unsigned int *) bitmasks[0].fAllBits)[voxels[0]]
823 )) return 0;
824 if (!(mask &= ((unsigned int *) bitmasks[1].fAllBits)[voxels[1]]
825 )) return 0;
826 if (!(mask &= ((unsigned int *) bitmasks[2].fAllBits)[voxels[2]]
827 )) return 0;
828 if (crossed && (!(mask &= ~((unsigned int *)crossed->fAllBits)[0])))
829 return 0;
830
831 FindComponentsFastest(mask, list, 0);
832 }
833 else
834 {
835 unsigned int *masks[3], mask; // masks for X,Y,Z axis
836 for (G4int i = 0; i <= 2; ++i)
837 {
838 masks[i] = ((unsigned int *) bitmasks[i].fAllBits)
839 + voxels[i]*fNPerSlice;
840 }
841 unsigned int *maskCrossed =
842 crossed ? (unsigned int *)crossed->fAllBits : 0;
843
844 for (G4int i = 0 ; i < fNPerSlice; ++i)
845 {
846 // Logic "and" of the masks along the 3 axes x, y, z:
847 // removing "if (!" and ") continue" => slightly slower
848 //
849 if (!(mask = masks[0][i])) continue;
850 if (!(mask &= masks[1][i])) continue;
851 if (!(mask &= masks[2][i])) continue;
852 if (maskCrossed && !(mask &= ~maskCrossed[i])) continue;
853
854 FindComponentsFastest(mask, list, i);
855 }
856 }
857 }
858 return list.size();
859}

◆ GetCandidatesVoxelArray() [3/3]

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

Definition at line 863 of file G4SurfaceVoxelizer.cc.

865{
866 // Method returning the candidates corresponding to the passed point
867
868 return GetCandidatesVoxelArray(voxels, fBitmasks, list, crossed);
869}

◆ GetCountOfVoxels()

long long G4SurfaceVoxelizer::GetCountOfVoxels ( ) const
inline

◆ GetDefaultVoxelsCount()

G4int G4SurfaceVoxelizer::GetDefaultVoxelsCount ( )
static

Definition at line 1023 of file G4SurfaceVoxelizer.cc.

1024{
1025 return fDefaultVoxelsCount;
1026}

◆ GetMaxVoxels()

G4int G4SurfaceVoxelizer::GetMaxVoxels ( G4ThreeVector ratioOfReduction)
inline

◆ GetPointIndex()

G4int G4SurfaceVoxelizer::GetPointIndex ( const G4ThreeVector p) const
inline

◆ GetVoxel()

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

◆ GetVoxelBox()

const G4VoxelBox & G4SurfaceVoxelizer::GetVoxelBox ( G4int  i) const
inline

◆ GetVoxelBoxCandidates()

const std::vector< G4int > & G4SurfaceVoxelizer::GetVoxelBoxCandidates ( G4int  i) const
inline

◆ GetVoxelBoxesSize()

G4int G4SurfaceVoxelizer::GetVoxelBoxesSize ( ) const
inline

◆ GetVoxelsIndex() [1/2]

G4int G4SurfaceVoxelizer::GetVoxelsIndex ( const std::vector< G4int > &  voxels) const
inline

◆ GetVoxelsIndex() [2/2]

G4int G4SurfaceVoxelizer::GetVoxelsIndex ( G4int  x,
G4int  y,
G4int  z 
) const
inline

◆ IsEmpty()

G4bool G4SurfaceVoxelizer::IsEmpty ( G4int  index) const
inline

◆ MinDistanceToBox()

G4double G4SurfaceVoxelizer::MinDistanceToBox ( const G4ThreeVector aPoint,
const G4ThreeVector f 
)
static

Definition at line 903 of file G4SurfaceVoxelizer.cc.

905{
906 // Estimates the isotropic safety from a point outside the current solid to
907 // any of its surfaces. The algorithm may be accurate or should provide a
908 // fast underestimate.
909
910 G4double safe, safx, safy, safz;
911 safe = safx = -f.x() + std::abs(aPoint.x());
912 safy = -f.y() + std::abs(aPoint.y());
913 if ( safy > safe ) safe = safy;
914 safz = -f.z() + std::abs(aPoint.z());
915 if ( safz > safe ) safe = safz;
916 if (safe < 0.0) return 0.0; // point is inside
917 // if (!aAccurate) return safe;
918 G4double safsq = 0.0;
919 G4int count = 0;
920 if ( safx > 0 ) { safsq += safx*safx; count++; }
921 if ( safy > 0 ) { safsq += safy*safy; count++; }
922 if ( safz > 0 ) { safsq += safz*safz; count++; }
923 if (count == 1) return safe;
924 return std::sqrt(safsq);
925}

Referenced by DistanceToBoundingBox().

◆ SetDefaultVoxelsCount()

G4int G4SurfaceVoxelizer::SetDefaultVoxelsCount ( G4int  count)
static

Definition at line 1015 of file G4SurfaceVoxelizer.cc.

1016{
1017 G4int res = fDefaultVoxelsCount;
1018 fDefaultVoxelsCount = count;
1019 return res;
1020}

◆ SetMaxVoxels() [1/2]

void G4SurfaceVoxelizer::SetMaxVoxels ( const G4ThreeVector reductionRatio)

Definition at line 1008 of file G4SurfaceVoxelizer.cc.

1009{
1010 fMaxVoxels = -1;
1011 fReductionRatio = ratioOfReduction;
1012}

◆ SetMaxVoxels() [2/2]

void G4SurfaceVoxelizer::SetMaxVoxels ( G4int  max)

Definition at line 1001 of file G4SurfaceVoxelizer.cc.

1002{
1003 fMaxVoxels = max;
1004 fReductionRatio.set(0,0,0);
1005}
void set(double x, double y, double z)

Referenced by G4SurfaceVoxelizer(), and G4TessellatedSolid::SetMaxVoxels().

◆ UpdateCurrentVoxel()

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

Definition at line 970 of file G4SurfaceVoxelizer.cc.

973{
974 for (G4int i = 0; i <= 2; ++i)
975 {
976 G4int index = curVoxel[i];
977 const vector<G4double> &boundary = fBoundaries[i];
978
979 if (direction[i] > 0)
980 {
981 if (point[i] >= boundary[++index])
982 if (++curVoxel[i] >= (G4int) boundary.size() - 1)
983 return false;
984 }
985 else
986 {
987 if (point[i] < boundary[index])
988 if (--curVoxel[i] < 0)
989 return false;
990 }
991#ifdef G4SPECSDEBUG
992 G4int indexOK = BinarySearch(boundary, point[i]);
993 if (curVoxel[i] != indexOK)
994 curVoxel[i] = indexOK; // put breakpoint here
995#endif
996 }
997 return true;
998}

◆ Voxelize()

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

Definition at line 611 of file G4SurfaceVoxelizer.cc.

612{
613 G4int maxVoxels = fMaxVoxels;
614 G4ThreeVector reductionRatio = fReductionRatio;
615
616 G4int size = facets.size();
617 if (size < 10)
618 {
619 for (G4int i = 0; i < (G4int) facets.size(); i++)
620 {
621 if (facets[i]->GetNumberOfVertices() > 3) size++;
622 }
623 }
624
625 if ((size >= 10 || maxVoxels > 0) && maxVoxels != 0 && maxVoxels != 1)
626 {
627 BuildVoxelLimits(facets);
628
629 BuildBoundaries();
630
631 BuildBitmasks(fBoundaries, 0, true);
632
633 if (maxVoxels < 0 && reductionRatio == G4ThreeVector())
634 {
635 maxVoxels = fTotalCandidates;
636 if (fTotalCandidates > 1000000) maxVoxels = 1000000;
637 }
638
639 SetReductionRatio(maxVoxels, reductionRatio);
640
641 fCountOfVoxels = CountVoxels(fBoundaries);
642
643#ifdef G4SPECSDEBUG
644 G4cout << "Total number of voxels: " << fCountOfVoxels << endl;
645#endif
646
647 BuildReduceVoxels2(fBoundaries, reductionRatio);
648
649 fCountOfVoxels = CountVoxels(fBoundaries);
650
651#ifdef G4SPECSDEBUG
652 G4cout << "Total number of voxels after reduction: "
653 << fCountOfVoxels << endl;
654#endif
655
656 BuildBitmasks(fBoundaries, fBitmasks);
657
658 G4ThreeVector reductionRatioMini;
659
660 G4SurfBits bitmasksMini[3];
661
662 // section for building mini voxels
663
664 vector<G4double> miniBoundaries[3];
665
666 for (G4int i = 0; i <= 2; ++i) { miniBoundaries[i] = fBoundaries[i]; }
667
668 G4int voxelsCountMini = (fCountOfVoxels >= 1000)
669 ? 100 : fCountOfVoxels / 10;
670
671 // if (voxelCountMini < 8) voxelCountMini = 8;
672 // voxelsCountMini = 1;
673
674 SetReductionRatio(voxelsCountMini, reductionRatioMini);
675
676 BuildReduceVoxels(miniBoundaries, reductionRatioMini);
677
678#ifdef G4SPECSDEBUG
679 G4int total = CountVoxels(miniBoundaries);
680 G4cout << "Total number of mini voxels: " << total << endl;
681#endif
682
683 BuildBitmasks(miniBoundaries, bitmasksMini);
684
685 CreateMiniVoxels(miniBoundaries, bitmasksMini);
686
687 BuildBoundingBox();
688
689 BuildEmpty();
690
691 // deallocate fields unnecessary during runtime
692 //
693 fBoxes.resize(0);
694 for (G4int i = 0; i < 3; i++)
695 {
696 fCandidatesCounts[i].resize(0);
697 fBitmasks[i].Clear();
698 }
699 }
700}
CLHEP::Hep3Vector G4ThreeVector
void Clear()
Definition: G4SurfBits.cc:92
long long CountVoxels(std::vector< G4double > boundaries[]) const

Friends And Related Function Documentation

◆ G4VoxelCandidatesIterator

friend class G4VoxelCandidatesIterator
friend

Definition at line 70 of file G4SurfaceVoxelizer.hh.


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