86G4int G4HepRepSceneHandler::sceneIdCount = 0;
95 geometryLayer (
"Geometry"),
97 calHitLayer (
"CalHit"),
98 trajectoryLayer (
"Trajectory"),
100 rootVolumeName (
"Geometry"),
102 eventNumberPrefix (
""),
103 eventNumberSuffix (
""),
105 eventNumberWidth (-1),
110 writeMultipleFiles (false),
114 _heprepGeometry (NULL)
118 cout <<
"G4HepRepSceneHandler::G4HepRepSceneHandler: " << system << endl;
136 cout <<
"G4HepRepSceneHandler::~G4HepRepSceneHandler() " << endl;
148void G4HepRepSceneHandler::open(
G4String name) {
149 if (writer != NULL)
return;
151 if (name ==
"stdout") {
153 cout <<
"G4HepRepSceneHandler::Open() stdout" << endl;
158 eventNumberPrefix =
"";
159 eventNumberSuffix =
"";
164 writeMultipleFiles =
false;
166 eventNumberWidth = 0;
167 }
else if (name ==
"stderr") {
169 cout <<
"G4HepRepSceneHandler::Open() stderr" << endl;
174 eventNumberPrefix =
"";
175 eventNumberSuffix =
"";
180 writeMultipleFiles =
false;
182 eventNumberWidth = 0;
185 cout <<
"G4HepRepSceneHandler::Open() " <<
name << endl;
187 if (eventNumberWidth < 0) {
190 const unsigned int numberOfExtensions = 8;
191 string ext[numberOfExtensions] = {
".heprep",
".heprep.xml",
".heprep.zip",
".heprep.gz",
192 ".bheprep",
".bheprep.xml",
".bheprep.zip",
".bheprep.gz"};
194 while (i < numberOfExtensions) {
195 int dot =
name.size() - ext[i].size();
197 (
name.substr(dot, ext[i].size()) == ext[i]))
break;
201 if (i != numberOfExtensions) {
203 writeBinary = i >= (numberOfExtensions/2);
204 writeZip = (i == 2) || (i == 6);
205 writeGZ = (i == 3) || (i == 7);
207 int dot =
name.length() - extension.length();
208 baseName = (dot >= 0) ?
name.substr(0, dot) :
"";
212 extension =
".heprep.zip";
219 writeMultipleFiles =
false;
220 int startDigit = -1;
int endDigit = -1;
227 endDigit = suffix.length()-1;
228 while (endDigit >= 0) {
229 if (isdigit(suffix.at(endDigit)))
break;
233 cerr <<
"/vis/heprep/appendEventNumberSuffix contains no digits" << endl;
235 writeMultipleFiles =
true;
236 startDigit = endDigit;
237 while (startDigit >= 0) {
238 if (!isdigit(suffix.at(startDigit)))
break;
245 if (writeMultipleFiles) {
246 eventNumberPrefix = suffix.substr(0, startDigit);
247 eventNumber = atoi(suffix.substr(startDigit, endDigit).c_str());
248 eventNumberWidth = endDigit +1 - startDigit;
249 eventNumberSuffix = suffix.substr(endDigit+1);
255 eventNumberWidth = 10;
256 eventNumberPrefix =
"";
257 eventNumberSuffix =
"";
266 cout <<
"G4HepRepSceneHandler::OpenHepRep() " << endl;
269 if (_heprep != NULL)
return;
272 _heprepGeometry = NULL;
273 _geometryInstanceTree = NULL;
274 _geometryRootInstance = NULL;
275 _geometryInstance.clear();
276 _geometryTypeTree = NULL;
277 _geometryRootType = NULL;
278 _geometryTypeName.clear();
279 _geometryType.clear();
280 _eventInstanceTree = NULL;
281 _eventInstance = NULL;
282 _eventTypeTree = NULL;
284 _trajectoryType = NULL;
287 _calHitFaceType = NULL;
295 if (_heprep == NULL)
return true;
298 cout <<
"G4HepRepSceneHandler::CloseHepRep() start" << endl;
303 if (_eventInstanceTree != NULL) {
304 cerr <<
"WARNING: you probably used '/vis/viewer/endOfEventAction accumulate' and "
305 <<
"forgot to call /vis/viewer/update before exit. No event written." << endl;
313 if (_eventInstanceTree != NULL) {
320 if ((_geometryInstanceTree != NULL)) {
325 if (writeMultipleFiles) {
326 sprintf(name,
"%s%s%s#%s", baseName.c_str(),
"-geometry", extension.c_str(),
"G4GeometryData");
328 sprintf(name,
"%s%s#%s",
"geometry", (writeBinary ?
".bheprep" :
".heprep"),
"G4GeometryData");
335 if (_eventInstanceTree != NULL) {
345 writeLayers(_heprepGeometry);
346 writeLayers(_heprep);
349 if (writer == NULL) {
355 if (writeMultipleFiles) {
357 sprintf(fileName,
"%s%s%s", baseName.c_str(),
"-geometry", extension.c_str());
362 sprintf(name,
"%s%s",
"geometry", (writeBinary ?
".bheprep" :
".heprep"));
363 if (!writeMultipleFiles) {
369 delete _heprepGeometry;
370 _heprepGeometry = NULL;
375 if (writeMultipleFiles) {
382 char fileFormat[128];
383 sprintf(fileFormat,
"%s%d%s",
"%s%s%0", eventNumberWidth,
"d%s%s");
384 sprintf(fileName, fileFormat, baseName.c_str(), eventNumberPrefix.c_str(), eventNumber, eventNumberSuffix.c_str(), extension.c_str());
395 char eventFormat[128];
396 sprintf(eventFormat,
"%s%d%s%s",
"event-%0", eventNumberWidth,
"d", (writeBinary ?
".bheprep" :
".heprep"));
397 sprintf(eventName, eventFormat, eventNumber);
412void G4HepRepSceneHandler::close() {
415 cout <<
"G4HepRepSceneHandler::Close() " << endl;
418 if (writer == NULL)
return;
420 if (!writeMultipleFiles) {
430 out =
new ofstream(name.c_str(), std::ios::out | std::ios::binary );
443void G4HepRepSceneHandler::writeLayers(
HepRep* heprep) {
444 if (heprep == NULL)
return;
454 cout <<
"G4HepRepSceneHandler::BeginModeling() " << endl;
462 cout <<
"G4HepRepSceneHandler::EndModeling() " << endl;
469 cout <<
"G4HepRepSceneHandler::AddSolid(const G4Box& box)" << endl;
472 if (dontWrite())
return;
494 vertex1 = (transform) * vertex1;
495 vertex2 = (transform) * vertex2;
496 vertex3 = (transform) * vertex3;
497 vertex4 = (transform) * vertex4;
498 vertex5 = (transform) * vertex5;
499 vertex6 = (transform) * vertex6;
500 vertex7 = (transform) * vertex7;
501 vertex8 = (transform) * vertex8;
503 HepRepInstance* instance = getGeometryOrEventInstance(getCalHitType());
504 addAttributes(instance, getCalHitType());
506 setAttribute(instance,
"DrawAs",
G4String(
"Prism"));
508 setVisibility(instance, box);
509 setLine(instance, box);
510 setColor(instance, getColorFor(box));
525 cout <<
"G4HepRepSceneHandler::AddSolid(const G4Cons& cons)" << endl;
528 if (dontWrite())
return;
551 vertex1 = (transform) * vertex1;
552 vertex2 = (transform) * vertex2;
554 HepRepInstance* instance = getGeometryInstance(pCurrentLV, pCurrentMaterial, currentDepth);
555 setAttribute(instance,
"DrawAs",
G4String(
"Cylinder"));
557 setVisibility(instance, cons);
558 setLine(instance, cons);
559 setColor(instance, getColorFor(cons));
589 cout <<
"G4HepRepSceneHandler::AddSolid(const G4Tubs& tubs)" << endl;
592 if (dontWrite())
return;
615 vertex1 = (transform) * vertex1;
616 vertex2 = (transform) * vertex2;
618 HepRepInstance* instance = getGeometryInstance(pCurrentLV, pCurrentMaterial, currentDepth);
619 setAttribute(instance,
"DrawAs",
G4String(
"Cylinder"));
621 setVisibility(instance, tubs);
622 setLine(instance, tubs);
623 setColor(instance, getColorFor(tubs));
649 cout <<
"G4HepRepSceneHandler::AddSolid(const G4Trd& trd)" << endl;
651 if (dontWrite())
return;
675 vertex1 = (transform) * vertex1;
676 vertex2 = (transform) * vertex2;
677 vertex3 = (transform) * vertex3;
678 vertex4 = (transform) * vertex4;
679 vertex5 = (transform) * vertex5;
680 vertex6 = (transform) * vertex6;
681 vertex7 = (transform) * vertex7;
682 vertex8 = (transform) * vertex8;
684 HepRepInstance* instance = getGeometryOrEventInstance(getCalHitType());
686 addAttributes(instance, getCalHitType());
688 setAttribute(instance,
"DrawAs",
G4String(
"Prism"));
690 setVisibility(instance, trd);
691 setLine(instance, trd);
692 setColor(instance, getColorFor(trd));
705 if (dontWrite())
return;
710 if (dontWrite())
return;
715 if (dontWrite())
return;
720 if (dontWrite())
return;
725 if (dontWrite())
return;
730 if (dontWrite())
return;
735 if (dontWrite())
return;
740 if (dontWrite())
return;
745 if (dontWrite())
return;
750 if (dontWrite())
return;
758 cout <<
"G4HepRepSceneHandler::AddPrimitive(G4Polyline&) " << line.size() << endl;
760 if (dontWrite())
return;
763 static G4bool warned =
false;
767 (
"G4HepRepSceneHandler::AddPrimitive (const G4Polyline&)",
769 "2D polylines not implemented. Ignored.");
776 addAttributes(instance, getTrajectoryType());
781 setVisibility(instance, line);
783 setLine(instance, line);
785 for (
size_t i=0; i < line.size(); i++) {
795 cout <<
"G4HepRepSceneHandler::AddPrimitive(G4Polymarker&) " << line.size() << endl;
797 if (dontWrite())
return;
800 static G4bool warned =
false;
804 (
"G4HepRepSceneHandler::AddPrimitive (const G4Polymarker&)",
806 "2D polymarkers not implemented. Ignored.");
813 addAttributes(instance, getHitType());
818 setVisibility(instance, line);
820 setMarker(instance, line);
826 if (mtype == line.
dots) {
827 setAttribute(instance,
"Fill",
true);
829 }
else if (mtype == line.
circles) {
830 }
else if (mtype == line.
squares) {
831 setAttribute(instance,
"MarkName",
G4String(
"Box"));
834 setAttribute(instance,
"MarkName",
G4String(
"Plus"));
837 for (
size_t i=0; i < line.size(); i++) {
846 cout <<
"G4HepRepSceneHandler::AddPrimitive(G4Circle&) " << endl;
848 if (dontWrite())
return;
851 static G4bool warned =
false;
855 (
"G4HepRepSceneHandler::AddPrimitive (const G4Circle&)",
857 "2D circles not implemented. Ignored.");
864 addAttributes(instance, getHitType());
871 setVisibility(instance, circle);
873 setMarker(instance, circle);
882 cout <<
"G4HepRepSceneHandler::AddPrimitive(G4Polyhedron&) " << endl;
884 if (dontWrite())
return;
887 static G4bool warned =
false;
891 (
"G4HepRepSceneHandler::AddPrimitive (const G4Polyhedron&)",
893 "2D polyhedra not implemented. Ignored.");
903 HepRepInstance* instance = getGeometryOrEventInstance(getCalHitType());
905 addAttributes(instance, getCalHitType());
907 setVisibility(instance, polyhedron);
909 G4int currentDepth = 0;
920 face = getGeometryInstance(
"*Face", currentDepth+1);
921 setAttribute(face,
"PickParent",
true);
922 setAttribute(face,
"DrawAs",
G4String(
"Polygon"));
925 setLine(face, polyhedron);
936 vertex = transform * vertex;
938 }
while (notLastEdge);
939 }
while (notLastFace);
945 cout <<
"G4HepRepSceneHandler::AddPrimitive(G4Text&) " << endl;
947 if (dontWrite())
return;
963 cout <<
"G4HepRepSceneHandler::AddPrimitive G4Text : not yet implemented. " << endl;
969 cout <<
"G4HepRepSceneHandler::AddPrimitive(G4Square&) " << endl;
971 if (dontWrite())
return;
974 static G4bool warned =
false;
978 (
"G4HepRepSceneHandler::AddPrimitive (const G4Square&)",
980 "2D squares not implemented. Ignored.");
987 addAttributes(instance, getHitType());
991 setColor (instance, getColorFor(square));
993 setVisibility(instance, square);
995 setMarker(instance, square);
1001 if (dontWrite())
return;
1007 cout <<
"G4HepRepSceneHandler::AddCompound(G4VTrajectory&) " << endl;
1009 if (dontWrite())
return;
1011 currentTrack = &trajectory;
1013 currentTrack = NULL;
1019 cout <<
"G4HepRepSceneHandler::AddCompound(G4VHit&) " << endl;
1021 if (dontWrite())
return;
1033 transform = objectTransformation;
1035 cout <<
"G4HepRepSceneHandler::PreAddSolid(G4Transform3D&, G4VisAttributes&)" << endl;
1042 cout <<
"G4HepRepSceneHandler::PostAddSolid()" << endl;
1050 cout <<
"G4HepRepSceneHandler::BeginPrimitives(G4Transform3D&)" << endl;
1054 transform = objectTransformation;
1060 cout <<
"G4HepRepSceneHandler::EndPrimitives" << endl;
1066G4bool G4HepRepSceneHandler::dontWrite() {
1075 cout <<
"G4HepRepSceneHandler::setColor : red : " << color.
GetRed () <<
1076 " green : " << color.
GetGreen () <<
1077 " blue : " << color.
GetBlue () << endl;
1100 setAttribute(attribute,
"Visibility", (
atts && (
atts->IsVisible()==0)) ?
false :
true);
1104 setAttribute(attribute,
"LineWidth", 1.0);
1110 setAttribute(attribute,
"LineWidth", (
atts != NULL) ?
atts->GetLineWidth() : 1.0);
1113 switch (
atts->GetLineStyle()) {
1115 setAttribute(attribute,
"LineStyle",
G4String(
"Dotted"));
1118 setAttribute(attribute,
"LineStyle",
G4String(
"Dashed"));
1131 setAttribute(attribute,
"MarkSize", size);
1133 if (markerType ==
screen) setAttribute(attribute,
"MarkType",
G4String(
"Symbol"));
1135 setAttribute(attribute,
"Fill",
false);
1145 const map<G4String,G4AttDef>* hitAttDefs = currentHit->
GetAttDefs();
1147 addAttDefs(getHitType(), hitAttDefs);
1158 addAttVals(instance, hitAttDefs, hitAttValues);
1160 delete hitAttValues;
1162 }
else if (currentTrack) {
1163 vector<G4AttValue>* trajectoryAttValues = currentTrack->
CreateAttValues();
1164 const map<G4String,G4AttDef>* trajectoryAttDefs = currentTrack->
GetAttDefs();
1166 addAttDefs(type, trajectoryAttDefs);
1178 addAttVals(instance, trajectoryAttDefs, trajectoryAttValues);
1180 delete trajectoryAttValues;
1187 if ((attValue == NULL) || (attValue->
getString() != value)) {
1189 if (point != NULL) {
1196 if (instance != NULL) {
1199 attribute = instance->
getType();
1209 if ((attValue == NULL) || (attValue->
getBoolean() != value)) {
1211 if (point != NULL) {
1218 if (instance != NULL) {
1221 attribute = instance->
getType();
1231 if ((attValue == NULL) || (attValue->
getDouble() != value)) {
1233 if (point != NULL) {
1240 if (instance != NULL) {
1243 attribute = instance->
getType();
1253 if ((attValue == NULL) || (attValue->
getInteger() != value)) {
1255 if (point != NULL) {
1262 if (instance != NULL) {
1265 attribute = instance->
getType();
1273void G4HepRepSceneHandler::setAttribute(
HepRepAttribute* attribute,
G4String name,
double red,
double green,
double blue,
double alpha) {
1275 vector<double> color;
1276 if (attValue != NULL) color = attValue->
getColor();
1277 if ((color.size() == 0) ||
1278 (color[0] != red) ||
1279 (color[1] != green) ||
1280 (color[2] != blue) ||
1281 ((color.size() > 3) && (color[3] != alpha))) {
1284 if (point != NULL) {
1291 if (instance != NULL) {
1294 attribute = instance->
getType();
1298 attribute->
addAttValue(name, red, green, blue, alpha);
1302void G4HepRepSceneHandler::addAttDefs(
HepRepDefinition* definition,
const map<G4String,G4AttDef>* attDefs) {
1303 if (attDefs == NULL)
return;
1306 map<G4String,G4AttDef>::const_iterator attDefIterator = attDefs->begin();
1307 while (attDefIterator != attDefs->end()) {
1308 definition->
addAttDef(attDefIterator->first, attDefIterator->second.GetDesc(),
1309 attDefIterator->second.GetCategory(), attDefIterator->second.GetExtra());
1314void G4HepRepSceneHandler::addAttVals(
HepRepAttribute* attribute,
const map<G4String,G4AttDef>* attDefs, vector<G4AttValue>* attValues) {
1315 if (attValues == NULL)
return;
1318 for (vector<G4AttValue>::iterator attValIterator = attValues->begin(); attValIterator != attValues->end(); attValIterator++) {
1322 if ((name ==
"Pos") && (point != NULL)) {
1329 for (
unsigned int i=0; i<
pos.length(); i++) {
1330 if (pos[i] ==
' ') {
1333 double factor = atof(
pos.substr(is, i-is).c_str())/point->
getX();
1334 im = (int)(std::log10(factor)+((factor < 1) ? -0.5 : 0.5));
1336 }
else if (in == 3) {
1338 unit =
pos.substr(is, i-is);
1341 }
else if (unit ==
G4String(
"mm")) {
1343 }
else if (unit ==
G4String(
"cm")) {
1345 }
else if (unit ==
G4String(
"m")) {
1347 }
else if (unit ==
G4String(
"km")) {
1350 cerr <<
"HepRepSceneHandler: Unrecognized Unit: '" << unit <<
"'" << endl;
1374 cerr <<
"HepRepSceneHandler: No valid unit found for im: " << im << endl;
1379 setAttribute(attribute,
G4String(
"PointUnit"), unit);
1384 if (name ==
"NTP")
continue;
1387 const map<G4String,G4AttDef>::const_iterator attDefIterator = attDefs->find(name);
1388 G4String type = attDefIterator->second.GetValueType();
1391 if ((type ==
"G4double") || (type ==
"double")) {
1392 setAttribute(attribute, attValIterator->GetName(), atof(attValIterator->GetValue()));
1393 }
else if ((type ==
"G4int") || (type ==
"int")) {
1394 setAttribute(attribute, attValIterator->GetName(), atoi(attValIterator->GetValue()));
1396 setAttribute(attribute, attValIterator->GetName(), attValIterator->GetValue());
1402bool G4HepRepSceneHandler::isEventData () {
1408void G4HepRepSceneHandler::addTopLevelAttributes(
HepRepType* type) {
1411 type->
addAttDef(
"Generator",
"Generator of the file",
"General",
"");
1414 type->
addAttDef(
"GeneratorVersion",
"Version of the Generator",
"General",
"");
1415 G4String versionString = G4Version;
1416 versionString = versionString.substr(1,versionString.size()-2);
1417 versionString =
" Geant4 version " + versionString +
" " + G4Date;
1418 type->
addAttValue(
"GeneratorVersion", versionString);
1422 type->
addAttDef(
"ViewTheta",
"Theta of initial suggested viewpoint",
"Draw",
"rad");
1425 type->
addAttDef(
"ViewPhi",
"Phi of initial suggested viewpoint",
"Draw",
"rad");
1428 type->
addAttDef(
"ViewScale",
"Scale of initial suggested viewpoint",
"Draw",
"");
1432 type->
addAttDef(
"ViewTranslateX",
"Translate in X of initial suggested viewpoint",
"Draw",
"");
1435 type->
addAttDef(
"ViewTranslateY",
"Translate in Y of initial suggested viewpoint",
"Draw",
"");
1438 type->
addAttDef(
"ViewTranslateZ",
"Translate in Z of initial suggested viewpoint",
"Draw",
"");
1441 type->
addAttDef(
"PointUnit",
"Length",
"Physics",
"");
1446 type->
addAttDef(
"UseSolids",
"Use HepRep Solids rather than Geant4 Primitives",
"Draw",
"");
1449 type->
addAttDef(
"WriteInvisibles",
"Write Invisible Objects",
"Draw",
"");
1455 if (isEventData()) {
1464 return getGeometryInstance(pCurrentLV, pCurrentMaterial, currentDepth);
1468HepRep* G4HepRepSceneHandler::getHepRep() {
1469 if (_heprep == NULL) {
1476HepRep* G4HepRepSceneHandler::getHepRepGeometry() {
1477 if (_heprepGeometry == NULL) {
1481 return _heprepGeometry;
1485 if (_geometryInstanceTree == NULL) {
1496 return _geometryInstanceTree;
1500 if (_geometryRootInstance == NULL) {
1502 _geometryRootInstance = factory->
createHepRepInstance(getGeometryInstanceTree(), getGeometryRootType());
1504 return _geometryRootInstance;
1510 setAttribute(instance,
"LVol", volume->
GetName());
1513 setAttribute(instance,
"Region", regionName);
1514 setAttribute(instance,
"RootRegion", volume->
IsRootRegion());
1518 setAttribute(instance,
"Material", matName );
1520 setAttribute(instance,
"Density", matDensity);
1522 setAttribute(instance,
"Radlen", matRadlen);
1525 G4String state = materialState[matState];
1526 setAttribute(instance,
"State", state);
1535 while ((
int)_geometryInstance.size() > depth) {
1536 _geometryInstance.pop_back();
1540 HepRepInstance* parent = (_geometryInstance.empty()) ? getGeometryRootInstance() : _geometryInstance.back();
1543 HepRepType* type = getGeometryType(volumeName, depth);
1547 _geometryInstance.push_back(instance);
1553 if (_geometryTypeTree == NULL) {
1562 getHepRepGeometry()->
addTypeTree(_geometryTypeTree);
1565 return _geometryTypeTree;
1568HepRepType* G4HepRepSceneHandler::getGeometryRootType() {
1569 if (_geometryRootType == NULL) {
1571 _geometryRootType = factory->
createHepRepType(getGeometryTypeTree(), rootVolumeName);
1572 _geometryRootType->
addAttValue(
"Layer", geometryLayer);
1575 _geometryRootType->
addAttDef (
"LVol",
"Logical Volume",
"Physics",
"");
1577 _geometryRootType->
addAttDef (
"Region",
"Cuts Region",
"Physics",
"");
1579 _geometryRootType->
addAttDef (
"RootRegion",
"Root Region",
"Physics",
"");
1580 _geometryRootType->
addAttValue(
"RootRegion",
false);
1581 _geometryRootType->
addAttDef (
"Solid",
"Solid Name",
"Physics",
"");
1583 _geometryRootType->
addAttDef (
"EType",
"Entity Type",
"Physics",
"");
1585 _geometryRootType->
addAttDef (
"Material",
"Material Name",
"Physics",
"");
1587 _geometryRootType->
addAttDef (
"Density",
"Material Density",
"Physics",
"");
1589 _geometryRootType->
addAttDef (
"State",
"Material State",
"Physics",
"");
1591 _geometryRootType->
addAttDef (
"Radlen",
"Material Radiation Length",
"Physics",
"");
1595 _geometryRootType->
addAttValue(
"Color", 0.8, 0.8, 0.8, 1.0);
1596 _geometryRootType->
addAttValue(
"Visibility",
true);
1597 _geometryRootType->
addAttValue(
"FillColor", 0.8, 0.8, 0.8, 1.0);
1600 _geometryRootType->
addAttValue(
"PickParent",
false);
1601 _geometryRootType->
addAttValue(
"ShowParentAttributes",
true);
1603 _geometryRootType->
addAttValue(
"MarkSizeMultiplier", 4.0);
1604 _geometryRootType->
addAttValue(
"LineWidthMultiplier", 1.0);
1606 addTopLevelAttributes(_geometryRootType);
1608 _geometryType[
"/"+_geometryRootType->
getName()] = _geometryRootType;
1610 return _geometryRootType;
1615 getGeometryRootType();
1623 G4String parentName = getParentTypeName(depth);
1624 HepRepType* parentType = _geometryType[parentName];
1627 _geometryType[
name] = type;
1632G4String G4HepRepSceneHandler::getFullTypeName(
G4String volumeName,
int depth) {
1634 if (depth > (
int)_geometryTypeName.size()) {
1636 G4String problem =
"HierarchyProblem";
1637 if (_geometryType[
"/"+problem] == NULL) {
1640 _geometryType[
"/"+problem] = type;
1642 return "/" + problem +
"/" + volumeName;
1646 while ((
int)_geometryTypeName.size() > depth) {
1647 _geometryTypeName.pop_back();
1651 G4String name = (_geometryTypeName.empty()) ?
G4String(
"/"+rootVolumeName) : _geometryTypeName.back();
1653 _geometryTypeName.push_back(name);
1657G4String G4HepRepSceneHandler::getParentTypeName(
int depth) {
1658 return (depth >= 1) ? _geometryTypeName[depth-1] :
G4String(
"/"+rootVolumeName);
1662 if (_eventInstanceTree == NULL) {
1667 return _eventInstanceTree;
1671 if (_eventInstance == NULL) {
1675 return _eventInstance;
1679 if (_eventTypeTree == NULL) {
1686 return _eventTypeTree;
1689HepRepType* G4HepRepSceneHandler::getEventType() {
1690 if (_eventType == NULL) {
1697 _eventType->
addAttValue(
"Color", 1.0, 1.0, 1.0, 1.0);
1698 _eventType->
addAttValue(
"FillColor", 1.0, 1.0, 1.0, 1.0);
1702 _eventType->
addAttValue(
"ShowParentAttributes",
false);
1704 _eventType->
addAttValue(
"MarkSizeMultiplier", 4.0);
1705 _eventType->
addAttValue(
"LineWidthMultiplier", 1.0);
1707 addTopLevelAttributes(_eventType);
1713HepRepType* G4HepRepSceneHandler::getTrajectoryType() {
1714 if (_trajectoryType == NULL) {
1717 _trajectoryType->
addAttValue(
"Layer", trajectoryLayer);
1720 _trajectoryType->
addAttValue(
"LineWidthMultiplier", 2.0);
1728 return _trajectoryType;
1731HepRepType* G4HepRepSceneHandler::getHitType() {
1732 if (_hitType == NULL) {
1744HepRepType* G4HepRepSceneHandler::getCalHitType() {
1745 if (_calHitType == NULL) {
1754HepRepType* G4HepRepSceneHandler::getCalHitFaceType() {
1755 if (_calHitFaceType == NULL) {
1756 _calHitFaceType = factory->
createHepRepType(getCalHitType(),
"CalHitFace");
1759 return _calHitFaceType;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
HepGeom::Point3D< G4double > G4Point3D
G4double GetYHalfLength() const
G4double GetZHalfLength() const
G4double GetXHalfLength() const
G4double GetAlpha() const
G4double GetGreen() const
G4double GetOuterRadiusPlusZ() const
G4double GetDeltaPhiAngle() const
G4double GetInnerRadiusMinusZ() const
G4double GetInnerRadiusPlusZ() const
G4double GetOuterRadiusMinusZ() const
G4double GetZHalfLength() const
virtual G4bool writeInvisibles()
virtual G4bool useSolids()
virtual G4String getEventNumberSuffix()
virtual G4bool appendGeometry()
static G4HepRepMessenger * GetInstance()
void AddCompound(const G4VTrajectory &)
void openFile(G4String name)
void BeginPrimitives(const G4Transform3D &objectTransformation)
void AddPrimitive(const G4Polyline &)
G4HepRepSceneHandler(G4VGraphicsSystem &system, const G4String &name="")
void AddSolid(const G4Box &box)
bool closeHepRep(bool final=false)
void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &visAttribs)
virtual ~G4HepRepSceneHandler()
void removeSceneHandler()
G4VSolid * GetSolid() const
G4bool IsRootRegion() const
G4Region * GetRegion() const
const G4String & GetName() const
G4double GetDensity() const
G4double GetRadlen() const
const G4String & GetName() const
G4LogicalVolume * GetCurrentLV() const
G4Material * GetCurrentMaterial() const
G4int GetCurrentDepth() const
MarkerType GetMarkerType() const
const G4String & GetName() const
G4double GetXHalfLength2() const
G4double GetYHalfLength2() const
G4double GetXHalfLength1() const
G4double GetYHalfLength1() const
G4double GetZHalfLength() const
G4double GetZHalfLength() const
G4double GetInnerRadius() const
G4double GetOuterRadius() const
G4double GetDeltaPhiAngle() const
virtual std::vector< G4AttValue > * CreateAttValues() const
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
FillStyle GetFillStyle() const
G4Point3D GetPosition() const
virtual void BeginModeling()
G4VGraphicsSystem * GetGraphicsSystem() const
G4double GetMarkerRadius(const G4VMarker &, MarkerSizeType &)
G4Scene * GetScene() const
virtual void EndPrimitives()
G4VViewer * GetCurrentViewer() const
virtual void EndModeling()
virtual void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &)
virtual void PostAddSolid()
const G4String & GetName() const
const G4VisAttributes * fpVisAttribs
const G4Colour & GetColor()
G4bool fReadyForTransients
virtual void BeginPrimitives(const G4Transform3D &objectTransformation=G4Transform3D())
virtual void AddSolid(const G4Box &)
virtual void AddCompound(const G4VTrajectory &)
virtual void AddPrimitive(const G4Polyline &)=0
virtual G4GeometryType GetEntityType() const =0
virtual std::vector< G4AttValue > * CreateAttValues() const
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
virtual void DrawView()=0
const G4ViewParameters & GetViewParameters() const
const G4Vector3D & GetViewpointDirection() const
G4double GetZoomFactor() const
const G4VisAttributes * GetVisAttributes() const
virtual std::vector< double > getColor()=0
virtual bool getBoolean()=0
virtual std::string getString()=0
virtual double getDouble()=0
virtual int getInteger()=0
virtual HepRepAttValue * getAttValue(std::string name)=0
virtual HepRepAttValue * getAttValueFromNode(std::string lowerCaseName)=0
virtual void addAttValue(HepRepAttValue *attValue)=0
virtual void addAttDef(std::string name, std::string desc, std::string category, std::string extra)=0
virtual HepRepInstanceTree * createHepRepInstanceTree(std::string name, std::string version, HepRepTreeID *typeTree)=0
virtual HepRepTypeTree * createHepRepTypeTree(HepRepTreeID *treeID)=0
virtual HepRepInstance * createHepRepInstance(HepRepInstance *parent, HepRepType *type)=0
virtual HepRepWriter * createHepRepWriter(std::ostream *out, bool randomAccess, bool compress)=0
virtual HepRepPoint * createHepRepPoint(HepRepInstance *instance, double x, double y, double z)=0
virtual HepRepType * createHepRepType(HepRepTypeTree *parent, std::string name)=0
virtual HepRep * createHepRep()=0
virtual HepRepTreeID * createHepRepTreeID(std::string name, std::string version, std::string qualifier="top-level")=0
virtual void addInstanceTree(HepRepTreeID *instanceTree)=0
virtual HepRepType * getType()=0
virtual HepRepInstance * getInstance()=0
virtual std::string getName()=0
virtual bool addProperty(std::string key, std::string value)=0
virtual bool write(HepRep *heprep, std::string name)=0
virtual void addInstanceTree(HepRepInstanceTree *instanceTree)=0
virtual void addTypeTree(HepRepTypeTree *typeTree)=0
virtual void addLayer(std::string layer)=0
G4bool GetNextNormal(G4Normal3D &normal) const
G4bool GetNextVertex(G4Point3D &vertex, G4int &edgeFlag) const
G4int GetNoFacets() const
const char * name(G4int ptype)