Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4HepRepSceneHandler Class Reference

#include <G4HepRepSceneHandler.hh>

+ Inheritance diagram for G4HepRepSceneHandler:

Public Member Functions

 G4HepRepSceneHandler (G4VGraphicsSystem &system, const G4String &name="")
 
virtual ~G4HepRepSceneHandler ()
 
void AddSolid (const G4Box &box)
 
void AddSolid (const G4Cons &cons)
 
void AddSolid (const G4Tubs &tubs)
 
void AddSolid (const G4Trd &trd)
 
void AddSolid (const G4Trap &trap)
 
void AddSolid (const G4Sphere &sphere)
 
void AddSolid (const G4Para &para)
 
void AddSolid (const G4Torus &torus)
 
void AddSolid (const G4Polycone &polycone)
 
void AddSolid (const G4Polyhedra &polyhedra)
 
void AddSolid (const G4VSolid &solid)
 
void AddCompound (const G4VTrajectory &)
 
void AddCompound (const G4VHit &hit)
 
void AddCompound (const G4VDigi &digi)
 
void AddCompound (const G4THitsMap< G4double > &hits)
 
void PreAddSolid (const G4Transform3D &objectTransformation, const G4VisAttributes &visAttribs)
 
void PostAddSolid ()
 
void AddPrimitive (const G4Polyline &)
 
void AddPrimitive (const G4Text &)
 
void AddPrimitive (const G4Circle &)
 
void AddPrimitive (const G4Square &)
 
void AddPrimitive (const G4Polyhedron &)
 
void AddPrimitive (const G4NURBS &)
 
void AddPrimitive (const G4Polymarker &)
 
void AddPrimitive (const G4Scale &scale)
 
void BeginPrimitives (const G4Transform3D &objectTransformation)
 
void EndPrimitives ()
 
void BeginModeling ()
 
void EndModeling ()
 
void openHepRep ()
 
bool closeHepRep (bool final=false)
 
void openFile (G4String name)
 
void closeFile ()
 
- Public Member Functions inherited from G4VSceneHandler
 G4VSceneHandler (G4VGraphicsSystem &system, G4int id, const G4String &name="")
 
virtual ~G4VSceneHandler ()
 
virtual void PreAddSolid (const G4Transform3D &objectTransformation, const G4VisAttributes &)
 
virtual void PostAddSolid ()
 
virtual void AddSolid (const G4Box &)
 
virtual void AddSolid (const G4Cons &)
 
virtual void AddSolid (const G4Tubs &)
 
virtual void AddSolid (const G4Trd &)
 
virtual void AddSolid (const G4Trap &)
 
virtual void AddSolid (const G4Sphere &)
 
virtual void AddSolid (const G4Para &)
 
virtual void AddSolid (const G4Torus &)
 
virtual void AddSolid (const G4Polycone &)
 
virtual void AddSolid (const G4Polyhedra &)
 
virtual void AddSolid (const G4VSolid &)
 
virtual void AddCompound (const G4VTrajectory &)
 
virtual void AddCompound (const G4VHit &)
 
virtual void AddCompound (const G4VDigi &)
 
virtual void AddCompound (const G4THitsMap< G4double > &)
 
virtual void BeginModeling ()
 
virtual void EndModeling ()
 
virtual void BeginPrimitives (const G4Transform3D &objectTransformation)
 
virtual void EndPrimitives ()
 
virtual void BeginPrimitives2D (const G4Transform3D &objectTransformation)
 
virtual void EndPrimitives2D ()
 
virtual void AddPrimitive (const G4Polyline &)=0
 
virtual void AddPrimitive (const G4Scale &)
 
virtual void AddPrimitive (const G4Text &)=0
 
virtual void AddPrimitive (const G4Circle &)=0
 
virtual void AddPrimitive (const G4Square &)=0
 
virtual void AddPrimitive (const G4Polymarker &)
 
virtual void AddPrimitive (const G4Polyhedron &)=0
 
virtual void AddPrimitive (const G4NURBS &)=0
 
const G4StringGetName () const
 
G4int GetSceneHandlerId () const
 
G4int GetViewCount () const
 
G4VGraphicsSystemGetGraphicsSystem () const
 
G4SceneGetScene () const
 
const G4ViewerListGetViewerList () const
 
G4VModelGetModel () const
 
G4VViewerGetCurrentViewer () const
 
G4bool GetMarkForClearingTransientStore () const
 
G4bool IsReadyForTransients () const
 
G4bool GetTransientsDrawnThisEvent () const
 
G4bool GetTransientsDrawnThisRun () const
 
const G4Transform3DGetObjectTransformation () const
 
void SetName (const G4String &)
 
void SetCurrentViewer (G4VViewer *)
 
virtual void SetScene (G4Scene *)
 
G4ViewerListSetViewerList ()
 
void SetModel (G4VModel *)
 
void SetMarkForClearingTransientStore (G4bool)
 
void SetTransientsDrawnThisEvent (G4bool)
 
void SetTransientsDrawnThisRun (G4bool)
 
void SetObjectTransformation (const G4Transform3D &)
 
const G4ColourGetColour (const G4Visible &)
 
const G4ColourGetColor (const G4Visible &)
 
const G4ColourGetTextColour (const G4Text &)
 
const G4ColourGetTextColor (const G4Text &)
 
G4double GetLineWidth (const G4VisAttributes *)
 
G4ViewParameters::DrawingStyle GetDrawingStyle (const G4VisAttributes *)
 
G4bool GetAuxEdgeVisible (const G4VisAttributes *)
 
G4int GetNoOfSides (const G4VisAttributes *)
 
G4double GetMarkerSize (const G4VMarker &, MarkerSizeType &)
 
G4double GetMarkerDiameter (const G4VMarker &, MarkerSizeType &)
 
G4double GetMarkerRadius (const G4VMarker &, MarkerSizeType &)
 
G4ModelingParametersCreateModelingParameters ()
 
void DrawEvent (const G4Event *)
 
void DrawEndOfRunModels ()
 
G4int IncrementViewCount ()
 
