source: trunk/source/graphics_reps/src/G4VisExtent.cc@ 1339

Last change on this file since 1339 was 1337, checked in by garnier, 15 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 3.4 KB
Line 
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,v 1.10 2006/06/29 19:07:28 gunter Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-01 $
29//
30//
31// A.Walkden 28/11/95
32// G4VisExtent.cc - to return parameters useful to the drawing window
33// employed by Visualization code.
34
35#include "G4VisExtent.hh"
36
37#include "G4ios.hh"
38
39const G4VisExtent G4VisExtent::NullExtent; // Default extent is null.
40
41G4VisExtent::G4VisExtent (G4double xmin, G4double xmax,
42 G4double ymin, G4double ymax,
43 G4double zmin, G4double zmax)
44:fXmin(xmin), fXmax(xmax), fYmin(ymin), fYmax(ymax), fZmin(zmin), fZmax(zmax)
45{}
46
47G4VisExtent::G4VisExtent (const G4Point3D& centre, G4double radius) {
48 // Use exscribed radius ... see comments in header file.
49 G4double halfSide (radius / std::sqrt (3.));
50 fXmin = centre.x () - halfSide;
51 fXmax = centre.x () + halfSide;
52 fYmin = centre.y () - halfSide;
53 fYmax = centre.y () + halfSide;
54 fZmin = centre.z () - halfSide;
55 fZmax = centre.z () + halfSide;
56}
57
58G4VisExtent::~G4VisExtent () {}
59
60G4Point3D G4VisExtent::GetExtentCentre () const {
61 return G4Point3D (((fXmin + fXmax) / 2.),
62 ((fYmin + fYmax) / 2.),
63 ((fZmin + fZmax) / 2.));
64}
65
66G4double G4VisExtent::GetExtentRadius () const {
67 return std::sqrt (((fXmax - fXmin) * (fXmax - fXmin)) +
68 ((fYmax - fYmin) * (fYmax - fYmin)) +
69 ((fZmax - fZmin) * (fZmax - fZmin))) / 2.;
70}
71
72std::ostream& operator << (std::ostream& os, const G4VisExtent& e) {
73 os << "G4VisExtent (bounding box):";
74 os << "\n X limits: " << e.fXmin << ' ' << e.fXmax;
75 os << "\n Y limits: " << e.fYmin << ' ' << e.fYmax;
76 os << "\n Z limits: " << e.fZmin << ' ' << e.fZmax;
77 return os;
78}
79
80G4bool G4VisExtent::operator != (const G4VisExtent& e) const {
81 return ((fXmin != e.fXmin) ||
82 (fXmax != e.fXmax) ||
83 (fYmin != e.fYmin) ||
84 (fYmax != e.fYmax) ||
85 (fZmin != e.fZmin) ||
86 (fZmax != e.fZmax));
87}
Note: See TracBrowser for help on using the repository browser.