Commit in GeomConverter/src/org/lcsim/geometry/compact on MAIN
CompactReader.java+18-11.26 -> 1.27
JM: Add CLHEP system of units constants to the compact description.

GeomConverter/src/org/lcsim/geometry/compact
CompactReader.java 1.26 -> 1.27
diff -u -r1.26 -r1.27
--- CompactReader.java	12 Sep 2006 02:42:48 -0000	1.26
+++ CompactReader.java	1 Mar 2007 19:06:57 -0000	1.27
@@ -5,12 +5,15 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
 
 import org.jdom.Document;
 import org.jdom.Element;
 import org.jdom.JDOMException;
 import org.jdom.input.SAXBuilder;
 import org.lcsim.material.XMLMaterialManager;
+import org.lcsim.units.clhep.SystemOfUnitsMap;
 import org.lcsim.util.cache.CachingEntityResolver;
 import org.lcsim.util.xml.ElementFactory;
 import org.lcsim.util.xml.JDOMExpressionFactory;
@@ -24,7 +27,7 @@
  * org.lcsim.geometry.GeometryReader class, which extends this.
  *
  * @author tonyj
- * @version $Id: CompactReader.java,v 1.26 2006/09/12 02:42:48 jeremy Exp $
+ * @version $Id: CompactReader.java,v 1.27 2007/03/01 19:06:57 jeremy Exp $
  *
  */
 public class CompactReader
@@ -58,6 +61,10 @@
     public Detector read(InputStream in) throws IOException, JDOMException, ElementCreationException
     {
         JDOMExpressionFactory jdom = new JDOMExpressionFactory();
+        
+        // Setup CLHEP units in the expression evaluator.
+        registerCLHEPConstants(jdom);
+        
         SAXBuilder builder = new SAXBuilder();
         builder.setFactory(jdom);        
         
@@ -244,4 +251,14 @@
             }
         }
     }
+    
+    private void registerCLHEPConstants(JDOMExpressionFactory f)
+    {    
+    	SystemOfUnitsMap units = new SystemOfUnitsMap();
+    	for (Entry<String,Double> unit : units.entrySet())
+    	{
+    		//System.out.println("adding constant " + unit.getKey() + "=" +unit.getValue());
+    		f.addConstant(unit.getKey(),unit.getValue());
+    	}
+    }
 }
\ No newline at end of file
CVSspam 0.2.8