JA Namespace Reference


Data Structures

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 G4PhysicalVolumeModel::G4PhysicalVolumeNodeID JA::PVNodeID

Definition at line 45 of file G4XXXSGSceneHandler.hh.

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

Definition at line 46 of file G4XXXSGSceneHandler.hh.


Function Documentation

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

Definition at line 427 of file G4XXXSGSceneHandler.cc.

References JA::Node::fDaughters, G4PhysicalVolumeModel::G4PhysicalVolumeNodeID::GetCopyNo(), G4VPhysicalVolume::GetCopyNo(), and G4PhysicalVolumeModel::G4PhysicalVolumeNodeID::GetPhysicalVolume().

Referenced by G4SmartVoxelHeader::BuildConsumedNodes(), G4SmartVoxelHeader::BuildNodes(), and G4XXXSGSceneHandler::CreateCurrentItem().

00428                                          {
00429   // Path passed as a PVNodeID* to avoid copying.
00430 
00431   /* Debug
00432   for (size_t i = 0; i < pathLength; ++i) {
00433     std::cout << pvPath[i].GetPhysicalVolume()->GetName() << ":"
00434               << pvPath[i].GetCopyNo() << " ("
00435               << index << "), ";
00436   }
00437   */
00438 
00439   // See if node has been encountered before
00440   G4bool found = false; size_t foundPosition = 0;
00441   for (size_t i = 0; i < node->fDaughters.size(); ++i) {
00442     PVNodeID& daughterPVNodeID = node->fDaughters[i]->fPVNodeID;
00443     // It is enough to compare volume and copy number at a given position in the tree
00444     if (daughterPVNodeID.GetPhysicalVolume() == pvPath[0].GetPhysicalVolume() &&
00445         daughterPVNodeID.GetCopyNo() == pvPath[0].GetCopyNo()) {
00446       found = true;
00447       foundPosition = i;
00448       break;
00449     }
00450   }
00451 
00452   if (pathLength == 1) {  // This is a leaf
00453     if (found) {  // Update index
00454       node->fDaughters[foundPosition]->fIndex = index;
00455     } else {      // Make a new full entry
00456       node->fDaughters.push_back(new Node(pvPath[0],index));
00457     }
00458     /* Debug
00459     std::cout << std::endl;
00460     */
00461   } else {  // Not a leaf - carry on with rest of path
00462     if (found) {  // Just carry on
00463       Insert(pvPath+1,--pathLength,index,
00464              node->fDaughters[foundPosition]);
00465     } else {      // Insert place holder, then carry on
00466       node->fDaughters.push_back(new Node(pvPath[0]));
00467       Insert(pvPath+1,--pathLength,index,
00468              node->fDaughters[node->fDaughters.size()-1]);
00469     }
00470   }
00471 }

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

Definition at line 473 of file G4XXXSGSceneHandler.cc.

References JA::Node::fDaughters, JA::Node::fIndex, JA::Node::fPVNodeID, G4PhysicalVolumeModel::G4PhysicalVolumeNodeID::GetCopyNo(), G4VPhysicalVolume::GetName(), and G4PhysicalVolumeModel::G4PhysicalVolumeNodeID::GetPhysicalVolume().

Referenced by G4XXXSGViewer::DrawFromStore().

00474 {
00475   static G4int depth = -1;
00476   depth++;
00477   PVNodeID& thisPVNodeID = node->fPVNodeID;
00478   G4int& thisIndex = node->fIndex;
00479   const size_t& nDaughters = node->fDaughters.size();
00480   G4VPhysicalVolume* thisPhysicalVolume= thisPVNodeID.GetPhysicalVolume();
00481   if (!thisPhysicalVolume) os << "Root" << std::endl;
00482   else {
00483     for (G4int i = 0; i < depth; ++i) os << "__";
00484     os << thisPVNodeID.GetPhysicalVolume()->GetName() << ":"
00485        << thisPVNodeID.GetCopyNo() << " ("
00486        << thisIndex << ")" << std::endl;;
00487   }
00488   for (size_t i = 0; i < nDaughters; ++i) {
00489     PrintTree(os, node->fDaughters[i]);
00490   }
00491   depth--;
00492 }

void JA::Clear ( Node *   ) 

Definition at line 494 of file G4XXXSGSceneHandler.cc.

References JA::Node::fDaughters.

Referenced by G4XXXSGSceneHandler::ClearStore(), and G4XXXSGSceneHandler::ClearTransientStore().

00495 {
00496   const size_t& nDaughters = node->fDaughters.size();
00497   for (size_t i = 0; i < nDaughters; ++i) {
00498     Clear(node->fDaughters[i]);
00499     delete node->fDaughters[i];
00500   }
00501 }


Generated on Mon May 27 17:54:09 2013 for Geant4 by  doxygen 1.4.7