virtual void ClearStore ()
 
virtual void ClearTransientStore ()
 
void AddViewerToList (G4VViewer *pView)
 
void RemoveViewerFromList (G4VViewer *pView)
 
- Public Member Functions inherited from G4VGraphicsScene
 G4VGraphicsScene ()
 
virtual ~G4VGraphicsScene ()
 
virtual void PreAddSolid (const G4Transform3D &objectTransformation, const G4VisAttributes &visAttribs)=0
 
virtual void PostAddSolid ()=0
 
virtual void AddSolid (const G4Box &)=0
 
virtual void AddSolid (const G4Cons &)=0
 
virtual void AddSolid (const G4Tubs &)=0
 
virtual void AddSolid (const G4Trd &)=0
 
virtual void AddSolid (const G4Trap &)=0
 
virtual void AddSolid (const G4Sphere &)=0
 
virtual void AddSolid (const G4Para &)=0
 
virtual void AddSolid (const G4Torus &)=0
 
virtual void AddSolid (const G4Polycone &)=0
 
virtual void AddSolid (const G4Polyhedra &)=0
 
virtual void AddSolid (const G4VSolid &)=0
 
virtual void AddCompound (const G4VTrajectory &)=0
 
virtual void AddCompound (const G4VHit &)=0
 
virtual void AddCompound (const G4VDigi &)=0
 
virtual void AddCompound (const G4THitsMap< G4double > &)=0
 
virtual void BeginPrimitives (const G4Transform3D &objectTransformation=G4Transform3D())=0
 
virtual void EndPrimitives ()=0
 
virtual void BeginPrimitives2D (const G4Transform3D &objectTransformation=G4Transform3D())=0
 
virtual void EndPrimitives2D ()=0
 
virtual void AddPrimitive (const G4Polyline &)=0
 
virtual void AddPrimitive (const G4Scale &)=0
 
virtual void AddPrimitive (const G4Text &)=0
 
virtual void AddPrimitive (const G4Circle &)=0
 
virtual void AddPrimitive (const G4Square &)=0
 
virtual void AddPrimitive (const G4Polymarker &)=0
 
virtual void AddPrimitive (const G4Polyhedron &)=0
 
virtual void AddPrimitive (const G4NURBS &)=0
 

Additional Inherited Members

- Public Types inherited from G4VSceneHandler
enum  MarkerSizeType { world , screen }
 
- Protected Member Functions inherited from G4VSceneHandler
virtual void ProcessScene ()
 
virtual void RequestPrimitives (const G4VSolid &solid)
 
virtual G4VSolidCreateSectionSolid ()
 
virtual G4VSolidCreateCutawaySolid ()
 
void LoadAtts (const G4Visible &, G4AttHolder *)
 
- Protected Attributes inherited from G4VSceneHandler
G4VGraphicsSystemfSystem
 
const G4int fSceneHandlerId
 
G4String fName
 
G4int fViewCount
 
G4ViewerList fViewerList
 
G4VViewerfpViewer
 
G4ScenefpScene
 
G4bool fMarkForClearingTransientStore
 
G4bool fReadyForTransients
 
G4bool fTransientsDrawnThisEvent
 
G4bool fTransientsDrawnThisRun
 
G4bool fProcessingSolid
 
G4bool fProcessing2D
 
G4VModelfpModel
 
G4Transform3D fObjectTransformation
 
G4int fNestingDepth
 
const G4VisAttributesfpVisAttribs
 
const G4Transform3D fIdentityTransformation
 

Detailed Description

Author
Mark Donszelmann

Definition at line 64 of file G4HepRepSceneHandler.hh.

Constructor & Destructor Documentation

◆ G4HepRepSceneHandler()

G4HepRepSceneHandler::G4HepRepSceneHandler ( G4VGraphicsSystem system,
const G4String name = "" 
)

Definition at line 93 of file G4HepRepSceneHandler.cc.

94 : G4VSceneHandler (system, sceneIdCount++, name),
95 geometryLayer ("Geometry"),
96 eventLayer ("Event"),
97 calHitLayer ("CalHit"),
98 trajectoryLayer ("Trajectory"),
99 hitLayer ("Hit"),
100 rootVolumeName ("Geometry"),
101 baseName (""),
102 eventNumberPrefix (""),
103 eventNumberSuffix (""),
104 eventNumber (1),
105 eventNumberWidth (-1),
106 extension (""),
107 writeBinary (false),
108 writeZip (false),
109 writeGZ (false),
110 writeMultipleFiles (false),
111 currentHit (NULL),
112 currentTrack (NULL),
113 _heprep (NULL),
114 _heprepGeometry (NULL)
115{
116
117#ifdef LDEBUG
118 cout << "G4HepRepSceneHandler::G4HepRepSceneHandler: " << system << endl;
119#endif
120
121 materialState[kStateSolid] = G4String("Solid");
122 materialState[kStateLiquid] = G4String("Liquid");
123 materialState[kStateGas] = G4String("Gas");
124 materialState[kStateUndefined] = G4String("Undefined");
125
126 factory = new XMLHepRepFactory();
127 writer = NULL;
128
129 // opening of file deferred to closeHepRep();
130 openHepRep();
131}
@ kStateSolid
Definition: G4Material.hh:114
@ kStateLiquid
Definition: G4Material.hh:114
@ kStateGas
Definition: G4Material.hh:114
@ kStateUndefined
Definition: G4Material.hh:114

◆ ~G4HepRepSceneHandler()

G4HepRepSceneHandler::~G4HepRepSceneHandler ( )
virtual

Definition at line 134 of file G4HepRepSceneHandler.cc.

134 {
135#ifdef LDEBUG
136 cout << "G4HepRepSceneHandler::~G4HepRepSceneHandler() " << endl;
137#endif
138 close();
139
140 delete factory;
141 factory = NULL;
142
143 dynamic_cast<G4HepRep*>(GetGraphicsSystem())->removeSceneHandler();
144}
G4VGraphicsSystem * GetGraphicsSystem() const

Member Function Documentation

◆ AddCompound() [1/4]

