#include <G4GMocrenFileSceneHandler.hh>
Inheritance diagram for G4GMocrenFileSceneHandler:
Public Member Functions | |
G4GMocrenFileSceneHandler (G4GMocrenFile &system, G4GMocrenMessenger &messenger, const G4String &name="") | |
virtual | ~G4GMocrenFileSceneHandler () |
void | AddPrimitive (const G4Polyline &line) |
void | AddPrimitive (const G4Polyhedron &p) |
void | AddPrimitive (const G4NURBS &nurb) |
void | AddPrimitive (const G4Text &) |
void | AddPrimitive (const G4Circle &) |
void | AddPrimitive (const G4Square &) |
void | AddPrimitive (const G4Polymarker &polymarker) |
void | AddPrimitive (const G4Scale &scale) |
virtual void | BeginModeling () |
virtual void | EndModeling () |
virtual void | BeginPrimitives (const G4Transform3D &objectTransformation) |
virtual void | EndPrimitives () |
void | AddSolid (const G4Box &box) |
void | AddSolid (const G4Cons &cons) |
void | AddSolid (const G4Tubs &tubs) |
void | AddSolid (const G4Trd &trd) |
void | AddSolid (const G4Trap &trap) |
void | AddSolid (const G4Sphere &sphere) |
void | AddSolid (const G4Para ¶) |
void | AddSolid (const G4Torus &torus) |
void | AddSolid (const G4Polycone &polycone) |
void | AddSolid (const G4Polyhedra &polyhedra) |
void | AddSolid (const G4VSolid &solid) |
void | AddCompound (const G4VTrajectory &traj) |
void | AddCompound (const G4VHit &hit) |
void | AddCompound (const G4VDigi &hit) |
void | AddCompound (const G4THitsMap< G4double > &hits) |
void | ClearTransientStore () |
void | GFBeginModeling () |
void | GFEndModeling () |
G4bool | GFIsInModeling () |
G4bool | IsSavingGdd (void) |
void | BeginSavingGdd (void) |
void | EndSavingGdd (void) |
void | SetGddFileName () |
G4GMocrenFile & | GetSystem () |
const char * | GetGddFileName () |
Friends | |
class | G4GMocrenFileViewer |
Data Structures | |
class | Detector |
class | Index3D |
Definition at line 54 of file G4GMocrenFileSceneHandler.hh.
G4GMocrenFileSceneHandler::G4GMocrenFileSceneHandler | ( | G4GMocrenFile & | system, | |
G4GMocrenMessenger & | messenger, | |||
const G4String & | name = "" | |||
) |
Definition at line 118 of file G4GMocrenFileSceneHandler.cc.
References DEFAULT_GDD_FILE_NAME, and FR_MAX_FILE_NUM.
00121 : G4VSceneHandler(system, kSceneIdCount++, name), 00122 kSystem(system), 00123 kMessenger(messenger), 00124 kgMocrenIO(new G4GMocrenIO()), 00125 kbSetModalityVoxelSize(false), 00126 kbModelingTrajectory(false), 00127 // kGddDest(0), 00128 kFlagInModeling(false), 00129 kFlagSaving_g4_gdd(false), 00130 kFlagParameterization(0), 00131 kFLagProcessedInteractiveScorer(false) { 00132 00133 // g4.gdd filename and its directory 00134 if(getenv("G4GMocrenFile_DEST_DIR") == NULL) { 00135 kGddDestDir[0] = '\0'; 00136 //std::strcpy(kGddDestDir , ""); // output dir 00137 //std::strcpy(kGddFileName, DEFAULT_GDD_FILE_NAME); // filename 00138 std::strncpy(kGddFileName, DEFAULT_GDD_FILE_NAME, std::strlen(DEFAULT_GDD_FILE_NAME)); // filename 00139 } else { 00140 const char * env = getenv("G4GMocrenFile_DEST_DIR"); 00141 std::strncpy(kGddDestDir, env, std::strlen(env)); // output dir 00142 std::strncpy(kGddFileName, DEFAULT_GDD_FILE_NAME, std::strlen(DEFAULT_GDD_FILE_NAME)); // filename 00143 } 00144 00145 // maximum number of g4.gdd files in the dest directory 00146 kMaxFileNum = FR_MAX_FILE_NUM ; // initialization 00147 if ( std::getenv( "G4GMocrenFile_MAX_FILE_NUM" ) != NULL ) { 00148 00149 std::sscanf( getenv("G4GMocrenFile_MAX_FILE_NUM"), "%d", &kMaxFileNum ) ; 00150 00151 } else { 00152 kMaxFileNum = FR_MAX_FILE_NUM ; 00153 } 00154 if( kMaxFileNum < 1 ) { kMaxFileNum = 1 ; } 00155 00156 InitializeParameters(); 00157 00158 }
G4GMocrenFileSceneHandler::~G4GMocrenFileSceneHandler | ( | ) | [virtual] |
Definition at line 162 of file G4GMocrenFileSceneHandler.cc.
References G4VisManager::confirmations, G4cout, G4endl, G4VisManager::GetVerbosity(), GFDEBUG, and GFEndModeling().
00163 { 00164 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 00165 G4cout << "***** ~G4GMocrenFileSceneHandler" << G4endl; 00166 00167 if(kGddDest) { 00168 //----- End of modeling 00169 // close g4.gdd 00170 GFEndModeling(); 00171 } 00172 }
void G4GMocrenFileSceneHandler::AddCompound | ( | const G4THitsMap< G4double > & | hits | ) | [virtual] |
Reimplemented from G4VSceneHandler.
Definition at line 1703 of file G4GMocrenFileSceneHandler.cc.
References G4cout, G4GMocrenMessenger::getHitScorerNames(), G4THitsMap< T >::GetMap(), G4VSceneHandler::GetName(), and GFDEBUG_HIT.
01703 { 01704 if(GFDEBUG_HIT) 01705 G4cout << " ::AddCompound(const std::map<G4int, G4double*> &) >>>>>>>>> " << G4endl; 01706 01707 01708 std::vector<G4String> hitScorerNames = kMessenger.getHitScorerNames(); 01709 G4int nhitname = (G4int)hitScorerNames.size(); 01710 G4String scorername = static_cast<G4VHitsCollection>(hits).GetName(); 01711 01712 //-- --// 01713 /* 01714 std::vector<G4String> hitScorerNames = kMessenger.getHitScorerNames(); 01715 if(GFDEBUG_HIT) { 01716 std::vector<G4String>::iterator itr = hitScorerNames.begin(); 01717 for(; itr != hitScorerNames.end(); itr++) 01718 G4cout << " PS name : " << *itr << G4endl; 01719 } 01720 */ 01721 01722 { // Scope bracket to avoid compiler messages about shadowing (JA). 01723 //for(G4int i = 0; i < nhitname; i++) { // this selection trusts 01724 //if(scorername == hitScorerNames[i]) { // thea command /vis/scene/add/psHits hit_name. 01725 01726 G4int idx[3]; 01727 std::map<G4int, G4double*> * map = hits.GetMap(); 01728 std::map<G4int, G4double*>::const_iterator itr = map->begin(); 01729 for(; itr != map->end(); itr++) { 01730 GetNestedVolumeIndex(itr->first, idx); 01731 Index3D id(idx[0], idx[1], idx[2]); 01732 01733 std::map<G4String, std::map<Index3D, G4double> >::iterator nestedHitsListItr; 01734 nestedHitsListItr = kNestedHitsList.find(scorername); 01735 if(nestedHitsListItr != kNestedHitsList.end()) { 01736 nestedHitsListItr->second[id] = *itr->second; 01737 } else { 01738 std::map<Index3D, G4double> hit; 01739 hit.insert(std::map<Index3D, G4double>::value_type(id, *itr->second)); 01740 kNestedHitsList[scorername] = hit; 01741 } 01742 } 01743 01744 //break; 01745 //} 01746 //} 01747 } 01748 01749 if(GFDEBUG_HIT) { 01750 G4String meshname = static_cast<G4VHitsCollection>(hits).GetSDname(); 01751 G4cout << " >>>>> " << meshname << " : " << scorername << G4endl; 01752 01753 for(G4int i = 0; i < nhitname; i++) 01754 if(scorername == hitScorerNames[i]) 01755 G4cout << " !!!! Hit scorer !!!! " << scorername << G4endl; 01756 01757 G4cout << " dimension: " 01758 << kNestedVolumeDimension[0] << " x " 01759 << kNestedVolumeDimension[1] << " x " 01760 << kNestedVolumeDimension[2] << G4endl; 01761 01762 G4int id[3]; 01763 std::map<G4int, G4double*> * map = hits.GetMap(); 01764 std::map<G4int, G4double*>::const_iterator itr = map->begin(); 01765 for(; itr != map->end(); itr++) { 01766 GetNestedVolumeIndex(itr->first, id); 01767 G4cout << "[" << itr->first << "] " 01768 << "("<< id[0] << "," << id[1] << "," << id[2] << ")" 01769 << *itr->second << ", "; 01770 } 01771 G4cout << G4endl; 01772 } 01773 01774 }
void G4GMocrenFileSceneHandler::AddCompound | ( | const G4VDigi & | hit | ) | [virtual] |
Reimplemented from G4VSceneHandler.
Definition at line 1698 of file G4GMocrenFileSceneHandler.cc.
References G4VSceneHandler::AddCompound(), G4cout, and GFDEBUG_DIGI.
01698 { 01699 if(GFDEBUG_DIGI) G4cout << " ::AddCompound(const G4VDigi&) >>>>>>>>> " << G4endl; 01700 G4VSceneHandler::AddCompound(digi); 01701 }
void G4GMocrenFileSceneHandler::AddCompound | ( | const G4VHit & | hit | ) | [virtual] |
Reimplemented from G4VSceneHandler.
Definition at line 1598 of file G4GMocrenFileSceneHandler.cc.
References G4VSceneHandler::AddCompound(), G4VHit::CreateAttValues(), FatalException, G4cout, G4Exception(), G4GMocrenMessenger::getHitNames(), and GFDEBUG_HIT.
01598 { 01599 if(GFDEBUG_HIT) G4cout << " ::AddCompound(const G4VHit&) >>>>>>>>> " << G4endl; 01600 01601 G4VSceneHandler::AddCompound(hit); 01602 01603 /* 01604 const std::map<G4String, G4AttDef> * map = hit.GetAttDefs(); 01605 if(!map) return; 01606 std::map<G4String, G4AttDef>::const_iterator itr = map->begin(); 01607 for(; itr != map->end(); itr++) { 01608 G4cout << itr->first << " : " << itr->second.GetName() 01609 << " , " << itr->second.GetDesc() << G4endl; 01610 } 01611 */ 01612 01613 std::vector<G4String> hitNames = kMessenger.getHitNames(); 01614 if(GFDEBUG_HIT) { 01615 std::vector<G4String>::iterator itr = hitNames.begin(); 01616 for(; itr != hitNames.end(); itr++) 01617 G4cout << " hit name : " << *itr << G4endl; 01618 } 01619 01620 std::vector<G4AttValue> * attval = hit.CreateAttValues(); 01621 if(!attval) {G4cout << "0 empty " << (unsigned long)attval << G4endl;} 01622 else { 01623 01624 G4bool bid[3] = {false, false, false}; 01625 Index3D id; 01626 01627 std::vector<G4AttValue>::iterator itr; 01628 // First, get IDs 01629 for(itr = attval->begin(); itr != attval->end(); itr++) { 01630 std::string stmp = itr->GetValue(); 01631 std::istringstream sval(stmp.c_str()); 01632 01633 if(itr->GetName() == G4String("XID")) { 01634 sval >> id.x; 01635 bid[0] = true; 01636 continue; 01637 } 01638 if(itr->GetName() == G4String("YID")) { 01639 sval >> id.y; 01640 bid[1] = true; 01641 continue; 01642 } 01643 if(itr->GetName() == G4String("ZID")) { 01644 sval >> id.z; 01645 bid[2] = true; 01646 continue; 01647 } 01648 } 01649 01650 G4int nhitname = (G4int)hitNames.size(); 01651 01652 if(bid[0] && bid[1] && bid[2]) { 01653 01654 if(GFDEBUG_HIT) 01655 G4cout << " Hit : index(" << id.x << ", " << id.y << ", " 01656 << id.z << ")" << G4endl; 01657 01658 // Get attributes 01659 for(itr = attval->begin(); itr != attval->end(); itr++) { 01660 for(G4int i = 0; i < nhitname; i++) { 01661 if(itr->GetName() == hitNames[i]) { 01662 01663 std::string stmp = itr->GetValue(); 01664 std::istringstream sval(stmp.c_str()); 01665 G4double value; 01666 G4String unit; 01667 sval >> value >> unit; 01668 01669 std::map<G4String, std::map<Index3D, G4double> >::iterator kNestedHitsListItr; 01670 kNestedHitsListItr = kNestedHitsList.find(hitNames[i]); 01671 if(kNestedHitsListItr != kNestedHitsList.end()) { 01672 //fTempNestedHits = &kNestedHitsListItr->second; 01673 //(*fTempNestedHits)[id] = value; 01674 kNestedHitsListItr->second[id] = value; 01675 } else { 01676 std::map<Index3D, G4double> hits; 01677 hits.insert(std::map<Index3D, G4double>::value_type(id, value)); 01678 kNestedHitsList[hitNames[i]] = hits; 01679 } 01680 01681 01682 if(GFDEBUG_HIT) 01683 G4cout << " : " << hitNames[i] << " -> " << value 01684 << " [" << unit << "]" << G4endl; 01685 } 01686 } 01687 } 01688 } else { 01689 G4Exception("G4GMocrenFileSceneHandler::AddCompound(const G4VHit &)", 01690 "gMocren0014", FatalException, "Error"); 01691 } 01692 01693 delete attval; 01694 } 01695 01696 }
void G4GMocrenFileSceneHandler::AddCompound | ( | const G4VTrajectory & | traj | ) | [virtual] |
Reimplemented from G4VSceneHandler.
Definition at line 1558 of file G4GMocrenFileSceneHandler.cc.
References G4VSceneHandler::AddCompound(), G4VTrajectory::DrawTrajectory(), FatalException, G4VSceneHandler::fpModel, G4cout, G4Exception(), G4VTrajectory::GetCharge(), G4TrajectoriesModel::GetCurrentTrajectory(), G4TrajectoriesModel::GetDrawingMode(), G4VTrajectory::GetInitialMomentum(), G4VTrajectory::GetParticleName(), G4VTrajectory::GetPoint(), G4VTrajectory::GetPointEntries(), G4VTrajectoryPoint::GetPosition(), G4VTrajectory::GetTrackID(), and GFDEBUG_TRK.
01558 { 01559 01560 kbModelingTrajectory = true; 01561 01562 G4VSceneHandler::AddCompound(traj); 01563 01564 if(GFDEBUG_TRK) { 01565 G4cout << " ::AddCompound(const G4VTrajectory&) >>>>>>>>> " << G4endl; 01566 G4TrajectoriesModel * pTrModel = dynamic_cast<G4TrajectoriesModel*>(fpModel); 01567 if (!pTrModel) { 01568 G4Exception 01569 ("G4VSceneHandler::AddCompound(const G4VTrajectory&)", 01570 "gMocren0013", FatalException, "Not a G4TrajectoriesModel."); 01571 } else { 01572 traj.DrawTrajectory(pTrModel->GetDrawingMode()); 01573 01574 const G4VTrajectory * trj = pTrModel->GetCurrentTrajectory(); 01575 G4cout << "------ track" << G4endl; 01576 G4cout << " name: " << trj->GetParticleName() << G4endl; 01577 G4cout << " id: " << trj->GetTrackID() << G4endl; 01578 G4cout << " charge: " << trj->GetCharge() << G4endl; 01579 G4cout << " momentum: " << trj->GetInitialMomentum() << G4endl; 01580 01581 G4int nPnt = trj->GetPointEntries(); 01582 G4cout << " point: "; 01583 for(G4int i = 0; i < nPnt; i++) { 01584 G4cout << trj->GetPoint(i)->GetPosition() << ", "; 01585 } 01586 G4cout << G4endl; 01587 } 01588 G4cout << G4endl; 01589 } 01590 01591 kbModelingTrajectory = false; 01592 }
void G4GMocrenFileSceneHandler::AddPrimitive | ( | const G4Scale & | scale | ) | [inline, virtual] |
Reimplemented from G4VSceneHandler.
Definition at line 78 of file G4GMocrenFileSceneHandler.hh.
References G4VSceneHandler::AddPrimitive().
00079 { G4VSceneHandler::AddPrimitive (scale); }
void G4GMocrenFileSceneHandler::AddPrimitive | ( | const G4Polymarker & | polymarker | ) | [inline, virtual] |
Reimplemented from G4VSceneHandler.
Definition at line 76 of file G4GMocrenFileSceneHandler.hh.
References G4VSceneHandler::AddPrimitive().
00077 { G4VSceneHandler::AddPrimitive (polymarker); }
void G4GMocrenFileSceneHandler::AddPrimitive | ( | const G4Square & | ) | [virtual] |
Implements G4VSceneHandler.
Definition at line 688 of file G4GMocrenFileSceneHandler.cc.
References G4VisManager::confirmations, G4VSceneHandler::fProcessing2D, G4cout, G4endl, G4Exception(), G4VisManager::GetVerbosity(), GFBeginModeling(), GFDEBUG, and JustWarning.
00689 { 00690 // to avoid a warning in the compile process 00691 G4Square dummysquare = mark_square; 00692 00693 if (fProcessing2D) { 00694 static G4bool warned = false; 00695 if (!warned) { 00696 warned = true; 00697 G4Exception 00698 ("G4GMocrenFileSceneHandler::AddPrimitive (const G4Square&)", 00699 "gMocren1004", JustWarning, 00700 "2D squares not implemented. Ignored."); 00701 } 00702 return; 00703 } 00704 00705 //----- 00706 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 00707 G4cout << "***** AddPrimitive( G4Square )" << G4endl; 00708 00709 //----- Initialize if necessary 00710 GFBeginModeling(); 00711 00712 } // G4GMocrenFileSceneHandler::AddPrimitive ( mark_square )
void G4GMocrenFileSceneHandler::AddPrimitive | ( | const G4Circle & | ) | [virtual] |
Implements G4VSceneHandler.
Definition at line 659 of file G4GMocrenFileSceneHandler.cc.
References G4VisManager::confirmations, G4VSceneHandler::fProcessing2D, G4cout, G4endl, G4Exception(), G4VisManager::GetVerbosity(), GFBeginModeling(), GFDEBUG, and JustWarning.
00660 { 00661 // to avoid a warning in the compile process 00662 G4Circle dummycircle = mark_circle; 00663 00664 if (fProcessing2D) { 00665 static G4bool warned = false; 00666 if (!warned) { 00667 warned = true; 00668 G4Exception 00669 ("G4GMocrenFileSceneHandler::AddPrimitive (const G4Circle&)", 00670 "gMocren1003", JustWarning, 00671 "2D circles not implemented. Ignored."); 00672 } 00673 return; 00674 } 00675 00676 //----- 00677 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 00678 G4cout << "***** AddPrimitive( G4Circle )" << G4endl; 00679 00680 //----- Initialize IF NECESSARY 00681 GFBeginModeling(); 00682 00683 00684 } // G4GMocrenFileSceneHandler::AddPrimitive ( mark_circle )
void G4GMocrenFileSceneHandler::AddPrimitive | ( | const G4Text & | ) | [virtual] |
Implements G4VSceneHandler.
Definition at line 631 of file G4GMocrenFileSceneHandler.cc.
References G4VisManager::confirmations, G4VSceneHandler::fProcessing2D, G4cout, G4endl, G4Exception(), G4VisManager::GetVerbosity(), GFBeginModeling(), GFDEBUG, and JustWarning.
00632 { 00633 if (fProcessing2D) { 00634 static G4bool warned = false; 00635 if (!warned) { 00636 warned = true; 00637 G4Exception 00638 ("G4GMocrenFileSceneHandler::AddPrimitive (const G4Text&)", 00639 "gMocren1002", JustWarning, 00640 "2D text not implemented. Ignored."); 00641 } 00642 return; 00643 } 00644 00645 // to avoid a warning in the compile process 00646 G4Text dummytext = text; 00647 00648 //----- 00649 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 00650 G4cout << "***** AddPrimitive( G4Text )" << G4endl; 00651 00652 //----- Initialize IF NECESSARY 00653 GFBeginModeling(); 00654 00655 } // G4GMocrenFileSceneHandler::AddPrimitive ( text )
void G4GMocrenFileSceneHandler::AddPrimitive | ( | const G4NURBS & | nurb | ) | [virtual] |
Implements G4VSceneHandler.
Definition at line 617 of file G4GMocrenFileSceneHandler.cc.
References G4VisManager::confirmations, G4cout, G4endl, G4VisManager::GetVerbosity(), GFBeginModeling(), and GFDEBUG.
00618 { 00619 //----- 00620 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 00621 G4cout << "***** AddPrimitive( G4NURBS )" << G4endl; 00622 00623 //----- Initialize if necessary 00624 GFBeginModeling(); 00625 00626 }
void G4GMocrenFileSceneHandler::AddPrimitive | ( | const G4Polyhedron & | p | ) | [virtual] |
Implements G4VSceneHandler.
Definition at line 716 of file G4GMocrenFileSceneHandler.cc.
References G4VisManager::confirmations, G4VSceneHandler::fpModel, G4VSceneHandler::fProcessing2D, G4cout, G4endl, G4Exception(), G4PhysicalVolumeModel::GetCurrentLV(), G4PhysicalVolumeModel::GetCurrentPV(), G4VSolid::GetEntityType(), G4VSolid::GetName(), G4VPhysicalVolume::GetName(), G4LogicalVolume::GetSolid(), G4VisManager::GetVerbosity(), GFBeginModeling(), GFDEBUG, and JustWarning.
00717 { 00718 //----- 00719 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 00720 G4cout << "***** AddPrimitive( G4Polyhedron )" << G4endl; 00721 00722 00723 if (polyhedron.GetNoFacets() == 0) return; 00724 00725 if (fProcessing2D) { 00726 static G4bool warned = false; 00727 if (!warned) { 00728 warned = true; 00729 G4Exception 00730 ("G4GMocrenFileSceneHandler::AddPrimitive (const G4Polyhedron&)", 00731 "gMocren1005", JustWarning, 00732 "2D polyhedra not implemented. Ignored."); 00733 } 00734 return; 00735 } 00736 00737 //----- Initialize if necessary 00738 GFBeginModeling(); 00739 00740 //---------- (3) Facet block 00741 for (G4int f = polyhedron.GetNoFacets(); f; f--){ 00742 G4bool notLastEdge = true; 00743 G4int index = -1; // initialization 00744 G4int edgeFlag = 1; 00745 //G4int preedgeFlag = 1; 00746 //G4int work[4], i = 0; 00747 G4int i = 0; 00748 do { 00749 //preedgeFlag = edgeFlag; 00750 notLastEdge = polyhedron.GetNextVertexIndex(index, edgeFlag); 00751 //work[i++] = index; 00752 i++; 00753 }while (notLastEdge); 00754 switch (i){ 00755 case 3: 00756 //SendStrInt3(FR_FACET, work[0], work[1], work[2] ); 00757 break; 00758 case 4: 00759 //SendStrInt4(FR_FACET, work[0], work[1], work[2], work[3] ); 00760 break; 00761 default: 00762 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 00763 G4cout << 00764 "ERROR G4GMocrenFileSceneHandler::AddPrimitive(G4Polyhedron)" << G4endl; 00765 G4PhysicalVolumeModel* pPVModel = 00766 dynamic_cast<G4PhysicalVolumeModel*>(fpModel); 00767 if (pPVModel) 00768 if(G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 00769 G4cout << "Volume " << pPVModel->GetCurrentPV()->GetName() << 00770 ", Solid " << pPVModel->GetCurrentLV()->GetSolid()->GetName() << 00771 " (" << pPVModel->GetCurrentLV()->GetSolid()->GetEntityType(); 00772 00773 if(G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 00774 G4cout << 00775 "\nG4Polyhedron facet with " << i << " edges" << G4endl; 00776 } 00777 } 00778 00779 } // G4GMocrenFileSceneHandler::AddPrimitive (polyhedron)
void G4GMocrenFileSceneHandler::AddPrimitive | ( | const G4Polyline & | line | ) | [virtual] |
Implements G4VSceneHandler.
Definition at line 525 of file G4GMocrenFileSceneHandler.cc.
References G4GMocrenIO::addTrack(), G4VisManager::confirmations, FatalException, G4VSceneHandler::fpModel, G4VSceneHandler::fProcessing2D, G4cout, G4endl, G4Exception(), G4Colour::GetBlue(), G4VisAttributes::GetColor(), G4Colour::GetGreen(), G4Colour::GetRed(), G4VisManager::GetVerbosity(), G4Visible::GetVisAttributes(), GFBeginModeling(), GFDEBUG, GFDEBUG_TRK, JustWarning, and MAX_NUM_TRAJECTORIES.
00526 { 00527 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 00528 G4cout << "***** AddPrimitive" << G4endl; 00529 00530 if (fProcessing2D) { 00531 static G4bool warned = false; 00532 if (!warned) { 00533 warned = true; 00534 G4Exception 00535 ("G4GMocrenFileSceneHandler::AddPrimitive (const G4Polyline&)", 00536 "gMocren1001", JustWarning, 00537 "2D polylines not implemented. Ignored."); 00538 } 00539 return; 00540 } 00541 00542 //----- Initialize if necessary 00543 GFBeginModeling(); 00544 00545 static G4int numTrajectories = 0; 00546 if(numTrajectories >= MAX_NUM_TRAJECTORIES) return; 00547 00548 // draw trajectories 00549 if(kbModelingTrajectory) { 00550 00551 G4TrajectoriesModel * pTrModel = dynamic_cast<G4TrajectoriesModel*>(fpModel); 00552 if (!pTrModel) { 00553 G4Exception 00554 ("G4VSceneHandler::AddCompound(const G4Polyline&)", 00555 "gMocren0002", FatalException, "Not a G4TrajectoriesModel."); 00556 } 00557 00558 G4ThreeVector trans; 00559 G4RotationMatrix rot; 00560 trans = kVolumeTrans3D.getTranslation(); 00561 rot = kVolumeTrans3D.getRotation().inverse(); 00562 00563 if(GFDEBUG_TRK) G4cout << " trajectory points : " << G4endl; 00564 std::vector<G4float *> trajectory; 00565 if(polyline.size() < 2) return; 00566 G4Polyline::const_iterator preitr = polyline.begin(); 00567 G4Polyline::const_iterator postitr = preitr; postitr++; 00568 for(; postitr != polyline.end(); preitr++, postitr++) { 00569 G4ThreeVector prePts(preitr->x(), preitr->y(), preitr->z()); 00570 prePts -= trans; 00571 prePts.transform(rot); 00572 G4ThreeVector postPts(postitr->x(), postitr->y(), postitr->z()); 00573 postPts -= trans; 00574 postPts.transform(rot); 00575 G4float * stepPts = new G4float[6]; 00576 stepPts[0] = prePts.x(); 00577 stepPts[1] = prePts.y(); 00578 stepPts[2] = prePts.z(); 00579 stepPts[3] = postPts.x(); 00580 stepPts[4] = postPts.y(); 00581 stepPts[5] = postPts.z(); 00582 trajectory.push_back(stepPts); 00583 00584 if(GFDEBUG_TRK) { 00585 G4cout << " (" 00586 << stepPts[0] << ", " 00587 << stepPts[1] << ", " 00588 << stepPts[2] << ") - (" 00589 << stepPts[3] << ", " 00590 << stepPts[4] << ", " 00591 << stepPts[5] << ")" << G4endl; 00592 } 00593 } 00594 00595 const G4VisAttributes * att = polyline.GetVisAttributes(); 00596 G4Color color = att->GetColor(); 00597 unsigned char trkcolor[3]; 00598 trkcolor[0] = (unsigned char)(color.GetRed()*255); 00599 trkcolor[1] = (unsigned char)(color.GetGreen()*255); 00600 trkcolor[2] = (unsigned char)(color.GetBlue()*255); 00601 if(GFDEBUG_TRK) { 00602 G4cout << " color : [" 00603 << color.GetRed() << ", " 00604 << color.GetGreen() << ", " 00605 << color.GetBlue() << "]" << G4endl; 00606 } 00607 00608 kgMocrenIO->addTrack(trajectory, trkcolor); 00609 00610 numTrajectories++; 00611 } 00612 00613 } // G4GMocrenFileSceneHandler::AddPrimitive (polyline)
void G4GMocrenFileSceneHandler::AddSolid | ( | const G4VSolid & | solid | ) | [virtual] |
Reimplemented from G4VSceneHandler.
Definition at line 1537 of file G4GMocrenFileSceneHandler.cc.
References G4VSceneHandler::AddSolid(), and GFBeginModeling().
01538 { 01539 //----- skip drawing invisible primitive 01540 if( !IsVisible() ) { return ; } 01541 01542 //----- Initialize if necessary 01543 GFBeginModeling(); 01544 01545 // 01546 AddDetector(solid); 01547 01548 //----- Send a primitive 01549 G4VSceneHandler::AddSolid( solid ) ; 01550 01551 } //G4GMocrenFileSceneHandler::AddSolid ( const G4VSolid& )
void G4GMocrenFileSceneHandler::AddSolid | ( | const G4Polyhedra & | polyhedra | ) | [inline, virtual] |
Reimplemented from G4VSceneHandler.
Definition at line 98 of file G4GMocrenFileSceneHandler.hh.
References G4VSceneHandler::AddSolid().
00098 { 00099 G4VSceneHandler::AddSolid (polyhedra); 00100 }
void G4GMocrenFileSceneHandler::AddSolid | ( | const G4Polycone & | polycone | ) | [inline, virtual] |
Reimplemented from G4VSceneHandler.
Definition at line 95 of file G4GMocrenFileSceneHandler.hh.
References G4VSceneHandler::AddSolid().
00095 { 00096 G4VSceneHandler::AddSolid (polycone); 00097 }
void G4GMocrenFileSceneHandler::AddSolid | ( | const G4Torus & | torus | ) | [virtual] |
Reimplemented from G4VSceneHandler.
Definition at line 1518 of file G4GMocrenFileSceneHandler.cc.
References G4VisManager::confirmations, G4cout, G4VisManager::GetVerbosity(), GFBeginModeling(), and GFDEBUG.
01519 { 01520 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 01521 G4cout << "***** AddSolid ( torus )" << G4endl; 01522 01523 //----- skip drawing invisible primitive 01524 if( !IsVisible() ) { return ; } 01525 01526 //----- Initialize if necessary 01527 GFBeginModeling(); 01528 01529 // 01530 AddDetector(torus); 01531 01532 } // void G4GMocrenFileSceneHandler::AddSolid( const G4Torus& )
void G4GMocrenFileSceneHandler::AddSolid | ( | const G4Para & | para | ) | [virtual] |
Reimplemented from G4VSceneHandler.
Definition at line 1481 of file G4GMocrenFileSceneHandler.cc.
References G4VisManager::confirmations, G4cout, G4VisManager::GetVerbosity(), GFBeginModeling(), and GFDEBUG.
01482 { 01483 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 01484 G4cout << "***** AddSolid ( para )" << G4endl; 01485 01486 //----- skip drawing invisible primitive 01487 if( !IsVisible() ) { return ; } 01488 01489 //----- Initialize if necessary 01490 GFBeginModeling(); 01491 01492 // 01493 AddDetector(para); 01494 01495 } // G4GMocrenFileSceneHandler::AddSolid ( para )
void G4GMocrenFileSceneHandler::AddSolid | ( | const G4Sphere & | sphere | ) | [virtual] |
Reimplemented from G4VSceneHandler.
Definition at line 1463 of file G4GMocrenFileSceneHandler.cc.
References G4VisManager::confirmations, G4cout, G4VisManager::GetVerbosity(), GFBeginModeling(), and GFDEBUG.
01464 { 01465 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 01466 G4cout << "***** AddSolid ( sphere )" << G4endl; 01467 01468 //----- skip drawing invisible primitive 01469 if( !IsVisible() ) { return ; } 01470 01471 //----- Initialize if necessary 01472 GFBeginModeling(); 01473 01474 // 01475 AddDetector(sphere); 01476 01477 } // G4GMocrenFileSceneHandler::AddSolid ( sphere )
void G4GMocrenFileSceneHandler::AddSolid | ( | const G4Trap & | trap | ) | [virtual] |
Reimplemented from G4VSceneHandler.
Definition at line 1499 of file G4GMocrenFileSceneHandler.cc.
References G4VisManager::confirmations, G4cout, G4VisManager::GetVerbosity(), GFBeginModeling(), and GFDEBUG.
01500 { 01501 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 01502 G4cout << "***** AddSolid ( trap )" << G4endl; 01503 01504 //----- skip drawing invisible primitive 01505 if( !IsVisible() ) { return ; } 01506 01507 //----- Initialize if necessary 01508 GFBeginModeling(); 01509 01510 // 01511 AddDetector(trap); 01512 01513 } // G4GMocrenFileSceneHandler::AddSolid (const G4Trap& trap)
void G4GMocrenFileSceneHandler::AddSolid | ( | const G4Trd & | trd | ) | [virtual] |
Reimplemented from G4VSceneHandler.
Definition at line 1444 of file G4GMocrenFileSceneHandler.cc.
References G4VisManager::confirmations, G4cout, G4VisManager::GetVerbosity(), GFBeginModeling(), and GFDEBUG.
01445 { 01446 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 01447 G4cout << "***** AddSolid ( trd )" << G4endl; 01448 01449 01450 //----- skip drawing invisible primitive 01451 if( !IsVisible() ) { return ; } 01452 01453 //----- Initialize if necessary 01454 GFBeginModeling(); 01455 01456 // 01457 AddDetector(trd); 01458 01459 } // G4GMocrenFileSceneHandler::AddSolid ( trd )
void G4GMocrenFileSceneHandler::AddSolid | ( | const G4Tubs & | tubs | ) | [virtual] |
Reimplemented from G4VSceneHandler.
Definition at line 1383 of file G4GMocrenFileSceneHandler.cc.
References G4VisManager::confirmations, G4Tubs::CreatePolyhedron(), G4VSceneHandler::fpModel, G4cout, G4PhysicalVolumeModel::GetCurrentMaterial(), G4VSceneHandler::GetModel(), G4Material::GetName(), G4VSolid::GetName(), G4VisManager::GetVerbosity(), GFBeginModeling(), GFDEBUG, and GFDEBUG_DET.
01384 { 01385 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 01386 G4cout << "***** AddSolid ( tubes )" << G4endl; 01387 01388 //----- skip drawing invisible primitive 01389 if( !IsVisible() ) { return ; } 01390 01391 //----- Initialize if necessary 01392 GFBeginModeling(); 01393 01394 // 01395 AddDetector(tubes); 01396 01397 01398 // for a debug 01399 if(GFDEBUG_DET > 0) { 01400 G4cout << "-------" << G4endl; 01401 G4cout << " " << tubes.GetName() << G4endl; 01402 G4Polyhedron * poly = tubes.CreatePolyhedron(); 01403 G4int nv = poly->GetNoVertices(); 01404 for(G4int i = 0; i < nv; i++) { 01405 G4cout << " (" << poly->GetVertex(i).x() << ", " 01406 << poly->GetVertex(i).y() << ", " 01407 << poly->GetVertex(i).z() << ")" << G4endl; 01408 } 01409 delete poly; 01410 } 01411 01412 const G4VModel* pv_model = GetModel(); 01413 if (!pv_model) { return ; } 01414 G4PhysicalVolumeModel* pPVModel = 01415 dynamic_cast<G4PhysicalVolumeModel*>(fpModel); 01416 if (!pPVModel) { return ; } 01417 G4Material * mat = pPVModel->GetCurrentMaterial(); 01418 G4String name = mat->GetName(); 01419 01420 } // void G4GMocrenFileSceneHandler::AddSolid( const G4Tubs& )
void G4GMocrenFileSceneHandler::AddSolid | ( | const G4Cons & | cons | ) | [virtual] |
Reimplemented from G4VSceneHandler.
Definition at line 1426 of file G4GMocrenFileSceneHandler.cc.
References G4VisManager::confirmations, G4cout, G4VisManager::GetVerbosity(), GFBeginModeling(), and GFDEBUG.
01427 { 01428 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 01429 G4cout << "***** AddSolid ( cons )" << G4endl; 01430 01431 //----- skip drawing invisible primitive 01432 if( !IsVisible() ) { return ; } 01433 01434 //----- Initialize if necessary 01435 GFBeginModeling(); 01436 01437 // 01438 AddDetector(cons); 01439 01440 }// G4GMocrenFileSceneHandler::AddSolid( cons )
void G4GMocrenFileSceneHandler::AddSolid | ( | const G4Box & | box | ) | [virtual] |
Reimplemented from G4VSceneHandler.
Definition at line 835 of file G4GMocrenFileSceneHandler.cc.
References G4VNestedParameterisation::ComputeDimensions(), G4PhantomParameterisation::ComputeMaterial(), G4VNestedParameterisation::ComputeMaterial(), G4VNestedParameterisation::ComputeTransformation(), G4VisManager::confirmations, G4Box::CreatePolyhedron(), FatalException, G4ScoringManager::FindMesh(), G4VSceneHandler::fObjectTransformation, G4VSceneHandler::fpModel, G4cout, G4endl, G4Exception(), G4VPhysicalVolume::GetCopyNo(), G4PhysicalVolumeModel::GetCurrentDepth(), G4PhysicalVolumeModel::GetCurrentMaterial(), G4PhysicalVolumeModel::GetCurrentPV(), G4LogicalVolume::GetDaughter(), G4Material::GetDensity(), G4PhysicalVolumeModel::GetDrawnPVPath(), G4GMocrenMessenger::getDrawVolumeGrid(), G4VPhysicalVolume::GetLogicalVolume(), G4VSceneHandler::GetModel(), G4VPhysicalVolume::GetMultiplicity(), G4VSceneHandler::GetName(), G4VPhysicalVolume::GetName(), G4Material::GetName(), G4VSolid::GetName(), G4LogicalVolume::GetNoDaughters(), G4PhantomParameterisation::GetNoVoxelX(), G4PhantomParameterisation::GetNoVoxelY(), G4PhantomParameterisation::GetNoVoxelZ(), G4VScoringMesh::GetNumberOfSegments(), G4VPhysicalVolume::GetObjectTranslation(), G4VPhysicalVolume::GetParameterisation(), G4VPhysicalVolume::GetReplicationData(), G4VScoringMesh::GetRotationMatrix(), G4ScoringManager::GetScoringManager(), G4VScoringMesh::GetSize(), G4PhysicalVolumeModel::GetTopPhysicalVolume(), G4VScoringMesh::GetTranslation(), G4VisManager::GetVerbosity(), G4GMocrenMessenger::getVolumeName(), G4PhantomParameterisation::GetVoxelHalfX(), G4PhantomParameterisation::GetVoxelHalfY(), G4PhantomParameterisation::GetVoxelHalfZ(), G4Box::GetXHalfLength(), G4Box::GetYHalfLength(), G4Box::GetZHalfLength(), GFBeginModeling(), GFDEBUG, GFDEBUG_DET, G4VPhysicalVolume::IsParameterised(), G4VPhysicalVolume::IsReplicated(), kXAxis, kYAxis, kZAxis, G4INCL::Math::pi, and G4GMocrenIO::setVoxelSpacing().
00836 { 00837 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 00838 G4cout << "***** AddSolid ( box )" << G4endl; 00839 00840 if(GFDEBUG_DET > 0) 00841 G4cout << "G4GMocrenFileSceneHandler::AddSolid(const G4Box&) : " 00842 << box.GetName() << G4endl; 00843 00844 //----- skip drawing invisible primitive 00845 if( !IsVisible() ) { return ; } 00846 00847 //----- Initialize if necessary 00848 GFBeginModeling(); 00849 00850 00851 //-- 00852 if(GFDEBUG_DET > 1) { 00853 G4cout << "-------" << G4endl; 00854 G4cout << " " << box.GetName() << G4endl; 00855 G4Polyhedron * poly = box.CreatePolyhedron(); 00856 poly->Transform(fObjectTransformation); 00857 //G4int nv = poly->GetNoVertices(); 00858 G4Point3D v1, v2; 00859 G4int next; 00860 //while(1) { // next flag isn't functional. 00861 for(G4int i = 0; i < 12; i++) { // # of edges is 12. 00862 poly->GetNextEdge(v1, v2, next); 00863 if(next == 0) break; 00864 G4cout << " (" << v1.x() << ", " 00865 << v1.y() << ", " 00866 << v1.z() << ") - (" 00867 << v2.x() << ", " 00868 << v2.y() << ", " 00869 << v2.z() << ") [" << next << "]" 00870 << G4endl; 00871 } 00872 delete poly; 00873 } 00874 00875 00876 // the volume name set by /vis/gMocren/setVolumeName 00877 G4String volName = kMessenger.getVolumeName(); 00878 00879 if(kFlagParameterization != 2) { 00880 G4ScoringManager * pScrMan = G4ScoringManager::GetScoringManager(); 00881 if(pScrMan) { 00882 G4ScoringBox * pScBox = dynamic_cast<G4ScoringBox*>(pScrMan->FindMesh(volName)); 00883 G4bool bMesh = false; 00884 if(pScBox != NULL) bMesh = true; 00885 if(bMesh) kFlagParameterization = 2; 00886 if(GFDEBUG_DET > 0) G4cout << " G4ScoringManager::FindMesh() : " 00887 << volName << " - " << bMesh << G4endl; 00888 } 00889 } 00890 00891 const G4VModel* pv_model = GetModel(); 00892 if (!pv_model) { return ; } 00893 G4PhysicalVolumeModel* pPVModel = 00894 dynamic_cast<G4PhysicalVolumeModel*>(fpModel); 00895 if (!pPVModel) { return ; } 00896 00897 00898 //-- debug information 00899 if(GFDEBUG_DET > 0) { 00900 G4Material * mat = pPVModel->GetCurrentMaterial(); 00901 G4String name = mat->GetName(); 00902 G4double dens = mat->GetDensity()/(g/cm3); 00903 G4int copyNo = pPVModel->GetCurrentPV()->GetCopyNo(); 00904 G4int depth = pPVModel->GetCurrentDepth(); 00905 G4cout << " copy no.: " << copyNo << G4endl; 00906 G4cout << " depth : " << depth << G4endl; 00907 G4cout << " density : " << dens << " [g/cm3]" << G4endl; 00908 G4cout << " location: " << pPVModel->GetCurrentPV()->GetObjectTranslation() << G4endl; 00909 G4cout << " Multiplicity : " << pPVModel->GetCurrentPV()->GetMultiplicity() << G4endl; 00910 G4cout << " Is replicated? : " << pPVModel->GetCurrentPV()->IsReplicated() << G4endl; 00911 G4cout << " Is parameterised? : " << pPVModel->GetCurrentPV()->IsParameterised() << G4endl; 00912 G4cout << " top phys. vol. name : " << pPVModel->GetTopPhysicalVolume()->GetName() << G4endl; 00913 } 00914 00915 //-- check the parameterised volume 00916 if(box.GetName() == volName) { 00917 00918 kVolumeTrans3D = fObjectTransformation; 00919 // coordination system correction for gMocren 00920 G4ThreeVector raxis(1., 0., 0.), dummy(0.,0.,0.); 00921 G4RotationMatrix rot(raxis, pi*rad); 00922 G4Transform3D trot(rot, dummy); 00923 if(GFDEBUG_DET) { 00924 G4ThreeVector trans1 = kVolumeTrans3D.getTranslation(); 00925 G4RotationMatrix rot1 = kVolumeTrans3D.getRotation().inverse(); 00926 G4cout << "kVolumeTrans3D: " << trans1 << G4endl << rot1 << G4endl; 00927 } 00928 kVolumeTrans3D = kVolumeTrans3D*trot; 00929 if(GFDEBUG_DET) G4cout << " Parameterised volume : " << box.GetName() << G4endl; 00930 00931 00932 00933 // 00934 G4VPhysicalVolume * pv[3] = {0,0,0}; 00935 pv[0] = pPVModel->GetCurrentPV()->GetLogicalVolume()->GetDaughter(0); 00936 if(!pv[0]) { 00937 G4Exception("G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )", 00938 "gMocren0003", FatalException, "Unexpected volume."); 00939 } 00940 G4int dirAxis[3] = {-1,-1,-1}; 00941 G4int nDaughters[3] = {0,0,0}; 00942 00943 EAxis axis; G4int nReplicas; G4double width; G4double offset; G4bool consuming; 00944 pv[0]->GetReplicationData(axis, nReplicas, width, offset, consuming); 00945 nDaughters[0] = nReplicas; 00946 switch(axis) { 00947 case kXAxis: dirAxis[0] = 0; break; 00948 case kYAxis: dirAxis[0] = 1; break; 00949 case kZAxis: dirAxis[0] = 2; break; 00950 default: 00951 G4Exception("G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )", 00952 "gMocren0004", FatalException, "Error."); 00953 } 00954 kNestedVolumeNames.push_back(pv[0]->GetName()); 00955 if(GFDEBUG_DET) 00956 G4cout << " daughter name : " << pv[0]->GetName() 00957 << " # : " << nDaughters[0] << G4endl; 00958 00959 // 00960 if(GFDEBUG_DET) { 00961 if(pv[0]->GetLogicalVolume()->GetNoDaughters()) { 00962 G4cout << "# of daughters : " 00963 << pv[0]->GetLogicalVolume()->GetNoDaughters() << G4endl; 00964 } else { 00965 //G4Exception("G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )", 00966 // "gMocren0005", FatalException, "Error."); 00967 } 00968 } 00969 00970 // check whether nested or regular parameterization 00971 if(GFDEBUG_DET) G4cout << "# of daughters : " 00972 << pv[0]->GetLogicalVolume()->GetNoDaughters() << G4endl; 00973 if(pv[0]->GetLogicalVolume()->GetNoDaughters() == 0) { 00974 kFlagParameterization = 1; 00975 //G4Exception("G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )", 00976 // "gMocren0006", FatalException, "Error."); 00977 } 00978 00979 if(kFlagParameterization == 0) { 00980 00981 pv[1] = pv[0]->GetLogicalVolume()->GetDaughter(0); 00982 if(pv[1]) { 00983 pv[1]->GetReplicationData(axis, nReplicas, width, offset, consuming); 00984 nDaughters[1] = nReplicas; 00985 switch(axis) { 00986 case kXAxis: dirAxis[1] = 0; break; 00987 case kYAxis: dirAxis[1] = 1; break; 00988 case kZAxis: dirAxis[1] = 2; break; 00989 default: 00990 G4Exception("G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )", 00991 "gMocren0007", FatalException, "Error."); 00992 } 00993 kNestedVolumeNames.push_back(pv[1]->GetName()); 00994 if(GFDEBUG_DET) 00995 G4cout << " sub-daughter name : " << pv[1]->GetName() 00996 << " # : " << nDaughters[1]<< G4endl; 00997 00998 // 00999 pv[2] = pv[1]->GetLogicalVolume()->GetDaughter(0); 01000 if(pv[2]) { 01001 nDaughters[2] = pv[2]->GetMultiplicity(); 01002 kNestedVolumeNames.push_back(pv[2]->GetName()); 01003 if(GFDEBUG_DET) 01004 G4cout << " sub-sub-daughter name : " << pv[2]->GetName() 01005 << " # : " << nDaughters[2] << G4endl; 01006 01007 if(nDaughters[2] > 1) { 01008 G4VNestedParameterisation * nestPara 01009 = dynamic_cast<G4VNestedParameterisation*>(pv[2]->GetParameterisation()); 01010 if(nestPara == NULL) 01011 G4Exception("G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )", 01012 "gMocren0008", FatalException, "Non-nested parameterisation"); 01013 01014 nestPara->ComputeTransformation(0, pv[2]); 01015 G4ThreeVector trans0 = pv[2]->GetObjectTranslation(); 01016 nestPara->ComputeTransformation(1, pv[2]); 01017 G4ThreeVector trans1 = pv[2]->GetObjectTranslation(); 01018 G4ThreeVector diff(trans0 - trans1); 01019 if(GFDEBUG_DET) 01020 G4cout << trans0 << " - " << trans1 << " - " << diff << G4endl; 01021 01022 if(diff.x() != 0.) dirAxis[2] = 0; 01023 else if(diff.y() != 0.) dirAxis[2] = 1; 01024 else if(diff.z() != 0.) dirAxis[2] = 2; 01025 else 01026 G4Exception("G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )", 01027 "gMocren0009", FatalException, "Unexpected nested parameterisation"); 01028 } 01029 } 01030 } 01031 01032 for(G4int i = 0; i < 3; i++) { 01033 kNestedVolumeDimension[i] = nDaughters[i]; 01034 //kNestedVolumeDimension[i] = nDaughters[dirAxis[i]]; 01035 kNestedVolumeDirAxis[i] = dirAxis[i]; 01036 } 01037 //G4cout << "@@@@@@@@@ " 01038 // << dirAxis[0] << ", " << dirAxis[1] << ", " << dirAxis[2] << G4endl; 01039 01040 // get densities 01041 G4VNestedParameterisation * nestPara 01042 = dynamic_cast<G4VNestedParameterisation*>(pv[2]->GetParameterisation()); 01043 if(nestPara != NULL) { 01044 G4double prexyz[3] = {0.,0.,0.}, xyz[3] = {0.,0.,0.}; 01045 for(G4int n0 = 0; n0 < nDaughters[0]; n0++) { 01046 for(G4int n1 = 0; n1 < nDaughters[1]; n1++) { 01047 for(G4int n2 = 0; n2 < nDaughters[2]; n2++) { 01048 01049 G4GMocrenTouchable * touch = new G4GMocrenTouchable(n1, n0); 01050 if(GFDEBUG_DET) 01051 G4cout << " retrieve volume : copy # : " << n0 01052 << ", " << n1 << ", " << n2 << G4endl; 01053 G4Material * mat = nestPara->ComputeMaterial(pv[2], n2, touch); 01054 delete touch; 01055 G4double dens = mat->GetDensity()/(g/cm3); 01056 01057 if(GFDEBUG_DET) 01058 G4cout << " density :" << dens << " [g/cm3]" << G4endl; 01059 01060 G4Box tbox(box); 01061 nestPara->ComputeDimensions(tbox, n2, pv[2]); 01062 xyz[0] = tbox.GetXHalfLength()/mm; 01063 xyz[1] = tbox.GetYHalfLength()/mm; 01064 xyz[2] = tbox.GetZHalfLength()/mm; 01065 if(n0 != 0 || n1 != 0 || n2 != 0) { 01066 for(G4int i = 0; i < 3; i++) { 01067 if(xyz[i] != prexyz[i]) 01068 G4Exception("G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )", 01069 "gMocren0010", FatalException, "Unsupported parameterisation"); 01070 } 01071 } 01072 if(GFDEBUG_DET) 01073 G4cout << " size : " << tbox.GetXHalfLength()/mm << " x " 01074 << tbox.GetYHalfLength()/mm << " x " 01075 << tbox.GetZHalfLength()/mm << " [mm3]" << G4endl; 01076 01077 G4int idx[3]; 01078 idx[dirAxis[0]] = n0; 01079 idx[dirAxis[1]] = n1; 01080 idx[dirAxis[2]] = n2; 01081 Index3D i3d(idx[0],idx[1],idx[2]); 01082 kNestedModality[i3d] = dens; 01083 if(GFDEBUG_DET) 01084 G4cout << " index: " << idx[0] << ", " << idx[1] << ", " << idx[2] 01085 << " density: " << dens << G4endl; 01086 01087 for(G4int i = 0; i < 3; i++) prexyz[i] = xyz[i]; 01088 } 01089 } 01090 } 01091 01092 kVolumeSize.set(box.GetXHalfLength()*2/mm, 01093 box.GetYHalfLength()*2/mm, 01094 box.GetZHalfLength()*2/mm); 01095 // mesh size 01096 if(!kbSetModalityVoxelSize) { 01097 G4float spacing[3] = {static_cast<G4float>(2*xyz[0]), 01098 static_cast<G4float>(2*xyz[1]), 01099 static_cast<G4float>(2*xyz[2])}; 01100 kgMocrenIO->setVoxelSpacing(spacing); 01101 kVoxelDimension.set(spacing[0], spacing[1], spacing[2]); 01102 kbSetModalityVoxelSize = true; 01103 } 01104 01105 } else { 01106 if(GFDEBUG_DET) 01107 G4cout << pv[2]->GetName() << G4endl; 01108 G4Exception("G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )", 01109 "gMocren0011", FatalException, "Non-nested parameterisation"); 01110 } 01111 01112 01113 01114 //-- debug 01115 if(GFDEBUG_DET > 1) { 01116 if(pPVModel->GetCurrentPV()->IsParameterised()) { 01117 G4VPVParameterisation * para = pPVModel->GetCurrentPV()->GetParameterisation(); 01118 G4cout << " Is nested parameterisation? : " << para->IsNested() << G4endl; 01119 01120 01121 G4int npvp = pPVModel->GetDrawnPVPath().size(); 01122 G4cout << " physical volume node id : " 01123 << "size: " << npvp << ", PV name: "; 01124 for(G4int i = 0; i < npvp; i++) { 01125 G4cout << pPVModel->GetDrawnPVPath()[i].GetPhysicalVolume()->GetName() 01126 << " [param:" 01127 << pPVModel->GetDrawnPVPath()[i].GetPhysicalVolume()->IsParameterised() 01128 << ",rep:" 01129 << pPVModel->GetDrawnPVPath()[i].GetPhysicalVolume()->IsReplicated(); 01130 if(pPVModel->GetDrawnPVPath()[i].GetPhysicalVolume()->GetParameterisation()) { 01131 G4cout << ",nest:" 01132 << pPVModel->GetDrawnPVPath()[i].GetPhysicalVolume()->GetParameterisation()->IsNested(); 01133 } 01134 G4cout << ",copyno:" 01135 << pPVModel->GetDrawnPVPath()[i].GetPhysicalVolume()->GetCopyNo(); 01136 G4cout << "] - "; 01137 } 01138 G4cout << G4endl; 01139 01140 01141 pPVModel->GetCurrentPV()->GetReplicationData(axis, nReplicas, width, offset, consuming); 01142 G4cout << " # replicas : " << nReplicas << G4endl; 01143 G4double pareDims[3] = {0.,0.,0.}; 01144 G4Box * pbox = dynamic_cast<G4Box *>(pPVModel->GetDrawnPVPath()[npvp-2].GetPhysicalVolume()->GetLogicalVolume()->GetSolid()); 01145 if(pbox) { 01146 pareDims[0] = 2.*pbox->GetXHalfLength()*mm; 01147 pareDims[1] = 2.*pbox->GetYHalfLength()*mm; 01148 pareDims[2] = 2.*pbox->GetZHalfLength()*mm; 01149 G4cout << " mother size [" 01150 << pPVModel->GetDrawnPVPath()[npvp-2].GetPhysicalVolume()->GetName() 01151 << "] : " 01152 << pareDims[0] << " x " 01153 << pareDims[1] << " x " 01154 << pareDims[2] << " [mm3]" 01155 << G4endl; 01156 } 01157 G4double paraDims[3]; 01158 G4Box * boxP = dynamic_cast<G4Box *>(pPVModel->GetDrawnPVPath()[npvp-1].GetPhysicalVolume()->GetLogicalVolume()->GetSolid()); 01159 if(boxP) { 01160 paraDims[0] = 2.*boxP->GetXHalfLength()*mm; 01161 paraDims[1] = 2.*boxP->GetYHalfLength()*mm; 01162 paraDims[2] = 2.*boxP->GetZHalfLength()*mm; 01163 G4cout << " parameterised volume? [" 01164 << pPVModel->GetDrawnPVPath()[npvp-1].GetPhysicalVolume()->GetName() 01165 << "] : " 01166 << paraDims[0] << " x " 01167 << paraDims[1] << " x " 01168 << paraDims[2] << " [mm3] : " 01169 << G4int(pareDims[0]/paraDims[0]) << " x " 01170 << G4int(pareDims[1]/paraDims[1]) << " x " 01171 << G4int(pareDims[2]/paraDims[2]) << G4endl; 01172 } else { 01173 G4cout << pPVModel->GetDrawnPVPath()[npvp-2].GetPhysicalVolume()->GetName() 01174 << " isn't a G4Box." << G4endl; 01175 } 01176 } 01177 } 01178 01179 01180 } else if(kFlagParameterization == 1) { // G4PhantomParameterisation based geom. construnction 01181 01182 // get the dimension of the parameterized patient geometry 01183 G4PhantomParameterisation * phantomPara 01184 = dynamic_cast<G4PhantomParameterisation*>(pv[0]->GetParameterisation()); 01185 if(phantomPara == NULL) { 01186 G4Exception("G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )", 01187 "gMocren0012", FatalException, "no G4PhantomParameterisation"); 01188 } else { 01189 ; 01190 } 01191 01192 kNestedVolumeDimension[0] = phantomPara->GetNoVoxelX(); 01193 kNestedVolumeDimension[1] = phantomPara->GetNoVoxelY(); 01194 kNestedVolumeDimension[2] = phantomPara->GetNoVoxelZ(); 01195 kNestedVolumeDirAxis[0] = 0; 01196 kNestedVolumeDirAxis[1] = 1; 01197 kNestedVolumeDirAxis[2] = 2; 01198 01199 // get densities of the parameterized patient geometry 01200 G4int nX = kNestedVolumeDimension[0]; 01201 G4int nXY = kNestedVolumeDimension[0]*kNestedVolumeDimension[1]; 01202 01203 for(G4int n0 = 0; n0 < kNestedVolumeDimension[0]; n0++) { 01204 for(G4int n1 = 0; n1 < kNestedVolumeDimension[1]; n1++) { 01205 for(G4int n2 = 0; n2 < kNestedVolumeDimension[2]; n2++) { 01206 01207 G4int repNo = n0 + n1*nX + n2*nXY; 01208 G4Material * mat = phantomPara->ComputeMaterial(repNo, pv[0]); 01209 G4double dens = mat->GetDensity()/(g/cm3); 01210 01211 01212 G4int idx[3]; 01213 idx[kNestedVolumeDirAxis[0]] = n0; 01214 idx[kNestedVolumeDirAxis[1]] = n1; 01215 idx[kNestedVolumeDirAxis[2]] = n2; 01216 Index3D i3d(idx[0],idx[1],idx[2]); 01217 kNestedModality[i3d] = dens; 01218 01219 if(GFDEBUG_DET) 01220 G4cout << " index: " << idx[0] << ", " << idx[1] << ", " << idx[2] 01221 << " density: " << dens << G4endl; 01222 01223 } 01224 } 01225 } 01226 01227 kVolumeSize.set(box.GetXHalfLength()*2/mm, 01228 box.GetYHalfLength()*2/mm, 01229 box.GetZHalfLength()*2/mm); 01230 01231 // mesh size 01232 if(!kbSetModalityVoxelSize) { 01233 G4float spacing[3] = {static_cast<G4float>(2*phantomPara->GetVoxelHalfX()), 01234 static_cast<G4float>(2*phantomPara->GetVoxelHalfY()), 01235 static_cast<G4float>(2*phantomPara->GetVoxelHalfZ())}; 01236 kgMocrenIO->setVoxelSpacing(spacing); 01237 kVoxelDimension.set(spacing[0], spacing[1], spacing[2]); 01238 kbSetModalityVoxelSize = true; 01239 } 01240 } 01241 01242 } // if(box.GetName() == volName) 01243 01244 01245 // processing geometry construction based on the interactive PS 01246 if(!kFLagProcessedInteractiveScorer) { 01247 01248 01249 // get the dimension of the geometry defined in G4VScoringMesh 01250 G4ScoringManager * pScrMan = G4ScoringManager::GetScoringManager(); 01251 if(!pScrMan) return; 01252 G4ScoringBox * scoringBox 01253 = dynamic_cast<G4ScoringBox*>(pScrMan->FindMesh(volName)); 01254 if(scoringBox == NULL) return; 01255 01256 01257 G4int nVoxels[3]; 01258 scoringBox->GetNumberOfSegments(nVoxels); 01259 // this order depends on the G4ScoringBox 01260 kNestedVolumeDimension[0] = nVoxels[2]; 01261 kNestedVolumeDimension[1] = nVoxels[1]; 01262 kNestedVolumeDimension[2] = nVoxels[0]; 01263 kNestedVolumeDirAxis[0] = 2; 01264 kNestedVolumeDirAxis[1] = 1; 01265 kNestedVolumeDirAxis[2] = 0; 01266 01267 // get densities of the parameterized patient geometry 01268 for(G4int n0 = 0; n0 < kNestedVolumeDimension[0]; n0++) { 01269 for(G4int n1 = 0; n1 < kNestedVolumeDimension[1]; n1++) { 01270 for(G4int n2 = 0; n2 < kNestedVolumeDimension[2]; n2++) { 01271 01272 G4double dens = 0.*(g/cm3); 01273 01274 G4int idx[3]; 01275 idx[kNestedVolumeDirAxis[0]] = n0; 01276 idx[kNestedVolumeDirAxis[1]] = n1; 01277 idx[kNestedVolumeDirAxis[2]] = n2; 01278 Index3D i3d(idx[0],idx[1],idx[2]); 01279 kNestedModality[i3d] = dens; 01280 01281 } 01282 } 01283 } 01284 01285 G4ThreeVector boxSize = scoringBox->GetSize(); 01286 if(GFDEBUG_DET > 1) { 01287 G4cout << "Interactive Scorer : size - " 01288 << boxSize.x()/cm << " x " 01289 << boxSize.y()/cm << " x " 01290 << boxSize.z()/cm << " [cm3]" << G4endl; 01291 G4cout << "Interactive Scorer : # voxels - " 01292 << nVoxels[0] << " x " 01293 << nVoxels[1] << " x " 01294 << nVoxels[2] << G4endl; 01295 } 01296 kVolumeSize.set(boxSize.x()*2, 01297 boxSize.y()*2, 01298 boxSize.z()*2); 01299 01300 // mesh size 01301 if(!kbSetModalityVoxelSize) { 01302 G4float spacing[3] = {static_cast<G4float>(boxSize.x()*2/nVoxels[0]), 01303 static_cast<G4float>(boxSize.y()*2/nVoxels[1]), 01304 static_cast<G4float>(boxSize.z()*2/nVoxels[2])}; 01305 01306 kgMocrenIO->setVoxelSpacing(spacing); 01307 kVoxelDimension.set(spacing[0], spacing[1], spacing[2]); 01308 kbSetModalityVoxelSize = true; 01309 01310 } 01311 01312 01313 kVolumeTrans3D = fObjectTransformation; 01314 01315 // translation for the scoring mesh 01316 G4ThreeVector sbth = scoringBox->GetTranslation(); 01317 G4Translate3D sbtranslate(sbth); 01318 kVolumeTrans3D = kVolumeTrans3D*sbtranslate; 01319 01320 // rotation matrix for the scoring mesh 01321 G4RotationMatrix sbrm; 01322 sbrm = scoringBox->GetRotationMatrix(); 01323 if(!sbrm.isIdentity()) { 01324 G4ThreeVector sbdummy(0.,0.,0.); 01325 G4Transform3D sbrotate(sbrm.inverse(), sbdummy); 01326 kVolumeTrans3D = kVolumeTrans3D*sbrotate; 01327 } 01328 01329 01330 // coordination system correction for gMocren 01331 G4ThreeVector raxisY(0., 1., 0.), dummyY(0.,0.,0.); 01332 G4RotationMatrix rotY(raxisY, pi*rad); 01333 G4Transform3D trotY(rotY, dummyY); 01334 G4ThreeVector raxisZ(0., 0., 1.), dummyZ(0.,0.,0.); 01335 G4RotationMatrix rotZ(raxisZ, pi*rad); 01336 G4Transform3D trotZ(rotZ, dummyZ); 01337 01338 kVolumeTrans3D = kVolumeTrans3D*trotY*trotZ; 01339 01340 01341 // 01342 kFLagProcessedInteractiveScorer = true; 01343 } 01344 01345 01346 01347 //-- add detectors 01348 G4bool bAddDet = true; 01349 if(!kMessenger.getDrawVolumeGrid()) { 01350 01351 if(kFlagParameterization == 0) { // nested parameterisation 01352 01353 if(volName == box.GetName()) { 01354 bAddDet = false; 01355 } 01356 01357 std::vector<G4String>::iterator itr = kNestedVolumeNames.begin(); 01358 for(; itr != kNestedVolumeNames.end(); itr++) { 01359 if(*itr == box.GetName()) { 01360 bAddDet = false; 01361 break; 01362 } 01363 } 01364 } else if(kFlagParameterization == 1) { // phantom paramemterisation 01365 01366 if(volName != box.GetName()) { 01367 bAddDet = false; 01368 } 01369 01370 } else if(kFlagParameterization == 2) { // interactive primitive scorer 01371 ; 01372 } 01373 01374 } 01375 if(bAddDet) AddDetector(box); 01376 01377 01378 } // void G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )
virtual void G4GMocrenFileSceneHandler::BeginModeling | ( | ) | [inline, virtual] |
Reimplemented from G4VSceneHandler.
Definition at line 81 of file G4GMocrenFileSceneHandler.hh.
References G4VSceneHandler::BeginModeling().
00081 { G4VSceneHandler::BeginModeling ();}
void G4GMocrenFileSceneHandler::BeginPrimitives | ( | const G4Transform3D & | objectTransformation | ) | [virtual] |
Reimplemented from G4VSceneHandler.
Definition at line 810 of file G4GMocrenFileSceneHandler.cc.
References G4VSceneHandler::BeginPrimitives(), G4VisManager::confirmations, G4cout, G4endl, G4VisManager::GetVerbosity(), GFBeginModeling(), and GFDEBUG.
00811 { 00812 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 00813 G4cout << "***** BeginPrimitives " << G4endl; 00814 00815 GFBeginModeling(); 00816 00817 G4VSceneHandler::BeginPrimitives (objectTransformation); 00818 00819 }
void G4GMocrenFileSceneHandler::BeginSavingGdd | ( | void | ) |
Definition at line 261 of file G4GMocrenFileSceneHandler.cc.
References G4GMocrenIO::clearDetector(), G4GMocrenIO::clearDoseDistAll(), G4GMocrenIO::clearROIAll(), G4GMocrenIO::clearTracks(), G4VisManager::confirmations, G4cout, G4endl, G4GMocrenFileCTtoDensityMap::GetDensity(), G4GMocrenFileCTtoDensityMap::GetMaxCT(), G4GMocrenFileCTtoDensityMap::GetMinCT(), G4VisManager::GetVerbosity(), GFDEBUG, IsSavingGdd(), SetGddFileName(), G4GMocrenIO::setModalityImageDensityMap(), and G4GMocrenIO::setModalityImageMinMax().
Referenced by GFBeginModeling().
00262 { 00263 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 00264 G4cout << "***** BeginSavingGdd (called)" << G4endl; 00265 00266 if( !IsSavingGdd() ) { 00267 00268 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) { 00269 G4cout << "***** (started) " ; 00270 G4cout << "(open g4.gdd, ##)" << G4endl; 00271 } 00272 00273 SetGddFileName() ; // result set to kGddFileName 00274 kFlagSaving_g4_gdd = true; 00275 00276 00277 G4GMocrenFileCTtoDensityMap ctdens; 00278 short minmax[2]; 00279 minmax[0] = ctdens.GetMinCT(); 00280 minmax[1] = ctdens.GetMaxCT(); 00281 kgMocrenIO->setModalityImageMinMax(minmax); 00282 std::vector<G4float> map; 00283 G4float dens; 00284 for(G4int i = minmax[0]; i <= minmax[1]; i++) { 00285 dens = ctdens.GetDensity(i); 00286 map.push_back(dens); 00287 } 00288 kgMocrenIO->setModalityImageDensityMap(map); 00289 00290 /* 00291 G4String fname = "modality-map.dat"; 00292 std::ifstream ifile(fname); 00293 if(ifile) { 00294 short minmax[2]; 00295 ifile >> minmax[0] >> minmax[1]; 00296 kgMocrenIO->setModalityImageMinMax(minmax); 00297 std::vector<G4float> map; 00298 G4float dens; 00299 for(G4int i = minmax[0]; i <= minmax[1]; i++) { 00300 ifile >> dens; 00301 map.push_back(dens); 00302 } 00303 kgMocrenIO->setModalityImageDensityMap(map); 00304 00305 } else { 00306 G4cout << "cann't open the file : " << fname << G4endl; 00307 } 00308 */ 00309 00310 // mesh size 00311 //kMessenger.getNoVoxels(kModalitySize[0], kModalitySize[1], kModalitySize[2]); 00312 //kgMocrenIO->setModalityImageSize(kModalitySize); 00313 00314 // initializations 00315 //kgMocrenIO->clearModalityImage(); 00316 kgMocrenIO->clearDoseDistAll(); 00317 kgMocrenIO->clearROIAll(); 00318 kgMocrenIO->clearTracks(); 00319 kgMocrenIO->clearDetector(); 00320 std::vector<Detector>::iterator itr = kDetectors.begin(); 00321 for(; itr != kDetectors.end(); itr++) { 00322 itr->clear(); 00323 } 00324 kDetectors.clear(); 00325 00326 kNestedHitsList.clear(); 00327 kNestedVolumeNames.clear(); 00328 00329 } 00330 }
void G4GMocrenFileSceneHandler::ClearTransientStore | ( | ) | [virtual] |
Reimplemented from G4VSceneHandler.
Definition at line 1795 of file G4GMocrenFileSceneHandler.cc.
References G4VSceneHandler::fpViewer.
01796 { 01797 // This is typically called after an update and before drawing hits 01798 // of the next event. To simulate the clearing of "transients" 01799 // (hits, etc.) the detector is redrawn... 01800 if (fpViewer) { 01801 fpViewer -> SetView (); 01802 fpViewer -> ClearView (); 01803 fpViewer -> DrawView (); 01804 } 01805 }
virtual void G4GMocrenFileSceneHandler::EndModeling | ( | ) | [inline, virtual] |
Reimplemented from G4VSceneHandler.
Definition at line 82 of file G4GMocrenFileSceneHandler.hh.
References G4VSceneHandler::EndModeling().
00082 { G4VSceneHandler::EndModeling ();}
void G4GMocrenFileSceneHandler::EndPrimitives | ( | ) | [virtual] |
Reimplemented from G4VSceneHandler.
Definition at line 823 of file G4GMocrenFileSceneHandler.cc.
References G4VisManager::confirmations, G4VSceneHandler::EndPrimitives(), G4cout, G4endl, G4VisManager::GetVerbosity(), and GFDEBUG.
00824 { 00825 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 00826 G4cout << "***** EndPrimitives " << G4endl; 00827 00828 G4VSceneHandler::EndPrimitives (); 00829 }
void G4GMocrenFileSceneHandler::EndSavingGdd | ( | void | ) |
Definition at line 332 of file G4GMocrenFileSceneHandler.cc.
References G4GMocrenIO::addTrack(), G4VisManager::confirmations, G4GMocrenIO::convertDensityToHU(), DBL_MAX, G4cout, G4endl, G4VisManager::GetVerbosity(), GFDEBUG, GFDEBUG_DET, IsSavingGdd(), CLHEP::detail::n, G4GMocrenIO::newDoseDist(), G4GMocrenIO::setDoseDist(), G4GMocrenIO::setDoseDistMinMax(), G4GMocrenIO::setDoseDistName(), G4GMocrenIO::setDoseDistScale(), G4GMocrenIO::setDoseDistSize(), G4GMocrenIO::setDoseDistUnit(), G4GMocrenIO::setModalityImage(), G4GMocrenIO::setModalityImageSize(), G4GMocrenIO::storeData(), G4GMocrenIO::translateDetector(), and G4GMocrenIO::translateTracks().
Referenced by GFEndModeling().
00333 { 00334 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 00335 G4cout << "***** EndSavingGdd (called)" << G4endl; 00336 00337 if(IsSavingGdd()) { 00338 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 00339 G4cout << "***** (started) (close " 00340 << kGddFileName << ")" << G4endl; 00341 00342 if(kGddDest) kGddDest.close(); 00343 kFlagSaving_g4_gdd = false; 00344 00345 std::map<Index3D, G4float>::iterator itr = kNestedModality.begin(); 00346 G4int xmax=0, ymax=0, zmax=0; 00347 for(; itr != kNestedModality.end(); itr++) { 00348 if(itr->first.x > xmax) xmax = itr->first.x; 00349 if(itr->first.y > ymax) ymax = itr->first.y; 00350 if(itr->first.z > zmax) zmax = itr->first.z; 00351 } 00352 // mesh size 00353 kModalitySize[0] = xmax+1; 00354 kModalitySize[1] = ymax+1; 00355 kModalitySize[2] = zmax+1; 00356 kgMocrenIO->setModalityImageSize(kModalitySize); 00357 if(GFDEBUG) G4cout << "gMocren-file driver : modality size : " 00358 << kModalitySize[0] << " x " 00359 << kModalitySize[1] << " x " 00360 << kModalitySize[2] << G4endl; 00361 00362 G4int nxy = kModalitySize[0]*kModalitySize[1]; 00363 //std::map<G4int, G4float>::iterator itr; 00364 for(G4int z = 0; z < kModalitySize[2]; z++) { 00365 short * modality = new short[nxy]; 00366 for(G4int y = 0; y < kModalitySize[1]; y++) { 00367 for(G4int x = 0; x < kModalitySize[0]; x++) { 00368 //for(G4int x = kModalitySize[0]-1; x >= 0 ; x--) { 00369 //G4int ixy = x + (kModalitySize[1]-y-1)*kModalitySize[0]; 00370 00371 G4int ixy = x + y*kModalitySize[0]; 00372 Index3D idx(x,y,z); 00373 itr = kNestedModality.find(idx); 00374 if(itr != kNestedModality.end()) { 00375 00376 modality[ixy] = kgMocrenIO->convertDensityToHU(itr->second); 00377 } else { 00378 modality[ixy] = -1024; 00379 } 00380 00381 } 00382 } 00383 kgMocrenIO->setModalityImage(modality); 00384 } 00385 00386 //-- dose 00387 size_t nhits = kNestedHitsList.size(); 00388 if(GFDEBUG) G4cout << "gMocren-file driver : # hits = " << nhits << G4endl; 00389 00390 std::map<Index3D, G4double>::iterator hitsItr; 00391 std::map<G4String, std::map<Index3D, G4double> >::iterator hitsListItr = kNestedHitsList.begin(); 00392 00393 for(G4int n = 0; hitsListItr != kNestedHitsList.end(); hitsListItr++, n++) { 00394 00395 kgMocrenIO->newDoseDist(); 00396 kgMocrenIO->setDoseDistName(hitsListItr->first, n); 00397 kgMocrenIO->setDoseDistSize(kModalitySize, n); 00398 00399 G4double minmax[2] = {DBL_MAX, -DBL_MAX}; 00400 for(G4int z = 0 ; z < kModalitySize[2]; z++) { 00401 G4double * values = new G4double[nxy]; 00402 for(G4int y = 0; y < kModalitySize[1]; y++) { 00403 for(G4int x = 0; x < kModalitySize[0]; x++) { 00404 00405 G4int ixy = x + y*kModalitySize[0]; 00406 Index3D idx(x,y,z); 00407 hitsItr = hitsListItr->second.find(idx); 00408 if(hitsItr != hitsListItr->second.end()) { 00409 00410 values[ixy] = hitsItr->second; 00411 } else { 00412 values[ixy] = 0.; 00413 } 00414 if(values[ixy] < minmax[0]) minmax[0] = values[ixy]; 00415 if(values[ixy] > minmax[1]) minmax[1] = values[ixy]; 00416 } 00417 } 00418 kgMocrenIO->setDoseDist(values, n); 00419 } 00420 kgMocrenIO->setDoseDistMinMax(minmax, n); 00421 G4double lower = 0.; 00422 if(minmax[0] < 0) lower = minmax[0]; 00423 G4double scale = (minmax[1]-lower)/25000.; 00424 kgMocrenIO->setDoseDistScale(scale, n); 00425 G4String sunit("unit?"); //temporarily 00426 kgMocrenIO->setDoseDistUnit(sunit, n); 00427 } 00428 00429 00430 //-- draw axes 00431 if(false) {//true,false 00432 G4ThreeVector trans; 00433 G4RotationMatrix rot; 00434 trans = kVolumeTrans3D.getTranslation(); 00435 rot = kVolumeTrans3D.getRotation().inverse(); 00436 // x 00437 std::vector<G4float *> tracks; 00438 unsigned char colors[3]; 00439 G4float * trk = new G4float[6]; 00440 tracks.push_back(trk); 00441 00442 G4ThreeVector orig(0.,0.,0), xa(2000.,0.,0.), ya(0.,2000.,0.), za(0.,0.,2000.); 00443 orig -= trans; 00444 orig.transform(rot); 00445 xa -= trans; 00446 xa.transform(rot); 00447 ya -= trans; 00448 ya.transform(rot); 00449 za -= trans; 00450 za.transform(rot); 00451 for(G4int i = 0; i < 3; i++) trk[i] = orig[i]; 00452 for(G4int i = 0; i < 3; i++) trk[i+3] = xa[i]; 00453 colors[0] = 255; colors[1] = 0; colors[2] = 0; 00454 kgMocrenIO->addTrack(tracks, colors); 00455 // y 00456 for(G4int i = 0; i < 3; i++) trk[i+3] = ya[i]; 00457 colors[0] = 0; colors[1] = 255; colors[2] = 0; 00458 kgMocrenIO->addTrack(tracks, colors); 00459 // z 00460 for(G4int i = 0; i < 3; i++) trk[i+3] = za[i]; 00461 colors[0] = 0; colors[1] = 0; colors[2] = 255; 00462 kgMocrenIO->addTrack(tracks, colors); 00463 } 00464 00465 //-- detector 00466 ExtractDetector(); 00467 00468 00469 if(GFDEBUG_DET) G4cout << ">>>>>>>>>>>>>>>>>>>>>> ("; 00470 std::vector<G4float> transformObjects; 00471 for(G4int i = 0; i < 3; i++) { 00472 // need to check!! 00473 transformObjects.push_back((kVolumeSize[i]/2. - kVoxelDimension[i]/2.)); 00474 if(GFDEBUG_DET) G4cout << transformObjects[i] << ", "; 00475 } 00476 if(GFDEBUG_DET) G4cout << ")" << G4endl; 00477 00478 00479 kgMocrenIO->translateTracks(transformObjects); 00480 kgMocrenIO->translateDetector(transformObjects); 00481 00482 // store 00483 kgMocrenIO->storeData(kGddFileName); 00484 } 00485 00486 }
const char* G4GMocrenFileSceneHandler::GetGddFileName | ( | ) | [inline] |
Definition at line 121 of file G4GMocrenFileSceneHandler.hh.
Referenced by G4GMocrenFileViewer::G4GMocrenFileViewer(), and G4GMocrenFileViewer::ShowView().
G4GMocrenFile& G4GMocrenFileSceneHandler::GetSystem | ( | ) | [inline] |
void G4GMocrenFileSceneHandler::GFBeginModeling | ( | ) |
Definition at line 490 of file G4GMocrenFileSceneHandler.cc.
References G4VSceneHandler::BeginModeling(), BeginSavingGdd(), G4VisManager::confirmations, G4cout, G4endl, G4Scene::GetEndOfEventModelList(), G4VSceneHandler::GetScene(), G4VisManager::GetVerbosity(), GFDEBUG, GFDEBUG_HIT, and GFIsInModeling().
Referenced by AddPrimitive(), AddSolid(), BeginPrimitives(), G4GMocrenFileViewer::ClearView(), and G4GMocrenFileViewer::DrawView().
00491 { 00492 G4VSceneHandler::BeginModeling(); 00493 00494 if( !GFIsInModeling() ) { 00495 00496 00497 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 00498 G4cout << "***** G4GMocrenFileSceneHandler::GFBeginModeling (called & started)" << G4endl; 00499 00500 //----- Send saving command and heading comment 00501 BeginSavingGdd(); 00502 00503 kFlagInModeling = true ; 00504 00505 // These models are entrusted to user commands /vis/scene/add/psHits or hits 00506 //GetScene()->AddEndOfEventModel(new G4PSHitsModel()); 00507 //GetScene()->AddEndOfRunModel(new G4PSHitsModel()); 00508 //scene->AddEndOfEventModel(new G4HitsModel()); 00509 if(GFDEBUG_HIT) { 00510 G4Scene * scene = GetScene(); 00511 std::vector<G4Scene::Model> vmodel = scene->GetEndOfEventModelList(); 00512 std::vector<G4Scene::Model>::iterator itr = vmodel.begin(); 00513 for(; itr != vmodel.end(); itr++) { 00514 G4cout << " IIIIII model name: " << itr->fpModel->GetGlobalTag() << G4endl; 00515 } 00516 } 00517 00518 } // if 00519 }
void G4GMocrenFileSceneHandler::GFEndModeling | ( | ) |
Definition at line 783 of file G4GMocrenFileSceneHandler.cc.
References G4VisManager::confirmations, G4VSceneHandler::EndModeling(), EndSavingGdd(), G4cout, G4endl, G4VisManager::GetVerbosity(), GFDEBUG, and GFIsInModeling().
Referenced by G4GMocrenFileViewer::ShowView(), and ~G4GMocrenFileSceneHandler().
00784 { 00785 G4VSceneHandler::EndModeling(); 00786 00787 //----- 00788 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) 00789 G4cout << "***** GFEndModeling (called)" << G4endl; 00790 00791 if( GFIsInModeling() ) { 00792 00793 if(GFDEBUG || G4VisManager::GetVerbosity() >= G4VisManager::confirmations) { 00794 G4cout << "***** GFEndModeling (started) " ; 00795 G4cout << "(/EndModeling, /DrawAll, /CloseDevice)" << G4endl; 00796 } 00797 00798 //----- End saving data to g4.gdd 00799 EndSavingGdd() ; 00800 00801 //------ Reset flag 00802 kFlagInModeling = false ; 00803 00804 } 00805 00806 }
G4bool G4GMocrenFileSceneHandler::GFIsInModeling | ( | ) | [inline] |
Definition at line 113 of file G4GMocrenFileSceneHandler.hh.
Referenced by GFBeginModeling(), GFEndModeling(), and G4GMocrenFileViewer::ShowView().
G4bool G4GMocrenFileSceneHandler::IsSavingGdd | ( | void | ) | [inline] |
Definition at line 115 of file G4GMocrenFileSceneHandler.hh.
Referenced by BeginSavingGdd(), and EndSavingGdd().
void G4GMocrenFileSceneHandler::SetGddFileName | ( | ) |
Definition at line 190 of file G4GMocrenFileSceneHandler.cc.
References DEFAULT_GDD_FILE_NAME, G4cout, G4endl, GDD_FILE_HEADER, G4VisManager::GetVerbosity(), GFDEBUG, MAX_NUM_TRAJECTORIES, and G4VisManager::warnings.
Referenced by BeginSavingGdd().
00191 { 00192 // g4_00.gdd, g4_01.gdd, ..., g4_MAX_FILE_INDEX.gdd 00193 const G4int MAX_FILE_INDEX = kMaxFileNum - 1 ; 00194 00195 // dest directory (null if no environmental variables is set) 00196 std::strncpy(kGddFileName, kGddDestDir, std::strlen(kGddDestDir)); 00197 00198 // create full path name (default) 00199 std::strncat ( kGddFileName, DEFAULT_GDD_FILE_NAME, std::strlen(DEFAULT_GDD_FILE_NAME)); 00200 00201 // Automatic updation of file names 00202 static G4int currentNumber = 0; 00203 for( G4int i = currentNumber ; i < kMaxFileNum ; i++) { 00204 00205 // Message in the final execution 00206 if( i == MAX_FILE_INDEX ) 00207 { 00208 if (G4VisManager::GetVerbosity() >= G4VisManager::warnings) { 00209 G4cout << "===========================================" << G4endl; 00210 G4cout << "WARNING MESSAGE from GMocrenFile driver: " << G4endl; 00211 G4cout << " This file name is the final one in the " << G4endl; 00212 G4cout << " automatic updation of the output file name." << G4endl; 00213 G4cout << " You may overwrite existing files, i.e. " << G4endl; 00214 G4cout << " g4_XX.gdd." << G4endl; 00215 G4cout << "===========================================" << G4endl; 00216 } 00217 } 00218 00219 // re-determine file name as G4GMocrenFile_DEST_DIR/g4_XX.gdd 00220 if( i >= 0 && i <= 9 ) { 00221 std::sprintf( kGddFileName, "%s%s%s%d.gdd" , kGddDestDir, GDD_FILE_HEADER, "0", i ); 00222 } else { 00223 std::sprintf( kGddFileName, "%s%s%d.gdd" , kGddDestDir, GDD_FILE_HEADER, i ); 00224 } 00225 00226 // check validity of the file name 00227 std::ifstream fin(kGddFileName); 00228 if(GFDEBUG) 00229 G4cout << "FILEOPEN: " << i << " : " << kGddFileName << fin.fail() << G4endl; 00230 if(!fin) { 00231 // new file 00232 fin.close(); 00233 currentNumber = i+1; 00234 break; 00235 } else { 00236 // already exists (try next) 00237 fin.close(); 00238 } 00239 00240 } // for 00241 00242 G4cout << "======================================================================" << G4endl; 00243 G4cout << "Output file: " << kGddFileName << G4endl; 00244 G4cout << "Destination directory (current dir if NULL): " << kGddDestDir << G4endl; 00245 G4cout << "Maximum number of files in the destination directory: " << kMaxFileNum << G4endl; 00246 G4cout << "Note:" << G4endl; 00247 G4cout << " * The maximum number is customizable as: " << G4endl; 00248 G4cout << " % setenv G4GMocrenFile_MAX_FILE_NUM number " << G4endl; 00249 G4cout << " * The destination directory is customizable as:" << G4endl; 00250 G4cout << " % setenv G4GMocrenFile_DEST_DIR dir_name/ " << G4endl; 00251 G4cout << " ** Do not forget \"/\" at the end of the dir_name, e.g. \"./tmp/\"." << G4endl; 00252 //G4cout << " dir_name, e.g. \"./tmp/\"." << G4endl; 00253 G4cout << G4endl; 00254 G4cout << "Maximum number of trajectories is set to " << MAX_NUM_TRAJECTORIES << "."<< G4endl; 00255 G4cout << "======================================================================" << G4endl; 00256 00257 } // G4GMocrenFileSceneHandler::SetGddFileName()
friend class G4GMocrenFileViewer [friend] |
Definition at line 56 of file G4GMocrenFileSceneHandler.hh.