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