OK thanks for the reply @Louis_Gombert @lgivord
- As for creating a Python filter, do you have an example? I followed this tutorial but it doesn’t seem to work. I opened a new discourse thread for this: Creating custom filter in Python - Support - VTK
- In the meantime, I wanted to know what was wrong with my earlier example of writing a temporal polydata (sphere) to vtkhdf. Here’s the code:
def write_simple_temporal_sphere(output_path: str):
# 1. Create a basic sphere
sphere = vtkSphereSource()
sphere.SetRadius(10)
sphere.SetThetaResolution(30)
sphere.SetPhiResolution(30)
# 2. Generate 2 time steps (e.g., t = 0 and pi)
time_gen = vtkGenerateTimeSteps()
time_gen.SetInputConnection(sphere.GetOutputPort())
time_gen.SetTimeStepValues(2, [0.0, np.pi])
# 3. Add time-varying field with one harmonic
harmonics = vtkSpatioTemporalHarmonicsAttribute()
harmonics.SetInputConnection(time_gen.GetOutputPort())
harmonics.AddHarmonic(1, 0, 0.5, 0.5, 0.5, 0.0) # magnitude, frequency, direction, phase
# 4. Warp the mesh using the harmonic field
warp = vtkWarpScalar()
warp.SetInputConnection(harmonics.GetOutputPort())
warp.SetInputArrayToProcess(0, 0, 0, vtkDataObject.FIELD_ASSOCIATION_POINTS, "SpatioTemporalHarmonics")
# 5. Write to .vtkhdf with all timesteps
writer = vtkHDFWriter()
writer.SetInputConnection(warp.GetOutputPort())
writer.SetFileName(output_path)
writer.SetWriteAllTimeSteps(True)
writer.Write()
While reading the file will tell me that it is temporal and there are 2 timesteps, the points don’t seem to differ between the two timesteps. Is there something wrong with my pipeline?
Thanks!