Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4GMocrenFileSceneHandler Class Reference

#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 &para)
 
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 ()
 
G4GMocrenFileGetSystem ()
 
const char * GetGddFileName ()
 
- Public Member Functions inherited from G4VSceneHandler
 G4VSceneHandler (G4VGraphicsSystem &system, G4int id, const G4String &name="")
 
virtual ~G4VSceneHandler ()
 
virtual void PreAddSolid (const G4Transform3D &objectTransformation, const G4VisAttributes &)
 
virtual void PostAddSolid ()
 
virtual void AddSolid (const G4Box &)
 
virtual void AddSolid (const G4Cons &)
 
virtual void AddSolid (const G4Tubs &)
 
virtual void AddSolid (const G4Trd &)
 
virtual void AddSolid (const G4Trap &)
 
virtual void AddSolid (const G4Sphere &)
 
virtual void AddSolid (const G4Para &)
 
virtual void AddSolid (const G4Torus &)
 
virtual void AddSolid (const G4Polycone &)
 
virtual void AddSolid (const G4Polyhedra &)
 
virtual void AddSolid (const G4VSolid &)
 
virtual void AddCompound (const G4VTrajectory &)
 
virtual void AddCompound (const G4VHit &)
 
virtual void AddCompound (const G4VDigi &)
 
virtual void AddCompound (const G4THitsMap< G4double > &)
 
virtual void BeginModeling ()
 
virtual void EndModeling ()
 
virtual void BeginPrimitives (const G4Transform3D &objectTransformation)
 
virtual void EndPrimitives ()
 
virtual void BeginPrimitives2D (const G4Transform3D &objectTransformation)
 
virtual void EndPrimitives2D ()
 
virtual void AddPrimitive (const G4Polyline &)=0
 
virtual void AddPrimitive (const G4Scale &)
 
virtual void AddPrimitive (const G4Text &)=0
 
virtual void AddPrimitive (const G4Circle &)=0
 
virtual void AddPrimitive (const G4Square &)=0
 
virtual void AddPrimitive (const G4Polymarker &)
 
virtual void AddPrimitive (const G4Polyhedron &)=0
 
virtual void AddPrimitive (const G4NURBS &)=0
 
const G4StringGetName () const
 
G4int GetSceneHandlerId () const
 
G4int GetViewCount () const
 
G4VGraphicsSystemGetGraphicsSystem () const
 
G4SceneGetScene () const
 
const G4ViewerListGetViewerList () const
 
G4VModelGetModel () const
 
G4VViewerGetCurrentViewer () const
 
G4bool GetMarkForClearingTransientStore () const
 
G4bool IsReadyForTransients () const
 
G4bool GetTransientsDrawnThisEvent () const
 
G4bool GetTransientsDrawnThisRun () const
 
const G4Transform3DGetObjectTransformation () const
 
void SetName (const G4String &)
 
void SetCurrentViewer (G4VViewer *)
 
virtual void SetScene (G4Scene *)
 
G4ViewerListSetViewerList ()
 
void SetModel (G4VModel *)
 
void SetMarkForClearingTransientStore (G4bool)
 
void SetTransientsDrawnThisEvent (G4bool)
 
void SetTransientsDrawnThisRun (G4bool)
 
void SetObjectTransformation (const G4Transform3D &)
 
const G4ColourGetColour (const G4Visible &)
 
const G4ColourGetColor (const G4Visible &)
 
const G4ColourGetTextColour (const G4Text &)
 
const G4ColourGetTextColor (const G4Text &)
 
G4double GetLineWidth (const G4VisAttributes *)
 
G4ViewParameters::DrawingStyle GetDrawingStyle (const G4VisAttributes *)
 
G4bool GetAuxEdgeVisible (const G4VisAttributes *)
 
G4int GetNoOfSides (const G4VisAttributes *)
 
G4double GetMarkerSize (const G4VMarker &, MarkerSizeType &)
 
G4double GetMarkerDiameter (const G4VMarker &, MarkerSizeType &)
 
G4double GetMarkerRadius (const G4VMarker &, MarkerSizeType &)
 
G4ModelingParametersCreateModelingParameters ()
 
void DrawEvent (const G4Event *)
 
void DrawEndOfRunModels ()
 
G4int IncrementViewCount ()
 
virtual void ClearStore ()
 
virtual void ClearTransientStore ()
 
void AddViewerToList (G4VViewer *pView)
 
void RemoveViewerFromList (G4VViewer *pView)
 
- Public Member Functions inherited from G4VGraphicsScene
 G4VGraphicsScene ()
 
virtual ~G4VGraphicsScene ()
 
virtual void PreAddSolid (const G4Transform3D &objectTransformation, const G4VisAttributes &visAttribs)=0
 
virtual void PostAddSolid ()=0
 
virtual void AddSolid (const G4Box &)=0
 
virtual void AddSolid (const G4Cons &)=0
 
virtual void AddSolid (const G4Tubs &)=0
 
virtual void AddSolid (const G4Trd &)=0
 
virtual void AddSolid (const G4Trap &)=0
 
virtual void AddSolid (const G4Sphere &)=0
 
virtual void AddSolid (const G4Para &)=0
 
virtual void AddSolid (const G4Torus &)=0
 
virtual void AddSolid (const G4Polycone &)=0
 
virtual void AddSolid (const G4Polyhedra &)=0
 
virtual void AddSolid (const G4VSolid &)=0
 
virtual void AddCompound (const G4VTrajectory &)=0
 
virtual void AddCompound (const G4VHit &)=0
 
virtual void AddCompound (const G4VDigi &)=0
 
virtual void AddCompound (const G4THitsMap< G4double > &)=0
 
virtual void BeginPrimitives (const G4Transform3D &objectTransformation=G4Transform3D())=0
 
virtual void EndPrimitives ()=0
 
virtual void BeginPrimitives2D (const G4Transform3D &objectTransformation=G4Transform3D())=0
 
virtual void EndPrimitives2D ()=0
 
virtual void AddPrimitive (const G4Polyline &)=0
 
virtual void AddPrimitive (const G4Scale &)=0
 
virtual void AddPrimitive (const G4Text &)=0
 
virtual void AddPrimitive (const G4Circle &)=0
 
virtual void AddPrimitive (const G4Square &)=0
 
virtual void AddPrimitive (const G4Polymarker &)=0
 
virtual void AddPrimitive (const G4Polyhedron &)=0
 
virtual void AddPrimitive (const G4NURBS &)=0
 

Friends

class G4GMocrenFileViewer
 

Additional Inherited Members

- Public Types inherited from G4VSceneHandler
enum  MarkerSizeType { world , screen }
 
- Protected Member Functions inherited from G4VSceneHandler
virtual void ProcessScene ()
 
virtual void RequestPrimitives (const G4VSolid &solid)
 
virtual G4VSolidCreateSectionSolid ()
 
virtual G4VSolidCreateCutawaySolid ()
 
void LoadAtts (const G4Visible &, G4AttHolder *)
 
- Protected Attributes inherited from G4VSceneHandler
G4VGraphicsSystemfSystem
 
const G4int fSceneHandlerId
 
G4String fName
 
G4int fViewCount
 
G4ViewerList fViewerList
 
G4VViewerfpViewer
 
G4ScenefpScene
 
G4bool fMarkForClearingTransientStore
 
G4bool fReadyForTransients
 
G4bool fTransientsDrawnThisEvent
 
G4bool fTransientsDrawnThisRun
 
G4bool fProcessingSolid
 
G4bool fProcessing2D
 
G4VModelfpModel
 
G4Transform3D fObjectTransformation
 
G4int fNestingDepth
 
const G4VisAttributesfpVisAttribs
 
const G4Transform3D fIdentityTransformation
 

Detailed Description

Definition at line 54 of file G4GMocrenFileSceneHandler.hh.

Constructor & Destructor Documentation

◆ G4GMocrenFileSceneHandler()

G4GMocrenFileSceneHandler::G4GMocrenFileSceneHandler ( G4GMocrenFile system,
G4GMocrenMessenger messenger,
const G4String name = "" 
)

Definition at line 118 of file G4GMocrenFileSceneHandler.cc.

121 : G4VSceneHandler(system, kSceneIdCount++, name),
122 kSystem(system),
123 kMessenger(messenger),
124 kgMocrenIO(new G4GMocrenIO()),
125 kbSetModalityVoxelSize(false),
126 kbModelingTrajectory(false),
127// kGddDest(0),
128 kFlagInModeling(false),
129 kFlagSaving_g4_gdd(false),
130 kFlagParameterization(0),
131 kFLagProcessedInteractiveScorer(false) {
132
133 // g4.gdd filename and its directory
134 if(getenv("G4GMocrenFile_DEST_DIR") == NULL) {
135 kGddDestDir[0] = '\0';
136 //std::strcpy(kGddDestDir , ""); // output dir
137 //std::strcpy(kGddFileName, DEFAULT_GDD_FILE_NAME); // filename
138 std::strncpy(kGddFileName, DEFAULT_GDD_FILE_NAME, std::strlen(DEFAULT_GDD_FILE_NAME)); // filename
139 } else {
140 const char * env = getenv("G4GMocrenFile_DEST_DIR");
141 std::strncpy(kGddDestDir, env, std::strlen(env)); // output dir
142 std::strncpy(kGddFileName, DEFAULT_GDD_FILE_NAME, std::strlen(DEFAULT_GDD_FILE_NAME)); // filename
143 }
144
145 // maximum number of g4.gdd files in the dest directory
146 kMaxFileNum = FR_MAX_FILE_NUM ; // initialization
147 if ( std::getenv( "G4GMocrenFile_MAX_FILE_NUM" ) != NULL ) {
148
149 std::sscanf( getenv("G4GMocrenFile_MAX_FILE_NUM"), "%d", &kMaxFileNum ) ;
150
151 } else {
152 kMaxFileNum = FR_MAX_FILE_NUM ;
153 }
154 if( kMaxFileNum < 1 ) { kMaxFileNum = 1 ; }
155
156 InitializeParameters();
157
158}
const int FR_MAX_FILE_NUM
const char DEFAULT_GDD_FILE_NAME[]

