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 // class G4GeometryTolerance 00030 // 00031 // Implementation 00032 // 00033 // Author: 00034 // 30.10.06 - G.Cosmo, first implementation 00035 // -------------------------------------------------------------------- 00036 00037 #include "G4GeometryTolerance.hh" 00038 #include "G4SystemOfUnits.hh" 00039 #include "globals.hh" 00040 00041 00042 // *************************************************************************** 00043 // Static class data 00044 // *************************************************************************** 00045 // 00046 G4GeometryTolerance* G4GeometryTolerance::fInstance = 0; 00047 G4bool G4GeometryTolerance::fInitialised = false; 00048 G4double G4GeometryTolerance::fCarTolerance = 1E-9*mm; 00049 G4double G4GeometryTolerance::fAngTolerance = 1E-9*rad; 00050 G4double G4GeometryTolerance::fRadTolerance = 1E-9*mm; 00051 00052 // *************************************************************************** 00053 // Constructor. 00054 // *************************************************************************** 00055 // 00056 G4GeometryTolerance::G4GeometryTolerance() 00057 { 00058 } 00059 00060 // *************************************************************************** 00061 // Empty destructor. 00062 // *************************************************************************** 00063 // 00064 G4GeometryTolerance::~G4GeometryTolerance() 00065 { 00066 } 00067 00068 // *************************************************************************** 00069 // Returns the instance of the singleton. 00070 // Creates it in case it's called for the first time. 00071 // *************************************************************************** 00072 // 00073 G4GeometryTolerance* G4GeometryTolerance::GetInstance() 00074 { 00075 static G4GeometryTolerance theToleranceManager; 00076 if (!fInstance) 00077 { 00078 fInstance = &theToleranceManager; 00079 } 00080 return fInstance; 00081 } 00082 00083 // *************************************************************************** 00084 // Accessors. 00085 // *************************************************************************** 00086 // 00087 G4double G4GeometryTolerance::GetSurfaceTolerance() const 00088 { 00089 return fCarTolerance; 00090 } 00091 00092 G4double G4GeometryTolerance::GetAngularTolerance() const 00093 { 00094 return fAngTolerance; 00095 } 00096 00097 G4double G4GeometryTolerance::GetRadialTolerance() const 00098 { 00099 return fRadTolerance; 00100 } 00101 00102 // *************************************************************************** 00103 // Sets the tolerance to a value computed on the basis of the world volume 00104 // extent provided as argument. The method can be called only once. 00105 // *************************************************************************** 00106 // 00107 void G4GeometryTolerance::SetSurfaceTolerance(G4double worldExtent) 00108 { 00109 if (!fInitialised) 00110 { 00111 fCarTolerance = worldExtent*1E-11; 00112 fInitialised = true; 00113 } 00114 else 00115 { 00116 G4cout << "WARNING - G4GeometryTolerance::SetSurfaceTolerance()" << G4endl 00117 << " Tolerance can only be set once. Currently set to: " 00118 << fCarTolerance/mm << " mm." << G4endl; 00119 G4Exception("G4GeometryTolerance::SetSurfaceTolerance()", 00120 "NotApplicable", JustWarning, 00121 "The tolerance has been already set!"); 00122 } 00123 }