GeomConverter/src/org/lcsim/detector
diff -u -r1.7 -r1.8
--- GeometryInfo.java 20 Mar 2007 00:47:17 -0000 1.7
+++ GeometryInfo.java 20 Mar 2007 01:16:46 -0000 1.8
@@ -21,23 +21,36 @@
IGeometryInfoContainer childIGeometryInfos;
IGeometryInfo parentIGeometryInfo;
IPhysicalVolumePath support;
- IPhysicalVolumeNavigator navigator;
ILogicalVolume logicalVolume;
ITransform3D globalToLocal;
ITransform3D localToGlobal;
ITransform3D parentToLocal;
Hep3Vector globalPosition;
+ /**
+ *
+ * This method provides a single point of entry
+ * for setting up a GeometryInfo object. Any
+ * of the arguments except for @param de are
+ * allowed to be null.
+ *
+ * @param de The DetectorElement that owns this GeometryInfo.
+ * @param lv The associated LogicalVolume.
+ * @param support The path into the geometry that is associated
+ * with this DetectorElement.
+ */
private void setup(
IDetectorElement de,
+ ILogicalVolume logicalVolume,
IPhysicalVolumePath support)
{
+ // The DetectorElement is not allowed to be null.
if ( de == null )
{
throw new IllegalArgumentException("The IDetectorElement is null!");
}
- // Set the ref to the DetectorElement.
+ // Set the DetectorElement.
this.de = de;
// Cache child IGeometryInfos.
@@ -58,34 +71,64 @@
{
this.parentIGeometryInfo = de.getParent().getGeometry();
}
+
+ // Set the LogicalVolume, if it is given explicitly.
+ if ( logicalVolume != null )
+ {
+ this.logicalVolume = logicalVolume;
+ }
+ // If the DetectorElement has support in the geometry tree,
+ // set the support variable and cache all the derivable geometry
+ // information.
if ( support != null )
{
- // Set the support reference.
- this.support = support;
-
- // Cache a PhysicalVolumeNavigator.
- navigator = new PhysicalVolumeNavigator(support.toString(), support.getTopVolume());
+ setupSupport(support);
+ }
+ }
+
+ private void setupSupport(
+ IPhysicalVolumePath support
+ )
+ {
+ if ( this.support != null )
+ {
+ throw new RuntimeException("The DetectorElement already has support in the geometry!");
+ }
+
+ if ( support == null )
+ {
+ throw new IllegalArgumentException("The IPhysicalVolumePath is null!");
+ }
+
+ // Set the support reference.
+ this.support = support;
+
+ // Get the current geometry navigator.
+ IPhysicalVolumeNavigator navigator =
+ PhysicalVolumeNavigatorStore.getInstance().getDefaultNavigator();
- // Set the reference to the LogicalVolume.
+ // Set the LogicalVolume from the path if it hasn't been setup already.
+ if ( this.logicalVolume == null )
+ {
logicalVolume = support.getLeafVolume().getLogicalVolume();
+ }
- // Compute and cache the local to global transform.
- localToGlobal = navigator.getTransform(support);
-
- // Compute and cache the global to local transform.
- globalToLocal = localToGlobal.inverse();
+ // Cache the local to global transform.
+ localToGlobal = navigator.getTransform(support);
- // Compute and cache the parent to global transform.
- if ( parentIGeometryInfo() != null ) {
- parentToLocal = Transform3D.multiply(
- getGlobalToLocal(),
- parentIGeometryInfo().getLocalToGlobal());
- }
+ // Cache the global to local transform.
+ globalToLocal = localToGlobal.inverse();
- // Compute and cache the global position.
- globalPosition = localToGlobal.transformed(new BasicHep3Vector());
+ // Cache the parent to global transform.
+ if ( parentIGeometryInfo() != null ) {
+ parentToLocal = Transform3D.multiply(
+ getGlobalToLocal(),
+ parentIGeometryInfo().getLocalToGlobal());
}
+
+ // Cache the global position.
+ globalPosition = localToGlobal.transformed(new BasicHep3Vector());
}
/**
@@ -97,7 +140,20 @@
public GeometryInfo(
IDetectorElement de)
{
- setup(de,null);
+ setup(de,null,null);
+ }
+
+ /**
+ * Creates an orphan volume with a LogicalVolume
+ * but no support in the geometry tree.
+ *
+ * @param de The associated DetectorElement.
+ */
+ public GeometryInfo(
+ IDetectorElement de,
+ ILogicalVolume lv)
+ {
+ setup(de,lv,null);
}
/**
@@ -121,7 +177,7 @@
throw new IllegalArgumentException("Support is empty!");
}
- setup(de,support);
+ setup(de,null,support);
}
/* (non-Javadoc)
@@ -135,9 +191,9 @@
/* (non-Javadoc)
* @see org.lcsim.detector.IGeometryInfoTest#getPhysicalVolumePath(hep.physics.vec.Hep3Vector)
*/
- public IPhysicalVolumePath getPhysicalVolumePath(Hep3Vector global_point)
+ public IPhysicalVolumePath getPhysicalVolumePath(Hep3Vector globalPoint)
{
- return navigator.getPath(global_point);
+ return PhysicalVolumeNavigatorStore.getInstance().getDefaultNavigator().getPath(globalPoint);
}
/* (non-Javadoc)
@@ -197,22 +253,6 @@
}
/* (non-Javadoc)
- * @see org.lcsim.detector.IGeometryInfoTest#hasLogicalVolume()
- */
- public boolean hasLogicalVolume()
- {
- return logicalVolume != null;
- }
-
- /* (non-Javadoc)
- * @see org.lcsim.detector.IGeometryInfoTest#hasSupport()
- */
- public boolean hasPhysicalVolumePath()
- {
- return support != null;
- }
-
- /* (non-Javadoc)
*
* Check if the point @param globalPoint is inside this volume
* by transforming the point from global to local coordinates
@@ -287,18 +327,35 @@
/* (non-Javadoc)
* @see org.lcsim.detector.IGeometryInfoTest#setSupport(org.lcsim.detector.IPhysicalVolumePath)
*/
- public void setPhysicalVolumePath(IPhysicalVolumePath support)
+ public void setSupport(IPhysicalVolumePath support)
{
- this.support = support;
+ setupSupport(support);
+ //this.support = support;
}
public boolean isGhost()
{
- return support == null;
+ return support == null && logicalVolume == null;
+ }
+
+ public boolean isOrphan()
+ {
+ return support == null && logicalVolume != null;
}
public IDetectorElement getDetectorElement()
{
return de;
}
-}
+
+ public boolean hasLogicalVolume()
+ {
+ return logicalVolume != null;
+ }
+
+ public boolean hasPhysicalVolumePath()
+ {
+ return support != null;
+ }
+
+}
\ No newline at end of file