GeomConverter/src/org/lcsim/geometry/segmentation
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);
}
}
}