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

#include <G4Scene.hh>

Classes

struct  Model
 

Public Types

enum  { UNLIMITED = -1 }
 

Public Member Functions

 G4Scene (const G4String &name="scene-with-unspecified-name")
 
 ~G4Scene ()
 
G4bool operator== (const G4Scene &) const
 
G4bool operator!= (const G4Scene &) const
 
const G4StringGetName () const
 
G4bool IsEmpty () const
 
const std::vector< Model > & GetRunDurationModelList () const
 
const std::vector< Model > & GetEndOfEventModelList () const
 
const std::vector< Model > & GetEndOfRunModelList () const
 
const G4VisExtentGetExtent () const
 
const G4Point3DGetStandardTargetPoint () const
 
G4bool GetRefreshAtEndOfEvent () const
 
G4int GetMaxNumberOfKeptEvents () const
 
G4bool GetRefreshAtEndOfRun () const
 
G4bool AddRunDurationModel (G4VModel *, G4bool warn=false)
 
G4bool AddWorldIfEmpty (G4bool warn=false)
 
G4bool AddEndOfEventModel (G4VModel *, G4bool warn=false)
 
G4bool AddEndOfRunModel (G4VModel *, G4bool warn=false)
 
void SetName (const G4String &)
 
std::vector< Model > & SetRunDurationModelList ()
 
std::vector< Model > & SetEndOfEventModelList ()
 
std::vector< Model > & SetEndOfRunModelList ()
 
void SetRefreshAtEndOfEvent (G4bool)
 
void SetMaxNumberOfKeptEvents (G4int)
 
void SetRefreshAtEndOfRun (G4bool)
 
void CalculateExtent ()
 

Friends

std::ostream & operator<< (std::ostream &os, const G4Scene &d)
 

Detailed Description

Definition at line 48 of file G4Scene.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
UNLIMITED 

Definition at line 54 of file G4Scene.hh.

54{UNLIMITED = -1};
@ UNLIMITED
Definition: G4Scene.hh:54

Constructor & Destructor Documentation

◆ G4Scene()

G4Scene::G4Scene ( const G4String name = "scene-with-unspecified-name")

Definition at line 43 of file G4Scene.cc.

43 :
44 fName (name),
45 fRefreshAtEndOfEvent(true),
46 fRefreshAtEndOfRun(true),
47 fMaxNumberOfKeptEvents(100)
48{} // Note all other data members have default initial values.

◆ ~G4Scene()

G4Scene::~G4Scene ( )

Definition at line 50 of file G4Scene.cc.

50{}

Member Function Documentation

◆ AddEndOfEventModel()

G4bool G4Scene::AddEndOfEventModel ( G4VModel pModel,
G4bool  warn = false 
)

Definition at line 184 of file G4Scene.cc.

184 {
185 std::size_t i, nModels = fEndOfEventModelList.size ();
186 for (i = 0; i < nModels; ++i) {
187 if (pModel -> GetGlobalDescription () ==
188 fEndOfEventModelList[i].fpModel -> GetGlobalDescription ()) break;
189 }
190 if (i < nModels) {
191 if (warn) {
192 G4warn << "G4Scene::AddEndOfEventModel: a model \""
193 << pModel -> GetGlobalDescription ()
194 << "\"\n is already in the end-of-event list of scene \""
195 << fName << "\"."
196 << G4endl;
197 }
198 return false;
199 }
200 fEndOfEventModelList.push_back (Model(pModel));
202 return true;
203}
#define G4warn
Definition: G4Scene.cc:41
#define G4endl
Definition: G4ios.hh:57
void CalculateExtent()
Definition: G4Scene.cc:64

◆ AddEndOfRunModel()

G4bool G4Scene::AddEndOfRunModel ( G4VModel pModel,
G4bool  warn = false 
)

Definition at line 205 of file G4Scene.cc.

