Commit in GeomConverter/src/org/lcsim/geometry/segmentation on MAIN
GridXYZ.java+15-11.22 -> 1.23
MJC: Patch to neighbour-finding routine in GridXYZ to avoid returning illegal cells as neighbours

GeomConverter/src/org/lcsim/geometry/segmentation
GridXYZ.java 1.22 -> 1.23
diff -u -r1.22 -r1.23
--- GridXYZ.java	11 May 2007 00:21:10 -0000	1.22
+++ GridXYZ.java	17 Apr 2008 12:34:43 -0000	1.23
@@ -155,7 +155,21 @@
 
 // 		    System.out.println("Adding neighbor: "+ilay+" "+ix+" "
 // 				       +iy+", total="+ (size+1));
-                    result[size++] = encoder.setValue(yIndex, iy);
+                    long candidate = encoder.setValue(yIndex, iy);
+                    // Verify that this is actually a legal value:
+                    this.setID(candidate);
+                    double candAbsZ = Math.abs(this.getZ());
+                    double candRho = Math.sqrt(this.getX()*this.getX() + this.getY()*this.getY());
+                    boolean candValid = (candAbsZ >= getZMin() && candAbsZ <= getZMax() && candRho >= getRMin() && candRho <= getRMax());
+                    if (candValid) {
+                        // OK -- neighbour is at a legal spacepoint
+                        result[size++] = candidate;
+                    } else {
+                        // Failure -- this can happen if the "neighbour" was just us wandering off the grid
+                        // Not serious -- don't add the candidate to the output, but don't panic either.
+                    }
+                    // Reset ID to previous value
+                    this.setID(id);
                 }
             }
         }
CVSspam 0.2.8