Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JA Namespace Reference

Classes

struct  Node
 

Typedefs

typedef
G4PhysicalVolumeModel::G4PhysicalVolumeNodeID 
PVNodeID
 
typedef std::vector< PVNodeIDPVPath
 

Functions

void Insert (const PVNodeID *pvPath, size_t pathLength, G4int index, Node *node)
 
void PrintTree (std::ostream &, Node *)
 
void Clear (Node *)
 

Typedef Documentation

typedef std::vector<PVNodeID> JA::PVPath

Definition at line 46 of file G4XXXSGSceneHandler.hh.

Function Documentation

void JA::Clear ( Node *  node)

Definition at line 485 of file G4XXXSGSceneHandler.cc.

486 {
487  const size_t& nDaughters = node->fDaughters.size();
488  for (size_t i = 0; i < nDaughters; ++i) {
489  Clear(node->fDaughters[i]);
490  delete node->fDaughters[i];
491  }
492 }
void Clear(Node *)

Here is the caller graph for this function:

void JA::Insert ( const PVNodeID *  pvPath,
size_t  pathLength,
G4int  index,
Node *  node 
)

Definition at line 418 of file G4XXXSGSceneHandler.cc.

419  {
420  // Path passed as a PVNodeID* to avoid copying.
421 
422  /* Debug
423  for (size_t i = 0; i < pathLength; ++i) {
424  std::cout << pvPath[i].GetPhysicalVolume()->GetName() << ":"
425  << pvPath[i].GetCopyNo() << " ("
426  << index << "), ";
427  }
428  */
429 
430  // See if node has been encountered before
431  G4bool found = false; size_t foundPosition = 0;
432  for (size_t i = 0; i < node->fDaughters.size(); ++i) {
433  PVNodeID& daughterPVNodeID = node->fDaughters[i]->fPVNodeID;
434  // It is enough to compare volume and copy number at a given position in the tree
435  if (daughterPVNodeID.GetPhysicalVolume() == pvPath[0].GetPhysicalVolume() &&
436  daughterPVNodeID.GetCopyNo() == pvPath[0].GetCopyNo()) {
437  found = true;
438  foundPosition = i;
439  break;
440  }
441  }
442 
443  if (pathLength == 1) { // This is a leaf
444  if (found) { // Update index
445  node->fDaughters[foundPosition]->fIndex = index;
446  } else { // Make a new full entry
447  node->fDaughters.push_back(new Node(pvPath[0],index));
448  }
449  /* Debug
450  std::cout << std::endl;
451  */
452  } else { // Not a leaf - carry on with rest of path
453  if (found) { // Just carry on
454  Insert(pvPath+1,--pathLength,index,
455  node->fDaughters[foundPosition]);
456  } else { // Insert place holder, then carry on
457  node->fDaughters.push_back(new Node(pvPath[0]));
458  Insert(pvPath+1,--pathLength,index,
459  node->fDaughters[node->fDaughters.size()-1]);
460  }
461  }
462 }
bool G4bool
Definition: G4Types.hh:79
G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID
void Insert(const PVNodeID *pvPath, size_t pathLength, G4int index, Node *node)

Here is the call graph for this function:

Here is the caller graph for this function:

void JA::PrintTree ( std::ostream &  os,
Node *  node 
)

Definition at line 464 of file G4XXXSGSceneHandler.cc.

465 {
466  static G4int depth = -1;
467  depth++;
468  PVNodeID& thisPVNodeID = node->fPVNodeID;
469  G4int& thisIndex = node->fIndex;
470  const size_t& nDaughters = node->fDaughters.size();
471  G4VPhysicalVolume* thisPhysicalVolume= thisPVNodeID.GetPhysicalVolume();
472  if (!thisPhysicalVolume) os << "Root" << std::endl;
473  else {
474  for (G4int i = 0; i < depth; ++i) os << "__";
475  os << thisPVNodeID.GetPhysicalVolume()->GetName() << ":"
476  << thisPVNodeID.GetCopyNo() << " ("
477  << thisIndex << ")" << std::endl;;
478  }
479  for (size_t i = 0; i < nDaughters; ++i) {
480  PrintTree(os, node->fDaughters[i]);
481  }
482  depth--;
483 }
void PrintTree(std::ostream &, Node *)
int G4int
Definition: G4Types.hh:78
const G4String & GetName() const
G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID

Here is the call graph for this function:

Here is the caller graph for this function: