Print

Print


Commit in GeomConverter/src/org/lcsim/detector on MAIN
IPhysicalVolumeNavigator.java+12-31.5 -> 1.6
PhysicalVolumeNavigator.java+381.7 -> 1.8
+50-3
2 modified files
JM: Add post-order traversal.

GeomConverter/src/org/lcsim/detector
IPhysicalVolumeNavigator.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- IPhysicalVolumeNavigator.java	7 Mar 2007 00:43:41 -0000	1.5
+++ IPhysicalVolumeNavigator.java	7 Mar 2007 01:13:17 -0000	1.6
@@ -11,7 +11,7 @@
  * transform of an IPhysicalVolumePath.
  * 
  * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: IPhysicalVolumeNavigator.java,v 1.5 2007/03/07 00:43:41 jeremy Exp $
+ * @version $Id: IPhysicalVolumeNavigator.java,v 1.6 2007/03/07 01:13:17 jeremy Exp $
  */
 public interface IPhysicalVolumeNavigator 
 {
@@ -82,11 +82,20 @@
 	public IPhysicalVolumePath getPath(Hep3Vector globalPoint);	
 	 
 	/**
-	 * Traverse the tree using preorder or parent first,
-	 * calling the visit method of the @param IPhysicalVolumeVisitor.
+	 * Traverse the tree using preorder, calling the visit method 
+	 * of the @param IPhysicalVolumeVisitor.
 	 * 
 	 * @param visitor An IPhysicalVolumeVisitor that will be activated
 	 *                at each PhysicalVolume in the tree.
 	 */
 	public void traversePreOrder(IPhysicalVolumeVisitor visitor);
+	
+	/**
+	 * Traverse the tree using postorder, calling the visit method 
+	 * of the @param IPhysicalVolumeVisitor.
+	 * 
+	 * @param visitor An IPhysicalVolumeVisitor that will be activated
+	 *                at each PhysicalVolume in the tree.
+	 */
+	public void traversePostOrder(IPhysicalVolumeVisitor visitor);	
 }
\ No newline at end of file

GeomConverter/src/org/lcsim/detector
PhysicalVolumeNavigator.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- PhysicalVolumeNavigator.java	7 Mar 2007 00:43:32 -0000	1.7
+++ PhysicalVolumeNavigator.java	7 Mar 2007 01:13:17 -0000	1.8
@@ -358,4 +358,42 @@
 			}
 		}		
 	}
+	
+	
+	/**
+	 * Visit the PhysicalVolume recursively using postorder,
+	 * calling the given IPhysicalVolumeVisitor's visit method
+	 * for each node.
+	 * 
+	 * @param physicalVolume
+	 * @param visitor
+	 */
+	protected void traversePostOrder(IPhysicalVolume physicalVolume, IPhysicalVolumeVisitor visitor)
+	{		
+		// Recursively traverse the daughters.
+		if ( physicalVolume.getLogicalVolume().getNumberOfDaughters() > 0 )
+		{
+			for ( IPhysicalVolume child : physicalVolume.getLogicalVolume().getDaughters())
+			{
+				traversePostOrder(child, visitor);
+			}
+		}
+		
+		// Visit this node.
+		visitor.visit(physicalVolume);		
+	}	
+	
+	/**
+	 * Visit the top volume recursively using postorder,
+	 * calling the given IPhysicalVolumeVisitor's visit method
+	 * for each node.
+	 * 
+	 * @param physicalVolume
+	 * @param visitor
+	 */
+	
+	public void traversePostOrder(IPhysicalVolumeVisitor visitor)
+	{
+		traversePostOrder(getTopPhysicalVolume(), visitor);
+	}	
 }
\ No newline at end of file
CVSspam 0.2.8