When calculating the intersection of a PlaneGeometry with an image-Geometry3D using the ClippedSurfaceBoundsCalculator the result is wrong if the plane is not parallel to the original slices of the image.
The problem is in the rounding of the index-coordinates. The interaction-points on the first slice (index == 0) actually have a index-coordinate of -0.5. This is fine as 0.0 is the center of the pixel, so -0.5 is the lower edge of the pixel.
However, the rounding turns this -0.5 to -1, which is not a valid index-coordinate (is more or less valid, but makes no sense in this context).
A simple solution would be to check the validity of the resulting index-coordinates and correct them if need be:
- lower value cannot be less than 0
- upper value cannot be more than dimension of image in each direction
Furthermore, an additional method should be implemented that is given a set of Point3Ds in world-coordinates. The result shall be the intersection point of this pointcloud with the image.