Geant4  10.02.p02
G4UPolycone.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 // Implementation of G4UPolycone wrapper class
30 // --------------------------------------------------------------------
31 
32 #include "G4Polycone.hh"
33 #include "G4UPolycone.hh"
34 
35 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
36 
37 #include "G4VPVParameterisation.hh"
38 
40 //
41 // Constructor (GEANT3 style parameters)
42 //
43 G4UPolycone::G4UPolycone( const G4String& name,
44  G4double phiStart,
45  G4double phiTotal,
46  G4int numZPlanes,
47  const G4double zPlane[],
48  const G4double rInner[],
49  const G4double rOuter[] )
50  : G4USolid(name, new UPolycone(name, phiStart, phiTotal,
51  numZPlanes, zPlane, rInner, rOuter))
52 {
53 }
54 
55 
57 //
58 // Constructor (generic parameters)
59 //
60 G4UPolycone::G4UPolycone(const G4String& name,
61  G4double phiStart,
62  G4double phiTotal,
63  G4int numRZ,
64  const G4double r[],
65  const G4double z[] )
66  : G4USolid(name, new UPolycone(name, phiStart, phiTotal, numRZ, r, z))
67 {
68 }
69 
70 
72 //
73 // Fake default constructor - sets only member data and allocates memory
74 // for usage restricted to object persistency.
75 //
76 G4UPolycone::G4UPolycone( __void__& a )
77  : G4USolid(a)
78 {
79 }
80 
81 
83 //
84 // Destructor
85 //
86 G4UPolycone::~G4UPolycone()
87 {
88 }
89 
90 
92 //
93 // Copy constructor
94 //
95 G4UPolycone::G4UPolycone( const G4UPolycone &source )
96  : G4USolid( source )
97 {
98 }
99 
100 
102 //
103 // Assignment operator
104 //
105 G4UPolycone &G4UPolycone::operator=( const G4UPolycone &source )
106 {
107  if (this == &source) return *this;
108 
109  G4USolid::operator=( source );
110 
111  return *this;
112 }
113 
114 
116 //
117 // Accessors & modifiers
118 //
119 G4double G4UPolycone::GetStartPhi() const
120 {
121  return GetShape()->GetStartPhi();
122 }
123 G4double G4UPolycone::GetEndPhi() const
124 {
125  return GetShape()->GetEndPhi();
126 }
127 G4bool G4UPolycone::IsOpen() const
128 {
129  return GetShape()->IsOpen();
130 }
131 G4int G4UPolycone::GetNumRZCorner() const
132 {
133  return GetShape()->GetNumRZCorner();
134 }
135 G4PolyconeSideRZ G4UPolycone::GetCorner(G4int index) const
136 {
137  UPolyconeSideRZ pside = GetShape()->GetCorner(index);
138  G4PolyconeSideRZ psiderz = { pside.r, pside.z };
139 
140  return psiderz;
141 }
142 G4PolyconeHistorical* G4UPolycone::GetOriginalParameters() const
143 {
144  UPolyconeHistorical* pars = GetShape()->GetOriginalParameters();
145  G4PolyconeHistorical* pdata = new G4PolyconeHistorical(pars->fNumZPlanes);
146  pdata->Start_angle = pars->fStartAngle;
147  pdata->Opening_angle = pars->fOpeningAngle;
148  for (G4int i=0; i<pars->fNumZPlanes; ++i)
149  {
150  pdata->Z_values[i] = pars->fZValues[i];
151  pdata->Rmin[i] = pars->Rmin[i];
152  pdata->Rmax[i] = pars->Rmax[i];
153  }
154  return pdata;
155 }
156 void G4UPolycone::SetOriginalParameters(G4PolyconeHistorical* pars)
157 {
158  UPolyconeHistorical* pdata = GetShape()->GetOriginalParameters();
159  pdata->fStartAngle = pars->Start_angle;
160  pdata->fOpeningAngle = pars->Opening_angle;
161  pdata->fNumZPlanes = pars->Num_z_planes;
162  for (G4int i=0; i<pdata->fNumZPlanes; ++i)
163  {
164  pdata->fZValues[i] = pars->Z_values[i];
165  pdata->Rmin[i] = pars->Rmin[i];
166  pdata->Rmax[i] = pars->Rmax[i];
167  }
168  fRebuildPolyhedron = true;
169 }
170 G4bool G4UPolycone::Reset()
171 {
172  GetShape()->Reset();
173  return 0;
174 }
175 
177 //
178 // Dispatch to parameterisation for replication mechanism dimension
179 // computation & modification.
180 //
181 void G4UPolycone::ComputeDimensions(G4VPVParameterisation* p,
182  const G4int n,
183  const G4VPhysicalVolume* pRep)
184 {
185  p->ComputeDimensions(*(G4Polycone*)this,n,pRep);
186 }
187 
188 
190 //
191 // Make a clone of the object
192 
193 G4VSolid* G4UPolycone::Clone() const
194 {
195  return new G4UPolycone(*this);
196 }
197 
198 
200 //
201 // CreatePolyhedron
202 //
203 G4Polyhedron* G4UPolycone::CreatePolyhedron() const
204 {
205  G4PolyconeHistorical* original_parameters = GetOriginalParameters();
207  polyhedron = new G4PolyhedronPcon( original_parameters->Start_angle,
208  original_parameters->Opening_angle,
209  original_parameters->Num_z_planes,
210  original_parameters->Z_values,
211  original_parameters->Rmin,
212  original_parameters->Rmax );
213 
214  delete original_parameters; // delete local copy
215 
216  return polyhedron;
217 }
218 
219 #endif // G4GEOM_USE_USOLIDS
G4double z
Definition: TRTMaterials.hh:39
G4String name
Definition: TRTMaterials.hh:40
G4double a
Definition: TRTMaterials.hh:39
int G4int
Definition: G4Types.hh:78
bool G4bool
Definition: G4Types.hh:79
const G4int n
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
double G4double
Definition: G4Types.hh:76