Geant4_10
G4LogicalBorderSurface.cc
Go to the documentation of this file.
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 //
27 // $Id: G4LogicalBorderSurface.cc 73926 2013-09-17 07:59:06Z gcosmo $
28 //
29 // --------------------------------------------------------------------
30 // G4LogicalBorderSurface Implementation
31 // --------------------------------------------------------------------
32 //
33 // A Logical Surface class for surfaces defined by the boundary
34 // of two physical volumes.
35 //
36 // Created: 1997-06-26
37 // Author: John Apostolakis (John.Apostolakis@cern.ch)
38 //
39 // ----------------------------------------------------------------------
40 
42 #include "G4VPhysicalVolume.hh"
43 
44 G4LogicalBorderSurfaceTable *G4LogicalBorderSurface::theBorderSurfaceTable = 0;
45 
46 //
47 // Constructor & destructor
48 //
49 
52  G4VPhysicalVolume* vol1,
53  G4VPhysicalVolume* vol2,
54  G4SurfaceProperty* surfaceProperty)
55  : G4LogicalSurface(name, surfaceProperty),
56  Volume1(vol1), Volume2(vol2)
57 {
58  if (!theBorderSurfaceTable)
59  {
60  theBorderSurfaceTable = new G4LogicalBorderSurfaceTable;
61  }
62 
63  // Store in the table of Surfaces
64  //
65  theBorderSurfaceTable->push_back(this);
66 }
67 
70  : G4LogicalSurface(right.GetName(), right.GetSurfaceProperty())
71 {
72  if (!theBorderSurfaceTable)
73  {
74  theBorderSurfaceTable = new G4LogicalBorderSurfaceTable;
75  }
77  Volume1 = right.Volume1;
78  Volume2 = right.Volume2;
79  (*theBorderSurfaceTable) = (*right.theBorderSurfaceTable);
80 }
81 
83 {
84 // delete theBorderSurfaceTable; theBorderSurfaceTable=0;
85 }
86 
87 //
88 // Operators
89 //
90 
92 G4LogicalBorderSurface::operator=(const G4LogicalBorderSurface &right)
93 {
94  if (&right == this) return *this;
95  if (&right)
96  {
98  SetName(right.GetName());
100  Volume1 = right.Volume1;
101  Volume2 = right.Volume2;
102  (*theBorderSurfaceTable) = (*right.theBorderSurfaceTable);
103  }
104  return *this;
105 }
106 
107 G4int
109 {
110  return (this == (G4LogicalBorderSurface *) &right);
111 }
112 
113 G4int
115 {
116  return (this != (G4LogicalBorderSurface *) &right);
117 }
118 
119 //
120 // Methods
121 //
122 
124 {
125  if (!theBorderSurfaceTable)
126  {
127  theBorderSurfaceTable = new G4LogicalBorderSurfaceTable;
128  }
129  return theBorderSurfaceTable;
130 }
131 
133 {
134  if (theBorderSurfaceTable)
135  {
136  return theBorderSurfaceTable->size();
137  }
138  return 0;
139 }
140 
143  const G4VPhysicalVolume* vol2)
144 {
145  if (theBorderSurfaceTable)
146  {
147  for (size_t i=0; i<theBorderSurfaceTable->size(); i++)
148  {
149  if( ((*theBorderSurfaceTable)[i]->GetVolume1() == vol1) &&
150  ((*theBorderSurfaceTable)[i]->GetVolume2() == vol2) )
151  return (*theBorderSurfaceTable)[i];
152  }
153  }
154  return 0;
155 }
156 
157 // Dump info for known surfaces
158 //
160 {
161  G4cout << "***** Surface Table : Nb of Surfaces = "
162  << GetNumberOfBorderSurfaces() << " *****" << G4endl;
163 
164  if (theBorderSurfaceTable)
165  {
166  for (size_t i=0; i<theBorderSurfaceTable->size(); i++)
167  {
168  G4LogicalBorderSurface* pBorderSurface = (*theBorderSurfaceTable)[i];
169  G4cout << pBorderSurface->GetName() << " : " << G4endl
170  << " Border of volumes "
171  << pBorderSurface->GetVolume1()->GetName() << " and "
172  << pBorderSurface->GetVolume2()->GetName()
173  << G4endl;
174  }
175  }
176  G4cout << G4endl;
177 }
178 
180 {
181  if (theBorderSurfaceTable)
182  {
183  G4LogicalBorderSurfaceTable::iterator pos;
184  for(pos=theBorderSurfaceTable->begin();
185  pos!=theBorderSurfaceTable->end(); pos++)
186  {
187  if (*pos) { delete *pos; }
188  }
189  theBorderSurfaceTable->clear();
190  }
191  return;
192 }
G4TransitionRadiationSurface * GetTransitionRadiationSurface() const
std::vector< G4LogicalBorderSurface * > G4LogicalBorderSurfaceTable
G4LogicalBorderSurface(const G4String &name, G4VPhysicalVolume *vol1, G4VPhysicalVolume *vol2, G4SurfaceProperty *surfaceProperty)
const G4VPhysicalVolume * GetVolume2() const
void SetName(const G4String &name)
const XML_Char * name
Definition: expat.h:151
int G4int
Definition: G4Types.hh:78
static G4LogicalBorderSurface * GetSurface(const G4VPhysicalVolume *vol1, const G4VPhysicalVolume *vol2)
static size_t GetNumberOfBorderSurfaces()
G4int operator!=(const G4LogicalBorderSurface &right) const
const G4String & GetName() const
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
static const G4LogicalBorderSurfaceTable * GetSurfaceTable()
void SetTransitionRadiationSurface(G4TransitionRadiationSurface *tRadSurf)
const G4VPhysicalVolume * GetVolume1() const
void SetSurfaceProperty(G4SurfaceProperty *ptrSurfaceProperty)
G4int operator==(const G4LogicalBorderSurface &right) const
#define G4endl
Definition: G4ios.hh:61
G4SurfaceProperty * GetSurfaceProperty() const