33     numFace(0), faces(0), fCubicVolume(0.), fSurfaceArea(0.),
 
   34     fMaxSection(0),fBoxShift(0.), fNoVoxels(true),fStatistics(1000000), fCubVolEpsilon(0.001), fAreaAccuracy(-1.)
 
   72   VUSolid::operator=(source);
 
  102               **sourceFace = source.
faces;
 
  105     *face = (*sourceFace)->
Clone();
 
  218   const vector<int>& candidates = 
fCandidates[index];
 
  219   int size = candidates.size();
 
  220   for (
int i = 0; i < size; ++i)
 
  222     int candidate = candidates[i];
 
  223     if (!bits[candidate])
 
  228       normal = face.
Normal(p, &distance);
 
  284     double   faceDistance, faceDistFromSurface;
 
  286     if ((*face)->Distance(p, v, 
false, htol,
 
  287                           faceDistance, faceDistFromSurface,
 
  288                           faceNormal, faceAllBehind))
 
  293       if (faceDistance < distance)
 
  295         distance = faceDistance;
 
  296         distFromSurface = faceDistFromSurface;
 
  298         if (distFromSurface <= 0)
 
  309     if (bestFace->
Safety(p, 
false) < htol)
 
  327   bool allBehind = 
true;
 
  336     double faceDistance, faceDistFromSurface;
 
  339                           faceDistance, faceDistFromSurface,
 
  340                           faceNormal, faceAllBehind))
 
  347       if (faceDistance < distance)
 
  349         distance = faceDistance;
 
  350         distFromSurface = faceDistFromSurface;
 
  353         if (distFromSurface <= 0)
 
  364     if (distFromSurface <= 0)
 
  401                                 const bool outgoing)
 const 
  407     double distance = (*face)->Safety(p, outgoing);
 
  408     if (distance < best)  best = distance;
 
  420   return std::string(
"UCSGfaceted");
 
  429   os << 
"-----------------------------------------------------------\n" 
  430      << 
"                *** Dump for solid - " << 
GetName() << 
" ***\n" 
  431      << 
"                ===================================================\n" 
  432      << 
" Solid type: UVCSGfaceted\n" 
  434      << 
"                number of faces: " << 
numFace << 
"\n" 
  435      << 
"-----------------------------------------------------------\n";
 
  562   std::vector<double> areas;
 
  569     areas.push_back(result);
 
  570     area = area + result;
 
  578   double Achose1, Achose2;
 
  586     if (chose >= Achose1 && chose < Achose2)
 
  589       point = (*face1)->GetPointOnFace();
 
  619   vector<double> r(size), 
z(size), zs;
 
  623   for (
int i = 0; i < size; ++i)
 
  626     if (std::find(
fZs.begin(), 
fZs.end(), v) == 
fZs.end())
 
  630     std::sort(
fZs.begin(), 
fZs.end());
 
  638     vector<int> candidates;
 
  641     double middle = (left + 
right) / 2;
 
  656   for (
int j = 0; j < 
numFace; j++)
 
  663       if (!sides || std::fabs(minZ - maxZ) < 
fgTolerance * 10)
 
  664         if (std::find(candidates.begin(), candidates.end(), j) == candidates.end())
 
  665           candidates.push_back(j);
 
  677   double idistance, shift;
 
  690   double z = p.
z + idistance * v.
z;
 
  692   int increment = (v.
z > 0) ? 1 : -1;
 
  703     const vector<int>& candidates = 
fCandidates[index];
 
  704     int size = candidates.size();
 
  705     for (
int i = 0; i < size; ++i)
 
  707       int candidate = candidates[i];
 
  708       if (!bits[candidate])
 
  717                           faceDistance, faceDistFromSurface,
 
  718                           faceNormal, faceAllBehind))
 
  721           if (faceDistance < distance)
 
  723             distance = faceDistance;
 
  724             distFromSurface = faceDistFromSurface;
 
  726             if (distFromSurface <= 0) 
return 0;
 
  738     int newz = increment > 0 ? index  : index + 1;
 
  739     shift = (
fZs[newz] - 
z) / v.
z;
 
  741   while (idistance + shift < distance);
 
  761   int increment = (v.
z > 0) ? 1 : -1;
 
  763   bool allBehind = 
true;
 
  774     const vector<int>& candidates = 
fCandidates[index];
 
  775     int size = candidates.size();
 
  776     for (
int i = 0; i < size; ++i)
 
  778       int candidate = candidates[i];
 
  779       if (!bits[candidate])
 
  784         double faceDistance, faceDistFromSurface;
 
  787                            faceNormal, faceAllBehind)))
 
  794           if (faceDistance < distance)
 
  796             distance = faceDistance;
 
  797             distFromSurface = faceDistFromSurface;
 
  800             if (distFromSurface <= 0) 
break;
 
  806     if (distFromSurface <= 0) 
break;
 
  807     if (!increment) 
break;
 
  812     int newz = increment > 0 ? index  : index + 1;
 
  813     shift = (
fZs[newz] - p.
z) / v.
z;
 
  815   while (shift < distance);
 
  819     if (distFromSurface <= 0)
 
  863     const vector<int>& candidates = 
