Geant4  10.03
G4GeometryTolerance.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: G4GeometryTolerance.cc 96427 2016-04-14 09:37:29Z gcosmo $
28 //
29 // class G4GeometryTolerance
30 //
31 // Implementation
32 //
33 // Author:
34 // 30.10.06 - G.Cosmo, first implementation
35 // --------------------------------------------------------------------
36 
37 #include "G4GeometryTolerance.hh"
38 #include "G4SystemOfUnits.hh"
39 #include "G4AutoDelete.hh"
40 #include "globals.hh"
41 
42 
43 // ***************************************************************************
44 // Static class instance
45 // ***************************************************************************
46 //
48 
49 // ***************************************************************************
50 // Constructor.
51 // ***************************************************************************
52 //
54 {
55  fCarTolerance = 1E-9*mm;
56  fAngTolerance = 1E-9*rad;
57  fRadTolerance = 1E-9*mm;
58 }
59 
60 // ***************************************************************************
61 // Empty destructor.
62 // ***************************************************************************
63 //
65 {
66 }
67 
68 // ***************************************************************************
69 // Returns the instance of the singleton.
70 // Creates it in case it's called for the first time.
71 // ***************************************************************************
72 //
74 {
75  if (fpInstance == 0)
76  {
79  }
80  return fpInstance;
81 }
82 
83 // ***************************************************************************
84 // Accessors.
85 // ***************************************************************************
86 //
88 {
89  return fCarTolerance;
90 }
91 
93 {
94  return fAngTolerance;
95 }
96 
98 {
99  return fRadTolerance;
100 }
101 
102 // ***************************************************************************
103 // Sets the tolerance to a value computed on the basis of the world volume
104 // extent provided as argument. The method can be called only once.
105 // ***************************************************************************
106 //
108 {
109  if (!fInitialised)
110  {
111  fCarTolerance = fRadTolerance = worldExtent*1E-11;
112  fInitialised = true;
113  }
114  else
115  {
116  G4cout << "WARNING - G4GeometryTolerance::SetSurfaceTolerance()" << G4endl
117  << " Tolerance can only be set once. Currently set to: "
118  << fCarTolerance/mm << " mm." << G4endl;
119  G4Exception("G4GeometryTolerance::SetSurfaceTolerance()",
120  "NotApplicable", JustWarning,
121  "The tolerance has been already set!");
122  }
123 }
static constexpr double mm
Definition: G4SIunits.hh:115
G4double GetSurfaceTolerance() const
static constexpr double rad
Definition: G4SIunits.hh:149
#define G4ThreadLocal
Definition: tls.hh:89
static G4ThreadLocal G4GeometryTolerance * fpInstance
void Register(T *inst)
Definition: G4AutoDelete.hh:65
G4GLOB_DLL std::ostream G4cout
G4double GetRadialTolerance() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
void SetSurfaceTolerance(G4double worldExtent)
G4double GetAngularTolerance() const
static G4GeometryTolerance * GetInstance()