void G4HepRepSceneHandler::AddCompound ( const G4THitsMap< G4double > &  hits)
inlinevirtual

Reimplemented from G4VSceneHandler.

Definition at line 87 of file G4HepRepSceneHandler.hh.

87 {
89 }
virtual void AddCompound(const G4VTrajectory &)

◆ AddCompound() [2/4]

void G4HepRepSceneHandler::AddCompound ( const G4VDigi digi)
inlinevirtual

Reimplemented from G4VSceneHandler.

Definition at line 84 of file G4HepRepSceneHandler.hh.

84 {
86 }

◆ AddCompound() [3/4]

void G4HepRepSceneHandler::AddCompound ( const G4VHit hit)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1049 of file G4HepRepSceneHandler.cc.

1049 {
1050#ifdef PDEBUG
1051 cout << "G4HepRepSceneHandler::AddCompound(G4VHit&) " << endl;
1052#endif
1053 if (dontWrite()) return;
1054
1055 currentHit = &hit;
1057 currentHit = NULL;
1058}

◆ AddCompound() [4/4]

void G4HepRepSceneHandler::AddCompound ( const G4VTrajectory trajectory)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1037 of file G4HepRepSceneHandler.cc.

1037 {
1038#ifdef PDEBUG
1039 cout << "G4HepRepSceneHandler::AddCompound(G4VTrajectory&) " << endl;
1040#endif
1041 if (dontWrite()) return;
1042
1043 currentTrack = &trajectory;
1044 G4VSceneHandler::AddCompound(trajectory);
1045 currentTrack = NULL;
1046}

◆ AddPrimitive() [1/8]

void G4HepRepSceneHandler::AddPrimitive ( const G4Circle circle)
virtual

Implements G4VSceneHandler.

Definition at line 855 of file G4HepRepSceneHandler.cc.

855 {
856#ifdef PDEBUG
857 cout << "G4HepRepSceneHandler::AddPrimitive(G4Circle&) " << endl;
858#endif
859 if (dontWrite()) return;
860
861 if (fProcessing2D) {
862 static G4bool warned = false;
863 if (!warned) {
864 warned = true;
866 ("G4HepRepSceneHandler::AddPrimitive (const G4Circle&)",
867 "vis-HepRep1003", JustWarning,
868 "2D circles not implemented. Ignored.");
869 }
870 return;
871 }
872
873 HepRepInstance* instance = factory->createHepRepInstance(getEventInstance(), getHitType());
874
875 addAttributes(instance, getHitType());
876
877 G4Point3D center = transform * circle.GetPosition();
878
879 setColor (instance, GetColor(circle));
880
881 setVisibility(instance, circle);
882
883 setMarker(instance, circle);
884
885 factory->createHepRepPoint(instance, center.x(), center.y(), center.z());
886}
@ JustWarning
bool G4bool
Definition: G4Types.hh:67
G4Point3D GetPosition() const
const G4Colour & GetColor(const G4Visible &)
virtual HepRepInstance * createHepRepInstance(HepRepInstance *parent, HepRepType *type)=0
virtual HepRepPoint * createHepRepPoint(HepRepInstance *instance, double x, double y, double z)=0
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

◆ AddPrimitive() [2/8]

void G4HepRepSceneHandler::AddPrimitive ( const G4NURBS )
virtual

Implements G4VSceneHandler.

Definition at line 1009 of file G4HepRepSceneHandler.cc.

1009 {
1010#ifdef PDEBUG
1011 cout << "G4HepRepSceneHandler::AddPrimitive(G4NURBS&) " << endl;
1012#endif
1013 if (dontWrite()) return;
1014
1015 /*** You may need this
1016 if (fProcessing2D) {
1017 static G4bool warned = false;
1018 if (!warned) {
1019 warned = true;
1020 G4Exception
1021 ("G4HepRepSceneHandler::AddPrimitive (const G4NURBS&)",
1022 "vis-HepRep1007", JustWarning,
1023 "2D NURBS not implemented. Ignored.");
1024 }
1025 return;
1026 }
1027 ***/
1028
1029 cout << "G4HepRepSceneHandler::AddPrimitive G4NURBS : not yet implemented. " << endl;
1030}

◆ AddPrimitive() [3/8]

void G4HepRepSceneHandler::AddPrimitive ( const G4Polyhedron polyhedron)
virtual

Implements G4VSceneHandler.

Definition at line 889 of file G4HepRepSceneHandler.cc.

889 {
890
891#ifdef PDEBUG
892 cout << "G4HepRepSceneHandler::AddPrimitive(G4Polyhedron&) " << endl;
893#endif
894 if (dontWrite()) return;
895
896 if (fProcessing2D) {
897 static G4bool warned = false;
898 if (!warned) {
899 warned = true;
901 ("G4HepRepSceneHandler::AddPrimitive (const G4Polyhedron&)",
902 "vis-HepRep1004", JustWarning,
903 "2D polyhedra not implemented. Ignored.");
904 }
905 return;
906 }
907
908 G4Normal3D surfaceNormal;
909 G4Point3D vertex;
910
911 if (polyhedron.GetNoFacets()==0) return;
912
913 HepRepInstance* instance = getGeometryOrEventInstance(getCalHitType());
914
915 addAttributes(instance, getCalHitType());
916
917 setVisibility(instance, polyhedron);
918
919 G4int currentDepth = 0;
920 G4PhysicalVolumeModel* pPVModel =
921 dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
922 if (pPVModel) currentDepth = pPVModel->GetCurrentDepth();
923
924 G4bool notLastFace;
925 do {
926 HepRepInstance* face;
927 if (isEventData()) {
928 face = factory->createHepRepInstance(instance, getCalHitFaceType());
929 } else {
930 face = getGeometryInstance("*Face", currentDepth+1);
931 setAttribute(face, "PickParent", true);
932 setAttribute(face, "DrawAs", G4String("Polygon"));
933 }
934
935 setLine(face, polyhedron);
936 setColor(face, GetColor(polyhedron));
937 if (isEventData()) setColor(face, GetColor(polyhedron), G4String("FillColor"));
938
939 notLastFace = polyhedron.GetNextNormal (surfaceNormal);
940
941 G4int edgeFlag = 1;
942 G4bool notLastEdge;
943 do {
944 notLastEdge = polyhedron.GetNextVertex (vertex, edgeFlag);
945 vertex = transform * vertex;
946 factory->createHepRepPoint(face, vertex.x(), vertex.y(), vertex.z());
947 } while (notLastEdge);
948 } while (notLastFace);
949}
int G4int
Definition: G4Types.hh:66
G4bool GetNextNormal(G4Normal3D &normal) const
G4bool GetNextVertex(G4Point3D &vertex, G4int &edgeFlag) const
G4int GetNoFacets() const

