Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:25

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 // G4VoxelLimits
0027 //
0028 // Class description:
0029 //
0030 // Represents limitation/restrictions of space, where restrictions
0031 // are only made perpendicular to the cartesian axes.
0032 //
0033 // Member data:
0034 //
0035 // G4double fxAxisMin,fxAxisMax
0036 // G4double fyAxisMin,fyAxisMax
0037 // G4double fzAxisMin,fzAxisMax
0038 // - The min and max values along each axis. +-kInfinity if not restricted.
0039 
0040 // 13.07.95, P.Kent - Initial version.
0041 // --------------------------------------------------------------------
0042 #ifndef G4VOXELLIMITS_HH
0043 #define G4VOXELLIMITS_HH 1
0044 
0045 #include "G4Types.hh"
0046 #include "geomdefs.hh"
0047 
0048 #include "G4ThreeVector.hh"
0049 
0050 #include <assert.h>
0051 
0052 class G4VoxelLimits
0053 {
0054   public:
0055   
0056     G4VoxelLimits() = default;
0057       // Constructor - initialise to be unlimited. Volume unrestricted.
0058 
0059     ~G4VoxelLimits() = default;
0060       // Destructor. No actions.
0061 
0062     void AddLimit(const EAxis pAxis, const G4double pMin, const G4double pMax);
0063       // Restrict the volume to between specified min and max along the
0064       // given axis. Cartesian axes only, pMin<=pMax.
0065 
0066     G4double GetMaxXExtent() const;
0067       // Return maximum x extent.
0068     G4double GetMaxYExtent() const;
0069       // Return maximum y extent.
0070     G4double GetMaxZExtent() const;
0071       // Return maximum z extent.
0072 
0073     G4double GetMinXExtent() const;
0074       // Return minimum x extent.
0075     G4double GetMinYExtent() const;
0076       // Return minimum y extent.
0077     G4double GetMinZExtent() const;
0078       // Return minimum z extent.
0079 
0080     G4double GetMaxExtent(const EAxis pAxis) const;
0081       // Return maximum extent of volume along specified axis.
0082     G4double GetMinExtent(const EAxis pAxis) const;
0083       // Return minimum extent of volume along specified axis.
0084 
0085     G4bool IsXLimited() const;
0086       // Return true if the x axis is limited.
0087     G4bool IsYLimited() const;
0088       // Return true if the y axis is limited.
0089     G4bool IsZLimited() const;
0090       // Return true if the z axis is limited.
0091 
0092     G4bool IsLimited() const;
0093       // Return true if limited along any axis
0094     G4bool IsLimited(const EAxis pAxis) const;
0095       // Return true if the specified axis is restricted/limited.
0096 
0097     G4bool ClipToLimits(G4ThreeVector& pStart, G4ThreeVector& pEnd) const;
0098       // Clip the line segment pStart->pEnd to the volume described by the
0099       // current limits. Return true if the line remains after clipping,
0100       // else false, and leave the vectors in an undefined state.
0101 
0102     G4bool Inside(const G4ThreeVector& pVec) const;
0103       // Return true if the specified vector is inside/on boundaries of limits.
0104 
0105     G4int OutCode(const G4ThreeVector& pVec) const;
0106       // Calculate the `outcode' for the specified vector.
0107       // Intended for use during clipping against the limits
0108       // The bits are set given the following conditions:
0109       //   0      pVec.x()<fxAxisMin && IsXLimited()
0110       //   1      pVec.x()>fxAxisMax && IsXLimited()
0111       //   2      pVec.y()<fyAxisMin && IsYLimited()
0112       //   3      pVec.y()>fyAxisMax && IsYLimited()
0113       //   4      pVec.z()<fzAxisMin && IsZLimited()
0114       //   5      pVec.z()>fzAxisMax && IsZLimited()
0115 
0116   private:
0117 
0118     G4double fxAxisMin = -kInfinity, fxAxisMax = kInfinity;
0119     G4double fyAxisMin = -kInfinity, fyAxisMax = kInfinity;
0120     G4double fzAxisMin = -kInfinity, fzAxisMax = kInfinity;
0121 };
0122 
0123 #include "G4VoxelLimits.icc"
0124 
0125 std::ostream& operator << (std::ostream& os, const G4VoxelLimits& pLim);
0126   // Print the limits to the stream in the form:
0127   //  "{(xmin,xmax) (ymin,ymax) (zmin,zmax)}"
0128   // Replace (xmin,xmax) by (-,-)  when not limited.
0129 
0130 #endif