Geant4  10.02.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 
48 #if defined(G4GEOM_USE_USOLIDS)
49 
50 #include "UGenericTrap.hh"
51 #include "G4TwoVector.hh"
52 
53 class G4Polyhedron;
54 
55 class G4UGenericTrap : public G4USolid
56 {
57  public: // with description
58 
59  G4UGenericTrap(const G4String& name, G4double halfZ,
60  const std::vector<G4TwoVector>& vertices);
61 
62  ~G4UGenericTrap();
63 
64  inline UGenericTrap* GetShape() const;
65 
66  inline G4double GetZHalfLength() const;
67  inline G4int GetNofVertices() const;
68  inline G4TwoVector GetVertex(G4int index) const;
69  inline const std::vector<G4TwoVector>& GetVertices() const;
70  inline G4double GetTwistAngle(G4int index) const;
71  inline G4bool IsTwisted() const;
72  inline G4int GetVisSubdivisions() const;
73  inline void SetVisSubdivisions(G4int subdiv);
74  inline void SetZHalfLength(G4double);
75 
76  public: // without description
77 
78  G4UGenericTrap(__void__&);
79  // Fake default constructor for usage restricted to direct object
80  // persistency for clients requiring preallocation of memory for
81  // persistifiable objects.
82 
83  G4UGenericTrap( const G4UGenericTrap& source );
84  G4UGenericTrap &operator=(const G4UGenericTrap& source);
85  // Copy constructor and assignment operator.
86 
87  G4Polyhedron* CreatePolyhedron() const;
88 };
89 
90 // --------------------------------------------------------------------
91 // Inline methods
92 // --------------------------------------------------------------------
93 
94 inline UGenericTrap* G4UGenericTrap::GetShape() const
95 {
96  return (UGenericTrap*) fShape;
97 }
98 
99 inline G4double G4UGenericTrap::GetZHalfLength() const
100 {
101  return GetShape()->GetZHalfLength();
102 }
103 inline G4int G4UGenericTrap::GetNofVertices() const
104 {
105  return GetShape()->GetNofVertices();
106 }
107 inline G4TwoVector G4UGenericTrap::GetVertex(G4int index) const
108 {
109  UVector2 v = GetShape()->GetVertex(index);
110  return G4TwoVector(v.x, v.y);
111 }
112 inline const std::vector<G4TwoVector>& G4UGenericTrap::GetVertices() const
113 {
114  std::vector<UVector2> v = GetShape()->GetVertices();
115  static std::vector<G4TwoVector> vertices; vertices.clear();
116  for (size_t n=0; n<v.size(); ++n)
117  {
118  vertices.push_back(G4TwoVector(v[n].x,v[n].y));
119  }
120  return vertices;
121 }
122 inline G4double G4UGenericTrap::GetTwistAngle(G4int index) const
123 {
124  return GetShape()->GetTwistAngle(index);
125 }
126 inline G4bool G4UGenericTrap::IsTwisted() const
127 {
128  return GetShape()->IsTwisted();
129 }
130 inline G4int G4UGenericTrap::GetVisSubdivisions() const
131 {
132  return GetShape()->GetVisSubdivisions();
133 }
134 
135 inline void G4UGenericTrap::SetVisSubdivisions(G4int subdiv)
136 {
137  GetShape()->SetVisSubdivisions(subdiv);
138 }
139 
140 inline void G4UGenericTrap::SetZHalfLength(G4double halfZ)
141 {
142  GetShape()->SetZHalfLength(halfZ);
143 }
144 
145 #endif // G4GEOM_USE_USOLIDS
146 
147 #endif
G4String name
Definition: TRTMaterials.hh:40
int G4int
Definition: G4Types.hh:78
bool G4bool
Definition: G4Types.hh:79
const G4int n
const G4double x[NPOINTSGL]
CLHEP::Hep2Vector G4TwoVector
Definition: G4TwoVector.hh:42
double G4double
Definition: G4Types.hh:76