Ignore:
Timestamp:
Jan 8, 2010, 11:56:51 AM (14 years ago)
Author:
garnier
Message:

update geant4.9.3 tag

Location:
trunk/source/persistency/gdml/src
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/persistency/gdml/src/G4GDMLEvaluator.cc

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLEvaluator.cc,v 1.22 2009/02/26 10:13:35 gcosmo Exp $
     27// $Id: G4GDMLEvaluator.cc,v 1.23 2009/04/24 15:34:20 gcosmo Exp $
    2828// GEANT4 tag $ Name:$
    2929//
     
    3535
    3636#include <sstream>
     37
     38#include "globals.hh"
     39
    3740#include "G4GDMLEvaluator.hh"
    3841
  • trunk/source/persistency/gdml/src/G4GDMLParameterisation.cc

    r987 r1228  
    2525//
    2626// $Id: G4GDMLParameterisation.cc,v 1.11 2008/07/16 15:46:34 gcosmo Exp $
    27 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// GEANT4 tag $Name: geant4-09-03 $
    2828//
    2929// class G4GDMLParameterisation Implementation
  • trunk/source/persistency/gdml/src/G4GDMLParser.cc

    r921 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLParser.cc,v 1.13 2008/11/20 15:33:52 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-cand-01 $
     27// $Id: G4GDMLParser.cc,v 1.14 2009/04/15 13:29:30 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
     
    3636
    3737G4GDMLParser::G4GDMLParser()
    38   : ucode(false)
     38  : urcode(false), uwcode(false)
    3939{
    4040  reader = new G4GDMLReadStructure;
     
    4343}
    4444
    45 G4GDMLParser::G4GDMLParser(G4GDMLReadStructure* ext)
    46   : ucode(true)
     45G4GDMLParser::G4GDMLParser(G4GDMLReadStructure* extr)
     46  : urcode(true), uwcode(false)
    4747{
    48   reader = ext;
     48  reader = extr;
    4949  writer = new G4GDMLWriteStructure;
     50  xercesc::XMLPlatformUtils::Initialize();
     51}
     52
     53G4GDMLParser::G4GDMLParser(G4GDMLReadStructure* extr,
     54                           G4GDMLWriteStructure* extw)
     55  : urcode(true), uwcode(true)
     56{
     57  reader = extr;
     58  writer = extw;
    5059  xercesc::XMLPlatformUtils::Initialize();
    5160}
     
    5463{
    5564  xercesc::XMLPlatformUtils::Terminate();
    56   delete writer;
    57   if (!ucode) { delete reader; }
     65  if (!urcode) { delete reader; }
     66  if (!uwcode) { delete writer; }
    5867}
  • trunk/source/persistency/gdml/src/G4GDMLRead.cc

    r987 r1228  
    2424// ********************************************************************
    2525//
    26 // $Id: G4GDMLRead.cc,v 1.41 2009/01/22 11:02:07 gcosmo Exp $
    27 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     26// $Id: G4GDMLRead.cc,v 1.47 2009/05/12 15:46:43 gcosmo Exp $
     27// GEANT4 tag $Name: geant4-09-03 $
    2828//
    2929// class G4GDMLRead Implementation
     
    3333// -------------------------------------------------------------------------
    3434
     35#include "globals.hh"
     36
    3537#include "G4GDMLRead.hh"
     38
     39#include "G4UnitsTable.hh"
    3640#include "G4Element.hh"
    3741#include "G4Material.hh"
     
    3943#include "G4LogicalVolumeStore.hh"
    4044#include "G4PhysicalVolumeStore.hh"
    41 #include "G4UnitsTable.hh"
    4245
    4346G4GDMLRead::G4GDMLRead()
    44   : validate(true), check(false)
     47  : validate(true), check(false), inLoop(0), loopCount(0)
    4548{
    4649   G4UnitDefinition::BuildUnitsTable();
     
    6871   G4String nameOut(nameIn);
    6972
    70    if (inLoop>0) { nameOut = eval.SolveBrackets(nameOut); }
     73   if (inLoop>0)
     74   {
     75     nameOut = eval.SolveBrackets(nameOut);
     76//     std::stringstream stream;
     77//     stream << "0x" << loopCount;
     78//     nameOut = nameOut + stream.str();
     79   }
    7180   if (strip) { StripName(nameOut); }
    7281
     
    235244
    236245   inLoop++;
    237    
     246
    238247   while (_var <= _to)
    239248   {
    240249      eval.SetVariable(var,_var);
    241250      (this->*func)(element);
    242 
    243251      _var += _step;
     252      loopCount++;
    244253   }
    245254
    246255   inLoop--;
     256   if (!inLoop) { loopCount = 0; }
    247257}
    248258
  • trunk/source/persistency/gdml/src/G4GDMLReadDefine.cc

    r987 r1228  
    2424// ********************************************************************
    2525//
    26 // $Id: G4GDMLReadDefine.cc,v 1.20 2008/07/16 15:46:34 gcosmo Exp $
    27 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     26// $Id: G4GDMLReadDefine.cc,v 1.24 2009/10/14 13:10:18 gcosmo Exp $
     27// GEANT4 tag $Name: geant4-09-03 $
    2828//
    2929// class G4GDMLReadDefine Implementation
     
    3636
    3737G4GDMLMatrix::G4GDMLMatrix()
    38 {
    39    rows = 0;
    40    cols = 0;
    41    m = 0;
    42 }
    43 
    44 G4GDMLMatrix::G4GDMLMatrix(size_t rows0,size_t cols0)
     38  : m(0), rows(0), cols(0)
     39{
     40}
     41
     42G4GDMLMatrix::G4GDMLMatrix(size_t rows0, size_t cols0)
    4543{   
     44   if ((rows<=0) || (cols<=0))
     45   {
     46     G4Exception("G4GDMLMatrix::G4GDMLMatrix(r,c)", "InvalidSetup",
     47                 FatalException, "Zero indeces as arguments!?");
     48   }
    4649   rows = rows0;
    4750   cols = cols0;
     
    4952}
    5053
     54G4GDMLMatrix::G4GDMLMatrix(const G4GDMLMatrix& rhs)
     55  : m(0), rows(0), cols(0)
     56{
     57   if (rhs.m)
     58   {
     59     rows = rhs.rows;
     60     cols = rhs.cols;
     61     m = new G4double[rows*cols];
     62     for (size_t i=0; i<rows*cols; i++)  { m[i] = rhs.m[i]; }
     63   }
     64}
     65
     66G4GDMLMatrix& G4GDMLMatrix::operator=(const G4GDMLMatrix& rhs)
     67{
     68   // Check assignment to self
     69   //
     70   if (this == &rhs)  { return *this; }
     71
     72   // Copy data
     73   //
     74   rows = rhs.rows;
     75   cols = rhs.cols;
     76   if (rhs.m)
     77   {
     78     m = new G4double[rows*cols];
     79     for (size_t i=0; i<rows*cols; i++)  { m[i] = rhs.m[i]; }
     80   }
     81   else
     82   {
     83     m = 0;
     84   }
     85
     86   return *this;
     87}
     88
    5189G4GDMLMatrix::~G4GDMLMatrix()
    5290{
    53    if (m) { delete [] m; }
     91   delete [] m;
    5492}
    5593
     
    84122}
    85123
     124G4GDMLReadDefine::G4GDMLReadDefine() : G4GDMLRead()
     125{
     126}
     127
     128G4GDMLReadDefine::~G4GDMLReadDefine()
     129{
     130}
     131
    86132G4RotationMatrix
    87133G4GDMLReadDefine::GetRotationMatrix(const G4ThreeVector& angles)
     
    122168   }
    123169
     170   eval.DefineConstant(name,value);
     171}
     172
     173void
     174G4GDMLReadDefine::ExpressionRead(const xercesc::DOMElement* const expElement)
     175{
     176   G4String name  = "";
     177   G4double value = 0.0;
     178
     179   const xercesc::DOMNamedNodeMap* const attributes
     180         = expElement->getAttributes();
     181   XMLSize_t attributeCount = attributes->getLength();
     182
     183   for (XMLSize_t attribute_index=0;
     184        attribute_index<attributeCount; attribute_index++)
     185   {
     186      xercesc::DOMNode* node = attributes->item(attribute_index);
     187
     188      if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
     189
     190      const xercesc::DOMAttr* const attribute
     191            = dynamic_cast<xercesc::DOMAttr*>(node);   
     192      const G4String attName = Transcode(attribute->getName());
     193      const G4String attValue = Transcode(attribute->getValue());
     194
     195      if (attName=="name")  { name = attValue; }
     196   }
     197
     198   const G4String expValue = Transcode(expElement->getTextContent());
     199   value = eval.Evaluate(expValue);
    124200   eval.DefineConstant(name,value);
    125201}
     
    328404
    329405   quantityMap[name] = value*unit;
     406   eval.DefineConstant(name,value*unit);
    330407}
    331408
     
    350427      if (tag=="scale")    { ScaleRead(child); }    else
    351428      if (tag=="variable") { VariableRead(child); } else
    352       if (tag=="quantity") { QuantityRead(child); }
     429      if (tag=="quantity") { QuantityRead(child); } else
     430      if (tag=="expression") { ExpressionRead(child); }
    353431      else
    354432      {
  • trunk/source/persistency/gdml/src/G4GDMLReadMaterials.cc

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLReadMaterials.cc,v 1.16 2008/08/22 10:00:20 gcosmo Exp $
     27// $Id: G4GDMLReadMaterials.cc,v 1.20 2009/04/24 15:34:20 gcosmo Exp $
    2828// GEANT4 tag $ Name:$
    2929//
     
    3535
    3636#include "G4GDMLReadMaterials.hh"
     37
     38#include "G4Element.hh"
     39#include "G4Isotope.hh"
     40#include "G4Material.hh"
     41#include "G4NistManager.hh"
     42
     43G4GDMLReadMaterials::G4GDMLReadMaterials() : G4GDMLReadDefine()
     44{
     45}
     46
     47G4GDMLReadMaterials::~G4GDMLReadMaterials()
     48{
     49}
    3750
    3851G4double
     
    497510   if (matrix.GetRows() == 0) { return; }
    498511
    499    G4MaterialPropertiesTable* matprop = material->GetMaterialPropertiesTable();
     512   G4MaterialPropertiesTable* matprop=material->GetMaterialPropertiesTable();
    500513   if (!matprop)
    501514   {
    502      material->SetMaterialPropertiesTable(
    503                matprop = new G4MaterialPropertiesTable());
    504    }
    505    G4MaterialPropertyVector* propvect = new G4MaterialPropertyVector(0,0,0);
    506    for (size_t i=0; i<matrix.GetRows(); i++)
    507    {
    508      propvect->AddElement(matrix.Get(i,0),matrix.Get(i,1));
    509    }
    510    matprop->AddProperty(Strip(name),propvect);
     515     matprop = new G4MaterialPropertiesTable();
     516     material->SetMaterialPropertiesTable(matprop);
     517   }
     518   if (matrix.GetCols() == 1)  // constant property assumed
     519   {
     520     matprop->AddConstProperty(Strip(name), matrix.Get(0,0));
     521   }
     522   else  // build the material properties vector
     523   {
     524     G4MaterialPropertyVector* propvect = new G4MaterialPropertyVector(0,0,0);
     525     for (size_t i=0; i<matrix.GetRows(); i++)
     526     {
     527       propvect->AddElement(matrix.Get(i,0),matrix.Get(i,1));
     528     }
     529     matprop->AddProperty(Strip(name),propvect);
     530   }
    511531}
    512532
     
    524544            = dynamic_cast<xercesc::DOMElement*>(iter);
    525545      const G4String tag = Transcode(child->getTagName());
    526 
     546     
     547      if (tag=="define")   { DefineRead(child);  }  else
    527548      if (tag=="element")  { ElementRead(child); }  else
    528549      if (tag=="isotope")  { IsotopeRead(child); }  else
  • trunk/source/persistency/gdml/src/G4GDMLReadParamvol.cc

    r987 r1228  
    2424// ********************************************************************
    2525//
    26 // $Id: G4GDMLReadParamvol.cc,v 1.11 2009/01/22 11:02:07 gcosmo Exp $
    27 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     26// $Id: G4GDMLReadParamvol.cc,v 1.13 2009/04/24 15:34:20 gcosmo Exp $
     27// GEANT4 tag $Name: geant4-09-03 $
    2828//
    2929// class G4GDMLReadParamvol Implementation
     
    3434
    3535#include "G4GDMLReadParamvol.hh"
     36
     37#include "G4LogicalVolume.hh"
     38#include "G4PVParameterised.hh"
     39#include "G4PVPlacement.hh"
     40#include "G4VPhysicalVolume.hh"
     41
     42G4GDMLReadParamvol::G4GDMLReadParamvol() : G4GDMLReadSetup()
     43{
     44}
     45
     46G4GDMLReadParamvol::~G4GDMLReadParamvol()
     47{
     48}
    3649
    3750void G4GDMLReadParamvol::
  • trunk/source/persistency/gdml/src/G4GDMLReadSetup.cc

    r987 r1228  
    2424// ********************************************************************
    2525//
    26 // $Id: G4GDMLReadSetup.cc,v 1.9 2008/07/16 15:46:34 gcosmo Exp $
    27 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     26// $Id: G4GDMLReadSetup.cc,v 1.10 2009/03/24 15:47:33 gcosmo Exp $
     27// GEANT4 tag $Name: geant4-09-03 $
    2828//
    2929// class G4GDMLReadSetup Implementation
     
    3434
    3535#include "G4GDMLReadSetup.hh"
     36
     37G4GDMLReadSetup::G4GDMLReadSetup() : G4GDMLReadSolids()
     38{
     39}
     40
     41G4GDMLReadSetup::~G4GDMLReadSetup()
     42{
     43}
    3644
    3745G4String G4GDMLReadSetup::GetSetup(const G4String& ref)
  • trunk/source/persistency/gdml/src/G4GDMLReadSolids.cc

    r987 r1228  
    2424// ********************************************************************
    2525//
    26 // $Id: G4GDMLReadSolids.cc,v 1.22 2008/11/21 09:32:46 gcosmo Exp $
    27 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     26// $Id: G4GDMLReadSolids.cc,v 1.27 2009/12/04 13:58:51 gcosmo Exp $
     27// GEANT4 tag $Name: geant4-09-03 $
    2828//
    2929// class G4GDMLReadSolids Implementation
     
    3434
    3535#include "G4GDMLReadSolids.hh"
     36
     37#include "G4Box.hh"
     38#include "G4Cons.hh"
     39#include "G4Ellipsoid.hh"
     40#include "G4EllipticalCone.hh"
     41#include "G4EllipticalTube.hh"
     42#include "G4Hype.hh"
     43#include "G4IntersectionSolid.hh"
     44#include "G4Orb.hh"
     45#include "G4Para.hh"
     46#include "G4Paraboloid.hh"
     47#include "G4Polycone.hh"
     48#include "G4Polyhedra.hh"
     49#include "G4QuadrangularFacet.hh"
     50#include "G4ReflectedSolid.hh"
     51#include "G4Sphere.hh"
     52#include "G4SolidStore.hh"
     53#include "G4SubtractionSolid.hh"
     54#include "G4TessellatedSolid.hh"
     55#include "G4Tet.hh"
     56#include "G4Torus.hh"
     57#include "G4Transform3D.hh"
     58#include "G4Trap.hh"
     59#include "G4Trd.hh"
     60#include "G4TriangularFacet.hh"
     61#include "G4Tubs.hh"
     62#include "G4TwistedBox.hh"
     63#include "G4TwistedTrap.hh"
     64#include "G4TwistedTrd.hh"
     65#include "G4TwistedTubs.hh"
     66#include "G4UnionSolid.hh"
     67#include "G4OpticalSurface.hh"
     68#include "G4SurfaceProperty.hh"
     69
     70G4GDMLReadSolids::G4GDMLReadSolids() : G4GDMLReadMaterials()
     71{
     72}
     73
     74G4GDMLReadSolids::~G4GDMLReadSolids()
     75{
     76}
    3677
    3778void G4GDMLReadSolids::
     
    14781519
    14791520void G4GDMLReadSolids::
    1480 OpticalsurfaceRead(const xercesc::DOMElement* const opticalsurfaceElement)
     1521OpticalSurfaceRead(const xercesc::DOMElement* const opticalsurfaceElement)
    14811522{
    14821523   G4String name;
     
    15141555   G4SurfaceType type;   
    15151556   
    1516    if (smodel="unified") { model = unified; } else { model = glisur; }
     1557   if (smodel="unified") { model = unified; } else
     1558   if (smodel="glisur") { model = glisur; }
     1559   else { model = LUT; }
    15171560
    15181561   if (sfinish=="polishedfrontpainted") { finish = polishedfrontpainted; } else
     
    15201563   if (sfinish=="groundfrontpainted") { finish = groundfrontpainted; } else
    15211564   if (sfinish=="groundbackpainted") { finish = groundbackpainted; } else
    1522    if (sfinish=="ground") { finish = ground; } else { finish = polished; }
     1565   if (sfinish=="ground") { finish = ground; } else
     1566   if (sfinish=="polished") { finish = polished; } else
     1567   if (sfinish=="polishedlumirrorair") { finish = polishedlumirrorair; } else
     1568   if (sfinish=="polishedlumirrorglue") { finish = polishedlumirrorglue; } else
     1569   if (sfinish=="polishedair") { finish = polishedair; } else
     1570   if (sfinish=="polishedteflonair") { finish = polishedteflonair; } else
     1571   if (sfinish=="polishedtioair") { finish = polishedtioair; } else
     1572   if (sfinish=="polishedtyvekair") { finish = polishedtyvekair; } else
     1573   if (sfinish=="polishedvm2000air") { finish = polishedvm2000air; } else
     1574   if (sfinish=="polishedvm2000glue") { finish = polishedvm2000glue; } else
     1575   if (sfinish=="etchedlumirrorair") { finish = etchedlumirrorair; } else
     1576   if (sfinish=="etchedlumirrorglue") { finish = etchedlumirrorglue; } else
     1577   if (sfinish=="etchedair") { finish = etchedair; } else
     1578   if (sfinish=="etchedteflonair") { finish = etchedteflonair; } else
     1579   if (sfinish=="etchedtioair") { finish = etchedtioair; } else
     1580   if (sfinish=="etchedtyvekair") { finish = etchedtyvekair; } else
     1581   if (sfinish=="etchedvm2000air") { finish = etchedvm2000air; } else
     1582   if (sfinish=="etchedvm2000glue") { finish = etchedvm2000glue; } else
     1583   if (sfinish=="groundlumirrorair") { finish = groundlumirrorair; } else
     1584   if (sfinish=="groundlumirrorglue") { finish = groundlumirrorglue; } else
     1585   if (sfinish=="groundair") { finish = groundair; } else
     1586   if (sfinish=="groundteflonair") { finish = groundteflonair; } else
     1587   if (sfinish=="groundtioair") { finish = groundtioair; } else
     1588   if (sfinish=="groundtyvekair") { finish = groundtyvekair; } else
     1589   if (sfinish=="groundvm2000air") { finish = groundvm2000air; }
     1590   else { finish = groundvm2000glue; }
    15231591
    15241592   if (stype=="dielectric_metal") { type = dielectric_metal; } else
    1525    if (stype=="x_ray") { type = x_ray; } else
    1526    if (stype=="firsov") { type = firsov; } else { type = dielectric_dielectric; }
     1593   if (stype=="dielectric_dielectric") { type = dielectric_dielectric; } else
     1594   if (stype=="dielectric_LUT") { type = dielectric_LUT; } else
     1595   if (stype=="x_ray") { type = x_ray; }
     1596   else { type = firsov; }
    15271597
    15281598   new G4OpticalSurface(name,model,finish,type,value);
     
    15411611            = dynamic_cast<xercesc::DOMElement*>(iter);
    15421612      const G4String tag = Transcode(child->getTagName());
    1543 
    1544       if (tag=="box") { BoxRead(child); } else
    1545       if (tag=="cone") { ConeRead(child); } else
     1613      if (tag=="define") { DefineRead(child);  }  else
     1614      if (tag=="box")    { BoxRead(child); } else
     1615      if (tag=="cone")   { ConeRead(child); } else
    15461616      if (tag=="elcone") { ElconeRead(child); } else
    15471617      if (tag=="ellipsoid") { EllipsoidRead(child); }else
     
    15691639      if (tag=="twistedtubs") { TwistedtubsRead(child); } else
    15701640      if (tag=="union") { BooleanRead(child,UNION); } else
    1571       if (tag=="opticalsurface") { OpticalsurfaceRead(child); } else
     1641      if (tag=="opticalsurface") { OpticalSurfaceRead(child); } else
    15721642      if (tag=="loop") { LoopRead(child,&G4GDMLRead::SolidsRead); }
    15731643      else
  • trunk/source/persistency/gdml/src/G4GDMLReadStructure.cc

    r987 r1228  
    2424// ********************************************************************
    2525//
    26 // $Id: G4GDMLReadStructure.cc,v 1.56 2009/02/24 17:41:44 gcosmo Exp $
    27 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     26// $Id: G4GDMLReadStructure.cc,v 1.62 2009/09/24 15:04:34 gcosmo Exp $
     27// GEANT4 tag $Name: geant4-09-03 $
    2828//
    2929// class G4GDMLReadStructure Implementation
     
    3535#include "G4GDMLReadStructure.hh"
    3636
     37#include "G4LogicalVolume.hh"
     38#include "G4VPhysicalVolume.hh"
     39#include "G4PVPlacement.hh"
     40#include "G4LogicalVolumeStore.hh"
     41#include "G4PhysicalVolumeStore.hh"
     42#include "G4AssemblyVolume.hh"
     43#include "G4ReflectionFactory.hh"
     44#include "G4PVDivisionFactory.hh"
     45#include "G4LogicalBorderSurface.hh"
     46#include "G4LogicalSkinSurface.hh"
     47#include "G4VisAttributes.hh"
     48
     49G4GDMLReadStructure::G4GDMLReadStructure() : G4GDMLReadParamvol()
     50{
     51}
     52
     53G4GDMLReadStructure::~G4GDMLReadStructure()
     54{
     55}
     56
    3757G4GDMLAuxPairType G4GDMLReadStructure::
    3858AuxiliaryRead(const xercesc::DOMElement* const auxiliaryElement)
     
    6585
    6686void G4GDMLReadStructure::
    67 BordersurfaceRead(const xercesc::DOMElement* const bordersurfaceElement)
     87BorderSurfaceRead(const xercesc::DOMElement* const bordersurfaceElement)
    6888{
    6989   G4String name;
     
    255275
    256276void G4GDMLReadStructure::
    257 PhysvolRead(const xercesc::DOMElement* const physvolElement)
     277PhysvolRead(const xercesc::DOMElement* const physvolElement,
     278            G4AssemblyVolume* pAssembly)
    258279{
    259280   G4String name;
    260281   G4LogicalVolume* logvol = 0;
     282   G4AssemblyVolume* assembly = 0;
    261283   G4ThreeVector position(0.0,0.0,0.0);
    262284   G4ThreeVector rotation(0.0,0.0,0.0);
     
    270292        attribute_index<attributeCount; attribute_index++)
    271293   {
    272       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
    273 
    274       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
    275         { continue; }
    276 
    277       const xercesc::DOMAttr* const attribute
    278             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
    279       const G4String attName = Transcode(attribute->getName());
    280       const G4String attValue = Transcode(attribute->getValue());
    281 
    282       if (attName=="name") { name = attValue; }
     294     xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
     295
     296     if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
     297       { continue; }
     298
     299     const xercesc::DOMAttr* const attribute
     300           = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
     301     const G4String attName = Transcode(attribute->getName());
     302     const G4String attValue = Transcode(attribute->getValue());
     303
     304     if (attName=="name") { name = attValue; }
    283305   }
    284306
     
    286308        iter != 0; iter = iter->getNextSibling())
    287309   {
    288       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)  { continue; }
    289 
    290       const xercesc::DOMElement* const child
    291             = dynamic_cast<xercesc::DOMElement*>(iter);
    292       const G4String tag = Transcode(child->getTagName());
    293 
    294       if (tag=="file")
    295         { logvol = FileRead(child); } else
    296       if (tag=="volumeref")
    297         { logvol = GetVolume(GenerateName(RefRead(child))); } else
    298       if (tag=="position")
    299         { VectorRead(child,position); } else
    300       if (tag=="rotation")
    301         { VectorRead(child,rotation); } else
    302       if (tag=="scale")
    303         { VectorRead(child,scale); } else
    304       if (tag=="positionref")
    305         { position = GetPosition(GenerateName(RefRead(child))); } else
    306       if (tag=="rotationref")
    307         { rotation = GetRotation(GenerateName(RefRead(child))); } else
    308       if (tag=="scaleref")
     310     if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)  { continue; }
     311
     312     const xercesc::DOMElement* const child
     313           = dynamic_cast<xercesc::DOMElement*>(iter);
     314     const G4String tag = Transcode(child->getTagName());
     315
     316     if (tag=="volumeref")
     317       {
     318         const G4String& child_name = GenerateName(RefRead(child));
     319         assembly = GetAssembly(child_name);
     320         if (!assembly) { logvol = GetVolume(child_name); }
     321       }
     322     else if (tag=="file")
     323       { logvol = FileRead(child); }
     324     else if (tag=="position")
     325       { VectorRead(child,position); }
     326     else if (tag=="rotation")
     327       { VectorRead(child,rotation); }
     328     else if (tag=="scale")
     329       { VectorRead(child,scale); }
     330     else if (tag=="positionref")
     331       { position = GetPosition(GenerateName(RefRead(child))); }
     332     else if (tag=="rotationref")
     333        { rotation = GetRotation(GenerateName(RefRead(child))); }
     334     else if (tag=="scaleref")
    309335        { scale = GetScale(GenerateName(RefRead(child))); }
    310       else
    311       {
    312         G4String error_msg = "Unknown tag in physvol: " + tag;
    313         G4Exception("G4GDMLReadStructure::PhysvolRead()", "ReadError",
    314                     FatalException, error_msg);
    315       }
     336     else
     337        {
     338          G4String error_msg = "Unknown tag in physvol: " + tag;
     339          G4Exception("G4GDMLReadStructure::PhysvolRead()", "ReadError",
     340                      FatalException, error_msg);
     341        }
    316342   }
    317343
     
    319345   transform = transform*G4Scale3D(scale.x(),scale.y(),scale.z());
    320346
    321    G4String pv_name = logvol->GetName() + "_PV";
    322    G4PhysicalVolumesPair pair = G4ReflectionFactory::Instance()
    323      ->Place(transform,pv_name,logvol,pMotherLogical,false,0,check);
    324 
    325    if (pair.first != 0) { GeneratePhysvolName(name,pair.first); }
    326    if (pair.second != 0) { GeneratePhysvolName(name,pair.second); }
     347   if (pAssembly)   // Fill assembly structure
     348   {
     349     pAssembly->AddPlacedVolume(logvol, transform);
     350   }
     351   else             // Generate physical volume tree or do assembly imprint
     352   {
     353     if (assembly)
     354     {
     355       assembly->MakeImprint(pMotherLogical, transform, 0, check);
     356     }
     357     else
     358     {
     359       G4String pv_name = logvol->GetName() + "_PV";
     360       G4PhysicalVolumesPair pair = G4ReflectionFactory::Instance()
     361         ->Place(transform,pv_name,logvol,pMotherLogical,false,0,check);
     362
     363       if (pair.first != 0) { GeneratePhysvolName(name,pair.first); }
     364       if (pair.second != 0) { GeneratePhysvolName(name,pair.second); }
     365     }
     366   }
    327367}
    328368
     
    510550
    511551void G4GDMLReadStructure::
    512 SkinsurfaceRead(const xercesc::DOMElement* const skinsurfaceElement)
     552AssemblyRead(const xercesc::DOMElement* const assemblyElement)
     553{
     554   XMLCh *name_attr = xercesc::XMLString::transcode("name");
     555   const G4String name = Transcode(assemblyElement->getAttribute(name_attr));
     556   xercesc::XMLString::release(&name_attr);
     557
     558   G4AssemblyVolume* pAssembly = new G4AssemblyVolume();
     559   assemblyMap.insert(std::make_pair(GenerateName(name), pAssembly));
     560
     561   for (xercesc::DOMNode* iter = assemblyElement->getFirstChild();
     562        iter != 0; iter = iter->getNextSibling())
     563   {
     564      if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
     565      const xercesc::DOMElement* const child
     566            = dynamic_cast<xercesc::DOMElement*>(iter);
     567      const G4String tag = Transcode(child->getTagName());
     568
     569      if (tag=="physvol")
     570      {
     571        PhysvolRead(child, pAssembly);
     572      }
     573      else
     574      {
     575        G4cout << "Unsupported GDML tag '" << tag
     576               << "' for Geant4 assembly structure !" << G4endl;
     577      }
     578   }
     579}
     580
     581void G4GDMLReadStructure::
     582SkinSurfaceRead(const xercesc::DOMElement* const skinsurfaceElement)
    513583{
    514584   G4String name;
     
    643713      const G4String tag = Transcode(child->getTagName());
    644714
    645       if (tag=="bordersurface") { BordersurfaceRead(child); } else
    646       if (tag=="skinsurface") { SkinsurfaceRead(child); } else
     715      if (tag=="bordersurface") { BorderSurfaceRead(child); } else
     716      if (tag=="skinsurface") { SkinSurfaceRead(child); } else
    647717      if (tag=="volume") { VolumeRead(child); } else
     718      if (tag=="assembly") { AssemblyRead(child); } else
    648719      if (tag=="loop") { LoopRead(child,&G4GDMLRead::StructureRead); }
    649720      else
     
    688759}
    689760
     761G4AssemblyVolume* G4GDMLReadStructure::
     762GetAssembly(const G4String& ref) const
     763{
     764   G4GDMLAssemblyMapType::const_iterator pos = assemblyMap.find(ref);
     765   if (pos != assemblyMap.end()) { return pos->second; }
     766   return 0;
     767}
     768
    690769G4GDMLAuxListType G4GDMLReadStructure::
    691770GetVolumeAuxiliaryInformation(const G4LogicalVolume* const logvol)
    692771{
    693    if (auxMap.find(logvol) != auxMap.end()) { return auxMap[logvol]; }
     772   G4GDMLAuxMapType::const_iterator pos = auxMap.find(logvol);
     773   if (pos != auxMap.end()) { return pos->second; }
    694774   else { return G4GDMLAuxListType(); }
    695775}
  • trunk/source/persistency/gdml/src/G4GDMLWrite.cc

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLWrite.cc,v 1.50 2008/11/13 17:00:50 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4GDMLWrite.cc,v 1.55 2009/04/24 15:34:20 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030// class G4GDMLWrite Implementation
     
    3434// --------------------------------------------------------------------
    3535
     36#include <sys/stat.h>
     37#include <iostream>
     38
    3639#include "G4GDMLWrite.hh"
    3740
     41#include "G4LogicalVolume.hh"
     42#include "G4Transform3D.hh"
     43#include "G4PVDivision.hh"
     44
    3845G4bool G4GDMLWrite::addPointerToName = true;
     46
     47G4GDMLWrite::G4GDMLWrite() : extElement(0)
     48{
     49}
     50
     51G4GDMLWrite::~G4GDMLWrite()
     52{
     53}
    3954
    4055G4bool G4GDMLWrite::FileExists(const G4String& fname) const
     
    6277}
    6378
     79void G4GDMLWrite::AddExtension(xercesc::DOMElement*,
     80                               const G4LogicalVolume* const)
     81{
     82   // Empty implementation. To be overwritten by user for specific extensions
     83   // related to attributes associated to volumes
     84}
     85
     86void G4GDMLWrite::ExtensionWrite(xercesc::DOMElement*)
     87{
     88   // Empty implementation. To be overwritten by user for specific extensions
     89}
     90
    6491G4String G4GDMLWrite::GenerateName(const G4String& name, const void* const ptr)
    6592{
     93   G4String nameOut;
    6694   std::stringstream stream; stream << name;
    67    if (addPointerToName) { stream << ptr; }
    68    return G4String(stream.str());
     95   if (addPointerToName) { stream << ptr; };
     96
     97   nameOut=G4String(stream.str());
     98   if(nameOut.contains(' '))
     99   nameOut.erase(std::remove(nameOut.begin(),nameOut.end(),' '),nameOut.end());
     100
     101   return nameOut;
    69102}
    70103
     
    153186                          SchemaLocation));
    154187
     188   ExtensionWrite(gdml);
    155189   DefineWrite(gdml);
    156190   MaterialsWrite(gdml);
     
    161195   G4Transform3D R = TraverseVolumeTree(logvol,depth);
    162196
     197   SurfacesWrite();
    163198   xercesc::XMLFormatTarget *myFormTarget =
    164199     new xercesc::LocalFileFormatTarget(fname.c_str());
  • trunk/source/persistency/gdml/src/G4GDMLWriteDefine.cc

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLWriteDefine.cc,v 1.18 2008/07/16 15:46:34 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4GDMLWriteDefine.cc,v 1.19 2009/03/24 15:47:33 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030// class G4GDMLWriteDefine Implementation
     
    3939const G4double G4GDMLWriteDefine::kAngularPrecision = DBL_EPSILON;
    4040const G4double G4GDMLWriteDefine::kLinearPrecision = DBL_EPSILON;
     41
     42G4GDMLWriteDefine::G4GDMLWriteDefine() : G4GDMLWrite()
     43{
     44}
     45
     46G4GDMLWriteDefine::~G4GDMLWriteDefine()
     47{
     48}
    4149
    4250G4ThreeVector G4GDMLWriteDefine::GetAngles(const G4RotationMatrix& mat)
  • trunk/source/persistency/gdml/src/G4GDMLWriteMaterials.cc

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLWriteMaterials.cc,v 1.20 2008/07/16 15:46:34 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4GDMLWriteMaterials.cc,v 1.24 2009/04/27 07:22:36 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030// class G4GDMLWriteMaterials Implementation
     
    3434// --------------------------------------------------------------------
    3535
     36#include <sstream>
    3637#include "G4GDMLWriteMaterials.hh"
     38
     39#include "G4Element.hh"
     40#include "G4Isotope.hh"
     41#include "G4Material.hh"
     42
     43G4GDMLWriteMaterials::
     44G4GDMLWriteMaterials() : G4GDMLWriteDefine()
     45{
     46}
     47
     48G4GDMLWriteMaterials::
     49~G4GDMLWriteMaterials()
     50{
     51}
    3752
    3853void G4GDMLWriteMaterials::
     
    134149   materialElement->setAttributeNode(NewAttribute("state",state_str));
    135150
     151   // Write any property attached to the material...
     152   //
     153   if (materialPtr->GetMaterialPropertiesTable())
     154   {
     155     PropertyWrite(materialElement, materialPtr);
     156   }
     157
    136158   if (materialPtr->GetTemperature() != STP_Temperature)
    137159     { TWrite(materialElement,materialPtr->GetTemperature()); }
     
    165187   }
    166188
     189   // Append the material AFTER all the possible components are appended!
     190   //
    167191   materialsElement->appendChild(materialElement);
    168      // Append the material AFTER all the possible components are appended!
     192}
     193
     194void G4GDMLWriteMaterials::PropertyVectorWrite(const G4String& key,
     195                           const G4MaterialPropertyVector* const pvec)
     196{
     197   xercesc::DOMElement* matrixElement = NewElement("matrix");
     198   matrixElement->setAttributeNode(NewAttribute("name", key));
     199   matrixElement->setAttributeNode(NewAttribute("coldim", "2"));
     200   std::ostringstream pvalues;
     201   for (G4int i=0; i<pvec->Entries(); i++)
     202   {
     203     G4MPVEntry cval = pvec->GetEntry(i);
     204     if (i!=0)  { pvalues << " "; }
     205     pvalues << cval.GetPhotonEnergy() << " " << cval.GetProperty();
     206   }
     207   matrixElement->setAttributeNode(NewAttribute("values", pvalues.str()));
     208
     209   defineElement->appendChild(matrixElement);
     210}
     211
     212void G4GDMLWriteMaterials::PropertyWrite(xercesc::DOMElement* matElement,
     213                                         const G4Material* const mat)
     214{
     215   xercesc::DOMElement* propElement;
     216   G4MaterialPropertiesTable* ptable = mat->GetMaterialPropertiesTable();
     217   const std::map< G4String, G4MaterialPropertyVector*,
     218                 std::less<G4String> >* pmap = ptable->GetPropertiesMap();
     219   const std::map< G4String, G4double,
     220                 std::less<G4String> >* cmap = ptable->GetPropertiesCMap();
     221   std::map< G4String, G4MaterialPropertyVector*,
     222                 std::less<G4String> >::const_iterator mpos;
     223   std::map< G4String, G4double,
     224                 std::less<G4String> >::const_iterator cpos;
     225   for (mpos=pmap->begin(); mpos!=pmap->end(); mpos++)
     226   {
     227      propElement = NewElement("property");
     228      propElement->setAttributeNode(NewAttribute("name", mpos->first));
     229      propElement->setAttributeNode(NewAttribute("ref", mpos->first));
     230      PropertyVectorWrite(mpos->first, mpos->second);
     231      matElement->appendChild(propElement);
     232   }
     233   for (cpos=cmap->begin(); cpos!=cmap->end(); cpos++)
     234   {
     235      propElement = NewElement("property");
     236      propElement->setAttributeNode(NewAttribute("name", cpos->first));
     237      propElement->setAttributeNode(NewAttribute("ref", cpos->first));
     238      xercesc::DOMElement* constElement = NewElement("constant");
     239      constElement->setAttributeNode(NewAttribute("name", cpos->first));
     240      constElement->setAttributeNode(NewAttribute("value", cpos->second));
     241      defineElement->appendChild(constElement);
     242      matElement->appendChild(propElement);
     243   }
    169244}
    170245
  • trunk/source/persistency/gdml/src/G4GDMLWriteParamvol.cc

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLWriteParamvol.cc,v 1.23 2008/08/20 08:56:32 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4GDMLWriteParamvol.cc,v 1.25 2009/04/24 15:34:20 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030// class G4GDMLParamVol Implementation
     
    3535
    3636#include "G4GDMLWriteParamvol.hh"
    37 #include <sstream>
     37
     38#include "G4Box.hh"
     39#include "G4Trd.hh"
     40#include "G4Trap.hh"
     41#include "G4Tubs.hh"
     42#include "G4Cons.hh"
     43#include "G4Sphere.hh"
     44#include "G4Orb.hh"
     45#include "G4Torus.hh"
     46#include "G4Para.hh"
     47#include "G4Hype.hh"
     48#include "G4LogicalVolume.hh"
     49#include "G4VPhysicalVolume.hh"
     50#include "G4PVParameterised.hh"
     51#include "G4VPVParameterisation.hh"
     52
     53G4GDMLWriteParamvol::
     54G4GDMLWriteParamvol() : G4GDMLWriteSetup()
     55{
     56}
     57
     58G4GDMLWriteParamvol::
     59~G4GDMLWriteParamvol()
     60{
     61}
    3862
    3963void G4GDMLWriteParamvol::
  • trunk/source/persistency/gdml/src/G4GDMLWriteSetup.cc

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLWriteSetup.cc,v 1.11 2008/07/16 15:46:34 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4GDMLWriteSetup.cc,v 1.13 2009/04/24 15:34:20 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030// class G4GDMLWriteSetup Implementation
     
    3535
    3636#include "G4GDMLWriteSetup.hh"
     37
     38#include "G4LogicalVolume.hh"
     39
     40G4GDMLWriteSetup::G4GDMLWriteSetup() : G4GDMLWriteSolids()
     41{
     42}
     43
     44G4GDMLWriteSetup::~G4GDMLWriteSetup()
     45{
     46}
    3747
    3848void G4GDMLWriteSetup::SetupWrite(xercesc::DOMElement* gdmlElement,
  • trunk/source/persistency/gdml/src/G4GDMLWriteSolids.cc

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLWriteSolids.cc,v 1.59 2008/11/21 09:32:46 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4GDMLWriteSolids.cc,v 1.65 2009/04/24 15:34:20 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030// class G4GDMLWriteSolids Implementation
     
    3636#include "G4GDMLWriteSolids.hh"
    3737
     38#include "G4BooleanSolid.hh"
     39#include "G4Box.hh"
     40#include "G4Cons.hh"
     41#include "G4Ellipsoid.hh"
     42#include "G4EllipticalCone.hh"
     43#include "G4EllipticalTube.hh"
     44#include "G4ExtrudedSolid.hh"
     45#include "G4Hype.hh"
     46#include "G4Orb.hh"
     47#include "G4Para.hh"
     48#include "G4Paraboloid.hh"
     49#include "G4IntersectionSolid.hh"
     50#include "G4Polycone.hh"
     51#include "G4Polyhedra.hh"
     52#include "G4ReflectedSolid.hh"
     53#include "G4Sphere.hh"
     54#include "G4SubtractionSolid.hh"
     55#include "G4TessellatedSolid.hh"
     56#include "G4Tet.hh"
     57#include "G4Torus.hh"
     58#include "G4Trap.hh"
     59#include "G4Trd.hh"
     60#include "G4Tubs.hh"
     61#include "G4TwistedBox.hh"
     62#include "G4TwistedTrap.hh"
     63#include "G4TwistedTrd.hh"
     64#include "G4TwistedTubs.hh"
     65#include "G4UnionSolid.hh"
     66#include "G4OpticalSurface.hh"
     67#include "G4SurfaceProperty.hh"
     68
     69G4GDMLWriteSolids::
     70G4GDMLWriteSolids() : G4GDMLWriteMaterials()
     71{
     72}
     73
     74G4GDMLWriteSolids::
     75~G4GDMLWriteSolids()
     76{
     77}
     78
    3879void G4GDMLWriteSolids::
    3980BooleanWrite(xercesc::DOMElement* solidsElement,
    4081             const G4BooleanSolid* const boolean)
    4182{
     83   G4int displaced=0;
     84
    4285   G4String tag("undefined");
    4386   if (dynamic_cast<const G4IntersectionSolid*>(boolean))
     
    5396   G4ThreeVector firstpos,firstrot,pos,rot;
    5497
    55    if (const G4DisplacedSolid* disp
    56        = dynamic_cast<const G4DisplacedSolid*>(firstPtr))
    57    {   
    58       firstpos = disp->GetObjectTranslation();
    59       firstrot = GetAngles(disp->GetObjectRotation());
    60       firstPtr = disp->GetConstituentMovedSolid();
    61    }
    62 
    63    if (const G4DisplacedSolid* disp
    64        = dynamic_cast<const G4DisplacedSolid*>(secondPtr))
    65    {
    66       pos = disp->GetObjectTranslation();
    67       rot = GetAngles(disp->GetObjectRotation());
    68       secondPtr = disp->GetConstituentMovedSolid();
     98   // Solve possible displacement of referenced solids!
     99   //
     100   while (true)
     101   {
     102      if ( displaced>8 )
     103      {
     104        G4String ErrorMessage = "The referenced solid '"
     105                              + firstPtr->GetName() +
     106                              + "in the Boolean shape '" +
     107                              + boolean->GetName() +
     108                              + "' was displaced too many times!";
     109        G4Exception("G4GDMLWriteSolids::BooleanWrite()",
     110                    "InvalidSetup", FatalException, ErrorMessage);
     111      }
     112
     113      if (G4DisplacedSolid* disp = dynamic_cast<G4DisplacedSolid*>(firstPtr))
     114      {
     115         firstpos += disp->GetObjectTranslation();
     116         firstrot += firstrot + GetAngles(disp->GetObjectRotation());
     117         firstPtr = disp->GetConstituentMovedSolid();
     118         displaced++;
     119         continue;
     120      }
     121      break;
     122   }
     123   displaced = 0;
     124   while (true)
     125   {
     126      if ( displaced>maxTransforms )
     127      {
     128        G4String ErrorMessage = "The referenced solid '"
     129                              + secondPtr->GetName() +
     130                              + "in the Boolean shape '" +
     131                              + boolean->GetName() +
     132                              + "' was displaced too many times!";
     133        G4Exception("G4GDMLWriteSolids::BooleanWrite()",
     134                    "InvalidSetup", FatalException, ErrorMessage);
     135      }
     136
     137      if (G4DisplacedSolid* disp = dynamic_cast<G4DisplacedSolid*>(secondPtr))
     138      {
     139         pos += disp->GetObjectTranslation();
     140         rot += GetAngles(disp->GetObjectRotation());
     141         secondPtr = disp->GetConstituentMovedSolid();
     142         displaced++;
     143         continue;
     144      }
     145      break;
    69146   }
    70147
     
    727804   zplaneElement->setAttributeNode(NewAttribute("rmax",rmax/mm));
    728805   element->appendChild(zplaneElement);
     806}
     807
     808void G4GDMLWriteSolids::
     809OpticalSurfaceWrite(xercesc::DOMElement* solidsElement,
     810                    const G4OpticalSurface* const surf)
     811{
     812   xercesc::DOMElement* optElement = NewElement("opticalsurface");
     813   G4OpticalSurfaceModel smodel = surf->GetModel();
     814   G4double sval = (smodel==glisur) ? surf->GetPolish() : surf->GetSigmaAlpha();
     815
     816   optElement->setAttributeNode(NewAttribute("name", surf->GetName()));
     817   optElement->setAttributeNode(NewAttribute("model", smodel));
     818   optElement->setAttributeNode(NewAttribute("finish", surf->GetFinish()));
     819   optElement->setAttributeNode(NewAttribute("type", surf->GetType()));
     820   optElement->setAttributeNode(NewAttribute("value", sval));
     821
     822   solidsElement->appendChild(optElement);
    729823}
    730824
     
    822916   else
    823917   {
    824      G4String error_msg = "Unknown solid: " + solidPtr->GetName();
    825      G4Exception("G4GDMLWriteSolids::AddSolid()", "ReadError",
     918     G4String error_msg = "Unknown solid: " + solidPtr->GetName()
     919                        + "; Type: " + solidPtr->GetEntityType();
     920     G4Exception("G4GDMLWriteSolids::AddSolid()", "WriteError",
    826921                 FatalException, error_msg);
    827922   }
  • trunk/source/persistency/gdml/src/G4GDMLWriteStructure.cc

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLWriteStructure.cc,v 1.74 2008/11/13 16:48:19 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4GDMLWriteStructure.cc,v 1.80 2009/04/24 15:34:20 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030// class G4GDMLWriteStructure Implementation
     
    3535
    3636#include "G4GDMLWriteStructure.hh"
     37
     38#include "G4Material.hh"
     39#include "G4ReflectedSolid.hh"
     40#include "G4DisplacedSolid.hh"
     41#include "G4LogicalVolumeStore.hh"
     42#include "G4PhysicalVolumeStore.hh"
     43#include "G4PVDivision.hh"
     44#include "G4PVReplica.hh"
     45#include "G4OpticalSurface.hh"
     46#include "G4LogicalSkinSurface.hh"
     47#include "G4LogicalBorderSurface.hh"
     48
     49G4GDMLWriteStructure::G4GDMLWriteStructure()
     50  : G4GDMLWriteParamvol()
     51{
     52}
     53
     54G4GDMLWriteStructure::~G4GDMLWriteStructure()
     55{
     56}
    3757
    3858void
     
    5070   G4String unitString("mm");
    5171   G4String axisString("kUndefined");
    52    if (axis==kXAxis) { axisString = "kXAxis"; } else
    53    if (axis==kYAxis) { axisString = "kYAxis"; } else
    54    if (axis==kZAxis) { axisString = "kZAxis"; } else
    55    if (axis==kRho) { axisString = "kRho";     } else
    56    if (axis==kPhi) { axisString = "kPhi"; unitString = "degree"; }
     72   if (axis==kXAxis) { axisString = "kXAxis"; }
     73   else if (axis==kYAxis) { axisString = "kYAxis"; }
     74   else if (axis==kZAxis) { axisString = "kZAxis"; }
     75   else if (axis==kRho)   { axisString = "kRho";     }
     76   else if (axis==kPhi)  { axisString = "kPhi"; unitString = "degree"; }
    5777
    5878   const G4String name
     
    154174   volumerefElement->setAttributeNode(NewAttribute("ref",volumeref));
    155175   replicavolElement->appendChild(volumerefElement);
    156 
    157176   xercesc::DOMElement* replicateElement = NewElement("replicate_along_axis");
    158177   replicavolElement->appendChild(replicateElement);
    159178
    160179   xercesc::DOMElement* dirElement = NewElement("direction");
    161    if(axis==kXAxis)dirElement->setAttributeNode(NewAttribute("x","1"));
    162    if(axis==kYAxis)dirElement->setAttributeNode(NewAttribute("y","1"));
    163    if(axis==kZAxis)dirElement->setAttributeNode(NewAttribute("z","1"));
    164    if(axis==kRho)dirElement->setAttributeNode(NewAttribute("rho","1"));
    165    if(axis==kPhi)dirElement->setAttributeNode(NewAttribute("phi","1"));
     180   if(axis==kXAxis)
     181     { dirElement->setAttributeNode(NewAttribute("x","1")); }
     182   else if(axis==kYAxis)
     183     { dirElement->setAttributeNode(NewAttribute("y","1")); }
     184   else if(axis==kZAxis)
     185     { dirElement->setAttributeNode(NewAttribute("z","1")); }
     186   else if(axis==kRho)
     187     { dirElement->setAttributeNode(NewAttribute("rho","1")); }
     188   else if(axis==kPhi)
     189     { dirElement->setAttributeNode(NewAttribute("phi","1")); }
    166190   replicateElement->appendChild(dirElement);
    167191
     
    179203}
    180204
     205void G4GDMLWriteStructure::
     206BorderSurfaceCache(const G4LogicalBorderSurface* const bsurf)
     207{
     208   if (!bsurf)  { return; }
     209
     210   const G4SurfaceProperty* psurf = bsurf->GetSurfaceProperty();
     211
     212   // Generate the new element for border-surface
     213   //
     214   xercesc::DOMElement* borderElement = NewElement("bordersurface");
     215   borderElement->setAttributeNode(NewAttribute("name", bsurf->GetName()));
     216   borderElement->setAttributeNode(NewAttribute("surfaceproperty",
     217                                                psurf->GetName()));
     218
     219   const G4String volumeref1 = GenerateName(bsurf->GetVolume1()->GetName(),
     220                                            bsurf->GetVolume1());
     221   const G4String volumeref2 = GenerateName(bsurf->GetVolume2()->GetName(),
     222                                            bsurf->GetVolume2());
     223   xercesc::DOMElement* volumerefElement1 = NewElement("physvolref");
     224   xercesc::DOMElement* volumerefElement2 = NewElement("physvolref");
     225   volumerefElement1->setAttributeNode(NewAttribute("ref",volumeref1));
     226   volumerefElement2->setAttributeNode(NewAttribute("ref",volumeref2));
     227   borderElement->appendChild(volumerefElement1);
     228   borderElement->appendChild(volumerefElement2);
     229
     230   if (FindOpticalSurface(psurf))
     231   {
     232     OpticalSurfaceWrite(solidsElement,
     233                         dynamic_cast<const G4OpticalSurface*>(psurf));
     234   }
     235
     236   borderElementVec.push_back(borderElement);
     237}
     238
     239void G4GDMLWriteStructure::
     240SkinSurfaceCache(const G4LogicalSkinSurface* const ssurf)
     241{
     242   if (!ssurf)  { return; }
     243
     244   const G4SurfaceProperty* psurf = ssurf->GetSurfaceProperty();
     245
     246   // Generate the new element for border-surface
     247   //
     248   xercesc::DOMElement* skinElement = NewElement("skinsurface");
     249   skinElement->setAttributeNode(NewAttribute("name", ssurf->GetName()));
     250   skinElement->setAttributeNode(NewAttribute("surfaceproperty",
     251                                              psurf->GetName()));
     252
     253   const G4String volumeref = GenerateName(ssurf->GetLogicalVolume()->GetName(),
     254                                           ssurf->GetLogicalVolume());
     255   xercesc::DOMElement* volumerefElement = NewElement("volumeref");
     256   volumerefElement->setAttributeNode(NewAttribute("ref",volumeref));
     257   skinElement->appendChild(volumerefElement);
     258
     259   if (FindOpticalSurface(psurf))
     260   {
     261     OpticalSurfaceWrite(solidsElement,
     262                         dynamic_cast<const G4OpticalSurface*>(psurf));
     263   }
     264
     265   skinElementVec.push_back(skinElement);
     266}
     267
     268G4bool G4GDMLWriteStructure::FindOpticalSurface(const G4SurfaceProperty* psurf)
     269{
     270   const G4OpticalSurface* osurf = dynamic_cast<const G4OpticalSurface*>(psurf);
     271   std::vector<const G4OpticalSurface*>::const_iterator pos;
     272   pos = std::find(opt_vec.begin(), opt_vec.end(), osurf);
     273   if (pos != opt_vec.end()) { return false; }  // item already created!
     274
     275   opt_vec.push_back(osurf);              // cache it for future reference
     276   return true;
     277}
     278
     279const G4LogicalSkinSurface*
     280G4GDMLWriteStructure::GetSkinSurface(const G4LogicalVolume* const lvol)
     281{
     282  G4LogicalSkinSurface* surf = 0;
     283  G4int nsurf = G4LogicalSkinSurface::GetNumberOfSkinSurfaces();
     284  if (nsurf)
     285  {
     286    const G4LogicalSkinSurfaceTable* stable =
     287          G4LogicalSkinSurface::GetSurfaceTable();
     288    std::vector<G4LogicalSkinSurface*>::const_iterator pos;
     289    for (pos = stable->begin(); pos != stable->end(); pos++)
     290    {
     291      if (lvol == (*pos)->GetLogicalVolume())
     292      {
     293        surf = *pos; break;
     294      }
     295    }
     296  }
     297  return surf;
     298}
     299
     300const G4LogicalBorderSurface*
     301G4GDMLWriteStructure::GetBorderSurface(const G4VPhysicalVolume* const pvol)
     302{
     303  G4LogicalBorderSurface* surf = 0;
     304  G4int nsurf = G4LogicalBorderSurface::GetNumberOfBorderSurfaces();
     305  if (nsurf)
     306  {
     307    const G4LogicalBorderSurfaceTable* btable =
     308          G4LogicalBorderSurface::GetSurfaceTable();
     309    std::vector<G4LogicalBorderSurface*>::const_iterator pos;
     310    for (pos = btable->begin(); pos != btable->end(); pos++)
     311    {
     312      if (pvol == (*pos)->GetVolume1())  // just the first in the couple
     313      {                                  // is enough
     314        surf = *pos; break;
     315      }
     316    }
     317  }
     318  return surf;
     319}
     320
     321void G4GDMLWriteStructure::SurfacesWrite()
     322{
     323   G4cout << "G4GDML: Writing surfaces..." << G4endl;
     324
     325   std::vector<xercesc::DOMElement*>::const_iterator pos;
     326   for (pos = skinElementVec.begin(); pos != skinElementVec.end(); pos++)
     327   {
     328     structureElement->appendChild(*pos);
     329   }
     330   for (pos = borderElementVec.begin(); pos != borderElementVec.end(); pos++)
     331   {
     332     structureElement->appendChild(*pos);
     333   }
     334}
     335
    181336void G4GDMLWriteStructure::StructureWrite(xercesc::DOMElement* gdmlElement)
    182337{
     
    197352   G4VSolid* solidPtr = volumePtr->GetSolid();
    198353   G4Transform3D R,invR;
    199    G4int reflected = 0;
     354   G4int trans=0;
    200355
    201356   while (true) // Solve possible displacement/reflection
    202357   {            // of the referenced solid!
    203       if (reflected>maxReflections)
     358      if (trans>maxTransforms)
    204359      {
    205360        G4String ErrorMessage = "Referenced solid in volume '"
     
    214369         R = R*refl->GetTransform3D();
    215370         solidPtr = refl->GetConstituentMovedSolid();
    216          reflected++;
     371         trans++;
    217372         continue;
    218373      }
     
    223378                             disp->GetObjectTranslation());
    224379         solidPtr = disp->GetConstituentMovedSolid();
    225          reflected++;
     380         trans++;
    226381         continue;
    227382      }
     
    230385   }
    231386
    232    if (reflected>0) { invR = R.inverse(); }
    233      // Only compute the inverse when necessary!
     387   // Only compute the inverse when necessary!
     388   //
     389   if (trans>0) { invR = R.inverse(); }
    234390
    235391   const G4String name
     
    318474         PhysvolWrite(volumeElement,physvol,invR*P*daughterR,ModuleName);
    319475      }
     476      BorderSurfaceCache(GetBorderSurface(physvol));
    320477   }
    321478
     
    326483   VolumeMap()[volumePtr] = R;
    327484
    328    G4GDMLWriteMaterials::AddMaterial(volumePtr->GetMaterial());
     485   AddExtension(volumeElement, volumePtr);
     486     // Add any possible user defined extension attached to a volume
     487
     488   AddMaterial(volumePtr->GetMaterial());
    329489     // Add the involved materials and solids!
    330490
    331    G4GDMLWriteSolids::AddSolid(solidPtr);
     491   AddSolid(solidPtr);
     492
     493   SkinSurfaceCache(GetSkinSurface(volumePtr));
    332494
    333495   return R;
  • trunk/source/persistency/gdml/src/G4STRead.cc

    r987 r1228  
    2424// ********************************************************************
    2525//
    26 // $Id: G4STRead.cc,v 1.3 2008/07/17 14:05:50 gcosmo Exp $
    27 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     26// $Id: G4STRead.cc,v 1.4 2009/04/24 15:34:20 gcosmo Exp $
     27// GEANT4 tag $Name: geant4-09-03 $
    2828//
    2929// class G4STRead Implementation
     
    3333// -------------------------------------------------------------------------
    3434
     35#include <fstream>
     36
    3537#include "G4STRead.hh"
     38
     39#include "G4Material.hh"
     40#include "G4Box.hh"
     41#include "G4QuadrangularFacet.hh"
     42#include "G4TriangularFacet.hh"
     43#include "G4TessellatedSolid.hh"
     44#include "G4LogicalVolume.hh"
     45#include "G4PVPlacement.hh"
    3646
    3747void G4STRead::TessellatedRead(const std::string& line)
Note: See TracChangeset for help on using the changeset viewer.