I am slogging through updating multiple projects too. While initially daunting, I do find that it tends to follow an easily resolved pattern.
Additionally, the SpatialObjects in particular had acquired an amazing amount of cruft and logic errors / inconsistencies. While individual spatialObjects would (typically) operate well, the behavior of different objects was amazingly inconsistent for the same API - sometimes operating in ObjectSpace and othertimes operating in WorldSpace, and often making assumptions that were simply wrong. We’re really hoping to lower the bar for adopting ITK - not requiring folks to be C++ developers and having to look at source code to decipher an implementation’s Space are big part’s of lowering that bar.
For example, looking at the test I referenced to you, the logic in that test is weak. It assumes that the min of the bounding box in physical space should map to the region’s index and the max-min of the bounding box should map to the region’s size. This is wrong if the image’s directions are not the identity transform. If the image directions are, for example, inverted, then the max of the bounding box in physical space should map to the region’s index. Similarly, if the image’s directions are not axis aligned, then the physical box’s min and max may not map at all to the index and size of the bounding region in index space. In that case, it is necessary to convert every corner of the physical bounding box into index space, and then take the coordinate-specific mins and maxs of those transformed corners to define the region.
Sorry - long answer, but that test is a valid test for the particular conditions it uses (identity directions) but it does give a general solution. It is another example of how the SpatialObjects have degraded over time.
If you need code to go from a bounding box in physical space to an image region, let me know. I do have it elsewhere.
Good luck with the conversion. It is a pain, but I think your project and all new developers will greatly benefit immediately after the update to ITKv5 (better threading, consistent APIs, …)