83 using namespace HEPREP;
 
   84 using namespace cheprep;
 
   87 G4int G4HepRepSceneHandler::sceneIdCount = 0;
 
   96           geometryLayer         (
"Geometry"),
 
   98           calHitLayer           (
"CalHit"),
 
   99           trajectoryLayer       (
"Trajectory"),
 
  101           rootVolumeName        (
"Geometry"),
 
  103           eventNumberPrefix     (
""),
 
  104           eventNumberSuffix     (
""),
 
  106           eventNumberWidth      (-1),
 
  111           writeMultipleFiles    (false),
 
  115           _heprepGeometry       (NULL)
 
  119     cout << 
"G4HepRepSceneHandler::G4HepRepSceneHandler: " << system << endl;
 
  137     cout << 
"G4HepRepSceneHandler::~G4HepRepSceneHandler() " << endl;
 
  150     if (writer != NULL) 
return;
 
  152     if (name == 
"stdout") {
 
  154         cout << 
"G4HepRepSceneHandler::Open() stdout" << endl;
 
  159         eventNumberPrefix = 
"";
 
  160         eventNumberSuffix = 
"";
 
  165         writeMultipleFiles = 
false;
 
  167         eventNumberWidth = 0;        
 
  168     } 
else if (name == 
"stderr") {
 
  170         cout << 
"G4HepRepSceneHandler::Open() stderr" << endl;
 
  175         eventNumberPrefix = 
"";
 
  176         eventNumberSuffix = 
"";
 
  181         writeMultipleFiles = 
false;
 
  183         eventNumberWidth = 0;        
 
  186         cout << 
"G4HepRepSceneHandler::Open() " << name << endl;
 
  188         if (eventNumberWidth < 0) {
 
  191             const unsigned int numberOfExtensions = 8;
 
  192             string ext[numberOfExtensions] = {
".heprep", 
".heprep.xml", 
".heprep.zip", 
".heprep.gz",
 
  193                                               ".bheprep", 
".bheprep.xml", 
".bheprep.zip", 
".bheprep.gz"};
 
  195             while (i < numberOfExtensions) {
 
  196                 int dot = name.size() - ext[i].size();
 
  198                     (name.substr(dot, ext[i].size()) == ext[i])) 
break;
 
  202             if (i != numberOfExtensions) {
 
  204                 writeBinary = i >= (numberOfExtensions/2);
 
  205                 writeZip = (i == 2) || (i == 6);
 
  206                 writeGZ = (i == 3) || (i == 7);
 
  208                 int dot = name.length() - extension.length();
 
  209                 baseName = (dot >= 0) ? name.substr(0, dot) : 
"";
 
  213                 extension = 
".heprep.zip";
 
  220             writeMultipleFiles = 
false;
 
  221             int startDigit = -1; 
int endDigit = -1;
 
  228                 endDigit = suffix.length()-1; 
 
  229                 while (endDigit >= 0) {
 
  230                     if (isdigit(suffix.at(endDigit))) 
break;
 
  234                     cerr << 
"/vis/heprep/appendEventNumberSuffix contains no digits" << endl;
 
  236                     writeMultipleFiles = 
true;
 
  237                     startDigit = endDigit;
 
  238                     while (startDigit >= 0) {
 
  239                         if (!isdigit(suffix.at(startDigit))) 
break;
 
  246             if (writeMultipleFiles) {
 
  247                 eventNumberPrefix = suffix.substr(0, startDigit);
 
  248                 eventNumber = atoi(suffix.substr(startDigit, endDigit).c_str());
 
  249                 eventNumberWidth = endDigit +1 - startDigit;
 
  250                 eventNumberSuffix = suffix.substr(endDigit+1);
 
  256                 eventNumberWidth = 10;
 
  257                 eventNumberPrefix = 
"";
 
  258                 eventNumberSuffix = 
"";
 
  267     cout << 
"G4HepRepSceneHandler::OpenHepRep() " << endl;
 
  270     if (_heprep != NULL) 
return;
 
  273     _heprepGeometry       = NULL;
 
  274     _geometryInstanceTree = NULL;
 
  275     _geometryRootInstance = NULL;
 
  276     _geometryInstance.clear();
 
  277     _geometryTypeTree     = NULL;
 
  278     _geometryRootType     = NULL;
 
  279     _geometryTypeName.clear();
 
  280     _geometryType.clear();
 
  281     _eventInstanceTree    = NULL;
 
  282     _eventInstance        = NULL;
 
  283     _eventTypeTree        = NULL;
 
  285     _trajectoryType       = NULL;
 
  288     _calHitFaceType       = NULL;     
 
  296     if (_heprep == NULL) 
return true;
 
  299     cout << 
"G4HepRepSceneHandler::CloseHepRep() start" << endl;
 
  304         if (_eventInstanceTree != NULL) {
 
  305             cerr << 
"WARNING: you probably used '/vis/viewer/endOfEventAction accumulate' and " 
  306                  << 
"forgot to call /vis/viewer/update before exit. No event written." << endl;
 
  314         if (_eventInstanceTree != NULL) {
 
  321                 if ((_geometryInstanceTree != NULL)) {
 
  326                 if (writeMultipleFiles) {
 
  327                     sprintf(name, 
"%s%s%s#%s", baseName.c_str(), 
"-geometry", extension.c_str(), 
"G4GeometryData");
 
  329                     sprintf(name, 
"%s%s#%s", 
"geometry", (writeBinary ? 
".bheprep" : 
".heprep"), 
"G4GeometryData");
 
  336         if (_eventInstanceTree != NULL) {
 
  346         writeLayers(_heprepGeometry);
 
  347         writeLayers(_heprep);
 
  350         if (writer == NULL) {
 
  356             if (writeMultipleFiles) {
 
  358                 sprintf(fileName, 
"%s%s%s", baseName.c_str(), 
"-geometry", extension.c_str());
 
  363             sprintf(name, 
"%s%s", 
"geometry", (writeBinary ? 
".bheprep" : 
".heprep"));
 
  364             if (!writeMultipleFiles) {
 
  370             delete _heprepGeometry;
 
  371             _heprepGeometry = NULL;
 
  376         if (writeMultipleFiles) {
 
  383             char fileFormat[128];
 
  384             sprintf(fileFormat, 
"%s%d%s", 
"%s%s%0", eventNumberWidth, 
"d%s%s");
 
  385             sprintf(fileName, fileFormat, baseName.c_str(), eventNumberPrefix.c_str(), eventNumber, eventNumberSuffix.c_str(), extension.c_str());
 
  396         char eventFormat[128];
 
  397         sprintf(eventFormat, 
"%s%d%s%s", 
"event-%0", eventNumberWidth, 
"d", (writeBinary ? 
".bheprep" : 
".heprep"));
 
  398         sprintf(eventName, eventFormat, eventNumber);
 
  413 void G4HepRepSceneHandler::close() {
 
  416     cout << 
"G4HepRepSceneHandler::Close() " << endl;
 
  419     if (writer == NULL) 
return;
 
  421     if (!writeMultipleFiles) {
 
  431     out = 
new ofstream(name.c_str(), std::ios::out | std::ios::binary );
 
  444 void G4HepRepSceneHandler::writeLayers(
HepRep* heprep) {
 
  445     if (heprep == NULL) 
return;
 
  455     cout << 
"G4HepRepSceneHandler::BeginModeling() " << endl;
 
  463     cout << 
"G4HepRepSceneHandler::EndModeling() " << endl;
 
  470     cout << 
"G4HepRepSceneHandler::AddSolid(const G4Box& box)" << endl;
 
  473     if (dontWrite()) 
return;
 
  495     vertex1 = (transform) * vertex1;
 
  496     vertex2 = (transform) * vertex2;
 
  497     vertex3 = (transform) * vertex3;
 
  498     vertex4 = (transform) * vertex4;
 
  499     vertex5 = (transform) * vertex5;
 
  500     vertex6 = (transform) * vertex6;
 
  501     vertex7 = (transform) * vertex7;
 
  502     vertex8 = (transform) * vertex8;
 
  505     addAttributes(instance, getCalHitType());
 
  507     setAttribute(instance, 
"DrawAs", 
G4String(
"Prism"));
 
  509     setVisibility(instance, box);
 
  510     setLine(instance, box);
 
  511     setColor(instance, getColorFor(box));
 
  526     cout << 
"G4HepRepSceneHandler::AddSolid(const G4Cons& cons)" << endl;
 
  529     if (dontWrite()) 
return;
 
  552     vertex1 = (transform) * vertex1;
 
  553     vertex2 = (transform) * vertex2;
 
  556     setAttribute(instance, 
"DrawAs", 
G4String(
"Cylinder"));
 
  558     setVisibility(instance, cons);
 
  559     setLine(instance, cons);
 
  560     setColor(instance, getColorFor(cons));
 
  567     outer->addAttValue(
"showParentAttributes",
true);
 
  590     cout << 
"G4HepRepSceneHandler::AddSolid(const G4Tubs& tubs)" << endl;
 
  593     if (dontWrite()) 
return;
 
  616     vertex1 = (transform) * vertex1;
 
  617     vertex2 = (transform) * vertex2;
 
  620     setAttribute(instance, 
"DrawAs", 
G4String(
"Cylinder"));
 
  622     setVisibility(instance, tubs);
 
  623     setLine(instance, tubs);
 
  624     setColor(instance, getColorFor(tubs));
 
  631     outer->addAttValue(
"pickParent",
true);
 
  632     outer->addAttValue(
"showParentAttributes",
true);
 
  650     cout << 
"G4HepRepSceneHandler::AddSolid(const G4Trd& trd)" << endl;
 
  652     if (dontWrite()) 
return;
 
  676     vertex1 = (transform) * vertex1;
 
  677     vertex2 = (transform) * vertex2;
 
  678     vertex3 = (transform) * vertex3;
 
  679     vertex4 = (transform) * vertex4;
 
  680     vertex5 = (transform) * vertex5;
 
  681     vertex6 = (transform) * vertex6;
 
  682     vertex7 = (transform) * vertex7;
 
  683     vertex8 = (transform) * vertex8;
 
  687     addAttributes(instance, getCalHitType());
 
  689     setAttribute(instance, 
"DrawAs", 
G4String(
"Prism"));
 
  691     setVisibility(instance, trd);
 
  692     setLine(instance, trd);
 
  693     setColor(instance, getColorFor(trd));
 
  706     if (dontWrite()) 
return;
 
  711     if (dontWrite()) 
return;
 
  716     if (dontWrite()) 
return;
 
  721     if (dontWrite()) 
return;
 
  726   if (dontWrite()) 
return;
 
  731   if (dontWrite()) 
return;
 
  736   if (dontWrite()) 
return;
 
  741   if (dontWrite()) 
return;
 
  746     if (dontWrite()) 
return;
 
  754     cout << 
"G4HepRepSceneHandler::AddPrimitive(G4Polyline&) " << line.size() << endl;
 
  756     if (dontWrite()) 
return;
 
  759       static G4bool warned = 
false;
 
  763       (
"G4HepRepSceneHandler::AddPrimitive (const G4Polyline&)",
 
  765        "2D polylines not implemented.  Ignored.");
 
  772     addAttributes(instance, getTrajectoryType());
 
  777     setVisibility(instance, line);
 
  779     setLine(instance, line);
 
  781     for (
size_t i=0; i < line.size(); i++) {
 
  791     cout << 
"G4HepRepSceneHandler::AddPrimitive(G4Polymarker&) " << line.size() << endl;
 
  793     if (dontWrite()) 
return;
 
  796       static G4bool warned = 
false;
 
  800       (
"G4HepRepSceneHandler::AddPrimitive (const G4Polymarker&)",
 
  802        "2D polymarkers not implemented.  Ignored.");
 
  809     addAttributes(instance, getHitType());
 
  814     setVisibility(instance, line);
 
  816     setMarker(instance, line);
 
  822     if (mtype == line.
dots) {
 
  823         setAttribute(instance, 
"Fill", 
true);
 
  825     } 
else if (mtype == line.
circles) {
 
  826     } 
else if (mtype == line.
squares) {
 
  827         setAttribute(instance, 
"MarkName", 
G4String(
"Box"));
 
  830         setAttribute(instance, 
"MarkName", 
G4String(
"Plus"));
 
  833     for (
size_t i=0; i < line.size(); i++) {
 
  842     cout << 
"G4HepRepSceneHandler::AddPrimitive(G4Circle&) " << endl;
 
  844     if (dontWrite()) 
return;
 
  847       static G4bool warned = 
false;
 
  851       (
"G4HepRepSceneHandler::AddPrimitive (const G4Circle&)",
 
  853        "2D circles not implemented.  Ignored.");
 
  860     addAttributes(instance, getHitType());
 
  867     setVisibility(instance, circle);
 
  869     setMarker(instance, circle);
 
  878     cout << 
"G4HepRepSceneHandler::AddPrimitive(G4Polyhedron&) " << endl;
 
  880     if (dontWrite()) 
return;
 
  883       static G4bool warned = 
false;
 
  887       (
"G4HepRepSceneHandler::AddPrimitive (const G4Polyhedron&)",
 
  889        "2D polyhedra not implemented.  Ignored.");
 
  901     addAttributes(instance, getCalHitType());
 
  903     setVisibility(instance, polyhedron);
 
  905     G4int currentDepth = 0;
 
  916             face = getGeometryInstance(
"*Face", currentDepth+1);
 
  917             setAttribute(face, 
"PickParent", 
true);
 
  918             setAttribute(face, 
"DrawAs", 
G4String(
"Polygon"));
 
  921         setLine(face, polyhedron);
 
  932             vertex = transform * vertex;
 
  934         } 
while (notLastEdge);
 
  935     } 
while (notLastFace);
 
  941     cout << 
"G4HepRepSceneHandler::AddPrimitive(G4Text&) " << endl;
 
  943     if (dontWrite()) 
return;
 
  959     cout << 
"G4HepRepSceneHandler::AddPrimitive G4Text : not yet implemented. " << endl;
 
  965     cout << 
"G4HepRepSceneHandler::AddPrimitive(G4Square&) " << endl;
 
  967     if (dontWrite()) 
return;
 
  970       static G4bool warned = 
false;
 
  974       (
"G4HepRepSceneHandler::AddPrimitive (const G4Square&)",
 
  976        "2D squares not implemented.  Ignored.");
 
  983     addAttributes(instance, getHitType());
 
  987     setColor (instance, getColorFor(square));
 
  989     setVisibility(instance, square);
 
  991     setMarker(instance, square);
 
  997     if (dontWrite()) 
return;
 
 1003     cout << 
"G4HepRepSceneHandler::AddCompound(G4VTrajectory&) " << endl;
 
 1005     if (dontWrite()) 
return;
 
 1007     currentTrack = &trajectory;
 
 1009     currentTrack = NULL;    
 
 1015     cout << 
"G4HepRepSceneHandler::AddCompound(G4VHit&) " << endl;
 
 1017     if (dontWrite()) 
return;
 
 1029     transform = objectTransformation;
 
 1031     cout << 
"G4HepRepSceneHandler::PreAddSolid(G4Transform3D&, G4VisAttributes&)" << endl;
 
 1038     cout << 
"G4HepRepSceneHandler::PostAddSolid()" << endl;
 
 1046     cout << 
"G4HepRepSceneHandler::BeginPrimitives(G4Transform3D&)" << endl;
 
 1050     transform = objectTransformation;
 
 1056     cout << 
"G4HepRepSceneHandler::EndPrimitives" << endl;
 
 1062 G4bool G4HepRepSceneHandler::dontWrite() {  
 
 1071     cout << 
"G4HepRepSceneHandler::setColor : red : " << color.
GetRed ()   <<
 
 1072                                   " green : " << color.
GetGreen () <<
 
 1073                                   " blue : " << color.
GetBlue ()   << endl;
 
 1096     setAttribute(attribute, 
"Visibility", (atts && (atts->
IsVisible()==0)) ? 
false : 
true);
 
 1100     setAttribute(attribute, 
"LineWidth", 1.0);
 
 1106     setAttribute(attribute, 
"LineWidth", (atts != NULL) ? atts->
GetLineWidth() : 1.0);
 
 1111                 setAttribute(attribute, 
"LineStyle", 
G4String(
"Dotted"));
 
 1114                 setAttribute(attribute, 
"LineStyle", 
G4String(
"Dashed"));
 
 1127     setAttribute(attribute, 
"MarkSize", size);
 
 1129     if (markerType == 
screen) setAttribute(attribute, 
"MarkType", 
G4String(
"Symbol"));
 
 1131         setAttribute(attribute, 
"Fill", 
false);
 
 1141         const map<G4String,G4AttDef>* hitAttDefs = currentHit->
GetAttDefs();
 
 1143         addAttDefs(getHitType(), hitAttDefs);
 
 1154         addAttVals(instance, hitAttDefs, hitAttValues);
 
 1156         delete hitAttValues;
 
 1158     } 
else if (currentTrack) {
 
 1159         vector<G4AttValue>* trajectoryAttValues = currentTrack->
CreateAttValues();
 
 1160         const map<G4String,G4AttDef>* trajectoryAttDefs = currentTrack->
GetAttDefs();
 
 1162         addAttDefs(type, trajectoryAttDefs);
 
 1174         addAttVals(instance, trajectoryAttDefs, trajectoryAttValues);
 
 1176         delete trajectoryAttValues;
 
 1185         if (point != NULL) {
 
 1192         if (instance != NULL) {
 
 1195                 attribute = instance->
getType();
 
 1207         if (point != NULL) {
 
 1214         if (instance != NULL) {
 
 1217                 attribute = instance->
getType();
 
 1229         if (point != NULL) {
 
 1236         if (instance != NULL) {
 
 1239                 attribute = instance->
getType();
 
 1251         if (point != NULL) {
 
 1258         if (instance != NULL) {
 
 1261                 attribute = instance->
getType();
 
 1271     vector<double> color;
 
 1272     if (attValue != NULL) color = attValue->
getColor();
 
 1273     if ((color.size() == 0) ||
 
 1274         (color[0] != red) ||
 
 1275         (color[1] != green) ||
 
 1276         (color[2] != blue) ||
 
 1277         ((color.size() > 3) && (color[3] != alpha))) {
 
 1280         if (point != NULL) {
 
 1287         if (instance != NULL) {
 
 1290                 attribute = instance->
getType();
 
 1294         attribute->
addAttValue(name, red, green, blue, alpha);
 
 1298 void G4HepRepSceneHandler::addAttDefs(
HepRepDefinition* definition, 
const map<G4String,G4AttDef>* attDefs) {
 
 1299     if (attDefs == NULL) 
return;
 
 1302     map<G4String,G4AttDef>::const_iterator attDefIterator = attDefs->begin();
 
 1303     while (attDefIterator != attDefs->end()) {
 
 1304         definition->
addAttDef(attDefIterator->first, attDefIterator->second.GetDesc(),
 
 1305                         attDefIterator->second.GetCategory(), attDefIterator->second.GetExtra());
 
 1310 void G4HepRepSceneHandler::addAttVals(
HepRepAttribute* attribute, 
const map<G4String,G4AttDef>* attDefs, vector<G4AttValue>* attValues) {
 
 1311     if (attValues == NULL) 
return;
 
 1314     for (vector<G4AttValue>::iterator attValIterator = attValues->begin(); attValIterator != attValues->end(); attValIterator++) {        
 
 1315         G4String name = attValIterator->GetName();
 
 1318         if ((name == 
"Pos") && (point != NULL)) {
 
 1325             for (
unsigned int i=0; i<pos.length(); i++) {
 
 1326                 if (pos[i] == 
' ') {
 
 1329                         double factor = atof(pos.substr(is, i-is).c_str())/point->
getX();
 
 1330                         im = (
int)(std::log10(factor)+((factor < 1) ? -0.5 : 0.5));
 
 1332                     } 
else if (in == 3) {
 
 1334                         unit = pos.substr(is, i-is);
 
 1337                         } 
else if (unit == 
G4String(
"mm")) {
 
 1339                         } 
else if (unit == 
G4String(
"cm")) {
 
 1341                         } 
else if (unit == 
G4String(
"m")) {
 
 1343                         } 
else if (unit == 
G4String(
"km")) {
 
 1346                             cerr << 
"HepRepSceneHandler: Unrecognized Unit: '" << unit << 
"'" << endl;
 
 1370                     cerr << 
"HepRepSceneHandler: No valid unit found for im: " << im << endl;
 
 1375             setAttribute(attribute, 
G4String(
"PointUnit"), unit);
 
 1380         if (name == 
"NTP") 
continue;
 
 1383         const map<G4String,G4AttDef>::const_iterator attDefIterator = attDefs->find(name);
 
 1384         G4String type = attDefIterator->second.GetValueType();
 
 1387         if ((type == 
"G4double") || (type == 
"double")) {   
 
 1388             setAttribute(attribute, attValIterator->GetName(), atof(attValIterator->GetValue()));           
 
 1389         } 
else if ((type == 
"G4int") || (type == 
"int")) {  
 
 1390             setAttribute(attribute, attValIterator->GetName(), atoi(attValIterator->GetValue()));           
 
 1392             setAttribute(attribute, attValIterator->GetName(), attValIterator->GetValue());
 
 1398 bool G4HepRepSceneHandler::isEventData () {
 
 1404 void G4HepRepSceneHandler::addTopLevelAttributes(
HepRepType* type) {
 
 1407     type->
addAttDef(  
"Generator", 
"Generator of the file", 
"General", 
"");
 
 1410     type->
addAttDef(  
"GeneratorVersion", 
"Version of the Generator", 
"General", 
"");
 
 1412     versionString = versionString.substr(1,versionString.size()-2);
 
 1413     versionString = 
" Geant4 version " + versionString + 
"   " + 
G4Date;
 
 1414     type->
addAttValue(
"GeneratorVersion", versionString);
 
 1418     type->
addAttDef(  
"ViewTheta", 
"Theta of initial suggested viewpoint", 
"Draw", 
"rad");
 
 1421     type->
addAttDef(  
"ViewPhi", 
"Phi of initial suggested viewpoint", 
"Draw", 
"rad");
 
 1424     type->
addAttDef(  
"ViewScale", 
"Scale of initial suggested viewpoint", 
"Draw", 
"");
 
 1428     type->
addAttDef(  
"ViewTranslateX", 
"Translate in X of initial suggested viewpoint", 
"Draw", 
"");
 
 1431     type->
addAttDef(  
"ViewTranslateY", 
"Translate in Y of initial suggested viewpoint", 
"Draw", 
"");
 
 1434     type->
addAttDef(  
"ViewTranslateZ", 
"Translate in Z of initial suggested viewpoint", 
"Draw", 
"");
 
 1437     type->
addAttDef(  
"PointUnit", 
"Length", 
"Physics", 
"");
 
 1442     type->
addAttDef(  
"UseSolids", 
"Use HepRep Solids rather than Geant4 Primitives", 
"Draw", 
"");
 
 1445     type->
addAttDef(  
"WriteInvisibles", 
"Write Invisible Objects", 
"Draw", 
"");
 
 1451     if (isEventData()) {
 
 1460       return getGeometryInstance(pCurrentLV, pCurrentMaterial, currentDepth);
 
 1464 HepRep* G4HepRepSceneHandler::getHepRep() {
 
 1465     if (_heprep == NULL) {
 
 1472 HepRep* G4HepRepSceneHandler::getHepRepGeometry() {
 
 1473     if (_heprepGeometry == NULL) {
 
 1477     return _heprepGeometry;
 
 1481     if (_geometryInstanceTree == NULL) {
 
 1492     return _geometryInstanceTree;
 
 1495 HepRepInstance* G4HepRepSceneHandler::getGeometryRootInstance() {
 
 1496     if (_geometryRootInstance == NULL) {
 
 1498         _geometryRootInstance = factory->
createHepRepInstance(getGeometryInstanceTree(), getGeometryRootType());
 
 1500     return _geometryRootInstance;
 
 1506     setAttribute(instance, 
"LVol",       volume->
GetName());
 
 1509     setAttribute(instance, 
"Region",     regionName);
 
 1510     setAttribute(instance, 
"RootRegion", volume->
IsRootRegion());
 
 1514     setAttribute(instance, 
"Material",   matName );
 
 1516     setAttribute(instance, 
"Density",    matDensity);
 
 1518     setAttribute(instance, 
"Radlen",     matRadlen);
 
 1521     G4String state = materialState[matState];
 
 1522     setAttribute(instance, 
"State", state);
 
 1531     while ((
int)_geometryInstance.size() > depth) {
 
 1532         _geometryInstance.pop_back();
 
 1536     HepRepInstance* parent = (_geometryInstance.empty()) ? getGeometryRootInstance() : _geometryInstance.back();
 
 1539     HepRepType* type = getGeometryType(volumeName, depth);
 
 1543     _geometryInstance.push_back(instance);
 
 1549     if (_geometryTypeTree == NULL) {
 
 1558             getHepRepGeometry()->
addTypeTree(_geometryTypeTree);
 
 1561     return _geometryTypeTree;
 
 1564 HepRepType* G4HepRepSceneHandler::getGeometryRootType() {
 
 1565     if (_geometryRootType == NULL) {
 
 1567         _geometryRootType = factory->
createHepRepType(getGeometryTypeTree(), rootVolumeName);
 
 1568         _geometryRootType->
addAttValue(
"Layer", geometryLayer);
 
 1571         _geometryRootType->
addAttDef  (
"LVol", 
"Logical Volume", 
"Physics",
"");
 
 1573         _geometryRootType->
addAttDef  (
"Region", 
"Cuts Region", 
"Physics",
"");
 
 1575         _geometryRootType->
addAttDef  (
"RootRegion", 
"Root Region", 
"Physics",
"");
 
 1576         _geometryRootType->
addAttValue(
"RootRegion", 
false);
 
 1577         _geometryRootType->
addAttDef  (
"Solid", 
"Solid Name", 
"Physics",
"");
 
 1579         _geometryRootType->
addAttDef  (
"EType", 
"Entity Type", 
"Physics",
"");
 
 1581         _geometryRootType->
addAttDef  (
"Material", 
"Material Name", 
"Physics",
"");
 
 1583         _geometryRootType->
addAttDef  (
"Density", 
"Material Density", 
"Physics",
"");
 
 1585         _geometryRootType->
addAttDef  (
"State", 
"Material State", 
"Physics",
"");
 
 1587         _geometryRootType->
addAttDef  (
"Radlen", 
"Material Radiation Length", 
"Physics",
"");
 
 1591         _geometryRootType->
addAttValue(
"Color", 0.8, 0.8, 0.8, 1.0);
 
 1592         _geometryRootType->
addAttValue(
"Visibility", 
true);
 
 1593         _geometryRootType->
addAttValue(
"FillColor", 0.8, 0.8, 0.8, 1.0);
 
 1596         _geometryRootType->
addAttValue(
"PickParent", 
false);
 
 1597         _geometryRootType->
addAttValue(
"ShowParentAttributes", 
true);
 
 1599         _geometryRootType->
addAttValue(
"MarkSizeMultiplier", 4.0);
 
 1600         _geometryRootType->
addAttValue(
"LineWidthMultiplier", 1.0);
 
 1602         addTopLevelAttributes(_geometryRootType);       
 
 1604         _geometryType[
"/"+_geometryRootType->
getName()] = _geometryRootType;
 
 1606     return _geometryRootType;
 
 1611     getGeometryRootType();   
 
 1614     G4String name = getFullTypeName(volumeName, depth);
 
 1619         G4String parentName = getParentTypeName(depth);
 
 1620         HepRepType* parentType = _geometryType[parentName];
 
 1623         _geometryType[
name] = type;
 
 1628 G4String G4HepRepSceneHandler::getFullTypeName(
G4String volumeName, 
int depth) {
 
 1630     if (depth > (
int)_geometryTypeName.size()) {
 
 1632         G4String problem = 
"HierarchyProblem";
 
 1633         if (_geometryType[
"/"+problem] == NULL) {
 
 1636             _geometryType[
"/"+problem] = type;
 
 1638         return "/" + problem + 
"/" + volumeName;
 
 1642     while ((
int)_geometryTypeName.size() > depth) {
 
 1643         _geometryTypeName.pop_back();
 
 1647     G4String name = (_geometryTypeName.empty()) ? 
G4String(
"/"+rootVolumeName) : _geometryTypeName.back();
 
 1648     name = name + 
"/" + volumeName;
 
 1649     _geometryTypeName.push_back(name);
 
 1653 G4String G4HepRepSceneHandler::getParentTypeName(
int depth) {
 
 1654     return (depth >= 1) ? _geometryTypeName[depth-1] : 
G4String(
"/"+rootVolumeName);
 
 1658     if (_eventInstanceTree == NULL) {
 
 1663     return _eventInstanceTree;
 
 1667     if (_eventInstance == NULL) {
 
 1671     return _eventInstance;
 
 1675     if (_eventTypeTree == NULL) {
 
 1682     return _eventTypeTree;
 
 1685 HepRepType* G4HepRepSceneHandler::getEventType() {
 
 1686     if (_eventType == NULL) {
 
 1693         _eventType->
addAttValue(
"Color", 1.0, 1.0, 1.0, 1.0);
 
 1694         _eventType->
addAttValue(
"FillColor", 1.0, 1.0, 1.0, 1.0);
 
 1698         _eventType->
addAttValue(
"ShowParentAttributes", 
false);
 
 1700         _eventType->
addAttValue(
"MarkSizeMultiplier", 4.0);
 
 1701         _eventType->
addAttValue(
"LineWidthMultiplier", 1.0);
 
 1703         addTopLevelAttributes(_eventType);
 
 1709 HepRepType* G4HepRepSceneHandler::getTrajectoryType() {
 
 1710     if (_trajectoryType == NULL) {
 
 1713         _trajectoryType->
addAttValue(
"Layer", trajectoryLayer);
 
 1716         _trajectoryType->
addAttValue(
"LineWidthMultiplier", 2.0);
 
 1724     return _trajectoryType;
 
 1727 HepRepType* G4HepRepSceneHandler::getHitType() {
 
 1728     if (_hitType == NULL) {
 
 1740 HepRepType* G4HepRepSceneHandler::getCalHitType() {
 
 1741     if (_calHitType == NULL) {
 
 1750 HepRepType* G4HepRepSceneHandler::getCalHitFaceType() {
 
 1751     if (_calHitFaceType == NULL) {
 
 1752         _calHitFaceType = factory->
createHepRepType(getCalHitType(), 
"CalHitFace");
 
 1755     return _calHitFaceType;
 
void removeSceneHandler()
 
G4double GetZoomFactor() const 
 
virtual bool write(HepRep *heprep, std::string name)=0
 
G4double GetXHalfLength() const 
 
void AddSolid(const G4Box &box)
 
virtual void AddSolid(const G4Box &)
 
virtual HepRepWriter * createHepRepWriter(std::ostream *out, bool randomAccess, bool compress)=0
 
G4double GetAlpha() const 
 
MarkerType GetMarkerType() const 
 
virtual G4bool writeInvisibles()
 
G4double GetYHalfLength1() const 
 
virtual void BeginModeling()
 
virtual void BeginPrimitives(const G4Transform3D &objectTransformation)
 
void BeginPrimitives(const G4Transform3D &objectTransformation)
 
G4bool GetNextNormal(G4Normal3D &normal) const 
 
bool closeHepRep(bool final=false)
 
virtual void addTypeTree(HepRepTypeTree *typeTree)=0
 
G4double GetLineWidth() const 
 
const XML_Char const XML_Char ** atts
 
void openFile(G4String name)
 
void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &visAttribs)
 
virtual bool addProperty(std::string key, std::string value)=0
 
const G4String & GetName() const 
 
virtual HepRepTreeID * createHepRepTreeID(std::string name, std::string version, std::string qualifier="top-level")=0
 
G4VViewer * GetCurrentViewer() const 
 
G4Material * GetCurrentMaterial() const 
 
virtual void PostAddSolid()
 
virtual HepRepInstance * getInstance()=0
 
const G4ViewParameters & GetViewParameters() const 
 
G4double GetDensity() const 
 
virtual std::string getString()=0
 
G4VSolid * GetSolid() const 
 
const G4String & GetName() const 
 
HepGeom::Point3D< G4double > G4Point3D
 
G4double GetOuterRadiusMinusZ() const 
 
G4Point3D GetPosition() const 
 
const G4VisAttributes * GetVisAttributes() const 
 
virtual std::vector< double > getColor()=0
 
G4Region * GetRegion() const 
 
virtual G4GeometryType GetEntityType() const =0
 
virtual void addAttDef(std::string name, std::string desc, std::string category, std::string extra)=0
 
G4double GetZHalfLength() const 
 
G4int GetCurrentDepth() const 
 
virtual void AddPrimitive(const G4Polyline &)=0
 
G4double GetZHalfLength() const 
 
LineStyle GetLineStyle() const 
 
static constexpr double twopi
 
virtual G4String getEventNumberSuffix()
 
virtual void addInstanceTree(HepRepTreeID *instanceTree)=0
 
virtual double getDouble()=0
 
virtual HepRepAttValue * getAttValueFromNode(std::string lowerCaseName)=0
 
virtual HepRepInstance * createHepRepInstance(HepRepInstance *parent, HepRepType *type)=0
 
virtual HepRepPoint * createHepRepPoint(HepRepInstance *instance, double x, double y, double z)=0
 
G4double GetXHalfLength2() const 
 
virtual HepRep * createHepRep()=0
 
virtual int getInteger()=0
 
virtual HepRepType * getType()=0
 
const G4Vector3D & GetViewpointDirection() const 
 
G4double GetDeltaPhiAngle() const 
 
const XML_Char int const XML_Char * value
 
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const 
 
virtual std::string getName()=0
 
G4double GetGreen() const 
 
G4bool IsRootRegion() const 
 
static const G4String G4Version
 
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
 
G4double GetMarkerRadius(const G4VMarker &, MarkerSizeType &)
 
virtual void EndModeling()
 
static G4HepRepMessenger * GetInstance()
 
G4VGraphicsSystem * GetGraphicsSystem() const 
 
virtual void EndPrimitives()
 
G4double GetYHalfLength() const 
 
virtual void addAttValue(HepRepAttValue *attValue)=0
 
G4double GetYHalfLength2() const 
 
static const G4String G4Date
 
G4double GetInnerRadiusPlusZ() const 
 
G4double GetInnerRadius() const 
 
virtual G4bool appendGeometry()
 
G4double GetRadlen() const 
 
virtual ~G4HepRepSceneHandler()
 
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
 
virtual HepRepType * createHepRepType(HepRepTypeTree *parent, std::string name)=0
 
virtual bool getBoolean()=0
 
const G4Colour & GetColor()
 
const G4VisAttributes * fpVisAttribs
 
G4Scene * GetScene() const 
 
virtual void AddCompound(const G4VTrajectory &)
 
virtual std::vector< G4AttValue > * CreateAttValues() const 
 
virtual HepRepAttValue * getAttValue(std::string name)=0
 
virtual HepRepTypeTree * createHepRepTypeTree(HepRepTreeID *treeID)=0
 
virtual HepRepInstanceTree * createHepRepInstanceTree(std::string name, std::string version, HepRepTreeID *typeTree)=0
 
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const 
 
virtual void addLayer(std::string layer)=0
 
void AddCompound(const G4VTrajectory &)
 
G4HepRepSceneHandler(G4VGraphicsSystem &system, const G4String &name="")
 
G4double GetZHalfLength() const 
 
virtual void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &)
 
virtual std::vector< G4AttValue > * CreateAttValues() const 
 
FillStyle GetFillStyle() const 
 
G4double GetXHalfLength1() const 
 
void AddPrimitive(const G4Polyline &)
 
static MCTruthManager * instance
 
G4bool fReadyForTransients
 
const G4String & GetName() const 
 
G4double GetInnerRadiusMinusZ() const 
 
G4bool GetNextVertex(G4Point3D &vertex, G4int &edgeFlag) const 
 
G4LogicalVolume * GetCurrentLV() const 
 
G4int GetNoFacets() const 
 
static const G4double alpha
 
virtual void addInstanceTree(HepRepInstanceTree *instanceTree)=0
 
G4double GetOuterRadiusPlusZ() const 
 
G4double GetZHalfLength() const 
 
virtual G4bool useSolids()
 
static const G4double pos
 
G4double GetOuterRadius() const 
 
virtual void DrawView()=0
 
G4double GetDeltaPhiAngle() const