32 stream <<
"{" << rhs.
x <<
", " << rhs.
y <<
", " << rhs.
z <<
"}";
38 auto iter = fIndexMap.find(key);
39 if(iter == fIndexMap.end())
44 fVoxelVector.emplace_back(std::make_tuple(key, box, std::move(mapList)));
45 fIndexMap[key] =
G4int(fVoxelVector.size() - 1);
49 auto index = fIndexMap[key];
50 return fVoxelVector[index];
54 : fpBoundingMesh(&boundingBox)
55 , fResolution((2 * boundingBox.halfSideLengthInY() / pixel))
63 return std::get<2>(pVoxel);
68 G4cout <<
"*********PrintMesh::Size : " << fVoxelVector.size() <<
G4endl;
69 for(
const auto& iter : fVoxelVector)
71 auto data = std::get<2>(iter);
72 G4cout <<
"Index : " << std::get<0>(iter)
73 <<
" number of type : " << std::get<2>(iter).size() <<
G4endl;
74 for(
const auto& it : data)
76 G4cout <<
"_____________" << it.first->GetName() <<
" : " << it.second
88 for(
const auto& iter : fVoxelVector)
90 auto data = std::get<2>(iter);
91 auto it = data.find(type);
102 G4cout <<
"*********PrintVoxel::";
103 G4cout <<
" index : " << index
109 G4cout <<
"_____________" << it.first->GetName() <<
" : " << it.second
118 std::get<2>(pVoxel) = std::move(mapList);
123 auto xlo = fpBoundingMesh->
Getxlo() + index.
x * fResolution;
124 auto ylo = fpBoundingMesh->
Getylo() + index.
y * fResolution;
125 auto zlo = fpBoundingMesh->
Getzlo() + index.
z * fResolution;
126 auto xhi = fpBoundingMesh->
Getxlo() + (index.
x + 1) * fResolution;
127 auto yhi = fpBoundingMesh->
Getylo() + (index.
y + 1) * fResolution;
128 auto zhi = fpBoundingMesh->
Getzlo() + (index.
z + 1) * fResolution;
135 fVoxelVector.clear();
140 return *fpBoundingMesh;
143std::vector<G4DNAMesh::Index>
146 std::vector<Index> neighbors;
147 neighbors.reserve(6);
148 auto xMax = (
G4int) (std::floor(
149 (fpBoundingMesh->
Getxhi() - fpBoundingMesh->
Getxlo()) / fResolution));
150 auto yMax = (
G4int) (std::floor(
151 (fpBoundingMesh->
Getyhi() - fpBoundingMesh->
Getylo()) / fResolution));
152 auto zMax = (
G4int) (std::floor(
153 (fpBoundingMesh->
Getzhi() - fpBoundingMesh->
Getzlo()) / fResolution));
157 neighbors.emplace_back(index.
x - 1, index.
y, index.
z);
161 neighbors.emplace_back(index.
x, index.
y - 1, index.
z);
165 neighbors.emplace_back(index.
x, index.
y, index.
z - 1);
167 if(index.
x + 1 < xMax)
169 neighbors.emplace_back(index.
x + 1, index.
y, index.
z);
171 if(index.
y + 1 < yMax)
173 neighbors.emplace_back(index.
x, index.
y + 1, index.
z);
175 if(index.
z + 1 < zMax)
177 neighbors.emplace_back(index.
x, index.
y, index.
z + 1);
190 exceptionDescription <<
"the position: " <<
position
191 <<
" is not in the box : " << *fpBoundingMesh;
193 exceptionDescription);
197 std::floor((
position.x() - fpBoundingMesh->
Getxlo()) / fResolution);
199 std::floor((
position.y() - fpBoundingMesh->
Getylo()) / fResolution);
201 std::floor((
position.z() - fpBoundingMesh->
Getzlo()) / fResolution);
202 if(dx < 0 || dy < 0 || dz < 0)
205 exceptionDescription <<
"the old index: " <<
position
206 <<
" to new index : " <<
Index(dx, dx, dx);
208 exceptionDescription);
210 return Index{ dx, dy, dz };
214 const G4int& pixels)
const
216 G4int xmax = std::floor(
217 (fpBoundingMesh->
Getxhi() - fpBoundingMesh->
Getxlo()) / fResolution);
218 G4int ymax = std::floor(
219 (fpBoundingMesh->
Getyhi() - fpBoundingMesh->
Getylo()) / fResolution);
220 G4int zmax = std::floor(
221 (fpBoundingMesh->
Getzhi() - fpBoundingMesh->
Getzlo()) / fResolution);
222 auto dx = (
G4int) (index.
x * pixels / xmax);
223 auto dy = (
G4int) (index.
y * pixels / ymax);
224 auto dz = (
G4int) (index.
z * pixels / zmax);
225 if(dx < 0 || dy < 0 || dz < 0)
228 exceptionDescription <<
"the old index: " << index
229 <<
" to new index : " <<
Index(dx, dx, dx);
231 exceptionDescription);
233 return Index{ dx, dy, dz };
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
G4GLOB_DLL std::ostream G4cout
G4bool contains(const G4DNABoundingBox &other) const
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)
G4double GetResolution() const
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