Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4UTet.cc
이 파일의 문서화 페이지로 가기
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 #if 0
38 #include "G4UTet.hh"
39 
40 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
41 
42 #include "G4AffineTransform.hh"
43 #include "G4VPVParameterisation.hh"
44 #include "G4BoundingEnvelope.hh"
45 
46 using namespace CLHEP;
47 
49 //
50 // Constructor - create a tetrahedron
51 // This class is implemented separately from general polyhedra,
52 // because the simplex geometry can be computed very quickly,
53 // which may become important in situations imported from mesh generators,
54 // in which a very large number of G4Tets are created.
55 // A Tet has all of its geometrical information precomputed
56 //
57 G4UTet::G4UTet(const G4String& pName,
58  G4ThreeVector anchor,
59  G4ThreeVector p2,
60  G4ThreeVector p3,
61  G4ThreeVector p4, G4bool* degeneracyFlag)
62  : G4USolid(pName, new UTet(pName,
63  UVector3(anchor.x(),anchor.y(),anchor.z()),
64  UVector3(p2.x(), p2.y(), p2.z()),
65  UVector3(p3.x(), p3.y(), p3.z()),
66  UVector3(p4.x(), p4.y(), p4.z()),
67  degeneracyFlag))
68 {
69 }
70 
72 //
73 // Fake default constructor - sets only member data and allocates memory
74 // for usage restricted to object persistency.
75 //
76 G4UTet::G4UTet( __void__& a )
77  : G4USolid(a)
78 {
79 }
80 
82 //
83 // Destructor
84 //
85 G4UTet::~G4UTet()
86 {
87 }
88 
90 //
91 // Copy constructor
92 //
93 G4UTet::G4UTet(const G4UTet& rhs)
94  : G4USolid(rhs)
95 {
96 }
97 
98 
100 //
101 // Assignment operator
102 //
103 G4UTet& G4UTet::operator = (const G4UTet& rhs)
104 {
105  // Check assignment to self
106  //
107  if (this == &rhs) { return *this; }
108 
109  // Copy base class data
110  //
111  G4USolid::operator=(rhs);
112 
113  return *this;
114 }
115 
117 //
118 // Accessors
119 //
120 std::vector<G4ThreeVector> G4UTet::GetVertices() const
121 {
122  std::vector<UVector3> vec = GetShape()->GetVertices();
123  std::vector<G4ThreeVector> vertices;
124  for (unsigned int i=0; i<vec.size(); ++i)
125  {
126  G4ThreeVector v(vec[i].x(), vec[i].y(), vec[i].z());
127  vertices.push_back(v);
128  }
129  return vertices;
130 }
131 
133 //
134 // Get bounding box
135 
136 void G4UTet::BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const
137 {
138  UVector3 vmin, vmax;
139  GetShape()->Extent(vmin,vmax);
140  pMin.set(vmin.x(),vmin.y(),vmin.z());
141  pMax.set(vmax.x(),vmax.y(),vmax.z());
142 
143  // Check correctness of the bounding box
144  //
145  if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
146  {
147  std::ostringstream message;
148  message << "Bad bounding box (min >= max) for solid: "
149  << GetName() << " !"
150  << "\npMin = " << pMin
151  << "\npMax = " << pMax;
152  G4Exception("G4UTet::BoundingLimits()", "GeomMgt0001",
153  JustWarning, message);
154  StreamInfo(G4cout);
155  }
156 }
157 
159 //
160 // Calculate extent under transform and specified limit
161 
162 G4bool
163 G4UTet::CalculateExtent(const EAxis pAxis,
164  const G4VoxelLimits& pVoxelLimit,
165  const G4AffineTransform& pTransform,
166  G4double& pMin, G4double& pMax) const
167 {
168  G4ThreeVector bmin, bmax;
169  G4bool exist;
170 
171  // Check bounding box (bbox)
172  //
173  BoundingLimits(bmin,bmax);
174  G4BoundingEnvelope bbox(bmin,bmax);
175 #ifdef G4BBOX_EXTENT
176  if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
177 #endif
178  if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
179  {
180  return exist = (pMin < pMax) ? true : false;
181  }
182 
183  // Set bounding envelope (benv) and calculate extent
184  //
185  std::vector<UVector3> vec = GetShape()->GetVertices();
186 
187  G4ThreeVectorList anchor(1);
188  anchor[0].set(vec[0].x(),vec[0].y(),vec[0].z());
189 
191  base[0].set(vec[1].x(),vec[1].y(),vec[1].z());
192  base[1].set(vec[2].x(),vec[2].y(),vec[2].z());
193  base[2].set(vec[3].x(),vec[3].y(),vec[3].z());
194 
195  std::vector<const G4ThreeVectorList *> polygons(2);
196  polygons[0] = &anchor;
197  polygons[1] = &base;
198 
199  G4BoundingEnvelope benv(bmin,bmax,polygons);
200  exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
201  return exist;
202 }
203 
205 //
206 // CreatePolyhedron
207 //
208 G4Polyhedron* G4UTet::CreatePolyhedron() const
209 {
210  G4int index = 0;
211  G4double array[12];
212  GetShape()->GetParametersList(index, array);
213 
214  G4Polyhedron *ph=new G4Polyhedron;
215  G4double xyz[4][3];
216  const G4int faces[4][4]={{1,3,2,0},{1,4,3,0},{1,2,4,0},{2,3,4,0}};
217  xyz[0][0]=array[0]; xyz[0][1]=array[1]; xyz[0][2]=array[2]; // fAnchor
218  xyz[1][0]=array[3]; xyz[1][1]=array[4]; xyz[1][2]=array[5]; // fP2
219  xyz[2][0]=array[6]; xyz[2][1]=array[7]; xyz[2][2]=array[8]; // fP3
220  xyz[3][0]=array[9]; xyz[3][1]=array[10]; xyz[3][2]=array[11]; // fP4
221 
222  ph->createPolyhedron(4,4,xyz,faces);
223 
224  return ph;
225 }
226 
227 #endif // G4GEOM_USE_USOLIDS
228 #endif
Float_t x
Definition: compare.C:6
void set(double x, double y, double z)
G4int createPolyhedron(G4int Nnodes, G4int Nfaces, const G4double xyz[][3], const G4int faces[][4])
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
Float_t y
Definition: compare.C:6
Double_t z
void message(RunManager *runmanager)
Definition: ts_scorers.cc:72
double z() const
const XML_Char int const XML_Char int const XML_Char * base
Definition: expat.h:331
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
std::vector< G4ThreeVector > G4ThreeVectorList
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
int G4int
Definition: G4Types.hh:78
EAxis
Definition: geomdefs.hh:54
G4GLOB_DLL std::ostream G4cout
double x() const
double y() const