how to generate the curved planar reformation image?

The working, fully functional Python code is available here: SlicerSandbox/CurvedPlanarReformat/CurvedPlanarReformat.py at master · PerkLab/SlicerSandbox · GitHub

It is readily usable with GUI or from Slicer’s Python environment as is. If you want to implement your your own viewers, interactive widgets, user interface, etc. then it should not be a problem for you to remove the dependency on a few Slicer-specific classes.