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 // class G4VoxelLimits 00030 // 00031 // Class description: 00032 // 00033 // Represents limitation/restrictions of space, where restrictions 00034 // are only made perpendicular to the cartesian axes. 00035 // 00036 // 00037 // Member data: 00038 // 00039 // G4double fxAxisMin,fxAxisMax 00040 // G4double fyAxisMin,fyAxisMax 00041 // G4double fzAxisMin,fzAxisMax 00042 // - The min and max values along each axis. +-kInfinity if not restricted. 00043 // 00044 // 00045 // Notes: 00046 // 00047 // Beware no break statements after returns in switch(pAxis)s. 00048 00049 // History: 00050 // 13.07.95 P.Kent Initial version. 00051 // -------------------------------------------------------------------- 00052 #ifndef G4VOXELLIMITS_HH 00053 #define G4VOXELLIMITS_HH 00054 00055 #include "G4Types.hh" 00056 #include "geomdefs.hh" 00057 00058 #include "G4ThreeVector.hh" 00059 00060 #include <assert.h> 00061 00062 class G4VoxelLimits 00063 { 00064 public: // with description 00065 00066 G4VoxelLimits(); 00067 // Constructor - initialise to be unlimited. Volume unrestricted. 00068 00069 ~G4VoxelLimits(); 00070 // Destructor. No actions. 00071 00072 void AddLimit(const EAxis pAxis, const G4double pMin,const G4double pMax); 00073 // Restrict the volume to between specified min and max along the 00074 // given axis. Cartesian axes only, pMin<=pMax. 00075 00076 G4double GetMaxXExtent() const; 00077 // Return maximum x extent. 00078 G4double GetMaxYExtent() const; 00079 // Return maximum y extent. 00080 G4double GetMaxZExtent() const; 00081 // Return maximum z extent. 00082 00083 G4double GetMinXExtent() const; 00084 // Return minimum x extent. 00085 G4double GetMinYExtent() const; 00086 // Return minimum y extent. 00087 G4double GetMinZExtent() const; 00088 // Return minimum z extent. 00089 00090 G4double GetMaxExtent(const EAxis pAxis) const; 00091 // Return maximum extent of volume along specified axis. 00092 G4double GetMinExtent(const EAxis pAxis) const; 00093 // Return minimum extent of volume along specified axis. 00094 00095 G4bool IsXLimited() const; 00096 // Return true if the x axis is limited. 00097 G4bool IsYLimited() const; 00098 // Return true if the y axis is limited. 00099 G4bool IsZLimited() const; 00100 // Return true if the z axis is limited. 00101 00102 G4bool IsLimited() const; 00103 // Return true if limited along any axis 00104 G4bool IsLimited(const EAxis pAxis) const; 00105 // Return true if the specified axis is restricted/limited. 00106 00107 G4bool ClipToLimits(G4ThreeVector& pStart,G4ThreeVector& pEnd) const; 00108 // Clip the line segment pStart->pEnd to the volume described by the 00109 // current limits. Return true if the line remains after clipping, 00110 // else false, and leave the vectors in an undefined state. 00111 00112 G4bool Inside(const G4ThreeVector& pVec) const; 00113 // Return true if the specified vector is inside/on boundaries of limits. 00114 00115 G4int OutCode(const G4ThreeVector& pVec) const; 00116 // Calculate the `outcode' for the specified vector. 00117 // Intended for use during clipping against the limits 00118 // The bits are set given the following conditions: 00119 // 0 pVec.x()<fxAxisMin && IsXLimited() 00120 // 1 pVec.x()>fxAxisMax && IsXLimited() 00121 // 2 pVec.y()<fyAxisMin && IsYLimited() 00122 // 3 pVec.y()>fyAxisMax && IsYLimited() 00123 // 4 pVec.z()<fzAxisMin && IsZLimited() 00124 // 5 pVec.z()>fzAxisMax && IsZLimited() 00125 00126 private: 00127 00128 G4double fxAxisMin,fxAxisMax; 00129 G4double fyAxisMin,fyAxisMax; 00130 G4double fzAxisMin,fzAxisMax; 00131 }; 00132 00133 #include "G4VoxelLimits.icc" 00134 00135 std::ostream& operator << (std::ostream& os, const G4VoxelLimits& pLim); 00136 // Print the limits to the stream in the form: 00137 // "{(xmin,xmax) (ymin,ymax) (zmin,zmax)}" 00138 // Replace (xmin,xmax) by (-,-) when not limited. 00139 00140 #endif