Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 49 of file G4Scene.hh.

Member Enumeration Documentation

anonymous enum
Enumerator
UNLIMITED 

Definition at line 55 of file G4Scene.hh.

55 {UNLIMITED = -1};

Constructor & Destructor Documentation

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

Definition at line 40 of file G4Scene.cc.

40  :
41  fName (name),
42  fRefreshAtEndOfEvent(true),
43  fRefreshAtEndOfRun(true),
44  fMaxNumberOfKeptEvents(100)
45 {} // Note all other data members have default initial values.
G4Scene::~G4Scene ( )

Definition at line 47 of file G4Scene.cc.

47 {}

Member Function Documentation

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

Definition at line 192 of file G4Scene.cc.

192  {
193  G4int i, nModels = fEndOfEventModelList.size ();
194  for (i = 0; i < nModels; i++) {
195  if (pModel -> GetGlobalDescription () ==
196  fEndOfEventModelList[i].fpModel -> GetGlobalDescription ()) break;
197  }
198  if (i < nModels) {
199  if (warn) {
200  G4cout << "G4Scene::AddEndOfEventModel: a model \""
201  << pModel -> GetGlobalDescription ()
202  << "\"\n is already in the end-of-event list of scene \""
203  << fName << "\"."
204  << G4endl;
205  }
206  return false;
207  }
208  fEndOfEventModelList.push_back (Model(pModel));
209  return true;
210 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
G4bool G4Scene::AddEndOfRunModel ( G4VModel pModel,
G4bool  warn = false 
)

Definition at line 212 of file G4Scene.cc.

212  {
213  G4int i, nModels = fEndOfRunModelList.size ();
214  for (i = 0; i < nModels; i++) {
215  if (pModel -> GetGlobalDescription () ==
216  fEndOfRunModelList[i].fpModel -> GetGlobalDescription ()) break;
217  }
218  if (i < nModels) {
219  if (warn) {
220  G4cout << "G4Scene::AddEndOfRunModel: a model \""
221  << pModel -> GetGlobalDescription ()
222  << "\"\n is already in the end-of-run list of scene \""
223  << fName << "\"."
224  << G4endl;
225  }
226  return false;
227  }
228  fEndOfRunModelList.push_back (pModel);
229  return true;
230 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
G4bool G4Scene::AddRunDurationModel ( G4VModel pModel,
G4bool  warn = false 
)

Definition at line 49 of file G4Scene.cc.

49  {
50  std::vector<Model>::const_iterator i;
51  for (i = fRunDurationModelList.begin ();
52  i != fRunDurationModelList.end (); ++i) {
53  if (pModel -> GetGlobalDescription () ==
54  i->fpModel->GetGlobalDescription ()) break;
55  }
56  if (i != fRunDurationModelList.end ()) {
57  if (warn) {
58  G4cout << "G4Scene::AddRunDurationModel: model \""
59  << pModel -> GetGlobalDescription ()
60  << "\"\n is already in the run-duration list of scene \""
61  << fName
62  << "\"."
63  << G4endl;
64  }
65  return false;
66  }
67  fRunDurationModelList.push_back (Model(pModel));
68  CalculateExtent ();
69  return true;
70 }
G4GLOB_DLL std::ostream G4cout
const G4String & GetGlobalDescription() const
void CalculateExtent()
Definition: G4Scene.cc:72
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool G4Scene::AddWorldIfEmpty ( G4bool  warn = false)

Definition at line 156 of file G4Scene.cc.

156  {
157  G4bool successful = true;
158  if (IsEmpty ()) {
159  successful = false;
160  G4VPhysicalVolume* pWorld =
162  -> GetNavigatorForTracking () -> GetWorldVolume ();
163  if (pWorld) {
164  const G4VisAttributes* pVisAttribs =
165  pWorld -> GetLogicalVolume () -> GetVisAttributes ();
166  if (!pVisAttribs || pVisAttribs -> IsVisible ()) {
167  if (warn) {
168  G4cout <<
169  "Your \"world\" has no vis attributes or is marked as visible."
170  "\n For a better view of the contents, mark the world as"
171  " invisible, e.g.,"
172  "\n myWorldLogicalVol ->"
173  " SetVisAttributes (G4VisAttributes::GetInvisible());"
174  << G4endl;
175  }
176  }
177  successful = AddRunDurationModel (new G4PhysicalVolumeModel (pWorld));
178  // Note: default depth and no modeling parameters.
179  if (successful) {
180  if (warn) {
181  G4cout <<
182  "G4Scene::AddWorldIfEmpty: The scene was empty of run-duration models."
183  "\n \"world\" has been added.";
184  G4cout << G4endl;
185  }
186  }
187  }
188  }
189  return successful;
190 }
G4bool IsEmpty() const
G4GLOB_DLL std::ostream G4cout
G4bool AddRunDurationModel(G4VModel *, G4bool warn=false)
Definition: G4Scene.cc:49
bool G4bool
Definition: G4Types.hh:79
static G4TransportationManager * GetTransportationManager()
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Here is the caller graph for this function:

void G4Scene::CalculateExtent ( )

Definition at line 72 of file G4Scene.cc.

73 {
74  G4BoundingSphereScene boundingSphereScene;
75 
76  for (size_t i = 0; i < fRunDurationModelList.size(); i++) {
77  if (fRunDurationModelList[i].fActive) {
78  G4VModel* model = fRunDurationModelList[i].fpModel;
79  if (model -> Validate()) { // Validates and also recomputes extent.
80  const G4VisExtent& thisExtent = model -> GetExtent ();
81  G4double thisRadius = thisExtent.GetExtentRadius ();
82  if (thisRadius > 0.) {
83  G4Point3D thisCentre = thisExtent.GetExtentCentre ();
84  thisCentre.transform (model -> GetTransformation ());
85  boundingSphereScene.AccrueBoundingSphere (thisCentre, thisRadius);
86  }
87  } else {
89  ed << "Invalid model \"" << model->GetGlobalDescription()
90  << "\".\n Not included in extent calculation.";
92  ("G4Scene::CalculateExtent",
93  "visman0201", JustWarning, ed);
94  }
95  }
96  }
97 
98  for (size_t i = 0; i < fEndOfEventModelList.size(); i++) {
99  if (fEndOfEventModelList[i].fActive) {
100  G4VModel* model = fEndOfEventModelList[i].fpModel;
101  if (model -> Validate()) { // Validates and also recomputes extent.
102  const G4VisExtent& thisExtent = model -> GetExtent ();
103  G4double thisRadius = thisExtent.GetExtentRadius ();
104  if (thisRadius > 0.) {
105  G4Point3D thisCentre = thisExtent.GetExtentCentre ();
106  thisCentre.transform (model -> GetTransformation ());
107  boundingSphereScene.AccrueBoundingSphere (thisCentre, thisRadius);
108  }
109  } else {
111  ed << "Invalid model \"" << model->GetGlobalDescription()
112  << "\".\n Not included in extent calculation.";
114  ("G4Scene::CalculateExtent",
115  "visman0201", JustWarning, ed);
116  }
117  }
118  }
119 
120  for (size_t i = 0; i < fEndOfRunModelList.size(); i++) {
121  if (fEndOfRunModelList[i].fActive) {
122  G4VModel* model = fEndOfRunModelList[i].fpModel;
123  if (model -> Validate()) { // Validates and also recomputes extent.
124  const G4VisExtent& thisExtent = model -> GetExtent ();
125  G4double thisRadius = thisExtent.GetExtentRadius ();
126  if (thisRadius > 0.) {
127  G4Point3D thisCentre = thisExtent.GetExtentCentre ();
128  thisCentre.transform (model -> GetTransformation ());
129  boundingSphereScene.AccrueBoundingSphere (thisCentre, thisRadius);
130  }
131  } else {
133  ed << "Invalid model \"" << model->GetGlobalDescription()
134  << "\".\n Not included in extent calculation.";
136  ("G4Scene::CalculateExtent",
137  "visman0201", JustWarning, ed);
138  }
139  }
140  }
141 
142  fExtent = boundingSphereScene.GetBoundingSphereExtent ();
143  fStandardTargetPoint = fExtent.GetExtentCentre ();
144  if (fExtent.GetExtentRadius() <= 0.) {
146  ("G4Scene::CalculateExtent",
147  "visman0202", JustWarning,
148  "Scene has no extent. Please activate or add something."
149  "\nThe camera needs to have something to point at!"
150  "\nAdd a volume. (You may need \"/run/initialize\".)"
151  "\nOr use \"/vis/scene/add/extent\"."
152  "\n\"/vis/scene/list\" to see list of models.");
153  }
154 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
const G4Point3D & GetExtentCentre() const
Definition: G4VisExtent.cc:63
G4double GetExtentRadius() const
Definition: G4VisExtent.cc:73
const G4VisExtent & GetExtent() const
const G4String & GetGlobalDescription() const
G4VisExtent GetBoundingSphereExtent()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void AccrueBoundingSphere(const G4Point3D &centre, G4double radius)
double G4double
Definition: G4Types.hh:76
const XML_Char XML_Content * model
Definition: expat.h:151

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the caller graph for this function:

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

Here is the caller graph for this function:

G4int G4Scene::GetMaxNumberOfKeptEvents ( ) const
const G4String& G4Scene::GetName ( ) const

Here is the caller graph for this function:

G4bool G4Scene::GetRefreshAtEndOfEvent ( ) const

Here is the caller graph for this function:

G4bool G4Scene::GetRefreshAtEndOfRun ( ) const

Here is the caller graph for this function:

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

Here is the caller graph for this function:

const G4Point3D& G4Scene::GetStandardTargetPoint ( ) const

Here is the caller graph for this function:

G4bool G4Scene::IsEmpty ( ) const

Here is the caller graph for this function:

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

Definition at line 280 of file G4Scene.cc.

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

Here is the caller graph for this function:

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

Here is the caller graph for this function:

void G4Scene::SetMaxNumberOfKeptEvents ( G4int  )

Here is the caller graph for this function:

void G4Scene::SetName ( const G4String )
void G4Scene::SetRefreshAtEndOfEvent ( G4bool  )

Here is the caller graph for this function:

void G4Scene::SetRefreshAtEndOfRun ( G4bool  )

Here is the caller graph for this function:

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

Here is the caller graph for this function:

Friends And Related Function Documentation

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

Definition at line 232 of file G4Scene.cc.

232  {
233 
234  size_t i;
235 
236  os << "Scene data:";
237 
238  os << "\n Run-duration model list:";
239  for (i = 0; i < scene.fRunDurationModelList.size (); i++) {
240  if (scene.fRunDurationModelList[i].fActive) os << "\n Active: ";
241  else os << "\n Inactive: ";
242  os << *(scene.fRunDurationModelList[i].fpModel);
243  }
244 
245  os << "\n End-of-event model list:";
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  for (i = 0; i < scene.fEndOfRunModelList.size (); i++) {
254  if (scene.fEndOfRunModelList[i].fActive) os << "\n Active: ";
255  else os << "\n Inactive: ";
256  os << *(scene.fEndOfRunModelList[i].fpModel);
257  }
258 
259  os << "\n Extent or bounding box: " << scene.fExtent;
260 
261  os << "\n Standard target point: " << scene.fStandardTargetPoint;
262 
263  os << "\n End of event action set to \"";
264  if (scene.fRefreshAtEndOfEvent) os << "refresh\"";
265  else {
266  os << "accumulate (maximum number of kept events: ";
267  if (scene.fMaxNumberOfKeptEvents >= 0) os << scene.fMaxNumberOfKeptEvents;
268  else os << "unlimited";
269  os << ")";
270  }
271 
272  os << "\n End of run action set to \"";
273  if (scene.fRefreshAtEndOfRun) os << "refresh";
274  else os << "accumulate";
275  os << "\"";
276 
277  return os;
278 }

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