Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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: G4CSGSolid.cc 69788 2013-05-15 12:06:57Z gcosmo $
28 //
29 // --------------------------------------------------------------------
30 
31 #include <cmath>
32 
33 #include "G4CSGSolid.hh"
34 #include "Randomize.hh"
35 #include "G4Polyhedron.hh"
36 
38 //
39 // Constructor
40 // - Base class constructor
41 
43  G4VSolid(name), fCubicVolume(0.), fSurfaceArea(0.), fpPolyhedron(0)
44 {
45 }
46 
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 
58 //
59 // Destructor
60 //
61 
63 {
64  delete fpPolyhedron;
65 }
66 
68 //
69 // Copy constructor
70 //
71 
73  : G4VSolid(rhs), fCubicVolume(rhs.fCubicVolume),
74  fSurfaceArea(rhs.fSurfaceArea), fpPolyhedron(0)
75 {
76 }
77 
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 
111 std::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 }