]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant4/TG4XMLConvertor.h
Updated class description: added class name title, author;
[u/mrichter/AliRoot.git] / TGeant4 / TG4XMLConvertor.h
1 // $Id$
2 // Category: geometry
3 //
4 // Author: I. Hrivnacova, 27.07.2000 
5 //
6 // Class TG4XMLConvertor
7 // ---------------------
8 // The class provides methods for conversion of G4 basic geometry objects 
9 // to XML defined by AGDD.dtd
10 // (ATLAS Generic Detector Description)
11
12 #ifndef TG4_XML_CONVERTOR_H
13 #define TG4_XML_CONVERTOR_H
14
15 #include "TG4VXMLConvertor.h"
16 #include "TG4Globals.h"
17
18 #include <globals.hh>
19 #include <g4std/fstream>
20 #include <g4std/vector>
21
22 class G4Material;
23 class G4VSolid;
24 class G4LogicalVolume;
25 class G4PVReplica;
26 class G4Box;
27 class G4Tubs;
28 class G4Cons;
29 class G4Trd;
30 class G4Trap;
31 class G4Para;
32 class G4Polycone;
33 class G4Polyhedra;
34
35 class TG4XMLConvertor : public TG4VXMLConvertor
36 {
37   typedef G4std::vector<const G4RotationMatrix*> RotationMatrixVector;
38
39   public:
40     TG4XMLConvertor(G4std::ofstream& outFile);
41     virtual ~TG4XMLConvertor();
42
43     // methods
44     virtual void OpenMaterials(const G4String& version, const G4String& date, 
45             const G4String& author, const G4String dtdVersion);
46     virtual void OpenSection(const G4String& name, const G4String& version,
47             const G4String& date, const G4String& author,
48             const G4String& topVolume);
49     virtual void OpenComposition(const G4String& name);
50     virtual void CloseMaterials();
51     virtual void CloseSection();
52     virtual void CloseComposition();
53
54     virtual void WriteMaterial(const G4Material* material); 
55     virtual void WriteSolid(G4String lvName, const G4VSolid* solid, 
56                             G4String materialName); 
57     virtual void WriteRotation(const G4RotationMatrix* rotation); 
58     virtual void WritePosition(G4String lvName, G4ThreeVector position); 
59     virtual void WritePositionWithRotation(
60                                G4String lvName, G4ThreeVector position,
61                                const G4RotationMatrix* rotation); 
62     virtual void WriteReplica(G4String lvName, G4PVReplica* pvr);                              
63     virtual void WriteEmptyLine();
64     virtual void IncreaseIndention();
65     virtual void DecreaseIndention();
66     
67     // set methods
68     void SetNumWidth(G4int width);
69     void SetNumPrecision(G4int precision);
70
71   private:
72     //methods
73     void CutName(G4String& name) const;
74     void CutName(G4String& name, G4int size) const;
75     void PutName(G4String& element, G4String name, G4String templ) const;
76     
77          // writing solids
78     void WriteBox (G4String lvName, const G4Box*  box,  G4String materialName); 
79     void WriteTubs(G4String lvName, const G4Tubs* tubs, G4String materialName); 
80     void WriteCons(G4String lvName, const G4Cons* cons, G4String materialName); 
81     void WriteTrd (G4String lvName, const G4Trd*  trd,  G4String materialName); 
82     void WriteTrap(G4String lvName, const G4Trap* trap, G4String materialName); 
83     void WritePara(G4String lvName, const G4Para* para, G4String materialName); 
84     void WritePolycone(G4String lvName, const G4Polycone* polycone, 
85                    G4String materialName); 
86     void WritePolyhedra(G4String lvName, const G4Polyhedra* polyhedra, 
87                    G4String materialName); 
88   
89     // static data members
90     static const G4int fgkMaxVolumeNameLength;  //maximal volume name length
91     static const G4int fgkMaxMaterialNameLength;//maximal material name length
92     static const G4int fgkDefaultNumWidth;      //default output numbers width
93     static const G4int fgkDefaultNumPrecision;  //default output numbers precision 
94
95     // data members
96     G4std::ofstream&  fOutFile;          //output file
97     const G4String    fkBasicIndention;  //basic indention 
98     G4String          fIndention;        //indention string
99     G4int             fNW;               //output numbers width
100     G4int             fNP;               //output numbers precision 
101     G4int             fRotationCounter;  //counter of rotations
102     RotationMatrixVector  fRotations;    //vector of rot matrices
103 };
104
105 inline void TG4XMLConvertor::SetNumWidth(G4int width)
106 { fNW = width; }
107
108 inline void TG4XMLConvertor::SetNumPrecision(G4int precision)
109 { fNP = precision; }
110
111 #endif //TG4_XML_CONVERTOR_H
112