◆ ~G4GMocrenFileSceneHandler()

G4GMocrenFileSceneHandler::~G4GMocrenFileSceneHandler ( )
virtual

Definition at line 162 of file G4GMocrenFileSceneHandler.cc.

163{
165 G4cout << "***** ~G4GMocrenFileSceneHandler" << G4endl;
166
167 if(kGddDest) {
168 //----- End of modeling
169 // close g4.gdd
171 }
172}
const G4bool GFDEBUG
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
static Verbosity GetVerbosity()

Member Function Documentation

◆ AddCompound() [1/4]

void G4GMocrenFileSceneHandler::AddCompound ( const G4THitsMap< G4double > &  hits)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1703 of file G4GMocrenFileSceneHandler.cc.

1703 {
1704 if(GFDEBUG_HIT)
1705 G4cout << " ::AddCompound(const std::map<G4int, G4double*> &) >>>>>>>>> " << G4endl;
1706
1707
1708 std::vector<G4String> hitScorerNames = kMessenger.getHitScorerNames();
1709 G4int nhitname = (G4int)hitScorerNames.size();
1710 G4String scorername = static_cast<G4VHitsCollection>(hits).GetName();
1711
1712 //-- --//
1713 /*
1714 std::vector<G4String> hitScorerNames = kMessenger.getHitScorerNames();
1715 if(GFDEBUG_HIT) {
1716 std::vector<G4String>::iterator itr = hitScorerNames.begin();
1717 for(; itr != hitScorerNames.end(); itr++)
1718 G4cout << " PS name : " << *itr << G4endl;
1719 }
1720 */
1721
1722 { // Scope bracket to avoid compiler messages about shadowing (JA).
1723 //for(G4int i = 0; i < nhitname; i++) { // this selection trusts
1724 //if(scorername == hitScorerNames[i]) { // thea command /vis/scene/add/psHits hit_name.
1725
1726 G4int idx[3];
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]);
1732
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;
1737 } else {
1738 std::map<Index3D, G4double> hit;
1739 hit.insert(std::map<Index3D, G4double>::value_type(id, *itr->second));
1740 kNestedHitsList[scorername] = hit;
1741 }
1742 }
1743
1744 //break;
1745 //}
1746 //}
1747 }
1748
1749 if(GFDEBUG_HIT) {
1750 G4String meshname = static_cast<G4VHitsCollection>(hits).GetSDname();
1751 G4cout << " >>>>> " << meshname << " : " << scorername << G4endl;
1752
1753 for(G4int i = 0; i < nhitname; i++)
1754 if(scorername == hitScorerNames[i])
1755 G4cout << " !!!! Hit scorer !!!! " << scorername << G4endl;
1756
1757 G4cout << " dimension: "
1758 << kNestedVolumeDimension[0] << " x "
1759 << kNestedVolumeDimension[1] << " x "
1760 << kNestedVolumeDimension[2] << G4endl;
1761
1762 G4int id[3];
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 << ", ";
1770 }
1771 G4cout << G4endl;
1772 }
1773
1774}
const G4bool GFDEBUG_HIT
int G4int
Definition: G4Types.hh:66
virtual std::vector< G4String > getHitScorerNames()
std::map< G4int, T * > * GetMap() const
Definition: G4THitsMap.hh:68
const G4String & GetName() const

◆ AddCompound() [2/4]

void G4GMocrenFileSceneHandler::AddCompound ( const G4VDigi hit)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1698 of file G4GMocrenFileSceneHandler.cc.

1698 {
1699 if(GFDEBUG_DIGI) G4cout << " ::AddCompound(const G4VDigi&) >>>>>>>>> " << G4endl;
1701}
const G4bool GFDEBUG_DIGI
virtual void AddCompound(const G4VTrajectory &)

◆ AddCompound() [3/4]

void G4GMocrenFileSceneHandler::AddCompound ( const G4VHit hit)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1598 of file G4GMocrenFileSceneHandler.cc.

1598 {
1599 if(GFDEBUG_HIT) G4cout << " ::AddCompound(const G4VHit&) >>>>>>>>> " << G4endl;
1600
1602
1603 /*
1604 const std::map<G4String, G4AttDef> * map = hit.GetAttDefs();
1605 if(!map) return;
1606 std::map<G4String, G4AttDef>::const_iterator itr = map->begin();
1607 for(; itr != map->end(); itr++) {
1608 G4cout << itr->first << " : " << itr->second.GetName()
1609 << " , " << itr->second.GetDesc() << G4endl;
1610 }
1611 */
1612
1613 std::vector<G4String> hitNames = kMessenger.getHitNames();
1614 if(GFDEBUG_HIT) {
1615 std::vector<G4String>::iterator itr = hitNames.begin();
1616 for(; itr != hitNames.end(); itr++)
1617 G4cout << " hit name : " << *itr << G4endl;
1618 }
1619
1620 std::vector<G4AttValue> * attval = hit.CreateAttValues();
1621 if(!attval) {G4cout << "0 empty " << (unsigned long)attval << G4endl;}
1622 else {
1623
1624 G4bool bid[3] = {false, false, false};
1625 Index3D id;
1626
1627 std::vector<G4AttValue>::iterator itr;
1628 // First, get IDs
1629 for(itr = attval->begin(); itr != attval->end(); itr++) {
1630 std::string stmp = itr->GetValue();
1631 std::istringstream sval(stmp.c_str());
1632
1633 if(itr->GetName() == G4String("XID")) {
1634 sval >> id.x;
1635 bid[0] = true;
1636 continue;
1637 }
1638 if(itr->GetName() == G4String("YID")) {
1639 sval >> id.y;
1640 bid[1] = true;
1641 continue;
1642 }
1643 if(itr->GetName() == G4String("ZID")) {
1644 sval >> id.z;
1645 bid[2] = true;
1646 continue;
1647 }
1648 }
1649
1650 G4int nhitname = (G4int)hitNames.size();
1651
1652 if(bid[0] && bid[1] && bid[2]) {
1653
1654 if(GFDEBUG_HIT)
1655 G4cout << " Hit : index(" << id.x << ", " << id.y << ", "
1656 << id.z << ")" << G4endl;
1657
1658 // Get attributes
1659 for(itr = attval->begin(); itr != attval->end(); itr++) {
1660 for(G4int i = 0; i < nhitname; i++) {
1661 if(itr->GetName() == hitNames[i]) {
1662
1663 std::string stmp = itr->GetValue();
1664 std::istringstream sval(stmp.c_str());
1665 G4double value;
1666 G4String unit;
1667 sval >> value >> unit;
1668
1669 std::map<G4String, std::map<Index3D, G4double> >::iterator kNestedHitsListItr;
1670 kNestedHitsListItr = kNestedHitsList.find(hitNames[i]);
1671 if(kNestedHitsListItr != kNestedHitsList.end()) {
1672 //fTempNestedHits = &kNestedHitsListItr->second;
1673 //(*fTempNestedHits)[id] = value;
1674 kNestedHitsListItr->second[id] = value;
1675 } else {
1676 std::map<Index3D, G4double> hits;
1677 hits.insert(std::map<Index3D, G4double>::value_type(id, value));
1678 kNestedHitsList[hitNames[i]] = hits;
1679 }
1680
1681
1682 if(GFDEBUG_HIT)
1683 G4cout << " : " << hitNames[i] << " -> " << value
1684 << " [" << unit << "]" << G4endl;
1685 }
1686 }
1687 }
1688 } else {
1689 G4Exception("G4GMocrenFileSceneHandler::AddCompound(const G4VHit &)",
1690 "gMocren0014", FatalException, "Error");
1691 }
1692
1693 delete attval;
1694 }
1695
1696}
@ FatalException
double G4double
Definition: G4Types.hh:64
bool G4bool
Definition: G4Types.hh:67
virtual std::vector< G4String > getHitNames()
virtual std::vector< G4AttValue > * CreateAttValues() const
Definition: G4VHit.hh:67
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

◆ AddCompound() [4/4]

void G4GMocrenFileSceneHandler::AddCompound ( const G4VTrajectory traj)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1558 of file G4GMocrenFileSceneHandler.cc.

1558 {
1559
1560 kbModelingTrajectory = true;
1561
1563
1564 if(GFDEBUG_TRK) {
1565 G4cout << " ::AddCompound(const G4VTrajectory&) >>>>>>>>> " << G4endl;
1566 G4TrajectoriesModel * pTrModel = dynamic_cast<G4TrajectoriesModel*>(fpModel);
1567 if (!pTrModel) {
1569 ("G4VSceneHandler::AddCompound(const G4VTrajectory&)",
1570 "gMocren0013", FatalException, "Not a G4TrajectoriesModel.");
1571 } else {
1572 traj.DrawTrajectory(pTrModel->GetDrawingMode());
1573
1574 const G4VTrajectory * trj = pTrModel->GetCurrentTrajectory();
1575 G4cout << "------ track" << G4endl;
1576 G4cout << " name: " << trj->GetParticleName() << G4endl;
1577 G4cout << " id: " << trj->GetTrackID() << G4endl;
1578 G4cout << " charge: " << trj->GetCharge() << G4endl;
1579 G4cout << " momentum: " << trj->GetInitialMomentum() << G4endl;
1580
1581 G4int nPnt = trj->GetPointEntries();
1582 G4cout << " point: ";
1583 for(G4int i = 0; i < nPnt; i++) {
1584 G4cout << trj->GetPoint(i)->GetPosition() << ", ";
1585 }
1586 G4cout << G4endl;
1587 }
1588 G4cout << G4endl;
1589 }
1590
1591 kbModelingTrajectory = false;
1592}
const G4bool GFDEBUG_TRK
const G4VTrajectory * GetCurrentTrajectory() const
virtual const G4ThreeVector GetPosition() const =0
virtual G4VTrajectoryPoint * GetPoint(G4int i) const =0
virtual int GetPointEntries() const =0
virtual G4String GetParticleName() const =0
virtual G4int GetTrackID() const =0
virtual void DrawTrajectory(G4int i_mode=0) const
virtual G4ThreeVector GetInitialMomentum() const =0
virtual G4double GetCharge() const =0

