Re: [Paraview] "Rotate" look up table
Hi Nicolas, You can create a programmable filter that will alter the scalars based on a "fake" time. I've attached an example on how to create a time based filter. Good luck, Seb PS: I'm not sure, the latest ParaView allow programable filter to be time aware. If not, I've also attached an XML (plugin) that you can load and use for that filter. On Fri, Feb 3, 2017 at 1:47 AM, Nicolas Cedilnik wrote: > Hi all, > > I'm replying to my own email because I worked out a solution and wanted to > share but also because I believe what I'm doing is FAR from optimal and > hope that someone > >> Would it be possible with python scripting to create an animation by >> "rotating" the look up table in a way that would look like this: >> https://www.youtube.com/watch?v=qA_vInXwdKM#t=3m25s ? It is a >> pseudo-animation created by changing the "range" of the LUT. >> > So I made this python script (see attachment) that generates different > meshes with scalar values "rotated" (I don't find a better term to describe > what I'm doing). > It works and make it easy to play the animation by opening the produced > vtk files as a sequence in paraview. > > However, every vtk file contains both the mesh geometry and the scalar > values, but only the latter change. What would be the right way to animate > only the scalar values and not the mesh geometry? What data format should I > use? How could I import it into an animation in paraview? > > Thanks for your guidance > > -- > Nicolas > > ___ > Powered by www.kitware.com > > Visit other Kitware open-source projects at http://www.kitware.com/ > opensource/opensource.html > > Please keep messages on-topic and check the ParaView Wiki at: > http://paraview.org/Wiki/ParaView > > Search the list archives at: http://markmail.org/search/?q=ParaView > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/mailman/listinfo/paraview > > # = # Request Data # = import vtk executive = self.GetExecutive() outInfo = executive.GetOutputInformation(0) req_timestep = outInfo.Get(executive.UPDATE_TIME_STEP()) print req_timestep input = self.GetPolyDataInput() inputCells = input.GetPolys() newCells = vtk.vtkCellArray() # Keep cells in range nbCells = inputCells.GetNumberOfCells() allowedIds = range(int(req_timestep) * (nbCells / 5), (int(req_timestep) + 1) * (nbCells / 5)) cellLocation = 0 ids = vtk.vtkIdList() for cellIdx in range(nbCells): inputCells.GetCell(cellLocation, ids) cellSize = ids.GetNumberOfIds() if cellIdx in allowedIds: newCells.InsertNextCell(ids) cellLocation += cellSize + 1 self.GetPolyDataOutput().ShallowCopy(input) self.GetPolyDataOutput().SetPolys(newCells) # = # Request Informations # = timesteps = range(5) executive = self.GetExecutive() outInfo = executive.GetOutputInformation(0) outInfo.Remove(executive.TIME_STEPS()) for timestep in timesteps: outInfo.Append(executive.TIME_STEPS(), timestep) outInfo.Remove(executive.TIME_RANGE()) outInfo.Append(executive.TIME_RANGE(), timesteps[0]) outInfo.Append(executive.TIME_RANGE(), timesteps[-1]) ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Search the list archives at: http://markmail.org/search/?q=ParaView Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/paraview
Re: [Paraview] "Rotate" look up table
Hi all, I'm replying to my own email because I worked out a solution and wanted to share but also because I believe what I'm doing is FAR from optimal and hope that someone Would it be possible with python scripting to create an animation by "rotating" the look up table in a way that would look like this: https://www.youtube.com/watch?v=qA_vInXwdKM#t=3m25s ? It is a pseudo-animation created by changing the "range" of the LUT. So I made this python script (see attachment) that generates different meshes with scalar values "rotated" (I don't find a better term to describe what I'm doing). It works and make it easy to play the animation by opening the produced vtk files as a sequence in paraview. However, every vtk file contains both the mesh geometry and the scalar values, but only the latter change. What would be the right way to animate only the scalar values and not the mesh geometry? What data format should I use? How could I import it into an animation in paraview? Thanks for your guidance -- Nicolas #!/usr/bin/env python from sys import argv import numpy as np import pyvtk def open_binary(file_name): reader = vtk.vtkUnstructuredGridReader() reader.SetFileName(file_name) reader.Update() unstr_grid = reader.GetOutput() triangles = vtk_to_numpy(unstr_grid.GetCells().GetData()) triangles = triangles.reshape((int(len(triangles) / 4), 4))[:, 1:] points = vtk_to_numpy(unstr_grid.GetPoints().GetData()) scalars = pyvtk.Scalars( vtk_to_numpy(unstr_grid.GetPointData().GetArray(0))) points_data = pyvtk.PointData(scalars) grid = pyvtk.UnstructuredGrid(points, triangle=triangles) mesh = pyvtk.VtkData(grid, points_data) return mesh file_name = argv[1] output_prefix = argv[2] n = int(argv[3]) try: mesh = pyvtk.VtkData(file_name) except NotImplementedError: mesh = open_binary(file_name) t0 = np.copy(mesh.point_data.data[0].scalars) scalars_range = np.nanmax(t0) - np.nanmin(t0) step = scalars_range / n for i in range(1, n): mesh.tofile(file_name, format='binary') vals = t0 + i * step above = np.nan vals[vals > np.nanmax(t0)] = vals[vals > np.nanmax(t0)] - scalars_range mesh.point_data.data[0].scalars = vals file_name = "{}{:04d}.vtk".format(output_prefix, i) print(file_name) ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Search the list archives at: http://markmail.org/search/?q=ParaView Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/paraview
[Paraview] "Rotate" look up table
Hello, Would it be possible with python scripting to create an animation by "rotating" the look up table in a way that would look like this: https://www.youtube.com/watch?v=qA_vInXwdKM#t=3m25s ? It is a pseudo-animation created by changing the "range" of the LUT. Would paraview be the right tool to do that? I have a vtk file containing a triangular mesh with scalar values assigned to each point. I'm already using paraview and I'm pretty satisfied with the static output. I was wondering how complicated it would be to "pseudo-animate" it. Maybe someone can point me to some documentation or other tools that might do the job... Thanks -- Nicolas Cedilnik ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Search the list archives at: http://markmail.org/search/?q=ParaView Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/paraview