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
Files:
38 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/persistency/gdml/History

    r987 r1228  
    1 $Id: History,v 1.101 2009/02/26 10:13:49 gcosmo Exp $
     1$Id: History,v 1.116 2009/12/04 13:59:05 gcosmo Exp $
    22-------------------------------------------------------------------
    33
     
    1717     * Reverse chronological order (last date on top), please *
    1818     ----------------------------------------------------------
     19
     2004 Dec 2009 Gabriele Cosmo (gdml-V09-02-18)
     21- Updated list of optical properties in G4GDMLReadSolid according to
     22  last changes to G4OpticalSurface and G4SurfaceProperty.
     23
     2414 Oct 2009 Gabriele Cosmo (gdml-V09-02-17)
     25- Added support for GDML 'expression' tag, implementing generic expressions
     26  stored as literal constants.
     27- Corrected handling of 'quantity' tag; added missing caching of evaluation.
     28
     2924 Sep 2009 Gabriele Cosmo (gdml-V09-02-16)
     30- Added support for the GDML 'assembly' tag, implementing assemblies of
     31  simple placements through G4AssemblyVolume.
     32
     3312 May 2009 Gabriele Cosmo (gdml-V09-02-15)
     34- Restricted usage of loops only for placement of volumes. Now correctly
     35  handling most common use-case of multiple copies of the same volume/solid
     36  through loop statement. Addressing problem report #1063.
     37
     3811 May 2009 Gabriele Cosmo (gdml-V09-02-14)
     39- Allow for name stripping of volumes which are included in loops; do not
     40  store appended internal counter reference.
     41
     4227 April 2009 Gabriele Cosmo (gdml-V09-02-13)
     43- Get rid of unused parameter in G4GDMLWriteMaterials::PropertyVectorWrite().
     44
     4524 April 2009 Gabriele Cosmo (gdml-V09-02-12)
     46- Some code cleanup: rationalised inclusion of headers, replacing them
     47  with forward declarations where possible.
     48
     4924 April 2009 Gabriele Cosmo (gdml-V09-02-11)
     50- Allow for reading/writing of constant material properties.
     51- Implemented ability to write surface properties associated to volumes
     52  and material properties.
     53
     5417 April 2009 Gabriele Cosmo (gdml-V09-02-10)
     55- Defined missing copy constructor and operator=() to G4GDMLMatrix
     56  internal class, to avoid cases of memory corruption when handling matrices.
     57
     5815 April 2009 Gabriele Cosmo (gdml-V09-02-09)
     59- Completed virtual layer for allowing customisation of the writer for
     60  user-extended schemas.
     61
     6209 April 2009 Gabriele Cosmo (gdml-V09-02-08)
     63- Correction in G4GDMLWriteSolids::BooleanWrite() in order to handle
     64  cases of nested displaced solids given to both operands in a Boolean
     65  operation (ATLAS use case).
     66- Renamed flag for maximum number of transformations applied to a solid
     67  and moved to G4GDMLWriteSolids base class.
     68- First virtual layer for custom writer classes G4GDMLWriteSolids and
     69  G4GDMLWriteStructure.
     70
     7103 April 2009 Tatiana Nikitina (gdml-V09-02-07)
     72- Correction in materials and solids tags for allowing parsing of
     73  definitions within the tag scope; possibility foreseen by the schema.
     74
     7524 March 2009 Gabriele Cosmo (gdml-V09-02-06)
     76- Added empty default constructor and virtual destructor to classes in the
     77  inheritance chain.
     78
     7902 March 2009 Gabriele Cosmo (gdml-V09-02-05)
     80- Fixed association of entities in nested loops for solids and materials.
     81  Definitions of materials are not supposed to be included in loops being
     82  therefore repeated...
     83- Strip off white spaces from names G4GDMLWrite::GenerateName(), to avoid
     84  parsing problems in imported files.
    1985
    208626 February 2009 Tatiana Nikitina (gdml-V09-02-04)
  • trunk/source/persistency/gdml/include/G4GDMLEvaluator.hh

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLEvaluator.hh,v 1.16 2008/07/16 15:46:33 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4GDMLEvaluator.hh,v 1.17 2009/04/24 15:34:20 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
     
    4545#include <vector>
    4646
    47 #include "globals.hh"
     47#include "G4Types.hh"
    4848
    4949class G4GDMLEvaluator
  • trunk/source/persistency/gdml/include/G4GDMLParameterisation.hh

    r987 r1228  
    2626//
    2727// $Id: G4GDMLParameterisation.hh,v 1.10 2008/07/16 15:46:33 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
  • trunk/source/persistency/gdml/include/G4GDMLParser.hh

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLParser.hh,v 1.57 2009/01/22 11:02:07 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4GDMLParser.hh,v 1.58 2009/04/15 13:29:30 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
     
    5454   G4GDMLParser();
    5555   G4GDMLParser(G4GDMLReadStructure*);
     56   G4GDMLParser(G4GDMLReadStructure*, G4GDMLWriteStructure*);
    5657  ~G4GDMLParser();
    5758     //
     
    113114   G4GDMLReadStructure* reader;
    114115   G4GDMLWriteStructure* writer;
    115    G4bool ucode;
     116   G4bool urcode, uwcode;
    116117
    117118};
  • trunk/source/persistency/gdml/include/G4GDMLParser.icc

    r987 r1228  
    2626//
    2727// $Id: G4GDMLParser.icc,v 1.8 2009/01/22 11:02:07 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
  • trunk/source/persistency/gdml/include/G4GDMLRead.hh

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLRead.hh,v 1.27 2009/01/22 11:02:07 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4GDMLRead.hh,v 1.31 2009/05/12 15:46:43 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030// class G4GDMLRead
     
    4747#include <xercesc/dom/DOM.hpp>
    4848
     49#include "G4Types.hh"
     50
    4951#include "G4GDMLEvaluator.hh"
    5052
    51 #include "G4LogicalVolume.hh"
    52 #include "G4VisAttributes.hh"
    53 #include "G4PVPlacement.hh"
    54 
    55 #include <sstream>
     53class G4LogicalVolume;
     54class G4VPhysicalVolume;
    5655
    5756class G4GDMLErrorHandler : public xercesc::ErrorHandler
     
    149148 private:
    150149
    151    G4int inLoop;
     150   G4int inLoop, loopCount;
    152151
    153152};
  • trunk/source/persistency/gdml/include/G4GDMLReadDefine.hh

    r987 r1228  
    4141
    4242#include "G4ThreeVector.hh"
     43#include "G4RotationMatrix.hh"
     44
    4345#include "G4GDMLRead.hh"
    4446
     
    5052   G4GDMLMatrix();
    5153   G4GDMLMatrix(size_t rows0,size_t cols0);
    52    ~G4GDMLMatrix();
     54   G4GDMLMatrix(const G4GDMLMatrix& rhs);
     55   G4GDMLMatrix& operator=(const G4GDMLMatrix& rhs);
     56  ~G4GDMLMatrix();
    5357
    5458   void Set(size_t r,size_t c,G4double a);
     
    8084 protected:
    8185
     86   G4GDMLReadDefine();
     87   virtual ~G4GDMLReadDefine();
     88
    8289   G4RotationMatrix GetRotationMatrix(const G4ThreeVector&);
    8390   void VectorRead(const xercesc::DOMElement* const,G4ThreeVector&);
     
    9097   void ScaleRead(const xercesc::DOMElement* const);
    9198   void VariableRead(const xercesc::DOMElement* const);
    92    void QuantityRead(const xercesc::DOMElement* const);
     99   void QuantityRead(const xercesc::DOMElement* const);
     100   void ExpressionRead(const xercesc::DOMElement* const);
    93101
    94102 protected:
  • trunk/source/persistency/gdml/include/G4GDMLReadMaterials.hh

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLReadMaterials.hh,v 1.9 2008/11/20 15:33:52 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4GDMLReadMaterials.hh,v 1.11 2009/04/24 15:34:20 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
     
    4343#define _G4GDMLREADMATERIALS_INCLUDED_
    4444
    45 #include "G4Element.hh"
    46 #include "G4Isotope.hh"
    47 #include "G4Material.hh"
    48 #include "G4NistManager.hh"
     45#include "G4Types.hh"
     46#include "G4GDMLReadDefine.hh"
    4947
    50 #include "G4GDMLReadDefine.hh"
     48class G4Element;
     49class G4Isotope;
     50class G4Material;
    5151
    5252class G4GDMLReadMaterials : public G4GDMLReadDefine
     
    6262
    6363 protected:
     64
     65   G4GDMLReadMaterials();
     66   virtual ~G4GDMLReadMaterials();
    6467
    6568   G4double AtomRead(const xercesc::DOMElement* const);
  • trunk/source/persistency/gdml/include/G4GDMLReadParamvol.hh

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLReadParamvol.hh,v 1.6 2008/11/20 15:33:52 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4GDMLReadParamvol.hh,v 1.8 2009/04/24 15:34:20 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
     
    4242#define _G4GDMLREADPARAMVOL_INCLUDED_
    4343
    44 #include "G4LogicalVolume.hh"
    45 #include "G4PVParameterised.hh"
    46 #include "G4PVPlacement.hh"
    47 #include "G4VPhysicalVolume.hh"
     44#include "G4GDMLReadSetup.hh"
     45#include "G4GDMLParameterisation.hh"
    4846
    49 #include "G4GDMLParameterisation.hh"
    50 #include "G4GDMLReadSetup.hh"
     47class G4LogicalVolume;
    5148
    5249class G4GDMLReadParamvol : public G4GDMLReadSetup
     
    6057
    6158 protected:
     59
     60   G4GDMLReadParamvol();
     61   virtual ~G4GDMLReadParamvol();
    6262
    6363   void Box_dimensionsRead(const xercesc::DOMElement* const,
  • trunk/source/persistency/gdml/include/G4GDMLReadSetup.hh

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLReadSetup.hh,v 1.5 2008/11/20 15:33:52 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4GDMLReadSetup.hh,v 1.6 2009/03/24 15:47:33 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
     
    5858 protected:
    5959
     60   G4GDMLReadSetup();
     61   virtual ~G4GDMLReadSetup();
     62
     63 protected:
     64
    6065   std::map<G4String,G4String> setupMap;
    6166};
  • trunk/source/persistency/gdml/include/G4GDMLReadSolids.hh

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLReadSolids.hh,v 1.12 2008/11/21 09:32:46 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4GDMLReadSolids.hh,v 1.15 2009/04/24 15:34:20 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
     
    4242#define _G4GDMLREADSOLIDS_INCLUDED_
    4343
    44 #include "G4Box.hh"
    45 #include "G4Cons.hh"
    46 #include "G4Ellipsoid.hh"
    47 #include "G4EllipticalCone.hh"
    48 #include "G4EllipticalTube.hh"
     44#include "G4Types.hh"
     45#include "G4GDMLReadMaterials.hh"
    4946#include "G4ExtrudedSolid.hh"
    50 #include "G4Hype.hh"
    51 #include "G4IntersectionSolid.hh"
    52 #include "G4Orb.hh"
    53 #include "G4Para.hh"
    54 #include "G4Paraboloid.hh"
    55 #include "G4Polycone.hh"
    56 #include "G4Polyhedra.hh"
    57 #include "G4QuadrangularFacet.hh"
    58 #include "G4ReflectedSolid.hh"
    59 #include "G4Sphere.hh"
    60 #include "G4SolidStore.hh"
    61 #include "G4SubtractionSolid.hh"
    62 #include "G4TessellatedSolid.hh"
    63 #include "G4Tet.hh"
    64 #include "G4Torus.hh"
    65 #include "G4Transform3D.hh"
    66 #include "G4Trap.hh"
    67 #include "G4Trd.hh"
    68 #include "G4TriangularFacet.hh"
    69 #include "G4Tubs.hh"
    70 #include "G4TwistedBox.hh"
    71 #include "G4TwistedTrap.hh"
    72 #include "G4TwistedTrd.hh"
    73 #include "G4TwistedTubs.hh"
    74 #include "G4UnionSolid.hh"
    75 #include "G4OpticalSurface.hh"
    76 #include "G4SurfaceProperty.hh"
    7747
    78 #include "G4GDMLReadMaterials.hh"
     48class G4VSolid;
     49class G4QuadrangularFacet;
     50class G4TriangularFacet;
     51class G4SurfaceProperty;
    7952
    8053class G4GDMLReadSolids : public G4GDMLReadMaterials
     
    9164
    9265 protected:
     66
     67   G4GDMLReadSolids();
     68   virtual ~G4GDMLReadSolids();
    9369
    9470   void BooleanRead(const xercesc::DOMElement* const,const BooleanOp);
     
    12298   G4TwoVector TwoDimVertexRead(const xercesc::DOMElement* const,G4double);
    12399   zplaneType ZplaneRead(const xercesc::DOMElement* const);
    124    void OpticalsurfaceRead(const xercesc::DOMElement* const);
     100   void OpticalSurfaceRead(const xercesc::DOMElement* const);
    125101};
    126102
  • trunk/source/persistency/gdml/include/G4GDMLReadStructure.hh

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLReadStructure.hh,v 1.24 2009/02/24 17:41:44 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4GDMLReadStructure.hh,v 1.28 2009/09/24 15:04:34 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
     
    4242#define _G4GDMLREADSTRUCTURE_INCLUDED_
    4343
    44 #include "G4AssemblyVolume.hh"
    45 #include "G4LogicalVolume.hh"
    46 #include "G4LogicalVolumeStore.hh"
    47 #include "G4PhysicalVolumeStore.hh"
    48 #include "G4PVDivision.hh"
    49 #include "G4PVPlacement.hh"
    50 #include "G4PVReplica.hh"
    51 #include "G4SolidStore.hh"
    52 #include "G4VPhysicalVolume.hh"
    53 #include "G4ReflectionFactory.hh"
    54 #include "G4PhysicalVolumeStore.hh"
    55 #include "G4LogicalSkinSurface.hh"
    56 #include "G4LogicalBorderSurface.hh"
    57 #include "G4PVDivisionFactory.hh"
     44#include "G4Types.hh"
     45#include "geomdefs.hh"
    5846
    5947#include "G4GDMLReadParamvol.hh"
     48
     49class G4AssemblyVolume;
     50class G4LogicalVolume;
     51class G4VPhysicalVolume;
    6052
    6153struct G4GDMLAuxPairType
     
    6759typedef std::vector<G4GDMLAuxPairType> G4GDMLAuxListType;
    6860typedef std::map<const G4LogicalVolume*,G4GDMLAuxListType> G4GDMLAuxMapType;
     61typedef std::map<G4String, G4AssemblyVolume*> G4GDMLAssemblyMapType;
    6962
    7063class G4GDMLReadStructure : public G4GDMLReadParamvol
     
    7366 public:
    7467
     68   G4GDMLReadStructure();
     69   virtual ~G4GDMLReadStructure();
     70
    7571   G4VPhysicalVolume* GetPhysvol(const G4String&) const;
    7672   G4LogicalVolume* GetVolume(const G4String&) const;
     73   G4AssemblyVolume* GetAssembly(const G4String&) const;
    7774   G4GDMLAuxListType GetVolumeAuxiliaryInformation(const G4LogicalVolume* const);
    7875   G4VPhysicalVolume* GetWorldVolume(const G4String&);
     
    8683
    8784   G4GDMLAuxPairType AuxiliaryRead(const xercesc::DOMElement* const);
    88    void BordersurfaceRead(const xercesc::DOMElement* const);
     85   void AssemblyRead(const xercesc::DOMElement* const);
    8986   void DivisionvolRead(const xercesc::DOMElement* const);
    9087   G4LogicalVolume* FileRead(const xercesc::DOMElement* const);
    91    void PhysvolRead(const xercesc::DOMElement* const);
     88   void PhysvolRead(const xercesc::DOMElement* const,
     89                    G4AssemblyVolume* assembly=0);
    9290   void ReplicavolRead(const xercesc::DOMElement* const, G4int number);
    9391   void ReplicaRead(const xercesc::DOMElement* const replicaElement,
     
    9593   EAxis AxisRead(const xercesc::DOMElement* const axisElement);
    9694   G4double QuantityRead(const xercesc::DOMElement* const readElement);
    97    void SkinsurfaceRead(const xercesc::DOMElement* const);
     95   void BorderSurfaceRead(const xercesc::DOMElement* const);
     96   void SkinSurfaceRead(const xercesc::DOMElement* const);
    9897
    9998 protected:
    10099
    101100   G4GDMLAuxMapType auxMap;
     101   G4GDMLAssemblyMapType assemblyMap;
    102102   G4LogicalVolume *pMotherLogical;
    103103
  • trunk/source/persistency/gdml/include/G4GDMLWrite.hh

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLWrite.hh,v 1.37 2008/08/19 15:03:17 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4GDMLWrite.hh,v 1.41 2009/04/24 15:34:20 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
     
    4242#define _G4GDMLWRITE_INCLUDED_
    4343
    44 #include <sys/stat.h>
    45 #include <iostream>
     44#include <map>
    4645
    4746#include <xercesc/dom/DOM.hpp>
     
    5049#include <xercesc/framework/LocalFileFormatTarget.hpp>
    5150
    52 #include "G4LogicalVolume.hh"
    5351#include "G4Transform3D.hh"
    54 #include "G4PVDivision.hh"
     52
     53class G4LogicalVolume;
     54class G4VPhysicalVolume;
    5555
    5656class G4GDMLWrite
    5757{
    58    typedef std::map<const G4LogicalVolume*,G4Transform3D> VolumeMapType;
    59    typedef std::map<const G4VPhysicalVolume*,G4String> PhysVolumeMapType;
    60    typedef std::map<G4int,G4int> DepthMapType;
     58  typedef std::map<const G4LogicalVolume*,G4Transform3D> VolumeMapType;
     59  typedef std::map<const G4VPhysicalVolume*,G4String> PhysVolumeMapType;
     60  typedef std::map<G4int,G4int> DepthMapType;
    6161
    62  public:  // without description
     62  public:  // with description
    6363
    64    G4Transform3D Write(const G4String& filename,
    65                        const G4LogicalVolume* const topLog,
    66                        const G4String& schemaPath,
    67                        const G4int depth, G4bool storeReferences=true);
    68    void AddModule(const G4VPhysicalVolume* const topVol);
    69    void AddModule(const G4int depth);
    70    static void SetAddPointerToName(G4bool);
     64    G4Transform3D Write(const G4String& filename,
     65                        const G4LogicalVolume* const topLog,
     66                        const G4String& schemaPath,
     67                        const G4int depth, G4bool storeReferences=true);
     68      //
     69      // Main method for writing GDML files.
    7170
    72  protected:
     71    void AddModule(const G4VPhysicalVolume* const topVol);
     72    void AddModule(const G4int depth);
     73      //
     74      // Split geometry structure in modules, by volume subtree or level
    7375
    74    G4String SchemaLocation;
     76    static void SetAddPointerToName(G4bool);
     77      //
     78      // Specify if to add or not memory addresses to IDs.
    7579
    76    VolumeMapType& VolumeMap();
     80    virtual void DefineWrite(xercesc::DOMElement*)=0;
     81    virtual void MaterialsWrite(xercesc::DOMElement*)=0;
     82    virtual void SolidsWrite(xercesc::DOMElement*)=0;
     83    virtual void StructureWrite(xercesc::DOMElement*)=0;
     84    virtual G4Transform3D TraverseVolumeTree(const G4LogicalVolume* const,
     85                                             const G4int)=0;
     86    virtual void SurfacesWrite()=0;
     87    virtual void SetupWrite(xercesc::DOMElement*,
     88                            const G4LogicalVolume* const)=0;
     89      //
     90      // Pure virtual methods implemented in concrete writer plugin's classes
    7791
    78    G4String GenerateName(const G4String&,const void* const);
    79    xercesc::DOMAttr* NewAttribute(const G4String&, const G4String&);
    80    xercesc::DOMAttr* NewAttribute(const G4String&, const G4double&);
    81    xercesc::DOMElement* NewElement(const G4String&);
    82    virtual void DefineWrite(xercesc::DOMElement*)=0;
    83    virtual void MaterialsWrite(xercesc::DOMElement*)=0;
    84    virtual void SolidsWrite(xercesc::DOMElement*)=0;
    85    virtual void StructureWrite(xercesc::DOMElement*)=0;
    86    virtual G4Transform3D TraverseVolumeTree(const G4LogicalVolume* const,
    87                                             const G4int)=0;
    88    virtual void SetupWrite(xercesc::DOMElement*,
    89                            const G4LogicalVolume* const)=0;
    90    G4String Modularize(const G4VPhysicalVolume* const topvol,
    91                        const G4int depth);
     92    virtual void ExtensionWrite(xercesc::DOMElement*);
     93    virtual void AddExtension(xercesc::DOMElement*,
     94                              const G4LogicalVolume* const);
     95      //
     96      // To be implemented in the client code for handling extensions
     97      // to the GDML schema, identified with the tag "extension".
     98      // The implementation should be placed inside a user-class
     99      // inheriting from G4GDMLWriteStructure and being registered
     100      // as argument to G4GDMLParser.
    92101
    93  private:
     102  protected:
    94103
    95    G4bool FileExists(const G4String&) const;
    96    PhysVolumeMapType& PvolumeMap();
    97    DepthMapType& DepthMap();
     104    G4GDMLWrite();
     105    virtual ~G4GDMLWrite();
    98106
    99  private:
     107    VolumeMapType& VolumeMap();
    100108
    101    static G4bool addPointerToName;
    102    xercesc::DOMDocument* doc;
    103    XMLCh tempStr[100];
     109    G4String GenerateName(const G4String&,const void* const);
     110    xercesc::DOMAttr* NewAttribute(const G4String&, const G4String&);
     111    xercesc::DOMAttr* NewAttribute(const G4String&, const G4double&);
     112    xercesc::DOMElement* NewElement(const G4String&);
     113    G4String Modularize(const G4VPhysicalVolume* const topvol,
     114                        const G4int depth);
     115
     116    G4bool FileExists(const G4String&) const;
     117    PhysVolumeMapType& PvolumeMap();
     118    DepthMapType& DepthMap();
     119
     120  protected:
     121
     122    G4String SchemaLocation;
     123    static G4bool addPointerToName;
     124    xercesc::DOMDocument* doc;
     125    xercesc::DOMElement* extElement;
     126    XMLCh tempStr[100];
    104127
    105128};
  • trunk/source/persistency/gdml/include/G4GDMLWriteDefine.hh

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLWriteDefine.hh,v 1.11 2008/07/16 15:46:33 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4GDMLWriteDefine.hh,v 1.14 2009/04/24 15:34:20 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
     
    4242#define _G4GDMLWRITEDEFINE_INCLUDED_
    4343
     44#include "G4Types.hh"
     45#include "G4ThreeVector.hh"
     46#include "G4RotationMatrix.hh"
     47
    4448#include "G4GDMLWrite.hh"
    45 #include <sstream>
    4649
    4750class G4GDMLWriteDefine : public G4GDMLWrite
    4851{
    4952
    50  protected:
     53  public:
    5154
    52    G4ThreeVector GetAngles(const G4RotationMatrix&);
    53    void ScaleWrite(xercesc::DOMElement* element, const G4String& name,
    54                     const G4ThreeVector& scl)
    55      { Scale_vectorWrite(element,"scale",name,scl); }
    56    void RotationWrite(xercesc::DOMElement* element, const G4String& name,
    57                     const G4ThreeVector& rot)
    58      { Rotation_vectorWrite(element,"rotation",name,rot); }
    59    void PositionWrite(xercesc::DOMElement* element, const G4String& name,
    60                     const G4ThreeVector& pos)
    61      { Position_vectorWrite(element,"position",name,pos); }
    62    void FirstrotationWrite(xercesc::DOMElement* element, const G4String& name,
    63                     const G4ThreeVector& rot)
    64      { Rotation_vectorWrite(element,"firstrotation",name,rot); }
    65    void FirstpositionWrite(xercesc::DOMElement* element, const G4String& name,
    66                     const G4ThreeVector& pos)
    67      { Position_vectorWrite(element,"firstposition",name,pos); }
    68    void AddPosition(const G4String& name,
    69                     const G4ThreeVector& pos)
    70      { Position_vectorWrite(defineElement,"position",name,pos); }
     55    G4ThreeVector GetAngles(const G4RotationMatrix&);
     56    void ScaleWrite(xercesc::DOMElement* element,
     57                    const G4String& name, const G4ThreeVector& scl)
     58         { Scale_vectorWrite(element,"scale",name,scl); }
     59    void RotationWrite(xercesc::DOMElement* element,
     60                    const G4String& name, const G4ThreeVector& rot)
     61         { Rotation_vectorWrite(element,"rotation",name,rot); }
     62    void PositionWrite(xercesc::DOMElement* element,
     63                    const G4String& name, const G4ThreeVector& pos)
     64         { Position_vectorWrite(element,"position",name,pos); }
     65    void FirstrotationWrite(xercesc::DOMElement* element,
     66                    const G4String& name, const G4ThreeVector& rot)
     67         { Rotation_vectorWrite(element,"firstrotation",name,rot); }
     68    void FirstpositionWrite(xercesc::DOMElement* element,
     69                    const G4String& name, const G4ThreeVector& pos)
     70         { Position_vectorWrite(element,"firstposition",name,pos); }
     71    void AddPosition(const G4String& name, const G4ThreeVector& pos)
     72         { Position_vectorWrite(defineElement,"position",name,pos); }
    7173
    72  protected:
     74    virtual void DefineWrite(xercesc::DOMElement*);
    7375
    74    static const G4double kRelativePrecision;
    75    static const G4double kAngularPrecision;
    76    static const G4double kLinearPrecision;
     76  protected:
     77
     78    G4GDMLWriteDefine();
     79    virtual ~G4GDMLWriteDefine();
     80
     81    void Scale_vectorWrite(xercesc::DOMElement*, const G4String&,
     82                              const G4String&, const G4ThreeVector&);
     83    void Rotation_vectorWrite(xercesc::DOMElement*, const G4String&,
     84                              const G4String&, const G4ThreeVector&);
     85    void Position_vectorWrite(xercesc::DOMElement*, const G4String&,
     86                              const G4String&, const G4ThreeVector&);
     87
     88  protected:
     89
     90    static const G4double kRelativePrecision;
     91    static const G4double kAngularPrecision;
     92    static const G4double kLinearPrecision;
    7793 
    78  private:
    79 
    80    void Scale_vectorWrite(xercesc::DOMElement*, const G4String&,
    81                              const G4String&, const G4ThreeVector&);
    82    void Rotation_vectorWrite(xercesc::DOMElement*, const G4String&,
    83                              const G4String&, const G4ThreeVector&);
    84    void Position_vectorWrite(xercesc::DOMElement*, const G4String&,
    85                              const G4String&, const G4ThreeVector&);
    86    void DefineWrite(xercesc::DOMElement*);
    87 
    88  private:
    89 
    90    xercesc::DOMElement* defineElement;
     94    xercesc::DOMElement* defineElement;
    9195
    9296};
  • trunk/source/persistency/gdml/include/G4GDMLWriteMaterials.hh

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLWriteMaterials.hh,v 1.12 2008/07/16 15:46:33 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4GDMLWriteMaterials.hh,v 1.17 2009/04/27 07:22:36 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
     
    4242#define _G4GDMLWRITEMATERIALS_INCLUDED_
    4343
    44 #include "G4Element.hh"
    45 #include "G4Isotope.hh"
    46 #include "G4Material.hh"
     44#include "G4Types.hh"
     45#include <vector>
    4746
    4847#include "G4GDMLWriteDefine.hh"
     48
     49class G4Isotope;
     50class G4Element;
     51class G4Material;
     52class G4MaterialPropertyVector;
    4953
    5054class G4GDMLWriteMaterials : public G4GDMLWriteDefine
    5155{
    5256
    53  protected:
     57 public:
    5458
    5559   void AddIsotope(const G4Isotope* const);
     
    5761   void AddMaterial(const G4Material* const);
    5862
    59  private:
     63   virtual void MaterialsWrite(xercesc::DOMElement*);
     64
     65 protected:
     66
     67   G4GDMLWriteMaterials();
     68   virtual ~G4GDMLWriteMaterials();
    6069
    6170   void AtomWrite(xercesc::DOMElement*,const G4double&);
     
    6675   void ElementWrite(const G4Element* const);
    6776   void MaterialWrite(const G4Material* const);
    68    void MaterialsWrite(xercesc::DOMElement*);
    69 
    70  private:
     77   void PropertyWrite(xercesc::DOMElement*, const G4Material* const);
     78   void PropertyVectorWrite(const G4String&,
     79                            const G4MaterialPropertyVector* const);
     80 protected:
    7181
    7282   std::vector<const G4Isotope*> isotopeList;
  • trunk/source/persistency/gdml/include/G4GDMLWriteParamvol.hh

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLWriteParamvol.hh,v 1.10 2008/08/13 13:58:53 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4GDMLWriteParamvol.hh,v 1.13 2009/04/24 15:34:20 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
     
    4242#define _G4GDMLWRITEPARAMVOL_INCLUDED_
    4343
    44 #include "G4PVParameterised.hh"
    45 #include "G4VPhysicalVolume.hh"
     44#include "G4GDMLWriteSetup.hh"
    4645
    47 #include "G4GDMLWriteSetup.hh"
     46class G4Box;
     47class G4Trd;
     48class G4Trap;
     49class G4Tubs;
     50class G4Cons;
     51class G4Sphere;
     52class G4Orb;
     53class G4Torus;
     54class G4Para;
     55class G4Hype;
     56class G4VPhysicalVolume;
    4857
    4958class G4GDMLWriteParamvol : public G4GDMLWriteSetup
    5059{
    5160
     61 public:
     62
     63   virtual void ParamvolWrite(xercesc::DOMElement*,
     64                              const G4VPhysicalVolume* const);
     65   virtual void ParamvolAlgorithmWrite(xercesc::DOMElement* paramvolElement,
     66                              const G4VPhysicalVolume* const paramvol);
     67
    5268 protected:
    5369
    54    void ParamvolWrite(xercesc::DOMElement*, const G4VPhysicalVolume* const);
    55 
    56  private:
     70   G4GDMLWriteParamvol();
     71   virtual ~G4GDMLWriteParamvol();
    5772
    5873   void Box_dimensionsWrite(xercesc::DOMElement*, const G4Box* const);
     
    6883   void ParametersWrite(xercesc::DOMElement*,
    6984                        const G4VPhysicalVolume* const, const G4int&);
    70    void ParamvolAlgorithmWrite(xercesc::DOMElement* paramvolElement,
    71                                const G4VPhysicalVolume* const paramvol);
    7285
    7386};
  • trunk/source/persistency/gdml/include/G4GDMLWriteSetup.hh

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLWriteSetup.hh,v 1.7 2008/07/16 15:46:34 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4GDMLWriteSetup.hh,v 1.9 2009/04/15 13:29:30 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
     
    4646class G4GDMLWriteSetup : public G4GDMLWriteSolids
    4747{
    48  private:
     48  public:
    4949
    50    void SetupWrite(xercesc::DOMElement*, const G4LogicalVolume* const);
     50    virtual void SetupWrite(xercesc::DOMElement*, const G4LogicalVolume* const);
     51
     52 protected:
     53
     54   G4GDMLWriteSetup();
     55   virtual ~G4GDMLWriteSetup();
     56
    5157};
    5258
  • trunk/source/persistency/gdml/include/G4GDMLWriteSolids.hh

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLWriteSolids.hh,v 1.32 2008/11/21 09:32:46 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4GDMLWriteSolids.hh,v 1.38 2009/04/24 15:34:20 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
     
    4242#define _G4GDMLWRITESOLIDS_INCLUDED_
    4343
    44 #include "G4BooleanSolid.hh"
    45 #include "G4Box.hh"
    46 #include "G4Cons.hh"
    47 #include "G4Ellipsoid.hh"
    48 #include "G4EllipticalCone.hh"
    49 #include "G4EllipticalTube.hh"
    50 #include "G4ExtrudedSolid.hh"
    51 #include "G4Hype.hh"
    52 #include "G4Orb.hh"
    53 #include "G4Para.hh"
    54 #include "G4Paraboloid.hh"
    55 #include "G4IntersectionSolid.hh"
    56 #include "G4Polycone.hh"
    57 #include "G4Polyhedra.hh"
    58 #include "G4ReflectedSolid.hh"
    59 #include "G4Sphere.hh"
    60 #include "G4SubtractionSolid.hh"
    61 #include "G4TessellatedSolid.hh"
    62 #include "G4Tet.hh"
    63 #include "G4Torus.hh"
    64 #include "G4Trap.hh"
    65 #include "G4Trd.hh"
    66 #include "G4Tubs.hh"
    67 #include "G4TwistedBox.hh"
    68 #include "G4TwistedTrap.hh"
    69 #include "G4TwistedTrd.hh"
    70 #include "G4TwistedTubs.hh"
    71 #include "G4UnionSolid.hh"
     44#include "G4Types.hh"
    7245
    7346#include "G4GDMLWriteMaterials.hh"
    7447
     48class G4BooleanSolid;
     49class G4Box;
     50class G4Cons;
     51class G4EllipticalCone;
     52class G4Ellipsoid;
     53class G4EllipticalTube;
     54class G4ExtrudedSolid;
     55class G4Hype;
     56class G4Orb;
     57class G4Para;
     58class G4Paraboloid;
     59class G4Polycone;
     60class G4Polyhedra;
     61class G4Sphere;
     62class G4TessellatedSolid;
     63class G4Tet;
     64class G4Torus;
     65class G4Trap;
     66class G4Trd;
     67class G4Tubs;
     68class G4TwistedBox;
     69class G4TwistedTrap;
     70class G4TwistedTrd;
     71class G4TwistedTubs;
     72class G4VSolid;
     73class G4OpticalSurface;
     74
    7575class G4GDMLWriteSolids : public G4GDMLWriteMaterials
    7676{
     77  public:
    7778
    78  protected:
     79   virtual void AddSolid(const G4VSolid* const);
     80   virtual void SolidsWrite(xercesc::DOMElement*);
    7981
    80    void AddSolid(const G4VSolid* const);
     82  protected:
    8183
    82  private:
     84   G4GDMLWriteSolids();
     85   virtual ~G4GDMLWriteSolids();
    8386
    8487   void BooleanWrite(xercesc::DOMElement*, const G4BooleanSolid* const);
     
    108111   void ZplaneWrite(xercesc::DOMElement*, const G4double&,
    109112                    const G4double&, const G4double&);
    110    void SolidsWrite(xercesc::DOMElement*);
     113   void OpticalSurfaceWrite(xercesc::DOMElement*,
     114                    const G4OpticalSurface* const);
    111115
    112  private:
     116  protected:
    113117
    114118   std::vector<const G4VSolid*> solidList;
    115119   xercesc::DOMElement* solidsElement;
     120   static const G4int maxTransforms = 8; // Constant for limiting the number
     121                                         // of displacements/reflections
     122                                         // applied to a single solid
    116123};
    117124
  • trunk/source/persistency/gdml/include/G4GDMLWriteStructure.hh

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4GDMLWriteStructure.hh,v 1.34 2008/07/16 15:46:34 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4GDMLWriteStructure.hh,v 1.39 2009/04/24 15:34:20 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
     
    4242#define _G4GDMLWRITESTRUCTURE_INCLUDED_
    4343
    44 #include "G4LogicalVolumeStore.hh"
    45 #include "G4PhysicalVolumeStore.hh"
    46 #include "G4Material.hh"
    47 #include "G4PVDivision.hh"
    48 #include "G4PVReplica.hh"
    49 #include "G4VPhysicalVolume.hh"
    50 #include "G4ReflectedSolid.hh"
     44#include "G4Types.hh"
    5145#include "G4Transform3D.hh"
    5246
    5347#include "G4GDMLWriteParamvol.hh"
    5448
     49class G4LogicalVolume;
     50class G4VPhysicalVolume;
     51class G4PVDivision;
     52class G4LogicalBorderSurface;
     53class G4LogicalSkinSurface;
     54class G4OpticalSurface;
     55class G4SurfaceProperty;
     56
    5557class G4GDMLWriteStructure : public G4GDMLWriteParamvol
    5658{
    5759
    58  private:
     60 public:
    5961
    60    void DivisionvolWrite(xercesc::DOMElement*,const G4PVDivision* const);
     62   G4GDMLWriteStructure();
     63   virtual ~G4GDMLWriteStructure();
     64
     65   virtual void StructureWrite(xercesc::DOMElement*);
     66
     67 protected:
     68
     69   void DivisionvolWrite(xercesc::DOMElement*, const G4PVDivision* const);
    6170   void PhysvolWrite(xercesc::DOMElement*,const G4VPhysicalVolume* const topVol,
    62                                           const G4Transform3D& transform,
    63                                           const G4String& moduleName);
    64    void ReplicavolWrite(xercesc::DOMElement*,const G4VPhysicalVolume* const);
    65    void StructureWrite(xercesc::DOMElement*);
     71                   const G4Transform3D& transform, const G4String& moduleName);
     72   void ReplicavolWrite(xercesc::DOMElement*, const G4VPhysicalVolume* const);
    6673   G4Transform3D TraverseVolumeTree(const G4LogicalVolume* const topVol,
    6774                                    const G4int depth);
    68  private:
     75   void SurfacesWrite();
     76   void BorderSurfaceCache(const G4LogicalBorderSurface* const);
     77   void SkinSurfaceCache(const G4LogicalSkinSurface* const);
     78   const G4LogicalBorderSurface* GetBorderSurface(const G4VPhysicalVolume* const);
     79   const G4LogicalSkinSurface* GetSkinSurface(const G4LogicalVolume* const);
     80   G4bool FindOpticalSurface(const G4SurfaceProperty*);
     81
     82 protected:
    6983
    7084   xercesc::DOMElement* structureElement;
    71    static const int maxReflections = 8; // Constant for limiting the number
    72                                         // of displacements/reflections applied
    73                                         // to a single solid
     85   std::vector<xercesc::DOMElement*> borderElementVec;
     86   std::vector<xercesc::DOMElement*> skinElementVec;
     87
     88 private:  // cache for optical surfaces...
     89
     90   std::vector<const G4OpticalSurface*> opt_vec;
    7491};
    7592
  • trunk/source/persistency/gdml/include/G4STRead.hh

    r987 r1228  
    2525//
    2626//
    27 // $Id: G4STRead.hh,v 1.3 2008/07/17 14:05:50 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4STRead.hh,v 1.4 2009/04/24 15:34:20 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
     
    4444#define _G4STREAD_INCLUDED_
    4545
    46 #include <fstream>
    4746#include <vector>
    4847#include <map>
    4948
    50 #include "G4TessellatedSolid.hh"
    51 #include "G4QuadrangularFacet.hh"
    52 #include "G4TriangularFacet.hh"
    53 #include "G4LogicalVolume.hh"
    54 #include "G4PVPlacement.hh"
    55 #include "G4Material.hh"
    56 #include "G4Box.hh"
     49#include "G4ThreeVector.hh"
     50
     51class G4Material;
     52class G4Box;
     53class G4TessellatedSolid;
     54class G4LogicalVolume;
    5755
    5856class G4STRead
  • 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.