◆ AddPrimitive() [1/8]

void G4GMocrenFileSceneHandler::AddPrimitive ( const G4Circle mark_circle)
virtual

Implements G4VSceneHandler.

Definition at line 659 of file G4GMocrenFileSceneHandler.cc.

660{
661 // to avoid a warning in the compile process
662 G4Circle dummycircle = mark_circle;
663
664 if (fProcessing2D) {
665 static G4bool warned = false;
666 if (!warned) {
667 warned = true;
669 ("G4GMocrenFileSceneHandler::AddPrimitive (const G4Circle&)",
670 "gMocren1003", JustWarning,
671 "2D circles not implemented. Ignored.");
672 }
673 return;
674 }
675
676 //-----
678 G4cout << "***** AddPrimitive( G4Circle )" << G4endl;
679
680 //----- Initialize IF NECESSARY
682
683
684} // G4GMocrenFileSceneHandler::AddPrimitive ( mark_circle )
@ JustWarning

◆ AddPrimitive() [2/8]

void G4GMocrenFileSceneHandler::AddPrimitive ( const G4NURBS nurb)
virtual

Implements G4VSceneHandler.

Definition at line 617 of file G4GMocrenFileSceneHandler.cc.

618{
619 //-----
621 G4cout << "***** AddPrimitive( G4NURBS )" << G4endl;
622
623 //----- Initialize if necessary
625
626}

◆ AddPrimitive() [3/8]

void G4GMocrenFileSceneHandler::AddPrimitive ( const G4Polyhedron p)
virtual

Implements G4VSceneHandler.

Definition at line 716 of file G4GMocrenFileSceneHandler.cc.

717{
718 //-----
720 G4cout << "***** AddPrimitive( G4Polyhedron )" << G4endl;
721
722
723 if (polyhedron.GetNoFacets() == 0) return;
724
725 if (fProcessing2D) {
726 static G4bool warned = false;
727 if (!warned) {
728 warned = true;
730 ("G4GMocrenFileSceneHandler::AddPrimitive (const G4Polyhedron&)",
731 "gMocren1005", JustWarning,
732 "2D polyhedra not implemented. Ignored.");
733 }
734 return;
735 }
736
737 //----- Initialize if necessary
739
740 //---------- (3) Facet block
741 for (G4int f = polyhedron.GetNoFacets(); f; f--){
742 G4bool notLastEdge = true;
743 G4int index = -1; // initialization
744 G4int edgeFlag = 1;
745 //G4int preedgeFlag = 1;
746 //G4int work[4], i = 0;
747 G4int i = 0;
748 do {
749 //preedgeFlag = edgeFlag;
750 notLastEdge = polyhedron.GetNextVertexIndex(index, edgeFlag);
751 //work[i++] = index;
752 i++;
753 }while (notLastEdge);
754 switch (i){
755 case 3:
756 //SendStrInt3(FR_FACET, work[0], work[1], work[2] );
757 break;
758 case 4:
759 //SendStrInt4(FR_FACET, work[0], work[1], work[2], work[3] );
760 break;
761 default:
763 G4cout <<
764 "ERROR G4GMocrenFileSceneHandler::AddPrimitive(G4Polyhedron)" << G4endl;
765 G4PhysicalVolumeModel* pPVModel =
766 dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
767 if (pPVModel)
769 G4cout << "Volume " << pPVModel->GetCurrentPV()->GetName() <<
770 ", Solid " << pPVModel->GetCurrentLV()->GetSolid()->GetName() <<
771 " (" << pPVModel->GetCurrentLV()->GetSolid()->GetEntityType();
772
774 G4cout <<
775 "\nG4Polyhedron facet with " << i << " edges" << G4endl;
776 }
777 }
778
779} // G4GMocrenFileSceneHandler::AddPrimitive (polyhedron)
G4VSolid * GetSolid() const
G4VPhysicalVolume * GetCurrentPV() const
G4LogicalVolume * GetCurrentLV() const
const G4String & GetName() const
G4String GetName() const
virtual G4GeometryType GetEntityType() const =0

◆ AddPrimitive() [4/8]

void G4GMocrenFileSceneHandler::AddPrimitive ( const G4Polyline line)
virtual

Implements G4VSceneHandler.

Definition at line 525 of file G4GMocrenFileSceneHandler.cc.

526{
528 G4cout << "***** AddPrimitive" << G4endl;
529
530 if (fProcessing2D) {
531 static G4bool warned = false;
532 if (!warned) {
533 warned = true;
535 ("G4GMocrenFileSceneHandler::AddPrimitive (const G4Polyline&)",
536 "gMocren1001", JustWarning,
537 "2D polylines not implemented. Ignored.");
538 }
539 return;
540 }
541
542 //----- Initialize if necessary
544
545 static G4int numTrajectories = 0;
546 if(numTrajectories >= MAX_NUM_TRAJECTORIES) return;
547
548 // draw trajectories
549 if(kbModelingTrajectory) {
550
551 G4TrajectoriesModel * pTrModel = dynamic_cast<G4TrajectoriesModel*>(fpModel);
552 if (!pTrModel) {
554 ("G4VSceneHandler::AddCompound(const G4Polyline&)",
555 "gMocren0002", FatalException, "Not a G4TrajectoriesModel.");
556 }
557
558 G4ThreeVector trans;
560 trans = kVolumeTrans3D.getTranslation();
561 rot = kVolumeTrans3D.getRotation().inverse();
562
563 if(GFDEBUG_TRK) G4cout << " trajectory points : " << G4endl;
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++) {
569 G4ThreeVector prePts(preitr->x(), preitr->y(), preitr->z());
570 prePts -= trans;
571 prePts.transform(rot);
572 G4ThreeVector postPts(postitr->x(), postitr->y(), postitr->z());
573 postPts -= trans;
574 postPts.transform(rot);
575 G4float * stepPts = new G4float[6];
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);
583
584 if(GFDEBUG_TRK) {
585 G4cout << " ("
586 << stepPts[0] << ", "
587 << stepPts[1] << ", "
588 << stepPts[2] << ") - ("
589 << stepPts[3] << ", "
590 << stepPts[4] << ", "
591 << stepPts[5] << ")" << G4endl;
592 }
593 }
594
595 const G4VisAttributes * att = polyline.GetVisAttributes();
596 G4Color color = att->GetColor();
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);
601 if(GFDEBUG_TRK) {
602 G4cout << " color : ["
603 << color.GetRed() << ", "
604 << color.GetGreen() << ", "
605 << color.GetBlue() << "]" << G4endl;
606 }
607
608 kgMocrenIO->addTrack(trajectory, trkcolor);
609
610 numTrajectories++;
611 }
612
613} // G4GMocrenFileSceneHandler::AddPrimitive (polyline)
const G4int MAX_NUM_TRAJECTORIES
float G4float
Definition: G4Types.hh:65
double x() const
Hep3Vector & transform(const HepRotation &)
Definition: ThreeVectorR.cc:24
HepRotation inverse() const
G4double GetBlue() const
Definition: G4Colour.hh:140
G4double GetRed() const
Definition: G4Colour.hh:138
G4double GetGreen() const
Definition: G4Colour.hh:139
void addTrack(float *_tracks)
const G4Color & GetColor() const
CLHEP::HepRotation getRotation() const
CLHEP::Hep3Vector getTranslation() const

◆ AddPrimitive() [5/8]

void G4GMocrenFileSceneHandler::AddPrimitive ( const G4Polymarker polymarker)
inlinevirtual

Reimplemented from G4VSceneHandler.

Definition at line 76 of file G4GMocrenFileSceneHandler.hh.

77 { G4VSceneHandler::AddPrimitive (polymarker); }
virtual void AddPrimitive(const G4Polyline &)=0

◆ AddPrimitive() [6/8]

void G4GMocrenFileSceneHandler::AddPrimitive ( const G4Scale scale)
inlinevirtual

Reimplemented from G4VSceneHandler.

Definition at line 78 of file G4GMocrenFileSceneHandler.hh.

◆ AddPrimitive() [7/8]

void G4GMocrenFileSceneHandler::AddPrimitive ( const G4Square mark_square)
virtual

Implements G4VSceneHandler.

Definition at line 688 of file G4GMocrenFileSceneHandler.cc.

689{
690 // to avoid a warning in the compile process
691 G4Square dummysquare = mark_square;
692
693 if (fProcessing2D) {
694 static G4bool warned = false;
695 if (!warned) {
696 warned = true;
698 ("G4GMocrenFileSceneHandler::AddPrimitive (const G4Square&)",
699 "gMocren1004", JustWarning,
700 "2D squares not implemented. Ignored.");
701 }
702 return;
703 }
704
705 //-----
707 G4cout << "***** AddPrimitive( G4Square )" << G4endl;
708
709 //----- Initialize if necessary
711
712} // G4GMocrenFileSceneHandler::AddPrimitive ( mark_square )

◆ AddPrimitive() [8/8]

void G4GMocrenFileSceneHandler::AddPrimitive ( const G4Text text)
virtual

