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.16 2008-08-19 15:31:52 gcosmo Exp $ >> 28 // GEANT4 tag $Name: not supported by cvs2svn $ >> 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" 35 #include "G4LogicalVolume.hh" 43 #include "G4LogicalVolume.hh" 36 44 37 G4LogicalSkinSurfaceTable *G4LogicalSkinSurfac << 45 G4LogicalSkinSurfaceTable G4LogicalSkinSurface::theSkinSurfaceTable; 38 46 39 // ------------------------------------------- << 40 // Constructor << 41 // 47 // 42 G4LogicalSkinSurface::G4LogicalSkinSurface(con << 48 // Constructors & destructor 43 G4L << 49 // >> 50 >> 51 G4LogicalSkinSurface::G4LogicalSkinSurface(const G4String& name, >> 52 G4LogicalVolume* logicalVolume, 44 G4S 53 G4SurfaceProperty* surfaceProperty) 45 : G4LogicalSurface(name, surfaceProperty), 54 : G4LogicalSurface(name, surfaceProperty), 46 LogVolume(logicalVolume) 55 LogVolume(logicalVolume) 47 { 56 { 48 if (theSkinSurfaceTable == nullptr) << 49 { << 50 theSkinSurfaceTable = new G4LogicalSkinSur << 51 } << 52 // Store in the table of Surfaces 57 // Store in the table of Surfaces 53 // 58 // 54 theSkinSurfaceTable->insert(std::make_pair(l << 59 theSkinSurfaceTable.push_back(this); 55 } 60 } 56 61 57 // ------------------------------------------- << 62 G4LogicalSkinSurface::G4LogicalSkinSurface(const G4LogicalSkinSurface& right) 58 // Default destructor << 63 : G4LogicalSurface(right.GetName(), right.GetSurfaceProperty()) >> 64 { >> 65 SetTransitionRadiationSurface(right.GetTransitionRadiationSurface()); >> 66 LogVolume = right.LogVolume; >> 67 theSkinSurfaceTable = right.theSkinSurfaceTable; >> 68 } >> 69 >> 70 G4LogicalSkinSurface::~G4LogicalSkinSurface() >> 71 { >> 72 } >> 73 >> 74 // >> 75 // Operators 59 // 76 // 60 G4LogicalSkinSurface::~G4LogicalSkinSurface() << 61 77 62 // ------------------------------------------- << 78 const G4LogicalSkinSurface& 63 G4bool << 79 G4LogicalSkinSurface::operator=(const G4LogicalSkinSurface& right) >> 80 { >> 81 if (&right == this) return *this; >> 82 if (&right) >> 83 { >> 84 SetSurfaceProperty(right.GetSurfaceProperty()); >> 85 SetName(right.GetName()); >> 86 SetTransitionRadiationSurface(right.GetTransitionRadiationSurface()); >> 87 LogVolume = right.LogVolume; >> 88 theSkinSurfaceTable = right.theSkinSurfaceTable; >> 89 } >> 90 return *this; >> 91 } >> 92 >> 93 G4int 64 G4LogicalSkinSurface::operator==(const G4Logic 94 G4LogicalSkinSurface::operator==(const G4LogicalSkinSurface& right) const 65 { 95 { 66 return (this == (G4LogicalSkinSurface *) &ri 96 return (this == (G4LogicalSkinSurface *) &right); 67 } 97 } 68 98 69 // ------------------------------------------- << 99 G4int 70 G4bool << 71 G4LogicalSkinSurface::operator!=(const G4Logic 100 G4LogicalSkinSurface::operator!=(const G4LogicalSkinSurface& right) const 72 { 101 { 73 return (this != (G4LogicalSkinSurface *) &ri 102 return (this != (G4LogicalSkinSurface *) &right); 74 } 103 } 75 104 76 // ------------------------------------------- << 105 // >> 106 // Methods >> 107 // >> 108 77 const G4LogicalSkinSurfaceTable* G4LogicalSkin 109 const G4LogicalSkinSurfaceTable* G4LogicalSkinSurface::GetSurfaceTable() 78 { 110 { 79 if (theSkinSurfaceTable == nullptr) << 111 return &theSkinSurfaceTable; 80 { << 81 theSkinSurfaceTable = new G4LogicalSkinSur << 82 } << 83 return theSkinSurfaceTable; << 84 } 112 } 85 113 86 // ------------------------------------------- << 87 size_t G4LogicalSkinSurface::GetNumberOfSkinSu 114 size_t G4LogicalSkinSurface::GetNumberOfSkinSurfaces() 88 { 115 { 89 if (theSkinSurfaceTable != nullptr) << 116 return theSkinSurfaceTable.size(); 90 { << 91 return theSkinSurfaceTable->size(); << 92 } << 93 return 0; << 94 } 117 } 95 118 96 // ------------------------------------------- << 97 G4LogicalSkinSurface* 119 G4LogicalSkinSurface* 98 G4LogicalSkinSurface::GetSurface(const G4Logic 120 G4LogicalSkinSurface::GetSurface(const G4LogicalVolume* vol) 99 { 121 { 100 if (theSkinSurfaceTable != nullptr) << 122 for (size_t i=0; i<theSkinSurfaceTable.size(); i++) 101 { 123 { 102 auto pos = theSkinSurfaceTable->find(vol); << 124 if(theSkinSurfaceTable[i]->GetLogicalVolume() == vol) 103 if(pos != theSkinSurfaceTable->cend()) ret << 125 return theSkinSurfaceTable[i]; 104 } 126 } 105 return nullptr; << 127 return NULL; 106 } 128 } 107 129 108 // ------------------------------------------- << 109 // Dump info for known surfaces 130 // Dump info for known surfaces 110 // 131 // 111 void G4LogicalSkinSurface::DumpInfo() 132 void G4LogicalSkinSurface::DumpInfo() 112 { 133 { 113 G4cout << "***** Skin Surface Table : Nb of << 134 G4cout << "***** Skin Surface Table : Nb of Surfaces = " 114 << GetNumberOfSkinSurfaces() << " *** << 135 << GetNumberOfSkinSurfaces() << " *****" << G4endl; 115 136 116 if (theSkinSurfaceTable != nullptr) << 137 for (size_t i=0; i<theSkinSurfaceTable.size(); i++) 117 { << 118 for(const auto & pos : *theSkinSurfaceTabl << 119 { 138 { 120 G4LogicalSkinSurface* pSurf = pos.second << 139 G4LogicalSkinSurface* pSkinSurface = theSkinSurfaceTable[i]; 121 G4cout << pSurf->GetName() << " : " << G << 140 G4cout << pSkinSurface->GetName() << " : " << G4endl 122 << " Skin of logical volume " 141 << " Skin of logical volume " 123 << pSurf->GetLogicalVolume()->Get << 142 << pSkinSurface->GetLogicalVolume()->GetName() 124 << G4endl; 143 << G4endl; 125 } 144 } 126 } << 145 G4cout << G4endl; 127 G4cout << G4endl; << 128 } 146 } 129 147 130 // ------------------------------------------- << 131 void G4LogicalSkinSurface::CleanSurfaceTable() 148 void G4LogicalSkinSurface::CleanSurfaceTable() 132 { << 149 { 133 if (theSkinSurfaceTable != nullptr) << 150 G4LogicalSkinSurfaceTable::iterator pos; >> 151 for(pos=theSkinSurfaceTable.begin(); pos!=theSkinSurfaceTable.end(); pos++) 134 { 152 { 135 for(const auto & pos : *theSkinSurfaceTabl << 153 if (*pos) delete *pos; 136 { << 137 delete pos.second; << 138 } << 139 theSkinSurfaceTable->clear(); << 140 } 154 } 141 return; << 155 theSkinSurfaceTable.clear(); 142 } 156 } 143 157