205 {
206 std::size_t i, nModels = fEndOfRunModelList.size ();
207 for (i = 0; i < nModels; ++i) {
208 if (pModel -> GetGlobalDescription () ==
209 fEndOfRunModelList[i].fpModel -> GetGlobalDescription ()) break;
210 }
211 if (i < nModels) {
212 if (warn) {
213 G4warn << "G4Scene::AddEndOfRunModel: a model \""
214 << pModel -> GetGlobalDescription ()
215 << "\"\n is already in the end-of-run list of scene \""
216 << fName << "\"."
217 << G4endl;
218 }
219 return false;
220 }
221 fEndOfRunModelList.push_back (pModel);
223 return true;
224}

◆ AddRunDurationModel()

G4bool G4Scene::AddRunDurationModel ( G4VModel pModel,
G4bool  warn = false 
)

Definition at line 160 of file G4Scene.cc.

161{
162 std::vector<Model>::const_iterator i;
163 for (i = fRunDurationModelList.begin ();
164 i != fRunDurationModelList.end (); ++i) {
165 if (pModel -> GetGlobalDescription () ==
166 i->fpModel->GetGlobalDescription ()) break;
167 }
168 if (i != fRunDurationModelList.end ()) {
169 if (warn) {
170 G4warn << "G4Scene::AddRunDurationModel: model \""
171 << pModel -> GetGlobalDescription ()
172 << "\"\n is already in the run-duration list of scene \""
173 << fName
174 << "\"."
175 << G4endl;
176 }
177 return false;
178 }
179 fRunDurationModelList.push_back (Model(pModel));
181 return true;
182}

Referenced by AddWorldIfEmpty(), G4VisManager::GeometryHasChanged(), G4VisCommandSceneAddLocalAxes::SetNewValue(), G4VisCommandSceneAddVolume::SetNewValue(), G4VisCommandsTouchable::SetNewValue(), and G4VisCommandViewerCentreOn::SetNewValue().

◆ AddWorldIfEmpty()

G4bool G4Scene::AddWorldIfEmpty ( G4bool  warn = false)

Definition at line 124 of file G4Scene.cc.

124 {
125 G4bool successful = true;
126 if (IsEmpty ()) {
127 successful = false;
128 G4VPhysicalVolume* pWorld =
130 -> GetNavigatorForTracking () -> GetWorldVolume ();
131 if (pWorld) {
132 const G4VisAttributes* pVisAttribs =
133 pWorld -> GetLogicalVolume () -> GetVisAttributes ();
134 if (!pVisAttribs || pVisAttribs -> IsVisible ()) {
135 if (warn) {
136 G4warn <<
137 "Your \"world\" has no vis attributes or is marked as visible."
138 "\n For a better view of the contents, mark the world as"
139 " invisible, e.g.,"
140 "\n myWorldLogicalVol ->"
141 " SetVisAttributes (G4VisAttributes::GetInvisible());"
142 << G4endl;
143 }
144 }
145 successful = AddRunDurationModel (new G4PhysicalVolumeModel (pWorld));
146 // Note: default depth and no modeling parameters.
147 if (successful) {
148 if (warn) {
149 G4warn <<
150 "G4Scene::AddWorldIfEmpty: The scene had no extent."
151 "\n \"world\" has been added.";
152 G4warn << G4endl;
153 }
154 }
155 }
156 }
157 return successful;
158}
bool G4bool
Definition: G4Types.hh:86
G4bool AddRunDurationModel(G4VModel *, G4bool warn=false)
Definition: G4Scene.cc:160
G4bool IsEmpty() const
static G4TransportationManager * GetTransportationManager()

Referenced by G4RayTracerSceneHandler::G4RayTracerSceneHandler().

◆ CalculateExtent()

void G4Scene::CalculateExtent ( )

Definition at line 64 of file G4Scene.cc.