◆ AddPrimitive() [4/8]

void G4HepRepSceneHandler::AddPrimitive ( const G4Polyline line)
virtual

Implements G4VSceneHandler.

Definition at line 768 of file G4HepRepSceneHandler.cc.

768 {
769
770#ifdef PDEBUG
771 cout << "G4HepRepSceneHandler::AddPrimitive(G4Polyline&) " << line.size() << endl;
772#endif
773 if (dontWrite()) return;
774
775 if (fProcessing2D) {
776 static G4bool warned = false;
777 if (!warned) {
778 warned = true;
780 ("G4HepRepSceneHandler::AddPrimitive (const G4Polyline&)",
781 "vis-HepRep1001", JustWarning,
782 "2D polylines not implemented. Ignored.");
783 }
784 return;
785 }
786
787 HepRepInstance* instance = factory->createHepRepInstance(getEventInstance(), getTrajectoryType());
788
789 addAttributes(instance, getTrajectoryType());
790
791 setColor(instance, GetColor(line));
792
793 setVisibility(instance, line);
794
795 setLine(instance, line);
796
797 for (size_t i=0; i < line.size(); i++) {
798 G4Point3D vertex = transform * line[i];
799 factory->createHepRepPoint(instance, vertex.x(), vertex.y(), vertex.z());
800 }
801}

◆ AddPrimitive() [5/8]

void G4HepRepSceneHandler::AddPrimitive ( const G4Polymarker line)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 804 of file G4HepRepSceneHandler.cc.

804 {
805
806#ifdef PDEBUG
807 cout << "G4HepRepSceneHandler::AddPrimitive(G4Polymarker&) " << line.size() << endl;
808#endif
809 if (dontWrite()) return;
810
811 if (fProcessing2D) {
812 static G4bool warned = false;
813 if (!warned) {
814 warned = true;
816 ("G4HepRepSceneHandler::AddPrimitive (const G4Polymarker&)",
817 "vis-HepRep1002", JustWarning,
818 "2D polymarkers not implemented. Ignored.");
819 }
820 return;
821 }
822
823 HepRepInstance* instance = factory->createHepRepInstance(getEventInstance(), getHitType());
824
825 addAttributes(instance, getHitType());
826
827 setColor(instance, GetColor(line));
828
829 setVisibility(instance, line);
830
831 setMarker(instance, line);
832
833 // Default MarkName is set to Circle for this Type.
834 int mtype = line.GetMarkerType();
835
836 // Cannot be case statement since line.xxx is not a constant
837 if (mtype == line.dots) {
838 setAttribute(instance, "Fill", true);
839 setColor(instance, GetColor(line), G4String("FillColor"));
840 } else if (mtype == line.circles) {
841 } else if (line.squares) {
842 setAttribute(instance, "MarkName", G4String("Box"));
843 } else {
844 // line.line + default
845 setAttribute(instance, "MarkName", G4String("Plus"));
846 }
847
848 for (size_t i=0; i < line.size(); i++) {
849 G4Point3D vertex = transform * line[i];
850 factory->createHepRepPoint(instance, vertex.x(), vertex.y(), vertex.z());
851 }
852}
MarkerType GetMarkerType() const

◆ AddPrimitive() [6/8]

void G4HepRepSceneHandler::AddPrimitive ( const G4Scale scale)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1032 of file G4HepRepSceneHandler.cc.

1032 {
1033 if (dontWrite()) return;
1035}
virtual void AddPrimitive(const G4Polyline &)=0

◆ AddPrimitive() [7/8]

void G4HepRepSceneHandler::AddPrimitive ( const G4Square square)
virtual

Implements G4VSceneHandler.

Definition at line 976 of file G4HepRepSceneHandler.cc.

976 {
977#ifdef PDEBUG
978 cout << "G4HepRepSceneHandler::AddPrimitive(G4Square&) " << endl;
979#endif
980 if (dontWrite()) return;
981
982 if (fProcessing2D) {
983 static G4bool warned = false;
984 if (!warned) {
985 warned = true;
987 ("G4HepRepSceneHandler::AddPrimitive (const G4Square&)",
988 "vis-HepRep1006", JustWarning,
989 "2D squares not implemented. Ignored.");
990 }
991 return;
992 }
993
994 HepRepInstance* instance = factory->createHepRepInstance(getEventInstance(), getHitType());
995
996 addAttributes(instance, getHitType());
997
998 G4Point3D center = transform * square.GetPosition();
999
1000 setColor (instance, getColorFor(square));
1001
1002 setVisibility(instance, square);
1003
1004 setMarker(instance, square);
1005
1006 factory->createHepRepPoint(instance, center.x(), center.y(), center.z());
1007}

◆ AddPrimitive() [8/8]

void G4HepRepSceneHandler::AddPrimitive ( const G4Text )
virtual

Implements G4VSceneHandler.

Definition at line 952 of file G4HepRepSceneHandler.cc.

952 {
953#ifdef PDEBUG
954 cout << "G4HepRepSceneHandler::AddPrimitive(G4Text&) " << endl;
955#endif
956 if (dontWrite()) return;
957
958 /*** You may need this
959 if (fProcessing2D) {
960 static G4bool warned = false;
961 if (!warned) {
962 warned = true;
963 G4Exception
964 ("G4HepRepSceneHandler::AddPrimitive (const G4Text&)",
965 "vis-HepRep1005", JustWarning,
966 "2D text not implemented. Ignored.");
967 }
968 return;
969 }
970 ***/
971
972 cout << "G4HepRepSceneHandler::AddPrimitive G4Text : not yet implemented. " << endl;
973}

