[vtkusers] vtkParticleReader and vtkGlyph3D

Sgouros, Thomas thomas_sgouros at brown.edu
Fri Apr 6 20:56:48 EDT 2018


Thank you, this is very kind again. How did you convert it?

I would expect that a reader that did not read a file properly would issue
an error message. But perhaps I should modify those expectations.

Thank you,

 -Tom

On Fri, Apr 6, 2018 at 8:21 PM, kenichiro yoshimi <rccm.kyoshimi at gmail.com>
wrote:

> Hi Tom,
>
> At last I can replicate your problem. This may be caused by not
> selecting an appropriate reader.
>
> vtkParticleReader can't read output_p40.vtk you upload since the
> expected format is something like:
>  x, y, z, scalar
> It also allows for x\ty\tz\tscalar or x y z scalar. See the
> documentation about vtkParticleReader.
> https://www.vtk.org/doc/nightly/html/classvtkParticleReader.html#details
>
> The correct way to read output_p40.vtk is to use vtkPolyDataReader
> rather than vtkParticleReader.
>
> I hope this will be of some help.
> Thanks,
>
> 2018-04-07 3:30 GMT+09:00 Sgouros, Thomas <thomas_sgouros at brown.edu>:
> > Thank you, you are very kind to have taken this time. My original program
> > does indeed work with your data and your data is the same as mine, but
> the
> > data files are in different formats, even though they are both ASCII and
> > contain the same data. The top of my file looks like this:
> >
> > # vtk DataFile Version 2.0
> > particlePositions
> > ASCII
> > DATASET POLYDATA
> > POINTS 5111 float
> > 13.451000 37.225000 0.417060
> > 14.771000 10.352000 17.837000
> > 18.511000 32.313000 12.778000
> > 0.644430 21.956000 50.414000
> > 12.346000 22.660000 50.371000
> > 7.361000 7.991100 45.339000
> > 24.999000 16.144000 27.909000 ...
> >
> > There are 5,111 data points in this file, followed by a few thousand
> 1.0's.
> >
> > The top of the file you sent back to me looks like this, and this one
> works
> > fine.
> >
> > 13.451000 37.225000 0.417060 1.0
> > 14.771000 10.352000 17.837000 1.0
> > 18.511000 32.313000 12.778000 1.0
> > 0.644430 21.956000 50.414000 1.0
> > 12.346000 22.660000 50.371000 1.0
> > 7.361000 7.991100 45.339000 1.0
> > 24.999000 16.144000 27.909000 1.0 ...
> >
> > Both files read without obvious error, but only one of them shows data.
> Can
> > anyone explain this to me? Or is there somewhere I should be looking for
> > errors? (And what did you use to convert it?)
> >
> > Many thanks,
> >
> >  -Tom
> >
> >
> > On Fri, Apr 6, 2018 at 10:49 AM, kenichiro yoshimi <
> rccm.kyoshimi at gmail.com>
> > wrote:
> >>
> >> Hello Tom,
> >>
> >> Your code and data work without any problem and display glyphs. The
> >> testing data is attached.
> >> There is some doubt whether the problem always occurs.
> >>
> >> Thanks,
> >>
> >> 2018-04-04 5:54 GMT+09:00 Sgouros, Thomas <thomas_sgouros at brown.edu>:
> >> > "It is often some unexpected minor thing that causes the failure."
> >> >
> >> > I'm certain of that.
> >> >
> >> > Here's the code, mostly pinched straight from the Glyph3D example.
> (And
> >> > I've
> >> > tried swapping the endianness, just for giggles.) The data is an ASCII
> >> > vtk
> >> > file that you can get from sgouros.com/output_p40.vtk.
> >> >
> >> > Thank you,
> >> >
> >> >  -Tom
> >> >
> >> >
> >> > #include <vtkVersion.h>
> >> > #include <vtkSmartPointer.h>
> >> > #include <vtkCubeSource.h>
> >> > #include <vtkPolyData.h>
> >> > #include <vtkPoints.h>
> >> > #include <vtkGlyph3D.h>
> >> > #include <vtkCellArray.h>
> >> > #include <vtkPolyDataMapper.h>
> >> > #include <vtkActor.h>
> >> > #include <vtkRenderWindow.h>
> >> > #include <vtkRenderer.h>
> >> > #include <vtkRenderWindowInteractor.h>
> >> > #include <vtkParticleReader.h>
> >> > #include <vtkPolyDataMapper.h>
> >> >
> >> >
> >> > int main(int argc, char* argv[]) {
> >> >
> >> >   std::string filePath = argv[1];
> >> >   vtkSmartPointer<vtkParticleReader> reader =
> >> >     vtkSmartPointer<vtkParticleReader>::New();
> >> >
> >> >   reader->SetFileName ( filePath.c_str() );
> >> >   // if nothing gets displayed or totally wrong, swap the endianness
> >> >   reader->SetDataByteOrderToBigEndian();
> >> >   reader->Update();
> >> >
> >> >   // Create anything you want here, we will use a cube for the demo.
> >> >   vtkSmartPointer<vtkCubeSource> cubeSource =
> >> >       vtkSmartPointer<vtkCubeSource>::New();
> >> >
> >> >   vtkSmartPointer<vtkGlyph3D> glyph3D =
> >> >     vtkSmartPointer<vtkGlyph3D>::New();
> >> >
> >> >   glyph3D->SetSourceConnection(cubeSource->GetOutputPort());
> >> >   glyph3D->SetInputConnection(reader->GetOutputPort());
> >> >
> >> >   glyph3D->Update();
> >> >
> >> >   std::cout << *(reader->GetOutput()) << std::endl;
> >> >
> >> >   // Visualize
> >> >   vtkSmartPointer<vtkPolyDataMapper> mapper =
> >> >     vtkSmartPointer<vtkPolyDataMapper>::New();
> >> >   mapper->SetInputConnection(glyph3D->GetOutputPort());
> >> >
> >> >   vtkSmartPointer<vtkActor> actor =
> >> >     vtkSmartPointer<vtkActor>::New();
> >> >   actor->SetMapper(mapper);
> >> >
> >> >   vtkSmartPointer<vtkRenderer> renderer =
> >> >     vtkSmartPointer<vtkRenderer>::New();
> >> >   vtkSmartPointer<vtkRenderWindow> renderWindow =
> >> >     vtkSmartPointer<vtkRenderWindow>::New();
> >> >   renderWindow->AddRenderer(renderer);
> >> >   vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
> >> >     vtkSmartPointer<vtkRenderWindowInteractor>::New();
> >> >   renderWindowInteractor->SetRenderWindow(renderWindow);
> >> >
> >> >   renderer->AddActor(actor);
> >> >   renderer->SetBackground(.3, .6, .3); // Background color green
> >> >
> >> >   renderWindow->Render();
> >> >   renderWindowInteractor->Start();
> >> >
> >> >   return EXIT_SUCCESS;
> >> > }
> >> >
> >> >
> >> > On Tue, Apr 3, 2018 at 4:46 PM, Bill Lorensen <
> bill.lorensen at gmail.com>
> >> > wrote:
> >> >>
> >> >> Post a small compilable example, please. It is often some unexpected
> >> >> minor thing that causes the failure.
> >> >>
> >> >> Thanks,
> >> >>
> >> >> Bill
> >> >>
> >> >> BTW: The wiki examples have been replaced by VTKExamples here:
> >> >>
> >> >> https://lorensen.github.io/VTKExamples/site/
> >> >>
> >> >>
> >> >> On Tue, Apr 3, 2018 at 1:43 PM, Sebastien Jourdain
> >> >> <sebastien.jourdain at kitware.com> wrote:
> >> >> > What you are doing seems correct and the data is valid (it has
> >> >> > points).
> >> >> >
> >> >> > How do you render the glyph3d filter? Using a polydata mapper? I'm
> >> >> > guessing
> >> >> > no issue on that end?
> >> >> >
> >> >> > Ideally you should use the glyph mapper instead of the filter. But
> if
> >> >> > memory
> >> >> > is not a big deal, don't worry about it.
> >> >> >
> >> >> > Seb
> >> >> >
> >> >> > On Tue, Apr 3, 2018 at 1:47 PM, Sgouros, Thomas
> >> >> > <thomas_sgouros at brown.edu>
> >> >> > wrote:
> >> >> >>
> >> >> >> This is reader->GetOutput()
> >> >> >>
> >> >> >> vtkPolyData (0x7f8ce050dad0)
> >> >> >>
> >> >> >>   Debug: Off
> >> >> >>
> >> >> >>   Modified Time: 217
> >> >> >>
> >> >> >>   Reference Count: 1
> >> >> >>
> >> >> >>   Registered Events: (none)
> >> >> >>
> >> >> >>   Information: 0x7f8ce050d9b0
> >> >> >>
> >> >> >>   Data Released: False
> >> >> >>
> >> >> >>   Global Release Data: Off
> >> >> >>
> >> >> >>   UpdateTime: 218
> >> >> >>
> >> >> >>   Field Data:
> >> >> >>
> >> >> >>     Debug: Off
> >> >> >>
> >> >> >>     Modified Time: 167
> >> >> >>
> >> >> >>     Reference Count: 1
> >> >> >>
> >> >> >>     Registered Events: (none)
> >> >> >>
> >> >> >>     Number Of Arrays: 0
> >> >> >>
> >> >> >>     Number Of Components: 0
> >> >> >>
> >> >> >>     Number Of Tuples: 0
> >> >> >>
> >> >> >>   Number Of Points: 10229
> >> >> >>
> >> >> >>   Number Of Cells: 10229
> >> >> >>
> >> >> >>
> >> >> >> It goes on for quite a bit more. As I said, when I feed this to a
> >> >> >> vtkPolyDataMapper, it displays and works fine, but I want little
> >> >> >> spheres,
> >> >> >> not little flat rectangles and I thought I could just redirect
> that
> >> >> >> into the
> >> >> >> vtkGlyph3D object, but I must be misunderstanding something.
> >> >> >>
> >> >> >> Thank you,
> >> >> >>
> >> >> >>  -Tom
> >> >> >>
> >> >> >> On Tue, Apr 3, 2018 at 3:26 PM, Sebastien Jourdain
> >> >> >> <sebastien.jourdain at kitware.com> wrote:
> >> >> >>>
> >> >> >>> You can try to see what the GetOutput() contains as my assumption
> >> >> >>> it
> >> >> >>> would be empty (No points => Number of Points: 0).
> >> >> >>>
> >> >> >>> reader->GetOutput()->PrintSelf(cout, vtkIndent(2));
> >> >> >>>
> >> >> >>> What I mean was
> >> >> >>>
> >> >> >>> glyph3D->SetInputConnection(reader->GetOutputPort());
> >> >> >>>
> >> >> >>>
> >> >> >>> On Tue, Apr 3, 2018 at 1:23 PM, Sgouros, Thomas
> >> >> >>> <thomas_sgouros at brown.edu> wrote:
> >> >> >>>>
> >> >> >>>> Hi Sebastien:
> >> >> >>>>
> >> >> >>>> Sorry if that was unclear. The third block of code comes first,
> >> >> >>>> and
> >> >> >>>> reader->Update() is called before I use its GetOutput().  In
> situ,
> >> >> >>>> it
> >> >> >>>> looks
> >> >> >>>> like this:
> >> >> >>>>
> >> >> >>>>  ...
> >> >> >>>>   vtkSmartPointer<vtkParticleReader> reader =
> >> >> >>>> vtkSmartPointer<vtkParticleReader>::New();
> >> >> >>>>   reader->SetFileName ( filePath.c_str() );
> >> >> >>>>   reader->SetDataByteOrderToBigEndian();
> >> >> >>>>   reader->Update();
> >> >> >>>>
> >> >> >>>>   // Create anything you want here, we will use a cube for the
> >> >> >>>> demo.
> >> >> >>>>   vtkSmartPointer<vtkCubeSource> cubeSource =
> >> >> >>>>       vtkSmartPointer<vtkCubeSource>::New();
> >> >> >>>>
> >> >> >>>>   vtkSmartPointer<vtkGlyph3D> glyph3D =
> >> >> >>>> vtkSmartPointer<vtkGlyph3D>::New();
> >> >> >>>>   glyph3D->SetSourceConnection(cubeSource->GetOutputPort());
> >> >> >>>>   glyph3D->SetInputData(reader->GetOutput());
> >> >> >>>>   glyph3D->Update();
> >> >> >>>>
> >> >> >>>>   ...
> >> >> >>>>
> >> >> >>>> I don't think I understand what you mean by the connection
> instead
> >> >> >>>> of
> >> >> >>>> the dataset directly.
> >> >> >>>>
> >> >> >>>> Is there a way to peek inside glyph3D and see what it thinks it
> >> >> >>>> has?
> >> >> >>>>
> >> >> >>>> Thank you,
> >> >> >>>>
> >> >> >>>>  -Tom
> >> >> >>>>
> >> >> >>>>
> >> >> >>>> On Tue, Apr 3, 2018 at 2:53 PM, Sebastien Jourdain
> >> >> >>>> <sebastien.jourdain at kitware.com> wrote:
> >> >> >>>>>
> >> >> >>>>> Tom,
> >> >> >>>>>
> >> >> >>>>> Just make sure that reader->Update(); was called before
> >> >> >>>>> glyph3D->SetInputData(reader->GetOutput());
> >> >> >>>>> But it would be better to use the connection instead of the
> >> >> >>>>> dataset
> >> >> >>>>> directly.
> >> >> >>>>>
> >> >> >>>>> Seb
> >> >> >>>>>
> >> >> >>>>> On Tue, Apr 3, 2018 at 12:27 PM, Sgouros, Thomas
> >> >> >>>>> <thomas_sgouros at brown.edu> wrote:
> >> >> >>>>>>
> >> >> >>>>>> Hello all:
> >> >> >>>>>>
> >> >> >>>>>> Can someone help me understand why this code works:
> >> >> >>>>>>
> >> >> >>>>>>   vtkSmartPointer<vtkGlyph3D> glyph3D =
> >> >> >>>>>> vtkSmartPointer<vtkGlyph3D>::New();
> >> >> >>>>>>   glyph3D->SetSourceConnection(cubeSource->GetOutputPort());
> >> >> >>>>>>   glyph3D->SetInputData(polydata);
> >> >> >>>>>>   glyph3D->Update();
> >> >> >>>>>>
> >> >> >>>>>> And this does not (nothing displayed)?
> >> >> >>>>>>
> >> >> >>>>>>   vtkSmartPointer<vtkGlyph3D> glyph3D =
> >> >> >>>>>> vtkSmartPointer<vtkGlyph3D>::New();
> >> >> >>>>>>   glyph3D->SetSourceConnection(cubeSource->GetOutputPort());
> >> >> >>>>>>   glyph3D->SetInputData(reader->GetOutput());
> >> >> >>>>>>   glyph3D->Update();
> >> >> >>>>>>
> >> >> >>>>>> The first clip is from
> >> >> >>>>>> https://www.vtk.org/Wiki/VTK/Examples/Cxx/Filtering/Glyph3D
> >> >> >>>>>>
> >> >> >>>>>> The 'reader' object is stolen from the ParticleReader example:
> >> >> >>>>>>
> >> >> >>>>>>   vtkSmartPointer<vtkParticleReader> reader =
> >> >> >>>>>> vtkSmartPointer<vtkParticleReader>::New();
> >> >> >>>>>>   reader->SetFileName ( filePath.c_str() );
> >> >> >>>>>>   reader->SetDataByteOrderToBigEndian();
> >> >> >>>>>>   reader->Update();
> >> >> >>>>>>
> >> >> >>>>>> The program compiles, but no data appears. It works fine (data
> >> >> >>>>>> appears) in the context of the ParticleReader example, where
> it
> >> >> >>>>>> shows all
> >> >> >>>>>> the data points. But I want to see them as glyphs, not little
> >> >> >>>>>> squares. I
> >> >> >>>>>> seem to be misunderstanding something fundamental, but not
> >> >> >>>>>> seeing
> >> >> >>>>>> what it
> >> >> >>>>>> could be.
> >> >> >>>>>>
> >> >> >>>>>> Many thanks,
> >> >> >>>>>>
> >> >> >>>>>>  -Tom
> >> >> >>>>>>
> >> >> >>>>>>
> >> >> >>>>>>
> >> >> >>>>>> _______________________________________________
> >> >> >>>>>> 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
> >> >> >>>>>>
> >> >> >>>>>
> >> >> >>>>
> >> >> >>>
> >> >> >>
> >> >> >
> >> >> >
> >> >> > _______________________________________________
> >> >> > 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
> >> >> >
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >> Unpaid intern in BillsParadise at noware dot com
> >> >
> >> >
> >> >
> >> > _______________________________________________
> >> > 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 --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180406/5fa734a4/attachment.html>


More information about the vtkusers mailing list