Implements G4VSceneHandler.

Definition at line 631 of file G4GMocrenFileSceneHandler.cc.

632{
633 if (fProcessing2D) {
634 static G4bool warned = false;
635 if (!warned) {
636 warned = true;
638 ("G4GMocrenFileSceneHandler::AddPrimitive (const G4Text&)",
639 "gMocren1002", JustWarning,
640 "2D text not implemented. Ignored.");
641 }
642 return;
643 }
644
645 // to avoid a warning in the compile process
646 G4Text dummytext = text;
647
648 //-----
650 G4cout << "***** AddPrimitive( G4Text )" << G4endl;
651
652 //----- Initialize IF NECESSARY
654
655} // G4GMocrenFileSceneHandler::AddPrimitive ( text )
Definition: G4Text.hh:73

◆ AddSolid() [1/11]

void G4GMocrenFileSceneHandler::AddSolid ( const G4Box box)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 835 of file G4GMocrenFileSceneHandler.cc.

836{
838 G4cout << "***** AddSolid ( box )" << G4endl;
839
840 if(GFDEBUG_DET > 0)
841 G4cout << "G4GMocrenFileSceneHandler::AddSolid(const G4Box&) : "
842 << box.GetName() << G4endl;
843
844 //----- skip drawing invisible primitive
845 if( !IsVisible() ) { return ; }
846
847 //----- Initialize if necessary
849
850
851 //--
852 if(GFDEBUG_DET > 1) {
853 G4cout << "-------" << G4endl;
854 G4cout << " " << box.GetName() << G4endl;
855 G4Polyhedron * poly = box.CreatePolyhedron();
857 //G4int nv = poly->GetNoVertices();
858 G4Point3D v1, v2;
859 G4int next;
860 //while(1) { // next flag isn't functional.
861 for(G4int i = 0; i < 12; i++) { // # of edges is 12.
862 poly->GetNextEdge(v1, v2, next);
863 if(next == 0) break;
864 G4cout << " (" << v1.x() << ", "
865 << v1.y() << ", "
866 << v1.z() << ") - ("
867 << v2.x() << ", "
868 << v2.y() << ", "
869 << v2.z() << ") [" << next << "]"
870 << G4endl;
871 }
872 delete poly;
873 }
874
875
876 // the volume name set by /vis/gMocren/setVolumeName
877 G4String volName = kMessenger.getVolumeName();
878
879 if(kFlagParameterization != 2) {
881 if(pScrMan) {
882 G4ScoringBox * pScBox = dynamic_cast<G4ScoringBox*>(pScrMan->FindMesh(volName));
883 G4bool bMesh = false;
884 if(pScBox != NULL) bMesh = true;
885 if(bMesh) kFlagParameterization = 2;
886 if(GFDEBUG_DET > 0) G4cout << " G4ScoringManager::FindMesh() : "
887 << volName << " - " << bMesh << G4endl;
888 }
889 }
890
891 const G4VModel* pv_model = GetModel();
892 if (!pv_model) { return ; }
893 G4PhysicalVolumeModel* pPVModel =
894 dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
895 if (!pPVModel) { return ; }
896
897
898 //-- debug information
899 if(GFDEBUG_DET > 0) {
900 G4Material * mat = pPVModel->GetCurrentMaterial();
901 G4String name = mat->GetName();
902 G4double dens = mat->GetDensity()/(g/cm3);
903 G4int copyNo = pPVModel->GetCurrentPV()->GetCopyNo();
904 G4int depth = pPVModel->GetCurrentDepth();
905 G4cout << " copy no.: " << copyNo << G4endl;
906 G4cout << " depth : " << depth << G4endl;
907 G4cout << " density : " << dens << " [g/cm3]" << G4endl;
908 G4cout << " location: " << pPVModel->GetCurrentPV()->GetObjectTranslation() << G4endl;
909 G4cout << " Multiplicity : " << pPVModel->GetCurrentPV()->GetMultiplicity() << G4endl;
910 G4cout << " Is replicated? : " << pPVModel->GetCurrentPV()->IsReplicated() << G4endl;
911 G4cout << " Is parameterised? : " << pPVModel->GetCurrentPV()->IsParameterised() << G4endl;
912 G4cout << " top phys. vol. name : " << pPVModel->GetTopPhysicalVolume()->GetName() << G4endl;
913 }
914
915 //-- check the parameterised volume
916 if(box.GetName() == volName) {
917
918 kVolumeTrans3D = fObjectTransformation;
919 // coordination system correction for gMocren
920 G4ThreeVector raxis(1., 0., 0.), dummy(0.,0.,0.);
921 G4RotationMatrix rot(raxis, pi*rad);
922 G4Transform3D trot(rot, dummy);
923 if(GFDEBUG_DET) {
924 G4ThreeVector trans1 = kVolumeTrans3D.getTranslation();
925 G4RotationMatrix rot1 = kVolumeTrans3D.getRotation().inverse();
926 G4cout << "kVolumeTrans3D: " << trans1 << G4endl << rot1 << G4endl;
927 }
928 kVolumeTrans3D = kVolumeTrans3D*trot;
929 if(GFDEBUG_DET) G4cout << " Parameterised volume : " << box.GetName() << G4endl;
930
931
932
933 //
934 G4VPhysicalVolume * pv[3] = {0,0,0};
935 pv[0] = pPVModel->GetCurrentPV()->GetLogicalVolume()->GetDaughter(0);
936 if(!pv[0]) {
937 G4Exception("G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
938 "gMocren0003", FatalException, "Unexpected volume.");
939 }
940 G4int dirAxis[3] = {-1,-1,-1};
941 G4int nDaughters[3] = {0,0,0};
942
943 EAxis axis; G4int nReplicas; G4double width; G4double offset; G4bool consuming;
944 pv[0]->GetReplicationData(axis, nReplicas, width, offset, consuming);
945 nDaughters[0] = nReplicas;
946 switch(axis) {
947 case kXAxis: dirAxis[0] = 0; break;
948 case kYAxis: dirAxis[0] = 1; break;
949 case kZAxis: dirAxis[0] = 2; break;
950 default:
951 G4Exception("G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
952 "gMocren0004", FatalException, "Error.");
953 }
954 kNestedVolumeNames.push_back(pv[0]->GetName());
955 if(GFDEBUG_DET)
956 G4cout << " daughter name : " << pv[0]->GetName()
957 << " # : " << nDaughters[0] << G4endl;
958
959 //
960 if(GFDEBUG_DET) {
961 if(pv[0]->GetLogicalVolume()->GetNoDaughters()) {
962 G4cout << "# of daughters : "
963 << pv[0]->GetLogicalVolume()->GetNoDaughters() << G4endl;
964 } else {
965 //G4Exception("G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
966 // "gMocren0005", FatalException, "Error.");
967 }
968 }
969
970 // check whether nested or regular parameterization
971 if(GFDEBUG_DET) G4cout << "# of daughters : "
972 << pv[0]->GetLogicalVolume()->GetNoDaughters() << G4endl;
973 if(pv[0]->GetLogicalVolume()->GetNoDaughters() == 0) {
974 kFlagParameterization = 1;
975 //G4Exception("G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
976 // "gMocren0006", FatalException, "Error.");
977 }
978
979 if(kFlagParameterization == 0) {
980
981 pv[1] = pv[0]->GetLogicalVolume()->GetDaughter(0);
982 if(pv[1]) {
983 pv[1]->GetReplicationData(axis, nReplicas, width, offset, consuming);
984 nDaughters[1] = nReplicas;
985 switch(axis) {
986 case kXAxis: dirAxis[1] = 0; break;
987 case kYAxis: dirAxis[1] = 1; break;
988 case kZAxis: dirAxis[1] = 2; break;
989 default:
990 G4Exception("G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
991 "gMocren0007", FatalException, "Error.");
992 }
993 kNestedVolumeNames.push_back(pv[1]->GetName());
994 if(GFDEBUG_DET)
995 G4cout << " sub-daughter name : " << pv[1]->GetName()
996 << " # : " << nDaughters[1]<< G4endl;
997
998 //
999 pv[2] = pv[1]->GetLogicalVolume()->GetDaughter(0);
1000 if(pv[2]) {
1001 nDaughters[2] = pv[2]->GetMultiplicity();
1002 kNestedVolumeNames.push_back(pv[2]->GetName());
1003 if(GFDEBUG_DET)
1004 G4cout << " sub-sub-daughter name : " << pv[2]->GetName()
1005 << " # : " << nDaughters[2] << G4endl;
1006
1007 if(nDaughters[2] > 1) {
1008 G4VNestedParameterisation * nestPara
1009 = dynamic_cast<G4VNestedParameterisation*>(pv[2]->GetParameterisation());
1010 if(nestPara == NULL)
1011 G4Exception("G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
1012 "gMocren0008", FatalException, "Non-nested parameterisation");
1013
1014 nestPara->ComputeTransformation(0, pv[2]);
1015 G4ThreeVector trans0 = pv[2]->GetObjectTranslation();
1016 nestPara->ComputeTransformation(1, pv[2]);
1017 G4ThreeVector trans1 = pv[2]->GetObjectTranslation();
1018 G4ThreeVector diff(trans0 - trans1);
1019 if(GFDEBUG_DET)
1020 G4cout << trans0 << " - " << trans1 << " - " << diff << G4endl;
1021
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;
1025 else
1026 G4Exception("G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
1027 "gMocren0009", FatalException, "Unexpected nested parameterisation");
1028 }
1029 }
1030 }
1031
1032 for(G4int i = 0; i < 3; i++) {
1033 kNestedVolumeDimension[i] = nDaughters[i];
1034 //kNestedVolumeDimension[i] = nDaughters[dirAxis[i]];
1035 kNestedVolumeDirAxis[i] = dirAxis[i];
1036 }
1037 //G4cout << "@@@@@@@@@ "
1038 // << dirAxis[0] << ", " << dirAxis[1] << ", " << dirAxis[2] << G4endl;
1039
1040 // get densities
1041 G4VNestedParameterisation * nestPara
1042 = dynamic_cast<G4VNestedParameterisation*>(pv[2]->GetParameterisation());
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++) {
1048
1049 G4GMocrenTouchable * touch = new G4GMocrenTouchable(n1, n0);
1050 if(GFDEBUG_DET)
1051 G4cout << " retrieve volume : copy # : " << n0
1052 << ", " << n1 << ", " << n2 << G4endl;
1053 G4Material * mat = nestPara->ComputeMaterial(pv[2], n2, touch);
1054 delete touch;
1055 G4double dens = mat->GetDensity()/(g/cm3);
1056
1057 if(GFDEBUG_DET)
1058 G4cout << " density :" << dens << " [g/cm3]" << G4endl;
1059
1060 G4Box tbox(box);
1061 nestPara->ComputeDimensions(tbox, n2, pv[2]);
1062 xyz[0] = tbox.GetXHalfLength()/mm;
1063 xyz[1] = tbox.GetYHalfLength()/mm;
1064 xyz[2] = tbox.GetZHalfLength()/mm;
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 )",
1069 "gMocren0010", FatalException, "Unsupported parameterisation");
1070 }
1071 }
1072 if(GFDEBUG_DET)
1073 G4cout << " size : " << tbox.GetXHalfLength()/mm << " x "
1074 << tbox.GetYHalfLength()/mm << " x "
1075 << tbox.GetZHalfLength()/mm << " [mm3]" << G4endl;
1076
1077 G4int idx[3];
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;
1083 if(GFDEBUG_DET)
1084 G4cout << " index: " << idx[0] << ", " << idx[1] << ", " << idx[2]
1085 << " density: " << dens << G4endl;
1086
1087 for(G4int i = 0; i < 3; i++) prexyz[i] = xyz[i];
1088 }
1089 }
1090 }
1091
1092 kVolumeSize.set(box.GetXHalfLength()*2/mm,
1093 box.GetYHalfLength()*2/mm,
1094 box.GetZHalfLength()*2/mm);
1095 // mesh size
1096 if(!kbSetModalityVoxelSize) {
1097 G4float spacing[3] = {static_cast<G4float>(2*xyz[0]),
1098 static_cast<G4float>(2*xyz[1]),
1099 static_cast<G4float>(2*xyz[2])};
1100 kgMocrenIO->setVoxelSpacing(spacing);
1101 kVoxelDimension.set(spacing[0], spacing[1], spacing[2]);
1102 kbSetModalityVoxelSize = true;
1103 }
1104
1105 } else {
1106 if(GFDEBUG_DET)
1107 G4cout << pv[2]->GetName() << G4endl;
1108 G4Exception("G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
1109 "gMocren0011", FatalException, "Non-nested parameterisation");
1110 }
1111
1112
1113
1114 //-- debug
1115 if(GFDEBUG_DET > 1) {
1116 if(pPVModel->GetCurrentPV()->IsParameterised()) {
1118 G4cout << " Is nested parameterisation? : " << para->IsNested() << G4endl;
1119
1120
1121 G4int npvp = pPVModel->GetDrawnPVPath().size();
1122 G4cout << " physical volume node id : "
1123 << "size: " << npvp << ", PV name: ";
1124 for(G4int i = 0; i < npvp; i++) {
1125 G4cout << pPVModel->GetDrawnPVPath()[i].GetPhysicalVolume()->GetName()
1126 << " [param:"
1127 << pPVModel->GetDrawnPVPath()[i].GetPhysicalVolume()->IsParameterised()
1128 << ",rep:"
1129 << pPVModel->GetDrawnPVPath()[i].GetPhysicalVolume()->IsReplicated();
1130 if(pPVModel->GetDrawnPVPath()[i].GetPhysicalVolume()->GetParameterisation()) {
1131 G4cout << ",nest:"
1132 << pPVModel->GetDrawnPVPath()[i].GetPhysicalVolume()->GetParameterisation()->IsNested();
1133 }
1134 G4cout << ",copyno:"
1135 << pPVModel->GetDrawnPVPath()[i].GetPhysicalVolume()->GetCopyNo();
1136 G4cout << "] - ";
1137 }
1138 G4cout << G4endl;
1139
1140
1141 pPVModel->GetCurrentPV()->GetReplicationData(axis, nReplicas, width, offset, consuming);
1142 G4cout << " # replicas : " << nReplicas << G4endl;
1143 G4double pareDims[3] = {0.,0.,0.};
1144 G4Box * pbox = dynamic_cast<G4Box *>(pPVModel->GetDrawnPVPath()[npvp-2].GetPhysicalVolume()->GetLogicalVolume()->GetSolid());
1145 if(pbox) {
1146 pareDims[0] = 2.*pbox->GetXHalfLength()*mm;
1147 pareDims[1] = 2.*pbox->GetYHalfLength()*mm;
1148 pareDims[2] = 2.*pbox->GetZHalfLength()*mm;
1149 G4cout << " mother size ["
1150 << pPVModel->GetDrawnPVPath()[npvp-2].GetPhysicalVolume()->GetName()
1151 << "] : "
1152 << pareDims[0] << " x "
1153 << pareDims[1] << " x "
1154 << pareDims[2] << " [mm3]"
1155 << G4endl;
1156 }
1157 G4double paraDims[3];
1158 G4Box * boxP = dynamic_cast<G4Box *>(pPVModel->GetDrawnPVPath()[npvp-1].GetPhysicalVolume()->GetLogicalVolume()->GetSolid());
1159 if(boxP) {
1160 paraDims[0] = 2.*boxP->GetXHalfLength()*mm;
1161 paraDims[1] = 2.*boxP->GetYHalfLength()*mm;
1162 paraDims[2] = 2.*boxP->GetZHalfLength()*mm;
1163 G4cout << " parameterised volume? ["
1164 << pPVModel->GetDrawnPVPath()[npvp-1].GetPhysicalVolume()->GetName()
1165 << "] : "
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 "
1171 << G4int(pareDims[2]/paraDims[2]) << G4endl;
1172 } else {
1173 G4cout << pPVModel->GetDrawnPVPath()[npvp-2].GetPhysicalVolume()->GetName()
1174 << " isn't a G4Box." << G4endl;
1175 }
1176 }
1177 }
1178
1179
1180 } else if(kFlagParameterization == 1) { // G4PhantomParameterisation based geom. construnction
1181
1182 // get the dimension of the parameterized patient geometry
1183 G4PhantomParameterisation * phantomPara
1184 = dynamic_cast<G4PhantomParameterisation*>(pv[0]->GetParameterisation());
1185 if(phantomPara == NULL) {
1186 G4Exception("G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
1187 "gMocren0012", FatalException, "no G4PhantomParameterisation");
1188 } else {
1189 ;
1190 }
1191
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;
1198
1199 // get densities of the parameterized patient geometry
1200 G4int nX = kNestedVolumeDimension[0];
1201 G4int nXY = kNestedVolumeDimension[0]*kNestedVolumeDimension[1];
1202
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++) {
1206
1207 G4int repNo = n0 + n1*nX + n2*nXY;
1208 G4Material * mat = phantomPara->ComputeMaterial(repNo, pv[0]);
1209 G4double dens = mat->GetDensity()/(g/cm3);
1210
1211
1212 G4int idx[3];
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;
1218
1219 if(GFDEBUG_DET)
1220 G4cout << " index: " << idx[0] << ", " << idx[1] << ", " << idx[2]
1221 << " density: " << dens << G4endl;
1222
1223 }
1224 }
1225 }
1226
1227 kVolumeSize.set(box.GetXHalfLength()*2/mm,
1228 box.GetYHalfLength()*2/mm,
1229 box.GetZHalfLength()*2/mm);
1230
1231 // mesh size
1232 if(!kbSetModalityVoxelSize) {
1233 G4float spacing[3] = {static_cast<G4float>(2*phantomPara->GetVoxelHalfX()),
1234 static_cast<G4float>(2*phantomPara->GetVoxelHalfY()),
1235 static_cast<G4float>(2*phantomPara->GetVoxelHalfZ())};
1236 kgMocrenIO->setVoxelSpacing(spacing);
1237 kVoxelDimension.set(spacing[0], spacing[1], spacing[2]);
1238 kbSetModalityVoxelSize = true;
1239 }
1240 }
1241
1242 } // if(box.GetName() == volName)
1243
1244
1245 // processing geometry construction based on the interactive PS
1246 if(!kFLagProcessedInteractiveScorer) {
1247
1248
1249 // get the dimension of the geometry defined in G4VScoringMesh
1251 if(!pScrMan) return;
1252 G4ScoringBox * scoringBox
1253 = dynamic_cast<G4ScoringBox*>(pScrMan->FindMesh(volName));
1254 if(scoringBox == NULL) return;
1255
1256
1257 G4int nVoxels[3];
1258 scoringBox->GetNumberOfSegments(nVoxels);
1259 // this order depends on the G4ScoringBox
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;
1266
1267 // get densities of the parameterized patient geometry
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++) {
1271
1272 G4double dens = 0.*(g/cm3);
1273
1274 G4int idx[3];
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;
1280
1281 }
1282 }
1283 }
1284
1285 G4ThreeVector boxSize = scoringBox->GetSize();
1286 if(GFDEBUG_DET > 1) {
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 "
1294 << nVoxels[2] << G4endl;
1295 }
1296 kVolumeSize.set(boxSize.x()*2,
1297 boxSize.y()*2,
1298 boxSize.z()*2);
1299
1300 // mesh size
1301 if(!kbSetModalityVoxelSize) {
1302 G4float spacing[3] = {static_cast<G4float>(boxSize.x()*2/nVoxels[0]),
1303 static_cast<G4float>(boxSize.y()*2/nVoxels[1]),
1304 static_cast<G4float>(boxSize.z()*2/nVoxels[2])};
1305
1306 kgMocrenIO->setVoxelSpacing(spacing);
1307 kVoxelDimension.set(spacing[0], spacing[1], spacing[2]);
1308 kbSetModalityVoxelSize = true;
1309
1310 }
1311
1312
1313 kVolumeTrans3D = fObjectTransformation;
1314
1315 // translation for the scoring mesh
1316 G4ThreeVector sbth = scoringBox->GetTranslation();
1317 G4Translate3D sbtranslate(sbth);
1318 kVolumeTrans3D = kVolumeTrans3D*sbtranslate;
1319
1320 // rotation matrix for the scoring mesh
1321 G4RotationMatrix sbrm;
1322 sbrm = scoringBox->GetRotationMatrix();
1323 if(!sbrm.isIdentity()) {
1324 G4ThreeVector sbdummy(0.,0.,0.);
1325 G4Transform3D sbrotate(sbrm.inverse(), sbdummy);
1326 kVolumeTrans3D = kVolumeTrans3D*sbrotate;
1327 }
1328
1329
1330 // coordination system correction for gMocren
1331 G4ThreeVector raxisY(0., 1., 0.), dummyY(0.,0.,0.);
1332 G4RotationMatrix rotY(raxisY, pi*rad);
1333 G4Transform3D trotY(rotY, dummyY);
1334 G4ThreeVector raxisZ(0., 0., 1.), dummyZ(0.,0.,0.);
1335 G4RotationMatrix rotZ(raxisZ, pi*rad);
1336 G4Transform3D trotZ(rotZ, dummyZ);
1337
1338 kVolumeTrans3D = kVolumeTrans3D*trotY*trotZ;
1339
1340
1341 //
1342 kFLagProcessedInteractiveScorer = true;
1343 }
1344
1345
1346
1347 //-- add detectors
1348 G4bool bAddDet = true;
1349 if(!kMessenger.getDrawVolumeGrid()) {
1350
1351 if(kFlagParameterization == 0) { // nested parameterisation
1352
1353 if(volName == box.GetName()) {
1354 bAddDet = false;
1355 }
1356
1357 std::vector<G4String>::iterator itr = kNestedVolumeNames.begin();
1358 for(; itr != kNestedVolumeNames.end(); itr++) {
1359 if(*itr == box.GetName()) {
1360 bAddDet = false;
1361 break;
1362 }
1363 }
1364 } else if(kFlagParameterization == 1) { // phantom paramemterisation
1365
1366 if(volName != box.GetName()) {
1367 bAddDet = false;
1368 }
1369
1370 } else if(kFlagParameterization == 2) { // interactive primitive scorer
1371 ;
1372 }
1373
1374 }
1375 if(bAddDet) AddDetector(box);
1376
1377
1378} // void G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )
const G4int GFDEBUG_DET
double z() const
double y() const
void set(double x, double y, double z)
bool isIdentity() const
Definition: Rotation.cc:172
Definition: G4Box.hh:55
G4double GetYHalfLength() const
G4double GetZHalfLength() const
G4double GetXHalfLength() const
G4Polyhedron * CreatePolyhedron() const
Definition: G4Box.cc:1052
void setVoxelSpacing(float _spacing[3])
virtual G4bool getDrawVolumeGrid()
virtual G4String getVolumeName()
G4int GetNoDaughters() const
G4VPhysicalVolume * GetDaughter(const G4int i) const
G4double GetDensity() const
Definition: G4Material.hh:179
const G4String & GetName() const
Definition: G4Material.hh:177
size_t GetNoVoxelY() const
G4double GetVoxelHalfZ() const
G4double GetVoxelHalfY() const
virtual G4Material * ComputeMaterial(const G4int repNo, G4VPhysicalVolume *currentVol, const G4VTouchable *parentTouch=0)
G4double GetVoxelHalfX() const
size_t GetNoVoxelZ() const
size_t GetNoVoxelX() const
const std::vector< G4PhysicalVolumeNodeID > & GetDrawnPVPath() const
G4VPhysicalVolume * GetTopPhysicalVolume() const
G4Material * GetCurrentMaterial() const
G4VScoringMesh * FindMesh(const G4String &)
static G4ScoringManager * GetScoringManager()
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
virtual void ComputeTransformation(const G4int no, G4VPhysicalVolume *currentPV) const =0
virtual G4Material * ComputeMaterial(G4VPhysicalVolume *currentVol, const G4int repNo, const G4VTouchable *parentTouch=0)=0
virtual G4bool IsNested() const
virtual G4bool IsReplicated() const =0
G4LogicalVolume * GetLogicalVolume() const
virtual G4int GetMultiplicity() const
virtual void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const =0
virtual G4int GetCopyNo() const =0
virtual G4VPVParameterisation * GetParameterisation() const =0
G4ThreeVector GetObjectTranslation() const
virtual G4bool IsParameterised() const =0
G4VModel * GetModel() const
G4Transform3D fObjectTransformation
G4ThreeVector GetTranslation() const
G4ThreeVector GetSize() const
void GetNumberOfSegments(G4int nSegment[3])
G4RotationMatrix GetRotationMatrix() const
HepPolyhedron & Transform(const G4Transform3D &t)
G4bool GetNextEdge(G4Point3D &p1, G4Point3D &p2, G4int &edgeFlag) const
EAxis
Definition: geomdefs.hh:54
@ kYAxis
Definition: geomdefs.hh:54
@ kXAxis
Definition: geomdefs.hh:54
@ kZAxis
Definition: geomdefs.hh:54

