Geant4  10.02.p02
G4UTrd.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 // Implementation for G4UTrd wrapper class
31 // --------------------------------------------------------------------
32 
33 #include "G4Trd.hh"
34 #include "G4UTrd.hh"
35 
36 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
37 
38 #include "G4VPVParameterisation.hh"
39 
41 //
42 // Constructor - check & set half widths
43 //
44 G4UTrd::G4UTrd(const G4String& pName,
45  G4double pdx1, G4double pdx2,
46  G4double pdy1, G4double pdy2,
47  G4double pdz)
48  : G4USolid(pName, new UTrd(pName, pdx1, pdx2, pdy1, pdy2, pdz))
49 {
50 }
51 
53 //
54 // Fake default constructor - sets only member data and allocates memory
55 // for usage restricted to object persistency.
56 //
57 G4UTrd::G4UTrd( __void__& a )
58  : G4USolid(a)
59 {
60 }
61 
63 //
64 // Destructor
65 //
66 G4UTrd::~G4UTrd()
67 {
68 }
69 
71 //
72 // Copy constructor
73 //
74 G4UTrd::G4UTrd(const G4UTrd& rhs)
75  : G4USolid(rhs)
76 {
77 }
78 
80 //
81 // Assignment operator
82 //
83 G4UTrd& G4UTrd::operator = (const G4UTrd& rhs)
84 {
85  // Check assignment to self
86  //
87  if (this == &rhs) { return *this; }
88 
89  // Copy base class data
90  //
91  G4USolid::operator=(rhs);
92 
93  return *this;
94 }
95 
97 //
98 // Accessors & modifiers
99 
100 G4double G4UTrd::GetXHalfLength1() const
101 {
102  return GetShape()->GetXHalfLength1();
103 }
104 G4double G4UTrd::GetXHalfLength2() const
105 {
106  return GetShape()->GetXHalfLength2();
107 }
108 G4double G4UTrd::GetYHalfLength1() const
109 {
110  return GetShape()->GetYHalfLength1();
111 }
112 G4double G4UTrd::GetYHalfLength2() const
113 {
114  return GetShape()->GetYHalfLength2();
115 }
116 G4double G4UTrd::GetZHalfLength() const
117 {
118  return GetShape()->GetZHalfLength();
119 }
120 
121 void G4UTrd::SetXHalfLength1(G4double val)
122 {
123  GetShape()->SetXHalfLength1(val);
124  fRebuildPolyhedron = true;
125 }
126 void G4UTrd::SetXHalfLength2(G4double val)
127 {
128  GetShape()->SetXHalfLength2(val);
129  fRebuildPolyhedron = true;
130 }
131 void G4UTrd::SetYHalfLength1(G4double val)
132 {
133  GetShape()->SetYHalfLength1(val);
134  fRebuildPolyhedron = true;
135 }
136 void G4UTrd::SetYHalfLength2(G4double val)
137 {
138  GetShape()->SetYHalfLength2(val);
139  fRebuildPolyhedron = true;
140 }
141 void G4UTrd::SetZHalfLength(G4double val)
142 {
143  GetShape()->SetZHalfLength(val);
144  fRebuildPolyhedron = true;
145 }
146 void G4UTrd::SetAllParameters(G4double pdx1, G4double pdx2,
147  G4double pdy1, G4double pdy2, G4double pdz)
148 {
149  GetShape()->SetAllParameters(pdx1, pdx2, pdy1, pdy2, pdz);
150  fRebuildPolyhedron = true;
151 }
152 
154 //
155 // Dispatch to parameterisation for replication mechanism dimension
156 // computation & modification.
157 //
158 void G4UTrd::ComputeDimensions( G4VPVParameterisation* p,
159  const G4int n,
160  const G4VPhysicalVolume* pRep)
161 {
162  p->ComputeDimensions(*(G4Trd*)this,n,pRep);
163 }
164 
166 //
167 // Make a clone of the object
168 
169 G4VSolid* G4UTrd::Clone() const
170 {
171  return new G4UTrd(*this);
172 }
173 
175 //
176 // Create polyhedron for visualization
177 //
178 G4Polyhedron* G4UTrd::CreatePolyhedron() const
179 {
180  return new G4PolyhedronTrd2(GetXHalfLength1(),
181  GetXHalfLength2(),
182  GetYHalfLength1(),
183  GetYHalfLength2(),
184  GetZHalfLength());
185 }
186 
187 #endif // G4GEOM_USE_USOLIDS
G4double a
Definition: TRTMaterials.hh:39
Definition: G4Trd.hh:72
int G4int
Definition: G4Types.hh:78
const G4int n
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
double G4double
Definition: G4Types.hh:76