52 fPhantomMinusCorner(),
57 "and outputs the voxels that are totally inside the intersection as"
58 " a new phantom file. It must have the parameters: POS_X POS_Y POS_Z "
59 "ANG_X ANG_Y ANG_Z SOLID_TYPE SOLID_PARAM_1 (SOLID_PARAM_2 ...)");
65 " and outputs the voxels that are totally inside the intersection as "
66 " a new phantom file. It must have the parameters: POS_X POS_Y POS_Z "
67 "ANG_X ANG_Y ANG_Z SOLID_TYPE SOLID_PARAM_1 (SOLID_PARAM_2 ...)");
88 if( params.size() < 8 ) {
90 " There must be at least 8 parameter: SOLID_TYPE POS_X POS_Y POS_Z "
91 "ANG_X ANG_Y ANG_Z SOLID_PARAM_1 (SOLID_PARAM_2 ...)",
93 G4String(
"Number of parameters given = " +
106 std::vector<G4double> angles;
116 if( params.size() !=1 )
123 " needs 1 argument: VOLUME_NAME").c_str());
153 G4String thePhantomFileName =
"phantom.g4pdcm";
154 fout.open(thePhantomFileName);
157 for(
unsigned int ii = 0; ii < materials.size(); ++ii )
159 fout << ii <<
" " << materials[ii]->GetName() <<
G4endl;
173 fout << nx <<
" " << ny <<
" " << nz <<
G4endl;
174 fout << -voxelHalfWidthX*nx+thePhantomTransform.NetTranslation().x() <<
" "
175 << voxelHalfWidthX*nx+thePhantomTransform.NetTranslation().x() <<
G4endl;
176 fout << -voxelHalfWidthY*ny+thePhantomTransform.NetTranslation().y() <<
" "
177 << voxelHalfWidthY*ny+thePhantomTransform.NetTranslation().y() <<
G4endl;
178 fout << -voxelHalfWidthZ*nz+thePhantomTransform.NetTranslation().z() <<
" "
179 << voxelHalfWidthZ*nz+thePhantomTransform.NetTranslation().z() <<
G4endl;
181 for(
G4int iz = 0; iz < nz; ++iz ){
182 for(
G4int iy = 0; iy < ny; ++iy) {
184 G4bool bPrevVoxelInside =
true;
185 G4bool b1VoxelFoundInside =
false;
186 G4int firstVoxel = -1;
187 G4int lastVoxel = -1;
188 for(
G4int ix = 0; ix < nx; ++ix ){
190 (-ny+iy*2+1)*voxelHalfWidthY, (-nz+iz*2+1)*voxelHalfWidthZ);
192 G4bool bVoxelIsInside =
true;
193 for(
G4int ivx = -1; ivx <= 1; ivx+=2 ) {
194 for(
G4int ivy = -1; ivy <= 1; ivy+=2 ){
195 for(
G4int ivz = -1; ivz <= 1; ivz+=2 ) {
197 + ivx*voxelHalfWidthX*axisX +
198 ivy*voxelHalfWidthY*axisY + ivz*voxelHalfWidthZ*axisZ;
200 bVoxelIsInside =
false;
205 if( !bVoxelIsInside )
break;
207 if( !bVoxelIsInside )
break;
210 G4int copyNo = ix + nx*iy + nxy*iz;
211 if( bVoxelIsInside ) {
212 if( !bPrevVoxelInside ) {
216 "Volume cannot intersect phantom in discontiguous voxels, "
217 "please use other voxel");
219 if( !b1VoxelFoundInside ) {
221 b1VoxelFoundInside =
true;
230 fout << firstVoxel <<
" " << lastVoxel <<
G4endl;
235 for(
G4int iz = 0; iz < nz; ++iz ){
236 for(
G4int iy = 0; iy < ny; ++iy) {
238 for(
G4int ix = 0; ix < nx; ++ix ){
239 size_t copyNo = ix + ny*iy + nxy*iz;
250 for(
G4int iz = 0; iz < nz; ++iz ){
251 for(
G4int iy = 0; iy < ny; ++iy) {
253 for(
G4int ix = 0; ix < nx; ++ix ){
254 size_t copyNo = ix + ny*iy + nxy*iz;
269 for(
G4int ii = 0; ii < 6; ++ii ) params.erase( params.begin() );
271 params.insert( params.begin(),
":SOLID");
272 params.insert( params.begin(), params[1] );
293 for(
auto cite = pvs->cbegin(); cite != pvs->cend(); ++cite )
307 if( !paramreg && bMustExist )
308 G4Exception(
"DicomIntersectVolume::GetPhantomParam",
311 " No G4PhantomParameterisation found ");
321 std::vector<G4VPhysicalVolume*> vvolu;
322 std::string::size_type ial = name.rfind(
":");
325 if( ial != std::string::npos )
327 std::string::size_type ial2 = name.rfind(
":",ial-1);
328 if( ial2 != std::string::npos )
330 G4Exception(
"DicomIntersectVolume::GetPhysicalVolumes",
333 G4String(
"Name corresponds to a touchable " + name).c_str());
337 volname = name.substr( 0, ial );
348 for(
auto citepv = pvs->cbegin(); citepv != pvs->cend(); ++citepv )
350 if( volname == (*citepv)->GetName()
351 && ( (*citepv)->GetCopyNo() == volcopy || -1 == volcopy ) )
353 vvolu.push_back( *citepv );
358 if( vvolu.size() == 0 ) {
360 G4Exception(
" DicomIntersectVolume::GetPhysicalVolumes",
363 G4String(
"No physical volume found with name " + name).c_str());
365 G4cerr <<
"!!WARNING: DicomIntersectVolume::GetPhysicalVolumes: "<<
366 " no physical volume found with name " << name <<
G4endl;
370 if( nVols != -1 &&
G4int(vvolu.size()) != nVols ) {
371 G4Exception(
"DicomIntersectVolume::GetLogicalVolumes:",
372 "Wrong number of physical volumes found",
374 (
"Number of physical volumes " +
404 std::vector<G4LogicalVolume*> vvolu;
407 G4Exception(
"DicomIntersectVolume::GetLogicalVolumes",
410 G4String(
"Name corresponds to a touchable or physcal volume"
415 for(
auto citelv = lvs->cbegin(); citelv != lvs->cend(); ++citelv )
417 if( name == (*citelv)->GetName() ) {
418 vvolu.push_back( *citelv );
423 if( vvolu.size() == 0 ) {
425 G4Exception(
"DicomIntersectVolume::GetLogicalVolumes:",
"",
429 G4Exception(
"DicomIntersectVolume::GetLogicalVolumes:",
"",
430 JustWarning,(
"no logical volume found with name " + name).c_str());
434 if( nVols != -1 &&
G4int(vvolu.size()) != nVols ) {
435 G4Exception(
"DicomIntersectVolume::GetLogicalVolumes:",
436 "Wrong number of logical volumes found",
438 (
"Number of logical volumes " +
451 std::vector<G4String> wordlist;
456 const char* cstr = stemp.c_str();
460 G4bool lastIsBlank =
false;
461 G4bool lastIsQuote =
false;
462 for( ii = 0; ii < siz; ++ii )
464 if(cstr[ii] ==
'\"' ){
467 (
"There cannot be two quotes together " + stemp).c_str() );
469 if( nQuotes%2 == 1 ){
471 wordlist.push_back( stemp.substr(istart,ii-istart) );
481 }
else if(cstr[ii] ==
' ' ){
484 if( nQuotes%2 == 0 ){
485 if( !lastIsBlank && !lastIsQuote ) {
486 wordlist.push_back( stemp.substr(istart,ii-istart) );
498 wordlist.push_back( stemp.substr(istart,ii-istart+1) );
506 if( nQuotes%2 == 1 ) {
508 (
"unbalanced quotes in line " + stemp).c_str() );