G4PVParameterised Class Reference

#include <G4PVParameterised.hh>

Inheritance diagram for G4PVParameterised:

G4PVReplica G4VPhysicalVolume

Public Member Functions

 G4PVParameterised (const G4String &pName, G4LogicalVolume *pLogical, G4LogicalVolume *pMotherLogical, const EAxis pAxis, const G4int nReplicas, G4VPVParameterisation *pParam, G4bool pSurfChk=false)
 G4PVParameterised (const G4String &pName, G4LogicalVolume *pLogical, G4VPhysicalVolume *pMother, const EAxis pAxis, const G4int nReplicas, G4VPVParameterisation *pParam, G4bool pSurfChk=false)
 G4PVParameterised (__void__ &)
virtual ~G4PVParameterised ()
G4bool IsParameterised () const
G4VPVParameterisationGetParameterisation () const
void GetReplicationData (EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const
virtual void SetRegularStructureId (G4int Code)
G4bool CheckOverlaps (G4int res=1000, G4double tol=0., G4bool verbose=true)

Detailed Description

Definition at line 47 of file G4PVParameterised.hh.


Constructor & Destructor Documentation

G4PVParameterised::G4PVParameterised ( const G4String pName,
G4LogicalVolume pLogical,
G4LogicalVolume pMotherLogical,
const EAxis  pAxis,
const G4int  nReplicas,
G4VPVParameterisation pParam,
G4bool  pSurfChk = false 
)

Definition at line 78 of file G4PVParameterised.cc.

References CheckOverlaps().

00085   : G4PVReplica(pName, pLogical, pMotherLogical, pAxis, nReplicas, 0, 0),
00086     fparam(pParam)
00087 {
00088   if (pSurfChk) { CheckOverlaps(); }
00089 }

G4PVParameterised::G4PVParameterised ( const G4String pName,
G4LogicalVolume pLogical,
G4VPhysicalVolume pMother,
const EAxis  pAxis,
const G4int  nReplicas,
G4VPVParameterisation pParam,
G4bool  pSurfChk = false 
)

Definition at line 46 of file G4PVParameterised.cc.

References CheckOverlaps(), G4endl, G4Exception(), G4VPhysicalVolume::GetName(), G4VPhysicalVolume::IsParameterised(), and JustWarning.

00053   : G4PVReplica(pName, pLogical, pMother, pAxis, nReplicas, 0, 0),
00054     fparam(pParam)
00055 {
00056 #ifdef G4VERBOSE  
00057   if ((pMother) && (pMother->IsParameterised()))
00058   {
00059     std::ostringstream message, hint;
00060     message << "A parameterised volume is being placed" << G4endl
00061             << "inside another parameterised volume !";
00062     hint << "To make sure that no overlaps are generated," << G4endl
00063          << "you should verify the mother replicated shapes" << G4endl
00064          << "are of the same type and dimensions." << G4endl
00065          << "   Mother physical volume: " << pMother->GetName() << G4endl
00066          << "   Parameterised volume: " << pName << G4endl
00067          << "  (To switch this warning off, compile with G4_NO_VERBOSE)";
00068     G4Exception("G4PVParameterised::G4PVParameterised()", "GeomVol1002",
00069                 JustWarning, message, G4String(hint.str()));
00070   }
00071 #endif
00072   if (pSurfChk) { CheckOverlaps(); }
00073 }

G4PVParameterised::G4PVParameterised ( __void__ &   ) 

Definition at line 95 of file G4PVParameterised.cc.

00096   : G4PVReplica(a), fparam(0)
00097 {
00098 }

G4PVParameterised::~G4PVParameterised (  )  [virtual]

Definition at line 103 of file G4PVParameterised.cc.

00104 {
00105 }


Member Function Documentation

G4bool G4PVParameterised::CheckOverlaps ( G4int  res = 1000,
G4double  tol = 0.,
G4bool  verbose = true 
) [virtual]

Reimplemented from G4VPhysicalVolume.

Definition at line 154 of file G4PVParameterised.cc.

References G4VSolid::ComputeDimensions(), G4VPVParameterisation::ComputeSolid(), G4VPVParameterisation::ComputeTransformation(), G4VSolid::DistanceToIn(), G4BestUnit, G4cout, G4endl, G4Exception(), G4VPhysicalVolume::GetMotherLogical(), G4PVReplica::GetMultiplicity(), G4LogicalVolume::GetName(), G4VPhysicalVolume::GetName(), G4VSolid::GetPointOnSurface(), G4VPhysicalVolume::GetRotation(), G4LogicalVolume::GetSolid(), G4VPhysicalVolume::GetTranslation(), G4VSolid::Inside(), G4AffineTransform::Inverse(), JustWarning, kInside, kOutside, CLHEP::detail::n, and G4AffineTransform::TransformPoint().

Referenced by G4PVParameterised().

00155 {
00156   if (res<=0) { return false; }
00157 
00158   G4VSolid *solidA = 0, *solidB = 0;
00159   G4LogicalVolume *motherLog = GetMotherLogical();
00160   G4VSolid *motherSolid = motherLog->GetSolid();
00161   std::vector<G4ThreeVector> points;
00162 
00163   if (verbose)
00164   {
00165     G4cout << "Checking overlaps for parameterised volume "
00166            << GetName() << " ... ";
00167   }
00168 
00169   for (G4int i=0; i<GetMultiplicity(); i++)
00170   {
00171     solidA = fparam->ComputeSolid(i, this);
00172     solidA->ComputeDimensions(fparam, i, this);
00173     fparam->ComputeTransformation(i, this);
00174 
00175     // Create the transformation from daughter to mother
00176     //
00177     G4AffineTransform Tm( GetRotation(), GetTranslation() );
00178 
00179     // Generate random points on surface according to the given resolution,
00180     // transform them to the mother's coordinate system and if no overlaps
00181     // with the mother volume, cache them in a vector for later use with
00182     // the daughters
00183     //
00184     for (G4int n=0; n<res; n++)
00185     {
00186       G4ThreeVector mp = Tm.TransformPoint(solidA->GetPointOnSurface());
00187 
00188       // Checking overlaps with the mother volume
00189       //
00190       if (motherSolid->Inside(mp)==kOutside)
00191       {
00192         G4double distin = motherSolid->DistanceToIn(mp);
00193         if (distin > tol)
00194         {
00195           std::ostringstream message;
00196           message << "Overlap with mother volume !" << G4endl
00197                   << "         Overlap is detected for volume "
00198                   << GetName() << ", parameterised instance: " << i << G4endl
00199                   << "          with its mother volume "
00200                   << motherLog->GetName() << G4endl
00201                   << "          at mother local point " << mp << ", "
00202                   << "overlapping by at least: "
00203                   << G4BestUnit(distin, "Length");
00204           G4Exception("G4PVParameterised::CheckOverlaps()",
00205                       "GeomVol1002", JustWarning, message);
00206           return true;
00207         }
00208       }
00209       points.push_back(mp);
00210     }
00211 
00212     // Checking overlaps with each other parameterised instance
00213     //
00214     std::vector<G4ThreeVector>::iterator pos;
00215     for (G4int j=i+1; j<GetMultiplicity(); j++)
00216     {
00217       solidB = fparam->ComputeSolid(j,this);
00218       solidB->ComputeDimensions(fparam, j, this);
00219       fparam->ComputeTransformation(j, this);
00220 
00221       // Create the transformation for daughter volume
00222       //
00223       G4AffineTransform Td( GetRotation(), GetTranslation() );
00224 
00225       for (pos=points.begin(); pos!=points.end(); pos++)
00226       {
00227         // Transform each point according to daughter's frame
00228         //
00229         G4ThreeVector md = Td.Inverse().TransformPoint(*pos);
00230 
00231         if (solidB->Inside(md)==kInside)
00232         {
00233           G4double distout = solidB->DistanceToOut(md);
00234           if (distout > tol)
00235           {
00236             std::ostringstream message;
00237             message << "Overlap within parameterised volumes !" << G4endl
00238                     << "          Overlap is detected for volume "
00239                     << GetName() << ", parameterised instance: " << i << G4endl
00240                     << "          with parameterised volume instance: " << j
00241                     << G4endl
00242                     << "          at local point " << md << ", "
00243                     << "overlapping by at least: "
00244                     << G4BestUnit(distout, "Length")
00245                     << ", related to volume instance: " << j << ".";
00246             G4Exception("G4PVParameterised::CheckOverlaps()",
00247                         "GeomVol1002", JustWarning, message);
00248             return true;
00249           }
00250         }
00251       }
00252     }
00253   }
00254   if (verbose)
00255   {
00256     G4cout << "OK! " << G4endl;
00257   }
00258 
00259   return false;
00260 }

G4VPVParameterisation * G4PVParameterised::GetParameterisation (  )  const [virtual]

Reimplemented from G4PVReplica.

Definition at line 110 of file G4PVParameterised.cc.

Referenced by G4tgbGeometryDumper::DumpPVParameterised().

00111 {
00112   return fparam;
00113 }

void G4PVParameterised::GetReplicationData ( EAxis axis,
G4int nReplicas,
G4double width,
G4double offset,
G4bool consuming 
) const [virtual]

Reimplemented from G4PVReplica.

Definition at line 126 of file G4PVParameterised.cc.

References G4PVReplica::faxis, G4PVReplica::fnReplicas, G4PVReplica::foffset, and G4PVReplica::fwidth.

Referenced by G4tgbGeometryDumper::DumpPVParameterised().

00131 {
00132   axis = faxis;
00133   nReplicas = fnReplicas;
00134   width = fwidth;
00135   offset = foffset;
00136   consuming = false;
00137 }

G4bool G4PVParameterised::IsParameterised (  )  const [virtual]

Reimplemented from G4PVReplica.

Definition at line 118 of file G4PVParameterised.cc.

00119 {
00120   return true;
00121 }

void G4PVParameterised::SetRegularStructureId ( G4int  Code  )  [virtual]

Reimplemented from G4PVReplica.

Definition at line 142 of file G4PVParameterised.cc.

References G4PVReplica::SetRegularStructureId().

00143 {
00144   G4PVReplica::SetRegularStructureId( Code );
00145   // To undertake additional preparation, a derived volume must
00146   //   redefine this method, while calling also the above method.
00147 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:53:04 2013 for Geant4 by  doxygen 1.4.7