Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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$
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;
45 
46 //
47 // Constructor & destructor
48 //
49 
51  G4VPhysicalVolume* vol1,
52  G4VPhysicalVolume* vol2,
53  G4SurfaceProperty* surfaceProperty)
54  : G4LogicalSurface(name, surfaceProperty),
55  Volume1(vol1), Volume2(vol2)
56 {
57  // Store in the table of Surfaces
58  //
59  theBorderSurfaceTable.push_back(this);
60 }
61 
64  : G4LogicalSurface(right.GetName(), right.GetSurfaceProperty())
65 {
67  Volume1 = right.Volume1;
68  Volume2 = right.Volume2;
69  theBorderSurfaceTable = right.theBorderSurfaceTable;
70 }
71 
73 {
74 }
75 
76 //
77 // Operators
78 //
79 
81 G4LogicalBorderSurface::operator=(const G4LogicalBorderSurface &right)
82 {
83  if (&right == this) return *this;
84  if (&right)
85  {
87  SetName(right.GetName());
89  Volume1 = right.Volume1;
90  Volume2 = right.Volume2;
91  theBorderSurfaceTable = right.theBorderSurfaceTable;
92  }
93  return *this;
94 }
95 
96 G4int
98 {
99  return (this == (G4LogicalBorderSurface *) &right);
100 }
101 
102 G4int
104 {
105  return (this != (G4LogicalBorderSurface *) &right);
106 }
107 
108 //
109 // Methods
110 //
111 
113 {
114  return &theBorderSurfaceTable;
115 }
116 
118 {
119  return theBorderSurfaceTable.size();
120 }
121 
124  const G4VPhysicalVolume* vol2)
125 {
126  for (size_t i=0; i<theBorderSurfaceTable.size(); i++)
127  {
128  if( (theBorderSurfaceTable[i]->GetVolume1() == vol1) &&
129  (theBorderSurfaceTable[i]->GetVolume2() == vol2) )
130  return theBorderSurfaceTable[i];
131  }
132  return NULL;
133 }
134 
135 // Dump info for known surfaces
136 //
138 {
139  G4cout << "***** Surface Table : Nb of Surfaces = "
140  << GetNumberOfBorderSurfaces() << " *****" << G4endl;
141 
142  for (size_t i=0; i<theBorderSurfaceTable.size(); i++)
143  {
144  G4LogicalBorderSurface* pBorderSurface = theBorderSurfaceTable[i];
145  G4cout << pBorderSurface->GetName() << " : " << G4endl
146  << " Border of volumes "
147  << pBorderSurface->GetVolume1()->GetName() << " and "
148  << pBorderSurface->GetVolume2()->GetName()
149  << G4endl;
150  }
151  G4cout << G4endl;
152 }
153 
155 {
156  G4LogicalBorderSurfaceTable::iterator pos;
157  for(pos=theBorderSurfaceTable.begin();
158  pos!=theBorderSurfaceTable.end(); pos++)
159  {
160  if (*pos) delete *pos;
161  }
162  theBorderSurfaceTable.clear();
163 }