Geant4  10.00.p01
UVCSGfaceted.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * This Software is part of the AIDA Unified Solids Library package *
4 // * See: https://aidasoft.web.cern.ch/USolids *
5 // ********************************************************************
6 //
7 // $Id:$
8 //
9 // --------------------------------------------------------------------
10 //
11 // UVCSGfaceted
12 //
13 // Class description:
14 //
15 // Virtual class defining CSG-like type shape that is built entire
16 // of UCSGface faces.
17 //
18 // 19.09.13 Marek Gayer
19 // Created from original implementation in Geant4
20 // --------------------------------------------------------------------
21 
22 #ifndef UVCSGfaceted_hh
23 #define UVCSGfaceted_hh
24 
25 #include "VUSolid.hh"
26 #include "UVoxelizer.hh"
27 #include "UBox.hh"
28 #include "UReduciblePolygon.hh"
29 
30 class UVCSGface;
31 class UVisExtent;
32 
33 class UVCSGfaceted : public VUSolid
34 {
35  public: // with description
36 
37  UVCSGfaceted(const std::string& name);
38  virtual ~UVCSGfaceted();
39 
40  UVCSGfaceted(const UVCSGfaceted& source);
41  UVCSGfaceted& operator=(const UVCSGfaceted& source);
42 
43 
45 
46  virtual VUSolid::EnumInside Inside(const UVector3& p) const;
47 
48  virtual bool Normal(const UVector3& p, UVector3& n) const;
49 
50  double DistanceToInNoVoxels(const UVector3& p,
51  const UVector3& v) const;
52 
53  virtual double DistanceToIn(const UVector3& p,
54  const UVector3& v, double aPstep = UUtils::kInfinity) const;
55 
56 
57  virtual double SafetyFromOutside(const UVector3& aPoint, bool aAccurate = false) const;
58 
59 
60  double DistanceTo(const UVector3& p, const bool outgoing) const;
61 
62  double DistanceToOutNoVoxels(const UVector3& p,
63  const UVector3& v,
64  UVector3& n,
65  bool& aConvex) const;
66 
67  virtual double DistanceToOut(const UVector3& p,
68  const UVector3& v,
69  UVector3& n,
70  bool& aConvex,
71  double aPstep = UUtils::kInfinity) const;
72 
73 
74  virtual double SafetyFromInside(const UVector3& aPoint, bool aAccurate = false) const;
75 
76  virtual double SafetyFromInsideNoVoxels(const UVector3& aPoint, bool aAccurate = false) const;
77 
78  virtual UGeometryType GetEntityType() const;
79 
80  virtual std::ostream& StreamInfo(std::ostream& os) const;
81 
82  int GetCubVolStatistics() const;
83  double GetCubVolEpsilon() const;
84  void SetCubVolStatistics(int st);
85  void SetCubVolEpsilon(double ep);
86  int GetAreaStatistics() const;
87  double GetAreaAccuracy() const;
88  void SetAreaStatistics(int st);
89  void SetAreaAccuracy(double ep);
90 
91  virtual double Capacity();
92  // Returns an estimation of the geometrical cubic volume of the
93  // solid. Caches the computed value once computed the first time.
94  virtual double SurfaceArea();
95  // Returns an estimation of the geometrical surface area of the
96  // solid. Caches the computed value once computed the first time.
97 
98  public: // without description
99 
100  protected: // without description
101 
102  double SafetyFromInsideSection(int index, const UVector3& p, UBits& bits) const;
103 
104  inline int GetSection(double z) const
105  {
106  int section = UVoxelizer::BinarySearch(fZs, z);
107  if (section < 0) section = 0;
108  else if (section > fMaxSection) section = fMaxSection;
109  return section;
110  }
111 
112  int numFace;
114  double fCubicVolume;
115  double fSurfaceArea;
116 
117 
118  std::vector<double> fZs; // z coordinates of given sections
119  std::vector<std::vector<int> > fCandidates; // precalculated candidates for each of the section
120  int fMaxSection; // maximum index number of sections of the solid (i.e. their number - 1). regular polyhedra with z = 1,2,3 section has 2 sections numbered 0 and 1, therefore the fMaxSection will be 1 (that is 2 - 1 = 1)
121  mutable UBox fBox; // bounding box of the polyhedra, used in some methods
122  double fBoxShift; // z-shift which is added during evaluation, because bounding box center does not have to be at (0,0,0)
123  bool fNoVoxels; // if set to true, no voxelized algorithms will be used
124 
126  // Returns a random point located on the surface of the solid
127  // in case of generic Polycone or generic Polyhedra.
128 
129  void CopyStuff(const UVCSGfaceted& source);
130  void DeleteStuff();
131 
132  void FindCandidates(double z, std::vector <int>& candidates, bool sides = false);
133 
134  void InitVoxels(UReduciblePolygon& z, double radius);
135 
136  private:
137 
141  // Statistics, error accuracy for volume estimation.
142 
143 };
144 
145 #endif
void SetCubVolStatistics(int st)
virtual ~UVCSGfaceted()
Definition: UVCSGfaceted.cc:41
double DistanceTo(const UVector3 &p, const bool outgoing) const
double fBoxShift
G4double z
Definition: TRTMaterials.hh:39
virtual bool Normal(const UVector3 &p, UVector3 &n) const
G4String name
Definition: TRTMaterials.hh:40
void FindCandidates(double z, std::vector< int > &candidates, bool sides=false)
double fSurfaceArea
double DistanceToOutNoVoxels(const UVector3 &p, const UVector3 &v, UVector3 &n, bool &aConvex) const
void SetAreaStatistics(int st)
void DeleteStuff()
Definition: UBox.hh:33
int GetCubVolStatistics() const
double fCubVolEpsilon
virtual double SafetyFromInsideNoVoxels(const UVector3 &aPoint, bool aAccurate=false) const
void SetCubVolEpsilon(double ep)
std::vector< double > fZs
static int BinarySearch(const std::vector< T > &vec, T value)
Definition: UVoxelizer.hh:58
static const double kInfinity
Definition: UUtils.hh:54
void InitVoxels(UReduciblePolygon &z, double radius)
void SetAreaAccuracy(double ep)
UVCSGfaceted & operator=(const UVCSGfaceted &source)
Definition: UVCSGfaceted.cc:63
double fCubicVolume
double fAreaAccuracy
int GetSection(double z) const
virtual double Capacity()
EnumInside
Definition: VUSolid.hh:23
const G4int n
virtual double SurfaceArea()
double SafetyFromInsideSection(int index, const UVector3 &p, UBits &bits) const
double DistanceToInNoVoxels(const UVector3 &p, const UVector3 &v) const
std::vector< std::vector< int > > fCandidates
std::string UGeometryType
Definition: UTypes.hh:70
UVCSGfaceted(const std::string &name)
Definition: UVCSGfaceted.cc:31
UVCSGface ** faces
void CopyStuff(const UVCSGfaceted &source)
Definition: UVCSGfaceted.cc:91
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
virtual VUSolid::EnumInside Inside(const UVector3 &p) const
int GetAreaStatistics() const
virtual UGeometryType GetEntityType() const
Definition: UBits.hh:38
double GetAreaAccuracy() const
virtual std::ostream & StreamInfo(std::ostream &os) const
virtual double SafetyFromInside(const UVector3 &aPoint, bool aAccurate=false) const