source: trunk/source/g3tog4/src/G4gsdvn.cc @ 1202

Last change on this file since 1202 was 965, checked in by garnier, 15 years ago

update g3tog4

File size: 4.1 KB
Line 
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: G4gsdvn.cc,v 1.10 2006/06/29 18:13:57 gunter Exp $
28// GEANT4 tag $Name: geant4-09-02-ref-02 $
29//
30// by I.Hrivnacova, V.Berejnoi, 29 Oct 99
31
32#include "G3G4Interface.hh"
33#include "G3Division.hh"
34#include "G3VolTableEntry.hh"
35#include "G3VolTable.hh"
36#include "globals.hh"
37#include "G3toG4.hh"
38
39void PG4gsdvn(G4String tokens[])
40{
41  // fill the parameter containers
42  G3fillParams(tokens,PTgsdvn);
43 
44  // interpret the parameters
45  G4String vname = Spar[0];
46  G4String vmoth = Spar[1];
47  G4int ndiv = Ipar[0];
48  G4int iaxis = Ipar[1];
49 
50  G4gsdvn(vname, vmoth, ndiv, iaxis);
51}
52
53void G4CreateCloneVTEWithDivision(G4String vname, G3VolTableEntry* mvte,
54        G3DivType divType, G4int nofDivisions, G4int iaxis, G4int, 
55        G4double c0, G4double step)
56{       
57  G3VolTableEntry* vte=0;
58
59  // loop over all mothers
60  for (G4int i=0; i<mvte->GetNoClones(); i++) {
61    G3VolTableEntry* mvteClone =  mvte->GetClone(i);
62    G4String shape = mvteClone->GetShape();
63    G4int    nmed  = mvteClone->GetNmed();
64    G4String mvteName = mvteClone->GetName();
65   
66    G4String newName = vname;
67    if (i>0) {
68      char index[5]; sprintf(index, "%d", i);
69      newName.append(gSeparator); newName = newName + index;
70    }   
71
72    // create new VTE with 0 solid
73    // and let vol table know about it
74    G3VolTableEntry* vteClone
75      = new G3VolTableEntry(newName, shape, 0, 0, nmed, 0, true);
76    G3Vol.PutVTE(vteClone);
77
78    // set mother <-> daughter
79    // (mother/daughter are reset in case an envelope
80    //  needs to be created in G3Division::UpdateVTE)
81    mvteClone->AddDaughter(vteClone);
82    vteClone->AddMother(mvteClone);
83
84    // create new G3Division
85    G3Division* division
86      = new G3Division(divType, vteClone, mvteClone,
87                       nofDivisions, iaxis, nmed, c0, step);
88
89    // set division to vte and update it
90    vteClone->SetDivision(division);
91    division->UpdateVTE();
92     
93    if (i == 0) {
94      // keep the first clone copy
95      vte = vteClone;
96    }
97    else {             
98      // let vte know about this clone copy
99      vte->AddClone(vteClone);     
100    }
101  }
102}   
103
104void G4gsdvn(G4String vname, G4String vmoth, G4int ndiv, G4int iaxis)
105{
106  // find mother VTE
107  G3VolTableEntry* mvte = G3Vol.GetVTE(vmoth);
108 
109  if (mvte == 0) {
110    G4Exception("G4gsdvn:'" + vmoth + "' has no VolTableEntry");
111  } 
112  else {
113    // a new vte clone copy with division is created
114    // for each mother (clone copy)
115   
116    G4CreateCloneVTEWithDivision(vname, mvte, kDvn, ndiv, iaxis, 0, 0., 0.); 
117  } 
118}
Note: See TracBrowser for help on using the repository browser.