Back to home page

EIC code displayed by LXR

 
 

    


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

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 //
0027 //
0028 // 
0029 // A.Walkden 28/11/95
0030 
0031 // Class Description:
0032 // G4VisExtent defines a bounding box in a visualisable object's local
0033 // coordinate system which includes the object.
0034 // WARNING: it also attempts to support the concept of a bounding
0035 // sphere.  (This is used extensively in the G4 Visualisation System
0036 // to calculate camera parameters, etc.)  Be aware that this involves
0037 // loss of information.  Given a bounding box, one can calculate the
0038 // bounding sphere; inverting this will produce a cube which *might*
0039 // *not* include the object.  E.g., a long thin object of length l
0040 // will have a bounding sphere of diameter l; the corresponding cube
0041 // will have side l/std::sqrt(3) so that the bounding sphere diameter is
0042 // still l.  Thus the long thin object will stick out of the cube.
0043 // So, if you once use the concept of bounding sphere you must stick
0044 // with it and abandon the concept of bounding box.
0045 // Class Description - End:
0046 
0047 #ifndef G4VISEXTENT_HH
0048 #define G4VISEXTENT_HH
0049 
0050 #include "globals.hh"
0051 #include "G4Point3D.hh"
0052 #include "G4Transform3D.hh"
0053 
0054 class G4VisExtent
0055 {
0056 public: // With description
0057 
0058   G4VisExtent (G4double xmin = 0., G4double xmax = 0., 
0059                G4double ymin = 0., G4double ymax = 0., 
0060                G4double zmin = 0., G4double zmax = 0.);
0061   G4VisExtent (const G4Point3D& centre, G4double radius);
0062   ~G4VisExtent ();
0063   static const G4VisExtent& GetNullExtent ();
0064   G4bool operator != (const G4VisExtent& e) const;
0065   G4bool operator == (const G4VisExtent& e) const {return !operator!=(e);}
0066 
0067   G4VisExtent& Transform (const G4Transform3D&);
0068   // The above transforms the box defined by the 6 limits fXmin, fXmax,
0069   // etc., and produces a new box that encloses the transformed box. If the
0070   // transform includes a rotation the new box will likely be a good deal larger
0071   // than the old one, but hey-ho, the concept of G4VisExtent requires the
0072   // limits to be along the major axes and thus defines a box whose edges are
0073   // parallel to the major axes. So use the above with care.
0074 
0075   G4double  GetXmin         () const;
0076   G4double  GetXmax         () const;
0077   G4double  GetYmin         () const;
0078   G4double  GetYmax         () const;
0079   G4double  GetZmin         () const;
0080   G4double  GetZmax         () const;
0081   const G4Point3D& GetExtentCentre () const;
0082   const G4Point3D& GetExtentCenter () const;
0083   G4double  GetExtentRadius () const;
0084   void SetXmin (G4double xmin);
0085   void SetXmax (G4double xmax);
0086   void SetYmin (G4double ymin);
0087   void SetYmax (G4double ymax);
0088   void SetZmin (G4double zmin);
0089   void SetZmax (G4double zmax);
0090   friend std::ostream& operator << (std::ostream& os, const G4VisExtent& e);
0091 
0092 private:
0093   G4double fXmin, fXmax, fYmin, fYmax, fZmin, fZmax;
0094   mutable G4bool fRadiusCached, fCentreCached;
0095   mutable G4double fRadius;
0096   mutable G4Point3D fCentre;
0097 };
0098 
0099 inline G4double G4VisExtent::GetXmin () const { return fXmin; }
0100 inline G4double G4VisExtent::GetXmax () const { return fXmax; }
0101 inline G4double G4VisExtent::GetYmin () const { return fYmin; }
0102 inline G4double G4VisExtent::GetYmax () const { return fYmax; }
0103 inline G4double G4VisExtent::GetZmin () const { return fZmin; }
0104 inline G4double G4VisExtent::GetZmax () const { return fZmax; }
0105 
0106 inline const G4Point3D& G4VisExtent::GetExtentCenter () const {
0107   return GetExtentCentre ();
0108 }
0109 
0110 inline void G4VisExtent::SetXmin (G4double xmin)
0111 {fXmin = xmin; fRadiusCached = false; fCentreCached = false;}
0112 inline void G4VisExtent::SetXmax (G4double xmax)
0113 {fXmax = xmax; fRadiusCached = false; fCentreCached = false;}
0114 inline void G4VisExtent::SetYmin (G4double ymin)
0115 {fYmin = ymin; fRadiusCached = false; fCentreCached = false;}
0116 inline void G4VisExtent::SetYmax (G4double ymax)
0117 {fYmax = ymax; fRadiusCached = false; fCentreCached = false;}
0118 inline void G4VisExtent::SetZmin (G4double zmin)
0119 {fZmin = zmin; fRadiusCached = false; fCentreCached = false;}
0120 inline void G4VisExtent::SetZmax (G4double zmax)
0121 {fZmax = zmax; fRadiusCached = false; fCentreCached = false;}
0122 
0123 #endif