G3toG4MANY.cc File Reference

#include "globals.hh"
#include "G3toG4MANY.hh"
#include "G3Pos.hh"
#include "G3RotTable.hh"
#include "G4SubtractionSolid.hh"

Go to the source code of this file.

Functions

void G3toG4MANY (G3VolTableEntry *curVTE)
void MakeBooleanSolids (G3VolTableEntry *curVTE, G3VolTableEntryVector *overlaps, const G4Transform3D &transform)
void SubstractSolids (G3VolTableEntry *vte1, G3VolTableEntry *vte2, G4int copy, const G4Transform3D &transform)
G4Transform3D GetTransform3D (G3Pos *g3pos)


Function Documentation

void G3toG4MANY ( G3VolTableEntry curVTE  ) 

Definition at line 39 of file G3toG4MANY.cc.

References FatalException, G3toG4MANY(), G4cout, G4endl, G4Exception(), G3VolTableEntry::GetDaughter(), G3VolTableEntry::GetG3PosCopy(), G3VolTableEntry::GetName(), G3VolTableEntry::GetNoDaughters(), G3VolTableEntry::GetNoOverlaps(), G3VolTableEntry::GetOverlaps(), GetTransform3D(), G3VolTableEntry::HasMANY(), MakeBooleanSolids(), and G3VolTableEntry::NPCopies().

Referenced by G3toG4MANY().

00040 {
00041   if (curVTE->GetNoOverlaps() > 0) {
00042   
00043     // check consistency 
00044     if (!curVTE->HasMANY()) { 
00045       G4String text = "G3toG4MANY: volume ";
00046       text = text + curVTE->GetName() + " has specified overlaps \n";
00047       text = text + " but is not defined as MANY.";
00048       G4Exception("G3toG4MANY()", "G3toG40009",
00049                   FatalException, text);
00050       return;
00051     }  
00052 
00053     // only MANY volumes with one position are supported
00054     if (curVTE->NPCopies() != 1) {
00055       G4String text = "G3toG4MANY: volume ";
00056       text = text + curVTE->GetName() + " which has MANY has not just one position.";
00057       G4Exception("G3toG4MANY()", "G3toG40010",
00058                   FatalException, text);
00059       return;
00060     }  
00061 
00062     #ifdef G3G4DEBUG
00063     G4cout << "G3toG4MANY  " << curVTE->GetName() << " boolean" << G4endl;
00064     #endif
00065 
00066     G4Transform3D transform = GetTransform3D(curVTE->GetG3PosCopy(0)); 
00067     
00068     MakeBooleanSolids(curVTE, curVTE->GetOverlaps(), transform.inverse());
00069   }
00070 
00071   // process daughters
00072   for (G4int i=0; i<curVTE->GetNoDaughters(); i++)
00073     G3toG4MANY(curVTE->GetDaughter(i));
00074 }

G4Transform3D GetTransform3D ( G3Pos g3pos  ) 

Definition at line 146 of file G3toG4MANY.cc.

References G3Rot, G3RotTable::Get(), G3Pos::GetIrot(), and G3Pos::GetPos().

Referenced by G3toG4MANY(), and SubstractSolids().

00147 {
00148   G4int irot = g3pos->GetIrot();
00149   G4RotationMatrix* theMatrix = 0;
00150   if (irot>0) theMatrix = G3Rot.Get(irot);
00151   
00152   G4Rotate3D rotation;
00153   if (theMatrix) {            
00154      rotation = G4Rotate3D(*theMatrix);
00155   }
00156 
00157   G4Translate3D translation(*(g3pos->GetPos()));
00158   G4Transform3D transform3D = translation * (rotation.inverse());
00159   
00160   return transform3D;
00161 }

void MakeBooleanSolids ( G3VolTableEntry curVTE,
G3VolTableEntryVector overlaps,
const G4Transform3D transform 
)

Definition at line 76 of file G3toG4MANY.cc.

References G4cout, G4endl, G3VolTableEntry::GetName(), and SubstractSolids().

Referenced by G3toG4MANY().

00078 {                            
00079   // loop over overlap VTEs
00080   for (size_t i=0; i<overlaps->size(); i++){
00081    
00082     G3VolTableEntry* overlapVTE = (*overlaps)[i]; 
00083 
00084      // loop over clone VTEs
00085     for (G4int ij=0; ij<overlapVTE->GetMasterClone()->GetNoClones(); ij++){
00086     
00087       G3VolTableEntry* cloneVTE = overlapVTE->GetMasterClone()->GetClone(ij);   
00088    
00089       // loop over clone positions
00090       for (G4int j=0; j<cloneVTE->NPCopies(); j++){
00091 
00092         #ifdef G3G4DEBUG
00093         G4cout << "From '" << curVTE->GetName() << "' "
00094                << "cut '" << cloneVTE->GetName() << "' :"
00095                << i  << "th overlap (from " << overlaps->size() << ") "
00096                << ij << "th clone (from " << overlapVTE->GetMasterClone()->GetNoClones() << ") "
00097                << j  << "th copy (from " << cloneVTE->NPCopies() << ")  "
00098                << G4endl;
00099         #endif
00100 
00101         SubstractSolids(curVTE, cloneVTE, j, transform); 
00102       }
00103     }    
00104   }                               
00105 }                       

void SubstractSolids ( G3VolTableEntry vte1,
G3VolTableEntry vte2,
G4int  copy,
const G4Transform3D transform 
)

Definition at line 107 of file G3toG4MANY.cc.

References FatalException, G4cout, G4endl, G4Exception(), G3VolTableEntry::GetDaughter(), G3VolTableEntry::GetG3PosCopy(), G3VolTableEntry::GetName(), G4VSolid::GetName(), G3VolTableEntry::GetNoDaughters(), G3VolTableEntry::GetSolid(), GetTransform3D(), G3VolTableEntry::SetSolid(), and SubstractSolids().

Referenced by MakeBooleanSolids(), and SubstractSolids().

00109 {                            
00110   // vte2 transformation
00111   G4Transform3D transform2 = GetTransform3D(vte2->GetG3PosCopy(copy));
00112    
00113   // compose new name 
00114   G4String newName = vte1->GetSolid()->GetName();
00115   newName = newName + "-" + vte2->GetSolid()->GetName();   
00116 
00117   #ifdef G3G4DEBUG
00118   G4cout << "   " << newName << G4endl; 
00119   #endif
00120 
00121   G4VSolid* newSolid 
00122     = new G4SubtractionSolid(newName, vte1->GetSolid(), vte2->GetSolid(),
00123                              transform*transform2);
00124                                  
00125   // update vte1
00126   vte1->SetSolid(newSolid);
00127 
00128   // process daughters
00129   for (G4int k=0; k<vte1->GetNoDaughters(); k++){
00130                 
00131     G3VolTableEntry* dVTE = vte1->GetDaughter(k);                               
00132          
00133     if (dVTE->NPCopies() != 1) {
00134       G4String text = "G3toG4MANY: volume ";
00135       text = text + dVTE->GetName() + " which has MANY has not just one position.";
00136       G4Exception("G3toG4MANY()", "G3toG40011",
00137                   FatalException, text);
00138       return;
00139     }
00140           
00141     G4Transform3D dt = GetTransform3D(dVTE->GetG3PosCopy(0)); 
00142     SubstractSolids(dVTE, vte2, copy, dt.inverse()*transform);
00143   }     
00144 }                       


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