175 if (depth==0) {
G4cout <<
"G4GDML: Writing '" << fname <<
"'..." <<
G4endl; }
176 else {
G4cout <<
"G4GDML: Writing module '" << fname <<
"'..." <<
G4endl; }
180 G4String ErrorMessage =
"File '"+fname+
"' already exists!";
181 G4Exception(
"G4GDMLWrite::Write()",
"InvalidSetup",
188 xercesc::XMLString::transcode(
"LS",
tempStr, 9999);
189 xercesc::DOMImplementationRegistry::getDOMImplementation(
tempStr);
190 xercesc::XMLString::transcode(
"Range",
tempStr, 9999);
191 xercesc::DOMImplementation* impl =
192 xercesc::DOMImplementationRegistry::getDOMImplementation(
tempStr);
193 xercesc::XMLString::transcode(
"gdml",
tempStr, 9999);
195 xercesc::DOMElement* gdml =
doc->getDocumentElement();
197 #if XERCES_VERSION_MAJOR >= 3
199 xercesc::DOMLSSerializer* writer =
200 ((xercesc::DOMImplementationLS*)impl)->createLSSerializer();
202 xercesc::DOMConfiguration *dc = writer->getDomConfig();
203 dc->setParameter(xercesc::XMLUni::fgDOMWRTFormatPrettyPrint,
true);
207 xercesc::DOMWriter* writer =
208 ((xercesc::DOMImplementationLS*)impl)->createDOMWriter();
210 if (writer->canSetFeature(xercesc::XMLUni::fgDOMWRTFormatPrettyPrint,
true))
211 writer->setFeature(xercesc::XMLUni::fgDOMWRTFormatPrettyPrint,
true);
216 "http://www.w3.org/2001/XMLSchema-instance"));
217 gdml->setAttributeNode(
NewAttribute(
"xsi:noNamespaceSchemaLocation",
231 xercesc::XMLFormatTarget *myFormTarget =
232 new xercesc::LocalFileFormatTarget(fname.c_str());
236 #if XERCES_VERSION_MAJOR >= 3
238 xercesc::DOMLSOutput *theOutput =
239 ((xercesc::DOMImplementationLS*)impl)->createLSOutput();
240 theOutput->setByteStream(myFormTarget);
241 writer->write(
doc, theOutput);
243 writer->writeNode(myFormTarget, *
doc);
246 catch (
const xercesc::XMLException& toCatch)
248 char* message = xercesc::XMLString::transcode(toCatch.getMessage());
249 G4cout <<
"G4GDML: Exception message is: " << message <<
G4endl;
250 xercesc::XMLString::release(&message);
253 catch (
const xercesc::DOMException& toCatch)
255 char* message = xercesc::XMLString::transcode(toCatch.msg);
256 G4cout <<
"G4GDML: Exception message is: " << message <<
G4endl;
257 xercesc::XMLString::release(&message);
271 G4cout <<
"G4GDML: Writing '" << fname <<
"' done !" <<
G4endl;
275 G4cout <<
"G4GDML: Writing module '" << fname <<
"' done !" <<
G4endl;
virtual void ExtensionWrite(xercesc::DOMElement *)
xercesc::DOMDocument * doc
G4bool FileExists(const G4String &) const
virtual void SetupWrite(xercesc::DOMElement *, const G4LogicalVolume *const)=0
G4GLOB_DLL std::ostream G4cout
virtual void StructureWrite(xercesc::DOMElement *)=0
virtual void DefineWrite(xercesc::DOMElement *)=0
virtual void MaterialsWrite(xercesc::DOMElement *)=0
static G4bool addPointerToName
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
xercesc::DOMAttr * NewAttribute(const G4String &, const G4String &)
virtual G4Transform3D TraverseVolumeTree(const G4LogicalVolume *const, const G4int)=0
virtual void UserinfoWrite(xercesc::DOMElement *)
virtual void SolidsWrite(xercesc::DOMElement *)=0
virtual void SurfacesWrite()=0
VolumeMapType & VolumeMap()