◆ AddSolid() [2/11]

void G4GMocrenFileSceneHandler::AddSolid ( const G4Cons cons)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1426 of file G4GMocrenFileSceneHandler.cc.

1427{
1429 G4cout << "***** AddSolid ( cons )" << G4endl;
1430
1431 //----- skip drawing invisible primitive
1432 if( !IsVisible() ) { return ; }
1433
1434 //----- Initialize if necessary
1436
1437 //
1438 AddDetector(cons);
1439
1440}// G4GMocrenFileSceneHandler::AddSolid( cons )

◆ AddSolid() [3/11]

void G4GMocrenFileSceneHandler::AddSolid ( const G4Para para)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1481 of file G4GMocrenFileSceneHandler.cc.

1482{
1484 G4cout << "***** AddSolid ( para )" << G4endl;
1485
1486 //----- skip drawing invisible primitive
1487 if( !IsVisible() ) { return ; }
1488
1489 //----- Initialize if necessary
1491
1492 //
1493 AddDetector(para);
1494
1495} // G4GMocrenFileSceneHandler::AddSolid ( para )

◆ AddSolid() [4/11]

void G4GMocrenFileSceneHandler::AddSolid ( const G4Polycone polycone)
inlinevirtual

Reimplemented from G4VSceneHandler.

