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);
50 auto index = fIndexMap[key];
51 return fVoxelVector[index];
56 : fpBoundingMesh(&boundingBox)
57 , fResolution((2 * boundingBox.halfSideLengthInY() / pixel))
65 return std::get<2>(pVoxel);
70 G4cout <<
"*********PrintMesh::Size : " << fVoxelVector.size() <<
G4endl;
71 for(
const auto& iter : fVoxelVector)
73 auto data = std::get<2>(iter);
74 G4cout <<
"Index : " << std::get<0>(iter)
75 <<
" number of type : " << std::get<2>(iter).size() <<
G4endl;
76 for(
const auto& it : data)
78 G4cout <<
"_____________" << it.first->GetName() <<
" : " << it.second
90 for(
const auto& iter : fVoxelVector)
92 auto data = std::get<2>(iter);
93 auto it = data.find(type);
104 G4cout <<
"*********PrintVoxel::";
105 G4cout <<
" index : " << index
111 G4cout <<
"_____________" << it.first->GetName() <<
" : " << it.second
120 std::get<2>(pVoxel) = std::move(mapList);
125 auto xlo = fpBoundingMesh->
Getxlo() + index.
x * fResolution;
126 auto ylo = fpBoundingMesh->
Getylo() + index.
y * fResolution;
127 auto zlo = fpBoundingMesh->
Getzlo() + index.
z * fResolution;
128 auto xhi = fpBoundingMesh->
Getxlo() + (index.
x + 1) * fResolution;
129 auto yhi = fpBoundingMesh->
Getylo() + (index.
y + 1) * fResolution;
130 auto zhi = fpBoundingMesh->
Getzlo() + (index.
z + 1) * fResolution;
137 fVoxelVector.clear();
142 return *fpBoundingMesh;
145std::vector<G4DNAMesh::Index>
148 std::vector<Index> neighbors;
149 neighbors.reserve(6);
150 auto xMax = (
G4int) (std::floor(
151 (fpBoundingMesh->
Getxhi() - fpBoundingMesh->
Getxlo()) / fResolution));
152 auto yMax = (
G4int) (std::floor(
153 (fpBoundingMesh->
Getyhi() - fpBoundingMesh->
Getylo()) / fResolution));
154 auto zMax = (
G4int) (std::floor(
155 (fpBoundingMesh->
Getzhi() - fpBoundingMesh->
Getzlo()) / fResolution));
159 neighbors.push_back(
Index(index.
x - 1, index.
y, index.
z));
163 neighbors.push_back(
Index(index.
x, index.
y - 1, index.
z));
167 neighbors.push_back(
Index(index.
x, index.
y, index.
z - 1));
169 if(index.
x + 1 < xMax)
171 neighbors.push_back(
Index(index.
x + 1, index.
y, index.
z));
173 if(index.
y + 1 < yMax)
175 neighbors.push_back(
Index(index.
x, index.
y + 1, index.
z));
177 if(index.
z + 1 < zMax)
179 neighbors.push_back(
Index(index.
x, index.
y, index.
z + 1));
192 exceptionDescription <<
"the position: " <<
position
193 <<
" is not in the box : " << *fpBoundingMesh;
195 exceptionDescription);
199 std::floor((
position.x() - fpBoundingMesh->
Getxlo()) / fResolution);
201 std::floor((
position.y() - fpBoundingMesh->
Getylo()) / fResolution);
203 std::floor((
position.z() - fpBoundingMesh->
Getzlo()) / fResolution);
204 if(dx < 0 || dy < 0 || dz < 0)
207 exceptionDescription <<
"the old index: " <<
position
208 <<
" to new index : " <<
Index(dx, dx, dx);
210 exceptionDescription);
212 return Index{ dx, dy, dz };
216 const G4int& pixels)
const
218 G4int xmax = std::floor(
219 (fpBoundingMesh->
Getxhi() - fpBoundingMesh->
Getxlo()) / fResolution);
220 G4int ymax = std::floor(
221 (fpBoundingMesh->
Getyhi() - fpBoundingMesh->
Getylo()) / fResolution);
222 G4int zmax = std::floor(
223 (fpBoundingMesh->
Getzhi() - fpBoundingMesh->
Getzlo()) / fResolution);
224 auto dx = (
G4int) (index.
x * pixels / xmax);
225 auto dy = (
G4int) (index.
y * pixels / ymax);
226 auto dz = (
G4int) (index.
z * pixels / zmax);
227 if(dx < 0 || dy < 0 || dz < 0)
230 exceptionDescription <<
"the old index: " << index
231 <<
" to new index : " <<
Index(dx, dx, dx);
233 exceptionDescription);
235 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