Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4UBox.cc
이 파일의 문서화 페이지로 가기
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 // Implementation for G4UBox wrapper class
31 // --------------------------------------------------------------------
32 
33 #include "G4Box.hh"
34 #include "G4UBox.hh"
35 
36 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
37 
38 #include "G4AffineTransform.hh"
39 #include "G4VPVParameterisation.hh"
40 #include "G4BoundingEnvelope.hh"
41 
42 using namespace CLHEP;
43 
45 //
46 // Constructor - check & set half widths
47 
48 
49 G4UBox::G4UBox(const G4String& pName,
50  G4double pX,
51  G4double pY,
52  G4double pZ)
53  : Base_t(pName, pX, pY, pZ)
54 {
55 }
56 
58 //
59 // Fake default constructor - sets only member data and allocates memory
60 // for usage restricted to object persistency.
61 
62 G4UBox::G4UBox( __void__& a )
63  : Base_t(a)
64 {
65 }
66 
68 //
69 // Destructor
70 
71 G4UBox::~G4UBox()
72 {
73 }
74 
76 //
77 // Copy constructor
78 
79 G4UBox::G4UBox(const G4UBox& rhs)
80  : Base_t(rhs)
81 {
82 }
83 
85 //
86 // Assignment operator
87 
88 G4UBox& G4UBox::operator = (const G4UBox& rhs)
89 {
90  // Check assignment to self
91  //
92  if (this == &rhs) { return *this; }
93 
94  // Copy base class data
95  //
96  Base_t::operator=(rhs);
97 
98  return *this;
99 }
100 
102 //
103 // Accessors & modifiers
104 
105 G4double G4UBox::GetXHalfLength() const
106 {
107  return x();
108 }
109 G4double G4UBox::GetYHalfLength() const
110 {
111  return y();
112 }
113 G4double G4UBox::GetZHalfLength() const
114 {
115  return z();
116 }
117 
118 void G4UBox::SetXHalfLength(G4double dx)
119 {
120  SetX(dx);
121  fRebuildPolyhedron = true;
122 }
123 void G4UBox::SetYHalfLength(G4double dy)
124 {
125  SetY(dy);
126  fRebuildPolyhedron = true;
127 }
128 void G4UBox::SetZHalfLength(G4double dz)
129 {
130  SetZ(dz);
131  fRebuildPolyhedron = true;
132 }
133 
135 //
136 // Dispatch to parameterisation for replication mechanism dimension
137 // computation & modification.
138 
139 void G4UBox::ComputeDimensions(G4VPVParameterisation* p,
140  const G4int n,
141  const G4VPhysicalVolume* pRep)
142 {
143  p->ComputeDimensions(*(G4Box*)this,n,pRep);
144 }
145 
147 //
148 // Make a clone of the object
149 
150 G4VSolid* G4UBox::Clone() const
151 {
152  return new G4UBox(*this);
153 }
154 
156 //
157 // Get bounding box
158 
159 void G4UBox::BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const
160 {
161  G4double dx = GetXHalfLength();
162  G4double dy = GetYHalfLength();
163  G4double dz = GetZHalfLength();
164  pMin.set(-dx,-dy,-dz);
165  pMax.set( dx, dy, dz);
166 
167  // Check correctness of the bounding box
168  //
169  if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
170  {
171  std::ostringstream message;
172  message << "Bad bounding box (min >= max) for solid: "
173  << GetName() << " !"
174  << "\npMin = " << pMin
175  << "\npMax = " << pMax;
176  G4Exception("G4UBox::BoundingLimits()", "GeomMgt0001",
177  JustWarning, message);
178  StreamInfo(G4cout);
179  }
180 }
181 
183 //
184 // Calculate extent under transform and specified limit
185 
186 G4bool
187 G4UBox::CalculateExtent(const EAxis pAxis,
188  const G4VoxelLimits& pVoxelLimit,
189  const G4AffineTransform& pTransform,
190  G4double& pMin, G4double& pMax) const
191 {
192  G4ThreeVector bmin, bmax;
193 
194  // Get bounding box limits
195  BoundingLimits(bmin,bmax);
196 
197  // Find extent
198  G4BoundingEnvelope bbox(bmin,bmax);
199  return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
200 }
201 
202 
204 //
205 // Create polyhedron for visualization
206 
207 G4Polyhedron* G4UBox::CreatePolyhedron() const
208 {
209  return new G4PolyhedronBox(GetXHalfLength(),
210  GetYHalfLength(),
211  GetZHalfLength());
212 }
213 
214 #endif // G4GEOM_USE_USOLIDS
Float_t x
Definition: compare.C:6
void set(double x, double y, double z)
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
Float_t y
Definition: compare.C:6
const char * p
Definition: xmltok.h:285
Double_t z
void message(RunManager *runmanager)
Definition: ts_scorers.cc:72
double z() const
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
Definition: G4Box.hh:64
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
int G4int
Definition: G4Types.hh:78
EAxis
Definition: geomdefs.hh:54
G4GLOB_DLL std::ostream G4cout
double x() const
Char_t n[5]
double y() const