86 if (command == fUserVolumeCmd) {
88 std::vector<G4String> params = GetWordsInString( newValues );
89 if( params.size() < 8 ) {
91 " There must be at least 8 parameter: SOLID_TYPE POS_X POS_Y POS_Z "
92 "ANG_X ANG_Y ANG_Z SOLID_PARAM_1 (SOLID_PARAM_2 ...)",
94 G4String(
"Number of parameters given = " +
100 BuildUserSolid(params);
107 std::vector<double> angles;
113 }
else if (command == fG4VolumeCmd) {
114 std::vector<G4String> params = GetWordsInString( newValues );
115 if( params.size() !=1 )
122 " needs 1 argument: VOLUME_NAME").c_str());
125 BuildG4Solid(params);
152 G4String thePhantomFileName =
"phantom.g4pdcm";
153 fout.open(thePhantomFileName);
154 std::vector<G4Material*> materials = thePhantomParam->
GetMaterials();
155 fout << materials.size() <<
G4endl;
156 for(
unsigned int ii = 0; ii < materials.size(); ii++ ) {
157 fout << ii <<
" " << materials[ii]->GetName() <<
G4endl;
165 fVoxelIsInside =
new G4bool[nx*ny*nz];
171 fout << nx <<
" " << ny <<
" " << nz <<
G4endl;
172 fout << -voxelHalfWidthX*nx+thePhantomTransform.NetTranslation().x() <<
" "
173 << voxelHalfWidthX*nx+thePhantomTransform.NetTranslation().x() <<
G4endl;
174 fout << -voxelHalfWidthY*ny+thePhantomTransform.NetTranslation().y() <<
" "
175 << voxelHalfWidthY*ny+thePhantomTransform.NetTranslation().y() <<
G4endl;
176 fout << -voxelHalfWidthZ*nz+thePhantomTransform.NetTranslation().z() <<
" "
177 << voxelHalfWidthZ*nz+thePhantomTransform.NetTranslation().z() <<
G4endl;
179 for(
G4int iz = 0; iz < nz; iz++ ){
180 for(
G4int iy = 0; iy < ny; iy++) {
182 G4bool bPrevVoxelInside =
true;
183 G4bool b1VoxelFoundInside =
false;
184 G4int firstVoxel = -1;
185 G4int lastVoxel = -1;
186 for(
G4int ix = 0; ix < nx; ix++ ){
188 (-ny+iy*2+1)*voxelHalfWidthY, (-nz+iz*2+1)*voxelHalfWidthZ);
190 G4bool bVoxelIsInside =
true;
191 for(
G4int ivx = -1; ivx <= 1; ivx+=2 ) {
192 for(
G4int ivy = -1; ivy <= 1; ivy+=2 ){
193 for(
G4int ivz = -1; ivz <= 1; ivz+=2 ) {
195 + ivx*voxelHalfWidthX*axisX +
196 ivy*voxelHalfWidthY*axisY + ivz*voxelHalfWidthZ*axisZ;
198 bVoxelIsInside =
false;
203 if( !bVoxelIsInside )
break;
205 if( !bVoxelIsInside )
break;
208 G4int copyNo = ix + nx*iy + nxy*iz;
209 if( bVoxelIsInside ) {
210 if( !bPrevVoxelInside ) {
214 "Volume cannot intersect phantom in discontiguous voxels, "
215 "please use other voxel");
217 if( !b1VoxelFoundInside ) {
219 b1VoxelFoundInside =
true;
222 fVoxelIsInside[copyNo] =
true;
224 fVoxelIsInside[copyNo] =
false;
228 fout << firstVoxel <<
" " << lastVoxel <<
G4endl;
233 for(
G4int iz = 0; iz < nz; iz++ ){
234 for(
G4int iy = 0; iy < ny; iy++) {
236 for(
G4int ix = 0; ix < nx; ix++ ){
237 size_t copyNo = ix + ny*iy + nxy*iz;
239 if( fVoxelIsInside[copyNo] ) {
244 if(b1xFound ) fout <<
G4endl;
249 for(
G4int iz = 0; iz < nz; iz++ ){
250 for(
G4int iy = 0; iy < ny; iy++) {
252 for(
G4int ix = 0; ix < nx; ix++ ){
253 size_t copyNo = ix + ny*iy + nxy*iz;
254 if( fVoxelIsInside[copyNo] ) {
259 if(b1xFound ) fout <<
G4endl;
G4ThreeVector GetFrameTranslation() const
CLHEP::Hep3Vector G4ThreeVector
HepRotation & rotateX(double delta)
CLHEP::HepRotation G4RotationMatrix
G4double GetDensity() const
static G4String ConvertToString(G4bool boolVal)
HepRotation & rotateY(double delta)
size_t GetMaterialIndex(size_t nx, size_t ny, size_t nz) const
size_t GetNoVoxelZ() const
virtual EInside Inside(const G4ThreeVector &p) const =0
std::vector< G4Material * > GetMaterials() const
static G4double ConvertToDouble(const char *st)
const G4String & GetCommandPath() const
G4double GetVoxelHalfY() const
static constexpr double cm3
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4Material * GetMaterial(size_t nx, size_t ny, size_t nz) const
const G4RotationMatrix * GetFrameRotation() const
const G4String & GetCommandName() const
size_t GetNoVoxelY() const
G4double GetVoxelHalfX() const
G4double GetVoxelHalfZ() const
size_t GetNoVoxelX() const
static const G4double pos