50 double signed_vol = fV21.
Cross(fV31).
Dot(fV41);
85 if (degeneracyFlag) *degeneracyFlag = degenerate;
89 "Degenerate tetrahedron not allowed.");
92 fTol = 1e-9 * (std::fabs(
fXMin) + std::fabs(fXMax) + std::fabs(fYMin)
93 + std::fabs(fYMax) + std::fabs(fZMin) + std::fabs(fZMax));
101 UVector3 fCenter123 = (anchor + p2 + p3) * (1.0 / 3.0);
102 UVector3 fCenter134 = (anchor + p4 + p3) * (1.0 / 3.0);
103 UVector3 fCenter142 = (anchor + p4 +
p2) * (1.0 / 3.0);
104 UVector3 fCenter234 = (p2 + p3 + p4) * (1.0 / 3.0);
138 :
VUSolid(
""), fCubicVolume(0.), fSurfaceArea(0.),
139 fAnchor(0,0,0), fP2(0,0,0), fP3(0,0,0), fP4(0,0,0), fMiddle(0,0,0),
140 fNormal123(0,0,0), fNormal142(0,0,0), fNormal134(0,0,0),
141 fNormal234(0,0,0), warningFlag(0),
142 fCdotN123(0.), fCdotN142(0.), fCdotN134(0.), fCdotN234(0.),
143 fXMin(0.), fXMax(0.), fYMin(0.), fYMax(0.), fZMin(0.), fZMax(0.),
144 fDx(0.), fDy(0.), fDz(0.), fTol(0.), fMaxSize(0.)
162 fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea),
163 fAnchor(rhs.fAnchor),
164 fP2(rhs.fP2), fP3(rhs.fP3), fP4(rhs.fP4), fMiddle(rhs.fMiddle),
165 fNormal123(rhs.fNormal123), fNormal142(rhs.fNormal142),
166 fNormal134(rhs.fNormal134), fNormal234(rhs.fNormal234),
167 warningFlag(rhs.warningFlag), fCdotN123(rhs.fCdotN123),
168 fCdotN142(rhs.fCdotN142), fCdotN134(rhs.fCdotN134),
169 fCdotN234(rhs.fCdotN234), fXMin(rhs.fXMin), fXMax(rhs.fXMax),
170 fYMin(rhs.fYMin), fYMax(rhs.fYMax), fZMin(rhs.fZMin), fZMax(rhs.fZMax),
171 fDx(rhs.fDx), fDy(rhs.fDy), fDz(rhs.fDz), fTol(rhs.fTol),
172 fMaxSize(rhs.fMaxSize)
192 VUSolid::operator=(rhs);
233 double r123, r134, r142, r234;
245 else if ((r123 < -
fTol) && (r134 < -
fTol) && (r142 < -
fTol) && (r234 < -
fTol))
269 static const double delta = 0.5 *
fTol;
312 if ((r123 <= r134) && (r123 <= r142) && (r123 <= r234))
316 else if ((r134 <= r142) && (r134 <= r234))
320 else if (r142 <= r234)
343 double extraDistance = 10.0 *
fTol;
350 if ((t >= -
fTol) && (t < tmin))
353 hp = p + vu * (t + extraDistance);
368 if ((t >= -
fTol) && (t < tmin))
371 hp = p + vu * (t + extraDistance);
386 if ((t >= -
fTol) && (t < tmin))
389 hp = p + vu * (t + extraDistance);
404 if ((t >= -
fTol) && (t < tmin))
407 hp = p + vu * (t + extraDistance);
438 UVector3&
n,
bool& convex,
double )
const
472 std::ostringstream message;
473 message <<
"No good intersection found or already outside!?" << std::endl
474 <<
"p = " << p << std::endl
475 <<
"v = " << v << std::endl
477 << t1 <<
", " << t2 <<
", " << t3 <<
", " << t4;
480 UWarning, 1, message.str().c_str());
522 double t1, t2, t3, t4;
532 return (tmin <
fTol) ? 0 : tmin;
542 int oldprc = os.precision(16);
543 os <<
"-----------------------------------------------------------\n"
544 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
545 <<
" ===================================================\n"
546 <<
" Solid type: UTet\n"
548 <<
" anchor: " <<
fAnchor <<
" \n"
549 <<
" p2: " <<
fP2 <<
" \n"
550 <<
" p3: " <<
fP3 <<
" \n"
551 <<
" p4: " <<
fP4 <<
" \n"
556 <<
"-----------------------------------------------------------\n";
557 os.precision(oldprc);
572 double lambda1, lambda2;
581 area = 0.5 * (v.
Cross(w)).Mag();
582 return (p2 + lambda1 * w + lambda2 * v);
591 double chose, aOne, aTwo, aThree, aFour;
600 if ((chose >= 0.) && (chose < aOne))
604 else if ((chose >= aOne) && (chose < aOne + aTwo))
608 else if ((chose >= aOne + aTwo) && (chose < aOne + aTwo + aThree))
621 std::vector<UVector3> vertices(4);
653 aArray[10] =
fP4.
y();
654 aArray[11] =
fP4.
z();
659 return new UTet(*
this);
UVector3 GetPointOnSurface() const
const std::string & GetName() const
UVector3 Cross(const UVector3 &) const
UGeometryType GetEntityType() const
double DistanceToIn(const UVector3 &aPoint, const UVector3 &aDirection, double aPstep=UUtils::kInfinity) const
void Extent(UVector3 &aMin, UVector3 &aMax) const
static double normal(HepRandomEngine *eptr)
bool Normal(const UVector3 &aPoint, UVector3 &aNormal) const
static const double kInfinity
double SafetyFromOutside(const UVector3 &aPoint, bool aAccurate=false) const
std::ostream & StreamInfo(std::ostream &os) const
double DistanceToOut(const UVector3 &aPoint, const UVector3 &aDirection, UVector3 &aNormalVector, bool &aConvex, double aPstep=UUtils::kInfinity) const
UTet & operator=(const UTet &rhs)
double Dot(const UVector3 &) const
double SafetyFromInside(const UVector3 &aPoint, bool aAccurate=false) const
void GetParametersList(int aNumber, double *aArray) const
std::vector< UVector3 > GetVertices() const
void Exception(const char *originOfException, const char *exceptionCode, UExceptionSeverity severity, int level, const char *description)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
UVector3 GetPointOnFace(UVector3 p1, UVector3 p2, UVector3 p3, double &area) const
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
std::string UGeometryType
UTet(const std::string &name, UVector3 anchor, UVector3 p2, UVector3 p3, UVector3 p4, bool *degeneracyFlag=0)
EnumInside Inside(const UVector3 &p) const
double Random(double min=0.0, double max=1.0)