00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id$ 00028 // 00029 // -------------------------------------------------------------------- 00030 // G4LogicalBorderSurface Implementation 00031 // -------------------------------------------------------------------- 00032 // 00033 // A Logical Surface class for surfaces defined by the boundary 00034 // of two physical volumes. 00035 // 00036 // Created: 1997-06-26 00037 // Author: John Apostolakis (John.Apostolakis@cern.ch) 00038 // 00039 // ---------------------------------------------------------------------- 00040 00041 #include "G4LogicalBorderSurface.hh" 00042 #include "G4VPhysicalVolume.hh" 00043 00044 G4LogicalBorderSurfaceTable G4LogicalBorderSurface::theBorderSurfaceTable; 00045 00046 // 00047 // Constructor & destructor 00048 // 00049 00050 G4LogicalBorderSurface::G4LogicalBorderSurface(const G4String& name, 00051 G4VPhysicalVolume* vol1, 00052 G4VPhysicalVolume* vol2, 00053 G4SurfaceProperty* surfaceProperty) 00054 : G4LogicalSurface(name, surfaceProperty), 00055 Volume1(vol1), Volume2(vol2) 00056 { 00057 // Store in the table of Surfaces 00058 // 00059 theBorderSurfaceTable.push_back(this); 00060 } 00061 00062 G4LogicalBorderSurface:: 00063 G4LogicalBorderSurface(const G4LogicalBorderSurface& right) 00064 : G4LogicalSurface(right.GetName(), right.GetSurfaceProperty()) 00065 { 00066 SetTransitionRadiationSurface(right.GetTransitionRadiationSurface()); 00067 Volume1 = right.Volume1; 00068 Volume2 = right.Volume2; 00069 theBorderSurfaceTable = right.theBorderSurfaceTable; 00070 } 00071 00072 G4LogicalBorderSurface::~G4LogicalBorderSurface() 00073 { 00074 } 00075 00076 // 00077 // Operators 00078 // 00079 00080 const G4LogicalBorderSurface& 00081 G4LogicalBorderSurface::operator=(const G4LogicalBorderSurface &right) 00082 { 00083 if (&right == this) return *this; 00084 if (&right) 00085 { 00086 SetSurfaceProperty(right.GetSurfaceProperty()); 00087 SetName(right.GetName()); 00088 SetTransitionRadiationSurface(right.GetTransitionRadiationSurface()); 00089 Volume1 = right.Volume1; 00090 Volume2 = right.Volume2; 00091 theBorderSurfaceTable = right.theBorderSurfaceTable; 00092 } 00093 return *this; 00094 } 00095 00096 G4int 00097 G4LogicalBorderSurface::operator==(const G4LogicalBorderSurface &right) const 00098 { 00099 return (this == (G4LogicalBorderSurface *) &right); 00100 } 00101 00102 G4int 00103 G4LogicalBorderSurface::operator!=(const G4LogicalBorderSurface &right) const 00104 { 00105 return (this != (G4LogicalBorderSurface *) &right); 00106 } 00107 00108 // 00109 // Methods 00110 // 00111 00112 const G4LogicalBorderSurfaceTable* G4LogicalBorderSurface::GetSurfaceTable() 00113 { 00114 return &theBorderSurfaceTable; 00115 } 00116 00117 size_t G4LogicalBorderSurface::GetNumberOfBorderSurfaces() 00118 { 00119 return theBorderSurfaceTable.size(); 00120 } 00121 00122 G4LogicalBorderSurface* 00123 G4LogicalBorderSurface::GetSurface(const G4VPhysicalVolume* vol1, 00124 const G4VPhysicalVolume* vol2) 00125 { 00126 for (size_t i=0; i<theBorderSurfaceTable.size(); i++) 00127 { 00128 if( (theBorderSurfaceTable[i]->GetVolume1() == vol1) && 00129 (theBorderSurfaceTable[i]->GetVolume2() == vol2) ) 00130 return theBorderSurfaceTable[i]; 00131 } 00132 return NULL; 00133 } 00134 00135 // Dump info for known surfaces 00136 // 00137 void G4LogicalBorderSurface::DumpInfo() 00138 { 00139 G4cout << "***** Surface Table : Nb of Surfaces = " 00140 << GetNumberOfBorderSurfaces() << " *****" << G4endl; 00141 00142 for (size_t i=0; i<theBorderSurfaceTable.size(); i++) 00143 { 00144 G4LogicalBorderSurface* pBorderSurface = theBorderSurfaceTable[i]; 00145 G4cout << pBorderSurface->GetName() << " : " << G4endl 00146 << " Border of volumes " 00147 << pBorderSurface->GetVolume1()->GetName() << " and " 00148 << pBorderSurface->GetVolume2()->GetName() 00149 << G4endl; 00150 } 00151 G4cout << G4endl; 00152 } 00153 00154 void G4LogicalBorderSurface::CleanSurfaceTable() 00155 { 00156 G4LogicalBorderSurfaceTable::iterator pos; 00157 for(pos=theBorderSurfaceTable.begin(); 00158 pos!=theBorderSurfaceTable.end(); pos++) 00159 { 00160 if (*pos) delete *pos; 00161 } 00162 theBorderSurfaceTable.clear(); 00163 }