G4CSGSolid.cc

Go to the documentation of this file.
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: G4CSGSolid.cc 69788 2013-05-15 12:06:57Z gcosmo $
00028 //
00029 // --------------------------------------------------------------------
00030 
00031 #include <cmath>
00032 
00033 #include "G4CSGSolid.hh"
00034 #include "Randomize.hh"
00035 #include "G4Polyhedron.hh"
00036 
00038 //
00039 // Constructor
00040 //  - Base class constructor 
00041 
00042 G4CSGSolid::G4CSGSolid(const G4String& name) :
00043   G4VSolid(name), fCubicVolume(0.), fSurfaceArea(0.), fpPolyhedron(0)
00044 {
00045 }
00046 
00048 //
00049 // Fake default constructor - sets only member data and allocates memory
00050 //                            for usage restricted to object persistency.
00051 
00052 G4CSGSolid::G4CSGSolid( __void__& a )
00053   : G4VSolid(a), fCubicVolume(0.), fSurfaceArea(0.), fpPolyhedron(0)
00054 {
00055 }
00056 
00058 //
00059 // Destructor
00060 //
00061 
00062 G4CSGSolid::~G4CSGSolid() 
00063 {
00064   delete fpPolyhedron;
00065 }
00066 
00068 //
00069 // Copy constructor
00070 //
00071 
00072 G4CSGSolid::G4CSGSolid(const G4CSGSolid& rhs)
00073   : G4VSolid(rhs), fCubicVolume(rhs.fCubicVolume),
00074     fSurfaceArea(rhs.fSurfaceArea), fpPolyhedron(0)
00075 {
00076 }
00077 
00079 //
00080 // Assignment operator
00081 
00082 G4CSGSolid& G4CSGSolid::operator = (const G4CSGSolid& rhs) 
00083 {
00084    // Check assignment to self
00085    //
00086    if (this == &rhs)  { return *this; }
00087 
00088    // Copy base class data
00089    //
00090    G4VSolid::operator=(rhs);
00091 
00092    // Copy data
00093    //
00094    fCubicVolume = rhs.fCubicVolume;
00095    fSurfaceArea = rhs.fSurfaceArea;
00096    fpPolyhedron = 0;
00097 
00098    return *this;
00099 }  
00100 
00101 G4double G4CSGSolid::GetRadiusInRing(G4double rmin, G4double rmax) const
00102 {
00103   // Generate radius in annular ring according to uniform area
00104   //
00105   if (rmin<=0.)   { return rmax*std::sqrt(G4UniformRand()); }
00106   if (rmin!=rmax) { return std::sqrt(G4UniformRand()
00107                            * (sqr(rmax)-sqr(rmin))+sqr(rmin)); }
00108   return rmin;
00109 }
00110 
00111 std::ostream& G4CSGSolid::StreamInfo(std::ostream& os) const
00112 {
00113   os << "-----------------------------------------------------------\n"
00114      << "    *** Dump for solid - " << GetName() << " ***\n"
00115      << "    ===================================================\n"
00116      << " Solid type: " << GetEntityType() << "\n"
00117      << " Parameters: \n"
00118      << "   NOT available !\n"
00119      << "-----------------------------------------------------------\n";
00120 
00121   return os;
00122 }
00123 
00124 G4Polyhedron* G4CSGSolid::GetPolyhedron () const
00125 {
00126   if (!fpPolyhedron ||
00127       fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
00128       fpPolyhedron->GetNumberOfRotationSteps())
00129     {
00130       delete fpPolyhedron;
00131       fpPolyhedron = CreatePolyhedron();
00132     }
00133   return fpPolyhedron;
00134 }

Generated on Mon May 27 17:47:58 2013 for Geant4 by  doxygen 1.4.7