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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /visualization/modeling/src/G4Mesh.cc (Version 11.3.0) and /visualization/modeling/src/G4Mesh.cc (Version 9.1.p1)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 //                                                
 27 //                                                
 28 //                                                
 29 // John Allison  May 2021                         
 30 //                                                
 31 // G4Mesh captures and validates a parameteris    
 32 // call a "mesh". This is typically intended f    
 33 // a large number of parameterisations, such a    
 34 //                                                
 35 // G4Mesh is used by G4PhysicalVolumeModel if     
 36 // G4ModelingParameters::fSpecialMeshRendering    
 37 // name matches one in G4ModelingParameters::f    
 38 // if any. Then, if a valid mesh is found it c    
 39 // implementation of G4VGraphicsScene::AddComp    
 40 //                                                
 41 // To set the above parameters use the followi    
 42 // standard Geant4 Visualisation System:          
 43 //    /vis/viewer/set/specialMeshRendering        
 44 //    /vis/viewer/set/specialMeshRenderingOpti    
 45 //    /vis/viewer/set/specialMeshVolumes          
 46 // See guidance on the above commmands for mor    
 47 //                                                
 48 // Note that if no special mesh volumes are sp    
 49 // G4PhysicalVolumeModel will test all volumes    
 50 // it will capture *all* parameterisations. Th    
 51 // a problem, since there is usually only one,    
 52 // selective you have to /vis/viewer/set/speci    
 53 //                                                
 54 // The specified G4VPhysicalVolume is searched    
 55 // parameterisation. If none is found it will     
 56 // and it should simply be destroyed (as in G4    
 57 // The overhead of an invalid attempt is small    
 58                                                   
 59 #include "G4Mesh.hh"                              
 60                                                   
 61 #include "G4VPhysicalVolume.hh"                   
 62 #include "G4LogicalVolume.hh"                     
 63 #include "G4PVParameterised.hh"                   
 64 #include "G4VNestedParameterisation.hh"           
 65 #include "G4Box.hh"                               
 66 #include "G4Tubs.hh"                              
 67 #include "G4Sphere.hh"                            
 68 #include "G4Tet.hh"                               
 69                                                   
 70 std::map<G4int,G4String> G4Mesh::fEnumMap = {     
 71   {invalid,"invalid"},                            
 72   {rectangle,"rectangle"},                        
 73   {nested3DRectangular,"nested3Drectangular"},    
 74   {cylinder,"cylinder"},                          
 75   {sphere,"sphere"},                              
 76   {tetrahedron,"tetrahedron"}                     
 77 };                                                
 78                                                   
 79 G4Mesh::G4Mesh (G4VPhysicalVolume* containerVo    
 80 : fpContainerVolume(containerVolume)              
 81 , fpParameterisedVolume(nullptr)                  
 82 , fMeshType(invalid)                              
 83 , fMeshDepth(0)                                   
 84 , fTransform(transform)                           
 85 {                                                 
 86   if (fpContainerVolume == nullptr) return;       
 87                                                   
 88   G4VPhysicalVolume* pv0 = fpContainerVolume;     
 89   G4VPhysicalVolume* pv1 = nullptr;               
 90   G4VPhysicalVolume* pv2 = nullptr;               
 91   G4VPhysicalVolume* pv3 = nullptr;               
 92   G4LogicalVolume*   lv0 = pv0->GetLogicalVolu    
 93   G4LogicalVolume*   lv1 = nullptr;               
 94   G4LogicalVolume*   lv2 = nullptr;               
 95                                                   
 96   // Check if this is a container for a parame    
 97   // A simple parameterisation may only be one    
 98   // Nested parameterisations may be 2- or 3-l    
 99   G4bool isContainer = false;                     
100   if (lv0->GetNoDaughters()) {                    
101     fMeshDepth++;                                 
102     pv1 = lv0->GetDaughter(0);                    
103     lv1 = pv1->GetLogicalVolume();                
104     if (dynamic_cast<G4PVParameterised*>(pv1))    
105       isContainer = true;                         
106       fpParameterisedVolume = pv1;                
107     } else if (lv1->GetNoDaughters()) {           
108       fMeshDepth++;                               
109       pv2 = lv1->GetDaughter(0);                  
110       lv2 = pv2->GetLogicalVolume();              
111       if (dynamic_cast<G4PVParameterised*>(pv2    
112           dynamic_cast<G4VNestedParameterisati    
113         isContainer = true;                       
114         fpParameterisedVolume = pv2;              
115       } else if (lv2->GetNoDaughters()) {         
116         fMeshDepth++;                             
117         pv3 = lv2->GetDaughter(0);                
118         if (dynamic_cast<G4PVParameterised*>(p    
119             dynamic_cast<G4VNestedParameterisa    
120           isContainer = true;                     
121           fpParameterisedVolume = pv3;            
122         }                                         
123       }                                           
124     }                                             
125   }                                               
126                                                   
127   if (isContainer) {                              
128                                                   
129     // Get type                                   
130     G4VSolid* pEndSol = fpParameterisedVolume-    
131     if (dynamic_cast<G4Box*>(pEndSol)) {          
132       fMeshType = rectangle;                      
133       auto pBox = static_cast<G4Box*>(pEndSol)    
134       f3DRPs.fHalfX = pBox->GetXHalfLength();     
135       f3DRPs.fHalfY = pBox->GetYHalfLength();     
136       f3DRPs.fHalfZ = pBox->GetZHalfLength();     
137     } else if (dynamic_cast<G4Tet*>(pEndSol))     
138       fMeshType = tetrahedron;                    
139     } else if (dynamic_cast<G4Tubs*>(pEndSol))    
140       fMeshType = cylinder;                       
141     } else if (dynamic_cast<G4Sphere*>(pEndSol    
142       fMeshType = sphere;                         
143     }                                             
144                                                   
145     // Special case for rectangular nested par    
146     if (fMeshDepth == 3 && fMeshType == rectan    
147       auto nestedParam3 = dynamic_cast<G4VNest    
148       if (nestedParam3) {                         
149         fMeshType = nested3DRectangular;          
150         pv1->GetReplicationData                   
151         (f3DRPs.fAxis1,f3DRPs.fNreplica1,f3DRP    
152         pv2->GetReplicationData                   
153         (f3DRPs.fAxis2,f3DRPs.fNreplica2,f3DRP    
154         pv3->GetReplicationData                   
155         (f3DRPs.fAxis3,f3DRPs.fNreplica3,f3DRP    
156       }                                           
157     }                                             
158   }                                               
159 }                                                 
160                                                   
161 G4Mesh::~G4Mesh () {}                             
162                                                   
163 std::ostream& operator << (std::ostream& os, c    
164   os << "G4Mesh: ";                               
165   os << "\nContainer: " << mesh.GetContainerVo    
166   const auto& map = mesh.GetEnumMap();            
167   const auto& typeEntry = map.find(mesh.GetMes    
168   G4String type;                                  
169   if (typeEntry != map.end()) {                   
170     type = typeEntry->second;                     
171   } else {                                        
172     type = "unrecognised";                        
173   }                                               
174   os << "\nType: " << type;                       
175   os << "\nDepth: " << mesh.GetMeshDepth();       
176   os << "\nTranslation: " << mesh.GetTransform    
177   os << "\nRotation: " << mesh.GetTransform().    
178   if (mesh.GetMeshType() == G4Mesh::rectangle     
179       mesh.GetMeshDepth() == 3) {                 
180     // Print ThreeDRectangleParameters            
181   }                                               
182   return os;                                      
183 }                                                 
184