G4GDMLRead.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // class G4GDMLRead
00030 //
00031 // Class description:
00032 //
00033 // GDML reader.
00034 
00035 // History:
00036 // - Created.                                  Zoltan Torzsok, November 2007
00037 // -------------------------------------------------------------------------
00038 
00039 #ifndef _G4GDMLBASE_INCLUDED_
00040 #define _G4GDMLBASE_INCLUDED_
00041 
00042 #include <xercesc/parsers/XercesDOMParser.hpp>
00043 #include <xercesc/util/PlatformUtils.hpp>
00044 #include <xercesc/sax/HandlerBase.hpp>
00045 #include <xercesc/util/XMLUni.hpp>
00046 #include <xercesc/dom/DOM.hpp>
00047 
00048 #include "G4Types.hh"
00049 
00050 #include "G4GDMLEvaluator.hh"
00051 
00052 class G4LogicalVolume;
00053 class G4VPhysicalVolume;
00054 
00055 class G4GDMLErrorHandler : public xercesc::ErrorHandler
00056 {
00057    G4bool Suppress;
00058 
00059  public:
00060 
00061    G4GDMLErrorHandler(const G4bool set) { Suppress = set; }
00062 
00063    void warning(const xercesc::SAXParseException& exception)
00064    {
00065       if (Suppress)  { return; }
00066       char* message = xercesc::XMLString::transcode(exception.getMessage());
00067       G4cout << "G4GDML: VALIDATION WARNING! " << message
00068              << " at line: " << exception.getLineNumber() << G4endl;
00069       xercesc::XMLString::release(&message);
00070    }
00071 
00072    void error(const xercesc::SAXParseException& exception)
00073    {
00074       if (Suppress)  { return; }
00075       char* message = xercesc::XMLString::transcode(exception.getMessage());
00076       G4cout << "G4GDML: VALIDATION ERROR! " << message
00077              << " at line: " << exception.getLineNumber() << G4endl;
00078       xercesc::XMLString::release(&message);
00079    }
00080 
00081    void fatalError(const xercesc::SAXParseException& exception)
00082    {
00083       error(exception);
00084    }
00085    void resetErrors() {}
00086 };
00087 
00088 class G4GDMLRead
00089 {
00090 
00091  public:  // with description
00092 
00093    virtual void DefineRead(const xercesc::DOMElement* const)=0;
00094    virtual void MaterialsRead(const xercesc::DOMElement* const)=0;
00095    virtual void SetupRead(const xercesc::DOMElement* const)=0;
00096    virtual void SolidsRead(const xercesc::DOMElement* const)=0;
00097    virtual void Paramvol_contentRead(const xercesc::DOMElement* const)=0;
00098    virtual void Volume_contentRead(const xercesc::DOMElement* const)=0;
00099    virtual void StructureRead(const xercesc::DOMElement* const)=0;
00100      //
00101      // Pure virtual methods implemented in concrete reader plugin's classes
00102 
00103    virtual void ExtensionRead(const xercesc::DOMElement* const);
00104      //
00105      // To be implemented in the client code for handling extensions
00106      // to the GDML schema, identified with the tag "extension".
00107      // The implementation should be placed inside a user-class
00108      // inheriting from G4GDMLReadStructure and being registered
00109      // as argument to G4GDMLParser.
00110 
00111    virtual G4LogicalVolume* GetVolume(const G4String&) const=0;
00112    virtual G4String GetSetup(const G4String&)=0;
00113      //
00114      // More pure virtual methods implemented in the reader plugin.
00115 
00116    void Read(const G4String&, G4bool validation,
00117              G4bool isModule, G4bool strip=true);
00118      //
00119      // Main method for reading GDML files.
00120 
00121    void StripNames() const;
00122      //
00123      // Strip off pointers from entity IDs.
00124 
00125    void OverlapCheck(G4bool);
00126      //
00127      // Activate/de-activate surface check for overlaps (default is off)
00128 
00129  protected:
00130 
00131    G4GDMLRead();
00132    virtual ~G4GDMLRead();
00133 
00134    G4String Transcode(const XMLCh* const);
00135    G4String GenerateName(const G4String& name, G4bool strip=false);
00136    G4String Strip(const G4String&) const;
00137    void StripName(G4String&) const;
00138    void GeneratePhysvolName(const G4String&,G4VPhysicalVolume*);
00139    void LoopRead(const xercesc::DOMElement* const,
00140                  void(G4GDMLRead::*)(const xercesc::DOMElement* const));
00141 
00142  protected:
00143 
00144    G4GDMLEvaluator eval;
00145    G4bool validate;
00146    G4bool check;
00147 
00148  private:
00149 
00150    G4int inLoop, loopCount;
00151 
00152 };
00153 
00154 #endif

Generated on Mon May 27 17:48:19 2013 for Geant4 by  doxygen 1.4.7