#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 G4SurfBits & | Empty () 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 G4VoxelBox & | GetVoxelBox (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 |
Data Structures | |
class | G4VoxelComparator |
Definition at line 67 of file G4SurfaceVoxelizer.hh.
G4SurfaceVoxelizer::G4SurfaceVoxelizer | ( | ) |
Definition at line 60 of file G4SurfaceVoxelizer.cc.
References G4SolidStore::DeRegister(), G4SolidStore::GetInstance(), G4GeometryTolerance::GetInstance(), G4GeometryTolerance::GetSurfaceTolerance(), and SetMaxVoxels().
00061 : fBoundingBox("TessBBox", 1, 1, 1) 00062 { 00063 fCountOfVoxels = fNPerSlice = fTotalCandidates = 0; 00064 00065 fTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance(); 00066 00067 SetMaxVoxels(fDefaultVoxelsCount); 00068 00069 G4SolidStore::GetInstance()->DeRegister(&fBoundingBox); 00070 }
G4SurfaceVoxelizer::~G4SurfaceVoxelizer | ( | ) |
G4int G4SurfaceVoxelizer::AllocatedMemory | ( | ) |
Definition at line 1083 of file G4SurfaceVoxelizer.cc.
References G4SurfBits::GetNbytes().
Referenced by G4TessellatedSolid::AllocatedMemory().
01084 { 01085 G4int size = fEmpty.GetNbytes(); 01086 size += fBoxes.capacity() * sizeof(G4VoxelBox); 01087 size += sizeof(G4double) * (fBoundaries[0].capacity() 01088 + fBoundaries[1].capacity() + fBoundaries[2].capacity()); 01089 size += sizeof(G4int) * (fCandidatesCounts[0].capacity() 01090 + fCandidatesCounts[1].capacity() + fCandidatesCounts[2].capacity()); 01091 size += fBitmasks[0].GetNbytes() + fBitmasks[1].GetNbytes() 01092 + fBitmasks[2].GetNbytes(); 01093 01094 G4int csize = fCandidates.size(); 01095 for (G4int i = 0; i < csize; i++) 01096 { 01097 size += sizeof(vector<G4int>) + fCandidates[i].capacity() * sizeof(G4int); 01098 } 01099 01100 return size; 01101 }
G4int G4SurfaceVoxelizer::BinarySearch | ( | const std::vector< T > & | vec, | |
T | value | |||
) | [inline, static] |
Definition at line 39 of file G4SurfaceVoxelizer.icc.
Referenced by GetCandidatesVoxelArray(), GetPointIndex(), GetVoxel(), and UpdateCurrentVoxel().
00040 { 00041 typename std::vector<T>::const_iterator begin=vec.begin(), end=vec.end(); 00042 G4int res = std::upper_bound(begin, end, value) - begin - 1; 00043 return res; 00044 }
G4bool G4SurfaceVoxelizer::Contains | ( | const G4ThreeVector & | point | ) | const |
Definition at line 926 of file G4SurfaceVoxelizer.cc.
00927 { 00928 for (G4int i = 0; i < 3; ++i) 00929 { 00930 if (point[i] < fBoundaries[i].front() || point[i] > fBoundaries[i].back()) 00931 return false; 00932 } 00933 return true; 00934 }
long long G4SurfaceVoxelizer::CountVoxels | ( | std::vector< G4double > | boundaries[] | ) | const [inline] |
Definition at line 130 of file G4SurfaceVoxelizer.icc.
Referenced by Voxelize().
00131 { 00132 long long sx = boundaries[0].size() - 1; 00133 long long sy = boundaries[1].size() - 1; 00134 long long sz = boundaries[2].size() - 1; 00135 00136 return sx * sy *sz; 00137 }
void G4SurfaceVoxelizer::DisplayBoundaries | ( | ) |
Definition at line 281 of file G4SurfaceVoxelizer.cc.
References G4cout, and G4endl.
00282 { 00283 char axis[3] = {'X', 'Y', 'Z'}; 00284 for (G4int i = 0; i <= 2; ++i) 00285 { 00286 G4cout << " * " << axis[i] << " axis:" << G4endl << " | "; 00287 DisplayBoundaries(fBoundaries[i]); 00288 } 00289 }
void G4SurfaceVoxelizer::DisplayListNodes | ( | ) |
Definition at line 389 of file G4SurfaceVoxelizer.cc.
References G4cout, and G4SurfBits::set().
00390 { 00391 // Prints which solids are present in the slices previously elaborated. 00392 00393 char axis[3] = {'X', 'Y', 'Z'}; 00394 G4int size=8*sizeof(G4int)*fNPerSlice; 00395 G4SurfBits bits(size); 00396 00397 for (G4int j = 0; j <= 2; ++j) 00398 { 00399 G4cout << " * " << axis[j] << " axis:" << G4endl; 00400 G4int count = fBoundaries[j].size(); 00401 for(G4int i=0; i < count-1; ++i) 00402 { 00403 G4cout << " Slice #" << i+1 << ": [" << fBoundaries[j][i] 00404 << " ; " << fBoundaries[j][i+1] << "] -> "; 00405 bits.set(size,(const char *)fBitmasks[j].fAllBits+i 00406 *fNPerSlice*sizeof(G4int)); 00407 G4String result = GetCandidatesAsString(bits); 00408 G4cout << "[ " << result.c_str() << "] " << G4endl; 00409 } 00410 } 00411 }
void G4SurfaceVoxelizer::DisplayVoxelLimits | ( | ) |
Definition at line 154 of file G4SurfaceVoxelizer.cc.
References G4cout.
00155 { 00156 // "DisplayVoxelLimits" displays the dX, dY, dZ, pX, pY and pZ for each node 00157 00158 G4int numNodes = fBoxes.size(); 00159 G4int oldprec = G4cout.precision(16); 00160 for(G4int i = 0; i < numNodes; ++i) 00161 { 00162 G4cout << setw(10) << setiosflags(ios::fixed) << 00163 " -> Node " << i+1 << ":\n" << 00164 "\t * [x,y,z] = " << fBoxes[i].hlen << 00165 "\t * [x,y,z] = " << fBoxes[i].pos << "\n"; 00166 } 00167 G4cout.precision(oldprec); 00168 }
G4double G4SurfaceVoxelizer::DistanceToBoundingBox | ( | const G4ThreeVector & | point | ) | const |
Definition at line 948 of file G4SurfaceVoxelizer.cc.
References MinDistanceToBox().
Referenced by G4TessellatedSolid::SafetyFromOutside().
00949 { 00950 G4ThreeVector pointShifted = point - fBoundingBoxCenter; 00951 G4double shift = MinDistanceToBox(pointShifted, fBoundingBoxSize); 00952 return shift; 00953 }
G4double G4SurfaceVoxelizer::DistanceToFirst | ( | const G4ThreeVector & | point, | |
const G4ThreeVector & | direction | |||
) | const |
Definition at line 938 of file G4SurfaceVoxelizer.cc.
References G4Box::DistanceToIn().
00940 { 00941 G4ThreeVector pointShifted = point - fBoundingBoxCenter; 00942 G4double shift = fBoundingBox.DistanceToIn(pointShifted, direction); 00943 return shift; 00944 }
G4double G4SurfaceVoxelizer::DistanceToNext | ( | const G4ThreeVector & | point, | |
const G4ThreeVector & | direction, | |||
const std::vector< G4int > & | curVoxel | |||
) | const |
Definition at line 983 of file G4SurfaceVoxelizer.cc.
00986 { 00987 G4double shift = kInfinity; 00988 00989 for (G4int i = 0; i <= 2; ++i) 00990 { 00991 // Looking for the next voxels on the considered direction X,Y,Z axis 00992 // 00993 const vector<G4double> &boundary = fBoundaries[i]; 00994 G4int cur = curVoxel[i]; 00995 if(direction[i] >= 1e-10) 00996 { 00997 if (boundary[cur] - point[i] < fTolerance) // make sure shift would 00998 if (++cur >= (G4int) boundary.size()) // be non-zero 00999 continue; 01000 } 01001 else 01002 { 01003 if(direction[i] <= -1e-10) 01004 { 01005 if (point[i] - boundary[cur] < fTolerance) // make sure shift would 01006 if (--cur < 0) // be non-zero 01007 continue; 01008 } 01009 else 01010 continue; 01011 } 01012 G4double dif = boundary[cur] - point[i]; 01013 G4double distance = dif / direction[i]; 01014 01015 if (shift > distance) 01016 shift = distance; 01017 } 01018 01019 return shift; 01020 }
const G4SurfBits & G4SurfaceVoxelizer::Empty | ( | ) | const [inline] |
G4int G4SurfaceVoxelizer::GetBitsPerSlice | ( | ) | const [inline] |
const std::vector< G4VoxelBox > & G4SurfaceVoxelizer::GetBoxes | ( | ) | const [inline] |
const std::vector< G4int > & G4SurfaceVoxelizer::GetCandidates | ( | std::vector< G4int > & | curVoxel | ) | const [inline] |
Definition at line 141 of file G4SurfaceVoxelizer.icc.
References GetVoxelsIndex().
00142 { 00143 G4int voxelsIndex = GetVoxelsIndex(curVoxel); 00144 00145 if (voxelsIndex >= 0 && !fEmpty[voxelsIndex]) 00146 { 00147 return fCandidates[voxelsIndex]; 00148 } 00149 return fNoCandidates; 00150 }
G4int G4SurfaceVoxelizer::GetCandidates | ( | std::vector< G4int > & | curVoxel, | |
std::vector< G4int > *& | candidates, | |||
std::vector< G4int > & | space | |||
) | const [inline] |
Referenced by G4TessellatedSolid::Normal(), and G4TessellatedSolid::SafetyFromOutside().
void G4SurfaceVoxelizer::GetCandidatesVoxel | ( | std::vector< G4int > & | voxels | ) |
Definition at line 758 of file G4SurfaceVoxelizer.cc.
References G4cout, and GetCandidatesVoxelArray().
00759 { 00760 // "GetCandidates" should compute which solids are possibly contained in 00761 // the voxel defined by the three slices characterized by the passed indexes. 00762 00763 G4cout << " Candidates in voxel [" << voxels[0] << " ; " << voxels[1] 00764 << " ; " << voxels[2] << "]: "; 00765 vector<G4int> candidates; 00766 G4int count = GetCandidatesVoxelArray(voxels, candidates); 00767 G4cout << "[ "; 00768 for (G4int i = 0; i < count; ++i) G4cout << candidates[i]; 00769 G4cout << "] " << G4endl; 00770 }
G4int G4SurfaceVoxelizer::GetCandidatesVoxelArray | ( | const std::vector< G4int > & | voxels, | |
std::vector< G4int > & | list, | |||
G4SurfBits * | crossed = 0 | |||
) | const |
Definition at line 917 of file G4SurfaceVoxelizer.cc.
References GetCandidatesVoxelArray().
00919 { 00920 // Method returning the candidates corresponding to the passed point 00921 00922 return GetCandidatesVoxelArray(voxels, fBitmasks, list, crossed); 00923 }
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.
References G4SurfBits::fAllBits.
00863 { 00864 list.clear(); 00865 00866 if (fTotalCandidates == 1) 00867 { 00868 list.push_back(0); 00869 return 1; 00870 } 00871 else 00872 { 00873 if (fNPerSlice == 1) 00874 { 00875 unsigned int mask; 00876 if (!(mask = ((unsigned int *) bitmasks[0].fAllBits)[voxels[0]] 00877 )) return 0; 00878 if (!(mask &= ((unsigned int *) bitmasks[1].fAllBits)[voxels[1]] 00879 )) return 0; 00880 if (!(mask &= ((unsigned int *) bitmasks[2].fAllBits)[voxels[2]] 00881 )) return 0; 00882 if (crossed && (!(mask &= ~((unsigned int *)crossed->fAllBits)[0]))) 00883 return 0; 00884 00885 FindComponentsFastest(mask, list, 0); 00886 } 00887 else 00888 { 00889 unsigned int *masks[3], mask; // masks for X,Y,Z axis 00890 for (G4int i = 0; i <= 2; ++i) 00891 { 00892 masks[i] = ((unsigned int *) bitmasks[i].fAllBits) 00893 + voxels[i]*fNPerSlice; 00894 } 00895 unsigned int *maskCrossed = 00896 crossed ? (unsigned int *)crossed->fAllBits : 0; 00897 00898 for (G4int i = 0 ; i < fNPerSlice; ++i) 00899 { 00900 // Logic "and" of the masks along the 3 axes x, y, z: 00901 // removing "if (!" and ") continue" => slightly slower 00902 // 00903 if (!(mask = masks[0][i])) continue; 00904 if (!(mask &= masks[1][i])) continue; 00905 if (!(mask &= masks[2][i])) continue; 00906 if (maskCrossed && !(mask &= ~maskCrossed[i])) continue; 00907 00908 FindComponentsFastest(mask, list, i); 00909 } 00910 } 00911 } 00912 return list.size(); 00913 }
G4int G4SurfaceVoxelizer::GetCandidatesVoxelArray | ( | const G4ThreeVector & | point, | |
std::vector< G4int > & | list, | |||
G4SurfBits * | crossed = 0 | |||
) | const |
Definition at line 792 of file G4SurfaceVoxelizer.cc.
References BinarySearch(), and G4SurfBits::fAllBits.
Referenced by GetCandidatesVoxel(), and GetCandidatesVoxelArray().
00794 { 00795 // Method returning the candidates corresponding to the passed point 00796 00797 list.clear(); 00798 00799 for (G4int i = 0; i <= 2; ++i) 00800 { 00801 if(point[i] < fBoundaries[i].front() || point[i] >= fBoundaries[i].back()) 00802 return 0; 00803 } 00804 00805 if (fTotalCandidates == 1) 00806 { 00807 list.push_back(0); 00808 return 1; 00809 } 00810 else 00811 { 00812 if (fNPerSlice == 1) 00813 { 00814 unsigned int mask; 00815 G4int slice = BinarySearch(fBoundaries[0], point.x()); 00816 if (!(mask = ((unsigned int *) fBitmasks[0].fAllBits)[slice] 00817 )) return 0; 00818 slice = BinarySearch(fBoundaries[1], point.y()); 00819 if (!(mask &= ((unsigned int *) fBitmasks[1].fAllBits)[slice] 00820 )) return 0; 00821 slice = BinarySearch(fBoundaries[2], point.z()); 00822 if (!(mask &= ((unsigned int *) fBitmasks[2].fAllBits)[slice] 00823 )) return 0; 00824 if (crossed && (!(mask &= ~((unsigned int *)crossed->fAllBits)[0]))) 00825 return 0; 00826 00827 FindComponentsFastest(mask, list, 0); 00828 } 00829 else 00830 { 00831 unsigned int *masks[3], mask; // masks for X,Y,Z axis 00832 for (G4int i = 0; i <= 2; ++i) 00833 { 00834 G4int slice = BinarySearch(fBoundaries[i], point[i]); 00835 masks[i] = ((unsigned int *) fBitmasks[i].fAllBits) + slice*fNPerSlice; 00836 } 00837 unsigned int *maskCrossed = 00838 crossed ? (unsigned int *)crossed->fAllBits : 0; 00839 00840 for (G4int i = 0 ; i < fNPerSlice; ++i) 00841 { 00842 // Logic "and" of the masks along the 3 axes x, y, z: 00843 // removing "if (!" and ") continue" => slightly slower 00844 // 00845 if (!(mask = masks[0][i])) continue; 00846 if (!(mask &= masks[1][i])) continue; 00847 if (!(mask &= masks[2][i])) continue; 00848 if (maskCrossed && !(mask &= ~maskCrossed[i])) continue; 00849 00850 FindComponentsFastest(mask, list, i); 00851 } 00852 } 00853 } 00854 return list.size(); 00855 }
long long G4SurfaceVoxelizer::GetCountOfVoxels | ( | ) | const [inline] |
Definition at line 124 of file G4SurfaceVoxelizer.icc.
Referenced by G4TessellatedSolid::Inside(), G4TessellatedSolid::Normal(), G4TessellatedSolid::SafetyFromInside(), and G4TessellatedSolid::SafetyFromOutside().
G4int G4SurfaceVoxelizer::GetDefaultVoxelsCount | ( | ) | [static] |
G4int G4SurfaceVoxelizer::GetMaxVoxels | ( | G4ThreeVector & | ratioOfReduction | ) | [inline] |
G4int G4SurfaceVoxelizer::GetPointIndex | ( | const G4ThreeVector & | p | ) | const [inline] |
Definition at line 92 of file G4SurfaceVoxelizer.icc.
References BinarySearch().
Referenced by G4TessellatedSolid::SafetyFromOutside().
00093 { 00094 G4int maxX = fBoundaries[0].size(); 00095 G4int maxY = fBoundaries[1].size(); 00096 G4int x = BinarySearch(fBoundaries[0], p[0]); 00097 G4int y = BinarySearch(fBoundaries[1], p[1]); 00098 G4int z = BinarySearch(fBoundaries[2], p[2]); 00099 G4int index = x + y*maxX + z*maxX*maxY; 00100 00101 return index; 00102 }
void G4SurfaceVoxelizer::GetVoxel | ( | std::vector< G4int > & | curVoxel, | |
const G4ThreeVector & | point | |||
) | const [inline] |
Definition at line 59 of file G4SurfaceVoxelizer.icc.
References BinarySearch(), and GetBoundary().
Referenced by G4TessellatedSolid::Normal(), and G4TessellatedSolid::SafetyFromOutside().
00061 { 00062 for (G4int i=0; i<=2; ++i) 00063 { 00064 curVoxel[i] = BinarySearch(GetBoundary(i), point[i]); 00065 } 00066 }
const G4VoxelBox & G4SurfaceVoxelizer::GetVoxelBox | ( | G4int | i | ) | const [inline] |
G4int G4SurfaceVoxelizer::GetVoxelBoxesSize | ( | ) | const [inline] |
Definition at line 86 of file G4SurfaceVoxelizer.icc.
References GetVoxelsIndex().
00087 { 00088 return GetVoxelsIndex(voxels[0], voxels[1], voxels[2]); 00089 }
Definition at line 75 of file G4SurfaceVoxelizer.icc.
Referenced by GetCandidates(), and GetVoxelsIndex().
00076 { 00077 if (x < 0 || y < 0 || z < 0) { return -1; } 00078 G4int maxX = fBoundaries[0].size(); 00079 G4int maxY = fBoundaries[1].size(); 00080 G4int index = x + y*maxX + z*maxX*maxY; 00081 00082 return index; 00083 }
G4double G4SurfaceVoxelizer::MinDistanceToBox | ( | const G4ThreeVector & | aPoint, | |
const G4ThreeVector & | f | |||
) | [static] |
Definition at line 957 of file G4SurfaceVoxelizer.cc.
Referenced by DistanceToBoundingBox().
00959 { 00960 // Estimates the isotropic safety from a point outside the current solid to 00961 // any of its surfaces. The algorithm may be accurate or should provide a 00962 // fast underestimate. 00963 00964 G4double safe, safx, safy, safz; 00965 safe = safx = -f.x() + std::abs(aPoint.x()); 00966 safy = -f.y() + std::abs(aPoint.y()); 00967 if ( safy > safe ) safe = safy; 00968 safz = -f.z() + std::abs(aPoint.z()); 00969 if ( safz > safe ) safe = safz; 00970 if (safe < 0.0) return 0.0; // point is inside 00971 // if (!aAccurate) return safe; 00972 G4double safsq = 0.0; 00973 G4int count = 0; 00974 if ( safx > 0 ) { safsq += safx*safx; count++; } 00975 if ( safy > 0 ) { safsq += safy*safy; count++; } 00976 if ( safz > 0 ) { safsq += safz*safz; count++; } 00977 if (count == 1) return safe; 00978 return std::sqrt(safsq); 00979 }
Definition at line 1069 of file G4SurfaceVoxelizer.cc.
01070 { 01071 G4int res = fDefaultVoxelsCount; 01072 fDefaultVoxelsCount = count; 01073 return res; 01074 }
void G4SurfaceVoxelizer::SetMaxVoxels | ( | const G4ThreeVector & | reductionRatio | ) |
void G4SurfaceVoxelizer::SetMaxVoxels | ( | G4int | max | ) |
Definition at line 1055 of file G4SurfaceVoxelizer.cc.
Referenced by G4SurfaceVoxelizer(), and G4TessellatedSolid::SetMaxVoxels().
G4bool G4SurfaceVoxelizer::UpdateCurrentVoxel | ( | const G4ThreeVector & | point, | |
const G4ThreeVector & | direction, | |||
std::vector< G4int > & | curVoxel | |||
) | const |
Definition at line 1024 of file G4SurfaceVoxelizer.cc.
References BinarySearch().
01027 { 01028 for (G4int i = 0; i <= 2; ++i) 01029 { 01030 G4int index = curVoxel[i]; 01031 const vector<G4double> &boundary = fBoundaries[i]; 01032 01033 if (direction[i] > 0) 01034 { 01035 if (point[i] >= boundary[++index]) 01036 if (++curVoxel[i] >= (G4int) boundary.size() - 1) 01037 return false; 01038 } 01039 else 01040 { 01041 if (point[i] < boundary[index]) 01042 if (--curVoxel[i] < 0) 01043 return false; 01044 } 01045 #ifdef G4SPECSDEBUG 01046 G4int indexOK = BinarySearch(boundary, point[i]); 01047 if (curVoxel[i] != indexOK) 01048 curVoxel[i] = indexOK; // put breakpoint here 01049 #endif 01050 } 01051 return true; 01052 }
void G4SurfaceVoxelizer::Voxelize | ( | std::vector< G4VFacet * > & | facets | ) |
Definition at line 626 of file G4SurfaceVoxelizer.cc.
References G4SurfBits::Clear(), CountVoxels(), and G4cout.
00627 { 00628 G4int maxVoxels = fMaxVoxels; 00629 G4ThreeVector reductionRatio = fReductionRatio; 00630 00631 G4int size = facets.size(); 00632 if (size < 10) 00633 { 00634 for (G4int i = 0; i < (G4int) facets.size(); i++) 00635 { 00636 if (facets[i]->GetNumberOfVertices() > 3) size++; 00637 } 00638 } 00639 00640 if ((size >= 10 || maxVoxels > 0) && maxVoxels != 0 && maxVoxels != 1) 00641 { 00642 #ifdef G4SPECSDEBUG 00643 G4cout << "Building voxel limits..." << G4endl; 00644 #endif 00645 00646 BuildVoxelLimits(facets); 00647 00648 #ifdef G4SPECSDEBUG 00649 G4cout << "Building boundaries..." << G4endl; 00650 #endif 00651 00652 BuildBoundaries(); 00653 00654 #ifdef G4SPECSDEBUG 00655 G4cout << "Building bitmasks..." << G4endl; 00656 #endif 00657 00658 BuildBitmasks(fBoundaries, 0, true); 00659 00660 if (maxVoxels < 0 && reductionRatio == G4ThreeVector()) 00661 { 00662 maxVoxels = fTotalCandidates; 00663 if (fTotalCandidates > 1000000) maxVoxels = 1000000; 00664 } 00665 00666 SetReductionRatio(maxVoxels, reductionRatio); 00667 00668 fCountOfVoxels = CountVoxels(fBoundaries); 00669 00670 #ifdef G4SPECSDEBUG 00671 G4cout << "Total number of voxels: " << fCountOfVoxels << G4endl; 00672 #endif 00673 00674 BuildReduceVoxels2(fBoundaries, reductionRatio); 00675 00676 fCountOfVoxels = CountVoxels(fBoundaries); 00677 00678 #ifdef G4SPECSDEBUG 00679 G4cout << "Total number of voxels after reduction: " 00680 << fCountOfVoxels << G4endl; 00681 #endif 00682 00683 #ifdef G4SPECSDEBUG 00684 G4cout << "Building bitmasks..." << G4endl; 00685 #endif 00686 00687 BuildBitmasks(fBoundaries, fBitmasks); 00688 00689 G4ThreeVector reductionRatioMini; 00690 00691 G4SurfBits bitmasksMini[3]; 00692 00693 // section for building mini voxels 00694 00695 vector<G4double> miniBoundaries[3]; 00696 00697 for (G4int i = 0; i <= 2; ++i) { miniBoundaries[i] = fBoundaries[i]; } 00698 00699 G4int voxelsCountMini = (fCountOfVoxels >= 1000) 00700 ? 100 : fCountOfVoxels / 10; 00701 00702 // if (voxelCountMini < 8) voxelCountMini = 8; 00703 // voxelsCountMini = 1; 00704 00705 SetReductionRatio(voxelsCountMini, reductionRatioMini); 00706 00707 #ifdef G4SPECSDEBUG 00708 G4cout << "Building reduced voxels..." << G4endl; 00709 #endif 00710 00711 BuildReduceVoxels(miniBoundaries, reductionRatioMini); 00712 00713 #ifdef G4SPECSDEBUG 00714 G4int total = CountVoxels(miniBoundaries); 00715 G4cout << "Total number of mini voxels: " << total << G4endl; 00716 #endif 00717 00718 #ifdef G4SPECSDEBUG 00719 G4cout << "Building mini bitmasks..." << G4endl; 00720 #endif 00721 00722 BuildBitmasks(miniBoundaries, bitmasksMini); 00723 00724 #ifdef G4SPECSDEBUG 00725 G4cout << "Creating Mini Voxels..." << G4endl; 00726 #endif 00727 00728 CreateMiniVoxels(miniBoundaries, bitmasksMini); 00729 00730 #ifdef G4SPECSDEBUG 00731 G4cout << "Building bounding box..." << G4endl; 00732 #endif 00733 00734 BuildBoundingBox(); 00735 00736 #ifdef G4SPECSDEBUG 00737 G4cout << "Building empty..." << G4endl; 00738 #endif 00739 00740 BuildEmpty(); 00741 00742 #ifdef G4SPECSDEBUG 00743 G4cout << "Deallocating unnecessary fields during runtime..." << G4endl; 00744 #endif 00745 // deallocate fields unnecessary during runtime 00746 // 00747 fBoxes.resize(0); 00748 for (G4int i = 0; i < 3; i++) 00749 { 00750 fCandidatesCounts[i].resize(0); 00751 fBitmasks[i].Clear(); 00752 } 00753 } 00754 }
friend class G4VoxelCandidatesIterator [friend] |
Definition at line 69 of file G4SurfaceVoxelizer.hh.