Print

Print


Commit in GeomConverter/src/org/lcsim/geometry/compact/converter/svg on MAIN
SvgConverter.java+18-331.2 -> 1.3
bit of cleanup

GeomConverter/src/org/lcsim/geometry/compact/converter/svg
SvgConverter.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- SvgConverter.java	27 Jan 2011 00:52:48 -0000	1.2
+++ SvgConverter.java	27 Jan 2011 01:08:52 -0000	1.3
@@ -9,7 +9,6 @@
 import org.jdom.Element;
 import org.jdom.Namespace;
 import org.lcsim.detector.IDetectorElement;
-import org.lcsim.detector.ITranslation3D;
 import org.lcsim.detector.solids.Tube;
 import org.lcsim.geometry.Calorimeter;
 import org.lcsim.geometry.Tracker;
@@ -42,7 +41,8 @@
     // Scaling of Subdetector drawing from LCSim natural units (mm).
     private static final double scale = 0.1;
 
-    // These margins are in USER not absolute units.
+    // These margins are for positioning the Subdetector group and 
+    // are in LCSim units (mm).
     private static final double xmargin = 1500;
     private static final double ymargin = 1000;
 
@@ -101,8 +101,6 @@
         // All elements go into this group.
         Element g = new Element("g", ns);
         root.addContent(g);
-        // g.setAttribute("transform",
-        // "scale(" + scale + ") " + "translate(" + xmargin + ", " + 0 + ")");
 
         // Header with name.
         Element header = text(g, detector.getName(), viewportX / 2, 50);
@@ -111,7 +109,6 @@
 
         // Subdetector group.
         Element gs = new Element("g", ns);
-        // subdetGroup = gs;
         g.addContent(gs);
         gs.setAttribute("transform", "scale(" + scale + ") " + "translate(" + xmargin + ", " + ymargin + ")");
 
@@ -154,7 +151,7 @@
         return "rgb(" + rgba[0] * 100 + "%, " + rgba[1] * 100 + "%, " + rgba[2] * 100 + "%)";
     }
 
-    public static class InnerRadiusCompare implements Comparator<Calorimeter>
+    private static class InnerRadiusCompare implements Comparator<Calorimeter>
     {
         public int compare(Calorimeter subdet1, Calorimeter subdet2)
         {
@@ -196,7 +193,6 @@
         }
     }
 
-    // TODO Cleanup this messy method. Make and use one list of Subdetectors rather than several.
     private static void convertSubdetectors(Element parent, Detector detector, double maxZ, double maxY)
     {        
         List<Subdetector> subdetectors = detector.getSubdetectorList();
@@ -241,10 +237,6 @@
         // Now draw the Trackers, supports, and dead material.
         for (org.lcsim.geometry.Subdetector subdet : detector.getSubdetectors().values())
         {
-            // TODO Remove if statement here when all types are handled above.
-            //if (subdet instanceof SiTrackerBarrel || subdet instanceof MultiLayerTracker
-            //        || subdet instanceof DiskTracker || subdet instanceof PolyconeSupport
-            //        || subdet instanceof TubeSegment)
             if (!(subdet instanceof Calorimeter))
             {
                 SvgConverter.convertSubdetector(parent, (Subdetector)subdet, maxZ, maxY);
@@ -278,10 +270,10 @@
         // Debug print.
         System.out.println(">> " + subdet.getName());
 
-        // visualization
+        // Get VisAttributes of Subdetector.
         VisAttributes vis = subdet.getVisAttributes();
 
-        // If not visible then immediately return.
+        // If not visible then immediately return without drawing anything.
         if (!vis.getVisible())
         {
             System.out.println("    *not visible* ... skipping");
@@ -303,9 +295,7 @@
         g.setAttribute("stroke-width", "3"); // Default stroke-width.
         g.setAttribute("opacity", Float.toString(alpha));
 
-        // Margin group.
-        // g.setAttribute("transform", "translate(" + margin + ", " + margin + ")");
-
+        // Draw Calorimeters.
         if (subdet instanceof Calorimeter)
         {
             // Turn off shape outline.
@@ -430,8 +420,9 @@
                     }
                 }
             }
-            // TODO Replace compact based code with IDetectorElement, but DiskTracker
-            // layers need their own DetectorElements.
+            // Draw DiskTracker.
+            // FIXME Replace compact based code with IDetectorElement, but DiskTracker
+            // layers need their own DetectorElements first.
             else if (subdet instanceof DiskTracker)
             {
                 DiskTracker diskTracker = (DiskTracker)subdet;
@@ -482,11 +473,10 @@
                     // Make a modified ZPlane for components that cross the xaxis.
                     if (i > 0 && zplanesUse.size() == 0)
                     {
+                        // Get prior ZPlane with negative Z coordinate.
                         ZPlane lastNegZPlane = zplanes.get(i - 1);
 
-                        // Check if last point had same radius values, so that
-                        // drawing across the X axis can be done simply by starting
-                        // from x==0.
+                        // If radii are the same, then draw from Y axis.
                         if (lastNegZPlane.getRMin() == zplane.getRMin() && lastNegZPlane.getRMax() == zplane.getRMax())
                         {
                             ZPlane borderZPlane = new ZPlane(lastNegZPlane.getRMin(), lastNegZPlane.getRMax(), 0);
@@ -504,9 +494,10 @@
 
             if (zplanesUse.size() > 0)
             {
+                // Buffer to store positions for polygon.
                 StringBuffer buff = new StringBuffer();
 
-                // Start by making outer radii points in positive X direction.
+                // Add outer radii points going in positive X direction.
                 for (ZPlane zplane : zplanesUse)
                 {
                     double outerR = zplane.getRMax();
@@ -514,22 +505,21 @@
                     buff.append(z + "," + (maxY - outerR) + " ");
                 }
 
-                // Make a reverse list.
+                // Make a reverse list of the ZPlanes.
                 List<ZPlane> reverseZPlanes = new ArrayList<ZPlane>(zplanesUse);
                 Collections.reverse(reverseZPlanes);
 
-                // Now make inner radius points going in the negative X direction.
+                // Add inner radii points going in the negative X direction.
                 for (ZPlane zplane : reverseZPlanes)
                 {
                     double innerR = zplane.getRMin();
                     double z = zplane.getZ();
                     buff.append(z + "," + (maxY - innerR) + " ");
                 }
+                                
                 String points = buff.toString();
                 points.trim();
 
-                // System.out.println(points);
-
                 // Make the polygon using the list of points.
                 Element polygon = new Element("polygon", ns);
                 polygon.setAttribute("points", points);
@@ -553,8 +543,8 @@
                     rect(g, zmin, maxY - outerR, outerR - innerR, halfZ);
                 }
                 
-                // FIXME: Rotation is ignored.
-                // FIXME: TubeSegments going across Y axis are ignored.
+                // FIXME: Rotation is completely ignored.
+                // FIXME: TubeSegments that go across Y axis into positive X region are ignored.
             }
         }
         // TODO Handle these additional types...
@@ -627,9 +617,4 @@
 
         return zy;
     }
-
-    /*
-     * This would be nice. interface SubdetectorConverter { void convert(Element parent, Detector detector, double maxZ,
-     * double maxY); }
-     */
 }
\ No newline at end of file
CVSspam 0.2.8