◆ AddSolid() [1/11]

void G4HepRepSceneHandler::AddSolid ( const G4Box box)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 495 of file G4HepRepSceneHandler.cc.

495 {
496#ifdef SDEBUG
497 cout << "G4HepRepSceneHandler::AddSolid(const G4Box& box)" << endl;
498#endif
499
500 if (dontWrite()) return;
501
503
504 if (! messenger->useSolids()) {
506 return;
507 }
508
509 G4double dx = box.GetXHalfLength();
510 G4double dy = box.GetYHalfLength();
511 G4double dz = box.GetZHalfLength();
512
513 G4Point3D vertex1(G4Point3D( dx, dy,-dz));
514 G4Point3D vertex2(G4Point3D( dx,-dy,-dz));
515 G4Point3D vertex3(G4Point3D(-dx,-dy,-dz));
516 G4Point3D vertex4(G4Point3D(-dx, dy,-dz));
517 G4Point3D vertex5(G4Point3D( dx, dy, dz));
518 G4Point3D vertex6(G4Point3D( dx,-dy, dz));
519 G4Point3D vertex7(G4Point3D(-dx,-dy, dz));
520 G4Point3D vertex8(G4Point3D(-dx, dy, dz));
521
522 vertex1 = (transform) * vertex1;
523 vertex2 = (transform) * vertex2;
524 vertex3 = (transform) * vertex3;
525 vertex4 = (transform) * vertex4;
526 vertex5 = (transform) * vertex5;
527 vertex6 = (transform) * vertex6;
528 vertex7 = (transform) * vertex7;
529 vertex8 = (transform) * vertex8;
530
531 HepRepInstance* instance = getGeometryOrEventInstance(getCalHitType());
532 addAttributes(instance, getCalHitType());
533
534 setAttribute(instance, "DrawAs", G4String("Prism"));
535
536 setVisibility(instance, box);
537 setLine(instance, box);
538 setColor(instance, getColorFor(box));
539
540 factory->createHepRepPoint(instance, vertex1.x(), vertex1.y(), vertex1.z());
541 factory->createHepRepPoint(instance, vertex2.x(), vertex2.y(), vertex2.z());
542 factory->createHepRepPoint(instance, vertex3.x(), vertex3.y(), vertex3.z());
543 factory->createHepRepPoint(instance, vertex4.x(), vertex4.y(), vertex4.z());
544 factory->createHepRepPoint(instance, vertex5.x(), vertex5.y(), vertex5.z());
545 factory->createHepRepPoint(instance, vertex6.x(), vertex6.y(), vertex6.z());
546 factory->createHepRepPoint(instance, vertex7.x(), vertex7.y(), vertex7.z());
547 factory->createHepRepPoint(instance, vertex8.x(), vertex8.y(), vertex8.z());
548}
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:35
double G4double
Definition: G4Types.hh:64
G4double GetYHalfLength() const
G4double GetZHalfLength() const
G4double GetXHalfLength() const
virtual G4bool useSolids()
static G4HepRepMessenger * GetInstance()
virtual void AddSolid(const G4Box &)

◆ AddSolid() [2/11]

void G4HepRepSceneHandler::AddSolid ( const G4Cons cons)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 551 of file G4HepRepSceneHandler.cc.

551 {
552#ifdef SDEBUG
553 cout << "G4HepRepSceneHandler::AddSolid(const G4Cons& cons)" << endl;
554#endif
555
556 if (dontWrite()) return;
557
559
560 if (! messenger->useSolids() || (cons.GetDeltaPhiAngle() < twopi)) {
562 return;
563 }
564
565 G4PhysicalVolumeModel* pPVModel =
566 dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
567 if (!pPVModel) {
569 return;
570 }
571
572 G4LogicalVolume* pCurrentLV = pPVModel->GetCurrentLV();
573 G4int currentDepth = pPVModel->GetCurrentDepth();
574 G4Material* pCurrentMaterial = pPVModel->GetCurrentMaterial();
575
576 G4Point3D vertex1(G4Point3D( 0., 0., cons.GetZHalfLength()));
577 G4Point3D vertex2(G4Point3D( 0., 0.,-cons.GetZHalfLength()));
578
579 vertex1 = (transform) * vertex1;
580 vertex2 = (transform) * vertex2;
581
582 HepRepInstance* instance = getGeometryInstance(pCurrentLV, pCurrentMaterial, currentDepth);
583 setAttribute(instance, "DrawAs", G4String("Cylinder"));
584
585 setVisibility(instance, cons);
586 setLine(instance, cons);
587 setColor(instance, getColorFor(cons));
588
589 HepRepType* type = getGeometryType(pCurrentLV->GetName(), currentDepth);
590
591 // Outer cylinder.
592 HepRepInstance* outer = factory->createHepRepInstance(instance, type);
593 outer->addAttValue("pickParent",true);
594 outer->addAttValue("showParentAttributes",true);
595
596 HepRepPoint* op1 = factory->createHepRepPoint(outer, vertex1.x(), vertex1.y(), vertex1.z());
597 op1->addAttValue("Radius",cons.GetOuterRadiusPlusZ());
598
599 HepRepPoint* op2 = factory->createHepRepPoint(outer, vertex2.x(), vertex2.y(), vertex2.z());
600 op2->addAttValue("Radius",cons.GetOuterRadiusMinusZ());
601
602 // Inner cylinder.
603 HepRepInstance* inner = factory->createHepRepInstance(instance, type);
604 inner->addAttValue("pickParent",true);
605 inner->addAttValue("showParentAttributes",true);
606
607 HepRepPoint* ip1 = factory->createHepRepPoint(inner, vertex1.x(), vertex1.y(), vertex1.z());
608 ip1->addAttValue("Radius",cons.GetInnerRadiusPlusZ());
609
610 HepRepPoint* ip2 = factory->createHepRepPoint(inner, vertex2.x(), vertex2.y(), vertex2.z());
611 ip2->addAttValue("Radius",cons.GetInnerRadiusMinusZ());
612}
G4double GetOuterRadiusPlusZ() const
G4double GetDeltaPhiAngle() const
G4double GetInnerRadiusMinusZ() const
G4double GetInnerRadiusPlusZ() const
G4double GetOuterRadiusMinusZ() const
G4double GetZHalfLength() const
G4String GetName() const
G4LogicalVolume * GetCurrentLV() const
G4Material * GetCurrentMaterial() const
virtual void addAttValue(HepRepAttValue *attValue)=0

