Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4CSGSolid.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$
28//
29// --------------------------------------------------------------------
30
31#include <cmath>
32
33#include "G4CSGSolid.hh"
34#include "Randomize.hh"
35#include "G4Polyhedron.hh"
36
37//////////////////////////////////////////////////////////////////////////
38//
39// Constructor
40// - Base class constructor
41
43 G4VSolid(name), fCubicVolume(0.), fSurfaceArea(0.), fpPolyhedron(0)
44{
45}
46
47//////////////////////////////////////////////////////////////////////////
48//
49// Fake default constructor - sets only member data and allocates memory
50// for usage restricted to object persistency.
51
53 : G4VSolid(a), fCubicVolume(0.), fSurfaceArea(0.), fpPolyhedron(0)
54{
55}
56
57//////////////////////////////////////////////////////////////////////////
58//
59// Destructor
60//
61
63{
64 delete fpPolyhedron;
65}
66
67//////////////////////////////////////////////////////////////////////////
68//
69// Copy constructor
70//
71
73 : G4VSolid(rhs), fCubicVolume(rhs.fCubicVolume),
74 fSurfaceArea(rhs.fSurfaceArea), fpPolyhedron(0)
75{
76}
77
78//////////////////////////////////////////////////////////////////////////
79//
80// Assignment operator
81
83{
84 // Check assignment to self
85 //
86 if (this == &rhs) { return *this; }
87
88 // Copy base class data
89 //
91
92 // Copy data
93 //
96 fpPolyhedron = 0;
97
98 return *this;
99}
100
102{
103 // Generate radius in annular ring according to uniform area
104 //
105 if (rmin<=0.) { return rmax*std::sqrt(G4UniformRand()); }
106 if (rmin!=rmax) { return std::sqrt(G4UniformRand()
107 * (sqr(rmax)-sqr(rmin))+sqr(rmin)); }
108 return rmin;
109}
110
111std::ostream& G4CSGSolid::StreamInfo(std::ostream& os) const
112{
113 os << "-----------------------------------------------------------\n"
114 << " *** Dump for solid - " << GetName() << " ***\n"
115 << " ===================================================\n"
116 << " Solid type: " << GetEntityType() << "\n"
117 << " Parameters: \n"
118 << " NOT available !\n"
119 << "-----------------------------------------------------------\n";
120
121 return os;
122}
123
125{
126 if (!fpPolyhedron ||
129 {
130 delete fpPolyhedron;
132 }
133 return fpPolyhedron;
134}
double G4double
Definition: G4Types.hh:64
#define G4UniformRand()
Definition: Randomize.hh:53
G4Polyhedron * fpPolyhedron
Definition: G4CSGSolid.hh:80
G4double fSurfaceArea
Definition: G4CSGSolid.hh:79
G4double fCubicVolume
Definition: G4CSGSolid.hh:78
G4double GetRadiusInRing(G4double rmin, G4double rmax) const
Definition: G4CSGSolid.cc:101
virtual std::ostream & StreamInfo(std::ostream &os) const
Definition: G4CSGSolid.cc:111
G4CSGSolid(const G4String &pName)
Definition: G4CSGSolid.cc:42
virtual G4Polyhedron * GetPolyhedron() const
Definition: G4CSGSolid.cc:124
G4CSGSolid & operator=(const G4CSGSolid &rhs)
Definition: G4CSGSolid.cc:82
virtual ~G4CSGSolid()
Definition: G4CSGSolid.cc:62
G4int GetNumberOfRotationStepsAtTimeOfCreation() const
G4String GetName() const
virtual G4Polyhedron * CreatePolyhedron() const
Definition: G4VSolid.cc:637
G4VSolid & operator=(const G4VSolid &rhs)
Definition: G4VSolid.cc:110
virtual G4GeometryType GetEntityType() const =0
static G4int GetNumberOfRotationSteps()
T sqr(const T &x)
Definition: templates.hh:145