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(getenv(
"G4GMocrenFile_DEST_DIR") == NULL) {
135 kGddDestDir[0] =
'\0';
140 const char * env = getenv(
"G4GMocrenFile_DEST_DIR");
141 std::strncpy(kGddDestDir, env, std::strlen(env));
147 if ( std::getenv(
"G4GMocrenFile_MAX_FILE_NUM" ) != NULL ) {
149 std::sscanf( getenv(
"G4GMocrenFile_MAX_FILE_NUM"),
"%d", &kMaxFileNum ) ;
154 if( kMaxFileNum < 1 ) { kMaxFileNum = 1 ; }
156 InitializeParameters();
175 void G4GMocrenFileSceneHandler::InitializeParameters() {
177 kbSetModalityVoxelSize =
false;
179 for(
G4int i = 0; i < 3; i++) {
180 kModalitySize[i] = 0;
181 kNestedVolumeDimension[i] = 0;
182 kNestedVolumeDirAxis[i] = -1;
193 const G4int MAX_FILE_INDEX = kMaxFileNum - 1 ;
196 std::strncpy(kGddFileName, kGddDestDir, std::strlen(kGddDestDir));
202 static G4int currentNumber = 0;
203 for(
G4int i = currentNumber ; i < kMaxFileNum ; i++) {
206 if( i == MAX_FILE_INDEX )
209 G4cout <<
"===========================================" <<
G4endl;
210 G4cout <<
"WARNING MESSAGE from GMocrenFile driver: " <<
G4endl;
211 G4cout <<
" This file name is the final one in the " <<
G4endl;
212 G4cout <<
" automatic updation of the output file name." <<
G4endl;
213 G4cout <<
" You may overwrite existing files, i.e. " <<
G4endl;
215 G4cout <<
"===========================================" <<
G4endl;
220 if( i >= 0 && i <= 9 ) {
221 std::sprintf( kGddFileName,
"%s%s%s%d.gdd" , kGddDestDir,
GDD_FILE_HEADER,
"0", i );
223 std::sprintf( kGddFileName,
"%s%s%d.gdd" , kGddDestDir,
GDD_FILE_HEADER, i );
227 std::ifstream
fin(kGddFileName);
229 G4cout <<
"FILEOPEN: " << i <<
" : " << kGddFileName << fin.fail() <<
G4endl;
242 G4cout <<
"======================================================================" <<
G4endl;
244 G4cout <<
"Destination directory (current dir if NULL): " << kGddDestDir <<
G4endl;
245 G4cout <<
"Maximum number of files in the destination directory: " << kMaxFileNum <<
G4endl;
247 G4cout <<
" * The maximum number is customizable as: " <<
G4endl;
248 G4cout <<
" % setenv G4GMocrenFile_MAX_FILE_NUM number " <<
G4endl;
249 G4cout <<
" * The destination directory is customizable as:" <<
G4endl;
250 G4cout <<
" % setenv G4GMocrenFile_DEST_DIR dir_name/ " <<
G4endl;
251 G4cout <<
" ** Do not forget \"/\" at the end of the dir_name, e.g. \"./tmp/\"." <<
G4endl;
255 G4cout <<
"======================================================================" <<
G4endl;
269 G4cout <<
"***** (started) " ;
274 kFlagSaving_g4_gdd =
true;
282 std::vector<G4float> map;
284 for(
G4int i = minmax[0]; i <= minmax[1]; i++) {
320 std::vector<Detector>::iterator itr = kDetectors.begin();
321 for(; itr != kDetectors.end(); itr++) {
326 kNestedHitsList.clear();
327 kNestedVolumeNames.clear();
339 G4cout <<
"***** (started) (close "
340 << kGddFileName <<
")" <<
G4endl;
342 if(kGddDest) kGddDest.close();
343 kFlagSaving_g4_gdd =
false;
345 std::map<Index3D, G4float>::iterator itr = kNestedModality.begin();
346 G4int xmax=0, ymax=0, zmax=0;
347 for(; itr != kNestedModality.end(); itr++) {
348 if(itr->first.x > xmax) xmax = itr->first.x;
349 if(itr->first.y > ymax) ymax = itr->first.y;
350 if(itr->first.z > zmax) zmax = itr->first.z;
353 kModalitySize[0] = xmax+1;
354 kModalitySize[1] = ymax+1;
355 kModalitySize[2] = zmax+1;
357 if(
GFDEBUG)
G4cout <<
"gMocren-file driver : modality size : "
358 << kModalitySize[0] <<
" x "
359 << kModalitySize[1] <<
" x "
360 << kModalitySize[2] <<
G4endl;
362 G4int nxy = kModalitySize[0]*kModalitySize[1];
364 for(
G4int z = 0;
z < kModalitySize[2];
z++) {
365 short * modality =
new short[nxy];
366 for(
G4int y = 0;
y < kModalitySize[1];
y++) {
367 for(
G4int x = 0;
x < kModalitySize[0];
x++) {
371 G4int ixy =
x +
y*kModalitySize[0];
373 itr = kNestedModality.find(idx);
374 if(itr != kNestedModality.end()) {
378 modality[ixy] = -1024;
387 size_t nhits = kNestedHitsList.size();
390 std::map<Index3D, G4double>::iterator hitsItr;
391 std::map<G4String, std::map<Index3D, G4double> >::iterator hitsListItr = kNestedHitsList.begin();
393 for(
G4int n = 0; hitsListItr != kNestedHitsList.end(); hitsListItr++,
n++) {
400 for(
G4int z = 0 ;
z < kModalitySize[2];
z++) {
402 for(
G4int y = 0;
y < kModalitySize[1];
y++) {
403 for(
G4int x = 0;
x < kModalitySize[0];
x++) {
405 G4int ixy =
x +
y*kModalitySize[0];
407 hitsItr = hitsListItr->second.find(idx);
408 if(hitsItr != hitsListItr->second.end()) {
410 values[ixy] = hitsItr->second;
414 if(values[ixy] < minmax[0]) minmax[0] = values[ixy];
415 if(values[ixy] > minmax[1]) minmax[1] = values[ixy];
422 if(minmax[0] < 0) lower = minmax[0];
437 std::vector<G4float *> tracks;
438 unsigned char colors[3];
440 tracks.push_back(trk);
442 G4ThreeVector orig(0.,0.,0), xa(2000.,0.,0.), ya(0.,2000.,0.), za(0.,0.,2000.);
451 for(
G4int i = 0; i < 3; i++) trk[i] = orig[i];
452 for(
G4int i = 0; i < 3; i++) trk[i+3] = xa[i];
453 colors[0] = 255; colors[1] = 0; colors[2] = 0;
454 kgMocrenIO->
addTrack(tracks, colors);
456 for(
G4int i = 0; i < 3; i++) trk[i+3] = ya[i];
457 colors[0] = 0; colors[1] = 255; colors[2] = 0;
458 kgMocrenIO->
addTrack(tracks, colors);
460 for(
G4int i = 0; i < 3; i++) trk[i+3] = za[i];
461 colors[0] = 0; colors[1] = 0; colors[2] = 255;
462 kgMocrenIO->
addTrack(tracks, colors);
470 std::vector<G4float> transformObjects;
471 for(
G4int i = 0; i < 3; i++) {
473 transformObjects.push_back((kVolumeSize[i]/2. - kVoxelDimension[i]/2.));
498 G4cout <<
"***** G4GMocrenFileSceneHandler::GFBeginModeling (called & started)" <<
G4endl;
503 kFlagInModeling = true ;
512 std::vector<G4Scene::Model>::iterator itr = vmodel.begin();
513 for(; itr != vmodel.end(); itr++) {
514 G4cout <<
" IIIIII model name: " << itr->fpModel->GetGlobalTag() <<
G4endl;
531 static G4bool warned =
false;
535 (
"G4GMocrenFileSceneHandler::AddPrimitive (const G4Polyline&)",
537 "2D polylines not implemented. Ignored.");
545 static G4int numTrajectories = 0;
549 if(kbModelingTrajectory) {
554 (
"G4VSceneHandler::AddCompound(const G4Polyline&)",
564 std::vector<G4float *> trajectory;
565 if(polyline.size() < 2)
return;
566 G4Polyline::const_iterator preitr = polyline.begin();
567 G4Polyline::const_iterator postitr = preitr; postitr++;
568 for(; postitr != polyline.end(); preitr++, postitr++) {
572 G4ThreeVector postPts(postitr->x(), postitr->y(), postitr->z());
576 stepPts[0] = prePts.
x();
577 stepPts[1] = prePts.y();
578 stepPts[2] = prePts.z();
579 stepPts[3] = postPts.x();
580 stepPts[4] = postPts.y();
581 stepPts[5] = postPts.z();
582 trajectory.push_back(stepPts);
586 << stepPts[0] <<
", "
587 << stepPts[1] <<
", "
588 << stepPts[2] <<
") - ("
589 << stepPts[3] <<
", "
590 << stepPts[4] <<
", "
591 << stepPts[5] <<
")" <<
G4endl;
597 unsigned char trkcolor[3];
598 trkcolor[0] = (
unsigned char)(color.
GetRed()*255);
599 trkcolor[1] = (
unsigned char)(color.
GetGreen()*255);
600 trkcolor[2] = (
unsigned char)(color.
GetBlue()*255);
608 kgMocrenIO->
addTrack(trajectory, trkcolor);
634 static G4bool warned =
false;
638 (
"G4GMocrenFileSceneHandler::AddPrimitive (const G4Text&)",
640 "2D text not implemented. Ignored.");
665 static G4bool warned =
false;
669 (
"G4GMocrenFileSceneHandler::AddPrimitive (const G4Circle&)",
671 "2D circles not implemented. Ignored.");
694 static G4bool warned =
false;
698 (
"G4GMocrenFileSceneHandler::AddPrimitive (const G4Square&)",
700 "2D squares not implemented. Ignored.");
720 G4cout <<
"***** AddPrimitive( G4Polyhedron )" <<
G4endl;
726 static G4bool warned =
false;
730 (
"G4GMocrenFileSceneHandler::AddPrimitive (const G4Polyhedron&)",
732 "2D polyhedra not implemented. Ignored.");
742 G4bool notLastEdge =
true;
753 }
while (notLastEdge);
764 "ERROR G4GMocrenFileSceneHandler::AddPrimitive(G4Polyhedron)" <<
G4endl;
775 "\nG4Polyhedron facet with " << i <<
" edges" <<
G4endl;
794 G4cout <<
"***** GFEndModeling (started) " ;
795 G4cout <<
"(/EndModeling, /DrawAll, /CloseDevice)" <<
G4endl;
802 kFlagInModeling = false ;
841 G4cout <<
"G4GMocrenFileSceneHandler::AddSolid(const G4Box&) : "
845 if( !IsVisible() ) { return ; }
861 for(
G4int i = 0; i < 12; i++) {
864 G4cout <<
" (" << v1.
x() <<
", "
869 << v2.
z() <<
") [" << next <<
"]"
879 if(kFlagParameterization != 2) {
884 if(pScBox != NULL) bMesh =
true;
885 if(bMesh) kFlagParameterization = 2;
887 << volName <<
" - " << bMesh <<
G4endl;
892 if (!pv_model) { return ; }
895 if (!pPVModel) { return ; }
907 G4cout <<
" density : " << dens <<
" [g/cm3]" <<
G4endl;
926 G4cout <<
"kVolumeTrans3D: " << trans1 << G4endl << rot1 <<
G4endl;
928 kVolumeTrans3D = kVolumeTrans3D*trot;
937 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
940 G4int dirAxis[3] = {-1,-1,-1};
941 G4int nDaughters[3] = {0,0,0};
945 nDaughters[0] = nReplicas;
947 case kXAxis: dirAxis[0] = 0;
break;
948 case kYAxis: dirAxis[0] = 1;
break;
949 case kZAxis: dirAxis[0] = 2;
break;
951 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
954 kNestedVolumeNames.push_back(pv[0]->
GetName());
957 <<
" # : " << nDaughters[0] <<
G4endl;
961 if(pv[0]->GetLogicalVolume()->GetNoDaughters()) {
962 G4cout <<
"# of daughters : "
973 if(pv[0]->GetLogicalVolume()->GetNoDaughters() == 0) {
974 kFlagParameterization = 1;
979 if(kFlagParameterization == 0) {
984 nDaughters[1] = nReplicas;
986 case kXAxis: dirAxis[1] = 0;
break;
987 case kYAxis: dirAxis[1] = 1;
break;
988 case kZAxis: dirAxis[1] = 2;
break;
990 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
993 kNestedVolumeNames.push_back(pv[1]->
GetName());
996 <<
" # : " << nDaughters[1]<<
G4endl;
1002 kNestedVolumeNames.push_back(pv[2]->
GetName());
1005 <<
" # : " << nDaughters[2] <<
G4endl;
1007 if(nDaughters[2] > 1) {
1010 if(nestPara == NULL)
1011 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
1020 G4cout << trans0 <<
" - " << trans1 <<
" - " << diff <<
G4endl;
1022 if(diff.
x() != 0.) dirAxis[2] = 0;
1023 else if(diff.
y() != 0.) dirAxis[2] = 1;
1024 else if(diff.
z() != 0.) dirAxis[2] = 2;
1026 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
1027 "gMocren0009",
FatalException,
"Unexpected nested parameterisation");
1032 for(
G4int i = 0; i < 3; i++) {
1033 kNestedVolumeDimension[i] = nDaughters[i];
1035 kNestedVolumeDirAxis[i] = dirAxis[i];
1043 if(nestPara != NULL) {
1044 G4double prexyz[3] = {0.,0.,0.}, xyz[3] = {0.,0.,0.};
1045 for(
G4int n0 = 0; n0 < nDaughters[0]; n0++) {
1046 for(
G4int n1 = 0; n1 < nDaughters[1]; n1++) {
1047 for(
G4int n2 = 0; n2 < nDaughters[2]; n2++) {
1051 G4cout <<
" retrieve volume : copy # : " << n0
1052 <<
", " << n1 <<
", " << n2 <<
G4endl;
1058 G4cout <<
" density :" << dens <<
" [g/cm3]" <<
G4endl;
1065 if(n0 != 0 || n1 != 0 || n2 != 0) {
1066 for(
G4int i = 0; i < 3; i++) {
1067 if(xyz[i] != prexyz[i])
1068 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
1078 idx[dirAxis[0]] = n0;
1079 idx[dirAxis[1]] = n1;
1080 idx[dirAxis[2]] = n2;
1081 Index3D i3d(idx[0],idx[1],idx[2]);
1082 kNestedModality[i3d] = dens;
1084 G4cout <<
" index: " << idx[0] <<
", " << idx[1] <<
", " << idx[2]
1085 <<
" density: " << dens <<
G4endl;
1087 for(
G4int i = 0; i < 3; i++) prexyz[i] = xyz[i];
1096 if(!kbSetModalityVoxelSize) {
1098 static_cast<G4float>(2*xyz[1]),
1099 static_cast<G4float>(2*xyz[2])};
1101 kVoxelDimension.
set(spacing[0], spacing[1], spacing[2]);
1102 kbSetModalityVoxelSize =
true;
1108 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
1122 G4cout <<
" physical volume node id : "
1123 <<
"size: " << npvp <<
", PV name: ";
1124 for(
G4int i = 0; i < npvp; i++) {
1127 << pPVModel->
GetDrawnPVPath()[i].GetPhysicalVolume()->IsParameterised()
1129 << pPVModel->
GetDrawnPVPath()[i].GetPhysicalVolume()->IsReplicated();
1130 if(pPVModel->
GetDrawnPVPath()[i].GetPhysicalVolume()->GetParameterisation()) {
1132 << pPVModel->
GetDrawnPVPath()[i].GetPhysicalVolume()->GetParameterisation()->IsNested();
1135 << pPVModel->
GetDrawnPVPath()[i].GetPhysicalVolume()->GetCopyNo();
1144 G4Box * pbox =
dynamic_cast<G4Box *
>(pPVModel->
GetDrawnPVPath()[npvp-2].GetPhysicalVolume()->GetLogicalVolume()->GetSolid());
1149 G4cout <<
" mother size ["
1150 << pPVModel->
GetDrawnPVPath()[npvp-2].GetPhysicalVolume()->GetName()
1152 << pareDims[0] <<
" x "
1153 << pareDims[1] <<
" x "
1154 << pareDims[2] <<
" [mm3]"
1158 G4Box * boxP =
dynamic_cast<G4Box *
>(pPVModel->
GetDrawnPVPath()[npvp-1].GetPhysicalVolume()->GetLogicalVolume()->GetSolid());
1163 G4cout <<
" parameterised volume? ["
1164 << pPVModel->
GetDrawnPVPath()[npvp-1].GetPhysicalVolume()->GetName()
1166 << paraDims[0] <<
" x "
1167 << paraDims[1] <<
" x "
1168 << paraDims[2] <<
" [mm3] : "
1169 <<
G4int(pareDims[0]/paraDims[0]) <<
" x "
1170 <<
G4int(pareDims[1]/paraDims[1]) <<
" x "
1174 <<
" isn't a G4Box." <<
G4endl;
1180 }
else if(kFlagParameterization == 1) {
1185 if(phantomPara == NULL) {
1186 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
1192 kNestedVolumeDimension[0] = phantomPara->
GetNoVoxelX();
1193 kNestedVolumeDimension[1] = phantomPara->
GetNoVoxelY();
1194 kNestedVolumeDimension[2] = phantomPara->
GetNoVoxelZ();
1195 kNestedVolumeDirAxis[0] = 0;
1196 kNestedVolumeDirAxis[1] = 1;
1197 kNestedVolumeDirAxis[2] = 2;
1200 G4int nX = kNestedVolumeDimension[0];
1201 G4int nXY = kNestedVolumeDimension[0]*kNestedVolumeDimension[1];
1203 for(
G4int n0 = 0; n0 < kNestedVolumeDimension[0]; n0++) {
1204 for(
G4int n1 = 0; n1 < kNestedVolumeDimension[1]; n1++) {
1205 for(
G4int n2 = 0; n2 < kNestedVolumeDimension[2]; n2++) {
1207 G4int repNo = n0 + n1*nX + n2*nXY;
1213 idx[kNestedVolumeDirAxis[0]] = n0;
1214 idx[kNestedVolumeDirAxis[1]] = n1;
1215 idx[kNestedVolumeDirAxis[2]] = n2;
1216 Index3D i3d(idx[0],idx[1],idx[2]);
1217 kNestedModality[i3d] = dens;
1220 G4cout <<
" index: " << idx[0] <<
", " << idx[1] <<
", " << idx[2]
1221 <<
" density: " << dens <<
G4endl;
1232 if(!kbSetModalityVoxelSize) {
1237 kVoxelDimension.
set(spacing[0], spacing[1], spacing[2]);
1238 kbSetModalityVoxelSize =
true;
1246 if(!kFLagProcessedInteractiveScorer) {
1251 if(!pScrMan)
return;
1254 if(scoringBox == NULL)
return;
1260 kNestedVolumeDimension[0] = nVoxels[2];
1261 kNestedVolumeDimension[1] = nVoxels[1];
1262 kNestedVolumeDimension[2] = nVoxels[0];
1263 kNestedVolumeDirAxis[0] = 2;
1264 kNestedVolumeDirAxis[1] = 1;
1265 kNestedVolumeDirAxis[2] = 0;
1268 for(
G4int n0 = 0; n0 < kNestedVolumeDimension[0]; n0++) {
1269 for(
G4int n1 = 0; n1 < kNestedVolumeDimension[1]; n1++) {
1270 for(
G4int n2 = 0; n2 < kNestedVolumeDimension[2]; n2++) {
1275 idx[kNestedVolumeDirAxis[0]] = n0;
1276 idx[kNestedVolumeDirAxis[1]] = n1;
1277 idx[kNestedVolumeDirAxis[2]] = n2;
1278 Index3D i3d(idx[0],idx[1],idx[2]);
1279 kNestedModality[i3d] = dens;
1287 G4cout <<
"Interactive Scorer : size - "
1288 << boxSize.
x()/
cm <<
" x "
1289 << boxSize.
y()/
cm <<
" x "
1290 << boxSize.
z()/
cm <<
" [cm3]" <<
G4endl;
1291 G4cout <<
"Interactive Scorer : # voxels - "
1292 << nVoxels[0] <<
" x "
1293 << nVoxels[1] <<
" x "
1296 kVolumeSize.
set(boxSize.
x()*2,
1301 if(!kbSetModalityVoxelSize) {
1303 static_cast<G4float>(boxSize.
y()*2/nVoxels[1]),
1304 static_cast<G4float>(boxSize.
z()*2/nVoxels[2])};
1307 kVoxelDimension.
set(spacing[0], spacing[1], spacing[2]);
1308 kbSetModalityVoxelSize =
true;
1318 kVolumeTrans3D = kVolumeTrans3D*sbtranslate;
1326 kVolumeTrans3D = kVolumeTrans3D*sbrotate;
1338 kVolumeTrans3D = kVolumeTrans3D*trotY*trotZ;
1342 kFLagProcessedInteractiveScorer =
true;
1351 if(kFlagParameterization == 0) {
1353 if(volName == box.
GetName()) {
1357 std::vector<G4String>::iterator itr = kNestedVolumeNames.begin();
1358 for(; itr != kNestedVolumeNames.end(); itr++) {
1364 }
else if(kFlagParameterization == 1) {
1366 if(volName != box.
GetName()) {
1370 }
else if(kFlagParameterization == 2) {
1375 if(bAddDet) AddDetector(box);
1389 if( !IsVisible() ) { return ; }
1404 for(
G4int i = 0; i < nv; i++) {
1413 if (!pv_model) { return ; }
1416 if (!pPVModel) { return ; }
1432 if( !IsVisible() ) { return ; }
1451 if( !IsVisible() ) { return ; }
1469 if( !IsVisible() ) { return ; }
1475 AddDetector(sphere);
1487 if( !IsVisible() ) { return ; }
1505 if( !IsVisible() ) { return ; }
1524 if( !IsVisible() ) { return ; }
1540 if( !IsVisible() ) { return ; }
1560 kbModelingTrajectory =
true;
1565 G4cout <<
" ::AddCompound(const G4VTrajectory&) >>>>>>>>> " <<
G4endl;
1569 (
"G4VSceneHandler::AddCompound(const G4VTrajectory&)",
1583 for(
G4int i = 0; i < nPnt; i++) {
1591 kbModelingTrajectory =
false;
1613 std::vector<G4String> hitNames = kMessenger.
getHitNames();
1615 std::vector<G4String>::iterator itr = hitNames.begin();
1616 for(; itr != hitNames.end(); itr++)
1617 G4cout <<
" hit name : " << *itr << G4endl;
1621 if(!attval) {
G4cout <<
"0 empty " << (
unsigned long)attval << G4endl;}
1624 G4bool bid[3] = {
false,
false,
false};
1627 std::vector<G4AttValue>::iterator itr;
1629 for(itr = attval->begin(); itr != attval->end(); itr++) {
1630 std::string stmp = itr->GetValue();
1631 std::istringstream sval(stmp.c_str());
1633 if(itr->GetName() ==
G4String(
"XID")) {
1638 if(itr->GetName() ==
G4String(
"YID")) {
1643 if(itr->GetName() ==
G4String(
"ZID")) {
1652 if(bid[0] && bid[1] && bid[2]) {
1655 G4cout <<
" Hit : index(" <<
id.x <<
", " <<
id.y <<
", "
1656 <<
id.z <<
")" <<
G4endl;
1659 for(itr = attval->begin(); itr != attval->end(); itr++) {
1660 for(
G4int i = 0; i < nhitname; i++) {
1661 if(itr->GetName() == hitNames[i]) {
1663 std::string stmp = itr->GetValue();
1664 std::istringstream sval(stmp.c_str());
1667 sval >> value >> unit;
1669 std::map<G4String, std::map<Index3D, G4double> >::iterator kNestedHitsListItr;
1670 kNestedHitsListItr = kNestedHitsList.find(hitNames[i]);
1671 if(kNestedHitsListItr != kNestedHitsList.end()) {
1674 kNestedHitsListItr->second[id] =
value;
1676 std::map<Index3D, G4double>
hits;
1677 hits.insert(std::map<Index3D, G4double>::value_type(
id, value));
1678 kNestedHitsList[hitNames[i]] =
hits;
1683 G4cout <<
" : " << hitNames[i] <<
" -> " << value
1684 <<
" [" << unit <<
"]" <<
G4endl;
1689 G4Exception(
"G4GMocrenFileSceneHandler::AddCompound(const G4VHit &)",
1705 G4cout <<
" ::AddCompound(const std::map<G4int, G4double*> &) >>>>>>>>> " <<
G4endl;
1709 G4int nhitname = (
G4int)hitScorerNames.size();
1727 std::map<G4int, G4double*> * map = hits.
GetMap();
1728 std::map<G4int, G4double*>::const_iterator itr = map->begin();
1729 for(; itr != map->end(); itr++) {
1730 GetNestedVolumeIndex(itr->first, idx);
1731 Index3D id(idx[0], idx[1], idx[2]);
1733 std::map<G4String, std::map<Index3D, G4double> >::iterator nestedHitsListItr;
1734 nestedHitsListItr = kNestedHitsList.find(scorername);
1735 if(nestedHitsListItr != kNestedHitsList.end()) {
1736 nestedHitsListItr->second[id] = *itr->second;
1738 std::map<Index3D, G4double> hit;
1739 hit.insert(std::map<Index3D, G4double>::value_type(
id, *itr->second));
1740 kNestedHitsList[scorername] = hit;
1751 G4cout <<
" >>>>> " << meshname <<
" : " << scorername <<
G4endl;
1753 for(
G4int i = 0; i < nhitname; i++)
1754 if(scorername == hitScorerNames[i])
1755 G4cout <<
" !!!! Hit scorer !!!! " << scorername <<
G4endl;
1758 << kNestedVolumeDimension[0] <<
" x "
1759 << kNestedVolumeDimension[1] <<
" x "
1760 << kNestedVolumeDimension[2] <<
G4endl;
1763 std::map<G4int, G4double*> * map = hits.
GetMap();
1764 std::map<G4int, G4double*>::const_iterator itr = map->begin();
1765 for(; itr != map->end(); itr++) {
1766 GetNestedVolumeIndex(itr->first,
id);
1767 G4cout <<
"[" << itr->first <<
"] "
1768 <<
"("<<
id[0] <<
"," <<
id[1] <<
"," <<
id[2] <<
")"
1769 << *itr->second <<
", ";
1777 G4bool G4GMocrenFileSceneHandler::IsVisible()
1780 G4bool visibility = true ;
1808 void G4GMocrenFileSceneHandler::AddDetector(
const G4VSolid & solid) {
1813 detector.name = solid.
GetName();
1815 G4cout <<
"0 Detector name : " << detector.name <<
G4endl;
1818 if (!pv_model) { return ; }
1821 if (!pPVModel) { return ; }
1824 std::vector<G4float *> dedges;
1826 detector.polyhedron = poly;
1830 unsigned char uccolor[3] = {30, 30, 30};
1833 uccolor[0] = (
unsigned char)(color.
GetRed()*255);
1834 uccolor[1] = (
unsigned char)(color.
GetGreen()*255);
1835 uccolor[2] = (
unsigned char)(color.
GetBlue()*255);
1839 for(
G4int i = 0; i < 3; i++) detector.color[i] = uccolor[i];
1841 kDetectors.push_back(detector);
1844 G4cout <<
"0 color: (" << (
G4int)uccolor[0] <<
", "
1845 << (
G4int)uccolor[1] << ", " << (
G4int)uccolor[2] << ")"
1854 std::vector<Detector>::iterator itr = kDetectors.begin();
1856 for(; itr != kDetectors.end(); itr++) {
1864 std::vector<G4float *> dedges;
1876 if(!(poly->
GetNextEdge(v1, v2, next))) bnext =
false;
1878 edge[0] = v1.
x()/
mm;
1879 edge[1] = v1.
y()/
mm;
1880 edge[2] = v1.
z()/
mm;
1881 edge[3] = v2.
x()/
mm;
1882 edge[4] = v2.
y()/
mm;
1883 edge[5] = v2.
z()/
mm;
1884 dedges.push_back(edge);
1889 unsigned char uccolor[3] = {itr->color[0],
1893 kgMocrenIO->
addDetector(detname, dedges, uccolor);
1894 for(
G4int i = 0; i < nedges; i++) {
1895 delete [] dedges[i];
1900 G4cout <<
" color: (" << (
G4int)uccolor[0] <<
", "
1901 << (
G4int)uccolor[1] << ", " << (
G4int)uccolor[2] << ")"
1908 if(kNestedVolumeDimension[0] == 0 ||
1909 kNestedVolumeDimension[1] == 0 ||
1910 kNestedVolumeDimension[2] == 0) {
1911 for(
G4int i = 0; i < 3; i++) _idx3d[i] = 0;
1916 if(kFlagParameterization == 0) {
1918 G4int plane = kNestedVolumeDimension[2]*kNestedVolumeDimension[1];
1919 G4int line = kNestedVolumeDimension[2];
1931 _idx3d[kNestedVolumeDirAxis[0]] = _idx/plane;
1932 _idx3d[kNestedVolumeDirAxis[1]] = (_idx%plane)/line;
1933 _idx3d[kNestedVolumeDirAxis[2]] = (_idx%plane)%line;
1960 G4int plane = kNestedVolumeDimension[0]*kNestedVolumeDimension[1];
1961 G4int line = kNestedVolumeDimension[0];
1962 _idx3d[kNestedVolumeDirAxis[2]] = _idx/plane;
1963 _idx3d[kNestedVolumeDirAxis[1]] = (_idx%plane)/line;
1964 _idx3d[kNestedVolumeDirAxis[0]] = (_idx%plane)%line;
1972 G4GMocrenFileSceneHandler::Detector::Detector()
1974 color[0] = color[1] = color[2] = 255;
1976 G4GMocrenFileSceneHandler::Detector::~Detector() {
1977 if(!polyhedron)
delete polyhedron;
1981 if(!polyhedron)
delete polyhedron;
1982 color[0] = color[1] = color[2] = 255;
1987 G4GMocrenFileSceneHandler::Index3D::Index3D()
1988 :
x(0),
y(0),
z(0) {
1992 G4GMocrenFileSceneHandler::Index3D::Index3D(
const Index3D & _index3D)
1993 :
x(_index3D.
x),
y(_index3D.
y),
z(_index3D.
z) {
2003 G4GMocrenFileSceneHandler::Index3D::Index3D(
G4int _x,
G4int _y,
G4int _z)
2004 :
x(_x),
y(_y),
z(_z) {
2008 if(
z < static_cast<Index3D>(_right).
z) {
2010 }
else if(z == _right.z) {
2011 if(
y < static_cast<Index3D>(_right).
y)
return true;
2012 else if(y == _right.y)
2013 if(
x < static_cast<Index3D>(_right).
x)
return true;
2018 if(z == _right.z && y == _right.y &&
x == _right.x)
return true;