◆ AddSolid() [3/11]

void G4HepRepSceneHandler::AddSolid ( const G4Para para)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 742 of file G4HepRepSceneHandler.cc.

742 {
743 if (dontWrite()) return;
745}

◆ AddSolid() [4/11]

void G4HepRepSceneHandler::AddSolid ( const G4Polycone polycone)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 752 of file G4HepRepSceneHandler.cc.

752 {
753 if (dontWrite()) return;
754 G4VSceneHandler::AddSolid (polycone);
755}

◆ AddSolid() [5/11]

void G4HepRepSceneHandler::AddSolid ( const G4Polyhedra polyhedra)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 757 of file G4HepRepSceneHandler.cc.

757 {
758 if (dontWrite()) return;
759 G4VSceneHandler::AddSolid (polyhedra);
760}

◆ AddSolid() [6/11]

void G4HepRepSceneHandler::AddSolid ( const G4Sphere sphere)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 737 of file G4HepRepSceneHandler.cc.

737 {
738 if (dontWrite()) return;
740}

◆ AddSolid() [7/11]

void G4HepRepSceneHandler::AddSolid ( const G4Torus torus)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 747 of file G4HepRepSceneHandler.cc.

747 {
748 if (dontWrite()) return;
750}

◆ AddSolid() [8/11]

void G4HepRepSceneHandler::AddSolid ( const G4Trap trap)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 732 of file G4HepRepSceneHandler.cc.

732 {
733 if (dontWrite()) return;
735}

◆ AddSolid() [9/11]

void G4HepRepSceneHandler::AddSolid ( const G4Trd trd)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 675 of file G4HepRepSceneHandler.cc.

675 {
676#ifdef SDEBUG
677 cout << "G4HepRepSceneHandler::AddSolid(const G4Trd& trd)" << endl;
678#endif
679 if (dontWrite()) return;
680
682
683 if (! messenger->useSolids()) {
685 return;
686 }
687
688 G4double dx1 = trd.GetXHalfLength1();
689 G4double dy1 = trd.GetYHalfLength1();
690 G4double dx2 = trd.GetXHalfLength2();
691 G4double dy2 = trd.GetYHalfLength2();
692 G4double dz = trd.GetZHalfLength();
693
694 G4Point3D vertex1(G4Point3D( dx1, dy1,-dz));
695 G4Point3D vertex2(G4Point3D( dx1,-dy1,-dz));
696 G4Point3D vertex3(G4Point3D(-dx1,-dy1,-dz));
697 G4Point3D vertex4(G4Point3D(-dx1, dy1,-dz));
698 G4Point3D vertex5(G4Point3D( dx2, dy2, dz));
699 G4Point3D vertex6(G4Point3D( dx2,-dy2, dz));
700 G4Point3D vertex7(G4Point3D(-dx2,-dy2, dz));
701 G4Point3D vertex8(G4Point3D(-dx2, dy2, dz));
702
703 vertex1 = (transform) * vertex1;
704 vertex2 = (transform) * vertex2;
705 vertex3 = (transform) * vertex3;
706 vertex4 = (transform) * vertex4;
707 vertex5 = (transform) * vertex5;
708 vertex6 = (transform) * vertex6;
709 vertex7 = (transform) * vertex7;
710 vertex8 = (transform) * vertex8;
711
712 HepRepInstance* instance = getGeometryOrEventInstance(getCalHitType());
713
714 addAttributes(instance, getCalHitType());
715
716 setAttribute(instance, "DrawAs", G4String("Prism"));
717
718 setVisibility(instance, trd);
719 setLine(instance, trd);
720 setColor(instance, getColorFor(trd));
721
722 factory->createHepRepPoint(instance, vertex1.x(), vertex1.y(), vertex1.z());
723 factory->createHepRepPoint(instance, vertex2.x(), vertex2.y(), vertex2.z());
724 factory->createHepRepPoint(instance, vertex3.x(), vertex3.y(), vertex3.z());
725 factory->createHepRepPoint(instance, vertex4.x(), vertex4.y(), vertex4.z());
726 factory->createHepRepPoint(instance, vertex5.x(), vertex5.y(), vertex5.z());
727 factory->createHepRepPoint(instance, vertex6.x(), vertex6.y(), vertex6.z());
728 factory->createHepRepPoint(instance, vertex7.x(), vertex7.y(), vertex7.z());
729 factory->createHepRepPoint(instance, vertex8.x(), vertex8.y(), vertex8.z());
730}
G4double GetXHalfLength2() const
G4double GetYHalfLength2() const
G4double GetXHalfLength1() const
G4double GetYHalfLength1() const
G4double GetZHalfLength() const

◆ AddSolid() [10/11]

void G4HepRepSceneHandler::AddSolid ( const G4Tubs tubs)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 615 of file G4HepRepSceneHandler.cc.

