Fast (approximate) structure mask implementation
Implemented fast structure mask creation leveraging OpenCV's cv2.fillpoly(...) with contours from each slice read from ESAPI's Structure.GetContoursOnImagePlane(...). Boolean output only, when a lower slice (z) resolution is requested, the mask is generated based on the contours on the original CT slice intersected by the mid-plane of the lower resolution (requested) slice.
Example usage (CT grid):
mask_ct_res = plan.StructureSet.np_mask_for_structure_fast(structure, plan.StructureSet.Image)
Mask for dose grid:
mask_dose_res = plan.StructureSet.np_mask_for_structure_fast(structure, plan.Dose)
The super sampling implementation increases the accuracy significantly. I chose 8 as the super sampling factor default after some empirical experimentation comparing a fairly complex mask slice between the original PyESAPI method and this new/fast/approximate method. Maybe 6 could work too, but a better study would involve impact on DVH.