34#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
56 : Base_t(pName, U3Vector(anchor.x(),anchor.y(),anchor.z()),
57 U3Vector(p1.x(), p1.y(), p1.z()),
58 U3Vector(p2.x(), p2.y(), p2.z()),
59 U3Vector(p3.x(), p3.y(), p3.z()))
62 G4bool degenerate = CheckDegeneracy(anchor, p1, p2, p3);
63 if(degeneracyFlag !=
nullptr) *degeneracyFlag = degenerate;
67 "Degenerate tetrahedron not allowed.");
71 for (
G4int i = 0; i < 3; ++i)
73 fBmin[i] = std::min(std::min(std::min(anchor[i], p1[i]), p2[i]), p3[i]);
74 fBmax[i] = std::max(std::max(std::max(anchor[i], p1[i]), p2[i]), p3[i]);
82G4UTet::G4UTet(
const G4UTet& rhs)
94G4UTet& G4UTet::operator = (
const G4UTet& rhs)
97 if (
this == &rhs) {
return *
this; }
100 Base_t::operator=(rhs);
123 G4double vol = std::abs((p1 - p0).cross(p2 - p0).dot(p3 - p0));
127 ss[0] = ((p1 - p0).cross(p2 - p0)).mag2();
128 ss[1] = ((p2 - p0).cross(p3 - p0)).mag2();
129 ss[2] = ((p3 - p0).cross(p1 - p0)).mag2();
130 ss[3] = ((p2 - p1).cross(p3 - p1)).mag2();
134 for (
G4int i = 1; i < 4; ++i) {
if (ss[i] > ss[k]) k = i; }
137 return (vol*vol <= ss[k]*hmin*hmin);
157 return new G4UTet(*
this);
171 G4bool degenerate = CheckDegeneracy(anchor, p1, p2, p3);
172 if(degeneracyFlag !=
nullptr) *degeneracyFlag = degenerate;
176 "Degenerate tetrahedron not allowed.");
180 *
this = G4UTet(GetName(), anchor, p1, p2, p3, °enerate);
192 std::vector<U3Vector> vec(4);
193 Base_t::GetVertices(vec[0], vec[1], vec[2], vec[3]);
200std::vector<G4ThreeVector> G4UTet::GetVertices()
const
202 std::vector<U3Vector> vec(4);
203 Base_t::GetVertices(vec[0], vec[1], vec[2], vec[3]);
204 std::vector<G4ThreeVector> vertices;
205 for (
unsigned int i=0; i<4; ++i)
208 vertices.push_back(v);
221 GetVertices(fVertex[0], fVertex[1], fVertex[2], fVertex[3]);
223 G4int iout[4] = { 0, 0, 0, 0 };
224 for (
G4int i = 0; i < 4; ++i)
226 iout[i] = (
G4int)(fVertex[i].x() < pMin.
x() ||
227 fVertex[i].y() < pMin.
y() ||
228 fVertex[i].z() < pMin.
z() ||
229 fVertex[i].x() > pMax.
x() ||
230 fVertex[i].y() > pMax.
y() ||
231 fVertex[i].z() > pMax.
z());
233 if (iout[0] + iout[1] + iout[2] + iout[3] != 0)
235 std::ostringstream message;
236 message <<
"Attempt to set bounding box that does not encapsulate solid: "
237 << GetName() <<
" !\n"
238 <<
" Specified bounding box limits:\n"
239 <<
" pmin: " << pMin <<
"\n"
240 <<
" pmax: " << pMax <<
"\n"
241 <<
" Tetrahedron vertices:\n"
242 <<
" anchor " << fVertex[0] << ((iout[0]) != 0 ?
" is outside\n" :
"\n")
243 <<
" p1 " << fVertex[1] << ((iout[1]) != 0 ?
" is outside\n" :
"\n")
244 <<
" p2 " << fVertex[2] << ((iout[2]) != 0 ?
" is outside\n" :
"\n")
245 <<
" p3 " << fVertex[3] << ((iout[3]) != 0 ?
" is outside" :
"");
246 G4Exception(
"G4UTet::SetBoundingLimits()",
"GeomSolids0002",
268G4UTet::CalculateExtent(
const EAxis pAxis,
277 BoundingLimits(bmin,bmax);
282 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
288 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
290 return exist = (pMin < pMax) ?
true : false;
295 std::vector<G4ThreeVector> vec = GetVertices();
305 std::vector<const G4ThreeVectorList *> polygons(2);
306 polygons[0] = &anchor;
310 return exists = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
320 std::vector<U3Vector> vec(4);
321 Base_t::GetVertices(vec[0], vec[1], vec[2], vec[3]);
324 const G4int faces[4][4] = {{1,3,2,0},{1,4,3,0},{1,2,4,0},{2,3,4,0}};
325 for (
unsigned int i=0; i<4; ++i)
327 xyz[i][0] = vec[i].x();
328 xyz[i][1] = vec[i].y();
329 xyz[i][2] = vec[i].z();
const G4double kCarTolerance
std::vector< G4ThreeVector > G4ThreeVectorList
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
CLHEP::Hep3Vector G4ThreeVector
G4BoundingEnvelope is a helper class to facilitate calculation of the extent of a solid within the li...
G4VPVParameterisation ia an abstract base class for Parameterisation, able to compute the transformat...
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
G4VSolid is an abstract base class for solids, physical shapes that can be tracked through....
G4VoxelLimits represents limitation/restrictions of space, where restrictions are only made perpendic...
G4int createPolyhedron(G4int Nnodes, G4int Nfaces, const G4double xyz[][3], const G4int faces[][4])
bool exists(std::string const &a_path)