Definition at line 95 of file G4GMocrenFileSceneHandler.hh.

95 {
97 }
virtual void AddSolid(const G4Box &)

◆ AddSolid() [5/11]

void G4GMocrenFileSceneHandler::AddSolid ( const G4Polyhedra polyhedra)
inlinevirtual

Reimplemented from G4VSceneHandler.

Definition at line 98 of file G4GMocrenFileSceneHandler.hh.

98 {
99 G4VSceneHandler::AddSolid (polyhedra);
100 }

◆ AddSolid() [6/11]

void G4GMocrenFileSceneHandler::AddSolid ( const G4Sphere sphere)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1463 of file G4GMocrenFileSceneHandler.cc.

1464{
1466 G4cout << "***** AddSolid ( sphere )" << G4endl;
1467
1468 //----- skip drawing invisible primitive
1469 if( !IsVisible() ) { return ; }
1470
1471 //----- Initialize if necessary
1473
1474 //
1475 AddDetector(sphere);
1476
1477} // G4GMocrenFileSceneHandler::AddSolid ( sphere )

◆ AddSolid() [7/11]

void G4GMocrenFileSceneHandler::AddSolid ( const G4Torus torus)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1518 of file G4GMocrenFileSceneHandler.cc.

1519{
1521 G4cout << "***** AddSolid ( torus )" << G4endl;
1522
1523 //----- skip drawing invisible primitive
1524 if( !IsVisible() ) { return ; }
1525
1526 //----- Initialize if necessary
1528
1529 //
1530 AddDetector(torus);
1531
1532} // void G4GMocrenFileSceneHandler::AddSolid( const G4Torus& )

◆ AddSolid() [8/11]

void G4GMocrenFileSceneHandler::AddSolid ( const G4Trap trap)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1499 of file G4GMocrenFileSceneHandler.cc.

1500{
1502 G4cout << "***** AddSolid ( trap )" << G4endl;
1503
1504 //----- skip drawing invisible primitive
1505 if( !IsVisible() ) { return ; }
1506
1507 //----- Initialize if necessary
1509
1510 //
1511 AddDetector(trap);
1512
1513} // G4GMocrenFileSceneHandler::AddSolid (const G4Trap& trap)

◆ AddSolid() [9/11]

void G4GMocrenFileSceneHandler::AddSolid ( const G4Trd trd)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1444 of file G4GMocrenFileSceneHandler.cc.

1445{
1447 G4cout << "***** AddSolid ( trd )" << G4endl;
1448
1449
1450 //----- skip drawing invisible primitive
1451 if( !IsVisible() ) { return ; }
1452
1453 //----- Initialize if necessary
1455
1456 //
1457 AddDetector(trd);
1458
1459} // G4GMocrenFileSceneHandler::AddSolid ( trd )

