Commit in GeomConverter/src/org/lcsim/material on MAIN
XMLMaterialManager.java+13-121.15 -> 1.16
Fix problem with material references not processed correctly. (trunk)

GeomConverter/src/org/lcsim/material
XMLMaterialManager.java 1.15 -> 1.16
diff -u -r1.15 -r1.16
--- XMLMaterialManager.java	22 Jul 2005 23:23:42 -0000	1.15
+++ XMLMaterialManager.java	5 Oct 2005 21:59:09 -0000	1.16
@@ -395,7 +395,7 @@
     
     public org.jdom.Element findMaterialInDocument(String matName) throws JDOMException
     {
-        return findElementInDocument(matName);
+        return findMaterialInDocument(matName, currentDoc);
     }
     
     /* Load all materials and elements from an InputStream. */
@@ -467,7 +467,7 @@
      */
     private void addReferences(org.jdom.Element e, Document d) throws JDOMException
     {
-        //System.out.println("XMLMaterialManager.addReferences() - adding refs for " + e.getAttributeValue("name"));
+//        System.out.println("XMLMaterialManager.addReferences() - adding refs for " + e.getAttributeValue("name"));
         if ( e != null )
         {
             if ( "material".equals(e.getName()))
@@ -484,7 +484,7 @@
                     throw new JDOMException("Material does not contain fraction or composite tags.");
                 }
                 
-                for ( org.jdom.Element ce : (List<org.jdom.Element>) l )
+                for ( org.jdom.Element ce : (List<org.jdom.Element>) l)
                 {
                     
                     String ref = ce.getAttributeValue("ref");
@@ -502,22 +502,22 @@
                         
                         if ( fnd != null )
                         {
-                            //if ( materialMap.get(ref) == null) {
-                            addMaterial(fnd);
-                            
                             /* Recursively add references of this material. */
+//                            System.out.println("adding dep - " + fnd.getAttributeValue("name"));
                             addReferences(fnd, d);
-                            //}
+                            
+//                            addMaterial(fnd);
                         }
                         else
                         {
                             throw new JDOMException("Material or element reference not found: " + ref);
                         }
                     }
-                    
-                    /* Lastly, add the material that was passed in after its references recursively resolved. */
-                    addMaterial(e);
                 }
+                
+                /* Lastly, add the material that was passed in after its references recursively resolved. */
+//                System.out.println("adding material - " + e.getAttributeValue("name"));
+                addMaterial(e);
             }
         }
         else
@@ -541,7 +541,7 @@
         org.jdom.Element m = getMaterial(matName);
         
         if ( m != null )
-        {            
+        {
             if ( "material".equals(m.getName()))
             {
                 List l = m.getChildren("composite");
@@ -726,6 +726,7 @@
             org.jdom.Element element = (org.jdom.Element) i.next();
             if ("material".equals(element.getName()))
             {
+                //                System.out.println("addReferencesFromCompact - " + element.getAttributeValue("name"));
                 addReferences(element);
             }
         }
@@ -760,7 +761,7 @@
     {
         return getMaterial(defaultMaterialName);
     }
-       
+    
     /** Make org.lcsim.Material impl class for all org.jdom.Element in the map. */
     public void makeMaterials(LCDD lcdd) throws JDOMException
     {
CVSspam 0.2.8