Print

Print


Commit in lcdd on MAIN
include/GeometryManager.hh+18-41.8 -> 1.9
src/GeometryManager.cc+35-91.9 -> 1.10
   /LCDDMessenger.cc+12-51.5 -> 1.6
+65-18
3 modified files
JM: Overlap check, work in progress.

lcdd/include
GeometryManager.hh 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- GeometryManager.hh	17 Nov 2006 02:16:35 -0000	1.8
+++ GeometryManager.hh	17 Nov 2006 04:42:59 -0000	1.9
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/GeometryManager.hh,v 1.8 2006/11/17 02:16:35 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/GeometryManager.hh,v 1.9 2006/11/17 04:42:59 jeremy Exp $
 
 #ifndef GEOMETRYMANAGER_HH
 #define GEOMETRYMANAGER_HH 1
@@ -6,6 +6,7 @@
 class G4Run;
 class G4LogicalVolume;
 class G4VPhysicalVolume;
+class G4String;
 
 /**
  * @class GeometryManager
@@ -27,9 +28,22 @@
   void beginRun(const G4Run*);    
   void setupWorldRegionInformation();
 
-  // Check overlaps using G4PVPlacement::CheckOverlaps() on the 
-  // current world volume registered with Geant4.
-  const void checkOverlaps() const;
+  /**
+   * Check overlaps on all logical volumes registered with Geant4.
+   */
+  void checkOverlaps() const;
+
+  /**
+   * Check for overlaps by calling CheckOverlaps on all daughters
+   * of a given logical volume.
+   */
+  void checkOverlaps(G4LogicalVolume*) const;
+
+  /**
+   * Check for overlaps of a named logical volume by looking it
+   * up in the volume store.
+   */
+  void checkOverlaps(const G4String&) const;
 
 private:
 

lcdd/src
GeometryManager.cc 1.9 -> 1.10
diff -u -r1.9 -r1.10
--- GeometryManager.cc	17 Nov 2006 02:16:36 -0000	1.9
+++ GeometryManager.cc	17 Nov 2006 04:43:00 -0000	1.10
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/GeometryManager.cc,v 1.9 2006/11/17 02:16:36 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/GeometryManager.cc,v 1.10 2006/11/17 04:43:00 jeremy Exp $
 #include "GeometryManager.hh"
 
 // LCDD
@@ -13,7 +13,9 @@
 #include "G4LogicalVolume.hh"
 #include "G4VisAttributes.hh"
 #include "G4PVPlacement.hh"
+#include "G4LogicalVolumeStore.hh"
 #include "G4TransportationManager.hh"
+#include "G4Navigator.hh"
 
 GeometryManager* GeometryManager::m_instance = 0;
 
@@ -68,15 +70,39 @@
   m_worldRegionIsSetup = true;
 }
 
-const void GeometryManager::checkOverlaps() const
+void GeometryManager::checkOverlaps() const
 {
-  G4VPhysicalVolume* world = getWorldPhysicalVolume();
-  if (world) {
-    G4cout << "Running overlap check on world volume ..." << G4endl;
-    ((G4PVPlacement*)world)->CheckOverlaps();
-    G4cout << "Done with overlap check." << G4endl;
+  G4LogicalVolumeStore* store = G4LogicalVolumeStore::GetInstance();
+  for (std::vector<G4LogicalVolume*>::iterator it = store->begin();
+       it != store->end();
+       it++) {
+    G4LogicalVolume* vol = (*it);
+    checkOverlaps(vol);
   }
-  else {
-    G4cerr << "Failed to run overlap check.  The world volume does not exist!" << G4endl;
+}
+
+void GeometryManager::checkOverlaps(G4LogicalVolume* lvolume) const
+{
+  if (lvolume==0) return;
+  for (G4int i=0; i<lvolume->GetNoDaughters(); i++) {
+    G4PVPlacement* dau = static_cast<G4PVPlacement*>(lvolume->GetDaughter(i));
+    if (dau) {
+      dau->CheckOverlaps();
+    }
   }
 }
+
+void GeometryManager::checkOverlaps(const G4String& name) const
+{
+  G4LogicalVolumeStore* store = G4LogicalVolumeStore::GetInstance();
+  for (std::vector<G4LogicalVolume*>::iterator it = store->begin();
+       it != store->end();
+       it++) {
+    G4LogicalVolume* vol = (*it);
+    if (vol->GetName() == name) {
+      checkOverlaps(vol);
+    }
+  }   
+  G4cerr << "The volume <" << name << "> was not found!" << G4endl;
+}
+

lcdd/src
LCDDMessenger.cc 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- LCDDMessenger.cc	17 Nov 2006 02:16:36 -0000	1.5
+++ LCDDMessenger.cc	17 Nov 2006 04:43:00 -0000	1.6
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/LCDDMessenger.cc,v 1.5 2006/11/17 02:16:36 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/LCDDMessenger.cc,v 1.6 2006/11/17 04:43:00 jeremy Exp $
 
 // LCDD
 #include "LCDDMessenger.hh"
@@ -8,7 +8,6 @@
 // Geant4
 #include "G4UImessenger.hh"
 #include "G4UIcommand.hh"
-#include "G4UIcmdWithoutParameter.hh"
 #include "G4UIdirectory.hh"
 
 #include <cassert>
@@ -58,7 +57,12 @@
     parser->setVersion(version);
   }
   else if ( cmd == m_checkOverlapsCmd ) {
-    GeometryManager::instance()->checkOverlaps();
+    if (newVals != "") {
+      GeometryManager::instance()->checkOverlaps(newVals);
+    }
+    else {
+      GeometryManager::instance()->checkOverlaps();
+    }
   }
   else {
     G4cerr << "WARNING: Unknown cmd to LCDDMessenger - " << cmd << G4endl;
@@ -117,6 +121,9 @@
   m_setupCmd->SetParameter(p);
 
   // Check overlaps.
-  m_checkOverlapsCmd = new G4UIcmdWithoutParameter("/lcdd/check_overlaps",this); 
-  m_checkOverlapsCmd->SetGuidance("Call CheckOverlaps on the world volume.");  
+  m_checkOverlapsCmd = new G4UIcommand("/lcdd/checkOverlaps",this);
+  m_checkOverlapsCmd->SetGuidance("Call CheckOverlaps on a given volume or all volumes (no argument).");  
+
+  p = new G4UIparameter("Volume",'s',true);
+  m_checkOverlapsCmd->SetParameter(p);
 }
CVSspam 0.2.8