Geant4  10.01.p01
G4UGenericTrap.hh
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 // --------------------------------------------------------------------
31 // GEANT 4 class header file
32 //
33 //
34 // G4UGenericTrap
35 //
36 // Class description:
37 //
38 // Wrapper class for G4UGenericTrap to make use of it from USolids module.
39 
40 // History:
41 // 30.10.13 G.Cosmo, CERN/PH
42 // --------------------------------------------------------------------
43 #ifndef G4UGENERICTRAP_hh
44 #define G4UGENERICTRAP_hh
45 
46 #include "G4USolid.hh"
47 #include "UGenericTrap.hh"
48 #include "G4TwoVector.hh"
49 
50 class G4Polyhedron;
51 
52 class G4UGenericTrap : public G4USolid
53 {
54  public: // with description
55 
56  G4UGenericTrap(const G4String& name, G4double halfZ,
57  const std::vector<G4TwoVector>& vertices);
58 
60 
61  inline UGenericTrap* GetShape() const;
62 
63  inline G4double GetZHalfLength() const;
64  inline G4int GetNofVertices() const;
65  inline G4TwoVector GetVertex(G4int index) const;
66  inline const std::vector<G4TwoVector>& GetVertices() const;
67  inline G4double GetTwistAngle(G4int index) const;
68  inline G4bool IsTwisted() const;
69  inline G4int GetVisSubdivisions() const;
70  inline void SetVisSubdivisions(G4int subdiv);
71  inline void SetZHalfLength(G4double);
72 
73  public: // without description
74 
75  G4UGenericTrap(__void__&);
76  // Fake default constructor for usage restricted to direct object
77  // persistency for clients requiring preallocation of memory for
78  // persistifiable objects.
79 
80  G4UGenericTrap( const G4UGenericTrap& source );
81  G4UGenericTrap &operator=(const G4UGenericTrap& source);
82  // Copy constructor and assignment operator.
83 
85 };
86 
87 // --------------------------------------------------------------------
88 // Inline methods
89 // --------------------------------------------------------------------
90 
92 {
93  return (UGenericTrap*) fShape;
94 }
95 
97 {
98  return GetShape()->GetZHalfLength();
99 }
101 {
102  return GetShape()->GetNofVertices();
103 }
105 {
106  UVector2 v = GetShape()->GetVertex(index);
107  return G4TwoVector(v.x, v.y);
108 }
109 inline const std::vector<G4TwoVector>& G4UGenericTrap::GetVertices() const
110 {
111  std::vector<UVector2> v = GetShape()->GetVertices();
112  static std::vector<G4TwoVector> vertices; vertices.clear();
113  for (size_t n=0; n<v.size(); ++n)
114  {
115  vertices.push_back(G4TwoVector(v[n].x,v[n].y));
116  }
117  return vertices;
118 }
120 {
121  return GetShape()->GetTwistAngle(index);
122 }
124 {
125  return GetShape()->IsTwisted();
126 }
128 {
129  return GetShape()->GetVisSubdivisions();
130 }
131 
133 {
134  GetShape()->SetVisSubdivisions(subdiv);
135 }
136 
138 {
139  GetShape()->SetZHalfLength(halfZ);
140 }
141 
142 #endif
G4Polyhedron * CreatePolyhedron() const
const std::vector< G4TwoVector > & GetVertices() const
void SetZHalfLength(double)
UGenericTrap * GetShape() const
G4double GetZHalfLength() const
G4TwoVector GetVertex(G4int index) const
G4int GetVisSubdivisions() const
G4String name
Definition: TRTMaterials.hh:40
void SetVisSubdivisions(int subdiv)
G4UGenericTrap(const G4String &name, G4double halfZ, const std::vector< G4TwoVector > &vertices)
int G4int
Definition: G4Types.hh:78
int GetNofVertices() const
VUSolid * fShape
Definition: G4USolid.hh:182
int GetVisSubdivisions() const
bool IsTwisted() const
bool G4bool
Definition: G4Types.hh:79
void SetVisSubdivisions(G4int subdiv)
const G4int n
const std::vector< UVector2 > & GetVertices() const
G4int GetNofVertices() const
double x
Definition: UVector2.hh:195
void SetZHalfLength(G4double)
double GetTwistAngle(int index) const
G4UGenericTrap & operator=(const G4UGenericTrap &source)
G4double GetTwistAngle(G4int index) const
CLHEP::Hep2Vector G4TwoVector
Definition: G4TwoVector.hh:42
double G4double
Definition: G4Types.hh:76
G4bool IsTwisted() const
UVector2 GetVertex(int index) const
double y
Definition: UVector2.hh:196
double GetZHalfLength() const