@@ -156,7 +156,10 @@ See that function for details.
156156#include " TGeoElement.h"
157157#include " TGeoShape.h"
158158#include " TGeoCompositeShape.h"
159+ #include " TGeoExtension.h"
159160#include " TGeoOpticalSurface.h"
161+ #include " TMap.h"
162+ #include " TObjString.h"
160163#include < cstdlib>
161164#include < string>
162165#include < map>
@@ -758,6 +761,41 @@ void TGDMLWrite::ExtractVolumes(TGeoNode *node)
758761 fGdmlE ->AddChild (volumeN, childN);
759762 }
760763
764+ // export auxiliary user-data if present (TMap of TObjString->TObjString)
765+ {
766+ TGeoRCExtension *rcext = (TGeoRCExtension *)volume->GetUserExtension ();
767+ if (rcext) {
768+ TMap *auxmap = nullptr ;
769+ TObject *userObj = rcext->GetUserObject ();
770+ if (userObj && userObj->InheritsFrom (" TMap" )) {
771+ TMap *auxmap = (TMap *)userObj;
772+ TIterator *it = auxmap->MakeIterator ();
773+ TObject *k = nullptr ;
774+ while (k = it->Next ()) {
775+ TObject *valobj = auxmap->GetValue (k);
776+ if (!valobj || !k->InheritsFrom (" TObjString" ) || !valobj->InheritsFrom (" TObjString" ))
777+ continue ;
778+ TObjString *key = (TObjString *)k;
779+ TObjString *val = (TObjString *)valobj;
780+ TString auxtype = key->GetString ();
781+ TString auxvalue = val->GetString ();
782+ TString auxunit = " " ;
783+ Int_t pos = auxvalue.Index (' *' );
784+ if (pos >= 0 ) {
785+ auxunit = auxvalue (pos + 1 , auxvalue.Length ());
786+ auxvalue = auxvalue (0 , pos);
787+ }
788+ XMLNodePointer_t auxN = fGdmlE ->NewChild (nullptr , nullptr , " auxiliary" , nullptr );
789+ fGdmlE ->NewAttr (auxN, nullptr , " auxtype" , auxtype.Data ());
790+ fGdmlE ->NewAttr (auxN, nullptr , " auxvalue" , auxvalue.Data ());
791+ if (!auxunit.IsNull ())
792+ fGdmlE ->NewAttr (auxN, nullptr , " auxunit" , auxunit.Data ());
793+ fGdmlE ->AddChild (volumeN, auxN);
794+ }
795+ }
796+ }
797+ }
798+
761799 fVolCnt ++;
762800 // add volume/assembly node into the <structure> node
763801 fGdmlE ->AddChild (fStructureNode , volumeN);
0 commit comments