Import Geant4 10.6.0 source tree
This commit is contained in:
@@ -23,42 +23,35 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// G4Voxelizer inline methods
|
||||
//
|
||||
// History:
|
||||
// 19.10.12 Marek Gayer, created
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
|
||||
template <typename T> inline
|
||||
G4int G4Voxelizer::BinarySearch(const std::vector<T> &vec, T value)
|
||||
G4int G4Voxelizer::BinarySearch(const std::vector<T>& vec, T value)
|
||||
{
|
||||
typename std::vector<T>::const_iterator begin=vec.begin(), end=vec.end();
|
||||
G4int res = std::upper_bound(begin, end, value) - begin - 1;
|
||||
return res;
|
||||
typename std::vector<T>::const_iterator begin=vec.cbegin(), end=vec.cend();
|
||||
return G4int(std::upper_bound(begin, end, value) - begin - 1);
|
||||
}
|
||||
|
||||
inline
|
||||
const std::vector<G4VoxelBox> &G4Voxelizer::GetBoxes() const
|
||||
const std::vector<G4VoxelBox>& G4Voxelizer::GetBoxes() const
|
||||
{
|
||||
return fBoxes;
|
||||
}
|
||||
|
||||
inline
|
||||
const std::vector<G4double> &G4Voxelizer::GetBoundary(G4int index) const
|
||||
const std::vector<G4double>& G4Voxelizer::GetBoundary(G4int index) const
|
||||
{
|
||||
return fBoundaries[index];
|
||||
}
|
||||
|
||||
inline
|
||||
void G4Voxelizer::GetVoxel(std::vector<G4int> &curVoxel,
|
||||
const G4ThreeVector &point) const
|
||||
void G4Voxelizer::GetVoxel(std::vector<G4int>& curVoxel,
|
||||
const G4ThreeVector& point) const
|
||||
{
|
||||
for (G4int i=0; i<=2; ++i)
|
||||
for (auto i=0; i<=2; ++i)
|
||||
{
|
||||
const std::vector<double> &boundary = GetBoundary(i);
|
||||
G4int n = BinarySearch(boundary, point[i]);
|
||||
@@ -80,15 +73,14 @@ inline
|
||||
G4int G4Voxelizer::GetVoxelsIndex(G4int x, G4int y, G4int z) const
|
||||
{
|
||||
if (x < 0 || y < 0 || z < 0) { return -1; }
|
||||
G4int maxX = fBoundaries[0].size();
|
||||
G4int maxY = fBoundaries[1].size();
|
||||
G4int index = x + y*maxX + z*maxX*maxY;
|
||||
std::size_t maxX = fBoundaries[0].size();
|
||||
std::size_t maxY = fBoundaries[1].size();
|
||||
|
||||
return index;
|
||||
return G4int(x + y*maxX + z*maxX*maxY);
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4Voxelizer::GetVoxelsIndex(const std::vector<G4int> &voxels) const
|
||||
G4int G4Voxelizer::GetVoxelsIndex(const std::vector<G4int>& voxels) const
|
||||
{
|
||||
return GetVoxelsIndex(voxels[0], voxels[1], voxels[2]);
|
||||
}
|
||||
@@ -97,14 +89,14 @@ inline
|
||||
G4bool G4Voxelizer::GetPointVoxel(const G4ThreeVector& p,
|
||||
std::vector<G4int>& voxels) const
|
||||
{
|
||||
for (G4int i = 0; i <= 2; ++i)
|
||||
for (auto i = 0; i <= 2; ++i)
|
||||
{
|
||||
if (p[i] < *fBoundaries[i].begin() || p[i] > *fBoundaries[i].end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (G4int i = 0; i <= 2; ++i)
|
||||
for (auto i = 0; i <= 2; ++i)
|
||||
{
|
||||
voxels[i] = BinarySearch(fBoundaries[i], p[i]);
|
||||
}
|
||||
@@ -113,20 +105,19 @@ G4bool G4Voxelizer::GetPointVoxel(const G4ThreeVector& p,
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4Voxelizer::GetPointIndex(const G4ThreeVector &p) const
|
||||
G4int G4Voxelizer::GetPointIndex(const G4ThreeVector& p) const
|
||||
{
|
||||
G4int maxX = fBoundaries[0].size();
|
||||
G4int maxY = fBoundaries[1].size();
|
||||
std::size_t maxX = fBoundaries[0].size();
|
||||
std::size_t maxY = fBoundaries[1].size();
|
||||
G4int x = BinarySearch(fBoundaries[0], p[0]);
|
||||
G4int y = BinarySearch(fBoundaries[1], p[1]);
|
||||
G4int z = BinarySearch(fBoundaries[2], p[2]);
|
||||
G4int index = x + y*maxX + z*maxX*maxY;
|
||||
|
||||
return index;
|
||||
return G4int(x + y*maxX + z*maxX*maxY);
|
||||
}
|
||||
|
||||
inline
|
||||
const G4SurfBits &G4Voxelizer::Empty() const
|
||||
const G4SurfBits& G4Voxelizer::Empty() const
|
||||
{
|
||||
return fEmpty;
|
||||
}
|
||||
@@ -138,7 +129,7 @@ G4bool G4Voxelizer::IsEmpty(G4int index) const
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4Voxelizer::GetMaxVoxels(G4ThreeVector &ratioOfReduction)
|
||||
G4int G4Voxelizer::GetMaxVoxels(G4ThreeVector& ratioOfReduction)
|
||||
{
|
||||
ratioOfReduction = fReductionRatio;
|
||||
return fMaxVoxels;
|
||||
@@ -162,7 +153,7 @@ long long G4Voxelizer::CountVoxels(std::vector<G4double> boundaries[]) const
|
||||
|
||||
inline
|
||||
const std::vector<G4int>&
|
||||
G4Voxelizer::GetCandidates(std::vector<G4int> &curVoxel) const
|
||||
G4Voxelizer::GetCandidates(std::vector<G4int>& curVoxel) const
|
||||
{
|
||||
G4int voxelsIndex = GetVoxelsIndex(curVoxel);
|
||||
|
||||
@@ -182,7 +173,7 @@ G4int G4Voxelizer::GetTotalCandidates() const
|
||||
inline
|
||||
G4int G4Voxelizer::GetVoxelBoxesSize() const
|
||||
{
|
||||
return fVoxelBoxes.size();
|
||||
return G4int(fVoxelBoxes.size());
|
||||
}
|
||||
|
||||
inline
|
||||
|
||||
Reference in New Issue
Block a user