G4VisExtent.cc

Go to the documentation of this file.
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 // A.Walkden 28/11/95
00031 // G4VisExtent.cc - to return parameters useful to the drawing window
00032 // employed by Visualization code. 
00033 
00034 #include "G4VisExtent.hh"
00035 
00036 #include "G4ios.hh"
00037 
00038 const G4VisExtent G4VisExtent::NullExtent;  // Default extent is null.
00039 
00040 G4VisExtent::G4VisExtent (G4double xmin, G4double xmax, 
00041                           G4double ymin, G4double ymax, 
00042                           G4double zmin, G4double zmax):
00043   fXmin(xmin), fXmax(xmax), fYmin(ymin), fYmax(ymax), fZmin(zmin), fZmax(zmax),
00044   fRadiusCached(false), fCentreCached(false), fRadius(0.)
00045 {}
00046 
00047 G4VisExtent::G4VisExtent (const G4Point3D& centre, G4double radius):
00048   fRadiusCached(true), fCentreCached(true),
00049   fRadius(radius), fCentre(centre)
00050 {
00051   // Use exscribed radius ... see comments in header file.
00052   G4double halfSide (radius / std::sqrt (3.));
00053   fXmin = centre.x () - halfSide;
00054   fXmax = centre.x () + halfSide;
00055   fYmin = centre.y () - halfSide;
00056   fYmax = centre.y () + halfSide;
00057   fZmin = centre.z () - halfSide;
00058   fZmax = centre.z () + halfSide;
00059 }
00060 
00061 G4VisExtent::~G4VisExtent () {}
00062 
00063 const G4Point3D& G4VisExtent::GetExtentCentre () const {
00064   if (!fCentreCached) {
00065     fCentre = G4Point3D (((fXmin + fXmax) / 2.),
00066                          ((fYmin + fYmax) / 2.),
00067                          ((fZmin + fZmax) / 2.));
00068     fCentreCached = true;
00069   }
00070   return fCentre;
00071 }
00072 
00073 G4double G4VisExtent::GetExtentRadius () const {
00074   if (!fRadiusCached) {
00075     fRadius = std::sqrt (((fXmax - fXmin) * (fXmax - fXmin)) +
00076                          ((fYmax - fYmin) * (fYmax - fYmin)) +
00077                          ((fZmax - fZmin) * (fZmax - fZmin))) / 2.;
00078     fRadiusCached = true;
00079   }
00080   return fRadius;
00081 }
00082 
00083 std::ostream& operator << (std::ostream& os, const G4VisExtent& e) {
00084   os << "G4VisExtent (bounding box):";
00085   os << "\n  X limits: " << e.fXmin << ' ' << e.fXmax;
00086   os << "\n  Y limits: " << e.fYmin << ' ' << e.fYmax;
00087   os << "\n  Z limits: " << e.fZmin << ' ' << e.fZmax;
00088   return os;
00089 }
00090 
00091 G4bool G4VisExtent::operator != (const G4VisExtent& e) const {
00092   return ((fXmin != e.fXmin) ||
00093           (fXmax != e.fXmax) ||
00094           (fYmin != e.fYmin) ||
00095           (fYmax != e.fYmax) ||
00096           (fZmin != e.fZmin) ||
00097           (fZmax != e.fZmax));
00098 }

Generated on Mon May 27 17:50:16 2013 for Geant4 by  doxygen 1.4.7