33 stream <<
"{" << rhs.
x <<
", " << rhs.
y <<
", " << rhs.
z <<
"}";
39 auto iter = fIndexMap.find(key);
40 if(iter == fIndexMap.end())
45 fVoxelVector.emplace_back(std::make_tuple(key, box, std::move(mapList)));
46 fIndexMap[key] =
G4int(fVoxelVector.size() - 1);
50 auto index = fIndexMap[key];
51 return fVoxelVector[index];
55 : fpBoundingMesh(&boundingBox)
56 , fResolution((2 * boundingBox.halfSideLengthInY() / pixel))
64 return std::get<2>(pVoxel);
69 G4cout <<
"*********PrintMesh::Size : " << fVoxelVector.size() <<
G4endl;
70 for(
const auto& iter : fVoxelVector)
72 auto data = std::get<2>(iter);
73 G4cout <<
"Index : " << std::get<0>(iter)
74 <<
" number of type : " << std::get<2>(iter).size() <<
G4endl;
75 for(
const auto& it : data)
77 G4cout <<
"_____________" << it.first->GetName() <<
" : " << it.second
89 for(
const auto& iter : fVoxelVector)
91 auto data = std::get<2>(iter);
92 auto it = data.find(type);
103 G4cout <<
"*********PrintVoxel::";
104 G4cout <<
" index : " << index
110 G4cout <<
"_____________" << it.first->GetName() <<
" : " << it.second
119 std::get<2>(pVoxel) = std::move(mapList);
124 auto xlo = fpBoundingMesh->
Getxlo() + index.
x * fResolution;
125 auto ylo = fpBoundingMesh->Getylo() + index.
y * fResolution;
126 auto zlo = fpBoundingMesh->Getzlo() + index.
z * fResolution;
127 auto xhi = fpBoundingMesh->Getxlo() + (index.
x + 1) * fResolution;
128 auto yhi = fpBoundingMesh->Getylo() + (index.
y + 1) * fResolution;
129 auto zhi = fpBoundingMesh->Getzlo() + (index.
z + 1) * fResolution;
136 fVoxelVector.clear();
141 return *fpBoundingMesh;
144std::vector<G4DNAMesh::Index>
147 std::vector<Index> neighbors;
148 neighbors.reserve(6);
149 auto xMax = (
G4int) (std::floor(
150 (fpBoundingMesh->Getxhi() - fpBoundingMesh->Getxlo()) / fResolution));
151 auto yMax = (
G4int) (std::floor(
152 (fpBoundingMesh->Getyhi() - fpBoundingMesh->Getylo()) / fResolution));
153 auto zMax = (
G4int) (std::floor(
154 (fpBoundingMesh->Getzhi() - fpBoundingMesh->Getzlo()) / fResolution));
158 neighbors.emplace_back(index.
x - 1, index.
y, index.
z);
162 neighbors.emplace_back(index.
x, index.
y - 1, index.
z);
166 neighbors.emplace_back(index.
x, index.
y, index.
z - 1);
168 if(index.
x + 1 < xMax)
170 neighbors.emplace_back(index.
x + 1, index.
y, index.
z);
172 if(index.
y + 1 < yMax)
174 neighbors.emplace_back(index.
x, index.
y + 1, index.
z);
176 if(index.
z + 1 < zMax)
178 neighbors.emplace_back(index.
x, index.
y, index.
z + 1);
188 if(!fpBoundingMesh->contains(
position))
191 exceptionDescription <<
"the position: " <<
position
192 <<
" is not in the box : " << *fpBoundingMesh;
194 exceptionDescription);
198 std::floor((
position.x() - fpBoundingMesh->Getxlo()) / fResolution);
200 std::floor((
position.y() - fpBoundingMesh->Getylo()) / fResolution);
202 std::floor((
position.z() - fpBoundingMesh->Getzlo()) / fResolution);
203 if(dx < 0 || dy < 0 || dz < 0)
206 exceptionDescription <<
"the old index: " <<
position
207 <<
" to new index : " <<
Index(dx, dx, dx);
209 exceptionDescription);
211 return Index{ dx, dy, dz };
215 const G4int& pixels)
const
217 G4int xmax = std::floor(
218 (fpBoundingMesh->Getxhi() - fpBoundingMesh->Getxlo()) / fResolution);
219 G4int ymax = std::floor(
220 (fpBoundingMesh->Getyhi() - fpBoundingMesh->Getylo()) / fResolution);
221 G4int zmax = std::floor(
222 (fpBoundingMesh->Getzhi() - fpBoundingMesh->Getzlo()) / fResolution);
223 auto dx = (
G4int) (index.
x * pixels / xmax);
224 auto dy = (
G4int) (index.
y * pixels / ymax);
225 auto dz = (
G4int) (index.
z * pixels / zmax);
226 if(dx < 0 || dy < 0 || dz < 0)
229 exceptionDescription <<
"the old index: " << index
230 <<
" to new index : " <<
Index(dx, dx, dx);
232 exceptionDescription);
234 return Index{ dx, dy, dz };
240 G4double x_max = (oldIndex.
x + 1) * OldReso;
242 G4double y_max = (oldIndex.
y + 1) * OldReso;
244 G4double z_max = (oldIndex.
z + 1) * OldReso;
246 G4int i_max = std::floor(x_max / fResolution);
247 G4int j_max = std::floor(y_max / fResolution);
248 G4int k_max = std::floor(z_max / fResolution);
250 G4int i_min = std::floor(x_min / fResolution);
251 G4int j_min = std::floor(y_min / fResolution);
252 G4int k_min = std::floor(z_min / fResolution);
258 G4int i_n = i_min + (
G4int)std::floor(r1 * (i_max - i_min + 1));
259 G4int j_n = j_min + (
G4int)std::floor(r2 * (j_max - j_min + 1));
260 G4int k_n = k_min + (
G4int)std::floor(r3 * (k_max - k_min + 1));
262 return Index{ i_n, j_n, k_n };
std::ostream & operator<<(std::ostream &stream, const G4VDNAMesh::Index &rhs)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cout
void InitializeVoxel(const Index &key, Data &&mapList)
std::tuple< Index, Box, Data > Voxel
void PrintVoxel(const Index &index)
G4int GetNumberOfType(MolType type) const
Index ConvertIndex(const Index &index, const G4int &) const
Voxel & GetVoxel(const Index &index)
Index GetRandomIndex(const Index &, const G4double &resolution) const
G4double GetResolution() const
const G4MolecularConfiguration * MolType
Data & GetVoxelMapList(const Index &index)
std::map< MolType, size_t > Data
const G4DNABoundingBox & GetBoundingBox() const
G4DNAMesh(const G4DNABoundingBox &, G4int)
Index GetIndex(const G4ThreeVector &position) const
std::vector< Index > FindNeighboringVoxels(const Index &index) const