Geant4  10.02.p02
G4UTet.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 intellectual property of the *
19 // * Vanderbilt University Free Electron Laser Center *
20 // * Vanderbilt University, Nashville, TN, USA *
21 // * Development supported by: *
22 // * United States MFEL program under grant FA9550-04-1-0045 *
23 // * and NASA under contract number NNG04CT05P *
24 // * Written by Marcus H. Mendenhall and Robert A. Weller. *
25 // * *
26 // * Contributed to the Geant4 Core, January, 2005. *
27 // * *
28 // ********************************************************************
29 //
30 // $Id:$
31 //
32 //
33 // Implementation for G4UTet wrapper class
34 // --------------------------------------------------------------------
35 
36 #include "G4Tet.hh"
37 #include "G4UTet.hh"
38 
39 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
40 
42 //
43 // Constructor - create a tetrahedron
44 // This class is implemented separately from general polyhedra,
45 // because the simplex geometry can be computed very quickly,
46 // which may become important in situations imported from mesh generators,
47 // in which a very large number of G4Tets are created.
48 // A Tet has all of its geometrical information precomputed
49 //
50 G4UTet::G4UTet(const G4String& pName,
51  G4ThreeVector anchor,
52  G4ThreeVector p2,
53  G4ThreeVector p3,
54  G4ThreeVector p4, G4bool* degeneracyFlag)
55  : G4USolid(pName, new UTet(pName,
56  UVector3(anchor.x(),anchor.y(),anchor.z()),
57  UVector3(p2.x(), p2.y(), p2.z()),
58  UVector3(p3.x(), p3.y(), p3.z()),
59  UVector3(p4.x(), p4.y(), p4.z()),
60  degeneracyFlag))
61 {
62 }
63 
65 //
66 // Fake default constructor - sets only member data and allocates memory
67 // for usage restricted to object persistency.
68 //
69 G4UTet::G4UTet( __void__& a )
70  : G4USolid(a)
71 {
72 }
73 
75 //
76 // Destructor
77 //
78 G4UTet::~G4UTet()
79 {
80 }
81 
83 //
84 // Copy constructor
85 //
86 G4UTet::G4UTet(const G4UTet& rhs)
87  : G4USolid(rhs)
88 {
89 }
90 
91 
93 //
94 // Assignment operator
95 //
96 G4UTet& G4UTet::operator = (const G4UTet& rhs)
97 {
98  // Check assignment to self
99  //
100  if (this == &rhs) { return *this; }
101 
102  // Copy base class data
103  //
104  G4USolid::operator=(rhs);
105 
106  return *this;
107 }
108 
110 //
111 // Accessors
112 //
113 std::vector<G4ThreeVector> G4UTet::GetVertices() const
114 {
115  std::vector<UVector3> vec = GetShape()->GetVertices();
116  std::vector<G4ThreeVector> vertices;
117  for (unsigned int i=0; i<vec.size(); ++i)
118  {
119  G4ThreeVector v(vec[i].x(), vec[i].y(), vec[i].z());
120  vertices.push_back(v);
121  }
122  return vertices;
123 }
124 
126 //
127 // CreatePolyhedron
128 //
129 G4Polyhedron* G4UTet::CreatePolyhedron() const
130 {
131  G4int index = 0;
132  G4double array[12];
133  GetShape()->GetParametersList(index, array);
134 
135  G4Polyhedron *ph=new G4Polyhedron;
136  G4double xyz[4][3];
137  const G4int faces[4][4]={{1,3,2,0},{1,4,3,0},{1,2,4,0},{2,3,4,0}};
138  xyz[0][0]=array[0]; xyz[0][1]=array[1]; xyz[0][2]=array[2]; // fAnchor
139  xyz[1][0]=array[3]; xyz[1][1]=array[4]; xyz[1][2]=array[5]; // fP2
140  xyz[2][0]=array[6]; xyz[2][1]=array[7]; xyz[2][2]=array[8]; // fP3
141  xyz[3][0]=array[9]; xyz[3][1]=array[10]; xyz[3][2]=array[11]; // fP4
142 
143  ph->createPolyhedron(4,4,xyz,faces);
144 
145  return ph;
146 }
147 
148 #endif // G4GEOM_USE_USOLIDS
CLHEP::Hep3Vector G4ThreeVector
G4double z
Definition: TRTMaterials.hh:39
G4double a
Definition: TRTMaterials.hh:39
int G4int
Definition: G4Types.hh:78
bool G4bool
Definition: G4Types.hh:79
const G4double x[NPOINTSGL]
double G4double
Definition: G4Types.hh:76