Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // >> 26 // >> 27 // $Id: G4LogicalSkinSurface.cc,v 1.13 2006/06/29 18:57:59 gunter Exp $ >> 28 // GEANT4 tag $Name: geant4-08-01 $ >> 29 // >> 30 // -------------------------------------------------------------------- 26 // G4LogicalSkinSurface Implementation 31 // G4LogicalSkinSurface Implementation >> 32 // -------------------------------------------------------------------- 27 // 33 // 28 // A Logical Surface class for the surface sur 34 // A Logical Surface class for the surface surrounding a single 29 // logical volume. 35 // logical volume. 30 // 36 // 31 // Author: John Apostolakis, CERN - 26-06-1997 << 37 // Created: 1997-06-26 32 // ------------------------------------------- << 38 // Author: John Apostolakis (John.Apostolakis@cern.ch) >> 39 // >> 40 // ---------------------------------------------------------------------- 33 41 34 #include "G4LogicalSkinSurface.hh" 42 #include "G4LogicalSkinSurface.hh" >> 43 #include "G4ios.hh" 35 #include "G4LogicalVolume.hh" 44 #include "G4LogicalVolume.hh" 36 45 37 G4LogicalSkinSurfaceTable *G4LogicalSkinSurfac << 46 G4LogicalSkinSurfaceTable G4LogicalSkinSurface::theSurfaceTable; 38 47 39 // ------------------------------------------- << 40 // Constructor << 41 // 48 // 42 G4LogicalSkinSurface::G4LogicalSkinSurface(con << 49 // Constructors & destructor 43 G4L << 50 // >> 51 >> 52 G4LogicalSkinSurface::G4LogicalSkinSurface(const G4String& name, >> 53 G4LogicalVolume* logicalVolume, 44 G4S 54 G4SurfaceProperty* surfaceProperty) 45 : G4LogicalSurface(name, surfaceProperty), 55 : G4LogicalSurface(name, surfaceProperty), 46 LogVolume(logicalVolume) 56 LogVolume(logicalVolume) 47 { 57 { 48 if (theSkinSurfaceTable == nullptr) << 49 { << 50 theSkinSurfaceTable = new G4LogicalSkinSur << 51 } << 52 // Store in the table of Surfaces 58 // Store in the table of Surfaces 53 // 59 // 54 theSkinSurfaceTable->insert(std::make_pair(l << 60 theSurfaceTable.push_back(this); 55 } 61 } 56 62 57 // ------------------------------------------- << 63 G4LogicalSkinSurface::G4LogicalSkinSurface(const G4LogicalSkinSurface& right) 58 // Default destructor << 64 : G4LogicalSurface(right.GetName(), right.GetSurfaceProperty()) >> 65 { >> 66 SetTransitionRadiationSurface(right.GetTransitionRadiationSurface()); >> 67 LogVolume = right.LogVolume; >> 68 theSurfaceTable = right.theSurfaceTable; >> 69 } >> 70 >> 71 G4LogicalSkinSurface::~G4LogicalSkinSurface() >> 72 { >> 73 } >> 74 >> 75 // >> 76 // Operators 59 // 77 // 60 G4LogicalSkinSurface::~G4LogicalSkinSurface() << 61 78 62 // ------------------------------------------- << 79 const G4LogicalSkinSurface& 63 G4bool << 80 G4LogicalSkinSurface::operator=(const G4LogicalSkinSurface& right) >> 81 { >> 82 if (&right == this) return *this; >> 83 if (&right) >> 84 { >> 85 SetSurfaceProperty(right.GetSurfaceProperty()); >> 86 SetName(right.GetName()); >> 87 SetTransitionRadiationSurface(right.GetTransitionRadiationSurface()); >> 88 LogVolume = right.LogVolume; >> 89 theSurfaceTable = right.theSurfaceTable; >> 90 } >> 91 return *this; >> 92 } >> 93 >> 94 G4int 64 G4LogicalSkinSurface::operator==(const G4Logic 95 G4LogicalSkinSurface::operator==(const G4LogicalSkinSurface& right) const 65 { 96 { 66 return (this == (G4LogicalSkinSurface *) &ri 97 return (this == (G4LogicalSkinSurface *) &right); 67 } 98 } 68 99 69 // ------------------------------------------- << 100 G4int 70 G4bool << 71 G4LogicalSkinSurface::operator!=(const G4Logic 101 G4LogicalSkinSurface::operator!=(const G4LogicalSkinSurface& right) const 72 { 102 { 73 return (this != (G4LogicalSkinSurface *) &ri 103 return (this != (G4LogicalSkinSurface *) &right); 74 } 104 } 75 105 76 // ------------------------------------------- << 106 // 77 const G4LogicalSkinSurfaceTable* G4LogicalSkin << 107 // Methods 78 { << 108 // 79 if (theSkinSurfaceTable == nullptr) << 80 { << 81 theSkinSurfaceTable = new G4LogicalSkinSur << 82 } << 83 return theSkinSurfaceTable; << 84 } << 85 109 86 // ------------------------------------------- << 87 size_t G4LogicalSkinSurface::GetNumberOfSkinSu 110 size_t G4LogicalSkinSurface::GetNumberOfSkinSurfaces() 88 { 111 { 89 if (theSkinSurfaceTable != nullptr) << 112 return theSurfaceTable.size(); 90 { << 91 return theSkinSurfaceTable->size(); << 92 } << 93 return 0; << 94 } 113 } 95 114 96 // ------------------------------------------- << 97 G4LogicalSkinSurface* 115 G4LogicalSkinSurface* 98 G4LogicalSkinSurface::GetSurface(const G4Logic 116 G4LogicalSkinSurface::GetSurface(const G4LogicalVolume* vol) 99 { 117 { 100 if (theSkinSurfaceTable != nullptr) << 118 for (size_t i=0; i<theSurfaceTable.size(); i++) 101 { 119 { 102 auto pos = theSkinSurfaceTable->find(vol); << 120 if(theSurfaceTable[i]->GetLogicalVolume() == vol) 103 if(pos != theSkinSurfaceTable->cend()) ret << 121 return theSurfaceTable[i]; 104 } 122 } 105 return nullptr; << 123 return NULL; 106 } 124 } 107 125 108 // ------------------------------------------- << 109 // Dump info for known surfaces 126 // Dump info for known surfaces 110 // 127 // 111 void G4LogicalSkinSurface::DumpInfo() 128 void G4LogicalSkinSurface::DumpInfo() 112 { 129 { 113 G4cout << "***** Skin Surface Table : Nb of << 130 G4cout << "***** Surface Table : Nb of Surfaces = " 114 << GetNumberOfSkinSurfaces() << " *** << 131 << GetNumberOfSkinSurfaces() << " *****" << G4endl; 115 132 116 if (theSkinSurfaceTable != nullptr) << 133 for (size_t i=0; i<theSurfaceTable.size(); i++) 117 { << 118 for(const auto & pos : *theSkinSurfaceTabl << 119 { 134 { 120 G4LogicalSkinSurface* pSurf = pos.second << 135 G4LogicalSkinSurface* pSkinSurface = theSurfaceTable[i]; 121 G4cout << pSurf->GetName() << " : " << G << 136 G4cout << theSurfaceTable[i]->GetName() << " : " << G4endl 122 << " Skin of logical volume " 137 << " Skin of logical volume " 123 << pSurf->GetLogicalVolume()->Get << 138 << pSkinSurface->GetLogicalVolume()->GetName() 124 << G4endl; 139 << G4endl; 125 } 140 } 126 } << 141 G4cout << G4endl; 127 G4cout << G4endl; << 128 } 142 } 129 143 130 // ------------------------------------------- << 131 void G4LogicalSkinSurface::CleanSurfaceTable() 144 void G4LogicalSkinSurface::CleanSurfaceTable() 132 { << 145 { 133 if (theSkinSurfaceTable != nullptr) << 146 std::vector<G4LogicalSkinSurface*>::iterator pos; >> 147 for(pos=theSurfaceTable.begin(); pos!=theSurfaceTable.end(); pos++) 134 { 148 { 135 for(const auto & pos : *theSkinSurfaceTabl << 149 if (*pos) delete *pos; 136 { << 137 delete pos.second; << 138 } << 139 theSkinSurfaceTable->clear(); << 140 } 150 } 141 return; << 151 theSurfaceTable.clear(); 142 } 152 } 143 153