Geant4  10.01
UMultiUnion.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 // UMultiUnion
12 //
13 // Class description:
14 //
15 // An instance of "UMultiUnion" constitutes a grouping of several solids
16 // deriving from the "VUSolid" mother class. The subsolids are stored with
17 // their respective location in an instance of "UNode". An instance of
18 // "UMultiUnion" is subsequently composed of one or several nodes.
19 //
20 // 19.10.12 Marek Gayer
21 // --------------------------------------------------------------------
22 
23 #ifndef USOLIDS_UMultiUnion
24 #define USOLIDS_UMultiUnion
25 
26 #include <vector>
27 
28 #include "VUSolid.hh"
29 #include "UUtils.hh"
30 #include "UTransform3D.hh"
31 #include "UBits.hh"
32 #include "UVoxelizer.hh"
33 
34 class UMultiUnion : public VUSolid
35 {
36  friend class UVoxelizer;
37 
38  public:
40  UMultiUnion(const std::string& name);
41  ~UMultiUnion();
42 
43  // Build the multiple union by adding nodes
44  void AddNode(VUSolid& solid, UTransform3D& trans);
45 
46  UMultiUnion(const UMultiUnion& rhs);
47  UMultiUnion& operator=(const UMultiUnion& rhs);
48 
49  // Accessors
50  inline const UTransform3D& GetTransformation(int index) const;
51  inline VUSolid* GetSolid(int index) const;
52  inline int GetNumberOfSolids()const;
53 
54  // Navigation methods
55  EnumInside Inside(const UVector3& aPoint) const;
56 
57  EnumInside InsideIterator(const UVector3& aPoint) const;
58 
59  double SafetyFromInside(const UVector3& aPoint,
60  bool aAccurate = false) const;
61 
62  double SafetyFromOutside(const UVector3& aPoint,
63  bool aAccurate = false) const;
64 
65  double DistanceToInNoVoxels(const UVector3& aPoint,
66  const UVector3& aDirection,
67  double aPstep = UUtils::kInfinity) const;
68 
69  double DistanceToIn(const UVector3& aPoint,
70  const UVector3& aDirection,
71  double aPstep) const;
72 
73  double DistanceToOut(const UVector3& aPoint,
74  const UVector3& aDirection,
75  UVector3& aNormalVector,
76  bool& aConvex,
77  double aPstep = UUtils::kInfinity) const;
78 
79  double DistanceToOutVoxels(const UVector3& aPoint,
80  const UVector3& aDirection,
81  UVector3& aNormalVector,
82  bool& aConvex,
83  double aPstep = UUtils::kInfinity) const;
84 
85  double DistanceToOutVoxelsCore(const UVector3& aPoint,
86  const UVector3& aDirection,
87  UVector3& aNormalVector,
88  bool& aConvex,
89  std::vector<int>& candidates) const;
90 
91  double DistanceToOutNoVoxels(const UVector3& aPoint,
92  const UVector3& aDirection,
93  UVector3& aNormalVector,
94  bool& aConvex,
95  double aPstep = UUtils::kInfinity) const;
96 
97  bool Normal(const UVector3& aPoint, UVector3& aNormal) const;
98 
99  void Extent(EAxisType aAxis, double& aMin, double& aMax) const;
100  void Extent(UVector3& aMin, UVector3& aMax) const;
101 
102  double Capacity();
103  double SurfaceArea();
104 
105  VUSolid* Clone() const ;
106 
107  UGeometryType GetEntityType() const { return "MultipleUnion"; }
108  void ComputeBBox(UBBox* aBox, bool aStore = false);
109 
110  virtual void GetParametersList(int /*aNumber*/, double* /*aArray*/) const {}
111 
112  // Finalize and prepare for use. User MUST call it once before
113  // navigation use.
114  void Voxelize();
115  EnumInside InsideNoVoxels(const UVector3& aPoint) const;
116 
117  inline UVoxelizer& GetVoxels() const;
118 
119 
120  std::ostream& StreamInfo(std::ostream& os) const;
121 
122  UVector3 GetPointOnSurface() const;
123 
124  private:
125 
126  void SetVoxelFinder(const UVoxelizer& finder);
127  EnumInside InsideWithExclusion(const UVector3& aPoint, UBits* bits = NULL) const;
128  int SafetyFromOutsideNumberNode(const UVector3& aPoint, bool aAccurate, double& safety) const;
129  double DistanceToInCandidates(const UVector3& aPoint, const UVector3& aDirection, double aPstep, std::vector<int>& candidates, UBits& bits) const;
130 
131  std::vector<VUSolid*> fSolids;
132  std::vector<UTransform3D> fTransformObjs;
133  UVoxelizer fVoxels; // Pointer to the vozelized solid
134  double fCubicVolume; // Cubic Volume
135  double fSurfaceArea; // Surface Area
136 };
137 
139 {
140  return (UVoxelizer&)fVoxels;
141 }
142 inline const UTransform3D& UMultiUnion::GetTransformation(int index) const
143 {
144  return fTransformObjs[index];
145 }
146 inline VUSolid* UMultiUnion::GetSolid(int index) const
147 {
148  return fSolids[index];
149 }
151 {
152  return fSolids.size();
153 }
154 
155 #endif
double SurfaceArea()
Definition: UMultiUnion.cc:872
double DistanceToOutVoxels(const UVector3 &aPoint, const UVector3 &aDirection, UVector3 &aNormalVector, bool &aConvex, double aPstep=UUtils::kInfinity) const
Definition: UMultiUnion.cc:303
int GetNumberOfSolids() const
Definition: UMultiUnion.hh:150
void SetVoxelFinder(const UVoxelizer &finder)
std::ostream & StreamInfo(std::ostream &os) const
Definition: UMultiUnion.cc:934
G4String name
Definition: TRTMaterials.hh:40
double SafetyFromInside(const UVector3 &aPoint, bool aAccurate=false) const
Definition: UMultiUnion.cc:782
UMultiUnion & operator=(const UMultiUnion &rhs)
Definition: UMultiUnion.cc:67
UVoxelizer fVoxels
Definition: UMultiUnion.hh:133
bool Normal(const UVector3 &aPoint, UVector3 &aNormal) const
Definition: UMultiUnion.cc:696
double DistanceToIn(const UVector3 &aPoint, const UVector3 &aDirection, double aPstep) const
Definition: UMultiUnion.cc:178
EnumInside Inside(const UVector3 &aPoint) const
Definition: UMultiUnion.cc:571
int SafetyFromOutsideNumberNode(const UVector3 &aPoint, bool aAccurate, double &safety) const
Definition: UMultiUnion.cc:893
double DistanceToInNoVoxels(const UVector3 &aPoint, const UVector3 &aDirection, double aPstep=UUtils::kInfinity) const
Definition: UMultiUnion.cc:123
EnumInside InsideWithExclusion(const UVector3 &aPoint, UBits *bits=NULL) const
Definition: UMultiUnion.cc:434
UGeometryType GetEntityType() const
Definition: UMultiUnion.hh:107
double fSurfaceArea
Definition: UMultiUnion.hh:135
double SafetyFromOutside(const UVector3 &aPoint, bool aAccurate=false) const
Definition: UMultiUnion.cc:817
void Voxelize()
Definition: UMultiUnion.cc:887
virtual void GetParametersList(int, double *) const
Definition: UMultiUnion.hh:110
const UTransform3D & GetTransformation(int index) const
Definition: UMultiUnion.hh:142
static const double kInfinity
Definition: UUtils.hh:53
EnumInside InsideIterator(const UVector3 &aPoint) const
std::vector< UTransform3D > fTransformObjs
Definition: UMultiUnion.hh:132
UVoxelizer & GetVoxels() const
Definition: UMultiUnion.hh:138
double fCubicVolume
Definition: UMultiUnion.hh:134
EAxisType
Definition: VUSolid.hh:27
EnumInside
Definition: VUSolid.hh:23
EnumInside InsideNoVoxels(const UVector3 &aPoint) const
Definition: UMultiUnion.cc:600
void ComputeBBox(UBBox *aBox, bool aStore=false)
Definition: UMultiUnion.cc:116
UVector3 GetPointOnSurface() const
Definition: UMultiUnion.cc:962
double DistanceToOutVoxelsCore(const UVector3 &aPoint, const UVector3 &aDirection, UVector3 &aNormalVector, bool &aConvex, std::vector< int > &candidates) const
std::string UGeometryType
Definition: UTypes.hh:39
double DistanceToOut(const UVector3 &aPoint, const UVector3 &aDirection, UVector3 &aNormalVector, bool &aConvex, double aPstep=UUtils::kInfinity) const
Definition: UMultiUnion.cc:278
void AddNode(VUSolid &solid, UTransform3D &trans)
Definition: UMultiUnion.cc:44
double Capacity()
Definition: UMultiUnion.cc:84
std::vector< VUSolid * > fSolids
Definition: UMultiUnion.hh:131
VUSolid * Clone() const
Definition: UMultiUnion.cc:51
double DistanceToOutNoVoxels(const UVector3 &aPoint, const UVector3 &aDirection, UVector3 &aNormalVector, bool &aConvex, double aPstep=UUtils::kInfinity) const
Definition: UMultiUnion.cc:228
VUSolid * GetSolid(int index) const
Definition: UMultiUnion.hh:146
Definition: UBits.hh:38
void Extent(EAxisType aAxis, double &aMin, double &aMax) const
Definition: UMultiUnion.cc:627
double DistanceToInCandidates(const UVector3 &aPoint, const UVector3 &aDirection, double aPstep, std::vector< int > &candidates, UBits &bits) const
Definition: UMultiUnion.cc:146