◆ AddSolid() [10/11]

void G4GMocrenFileSceneHandler::AddSolid ( const G4Tubs tubs)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1383 of file G4GMocrenFileSceneHandler.cc.

1384{
1386 G4cout << "***** AddSolid ( tubes )" << G4endl;
1387
1388 //----- skip drawing invisible primitive
1389 if( !IsVisible() ) { return ; }
1390
1391 //----- Initialize if necessary
1393
1394 //
1395 AddDetector(tubes);
1396
1397
1398 // for a debug
1399 if(GFDEBUG_DET > 0) {
1400 G4cout << "-------" << G4endl;
1401 G4cout << " " << tubes.GetName() << G4endl;
1402 G4Polyhedron * poly = tubes.CreatePolyhedron();
1403 G4int nv = poly->GetNoVertices();
1404 for(G4int i = 0; i < nv; i++) {
1405 G4cout << " (" << poly->GetVertex(i).x() << ", "
1406 << poly->GetVertex(i).y() << ", "
1407 << poly->GetVertex(i).z() << ")" << G4endl;
1408 }
1409 delete poly;
1410 }
1411
1412 const G4VModel* pv_model = GetModel();
1413 if (!pv_model) { return ; }
1414 G4PhysicalVolumeModel* pPVModel =
1415 dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
1416 if (!pPVModel) { return ; }
1417 G4Material * mat = pPVModel->GetCurrentMaterial();
1418 G4String name = mat->GetName();
1419
1420} // void G4GMocrenFileSceneHandler::AddSolid( const G4Tubs& )
G4Point3D GetVertex(G4int index) const
G4int GetNoVertices() const

◆ AddSolid() [11/11]

void G4GMocrenFileSceneHandler::AddSolid ( const G4VSolid solid)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1537 of file G4GMocrenFileSceneHandler.cc.

1538{
1539 //----- skip drawing invisible primitive
1540 if( !IsVisible() ) { return ; }
1541
1542 //----- Initialize if necessary
1544
1545 //
1546 AddDetector(solid);
1547
1548 //----- Send a primitive
1549 G4VSceneHandler::AddSolid( solid ) ;
1550
1551} //G4GMocrenFileSceneHandler::AddSolid ( const G4VSolid& )

◆ BeginModeling()

virtual void G4GMocrenFileSceneHandler::BeginModeling ( )
inlinevirtual

Reimplemented from G4VSceneHandler.

Definition at line 81 of file G4GMocrenFileSceneHandler.hh.

◆ BeginPrimitives()

void G4GMocrenFileSceneHandler::BeginPrimitives ( const G4Transform3D objectTransformation)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 810 of file G4GMocrenFileSceneHandler.cc.

811{
813 G4cout << "***** BeginPrimitives " << G4endl;
814
816
817 G4VSceneHandler::BeginPrimitives (objectTransformation);
818
819}
virtual void BeginPrimitives(const G4Transform3D &objectTransformation)

◆ BeginSavingGdd()

void G4GMocrenFileSceneHandler::BeginSavingGdd ( void  )

Definition at line 261 of file G4GMocrenFileSceneHandler.cc.

262{
264 G4cout << "***** BeginSavingGdd (called)" << G4endl;
265
266 if( !IsSavingGdd() ) {
267
269 G4cout << "***** (started) " ;
270 G4cout << "(open g4.gdd, ##)" << G4endl;
271 }
272
273 SetGddFileName() ; // result set to kGddFileName
274 kFlagSaving_g4_gdd = true;
275
276
278 short minmax[2];
279 minmax[0] = ctdens.GetMinCT();
280 minmax[1] = ctdens.GetMaxCT();
281 kgMocrenIO->setModalityImageMinMax(minmax);
282 std::vector<G4float> map;
283 G4float dens;
284 for(G4int i = minmax[0]; i <= minmax[1]; i++) {
285 dens = ctdens.GetDensity(i);
286 map.push_back(dens);
287 }
288 kgMocrenIO->setModalityImageDensityMap(map);
289
290 /*
291 G4String fname = "modality-map.dat";
292 std::ifstream ifile(fname);
293 if(ifile) {
294 short minmax[2];
295 ifile >> minmax[0] >> minmax[1];
296 kgMocrenIO->setModalityImageMinMax(minmax);
297 std::vector<G4float> map;
298 G4float dens;
299 for(G4int i = minmax[0]; i <= minmax[1]; i++) {
300 ifile >> dens;
301 map.push_back(dens);
302 }
303 kgMocrenIO->setModalityImageDensityMap(map);
304
305 } else {
306 G4cout << "cann't open the file : " << fname << G4endl;
307 }
308 */
309
310 // mesh size
311 //kMessenger.getNoVoxels(kModalitySize[0], kModalitySize[1], kModalitySize[2]);
312 //kgMocrenIO->setModalityImageSize(kModalitySize);
313
314 // initializations
315 //kgMocrenIO->clearModalityImage();
316 kgMocrenIO->clearDoseDistAll();
317 kgMocrenIO->clearROIAll();
318 kgMocrenIO->clearTracks();
319 kgMocrenIO->clearDetector();
320 std::vector<Detector>::iterator itr = kDetectors.begin();
321 for(; itr != kDetectors.end(); itr++) {
322 itr->clear();
323 }
324 kDetectors.clear();
325
326 kNestedHitsList.clear();
327 kNestedVolumeNames.clear();
328
329 }
330}
G4double GetDensity(G4int &_ct) const
void setModalityImageDensityMap(std::vector< float > &_map)
void clearDetector()
Definition: G4GMocrenIO.hh:451
void clearROIAll()
void setModalityImageMinMax(short _minmax[2])
void clearDoseDistAll()
void clearTracks()
Definition: G4GMocrenIO.hh:439

Referenced by GFBeginModeling().

◆ ClearTransientStore()

void G4GMocrenFileSceneHandler::ClearTransientStore ( )
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1795 of file G4GMocrenFileSceneHandler.cc.

1796{
1797 // This is typically called after an update and before drawing hits
1798 // of the next event. To simulate the clearing of "transients"
1799 // (hits, etc.) the detector is redrawn...
1800 if (fpViewer) {
1801 fpViewer -> SetView ();
1802 fpViewer -> ClearView ();
1803 fpViewer -> DrawView ();
1804 }
1805}
G4VViewer * fpViewer

◆ EndModeling()

virtual void G4GMocrenFileSceneHandler::EndModeling ( )
inlinevirtual

Reimplemented from G4VSceneHandler.

Definition at line 82 of file G4GMocrenFileSceneHandler.hh.

◆ EndPrimitives()

void G4GMocrenFileSceneHandler::EndPrimitives ( )
virtual

Reimplemented from G4VSceneHandler.

Definition at line 823 of file G4GMocrenFileSceneHandler.cc.

824{
826 G4cout << "***** EndPrimitives " << G4endl;
827
829}
virtual void EndPrimitives()

◆ EndSavingGdd()

void G4GMocrenFileSceneHandler::EndSavingGdd ( void  )

Definition at line 332 of file G4GMocrenFileSceneHandler.cc.

