G4BREPSolidCylinder.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 // $Id$
00027 //
00028 // ----------------------------------------------------------------------
00029 // GEANT 4 class source file
00030 //
00031 // G4BREPSolidCylinder.cc
00032 //
00033 // ----------------------------------------------------------------------
00034 
00035 #include "G4BREPSolidCylinder.hh"
00036 #include "G4CircularCurve.hh"
00037 #include "G4FPlane.hh"
00038 #include "G4FCylindricalSurface.hh"
00039 
00040 G4BREPSolidCylinder::G4BREPSolidCylinder(const G4String& name,
00041                                          const G4ThreeVector& origin,
00042                                          const G4ThreeVector& axis,
00043                                          const G4ThreeVector& direction,
00044                                                G4double radius,
00045                                                G4double length)
00046   : G4BREPSolid(name)
00047 {
00048   nb_of_surfaces = 3;
00049   active=1;
00050   
00051   // Save constructor parameters
00052   constructorParams.origin       = origin;
00053   constructorParams.axis         = axis;
00054   constructorParams.direction    = direction;
00055   constructorParams.length       = length;
00056   constructorParams.radius       = radius;
00057   
00058   InitializeCylinder();
00059 }
00060 
00061 G4BREPSolidCylinder::G4BREPSolidCylinder( __void__& a )
00062   : G4BREPSolid(a)
00063 {
00064 }
00065 
00066 G4BREPSolidCylinder::~G4BREPSolidCylinder()
00067 {
00068 }
00069 
00070 G4BREPSolidCylinder::G4BREPSolidCylinder(const G4BREPSolidCylinder& rhs)
00071   : G4BREPSolid(rhs)
00072 {
00073   constructorParams.origin       = rhs.constructorParams.origin;
00074   constructorParams.axis         = rhs.constructorParams.axis;
00075   constructorParams.direction    = rhs.constructorParams.direction;
00076   constructorParams.length       = rhs.constructorParams.length;
00077   constructorParams.radius       = rhs.constructorParams.radius;
00078   
00079   InitializeCylinder();
00080 }
00081 
00082 G4BREPSolidCylinder&
00083 G4BREPSolidCylinder::operator = (const G4BREPSolidCylinder& rhs) 
00084 {
00085   // Check assignment to self
00086   //
00087   if (this == &rhs)  { return *this; }
00088 
00089   // Copy base class data
00090   //
00091   G4BREPSolid::operator=(rhs);
00092 
00093   // Copy data
00094   //
00095   constructorParams.origin       = rhs.constructorParams.origin;
00096   constructorParams.axis         = rhs.constructorParams.axis;
00097   constructorParams.direction    = rhs.constructorParams.direction;
00098   constructorParams.length       = rhs.constructorParams.length;
00099   constructorParams.radius       = rhs.constructorParams.radius;
00100   
00101   InitializeCylinder();
00102 
00103   return *this;
00104 }  
00105 
00106 void G4BREPSolidCylinder::InitializeCylinder()
00107 {
00108   SurfaceVec = new G4Surface*[3];
00109   G4CurveVector cv;
00110   G4CircularCurve* tmp;
00111 
00112   // Creation of the cylindrical surface
00113   SurfaceVec[0] = new G4FCylindricalSurface(constructorParams.origin,
00114                                             constructorParams.axis,
00115                                             constructorParams.radius,
00116                                             constructorParams.length);
00117   //SurfaceVec[0]->SetBoundaries(&cv);
00118   //cv.clear();
00119 
00120   // Creation of the first circular surface, which origin is origin
00121   G4Point3D  ArcStart1 = G4Point3D( constructorParams.origin
00122                                 + ( constructorParams.radius
00123                                 *   constructorParams.direction ) );
00124   G4Vector3D axis1 = G4Vector3D( constructorParams.axis.cross( constructorParams.direction ) );
00125 
00126   tmp = new G4CircularCurve;
00127   tmp->Init( G4Axis2Placement3D(constructorParams.direction, axis1,
00128                                 constructorParams.origin),
00129              constructorParams.radius );
00130   tmp->SetBounds(ArcStart1, ArcStart1);
00131   cv.push_back(tmp);
00132 
00133   SurfaceVec[1] = new G4FPlane(constructorParams.direction, axis1,
00134                                constructorParams.origin);
00135   SurfaceVec[1]->SetBoundaries(&cv);
00136   cv.clear();
00137   
00138 
00139   // Creation of the second circular surface
00140   G4Point3D  origin2   = G4Point3D( constructorParams.origin
00141                                 + ( constructorParams.length
00142                                 *   constructorParams.axis ) );  
00143   G4Point3D  ArcStart2 = origin2
00144                        + G4Point3D( constructorParams.radius
00145                                   * constructorParams.direction );
00146   G4Vector3D axis2     = axis1;
00147 
00148   tmp = new G4CircularCurve;
00149   tmp->Init( G4Axis2Placement3D(constructorParams.direction,
00150                                 axis2, origin2),
00151              constructorParams.radius);
00152   tmp->SetBounds(ArcStart2, ArcStart2);
00153   cv.push_back(tmp);
00154 
00155   SurfaceVec[2] = new G4FPlane(constructorParams.direction, axis2, origin2);
00156   SurfaceVec[2]->SetBoundaries(&cv);
00157   cv.clear();
00158 
00159   Initialize();
00160 }
00161 
00162 G4VSolid* G4BREPSolidCylinder::Clone() const
00163 {
00164   return new G4BREPSolidCylinder(*this);
00165 }
00166 
00167 std::ostream& G4BREPSolidCylinder::StreamInfo(std::ostream& os) const
00168 {
00169   // Streams solid contents to output stream.
00170 
00171   G4BREPSolid::StreamInfo( os )
00172   << "\n origin:       " << constructorParams.origin
00173   << "\n axis:         " << constructorParams.axis
00174   << "\n direction:    " << constructorParams.direction
00175   << "\n length:       " << constructorParams.length
00176   << "\n radius:       " << constructorParams.radius
00177   << "\n-----------------------------------------------------------\n";
00178 
00179   return os;
00180 }
00181 

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