00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id$ 00028 // 00029 // ---------------------------------------------------------------------- 00030 // Class G4BREPSolidPolyhedra 00031 // 00032 // Class description: 00033 // 00034 // The polygonal solid G4BREPSolidPolyhedra is a shape defined by an inner 00035 // and outer polygonal surface and two planes perpendicular to the Z axis. 00036 // Each polygonal surface is created by linking a series of polygons created 00037 // at different planes perpendicular to the Z-axis. All these polygons all 00038 // have the same number of sides (sides) and are defined at the same Z planes 00039 // for both inner and outer polygonal surfaces. 00040 // 00041 // G4BREPSolidPolyhedra( const G4String& name, 00042 // G4double phi1, 00043 // G4double dphi, 00044 // G4int sides, 00045 // G4int num_z_planes, 00046 // G4double z_start, 00047 // G4double z_values[], 00048 // G4double RMIN[], 00049 // G4double RMAX[] ) 00050 00051 // Authors: J.Sulkimo, P.Urban. 00052 // Revisions by: L.Broglia, S.Giani, G.Cosmo. 00053 // ---------------------------------------------------------------------- 00054 #ifndef __G4BREPPOLYHEDRA 00055 #define __G4BREPPOLYHEDRA 00056 00057 #include "G4BREPSolid.hh" 00058 00059 class G4BREPSolidPolyhedra : public G4BREPSolid 00060 { 00061 public: // with description 00062 00063 G4BREPSolidPolyhedra( const G4String& name, 00064 G4double phi1, 00065 G4double dphi, 00066 G4int sides, 00067 G4int num_z_planes, 00068 G4double z_start, 00069 G4double z_values[], 00070 G4double RMIN[], 00071 G4double RMAX[] ); 00072 // Constructor defining the polyhedra through its 00073 // polygonal surfaces and planes. 00074 00075 ~G4BREPSolidPolyhedra(); 00076 // Destructor. 00077 00078 void Initialize(); 00079 // Calculates the bounding box. 00080 00081 EInside Inside(register const G4ThreeVector& Pt) const; 00082 // Determines if the point Pt is inside, outside or on the surface 00083 // of the solid. 00084 00085 G4ThreeVector SurfaceNormal(const G4ThreeVector&) const; 00086 // Calculates the normal of the surface at a point on the surface 00087 // The sense of the normal depends on the sense of the surface. 00088 00089 G4double DistanceToIn(const G4ThreeVector&) const; 00090 // Calculates the shortest distance ("safety") from a point 00091 // outside the solid to any boundary of this solid. 00092 // Return 0 if the point is already inside. 00093 00094 G4double DistanceToIn(register const G4ThreeVector& Pt, 00095 register const G4ThreeVector& V) const; 00096 // Calculates the distance from a point Pt outside the solid 00097 // to the solid's boundary along a specified direction vector V. 00098 // Note: Intersections with boundaries less than the tolerance must 00099 // be ignored if the direction is away from the boundary. 00100 00101 G4double DistanceToOut(register const G4ThreeVector& Pt, 00102 register const G4ThreeVector& V, 00103 const G4bool calcNorm=false, 00104 G4bool *validNorm=0, G4ThreeVector *n=0) const; 00105 // Calculates the distance from a point inside the solid to the solid`s 00106 // boundary along a specified direction vector. 00107 // Return 0 if the point is already outside. 00108 // Note: If the shortest distance to a boundary is less than the 00109 // tolerance, it is ignored. This allows for a point within a 00110 // tolerant boundary to leave immediately. 00111 00112 G4double DistanceToOut(const G4ThreeVector&) const; 00113 // Calculates the shortest distance ("safety") from a point inside the 00114 // solid to any boundary of this solid. 00115 // Return 0 if the point is already outside. 00116 00117 G4VSolid* Clone() const; 00118 // Returns a pointer of a dynamically allocated copy of the solid. 00119 00120 std::ostream& StreamInfo(std::ostream& os) const; 00121 // Streams solid contents to output stream. 00122 00123 public: 00124 00125 G4Polyhedron* CreatePolyhedron () const; 00126 // Creates a G4Polyhedron 00127 00128 void Reset() const; 00129 // Resets all distance attributes. 00130 00131 public: // without description 00132 00133 G4BREPSolidPolyhedra(__void__&); 00134 // Fake default constructor for usage restricted to direct object 00135 // persistency for clients requiring preallocation of memory for 00136 // persistifiable objects. 00137 00138 G4BREPSolidPolyhedra(const G4BREPSolidPolyhedra& rhs); 00139 G4BREPSolidPolyhedra& operator=(const G4BREPSolidPolyhedra& rhs); 00140 // Copy constructor and assignment operator. 00141 00142 private: 00143 00144 typedef enum _SF { 00145 EInverse = 0, 00146 ENormal = 1 00147 } ESurfaceSense; 00148 00149 void InitializePolyhedra(); 00150 00151 G4Surface* CreateTrapezoidalSurface( G4double r1, G4double r2, 00152 const G4Point3D& origin, G4double zDistance, 00153 G4Vector3D& xAxis, G4double partAngle, 00154 ESurfaceSense sense ); 00155 00156 G4Surface* CreateTriangularSurface( G4double r1, G4double r2, 00157 const G4Point3D& origin, G4double zDistance, 00158 G4Vector3D& xAxis, G4double partAngle, 00159 ESurfaceSense sense ); 00160 00161 G4Surface* ComputePlanarSurface( G4double r1, G4double r2, 00162 const G4Point3D& origin, G4Vector3D& xAxis, 00163 G4int sides, G4double partAngle, 00164 ESurfaceSense sense ); 00165 00166 // The following is only utilised in storing the shape parameters for 00167 // use in visualising this shape. J.A. Feb 24, 1997 00168 // 00169 // R. Chytracek, Nov 2002, Update to new IO dumping mechanism 00170 00171 struct G4BREPPolyhedraParams 00172 { 00173 G4double start_angle; 00174 G4double opening_angle; 00175 G4int sides; 00176 G4int num_z_planes; 00177 G4double z_start; 00178 G4double* z_values; 00179 G4double* RMIN; 00180 G4double* RMAX; 00181 } constructorParams; 00182 00183 }; 00184 00185 #endif