fCandidates[index];
 
  864     int size = candidates.size();
 
  865     for (
int i = 0; i < size; ++i)
 
  867       int candidate = candidates[i];
 
  868       if (!bits[candidate])
 
  888         shift = 
fZs[index + 1] - p.
z;
 
  889         if (shift < best) 
continue;
 
  894     shift = p.
z - 
fZs[index];
 
  896   while (shift > best);
 
  905   const vector<int>& candidates = 
fCandidates[index];
 
  906   int size = candidates.size();
 
  907   for (
int i = 0; i < size; ++i)
 
  909     int candidate = candidates[i];
 
  910     if (!bits[candidate])
 
  915       double distance = face.
Safety(p, 
true);
 
  916       if (distance < best)  best = distance;
 
  933   if (minSafety < 1e-6) 
return 0;
 
  935   double zbase = 
fZs[index + 1];
 
  938     double dz = 
fZs[i] - zbase;
 
  939     if (dz >= minSafety) 
break;
 
  941     if (safety < minSafety) minSafety = safety;
 
  946     zbase = 
fZs[index - 1];
 
  947     for (
int i = index - 1; i >= 0; --i)
 
  949       double dz = zbase - 
fZs[i];
 
  950       if (dz >= minSafety) 
break;
 
  952       if (safety < minSafety) minSafety = safety;
 
void SetCubVolStatistics(int st)
 
double DistanceTo(const UVector3 &p, const bool outgoing) const 
 
virtual bool Distance(const UVector3 &p, const UVector3 &v, bool outgoing, double surfTolerance, double &distance, double &distFromSurface, UVector3 &normal, bool &allBehind)=0
 
const std::string & GetName() const 
 
static double fgTolerance
 
virtual bool Normal(const UVector3 &p, UVector3 &n) const 
 
void FindCandidates(double z, std::vector< int > &candidates, bool sides=false)
 
double EstimateCubicVolume(int nStat, double epsilon) const 
 
double DistanceToOutNoVoxels(const UVector3 &p, const UVector3 &v, UVector3 &n, bool &aConvex) const 
 
void SetAreaStatistics(int st)
 
void CopyVertices(double a[], double b[]) const 
 
double EstimateSurfaceArea(int nStat, double ell) const 
 
virtual UVCSGface * Clone()=0
 
int GetCubVolStatistics() const 
 
static double normal(HepRandomEngine *eptr)
 
virtual double SafetyFromInsideNoVoxels(const UVector3 &aPoint, bool aAccurate=false) const 
 
void SetCubVolEpsilon(double ep)
 
std::vector< double > fZs
 
virtual VUSolid::EnumInside Inside(const UVector3 &p, double tolerance, double *bestDistance)=0
 
static int BinarySearch(const std::vector< T > &vec, T value)
 
static const double kInfinity
 
void InitVoxels(UReduciblePolygon &z, double radius)
 
void SetAreaAccuracy(double ep)
 
UVCSGfaceted & operator=(const UVCSGfaceted &source)
 
int GetSection(double z) const 
 
virtual double Capacity()
 
virtual double Safety(const UVector3 &p, bool outgoing)=0
 
void SetBitNumber(unsigned int bitnumber, bool value=true)
 
double DistanceToIn(const UVector3 &aPoint, const UVector3 &aDirection, double aPstep=UUtils::kInfinity) const 
 
static const G4double minSafety
 
double GetZHalfLength() const 
 
virtual double SurfaceArea()
 
double SafetyFromInsideSection(int index, const UVector3 &p, UBits &bits) const 
 
virtual double Extent(const UVector3 axis)=0
 
double DistanceToInNoVoxels(const UVector3 &p, const UVector3 &v) const 
 
std::vector< std::vector< int > > fCandidates
 
void Set(double dx, double dy, double dz)
 
virtual UVector3 Normal(const UVector3 &p, double *bestDistance)=0
 
std::string UGeometryType
 
double SafetyFromOutside(const UVector3 &aPoint, bool aAccurate=false) const 
 
UVCSGfaceted(const std::string &name)
 
virtual double SurfaceArea()=0
 
void CopyStuff(const UVCSGfaceted &source)
 
UVector3 GetPointOnSurfaceGeneric() const 
 
virtual double SafetyFromOutside(const UVector3 &aPoint, bool aAccurate=false) const 
 
virtual double DistanceToIn(const UVector3 &p, const UVector3 &v, double aPstep=UUtils::kInfinity) const 
 
double GetCubVolEpsilon() const 
 
VUSolid::EnumInside InsideNoVoxels(const UVector3 &p) const 
 
virtual double DistanceToOut(const UVector3 &p, const UVector3 &v, UVector3 &n, bool &aConvex, double aPstep=UUtils::kInfinity) const 
 
double Random(double min=0.0, double max=1.0)
 
virtual VUSolid::EnumInside Inside(const UVector3 &p) const 
 
int GetAreaStatistics() const 
 
virtual UGeometryType GetEntityType() const 
 
double GetAreaAccuracy() const 
 
virtual double SafetyFromInside(const UVector3 &aPoint, bool aAccurate=false) const 
 
virtual std::ostream & StreamInfo(std::ostream &os) const