|
||||
Warning, file /include/Geant4/G4VSolid.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 // G4VSolid 0027 // 0028 // Class description: 0029 // 0030 // Abstract base class for solids, physical shapes that can be tracked through. 0031 // Each solid has a name, and the constructors and destructors automatically 0032 // add and subtract them from the G4SolidStore, a singleton `master' List 0033 // of available solids. 0034 // 0035 // This class defines, but does not implement, functions to compute 0036 // distances to/from the shape. Functions are also defined 0037 // to check whether a point is inside the shape, to return the 0038 // surface normal of the shape at a given point, and to compute 0039 // the extent of the shape. [see descriptions below] 0040 // 0041 // Some protected/private utility functions are implemented for the 0042 // clipping of regions for the computation of a solid's extent. Note that 0043 // the clipping mechanism is presently inefficient. 0044 // 0045 // Some visualization/graphics functions are also defined. 0046 // 0047 // Member Data: 0048 // 0049 // G4String fshapeName 0050 // - Name for this solid. 0051 0052 // 12.04.00 J.Allison Implemented GetExtent() in terms of CalculateExtent() 0053 // 17.06.98 J.Apostolakis Added pure virtual function GetEntityType() 0054 // 26.07.96 P.Kent Added ComputeDimensions() for replication mechanism 0055 // 27.03.96 J.Allison Methods for visualisation 0056 // 30.06.95 P.Kent Initial version, no scoping or visualisation functions 0057 // -------------------------------------------------------------------- 0058 #ifndef G4VSOLID_HH 0059 #define G4VSOLID_HH 1 0060 0061 #include "G4Types.hh" 0062 #include "G4String.hh" 0063 #include "geomdefs.hh" 0064 0065 class G4AffineTransform; 0066 class G4VoxelLimits; 0067 0068 class G4VPVParameterisation; 0069 class G4VPhysicalVolume; 0070 0071 class G4VGraphicsScene; 0072 class G4Polyhedron; 0073 class G4VisExtent; 0074 class G4DisplacedSolid; 0075 0076 #include "G4ThreeVector.hh" 0077 #include <vector> 0078 0079 using G4ThreeVectorList = std::vector<G4ThreeVector>; 0080 using G4GeometryType = G4String; 0081 0082 class G4VSolid 0083 { 0084 public: // with description 0085 0086 G4VSolid(const G4String& name); 0087 // Creates a new shape, with the supplied name. No provision is made 0088 // for sharing a common name amongst multiple classes. 0089 virtual ~G4VSolid(); 0090 // Default destructor. 0091 0092 inline G4bool operator==(const G4VSolid& s) const; 0093 // Return true only if addresses are the same. 0094 0095 inline G4String GetName() const; 0096 // Returns the current shape's name. 0097 void SetName(const G4String& name); 0098 // Sets the current shape's name. 0099 0100 inline G4double GetTolerance() const; 0101 // Returns the cached geometrical tolerance. 0102 0103 virtual void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const; 0104 // Returns the bounding box of the solid. 0105 0106 virtual G4bool CalculateExtent(const EAxis pAxis, 0107 const G4VoxelLimits& pVoxelLimit, 0108 const G4AffineTransform& pTransform, 0109 G4double& pMin, G4double& pMax) const = 0; 0110 // Calculate the minimum and maximum extent of the solid, when under the 0111 // specified transform, and within the specified limits. If the solid 0112 // is not intersected by the region, return false, else return true. 0113 0114 virtual EInside Inside(const G4ThreeVector& p) const = 0; 0115 // Returns kOutside if the point at offset p is outside the shapes 0116 // boundaries plus Tolerance/2, kSurface if the point is <= Tolerance/2 0117 // from a surface, otherwise kInside. 0118 0119 virtual G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const = 0; 0120 // Returns the outwards pointing unit normal of the shape for the 0121 // surface closest to the point at offset p. 0122 0123 virtual G4double DistanceToIn(const G4ThreeVector& p, 0124 const G4ThreeVector& v) const = 0; 0125 // Return the distance along the normalised vector v to the shape, 0126 // from the point at offset p. If there is no intersection, return 0127 // kInfinity. The first intersection resulting from `leaving' a 0128 // surface/volume is discarded. Hence, it is tolerant of points on 0129 // the surface of the shape. 0130 0131 virtual G4double DistanceToIn(const G4ThreeVector& p) const = 0; 0132 // Calculate the distance to the nearest surface of a shape from an 0133 // outside point. The distance can be an underestimate. 0134 0135 virtual G4double DistanceToOut(const G4ThreeVector& p, 0136 const G4ThreeVector& v, 0137 const G4bool calcNorm=false, 0138 G4bool* validNorm = nullptr, 0139 G4ThreeVector* n = nullptr) const = 0; 0140 // Return the distance along the normalised vector v to the shape, 0141 // from a point at an offset p inside or on the surface of the shape. 0142 // Intersections with surfaces, when the point is < Tolerance/2 from a 0143 // surface must be ignored. 0144 // If calcNorm==true: 0145 // validNorm set true if the solid lies entirely behind or on the 0146 // exiting surface. 0147 // n set to exiting outwards normal vector (undefined Magnitude). 0148 // validNorm set to false if the solid does not lie entirely behind 0149 // or on the exiting surface 0150 // If calcNorm==false: 0151 // validNorm and n are unused. 0152 // 0153 // Must be called as solid.DistanceToOut(p,v) or by specifying all 0154 // the parameters. 0155 0156 virtual G4double DistanceToOut(const G4ThreeVector& p) const = 0; 0157 // Calculate the distance to the nearest surface of a shape from an 0158 // inside point. The distance can be an underestimate. 0159 0160 0161 virtual void ComputeDimensions(G4VPVParameterisation* p, 0162 const G4int n, 0163 const G4VPhysicalVolume* pRep); 0164 // Throw exception if ComputeDimensions called frrom an illegal 0165 // derived class. 0166 0167 virtual G4double GetCubicVolume(); 0168 // Returns an estimation of the solid volume in internal units. 0169 // This method may be overloaded by derived classes to compute the 0170 // exact geometrical quantity for solids where this is possible, 0171 // or anyway to cache the computed value. 0172 // Note: the computed value is NOT cached. 0173 0174 virtual G4double GetSurfaceArea(); 0175 // Return an estimation of the solid surface area in internal units. 0176 // This method may be overloaded by derived classes to compute the 0177 // exact geometrical quantity for solids where this is possible, 0178 // or anyway to cache the computed value. 0179 // Note: the computed value is NOT cached. 0180 0181 virtual G4GeometryType GetEntityType() const = 0; 0182 // Provide identification of the class of an object. 0183 // (required for persistency and STEP interface) 0184 0185 virtual G4ThreeVector GetPointOnSurface() const; 0186 // Returns a random point located on the surface of the solid. 0187 // Points returned are not necessarily uniformly distributed. 0188 0189 virtual G4VSolid* Clone() const; 0190 // Returns a pointer of a dynamically allocated copy of the solid. 0191 // Returns NULL pointer with warning in case the concrete solid does not 0192 // implement this method. The caller has responsibility for ownership. 0193 0194 virtual std::ostream& StreamInfo(std::ostream& os) const = 0; 0195 // Dumps contents of the solid to a stream. 0196 inline void DumpInfo() const; 0197 // Dumps contents of the solid to the standard output. 0198 0199 // Visualization functions 0200 0201 virtual void DescribeYourselfTo (G4VGraphicsScene& scene) const = 0; 0202 // A "double dispatch" function which identifies the solid 0203 // to the graphics scene. 0204 virtual G4VisExtent GetExtent () const; 0205 // Provide extent (bounding box) as possible hint to the graphics view. 0206 virtual G4Polyhedron* CreatePolyhedron () const; 0207 // Create a G4Polyhedron. (It is the caller's responsibility 0208 // to delete it). A null pointer means "not created". 0209 virtual G4Polyhedron* GetPolyhedron () const; 0210 // Smart access function - creates on request and stores for future 0211 // access. A null pointer means "not available". 0212 0213 virtual const G4VSolid* GetConstituentSolid(G4int no) const; 0214 virtual G4VSolid* GetConstituentSolid(G4int no); 0215 // If the solid is made up from a Boolean operation of two solids, 0216 // return the "no" solid. If the solid is not a "Boolean", return 0. 0217 0218 virtual const G4DisplacedSolid* GetDisplacedSolidPtr() const; 0219 virtual G4DisplacedSolid* GetDisplacedSolidPtr(); 0220 // If the solid is a "G4DisplacedSolid", return a self pointer 0221 // else return 0. 0222 0223 public: // without description 0224 0225 G4VSolid(__void__&); 0226 // Fake default constructor for usage restricted to direct object 0227 // persistency for clients requiring preallocation of memory for 0228 // persistifiable objects. 0229 0230 G4VSolid(const G4VSolid& rhs); 0231 G4VSolid& operator=(const G4VSolid& rhs); 0232 // Copy constructor and assignment operator. 0233 0234 G4double EstimateCubicVolume(G4int nStat, G4double epsilon) const; 0235 // Calculate cubic volume based on Inside() method. 0236 // Accuracy is limited by the second argument or the statistics 0237 // expressed by the first argument. 0238 0239 G4double EstimateSurfaceArea(G4int nStat, G4double ell) const; 0240 // Calculate surface area only based on Inside() method. 0241 // Accuracy is limited by the second argument or the statistics 0242 // expressed by the first argument. 0243 0244 protected: // with description 0245 0246 void CalculateClippedPolygonExtent(G4ThreeVectorList& pPolygon, 0247 const G4VoxelLimits& pVoxelLimit, 0248 const EAxis pAxis, 0249 G4double& pMin, G4double& pMax) const; 0250 // Calculate the maximum and minimum extents of the convex polygon 0251 // pPolygon along the axis pAxis, within the limits pVoxelLimit. 0252 // 0253 // If the minimum is <pMin pMin is set to the new minimum. 0254 // If the maximum is >pMax pMax is set to the new maximum. 0255 // 0256 // Modifications to pPolygon are made - it is left in an undefined state. 0257 0258 void ClipCrossSection(G4ThreeVectorList* pVertices, 0259 const G4int pSectionIndex, 0260 const G4VoxelLimits& pVoxelLimit, 0261 const EAxis pAxis, 0262 G4double& pMin, G4double& pMax) const; 0263 // Calculate the maximum and minimum extents of the polygon described 0264 // by the vertices: pSectionIndex->pSectionIndex+1-> 0265 // pSectionIndex+2->pSectionIndex+3->pSectionIndex 0266 // in the List pVertices. 0267 // 0268 // If the minimum is <pMin pMin is set to the new minimum. 0269 // If the maximum is >pMax pMax is set to the new maximum. 0270 // 0271 // No modifications are made to pVertices. 0272 0273 void ClipBetweenSections(G4ThreeVectorList* pVertices, 0274 const G4int pSectionIndex, 0275 const G4VoxelLimits& pVoxelLimit, 0276 const EAxis pAxis, 0277 G4double& pMin, G4double& pMax) const; 0278 // Calculate the maximum and minimum extents of the polygons 0279 // joining the CrossSections at pSectionIndex->pSectionIndex+3 and 0280 // pSectionIndex+4->pSectionIndex7 0281 // in the List pVertices, within the boundaries of the voxel limits 0282 // pVoxelLimit. 0283 // 0284 // If the minimum is <pMin pMin is set to the new minimum. 0285 // If the maximum is >pMax pMax is set to the new maximum. 0286 // 0287 // No modifications are made to pVertices. 0288 0289 void ClipPolygon( G4ThreeVectorList& pPolygon, 0290 const G4VoxelLimits& pVoxelLimit, 0291 const EAxis pAxis ) const; 0292 // Clip the specified convex polygon to the given limits, where 0293 // the polygon is described by the vertices at (0),(1),...,(n),(0) in 0294 // pPolygon. 0295 // If the polygon is completely clipped away, the polygon is cleared. 0296 0297 protected: 0298 0299 G4double kCarTolerance; // Cached geometrical tolerance 0300 0301 private: 0302 0303 void ClipPolygonToSimpleLimits(G4ThreeVectorList& pPolygon, 0304 G4ThreeVectorList& outputPolygon, 0305 const G4VoxelLimits& pVoxelLimit ) const; 0306 // Clip the specified convex polygon to the given limits, storing the 0307 // result in outputPolygon. The voxel limits must be limited in one 0308 // *plane* only: This is achieved by having only x or y or z limits, 0309 // and either the minimum or maximum limit set to -+kInfinity 0310 // respectively. 0311 0312 G4String fshapeName; // Name 0313 }; 0314 0315 /// Output solid information to given ostream 0316 std::ostream& operator<<(std::ostream& os, const G4VSolid& e); 0317 0318 #include "G4VSolid.icc" 0319 0320 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |