1 \defgroup Geometry_gdml GDML tools
3 \brief GDML tools for geometry classes
5 The `$ROOTSYS/gdml` directory contains a set of Python modules designed
6 for writing out Geometry Description Markup Language (GDML) files.
7 There is also a C++ implementation for the import of GDML into ROOT.
8 They act as a converter between the GDML geometry files and the TGeo
9 geometry structures (and vice versa).
13 As this binding is integrated into the ROOT installation, you need to
14 enable the use of the binding at the configure point of the ROOT
15 installation. This can be done like so:
18 ./configure --enable-gdml
21 On doing this the libraries will be built by issuing the standard ROOT
22 make command. The GDML to TGeo converter uses the TXMLEngine to parse
23 the GDML files. This XML parser is a DOM parser and returns the DOM
24 tree to the class TGDMLParse. This class then interprets the GDML file
25 and adds the bindings in their TGeo equivalent.
27 The GDML schema is fully supported with a few exceptions:
29 - Replica Volumes are not supported
30 - Loops are not supported
31 - Matrices are not supported
33 These will hopefully be added in the near future.
35 Once you have enabled GDML in the configure process for ROOT, to import
36 a GDML file, this can be done using TGeoManager::Import. This automatically
37 calls the right method to parse the GDML by detecting the .gdml file
38 extension. Here is how to do it:
41 TGeoManager::Import("test.gdml");
44 Replace test.gdml with the gdml filename you want to import. Once the
45 GDML file has been successfully imported, you can view the geometry by
49 gGeoManager->GetTopVolume()->Draw("ogl");
52 For any questions or comments about the GDML->ROOT binding please contact ben.lloyd@cern.ch
57 The TGeo to GDML converter allows to export ROOT geometries (TGeo
58 geometry trees) as GDML files. The writer module writes a GDML file
59 out of the 'in-memory' representation of the geometry. The actual
60 application-specific (ROOT) binding is implemented in ROOTwriter
61 module. It contains 'binding methods' for TGeo geometry classes which
62 can be exported in GDML format. Please refere to the comment part of
63 the ROOTwriter.py file for the list of presently supported TGeo
64 classes. The ROOTwriter class contains also three methods,
65 dumpMaterials, dumpSolids and examineVol which need to be called in
66 order to export materials, solids and geometry tree respectively.
68 The TGeo to GDML converter is now interfaced to the
69 TGeoManager::Export method which automatically calls the appropriate
70 Python scripts whenever the geometry output file has the .gdml
73 Alternatively, one can also use the ROOT->GDML converter directly from
74 the Python prompt (assuming the TGeo geometry has already been loaded
75 into memory in one or another way), for example:
86 # get the top volume of the existing (in-memory) geometry tree
87 geomgr = ROOT.gGeoManager
88 topV = geomgr.GetTopVolume()
91 gdmlwriter = writer.writer('mygeo.gdml')
92 binding = ROOTwriter.ROOTwriter(gdmlwriter)
95 matlist = geomgr.GetListOfMaterials()
96 binding.dumpMaterials(matlist)
99 shapelist = geomgr.GetListOfShapes()
100 binding.dumpSolids(shapelist)
103 print 'Traversing geometry tree'
104 gdmlwriter.addSetup('default', '1.0', topV.GetName())
105 binding.examineVol(topV)
108 gdmlwriter.writeFile()
111 For all other functionality questions or comments, or even GDML in general,
112 please email Witold.Pokorski@cern.ch