Overall I haven’t seen any difficulties doing the conversions to the new VTK Python API.
My impression is that the code is more compact and much easier to read.
However … I started doing the more complex examples and came across this when updating PBR_Skybox:
I can update this function to:
def read_cubemap(cubemap):
cube_map = vtkTexture(cube_map=True, mipmap=True, interpolate=True)
flipped_images = list()
for fn in cubemap:
reader_factory = vtkImageReader2Factory()
img_reader = reader_factory.CreateImageReader2(str(fn))
img_reader.file_name = str(fn)
flip = vtkImageFlip(filtered_axis=1)
img_reader >> flip
flipped_images.append(flip)
for i in range(0, len(flipped_images)):
cube_map.SetInputConnection(i, flipped_images[i].GetOutputPort())
return cube_map
Which works fine. However, thinking along the lines of vtkAppendFilter
, is it possible to modify vtkTexture
so that:
flipped_images >> cube_map
works? To me SetInputConnection(i,...)
is working in the same way as the input to vtkAppendFilter
. Of course this assumes that the image files making up the cube map are already ordered as [right, left, top, bottom, front, back] or [+x, -x, +y, -y, +z, -z].