Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions geom/gdml/src/TGDMLWrite.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ See that function for details.
#include "TGeoElement.h"
#include "TGeoShape.h"
#include "TGeoCompositeShape.h"
#include "TGeoExtension.h"
#include "TGeoOpticalSurface.h"
#include "TMap.h"
#include "TObjString.h"
#include <cstdlib>
#include <string>
#include <map>
Expand Down Expand Up @@ -758,6 +761,41 @@ void TGDMLWrite::ExtractVolumes(TGeoNode *node)
fGdmlE->AddChild(volumeN, childN);
}

// export auxiliary user-data if present (TMap of TObjString->TObjString)
{
TGeoRCExtension *rcext = (TGeoRCExtension *)volume->GetUserExtension();
if (rcext) {
TMap *auxmap = nullptr;
TObject *userObj = rcext->GetUserObject();
if (userObj && userObj->InheritsFrom("TMap")) {
TMap *auxmap = (TMap *)userObj;
TIterator *it = auxmap->MakeIterator();
TObject *k = nullptr;
while (k = it->Next()) {
TObject *valobj = auxmap->GetValue(k);
if (!valobj || !k->InheritsFrom("TObjString") || !valobj->InheritsFrom("TObjString"))
continue;
TObjString *key = (TObjString *)k;
TObjString *val = (TObjString *)valobj;
TString auxtype = key->GetString();
TString auxvalue = val->GetString();
TString auxunit = "";
Int_t pos = auxvalue.Index('*');
if (pos >= 0) {
auxunit = auxvalue(pos + 1, auxvalue.Length());
auxvalue = auxvalue(0, pos);
}
XMLNodePointer_t auxN = fGdmlE->NewChild(nullptr, nullptr, "auxiliary", nullptr);
fGdmlE->NewAttr(auxN, nullptr, "auxtype", auxtype.Data());
fGdmlE->NewAttr(auxN, nullptr, "auxvalue", auxvalue.Data());
if (!auxunit.IsNull())
fGdmlE->NewAttr(auxN, nullptr, "auxunit", auxunit.Data());
fGdmlE->AddChild(volumeN, auxN);
}
}
}
}

fVolCnt++;
// add volume/assembly node into the <structure> node
fGdmlE->AddChild(fStructureNode, volumeN);
Expand Down