615 {
616#ifdef SDEBUG
617 cout << "G4HepRepSceneHandler::AddSolid(const G4Tubs& tubs)" << endl;
618#endif
619
620 if (dontWrite()) return;
621
623
624 if (! messenger->useSolids() || (tubs.GetDeltaPhiAngle() < twopi)) {
626 return;
627 }
628
629 G4PhysicalVolumeModel* pPVModel =
630 dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
631 if (!pPVModel) {
633 return;
634 }
635
636 G4LogicalVolume* pCurrentLV = pPVModel->GetCurrentLV();
637 G4int currentDepth = pPVModel->GetCurrentDepth();
638 G4Material* pCurrentMaterial = pPVModel->GetCurrentMaterial();
639
640 G4Point3D vertex1(G4Point3D( 0., 0., tubs.GetZHalfLength()));
641 G4Point3D vertex2(G4Point3D( 0., 0.,-tubs.GetZHalfLength()));
642
643 vertex1 = (transform) * vertex1;
644 vertex2 = (transform) * vertex2;
645
646 HepRepInstance* instance = getGeometryInstance(pCurrentLV, pCurrentMaterial, currentDepth);
647 setAttribute(instance, "DrawAs", G4String("Cylinder"));
648
649 setVisibility(instance, tubs);
650 setLine(instance, tubs);
651 setColor(instance, getColorFor(tubs));
652
653 HepRepType* type = getGeometryType(pCurrentLV->GetName(), currentDepth);
654
655 // Outer cylinder.
656 HepRepInstance* outer = factory->createHepRepInstance(instance, type);
657 outer->addAttValue("Radius",tubs.GetOuterRadius());
658 outer->addAttValue("pickParent",true);
659 outer->addAttValue("showParentAttributes",true);
660 factory->createHepRepPoint(outer, vertex1.x(), vertex1.y(), vertex1.z());
661 factory->createHepRepPoint(outer, vertex2.x(), vertex2.y(), vertex2.z());
662
663 // Inner cylinder.
664 if (tubs.GetInnerRadius() > 0.) {
665 HepRepInstance* inner = factory->createHepRepInstance(instance, type);
666 inner->addAttValue("Radius",tubs.GetInnerRadius());
667 inner->addAttValue("pickParent",true);
668 inner->addAttValue("showParentAttributes",true);
669 factory->createHepRepPoint(inner, vertex1.x(), vertex1.y(), vertex1.z());
670 factory->createHepRepPoint(inner, vertex2.x(), vertex2.y(), vertex2.z());
671 }
672}
G4double GetZHalfLength() const
G4double GetInnerRadius() const
G4double GetOuterRadius() const
G4double GetDeltaPhiAngle() const

◆ AddSolid() [11/11]

void G4HepRepSceneHandler::AddSolid ( const G4VSolid solid)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 762 of file G4HepRepSceneHandler.cc.

762 {
763 if (dontWrite()) return;
765}

◆ BeginModeling()

void G4HepRepSceneHandler::BeginModeling ( )
virtual

Reimplemented from G4VSceneHandler.

Definition at line 480 of file G4HepRepSceneHandler.cc.

480 {
481#ifdef SDEBUG
482 cout << "G4HepRepSceneHandler::BeginModeling() " << endl;
483#endif
485}
virtual void BeginModeling()

◆ BeginPrimitives()

void G4HepRepSceneHandler::BeginPrimitives ( const G4Transform3D objectTransformation)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1080 of file G4HepRepSceneHandler.cc.

1080 {
1081#ifdef SDEBUG
1082 cout << "G4HepRepSceneHandler::BeginPrimitives(G4Transform3D&)" << endl;
1083#endif
1084
1085 G4VSceneHandler::BeginPrimitives (objectTransformation);
1086 transform = objectTransformation;
1087}
virtual void BeginPrimitives(const G4Transform3D &objectTransformation)

◆ closeFile()

void G4HepRepSceneHandler::closeFile ( )

Definition at line 462 of file G4HepRepSceneHandler.cc.

462 {
463 writer->close();
464 delete writer;
465 writer = NULL;
466
467 delete out;
468 out = NULL;
469}
virtual bool close()=0

Referenced by closeHepRep().

◆ closeHepRep()

bool G4HepRepSceneHandler::closeHepRep ( bool  final = false)

Returns true if the HepRep was (already) closed, false if the HepRep is still open

Definition at line 322 of file G4HepRepSceneHandler.cc.