65{
66 G4BoundingExtentScene boundingExtentScene;
67
68 for (size_t i = 0; i < fRunDurationModelList.size(); i++) {
69 if (fRunDurationModelList[i].fActive) {
70 G4VModel* model = fRunDurationModelList[i].fpModel;
71 if (model -> Validate()) {
72 const G4VisExtent& thisExtent = model -> GetExtent ();
73 if (thisExtent != G4VisExtent::GetNullExtent()) {
74 boundingExtentScene.AccrueBoundingExtent(thisExtent);
75 }
76 } else {
77 PrintInvalidModel(model);
78 }
79 }
80 }
81
82 for (size_t i = 0; i < fEndOfEventModelList.size(); i++) {
83 if (fEndOfEventModelList[i].fActive) {
84 G4VModel* model = fEndOfEventModelList[i].fpModel;
85 if (model -> Validate()) {
86 const G4VisExtent& thisExtent = model -> GetExtent ();
87 if (thisExtent != G4VisExtent::GetNullExtent()) {
88 boundingExtentScene.AccrueBoundingExtent(thisExtent);
89 }
90 } else {
91 PrintInvalidModel(model);
92 }
93 }
94 }
95
96 for (size_t i = 0; i < fEndOfRunModelList.size(); i++) {
97 if (fEndOfRunModelList[i].fActive) {
98 G4VModel* model = fEndOfRunModelList[i].fpModel;
99 if (model -> Validate()) {
100 const G4VisExtent& thisExtent = model -> GetExtent ();
101 if (thisExtent != G4VisExtent::GetNullExtent()) {
102 boundingExtentScene.AccrueBoundingExtent(thisExtent);
103 }
104 } else {
105 PrintInvalidModel(model);
106 }
107 }
108 }
109
110 fExtent = boundingExtentScene.GetBoundingExtent ();
111 fStandardTargetPoint = fExtent.GetExtentCentre ();
112 if (fExtent.GetExtentRadius() <= 0.) {
114 ("G4Scene::CalculateExtent",
115 "visman0202", JustWarning,
116 "Scene has no extent. Please activate or add something."
117 "\nThe camera needs to have something to point at!"
118 "\nAdd a volume. (You may need \"/run/initialize\".)"
119 "\nOr use \"/vis/scene/add/extent\"."
120 "\n\"/vis/scene/list\" to see list of models.");
121 }
122}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
void AccrueBoundingExtent(const G4VisExtent &)
const G4VisExtent & GetBoundingExtent() const
const G4VisExtent & GetExtent() const
static const G4VisExtent & GetNullExtent()
Definition: G4VisExtent.cc:60
G4double GetExtentRadius() const
Definition: G4VisExtent.cc:75
const G4Point3D & GetExtentCentre() const
Definition: G4VisExtent.cc:65

Referenced by AddEndOfEventModel(), AddEndOfRunModel(), AddRunDurationModel(), G4VisManager::GeometryHasChanged(), G4VisManager::NotifyHandlers(), and G4VisCommandSceneNotifyHandlers::SetNewValue().

◆ GetEndOfEventModelList()

const std::vector< Model > & G4Scene::GetEndOfEventModelList ( ) const

◆ GetEndOfRunModelList()

const std::vector< Model > & G4Scene::GetEndOfRunModelList ( ) const

◆ GetExtent()

◆ GetMaxNumberOfKeptEvents()

G4int G4Scene::GetMaxNumberOfKeptEvents ( ) const

◆ GetName()

◆ GetRefreshAtEndOfEvent()

◆ GetRefreshAtEndOfRun()

◆ GetRunDurationModelList()

◆ GetStandardTargetPoint()

◆ IsEmpty()

G4bool G4Scene::IsEmpty ( ) const

Referenced by AddWorldIfEmpty().

◆ operator!=()

G4bool G4Scene::operator!= ( const G4Scene scene) const

Definition at line 283 of file G4Scene.cc.