333{
335 G4cout << "***** EndSavingGdd (called)" << G4endl;
336
337 if(IsSavingGdd()) {
339 G4cout << "***** (started) (close "
340 << kGddFileName << ")" << G4endl;
341
342 if(kGddDest) kGddDest.close();
343 kFlagSaving_g4_gdd = false;
344
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;
351 }
352 // mesh size
353 kModalitySize[0] = xmax+1;
354 kModalitySize[1] = ymax+1;
355 kModalitySize[2] = zmax+1;
356 kgMocrenIO->setModalityImageSize(kModalitySize);
357 if(GFDEBUG) G4cout << "gMocren-file driver : modality size : "
358 << kModalitySize[0] << " x "
359 << kModalitySize[1] << " x "
360 << kModalitySize[2] << G4endl;
361
362 G4int nxy = kModalitySize[0]*kModalitySize[1];
363 //std::map<G4int, G4float>::iterator itr;
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++) {
368 //for(G4int x = kModalitySize[0]-1; x >= 0 ; x--) {
369 //G4int ixy = x + (kModalitySize[1]-y-1)*kModalitySize[0];
370
371 G4int ixy = x + y*kModalitySize[0];
372 Index3D idx(x,y,z);
373 itr = kNestedModality.find(idx);
374 if(itr != kNestedModality.end()) {
375
376 modality[ixy] = kgMocrenIO->convertDensityToHU(itr->second);
377 } else {
378 modality[ixy] = -1024;
379 }
380
381 }
382 }
383 kgMocrenIO->setModalityImage(modality);
384 }
385
386 //-- dose
387 size_t nhits = kNestedHitsList.size();
388 if(GFDEBUG) G4cout << "gMocren-file driver : # hits = " << nhits << G4endl;
389
390 std::map<Index3D, G4double>::iterator hitsItr;
391 std::map<G4String, std::map<Index3D, G4double> >::iterator hitsListItr = kNestedHitsList.begin();
392
393 for(G4int n = 0; hitsListItr != kNestedHitsList.end(); hitsListItr++, n++) {
394
395 kgMocrenIO->newDoseDist();
396 kgMocrenIO->setDoseDistName(hitsListItr->first, n);
397 kgMocrenIO->setDoseDistSize(kModalitySize, n);
398
399 G4double minmax[2] = {DBL_MAX, -DBL_MAX};
400 for(G4int z = 0 ; z < kModalitySize[2]; z++) {
401 G4double * values = new G4double[nxy];
402 for(G4int y = 0; y < kModalitySize[1]; y++) {
403 for(G4int x = 0; x < kModalitySize[0]; x++) {
404
405 G4int ixy = x + y*kModalitySize[0];
406 Index3D idx(x,y,z);
407 hitsItr = hitsListItr->second.find(idx);
408 if(hitsItr != hitsListItr->second.end()) {
409
410 values[ixy] = hitsItr->second;
411 } else {
412 values[ixy] = 0.;
413 }
414 if(values[ixy] < minmax[0]) minmax[0] = values[ixy];
415 if(values[ixy] > minmax[1]) minmax[1] = values[ixy];
416 }
417 }
418 kgMocrenIO->setDoseDist(values, n);
419 }
420 kgMocrenIO->setDoseDistMinMax(minmax, n);
421 G4double lower = 0.;
422 if(minmax[0] < 0) lower = minmax[0];
423 G4double scale = (minmax[1]-lower)/25000.;
424 kgMocrenIO->setDoseDistScale(scale, n);
425 G4String sunit("unit?"); //temporarily
426 kgMocrenIO->setDoseDistUnit(sunit, n);
427 }
428
429
430 //-- draw axes
431 if(false) {//true,false
432 G4ThreeVector trans;
434 trans = kVolumeTrans3D.getTranslation();
435 rot = kVolumeTrans3D.getRotation().inverse();
436 // x
437 std::vector<G4float *> tracks;
438 unsigned char colors[3];
439 G4float * trk = new G4float[6];
440 tracks.push_back(trk);
441
442 G4ThreeVector orig(0.,0.,0), xa(2000.,0.,0.), ya(0.,2000.,0.), za(0.,0.,2000.);
443 orig -= trans;
444 orig.transform(rot);
445 xa -= trans;
446 xa.transform(rot);
447 ya -= trans;
448 ya.transform(rot);
449 za -= trans;
450 za.transform(rot);
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);
455 // y
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);
459 // z
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);
463 }
464
465 //-- detector
466 ExtractDetector();
467
468
469 if(GFDEBUG_DET) G4cout << ">>>>>>>>>>>>>>>>>>>>>> (";
470 std::vector<G4float> transformObjects;
471 for(G4int i = 0; i < 3; i++) {
472 // need to check!!
473 transformObjects.push_back((kVolumeSize[i]/2. - kVoxelDimension[i]/2.));
474 if(GFDEBUG_DET) G4cout << transformObjects[i] << ", ";
475 }
476 if(GFDEBUG_DET) G4cout << ")" << G4endl;
477
478
479 kgMocrenIO->translateTracks(transformObjects);
480 kgMocrenIO->translateDetector(transformObjects);
481
482 // store
483 kgMocrenIO->storeData(kGddFileName);
484 }
485
486}
void setModalityImageSize(int _size[3])
void setDoseDistUnit(std::string &_unit, int _num=0)
short convertDensityToHU(float &_dens)
void setDoseDistMinMax(short _minmax[2], int _num=0)
void setDoseDistScale(double &_scale, int _num=0)
void translateDetector(std::vector< float > &_translate)
void setDoseDistName(std::string _name, int _num=0)
bool storeData(char *_filename)
Definition: G4GMocrenIO.cc:457
void setModalityImage(short *_image)
void setDoseDistSize(int _size[3], int _num=0)
void newDoseDist()
void setDoseDist(double *_image, int _num=0)
void translateTracks(std::vector< float > &_translateo)
#define DBL_MAX
Definition: templates.hh:83

Referenced by GFEndModeling().

◆ GetGddFileName()

const char * G4GMocrenFileSceneHandler::GetGddFileName ( )
inline

Definition at line 121 of file G4GMocrenFileSceneHandler.hh.

121{ return kGddFileName ; }

Referenced by G4GMocrenFileViewer::G4GMocrenFileViewer(), and G4GMocrenFileViewer::ShowView().

◆ GetSystem()

G4GMocrenFile & G4GMocrenFileSceneHandler::GetSystem ( )
inline

Definition at line 120 of file G4GMocrenFileSceneHandler.hh.

120{ return kSystem ; }

◆ GFBeginModeling()

void G4GMocrenFileSceneHandler::GFBeginModeling ( void  )

Definition at line 490 of file G4GMocrenFileSceneHandler.cc.

491{
493
494 if( !GFIsInModeling() ) {
495
496
498 G4cout << "***** G4GMocrenFileSceneHandler::GFBeginModeling (called & started)" << G4endl;
499
500 //----- Send saving command and heading comment
502
503 kFlagInModeling = true ;
504
505 // These models are entrusted to user commands /vis/scene/add/psHits or hits
506 //GetScene()->AddEndOfEventModel(new G4PSHitsModel());
507 //GetScene()->AddEndOfRunModel(new G4PSHitsModel());
508 //scene->AddEndOfEventModel(new G4HitsModel());
509 if(GFDEBUG_HIT) {
510 G4Scene * scene = GetScene();
511 std::vector<G4Scene::Model> vmodel = scene->GetEndOfEventModelList();
512 std::vector<G4Scene::Model>::iterator itr = vmodel.begin();
513 for(; itr != vmodel.end(); itr++) {
514 G4cout << " IIIIII model name: " << itr->fpModel->GetGlobalTag() << G4endl;
515 }
516 }
517
518 } // if
519}
const std::vector< Model > & GetEndOfEventModelList() const
G4Scene * GetScene() const

Referenced by AddPrimitive(), AddSolid(), BeginPrimitives(), G4GMocrenFileViewer::ClearView(), and G4GMocrenFileViewer::DrawView().

◆ GFEndModeling()

void G4GMocrenFileSceneHandler::GFEndModeling ( )

Definition at line 783 of file G4GMocrenFileSceneHandler.cc.

784{
786
787 //-----
789 G4cout << "***** GFEndModeling (called)" << G4endl;
790
791 if( GFIsInModeling() ) {
792
794 G4cout << "***** GFEndModeling (started) " ;
795 G4cout << "(/EndModeling, /DrawAll, /CloseDevice)" << G4endl;
796 }
797
798 //----- End saving data to g4.gdd
799 EndSavingGdd() ;
800
801 //------ Reset flag
802 kFlagInModeling = false ;
803
804 }
805
806}

Referenced by G4GMocrenFileViewer::ShowView(), and ~G4GMocrenFileSceneHandler().

◆ GFIsInModeling()

G4bool G4GMocrenFileSceneHandler::GFIsInModeling ( )
inline

Definition at line 113 of file G4GMocrenFileSceneHandler.hh.

113{ return kFlagInModeling ; }

Referenced by GFBeginModeling(), GFEndModeling(), and G4GMocrenFileViewer::ShowView().

◆ IsSavingGdd()

G4bool G4GMocrenFileSceneHandler::IsSavingGdd ( void  )
inline

Definition at line 115 of file G4GMocrenFileSceneHandler.hh.

115{ return kFlagSaving_g4_gdd ; }

Referenced by BeginSavingGdd(), and EndSavingGdd().

◆ SetGddFileName()

void G4GMocrenFileSceneHandler::SetGddFileName ( )

Definition at line 190 of file G4GMocrenFileSceneHandler.cc.

191{
192 // g4_00.gdd, g4_01.gdd, ..., g4_MAX_FILE_INDEX.gdd
193 const G4int MAX_FILE_INDEX = kMaxFileNum - 1 ;
194
195 // dest directory (null if no environmental variables is set)
196 std::strncpy(kGddFileName, kGddDestDir, std::strlen(kGddDestDir));
197
198 // create full path name (default)
199 std::strncat ( kGddFileName, DEFAULT_GDD_FILE_NAME, std::strlen(DEFAULT_GDD_FILE_NAME));
200
201 // Automatic updation of file names
202 static G4int currentNumber = 0;
203 for( G4int i = currentNumber ; i < kMaxFileNum ; i++) {
204
205 // Message in the final execution
206 if( i == MAX_FILE_INDEX )
207 {
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;
214 G4cout << " g4_XX.gdd." << G4endl;
215 G4cout << "===========================================" << G4endl;
216 }
217 }
218
219 // re-determine file name as G4GMocrenFile_DEST_DIR/g4_XX.gdd
220 if( i >= 0 && i <= 9 ) {
221 std::sprintf( kGddFileName, "%s%s%s%d.gdd" , kGddDestDir, GDD_FILE_HEADER, "0", i );
222 } else {
223 std::sprintf( kGddFileName, "%s%s%d.gdd" , kGddDestDir, GDD_FILE_HEADER, i );
224 }
225
226 // check validity of the file name
227 std::ifstream fin(kGddFileName);
228 if(GFDEBUG)
229 G4cout << "FILEOPEN: " << i << " : " << kGddFileName << fin.fail() << G4endl;
230 if(!fin) {
231 // new file
232 fin.close();
233 currentNumber = i+1;
234 break;
235 } else {
236 // already exists (try next)
237 fin.close();
238 }
239
240 } // for
241
242 G4cout << "======================================================================" << G4endl;
243 G4cout << "Output file: " << kGddFileName << G4endl;
244 G4cout << "Destination directory (current dir if NULL): " << kGddDestDir << G4endl;
245 G4cout << "Maximum number of files in the destination directory: " << kMaxFileNum << G4endl;
246 G4cout << "Note:" << 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;
252 //G4cout << " dir_name, e.g. \"./tmp/\"." << G4endl;
253 G4cout << G4endl;
254 G4cout << "Maximum number of trajectories is set to " << MAX_NUM_TRAJECTORIES << "."<< G4endl;
255 G4cout << "======================================================================" << G4endl;
256
257} // G4GMocrenFileSceneHandler::SetGddFileName()
const char GDD_FILE_HEADER[]

Referenced by BeginSavingGdd().

Friends And Related Function Documentation

◆ G4GMocrenFileViewer

friend class G4GMocrenFileViewer
friend

Definition at line 56 of file G4GMocrenFileSceneHandler.hh.


The documentation for this class was generated from the following files: