6 modified files
GeomConverter/src/org/lcsim/geometry/compact
diff -u -r1.11 -r1.12
--- CompactReader.java 1 Jul 2005 00:10:49 -0000 1.11
+++ CompactReader.java 5 Jul 2005 22:40:16 -0000 1.12
@@ -15,7 +15,7 @@
/**
* A tool for reading xml files containing compact detector descriptions.
* @author tonyj
- * @version $Id: CompactReader.java,v 1.11 2005/07/01 00:10:49 jeremy Exp $
+ * @version $Id: CompactReader.java,v 1.12 2005/07/05 22:40:16 jeremy Exp $
*
* This class does not create subclass objects. For example, CylindricalBarrelCalorimeter
* is inserted into Detector as a generic Subdetector. To get subclasses, use the
@@ -60,10 +60,7 @@
Document doc = builder.build(in);
Element lccdd = doc.getRootElement();
- Detector det = factory.createElement(Detector.class,lccdd,null);
-
- /** Set parent material manager containing chem element materials. */
- det.getMaterialManager().setParentManager(XMLMaterialManager.elements() );
+ Detector det = factory.createElement(Detector.class,lccdd,null);
Element info = lccdd.getChild("info");
det.setHeader(factory.createElement(Header.class,info,null));
@@ -130,11 +127,14 @@
/** Create impl objects of materials and their references. */
void setupMaterials(org.jdom.Element lccdd, Detector det) throws JDOMException
{
- //System.out.println("CompactReader.setupMaterials()");
+ System.out.println("CompactReader.setupMaterials()");
+
+ /** Set parent material manager containing chem element materials. */
+ //det.getMaterialManager().setParentManager(XMLMaterialManager.elements() );
XMLMaterialManager matmgr = det.getMaterialManager();
- matmgr.addReferencesFromCompact(lccdd);
+ matmgr.addReferencesFromCompact(lccdd);
matmgr.makeMaterials(null);
}
}
\ No newline at end of file
GeomConverter/src/org/lcsim/geometry/compact
diff -u -r1.7 -r1.8
--- Detector.java 30 Jun 2005 00:35:30 -0000 1.7
+++ Detector.java 5 Jul 2005 22:40:16 -0000 1.8
@@ -27,7 +27,8 @@
*/
protected Detector(Element element)
{
- materialMgr = XMLMaterialManager.create(XMLMaterialManager.materials() );
+ materialMgr = XMLMaterialManager.create(XMLMaterialManager.materials() );
+ //materialMgr.setParentManager( XMLMaterialManager.elements() );
}
/**
* Called by the reader to associate a header with this detector
GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd/util
diff -u -r1.10 -r1.11
--- LCDD.java 30 Jun 2005 00:36:25 -0000 1.10
+++ LCDD.java 5 Jul 2005 22:40:17 -0000 1.11
@@ -134,10 +134,10 @@
/**
* This may be a material that was not defined in the materials
- * block. Attempt to lkp using the global materials manager. If
- * this fails, the material reference is probably invalid/undefined.
- *
- * jeremym
+ * block. Attempt to look it up using the global materials manager.
+ *
+ * If this fails, the material reference is probably invalid/undefined.
+ *
*/
if (mat == null)
{
GeomConverter/src/org/lcsim/geometry/layer
diff -u -r1.4 -r1.5
--- LayerSlice.java 1 Jul 2005 00:14:06 -0000 1.4
+++ LayerSlice.java 5 Jul 2005 22:40:17 -0000 1.5
@@ -8,6 +8,7 @@
import org.lcsim.material.Material;
import org.lcsim.material.MaterialManager;
+import org.lcsim.material.MaterialNotFoundException;
/**
*
@@ -36,17 +37,15 @@
public LayerSlice(String matName, double w, boolean sens)
{
- Material material = MaterialManager.getMaterial( matName );
-
- if ( material == null )
- {
- throw new RuntimeException("LayerSlice ctor - material not found: " + matName);
+ //Material material = MaterialManager.getMaterial( matName );
+ Material material;
+ try {
+ material = MaterialManager.findMaterial( matName );
}
-
- if ( material == null )
+ catch (MaterialNotFoundException mnfe)
{
- System.out.println("LayerSlice ctor - material not found: " + matName);
- }
+ throw new RuntimeException(mnfe);
+ }
thickness = w;
sensitive = sens;
GeomConverter/src/org/lcsim/material
diff -u -r1.6 -r1.7
--- MaterialManager.java 2 Jul 2005 00:49:48 -0000 1.6
+++ MaterialManager.java 5 Jul 2005 22:40:17 -0000 1.7
@@ -9,6 +9,7 @@
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;
+import org.jdom.JDOMException;
/**
*
@@ -62,7 +63,7 @@
//System.out.println("MaterialManager.addMaterial() - " + material.getName() );
/* Only add the material if doesn't exist already. */
- if ( getMaterial(material.getName()) == null )
+ if ( getMaterial( material.getName() ) == null )
{
_materials.put(material.getName(), material);
}
@@ -73,13 +74,48 @@
return _materials.get(materialName);
}
+ public static Material findMaterial(String materialName) throws MaterialNotFoundException
+ {
+ System.out.println("find material: " + materialName);
+
+ /* Check in the list of materials that already exists. */
+ Material m = getMaterial(materialName);
+
+ /* Not found, so lookup using the XMLMaterialManager's list of materials. */
+ if ( m == null )
+ {
+ XMLMaterialManager mgr = XMLMaterialManager.materials();
+ org.jdom.Element me = mgr.getMaterial(materialName);
+
+ if ( me != null )
+ {
+ //System.out.println("found material in xml mgr");
+ try
+ {
+ mgr.makeMaterial(me, null);
+ }
+ catch (JDOMException jde)
+ {
+ throw new RuntimeException(jde);
+ }
+ }
+ else
+ {
+ throw new MaterialNotFoundException(materialName);
+ }
+ }
+
+ /* now this should work */
+ return getMaterial(materialName);
+ }
+
public static MaterialElement getElement(String elementName)
{
- // System.out.println("nelem defs: " + elements().values().size());
+ // System.out.println("nelem defs: " + elements().values().size());
//for ( MaterialElement me : elements().values() )
//{
-// System.out.println( me.name() + " is defined");
-// }
+ // System.out.println( me.name() + " is defined");
+ // }
return (MaterialElement) elements().get(elementName);
}
@@ -100,22 +136,22 @@
private static void defineElements()
{
- MaterialElementData.defineElements();
+ MaterialElementData.defineElements();
}
private static void defineMaterialsForElements()
{
for ( MaterialElement me : elements().values() )
{
- Material material = new Material( me.fullName(),
+ Material material = new Material( me.fullName(),
1,
- me.getDensity(),
- MaterialState.UNKNOWN,
- Material.DEFAULT_TEMPERATURE,
+ me.getDensity(),
+ MaterialState.UNKNOWN,
+ Material.DEFAULT_TEMPERATURE,
Material.DEFAULT_PRESSURE );
material.addElement( me, 1.0);
- }
+ }
}
public static void printMaterials(PrintStream ps)
@@ -138,7 +174,7 @@
public static void printMaterials()
{
- printMaterials(System.out);
+ printMaterials(System.out);
}
public static void printElements()
GeomConverter/src/org/lcsim/material
diff -u -r1.11 -r1.12
--- XMLMaterialManager.java 2 Jul 2005 00:49:48 -0000 1.11
+++ XMLMaterialManager.java 5 Jul 2005 22:40:17 -0000 1.12
@@ -169,13 +169,13 @@
}
/** Get the material map. */
- public LinkedHashMap<String, org.jdom.Element> getMaterialMap()
+ private LinkedHashMap<String, org.jdom.Element> getMaterialMap()
{
return materialMap;
}
/** Get the chem element map. */
- public LinkedHashMap<String, org.jdom.Element> getElementMap()
+ private LinkedHashMap<String, org.jdom.Element> getElementMap()
{
return elementMap;
}
@@ -196,19 +196,7 @@
private void setCurrentDocument(Document d)
{
currentDoc = d;
- }
-
- /** Is the argument an element of type material? */
- public static boolean isMaterial(org.jdom.Element e)
- {
- return "material".equals(e.getName());
- }
-
- /** Is the argument an element of type element? [sic] */
- public static boolean isElement(org.jdom.Element e)
- {
- return "element".equals(e.getName());
- }
+ }
/** Return size of the material map. */
public int getNumberOfMaterials()
@@ -279,7 +267,7 @@
/** Add a material to the map. */
private void addMaterial(org.jdom.Element e) throws JDOMException
{
- if ( e.getName() != "material")
+ if ( !e.getName().equals("material"))
{
throw new JDOMException("Element is not named material.");
}
@@ -328,10 +316,10 @@
//}
}
- //if ( m != null )
- //{
- // System.out.println("fnd mat: " + matName);
- //}
+ if ( m != null )
+ {
+ System.out.println("fnd mat: " + matName);
+ }
return m;
}
@@ -787,6 +775,8 @@
*/
public void makeMaterial(org.jdom.Element materialElement, LCDD lcdd) throws JDOMException
{
+ System.out.println("makeMaterial - " + materialElement.getAttributeValue("name"));
+
/* Add the referenced material if it does not exist already. */
if ( MaterialManager.getMaterial(materialElement.getAttributeValue("name")) == null )
{
CVSspam 0.2.8