Geant4  10.01.p01
G4VisExtent.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4VisExtent.cc 78955 2014-02-05 09:45:46Z gcosmo $
28 //
29 //
30 // A.Walkden 28/11/95
31 // G4VisExtent.cc - to return parameters useful to the drawing window
32 // employed by Visualization code.
33 
34 #include "G4VisExtent.hh"
35 
36 #include "G4ios.hh"
37 
38 const G4VisExtent G4VisExtent::NullExtent; // Default extent is null.
39 
41  G4double ymin, G4double ymax,
42  G4double zmin, G4double zmax):
43  fXmin(xmin), fXmax(xmax), fYmin(ymin), fYmax(ymax), fZmin(zmin), fZmax(zmax),
44  fRadiusCached(false), fCentreCached(false), fRadius(0.)
45 {}
46 
48  fRadiusCached(true), fCentreCached(true),
49  fRadius(radius), fCentre(centre)
50 {
51  // Use exscribed radius ... see comments in header file.
52  G4double halfSide (radius / std::sqrt (3.));
53  fXmin = centre.x () - halfSide;
54  fXmax = centre.x () + halfSide;
55  fYmin = centre.y () - halfSide;
56  fYmax = centre.y () + halfSide;
57  fZmin = centre.z () - halfSide;
58  fZmax = centre.z () + halfSide;
59 }
60 
62 
64  if (!fCentreCached) {
65  fCentre = G4Point3D (((fXmin + fXmax) / 2.),
66  ((fYmin + fYmax) / 2.),
67  ((fZmin + fZmax) / 2.));
68  fCentreCached = true;
69  }
70  return fCentre;
71 }
72 
74  if (!fRadiusCached) {
75  fRadius = std::sqrt (((fXmax - fXmin) * (fXmax - fXmin)) +
76  ((fYmax - fYmin) * (fYmax - fYmin)) +
77  ((fZmax - fZmin) * (fZmax - fZmin))) / 2.;
78  fRadiusCached = true;
79  }
80  return fRadius;
81 }
82 
83 std::ostream& operator << (std::ostream& os, const G4VisExtent& e) {
84  os << "G4VisExtent (bounding box):";
85  os << "\n X limits: " << e.fXmin << ' ' << e.fXmax;
86  os << "\n Y limits: " << e.fYmin << ' ' << e.fYmax;
87  os << "\n Z limits: " << e.fZmin << ' ' << e.fZmax;
88  return os;
89 }
90 
92  return ((fXmin != e.fXmin) ||
93  (fXmax != e.fXmax) ||
94  (fYmin != e.fYmin) ||
95  (fYmax != e.fYmax) ||
96  (fZmin != e.fZmin) ||
97  (fZmax != e.fZmax));
98 }
G4double fXmin
Definition: G4VisExtent.hh:83
static const G4VisExtent NullExtent
Definition: G4VisExtent.hh:80
G4bool fRadiusCached
Definition: G4VisExtent.hh:84
const G4Point3D & GetExtentCentre() const
Definition: G4VisExtent.cc:63
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:35
G4double fZmin
Definition: G4VisExtent.hh:83
G4bool fCentreCached
Definition: G4VisExtent.hh:84
G4bool operator!=(const G4VisExtent &e) const
Definition: G4VisExtent.cc:91
G4double fYmin
Definition: G4VisExtent.hh:83
G4double GetExtentRadius() const
Definition: G4VisExtent.cc:73
bool G4bool
Definition: G4Types.hh:79
G4double fYmax
Definition: G4VisExtent.hh:83
G4double fRadius
Definition: G4VisExtent.hh:85
G4double fXmax
Definition: G4VisExtent.hh:83
G4double fZmax
Definition: G4VisExtent.hh:83
G4Point3D fCentre
Definition: G4VisExtent.hh:86
double G4double
Definition: G4Types.hh:76
std::ostream & operator<<(std::ostream &os, const G4VisExtent &e)
Definition: G4VisExtent.cc:83
G4VisExtent(G4double xmin=0., G4double xmax=0., G4double ymin=0., G4double ymax=0., G4double zmin=0., G4double zmax=0.)
Definition: G4VisExtent.cc:40