322 {
323 if (_heprep == NULL) return true;
324
325#ifdef LDEBUG
326 cout << "G4HepRepSceneHandler::CloseHepRep() start" << endl;
327#endif
328
329 // if this is the final close, then there should not be any event pending to be written.
330 if (final) {
331 if (_eventInstanceTree != NULL) {
332 cerr << "WARNING: you probably used '/vis/viewer/endOfEventAction accumulate' and "
333 << "forgot to call /vis/viewer/update before exit. No event written." << endl;
334 }
335 } else {
336
338
339 // add geometry to the heprep if there is an event (separate geometries are written
340 // using DrawView() called from /vis/viewer/flush)
341 if (_eventInstanceTree != NULL) {
343
344 // couple geometry
345
346 if ( messenger->appendGeometry()) {
347 // couple geometry to event if geometry was written
348 if ((_geometryInstanceTree != NULL)) {
349 getEventInstanceTree()->addInstanceTree(getGeometryInstanceTree());
350 }
351 } else {
352 char name[128];
353 if (writeMultipleFiles) {
354 sprintf(name, "%s%s%s#%s", baseName.c_str(), "-geometry", extension.c_str(), "G4GeometryData");
355 } else {
356 sprintf(name, "%s%s#%s", "geometry", (writeBinary ? ".bheprep" : ".heprep"), "G4GeometryData");
357 }
358 getEventInstanceTree()->addInstanceTree(factory->createHepRepTreeID(name, "1.0"));
359 }
360 }
361
362 // force inclusion of all subtypes of event
363 if (_eventInstanceTree != NULL) {
364 getEventType();
365 getTrajectoryType();
366 getHitType();
367 getCalHitType();
368 getCalHitFaceType();
369 }
370
371 // Give this HepRep all of the layer order info for both geometry and event,
372 // since these will both end up in a single HepRep.
373 writeLayers(_heprepGeometry);
374 writeLayers(_heprep);
375
376 // open heprep file
377 if (writer == NULL) {
378 open((GetScene() == NULL) ? G4String("G4HepRepOutput.heprep.zip") : GetScene()->GetName());
379 }
380
381 // write out separate geometry
382 if (! messenger->appendGeometry() && (_heprepGeometry != NULL)) {
383 if (writeMultipleFiles) {
384 char fileName[128];
385 sprintf(fileName, "%s%s%s", baseName.c_str(), "-geometry", extension.c_str());
386 openFile(G4String(fileName));
387 }
388
389 char name[128];
390 sprintf(name, "%s%s", "geometry", (writeBinary ? ".bheprep" : ".heprep"));
391 if (!writeMultipleFiles) {
392 writer->addProperty("RecordLoop.ignore", name);
393 }
394
395 writer->write(_heprepGeometry, G4String(name));
396
397 delete _heprepGeometry;
398 _heprepGeometry = NULL;
399
400 if (writeMultipleFiles) closeFile();
401 }
402
403 if (writeMultipleFiles) {
404// NOTE: does not work on Solaris 5.2 and Linux 2.95.2
405// stringstream fileName;
406// fileName << baseName << eventNumberPrefix << setw(eventNumberWidth) << setfill('0') << eventNumber << eventNumberSuffix << extension;
407// openFile(fileName.str());
408// Use instead:
409 char fileName[128];
410 char fileFormat[128];
411 sprintf(fileFormat, "%s%d%s", "%s%s%0", eventNumberWidth, "d%s%s");
412 sprintf(fileName, fileFormat, baseName.c_str(), eventNumberPrefix.c_str(), eventNumber, eventNumberSuffix.c_str(), extension.c_str());
413 openFile(G4String(fileName));
414 }
415
416 // write out the heprep
417// NOTE: does not work on Solaris 5.2 and Linux 2.95.2
418// stringstream eventName;
419// eventName << "event-" << setw(eventNumberWidth) << setfill('0') << eventNumber << (writeBinary ? ".bheprep" : ".heprep");
420// writer->write(_heprep, eventName.str());
421// Use instead:
422 char eventName[128];
423 char eventFormat[128];
424 sprintf(eventFormat, "%s%d%s%s", "event-%0", eventNumberWidth, "d", (writeBinary ? ".bheprep" : ".heprep"));
425 sprintf(eventName, eventFormat, eventNumber);
426 writer->write(_heprep, G4String(eventName));
427
428 eventNumber++;
429 }
430
431 delete _heprep;
432 _heprep = NULL;
433
434 if (writeMultipleFiles) closeFile();
435
436 return true;
437}
virtual G4bool appendGeometry()
void openFile(G4String name)
G4Scene * GetScene() const
G4VViewer * GetCurrentViewer() const
const G4String & GetName() const
virtual void DrawView()=0
virtual HepRepTreeID * createHepRepTreeID(std::string name, std::string version, std::string qualifier="top-level")=0
virtual void addInstanceTree(HepRepTreeID *instanceTree)=0
virtual bool addProperty(std::string key, std::string value)=0
virtual bool write(HepRep *heprep, std::string name)=0

Referenced by G4HepRepViewer::ShowView().

◆ EndModeling()

void G4HepRepSceneHandler::EndModeling ( )
virtual

Reimplemented from G4VSceneHandler.

Definition at line 488 of file G4HepRepSceneHandler.cc.

488 {
489#ifdef SDEBUG
490 cout << "G4HepRepSceneHandler::EndModeling() " << endl;
491#endif
493}
virtual void EndModeling()

◆ EndPrimitives()

void G4HepRepSceneHandler::EndPrimitives ( )
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1090 of file G4HepRepSceneHandler.cc.

1090 {
1091#ifdef SDEBUG
1092 cout << "G4HepRepSceneHandler::EndPrimitives" << endl;
1093#endif
1095}
virtual void EndPrimitives()

◆ openFile()

void G4HepRepSceneHandler::openFile ( G4String  name)

Definition at line 457 of file G4HepRepSceneHandler.cc.

457 {
458 out = new ofstream(name.c_str(), std::ios::out | std::ios::binary );
459 writer = factory->createHepRepWriter(out, writeZip, writeZip || writeGZ);
460}
virtual HepRepWriter * createHepRepWriter(std::ostream *out, bool randomAccess, bool compress)=0

Referenced by closeHepRep().

◆ openHepRep()

void G4HepRepSceneHandler::openHepRep ( )

Definition at line 292 of file G4HepRepSceneHandler.cc.

292 {
293#ifdef LDEBUG
294 cout << "G4HepRepSceneHandler::OpenHepRep() " << endl;
295#endif
296
297 if (_heprep != NULL) return;
298
299 // all done on demand, once pointers are set to NULL
300 _heprepGeometry = NULL;
301 _geometryInstanceTree = NULL;
302 _geometryRootInstance = NULL;
303 _geometryInstance.clear();
304 _geometryTypeTree = NULL;
305 _geometryRootType = NULL;
306 _geometryTypeName.clear();
307 _geometryType.clear();
308 _eventInstanceTree = NULL;
309 _eventInstance = NULL;
310 _eventTypeTree = NULL;
311 _eventType = NULL;
312 _trajectoryType = NULL;
313 _hitType = NULL;
314 _calHitType = NULL;
315 _calHitFaceType = NULL;
316}

Referenced by G4HepRepSceneHandler(), and G4HepRepViewer::ShowView().

◆ PostAddSolid()

void G4HepRepSceneHandler::PostAddSolid ( )
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1072 of file G4HepRepSceneHandler.cc.

1072 {
1073#ifdef SDEBUG
1074 cout << "G4HepRepSceneHandler::PostAddSolid()" << endl;
1075#endif
1077}
virtual void PostAddSolid()

◆ PreAddSolid()

void G4HepRepSceneHandler::PreAddSolid ( const G4Transform3D objectTransformation,
const G4VisAttributes visAttribs 
)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1060 of file G4HepRepSceneHandler.cc.

1061 {
1062
1063 G4VSceneHandler::PreAddSolid (objectTransformation, visAttribs);
1064
1065 transform = objectTransformation;
1066#ifdef SDEBUG
1067 cout << "G4HepRepSceneHandler::PreAddSolid(G4Transform3D&, G4VisAttributes&)" << endl;
1068#endif
1069}
virtual void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &)

The documentation for this class was generated from the following files: