110 G4int G4GMocrenFileSceneHandler::kSceneIdCount = 0;
123 kMessenger(messenger),
125 kbSetModalityVoxelSize(false),
126 kbModelingTrajectory(false),
128 kFlagInModeling(false),
129 kFlagSaving_g4_gdd(false),
130 kFlagParameterization(0),
131 kFlagProcessedInteractiveScorer(false) {
134 if(std::getenv(
"G4GMocrenFile_DEST_DIR") == NULL) {
135 kGddDestDir[0] =
'\0';
141 const char * env = std::getenv(
"G4GMocrenFile_DEST_DIR");
142 std::strncpy(kGddDestDir, env, std::strlen(env));
149 if ( std::getenv(
"G4GMocrenFile_MAX_FILE_NUM" ) != NULL ) {
150 char * pcFileNum = getenv(
"G4GMocrenFile_MAX_FILE_NUM");
152 std::strncpy(c10FileNum, pcFileNum, 10);
153 kMaxFileNum = std::atoi(c10FileNum);
158 if( kMaxFileNum < 1 ) { kMaxFileNum = 1 ; }
160 InitializeParameters();
176 if(kgMocrenIO != NULL)
delete kgMocrenIO;
181 void G4GMocrenFileSceneHandler::InitializeParameters() {
183 kbSetModalityVoxelSize =
false;
185 for(
G4int i = 0; i < 3; i++) {
186 kModalitySize[i] = 0;
187 kNestedVolumeDimension[i] = 0;
188 kNestedVolumeDirAxis[i] = -1;
199 const G4int MAX_FILE_INDEX = kMaxFileNum - 1 ;
202 std::strncpy(kGddFileName, kGddDestDir, std::strlen(kGddDestDir));
208 static G4int currentNumber = 0;
209 for(
G4int i = currentNumber ; i < kMaxFileNum ; i++) {
212 if( i == MAX_FILE_INDEX )
215 G4cout <<
"===========================================" <<
G4endl;
216 G4cout <<
"WARNING MESSAGE from GMocrenFile driver: " <<
G4endl;
217 G4cout <<
" This file name is the final one in the " <<
G4endl;
218 G4cout <<
" automatic updation of the output file name." <<
G4endl;
219 G4cout <<
" You may overwrite existing files, i.e. " <<
G4endl;
221 G4cout <<
"===========================================" <<
G4endl;
226 if( i >= 0 && i <= 9 ) {
227 std::sprintf( kGddFileName,
"%s%s%s%d.gdd" , kGddDestDir,
GDD_FILE_HEADER,
"0", i );
229 std::sprintf( kGddFileName,
"%s%s%d.gdd" , kGddDestDir,
GDD_FILE_HEADER, i );
233 std::ifstream
fin(kGddFileName);
235 G4cout <<
"FILEOPEN: " << i <<
" : " << kGddFileName << fin.fail()
249 G4cout <<
"======================================================================" <<
G4endl;
251 G4cout <<
"Destination directory (current dir if NULL): " << kGddDestDir <<
G4endl;
252 G4cout <<
"Maximum number of files in the destination directory: " << kMaxFileNum <<
G4endl;
254 G4cout <<
" * The maximum number is customizable as: " <<
G4endl;
255 G4cout <<
" % setenv G4GMocrenFile_MAX_FILE_NUM number " <<
G4endl;
256 G4cout <<
" * The destination directory is customizable as:" <<
G4endl;
257 G4cout <<
" % setenv G4GMocrenFile_DEST_DIR dir_name/ " <<
G4endl;
258 G4cout <<
" ** Do not forget \"/\" at the end of the dir_name, e.g. \"./tmp/\"." <<
G4endl;
262 G4cout <<
"======================================================================" <<
G4endl;
276 G4cout <<
"***** (started) " ;
281 kFlagSaving_g4_gdd =
true;
289 std::vector<G4float> map;
291 for(
G4int i = minmax[0]; i <= minmax[1]; i++) {
327 std::vector<Detector>::iterator itr = kDetectors.begin();
328 for(; itr != kDetectors.end(); itr++) {
333 kNestedHitsList.clear();
334 kNestedVolumeNames.clear();
346 G4cout <<
"***** (started) (close "
347 << kGddFileName <<
")" <<
G4endl;
349 if(kGddDest) kGddDest.close();
350 kFlagSaving_g4_gdd =
false;
352 std::map<Index3D, G4float>::iterator itr = kNestedModality.begin();
353 G4int xmax=0, ymax=0, zmax=0;
354 for(; itr != kNestedModality.end(); itr++) {
355 if(itr->first.x > xmax) xmax = itr->first.x;
356 if(itr->first.y > ymax) ymax = itr->first.y;
357 if(itr->first.z > zmax) zmax = itr->first.z;
360 kModalitySize[0] = xmax+1;
361 kModalitySize[1] = ymax+1;
362 kModalitySize[2] = zmax+1;
364 if(
GFDEBUG)
G4cout <<
"gMocren-file driver : modality size : "
365 << kModalitySize[0] <<
" x "
366 << kModalitySize[1] <<
" x "
367 << kModalitySize[2] <<
G4endl;
369 G4int nxy = kModalitySize[0]*kModalitySize[1];
371 for(
G4int z = 0;
z < kModalitySize[2];
z++) {
372 short * modality =
new short[nxy];
373 for(
G4int y = 0;
y < kModalitySize[1];
y++) {
374 for(
G4int x = 0;
x < kModalitySize[0];
x++) {
378 G4int ixy =
x +
y*kModalitySize[0];
380 itr = kNestedModality.find(idx);
381 if(itr != kNestedModality.end()) {
385 modality[ixy] = -1024;
394 size_t nhits = kNestedHitsList.size();
397 std::map<Index3D, G4double>::iterator hitsItr;
398 std::map<G4String, std::map<Index3D, G4double> >::iterator hitsListItr = kNestedHitsList.begin();
400 for(
G4int n = 0; hitsListItr != kNestedHitsList.end(); hitsListItr++,
n++) {
407 for(
G4int z = 0 ;
z < kModalitySize[2];
z++) {
409 for(
G4int y = 0;
y < kModalitySize[1];
y++) {
410 for(
G4int x = 0;
x < kModalitySize[0];
x++) {
412 G4int ixy =
x +
y*kModalitySize[0];
414 hitsItr = hitsListItr->second.find(idx);
415 if(hitsItr != hitsListItr->second.end()) {
417 values[ixy] = hitsItr->second;
421 if(values[ixy] < minmax[0]) minmax[0] = values[ixy];
422 if(values[ixy] > minmax[1]) minmax[1] = values[ixy];
429 if(minmax[0] < 0) lower = minmax[0];
444 std::vector<G4float *> tracks;
445 unsigned char colors[3];
447 tracks.push_back(trk);
449 G4ThreeVector orig(0.,0.,0), xa(2000.,0.,0.), ya(0.,2000.,0.), za(0.,0.,2000.);
458 for(
G4int i = 0; i < 3; i++) trk[i] = orig[i];
459 for(
G4int i = 0; i < 3; i++) trk[i+3] = xa[i];
460 colors[0] = 255; colors[1] = 0; colors[2] = 0;
461 kgMocrenIO->
addTrack(tracks, colors);
463 for(
G4int i = 0; i < 3; i++) trk[i+3] = ya[i];
464 colors[0] = 0; colors[1] = 255; colors[2] = 0;
465 kgMocrenIO->
addTrack(tracks, colors);
467 for(
G4int i = 0; i < 3; i++) trk[i+3] = za[i];
468 colors[0] = 0; colors[1] = 0; colors[2] = 255;
469 kgMocrenIO->
addTrack(tracks, colors);
477 std::vector<G4float> transformObjects;
478 for(
G4int i = 0; i < 3; i++) {
480 transformObjects.push_back((kVolumeSize[i]/2. - kVoxelDimension[i]/2.));
505 G4cout <<
"***** G4GMocrenFileSceneHandler::GFBeginModeling (called & started)" <<
G4endl;
510 kFlagInModeling = true ;
519 std::vector<G4Scene::Model>::iterator itr = vmodel.begin();
520 for(; itr != vmodel.end(); itr++) {
521 G4cout <<
" IIIIII model name: " << itr->fpModel->GetGlobalTag() <<
G4endl;
538 static G4bool warned =
false;
542 (
"G4GMocrenFileSceneHandler::AddPrimitive (const G4Polyline&)",
544 "2D polylines not implemented. Ignored.");
552 static G4int numTrajectories = 0;
556 if(kbModelingTrajectory) {
561 (
"G4VSceneHandler::AddCompound(const G4Polyline&)",
571 std::vector<G4float *> trajectory;
572 if(polyline.size() < 2)
return;
573 G4Polyline::const_iterator preitr = polyline.begin();
574 G4Polyline::const_iterator postitr = preitr; postitr++;
575 for(; postitr != polyline.end(); preitr++, postitr++) {
579 G4ThreeVector postPts(postitr->x(), postitr->y(), postitr->z());
583 stepPts[0] = prePts.
x();
584 stepPts[1] = prePts.y();
585 stepPts[2] = prePts.z();
586 stepPts[3] = postPts.x();
587 stepPts[4] = postPts.y();
588 stepPts[5] = postPts.z();
589 trajectory.push_back(stepPts);
593 << stepPts[0] <<
", "
594 << stepPts[1] <<
", "
595 << stepPts[2] <<
") - ("
596 << stepPts[3] <<
", "
597 << stepPts[4] <<
", "
598 << stepPts[5] <<
")" <<
G4endl;
604 unsigned char trkcolor[3];
605 trkcolor[0] = (
unsigned char)(color.
GetRed()*255);
606 trkcolor[1] = (
unsigned char)(color.
GetGreen()*255);
607 trkcolor[2] = (
unsigned char)(color.
GetBlue()*255);
615 kgMocrenIO->
addTrack(trajectory, trkcolor);
627 static G4bool warned =
false;
631 (
"G4GMocrenFileSceneHandler::AddPrimitive (const G4Text&)",
633 "2D text not implemented. Ignored.");
658 static G4bool warned =
false;
662 (
"G4GMocrenFileSceneHandler::AddPrimitive (const G4Circle&)",
664 "2D circles not implemented. Ignored.");
687 static G4bool warned =
false;
691 (
"G4GMocrenFileSceneHandler::AddPrimitive (const G4Square&)",
693 "2D squares not implemented. Ignored.");
713 G4cout <<
"***** AddPrimitive( G4Polyhedron )" <<
G4endl;
719 static G4bool warned =
false;
723 (
"G4GMocrenFileSceneHandler::AddPrimitive (const G4Polyhedron&)",
725 "2D polyhedra not implemented. Ignored.");
735 G4bool notLastEdge =
true;
746 }
while (notLastEdge);
757 "ERROR G4GMocrenFileSceneHandler::AddPrimitive(G4Polyhedron)" <<
G4endl;
768 "\nG4Polyhedron facet with " << i <<
" edges" <<
G4endl;
787 G4cout <<
"***** GFEndModeling (started) " ;
788 G4cout <<
"(/EndModeling, /DrawAll, /CloseDevice)" <<
G4endl;
795 kFlagInModeling = false ;
834 G4cout <<
"G4GMocrenFileSceneHandler::AddSolid(const G4Box&) : "
838 if( !IsVisible() ) { return ; }
854 for(
G4int i = 0; i < 12; i++) {
857 G4cout <<
" (" << v1.
x() <<
", "
862 << v2.
z() <<
") [" << next <<
"]"
872 if(kFlagParameterization != 2) {
877 if(pScBox != NULL) bMesh =
true;
878 if(bMesh) kFlagParameterization = 2;
880 << volName <<
" - " << bMesh <<
G4endl;
885 if (!pv_model) { return ; }
888 if (!pPVModel) { return ; }
900 G4cout <<
" density : " << dens <<
" [g/cm3]" <<
G4endl;
919 G4cout <<
"kVolumeTrans3D: " << trans1 << G4endl << rot1 <<
G4endl;
921 kVolumeTrans3D = kVolumeTrans3D*trot;
930 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
933 G4int dirAxis[3] = {-1,-1,-1};
934 G4int nDaughters[3] = {0,0,0};
938 nDaughters[0] = nReplicas;
940 case kXAxis: dirAxis[0] = 0;
break;
941 case kYAxis: dirAxis[0] = 1;
break;
942 case kZAxis: dirAxis[0] = 2;
break;
944 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
947 kNestedVolumeNames.push_back(pv[0]->
GetName());
950 <<
" # : " << nDaughters[0] <<
G4endl;
954 if(pv[0]->GetLogicalVolume()->GetNoDaughters()) {
955 G4cout <<
"# of daughters : "
966 if(pv[0]->GetLogicalVolume()->GetNoDaughters() == 0) {
967 kFlagParameterization = 1;
972 if(kFlagParameterization == 0) {
977 nDaughters[1] = nReplicas;
979 case kXAxis: dirAxis[1] = 0;
break;
980 case kYAxis: dirAxis[1] = 1;
break;
981 case kZAxis: dirAxis[1] = 2;
break;
983 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
986 kNestedVolumeNames.push_back(pv[1]->
GetName());
989 <<
" # : " << nDaughters[1]<<
G4endl;
995 kNestedVolumeNames.push_back(pv[2]->
GetName());
998 <<
" # : " << nDaughters[2] <<
G4endl;
1000 if(nDaughters[2] > 1) {
1003 if(nestPara == NULL)
1004 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
1013 G4cout << trans0 <<
" - " << trans1 <<
" - " << diff <<
G4endl;
1015 if(diff.
x() != 0.) dirAxis[2] = 0;
1016 else if(diff.
y() != 0.) dirAxis[2] = 1;
1017 else if(diff.
z() != 0.) dirAxis[2] = 2;
1019 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
1020 "gMocren0009",
FatalException,
"Unexpected nested parameterisation");
1025 for(
G4int i = 0; i < 3; i++) {
1026 kNestedVolumeDimension[i] = nDaughters[i];
1028 kNestedVolumeDirAxis[i] = dirAxis[i];
1036 if(nestPara != NULL) {
1037 G4double prexyz[3] = {0.,0.,0.}, xyz[3] = {0.,0.,0.};
1038 for(
G4int n0 = 0; n0 < nDaughters[0]; n0++) {
1039 for(
G4int n1 = 0; n1 < nDaughters[1]; n1++) {
1040 for(
G4int n2 = 0; n2 < nDaughters[2]; n2++) {
1044 G4cout <<
" retrieve volume : copy # : " << n0
1045 <<
", " << n1 <<
", " << n2 <<
G4endl;
1051 G4cout <<
" density :" << dens <<
" [g/cm3]" <<
G4endl;
1058 if(n0 != 0 || n1 != 0 || n2 != 0) {
1059 for(
G4int i = 0; i < 3; i++) {
1060 if(xyz[i] != prexyz[i])
1061 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
1071 idx[dirAxis[0]] = n0;
1072 idx[dirAxis[1]] = n1;
1073 idx[dirAxis[2]] = n2;
1074 Index3D i3d(idx[0],idx[1],idx[2]);
1075 kNestedModality[i3d] = dens;
1077 G4cout <<
" index: " << idx[0] <<
", " << idx[1] <<
", " << idx[2]
1078 <<
" density: " << dens <<
G4endl;
1080 for(
G4int i = 0; i < 3; i++) prexyz[i] = xyz[i];
1089 if(!kbSetModalityVoxelSize) {
1091 static_cast<G4float>(2*xyz[1]),
1092 static_cast<G4float>(2*xyz[2])};
1094 kVoxelDimension.
set(spacing[0], spacing[1], spacing[2]);
1095 kbSetModalityVoxelSize =
true;
1101 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
1115 G4cout <<
" physical volume node id : "
1116 <<
"size: " << npvp <<
", PV name: ";
1117 for(
G4int i = 0; i < npvp; i++) {
1120 << pPVModel->
GetDrawnPVPath()[i].GetPhysicalVolume()->IsParameterised()
1122 << pPVModel->
GetDrawnPVPath()[i].GetPhysicalVolume()->IsReplicated();
1123 if(pPVModel->
GetDrawnPVPath()[i].GetPhysicalVolume()->GetParameterisation()) {
1125 << pPVModel->
GetDrawnPVPath()[i].GetPhysicalVolume()->GetParameterisation()->IsNested();
1128 << pPVModel->
GetDrawnPVPath()[i].GetPhysicalVolume()->GetCopyNo();
1137 G4Box * pbox =
dynamic_cast<G4Box *
>(pPVModel->
GetDrawnPVPath()[npvp-2].GetPhysicalVolume()->GetLogicalVolume()->GetSolid());
1142 G4cout <<
" mother size ["
1143 << pPVModel->
GetDrawnPVPath()[npvp-2].GetPhysicalVolume()->GetName()
1145 << pareDims[0] <<
" x "
1146 << pareDims[1] <<
" x "
1147 << pareDims[2] <<
" [mm3]"
1151 G4Box * boxP =
dynamic_cast<G4Box *
>(pPVModel->
GetDrawnPVPath()[npvp-1].GetPhysicalVolume()->GetLogicalVolume()->GetSolid());
1156 G4cout <<
" parameterised volume? ["
1157 << pPVModel->
GetDrawnPVPath()[npvp-1].GetPhysicalVolume()->GetName()
1159 << paraDims[0] <<
" x "
1160 << paraDims[1] <<
" x "
1161 << paraDims[2] <<
" [mm3] : "
1162 <<
G4int(pareDims[0]/paraDims[0]) <<
" x "
1163 <<
G4int(pareDims[1]/paraDims[1]) <<
" x "
1167 <<
" isn't a G4Box." <<
G4endl;
1173 }
else if(kFlagParameterization == 1) {
1178 if(phantomPara == NULL) {
1179 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
1185 kNestedVolumeDimension[0] = phantomPara->
GetNoVoxelX();
1186 kNestedVolumeDimension[1] = phantomPara->
GetNoVoxelY();
1187 kNestedVolumeDimension[2] = phantomPara->
GetNoVoxelZ();
1188 kNestedVolumeDirAxis[0] = 0;
1189 kNestedVolumeDirAxis[1] = 1;
1190 kNestedVolumeDirAxis[2] = 2;
1193 G4int nX = kNestedVolumeDimension[0];
1194 G4int nXY = kNestedVolumeDimension[0]*kNestedVolumeDimension[1];
1196 for(
G4int n0 = 0; n0 < kNestedVolumeDimension[0]; n0++) {
1197 for(
G4int n1 = 0; n1 < kNestedVolumeDimension[1]; n1++) {
1198 for(
G4int n2 = 0; n2 < kNestedVolumeDimension[2]; n2++) {
1200 G4int repNo = n0 + n1*nX + n2*nXY;
1206 idx[kNestedVolumeDirAxis[0]] = n0;
1207 idx[kNestedVolumeDirAxis[1]] = n1;
1208 idx[kNestedVolumeDirAxis[2]] = n2;
1209 Index3D i3d(idx[0],idx[1],idx[2]);
1210 kNestedModality[i3d] = dens;
1213 G4cout <<
" index: " << idx[0] <<
", " << idx[1] <<
", " << idx[2]
1214 <<
" density: " << dens <<
G4endl;
1225 if(!kbSetModalityVoxelSize) {
1230 kVoxelDimension.
set(spacing[0], spacing[1], spacing[2]);
1231 kbSetModalityVoxelSize =
true;
1239 if(!kFlagProcessedInteractiveScorer) {
1244 if(!pScrMan)
return;
1247 if(scoringBox == NULL)
return;
1253 kNestedVolumeDimension[0] = nVoxels[2];
1254 kNestedVolumeDimension[1] = nVoxels[1];
1255 kNestedVolumeDimension[2] = nVoxels[0];
1256 kNestedVolumeDirAxis[0] = 2;
1257 kNestedVolumeDirAxis[1] = 1;
1258 kNestedVolumeDirAxis[2] = 0;
1261 for(
G4int n0 = 0; n0 < kNestedVolumeDimension[0]; n0++) {
1262 for(
G4int n1 = 0; n1 < kNestedVolumeDimension[1]; n1++) {
1263 for(
G4int n2 = 0; n2 < kNestedVolumeDimension[2]; n2++) {
1268 idx[kNestedVolumeDirAxis[0]] = n0;
1269 idx[kNestedVolumeDirAxis[1]] = n1;
1270 idx[kNestedVolumeDirAxis[2]] = n2;
1271 Index3D i3d(idx[0],idx[1],idx[2]);
1272 kNestedModality[i3d] = dens;
1280 G4cout <<
"Interactive Scorer : size - "
1281 << boxSize.
x()/
cm <<
" x "
1282 << boxSize.
y()/
cm <<
" x "
1283 << boxSize.
z()/
cm <<
" [cm3]" <<
G4endl;
1284 G4cout <<
"Interactive Scorer : # voxels - "
1285 << nVoxels[0] <<
" x "
1286 << nVoxels[1] <<
" x "
1289 kVolumeSize.
set(boxSize.
x()*2,
1294 if(!kbSetModalityVoxelSize) {
1296 static_cast<G4float>(boxSize.
y()*2/nVoxels[1]),
1297 static_cast<G4float>(boxSize.
z()*2/nVoxels[2])};
1300 kVoxelDimension.
set(spacing[0], spacing[1], spacing[2]);
1301 kbSetModalityVoxelSize =
true;
1311 kVolumeTrans3D = kVolumeTrans3D*sbtranslate;
1319 kVolumeTrans3D = kVolumeTrans3D*sbrotate;
1331 kVolumeTrans3D = kVolumeTrans3D*trotY*trotZ;
1335 kFlagProcessedInteractiveScorer =
true;
1344 if(kFlagParameterization == 0) {
1346 if(volName == box.
GetName()) {
1350 std::vector<G4String>::iterator itr = kNestedVolumeNames.begin();
1351 for(; itr != kNestedVolumeNames.end(); itr++) {
1357 }
else if(kFlagParameterization == 1) {
1359 if(volName != box.
GetName()) {
1363 }
else if(kFlagParameterization == 2) {
1368 if(bAddDet) AddDetector(box);
1382 if( !IsVisible() ) { return ; }
1397 for(
G4int i = 0; i < nv; i++) {
1406 if (!pv_model) { return ; }
1409 if (!pPVModel) { return ; }
1425 if( !IsVisible() ) { return ; }
1444 if( !IsVisible() ) { return ; }
1462 if( !IsVisible() ) { return ; }
1468 AddDetector(sphere);
1480 if( !IsVisible() ) { return ; }
1498 if( !IsVisible() ) { return ; }
1517 if( !IsVisible() ) { return ; }
1533 if( !IsVisible() ) { return ; }
1553 kbModelingTrajectory =
true;
1558 G4cout <<
" ::AddCompound(const G4VTrajectory&) >>>>>>>>> " <<
G4endl;
1562 (
"G4VSceneHandler::AddCompound(const G4VTrajectory&)",
1576 for(
G4int i = 0; i < nPnt; i++) {
1584 kbModelingTrajectory =
false;
1606 std::vector<G4String> hitNames = kMessenger.
getHitNames();
1608 std::vector<G4String>::iterator itr = hitNames.begin();
1609 for(; itr != hitNames.end(); itr++)
1610 G4cout <<
" hit name : " << *itr << G4endl;
1614 if(!attval) {
G4cout <<
"0 empty " << (
unsigned long)attval << G4endl;}
1617 G4bool bid[3] = {
false,
false,
false};
1620 std::vector<G4AttValue>::iterator itr;
1622 for(itr = attval->begin(); itr != attval->end(); itr++) {
1623 std::string stmp = itr->GetValue();
1624 std::istringstream sval(stmp.c_str());
1626 if(itr->GetName() ==
G4String(
"XID")) {
1631 if(itr->GetName() ==
G4String(
"YID")) {
1636 if(itr->GetName() ==
G4String(
"ZID")) {
1645 if(bid[0] && bid[1] && bid[2]) {
1648 G4cout <<
" Hit : index(" <<
id.x <<
", " <<
id.y <<
", "
1649 <<
id.z <<
")" <<
G4endl;
1652 for(itr = attval->begin(); itr != attval->end(); itr++) {
1653 for(
G4int i = 0; i < nhitname; i++) {
1654 if(itr->GetName() == hitNames[i]) {
1656 std::string stmp = itr->GetValue();
1657 std::istringstream sval(stmp.c_str());
1660 sval >> value >> unit;
1662 std::map<G4String, std::map<Index3D, G4double> >::iterator kNestedHitsListItr;
1663 kNestedHitsListItr = kNestedHitsList.find(hitNames[i]);
1664 if(kNestedHitsListItr != kNestedHitsList.end()) {
1667 kNestedHitsListItr->second[id] =
value;
1669 std::map<Index3D, G4double>
hits;
1670 hits.insert(std::map<Index3D, G4double>::value_type(
id, value));
1671 kNestedHitsList[hitNames[i]] =
hits;
1676 G4cout <<
" : " << hitNames[i] <<
" -> " << value
1677 <<
" [" << unit <<
"]" <<
G4endl;
1682 G4Exception(
"G4GMocrenFileSceneHandler::AddCompound(const G4VHit &)",
1698 G4cout <<
" ::AddCompound(const std::map<G4int, G4double*> &) >>>>>>>>> " <<
G4endl;
1702 G4int nhitname = (
G4int)hitScorerNames.size();
1720 std::map<G4int, G4double*> * map = hits.
GetMap();
1721 std::map<G4int, G4double*>::const_iterator itr = map->begin();
1722 for(; itr != map->end(); itr++) {
1723 GetNestedVolumeIndex(itr->first, idx);
1724 Index3D id(idx[0], idx[1], idx[2]);
1726 std::map<G4String, std::map<Index3D, G4double> >::iterator nestedHitsListItr;
1727 nestedHitsListItr = kNestedHitsList.find(scorername);
1728 if(nestedHitsListItr != kNestedHitsList.end()) {
1729 nestedHitsListItr->second[id] = *itr->second;
1731 std::map<Index3D, G4double> hit;
1732 hit.insert(std::map<Index3D, G4double>::value_type(
id, *itr->second));
1733 kNestedHitsList[scorername] = hit;
1744 G4cout <<
" >>>>> " << meshname <<
" : " << scorername <<
G4endl;
1746 for(
G4int i = 0; i < nhitname; i++)
1747 if(scorername == hitScorerNames[i])
1748 G4cout <<
" !!!! Hit scorer !!!! " << scorername <<
G4endl;
1751 << kNestedVolumeDimension[0] <<
" x "
1752 << kNestedVolumeDimension[1] <<
" x "
1753 << kNestedVolumeDimension[2] <<
G4endl;
1756 std::map<G4int, G4double*> * map = hits.
GetMap();
1757 std::map<G4int, G4double*>::const_iterator itr = map->begin();
1758 for(; itr != map->end(); itr++) {
1759 GetNestedVolumeIndex(itr->first,
id);
1760 G4cout <<
"[" << itr->first <<
"] "
1761 <<
"("<<
id[0] <<
"," <<
id[1] <<
"," <<
id[2] <<
")"
1762 << *itr->second <<
", ";
1770 G4bool G4GMocrenFileSceneHandler::IsVisible()
1773 G4bool visibility = true ;
1801 void G4GMocrenFileSceneHandler::AddDetector(
const G4VSolid & solid) {
1806 detector.name = solid.
GetName();
1808 G4cout <<
"0 Detector name : " << detector.name <<
G4endl;
1811 if (!pv_model) { return ; }
1814 if (!pPVModel) { return ; }
1817 std::vector<G4float *> dedges;
1819 detector.polyhedron = poly;
1823 unsigned char uccolor[3] = {30, 30, 30};
1826 uccolor[0] = (
unsigned char)(color.
GetRed()*255);
1827 uccolor[1] = (
unsigned char)(color.
GetGreen()*255);
1828 uccolor[2] = (
unsigned char)(color.
GetBlue()*255);
1832 for(
G4int i = 0; i < 3; i++) detector.color[i] = uccolor[i];
1834 kDetectors.push_back(detector);
1837 G4cout <<
"0 color: (" << (
G4int)uccolor[0] <<
", "
1838 << (
G4int)uccolor[1] << ", " << (
G4int)uccolor[2] << ")"
1847 std::vector<Detector>::iterator itr = kDetectors.begin();
1849 for(; itr != kDetectors.end(); itr++) {
1857 std::vector<G4float *> dedges;
1869 if(!(poly->
GetNextEdge(v1, v2, next))) bnext =
false;
1871 edge[0] = v1.
x()/
mm;
1872 edge[1] = v1.
y()/
mm;
1873 edge[2] = v1.
z()/
mm;
1874 edge[3] = v2.
x()/
mm;
1875 edge[4] = v2.
y()/
mm;
1876 edge[5] = v2.
z()/
mm;
1877 dedges.push_back(edge);
1882 unsigned char uccolor[3] = {itr->color[0],
1886 kgMocrenIO->
addDetector(detname, dedges, uccolor);
1887 for(
G4int i = 0; i < nedges; i++) {
1888 delete [] dedges[i];
1893 G4cout <<
" color: (" << (
G4int)uccolor[0] <<
", "
1894 << (
G4int)uccolor[1] << ", " << (
G4int)uccolor[2] << ")"
1901 if(kNestedVolumeDimension[0] == 0 ||
1902 kNestedVolumeDimension[1] == 0 ||
1903 kNestedVolumeDimension[2] == 0) {
1904 for(
G4int i = 0; i < 3; i++) _idx3d[i] = 0;
1909 if(kFlagParameterization == 0) {
1911 G4int plane = kNestedVolumeDimension[2]*kNestedVolumeDimension[1];
1912 G4int line = kNestedVolumeDimension[2];
1924 _idx3d[kNestedVolumeDirAxis[0]] = _idx/plane;
1925 _idx3d[kNestedVolumeDirAxis[1]] = (_idx%plane)/line;
1926 _idx3d[kNestedVolumeDirAxis[2]] = (_idx%plane)%line;
1953 G4int plane = kNestedVolumeDimension[0]*kNestedVolumeDimension[1];
1954 G4int line = kNestedVolumeDimension[0];
1955 _idx3d[kNestedVolumeDirAxis[2]] = _idx/plane;
1956 _idx3d[kNestedVolumeDirAxis[1]] = (_idx%plane)/line;
1957 _idx3d[kNestedVolumeDirAxis[0]] = (_idx%plane)%line;
1965 G4GMocrenFileSceneHandler::Detector::Detector()
1967 color[0] = color[1] = color[2] = 255;
1969 G4GMocrenFileSceneHandler::Detector::~Detector() {
1970 if(!polyhedron)
delete polyhedron;
1974 if(!polyhedron)
delete polyhedron;
1975 color[0] = color[1] = color[2] = 255;
1980 G4GMocrenFileSceneHandler::Index3D::Index3D()
1981 :
x(0),
y(0),
z(0) {
1985 G4GMocrenFileSceneHandler::Index3D::Index3D(
const Index3D & _index3D)
1986 :
x(_index3D.
x),
y(_index3D.
y),
z(_index3D.
z) {
1996 G4GMocrenFileSceneHandler::Index3D::Index3D(
G4int _x,
G4int _y,
G4int _z)
1997 :
x(_x),
y(_y),
z(_z) {
2001 if(
z < static_cast<Index3D>(_right).
z) {
2003 }
else if(z == _right.z) {
2004 if(
y < static_cast<Index3D>(_right).
y)
return true;
2005 else if(y == _right.y)
2006 if(
x < static_cast<Index3D>(_right).
x)
return true;
2011 if(z == _right.z && y == _right.y &&
x == _right.x)
return true;
void set(double x, double y, double z)
virtual G4Material * ComputeMaterial(G4VPhysicalVolume *currentVol, const G4int repNo, const G4VTouchable *parentTouch=0)=0
void AddCompound(const G4VTrajectory &traj)
G4VModel * GetModel() const
void GetNumberOfSegments(G4int nSegment[3])
short convertDensityToHU(float &_dens)
G4double GetXHalfLength() const
virtual ~G4GMocrenFileSceneHandler()
G4RotationMatrix GetRotationMatrix() const
void setDoseDistUnit(std::string &_unit, int _num=0)
virtual void AddSolid(const G4Box &)
const std::vector< Model > & GetEndOfEventModelList() const
virtual G4bool IsNested() const
virtual void BeginModeling()
virtual void BeginPrimitives(const G4Transform3D &objectTransformation)
virtual G4bool IsReplicated() const =0
void addTrack(float *_tracks)
virtual void BeginPrimitives(const G4Transform3D &objectTransformation)
G4bool GetNextEdge(G4Point3D &p1, G4Point3D &p2, G4int &edgeFlag) const
const G4String & GetName() const
virtual G4VTrajectoryPoint * GetPoint(G4int i) const =0
void setDoseDistMinMax(short _minmax[2], int _num=0)
G4Material * GetCurrentMaterial() const
G4double GetDensity() const
virtual G4String getVolumeName()
G4VPhysicalVolume * GetDaughter(const G4int i) const
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
void setModalityImageSize(int _size[3])
const G4String & GetName() const
G4Transform3D fObjectTransformation
void AddSolid(const G4Box &box)
const char DEFAULT_GDD_FILE_NAME[]
const G4VisAttributes * GetApplicableVisAttributes(const G4VisAttributes *) const
const G4VisAttributes * GetVisAttributes() const
void ClearTransientStore()
virtual G4GeometryType GetEntityType() const =0
const std::vector< G4PhysicalVolumeNodeID > & GetDrawnPVPath() const
HepPolyhedron & Transform(const G4Transform3D &t)
G4ThreeVector GetSize() const
virtual G4Material * ComputeMaterial(const G4int repNo, G4VPhysicalVolume *currentVol, const G4VTouchable *parentTouch=0)
G4int GetCurrentDepth() const
G4double GetZHalfLength() const
G4Polyhedron * CreatePolyhedron() const
size_t GetNoVoxelZ() const
HepRotation inverse() const
void translateDetector(std::vector< float > &_translate)
virtual void DrawTrajectory() const
void setDoseDist(double *_image, int _num=0)
virtual G4bool getDrawVolumeGrid()
virtual int GetPointEntries() const =0
bool storeData(char *_filename)
G4GLOB_DLL std::ostream G4cout
virtual std::vector< G4String > getHitNames()
virtual G4String GetParticleName() const =0
const G4String & GetName() const
G4Polyhedron * CreatePolyhedron() const
void BeginSavingGdd(void)
G4double GetGreen() const
G4double GetDensity(G4int &_ct) const
G4ThreeVector GetTranslation() const
virtual G4VPVParameterisation * GetParameterisation() const =0
const char GDD_FILE_HEADER[]
virtual void ComputeTransformation(const G4int no, G4VPhysicalVolume *currentPV) const =0
const G4VisAttributes * GetVisAttributes() const
virtual void EndModeling()
virtual void EndPrimitives()
G4double GetYHalfLength() const
G4VScoringMesh * FindMesh(const G4String &)
void setModalityImageMinMax(short _minmax[2])
virtual G4Polyhedron * CreatePolyhedron() const
Hep3Vector & transform(const HepRotation &)
G4double GetVoxelHalfY() const
virtual G4double GetCharge() const =0
void setModalityImage(short *_image)
G4int GetNoDaughters() const
void setVoxelSpacing(float _spacing[3])
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4VPhysicalVolume * GetTopPhysicalVolume() const
virtual G4bool IsParameterised() const =0
G4int GetNoVertices() const
const G4int MAX_NUM_TRAJECTORIES
virtual std::vector< G4String > getHitScorerNames()
const int FR_MAX_FILE_NUM
const G4Color & GetColor() const
size_t GetNoVoxelY() const
virtual const G4ThreeVector GetPosition() const =0
const G4VisAttributes * fpVisAttribs
G4Scene * GetScene() const
virtual void AddCompound(const G4VTrajectory &)
G4LogicalVolume * GetLogicalVolume() const
const G4VTrajectory * GetCurrentTrajectory() const
G4double GetVoxelHalfX() const
system("rm -rf dna.root")
bool operator<(const CexmcAngularRange &left, const CexmcAngularRange &right)
virtual G4int GetCopyNo() const =0
virtual G4int GetTrackID() const =0
void translateTracks(std::vector< float > &_translateo)
virtual G4int GetMultiplicity() const
static Verbosity GetVerbosity()
G4bool GetNextVertexIndex(G4int &index, G4int &edgeFlag) const
void AddPrimitive(const G4Polyline &line)
virtual std::vector< G4AttValue > * CreateAttValues() const
std::map< G4int, T * > * GetMap() const
virtual void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const =0
const XML_Char int const XML_Char * value
G4double GetVoxelHalfZ() const
size_t GetNoVoxelX() const
static G4ScoringManager * GetScoringManager()
G4ThreeVector GetObjectTranslation() const
virtual G4ThreeVector GetInitialMomentum() const =0
void setDoseDistScale(double &_scale, int _num=0)
bool operator==(shared_ctrl_handle const &lhs, shared_ctrl_handle const &rhs)
void addDetector(std::string &_name, std::vector< float * > &_det, unsigned char _color[3])
virtual void EndPrimitives()
const G4bool GFDEBUG_DIGI
void setDoseDistSize(int _size[3], int _num=0)
G4LogicalVolume * GetCurrentLV() const
G4VPhysicalVolume * GetCurrentPV() const
G4int GetNoFacets() const
void setDoseDistName(std::string _name, int _num=0)
G4VSolid * GetSolid() const
G4Point3D GetVertex(G4int index) const
G4GMocrenFileSceneHandler(G4GMocrenFile &system, G4GMocrenMessenger &messenger, const G4String &name="")
void setModalityImageDensityMap(std::vector< float > &_map)