[vtkusers] Animation with VTU files.

Zoltan Kovacs Zoltan.Kovacs at esi-group.com
Mon Apr 9 10:33:52 EDT 2018


Hi Kenichiro,

Yes , it works indeed. Thank you very much. However, when I use your code with my data series I can see only the content of the first file. After the first update the screen remains empty till the end of the series. I tried to figure out why I get this behavior but the only difference in our VTU files are the number and position of the particles and the presence of more point data fields besides the radii data. If you do not mind I attached my files since I am curious how it works with your executable


Thanks a lot,
Zoltan


-----Original Message-----
From: kenichiro yoshimi <rccm.kyoshimi at gmail.com> 
Sent: Montag, 9. April 2018 13:38
To: Zoltan Kovacs <Zoltan.Kovacs at esi-group.com>
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] Animation with VTU files.

Hi Zoltan,

I'm sorry my data is not special meaning. It was just used to confirm whether the data were read correctly.
New attachment contains the particles which positions move a little at every time steps.

Thanks,

2018-04-09 19:22 GMT+09:00 Zoltan Kovacs <Zoltan.Kovacs at esi-group.com>:
> Hi Kenichiro,
>
> Thank you very much for your help! It seems to be what I need. Just one question: when I run your code I see the particles in the same position with increasing radii.  Does it mean the radii are different in each VTU file whereas the particle positions are the same. Just to be sure that the particle coordinates were read in the file series correctly.
>
> Thanks,
> Zoltan
>
> -----Original Message-----
> From: kenichiro yoshimi <rccm.kyoshimi at gmail.com>
> Sent: Sonntag, 8. April 2018 06:56
> To: Zoltan Kovacs <Zoltan.Kovacs at esi-group.com>
> Cc: vtkusers at vtk.org
> Subject: Re: [vtkusers] Animation with VTU files.
>
> Hello Zoltan,
>
> Probably it is possible to retrieve the vtkXMLUnstructuredGridReader object from the object that sets the reader as input connection like something below:
>
>   sphereGlyph->SetSourceConnection(sphere->GetOutputPort());
>   sphereGlyph->SetInputConnection(reader->GetOutputPort());
>
>   // reversely access
>   auto reader = vtkXMLUnstructuredGridReader::SafeDownCast(
>     sphereGlyph->GetInputConnection(0, 0)->GetProducer());
>
> Here is ReverseAccess example from VTK examples 
> https://lorensen.github.io/VTKExamples/site/Cxx/Visualization/ReverseA
> ccess/
>
> And I attach a simple code without programmable filter though I'm not sure if this is a correct usage..
>
> Thanks
>
> 2018-04-07 0:50 GMT+09:00 Zoltan Kovacs <Zoltan.Kovacs at esi-group.com>:
>> Dear VTK Users,
>>
>>
>>
>> I have a question on animation with VTU file series. I wrote a code 
>> which displays particels modeled with sphere
>>
>> glyphs, where the particle positions and radii are read from VTU files:
>>
>>
>>
>>     VTK_CREATE(vtkXMLUnstructuredGridReader, particleReader);
>>
>>     VTK_CREATE(vtkSphereSource, sphere);
>>
>>     VTK_CREATE(vtkGlyph3D, sphereGlyph);
>>
>>     VTK_CREATE(vtkVertexGlyphFilter, glyphFilter);
>>
>>     VTK_CREATE(vtkPolyDataMapper, particleMapper);
>>
>>     VTK_CREATE(vtkActor, particleActor);
>>
>>
>>
>>     particleReader->SetFileName( particleName.c_str() );
>>
>>     particleReader->Update();
>>
>>
>>
>>     vtkUnstructuredGrid *grid           = particleReader->GetOutput();
>>
>>     vtkPointData        *pointData      = grid->GetPointData();
>>
>>     pointData->SetActiveScalars("Radii");
>>
>>
>>
>>     glyphFilter->SetInputData(grid);
>>
>>     glyphFilter->Update();
>>
>>
>>
>>     sphere->SetRadius(1);
>>
>>     sphereGlyph->SetSourceConnection(sphere->GetOutputPort());
>>
>>     sphereGlyph->SetInputConnection(glyphFilter->GetOutputPort());
>>
>>
>>
>>     particleMapper->SetInputConnection(sphereGlyph->GetOutputPort());
>>
>>     particleMapper->SetScalarModeToUsePointFieldData();
>>
>>     particleMapper->Update();
>>
>>     particleActor->SetMapper(particleMapper);
>>
>>
>>
>>     VTK_CREATE(vtkRenderer, renderer);
>>
>>     VTK_CREATE(vtkRenderWindow, renderWindow);
>>
>>     VTK_CREATE(vtkRenderWindowInteractor, renderWindowInteractor);
>>
>>
>>
>>     renderWindow->AddRenderer(renderer);
>>
>>     renderWindowInteractor->SetRenderWindow(renderWindow);
>>
>>
>>
>>     renderer->AddActor(particleActor);
>>
>>     renderer->SetBackground(.3, .6, .3);
>>
>>
>>
>>     renderWindow->Render();
>>
>>     renderWindowInteractor->Start();
>>
>>
>>
>> I would like to make an animation where the particle postions are updated.
>> Thus I would change the string particleName in the argument of the 
>> function
>> particleReader->SetFileName() reading a new VTU file and update the 
>> particleReader->whole
>> procedure with the unstructured grid / 3D glyph / glyp filter obejcts.
>> I try to use vktProgrammableFilter and vtkCallbackCommand to 
>> impelment the animation process as I found in the example
>>
>> https://lorensen.github.io/VTKExamples/site/Cxx/Utilities/DataAnimati
>> o
>> n/
>>
>>
>>
>> The example uses an vtkSphereSource as an input for the programmable 
>> filter, so the example has essentially the code
>>
>>
>>
>> VTK_CREATE(vtkSphereSource, sphere);
>>
>> VTK_CREATE(vtkProgrammableFilter, filter);
>>
>> filter->SetInputConnection(sphere->GetOutputPort());
>>
>> filter->SetExecuteMethod(AdjustPoints2, filter);
>>
>> where the function "AdjustPoints2" updates some point position for 
>> the sphere source.
>>
>>
>>
>> I try to figure out what kind of input can be given to the 
>> programmable filter in the case of the VTU files.
>>
>> If would like to pass the reader itself to the programmable filer, so 
>> that it could be updated for each file
>>
>> and I could make the proper update for the grid and the glyphs too.
>> Then the updating function for the
>>
>> programmable filter execution method looked like:
>>
>>
>>
>> void Update(void *filterPointer)
>>
>> {
>>
>>     vtkSmartPointer<vtkProgrammableFilter> filter = 
>> static_cast<vtkProgrammableFilter*>(filterPointer);
>>
>>
>>
>>     ...
>>
>>
>>
>>     GetNewVTUFileName(particeName);
>>
>>     particleReader->SetFileName( particleName.c_str() );
>>
>>     particleReader->Update();
>>
>>
>>
>>     vtkUnstructuredGrid *grid           = particleReader->GetOutput();
>>
>>     vtkPointData        *pointData      = grid->GetPointData();
>>
>>     pointData->SetActiveScalars("Radii");
>>
>>
>>
>>     glyphFilter->SetInputData(grid);
>>
>>     glyphFilter->Update();
>>
>>
>>
>>     sphere->SetRadius(1);
>>
>>     sphereGlyph->SetSourceConnection(sphere->GetOutputPort());
>>
>>     sphereGlyph->SetInputConnection(glyphFilter->GetOutputPort());
>>
>>
>>
>>     particleMapper->SetInputConnection(sphereGlyph->GetOutputPort());
>>
>>     particleMapper->SetScalarModeToUsePointFieldData();
>>
>>     particleMapper->Update();
>>
>>
>>
>> }
>>
>>
>>
>> I am not sure if this is feasible since I do not see how to pass the 
>> reader itself to the programmable filter.
>>
>> Could anyone help me with this problem?
>>
>>
>>
>> Thank you,
>>
>> Zoltan
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> 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 VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>
>> Follow this link to subscribe/unsubscribe:
>> https://vtk.org/mailman/listinfo/vtkusers
>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: particles.tar.gz
Type: application/x-gzip
Size: 638878 bytes
Desc: particles.tar.gz
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180409/06194db7/attachment-0001.bin>


More information about the vtkusers mailing list