283 {
284 if (
285 (fRunDurationModelList.size () !=
286 scene.fRunDurationModelList.size ()) ||
287 (fEndOfEventModelList.size () !=
288 scene.fEndOfEventModelList.size ()) ||
289 (fEndOfRunModelList.size () !=
290 scene.fEndOfRunModelList.size ()) ||
291 (fExtent != scene.fExtent) ||
292 !(fStandardTargetPoint == scene.fStandardTargetPoint) ||
293 fRefreshAtEndOfEvent != scene.fRefreshAtEndOfEvent ||
294 fRefreshAtEndOfRun != scene.fRefreshAtEndOfRun ||
295 fMaxNumberOfKeptEvents != scene.fMaxNumberOfKeptEvents
296 ) return true;
297
298 /* A complete comparison should, perhaps, include a comparison of
299 individual models, but it is not easy to implement operator!= for
300 all models. Also, it would be unfeasible to ask users to
301 implement opeerator!= if we ever get round to allowing
302 user-defined models. Moreover, there is no editing of G4Scene
303 objects, apart from changing fRefreshAtEndOfEvent, etc; as far as
304 models are concerned, all you can ever do is add them, so a test
305 on size (above) is enough.
306
307 for (size_t i = 0; i < fRunDurationModelList.size (); i++) {
308 if (fRunDurationModelList[i] != scene.fRunDurationModelList[i])
309 return true;
310 }
311
312 for (size_t i = 0; i < fEndOfEventModelList.size (); i++) {
313 if (fEndOfEventModelList[i] != scene.fEndOfEventModelList[i])
314 return true;
315 }
316
317 for (size_t i = 0; i < fEndOfRunModelList.size (); i++) {
318 if (fEndOfRunModelList[i] != scene.fEndOfRunModelList[i])
319 return true;
320 }
321 */
322
323 return false;
324}

◆ operator==()

G4bool G4Scene::operator== ( const G4Scene ) const

◆ SetEndOfEventModelList()

std::vector< Model > & G4Scene::SetEndOfEventModelList ( )

◆ SetEndOfRunModelList()

std::vector< Model > & G4Scene::SetEndOfRunModelList ( )

◆ SetMaxNumberOfKeptEvents()

void G4Scene::SetMaxNumberOfKeptEvents ( G4int  )

◆ SetName()

void G4Scene::SetName ( const G4String )

◆ SetRefreshAtEndOfEvent()

void G4Scene::SetRefreshAtEndOfEvent ( G4bool  )

◆ SetRefreshAtEndOfRun()

void G4Scene::SetRefreshAtEndOfRun ( G4bool  )

◆ SetRunDurationModelList()

std::vector< Model > & G4Scene::SetRunDurationModelList ( )

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const G4Scene d 
)
friend

Definition at line 226 of file G4Scene.cc.

226 {
227
228 size_t i;
229
230 os << "Scene data:";
231
232 os << "\n Run-duration model list:";
233 if (scene.fRunDurationModelList.size () == 0) {
234 os << " none";
235 }
236 for (i = 0; i < scene.fRunDurationModelList.size (); i++) {
237 if (scene.fRunDurationModelList[i].fActive) os << "\n Active: ";
238 else os << "\n Inactive: ";
239 os << *(scene.fRunDurationModelList[i].fpModel);
240 }
241
242 os << "\n End-of-event model list:";
243 if (scene.fEndOfEventModelList.size () == 0) {
244 os << " none";
245 }
246 for (i = 0; i < scene.fEndOfEventModelList.size (); i++) {
247 if (scene.fEndOfEventModelList[i].fActive) os << "\n Active: ";
248 else os << "\n Inactive: ";
249 os << *(scene.fEndOfEventModelList[i].fpModel);
250 }
251
252 os << "\n End-of-run model list:";
253 if (scene.fEndOfRunModelList.size () == 0) {
254 os << " none";
255 }
256 for (i = 0; i < scene.fEndOfRunModelList.size (); i++) {
257 if (scene.fEndOfRunModelList[i].fActive) os << "\n Active: ";
258 else os << "\n Inactive: ";
259 os << *(scene.fEndOfRunModelList[i].fpModel);
260 }
261
262 os << "\n Overall extent or bounding box: " << scene.fExtent;
263
264 os << "\n Standard target point: " << scene.fStandardTargetPoint;
265
266 os << "\n End of event action set to \"";
267 if (scene.fRefreshAtEndOfEvent) os << "refresh\"";
268 else {
269 os << "accumulate (maximum number of kept events: ";
270 if (scene.fMaxNumberOfKeptEvents >= 0) os << scene.fMaxNumberOfKeptEvents;
271 else os << "unlimited";
272 os << ")";
273 }
274
275 os << "\n End of run action set to \"";
276 if (scene.fRefreshAtEndOfRun) os << "refresh";
277 else os << "accumulate";
278 os << "\"";
279
280 return os;
281}

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