[vtkusers] Extra meta data in pvd

Chris Marsh chris.marsh at usask.ca
Fri Nov 18 14:18:22 EST 2016


Cory, that's awesome. Thanks very much.
Cheers
Chris


On 18 November 2016 at 12:41, Cory Quammen <cory.quammen at kitware.com> wrote:

> > I see what's going on now. But to be honest, it was easy to miss. If
> there
> > was a small "Oh, remember to use GetAbstractArrray for stringarray, etc"
> > that would have helped immensely. I find keeping vtk's inheritance
> graphs in
> > mind difficult  (they're pretty complex), so a reminder here and there
> would
> > go a long way towards someone like me who is piecing together usage off
> the
> > docs and examples, without fully groking the entirety of vtk.
>
> Thanks for the feedback. You are right that we should probably
> recommend using GetAbstractArray() by default as one typically needs
> to downcast the returned pointer anyway. Abstract arrays were added to
> VTK after the numeric arrays were added, so a lot of code still uses
> the GetArray() member function. To avoid breaking backwards
> compatibility, the GetAbstractArray() was added for accessing
> non-numeric arrays. Hence the confusion.
>
> I have a merge request for clarifying when to use these member
> functions up: https://gitlab.kitware.com/vtk/vtk/merge_requests/2180
>
> - Cory
>
> > Cheers
> > Chris
> >
> >
> >
> > Cheers
> > Chris
> >
> > On 16 November 2016 at 09:23, Cory Quammen <cory.quammen at kitware.com>
> wrote:
> >>
> >> > Does anyone know who would be able to amend the example I linked above
> >> > to
> >> > include the string? It is not at all clear from the docs that string
> >> > behaves
> >> > differently.
> >>
> >> Do you mean actually modify that example? Anyone with a wiki account
> >> can add an example. I just modified the example you cited to use
> >> GetAbstractArray(). Doing so doesn't really explain the API, but it
> >> may save someone the trouble you ran into. We always welcome
> >> improvements to the documentation in the source code.
> >>
> >> If you are asking for technical details on how to amend the example,
> this
> >> part
> >>
> >>   vtkSmartPointer<vtkIntArray> intValue =
> >>     vtkSmartPointer<vtkIntArray>::New();
> >>   intValue->SetNumberOfComponents(1);
> >>   intValue->SetName("MyIntValue");
> >>   intValue->InsertNextValue(5);
> >>
> >> should be changed to
> >>
> >> vtkSmartPointer<vtkStringArray> strArray =
> >>   vtkSmartPointer<vtkStringArray>::New();
> >> strArray->SetName("MyStringArray");
> >> vtkStdString strValue("my value");
> >> strArray->InsertNextValue(strValue);
> >>
> >> HTH,
> >> Cory
> >>
> >>
> >> >
> >> > On 11 November 2016 at 09:30, Cory Quammen <cory.quammen at kitware.com>
> >> > wrote:
> >> >>
> >> >> Ah, yes, I should have caught that you would be using a
> >> >> vtkStringArray, which is not accessed the same way as the numeric
> data
> >> >> arrays. Glad you found the solution.
> >> >>
> >> >> Cory
> >> >>
> >> >> On Thu, Nov 10, 2016 at 2:15 PM, Chris Marsh <chris.marsh at usask.ca>
> >> >> wrote:
> >> >> > Hi all,
> >> >> >
> >> >> > Following the advice here
> >> >> >
> >> >> > http://public.kitware.com/pipermail/paraview/2012-
> September/026100.html
> >> >> >
> >> >> > worked.  That is, in Python, the following works
> >> >> > my_mesh.GetFieldData().GetAbstractArray("proj4").GetValue(0)
> >> >> >
> >> >> >
> >> >> > On 9 November 2016 at 15:54, Chris Marsh <chris.marsh at usask.ca>
> >> >> > wrote:
> >> >> >>
> >> >> >> Hi Cory,
> >> >> >> Thanks for the reply. This looks like a perfect way forward.
> >> >> >>
> >> >> >> I am following this
> >> >> >> http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/FieldData
> >> >> >>
> >> >> >> and am having troubles with this approach. The field data doesn't
> >> >> >> seem
> >> >> >> to
> >> >> >> be set properly. I can see the field data *name* in paraview when
> I
> >> >> >> load my
> >> >> >> mesh, but it has an NA value.
> >> >> >>
> >> >> >>
> >> >> >> What I'm doing is:
> >> >> >>
> >> >> >> std::string _srs_wkt = "my projection data here";
> >> >> >> vtkSmartPointer<vtkStringArray> proj4 =
> >> >> >> vtkSmartPointer<vtkStringArray>::New();
> >> >> >> proj4->SetNumberOfComponents(1);
> >> >> >> proj4->SetName("proj4");
> >> >> >> proj4->InsertNextValue(_srs_wkt);
> >> >> >>
> >> >> >> vtkSmartPointer<vtkUnstructuredGrid> _vtk_unstructuredGrid =
> >> >> >> vtkSmartPointer<vtkUnstructuredGrid>::New();
> >> >> >>
> >> >> >> //... build up _vtk_unstructuredGrid etc.
> >> >> >>
> >> >> >>  _vtk_unstructuredGrid->GetFieldData()->AddArray(proj4);
> >> >> >>
> >> >> >>  //validate
> >> >> >>  vtkStringArray* test =
> >> >> >>
> >> >> >>
> >> >> >> vtkStringArray::SafeDownCast(_vtk_unstructuredGrid->
> GetFieldData()->GetArray("proj4"));
> >> >> >>
> >> >> >>  //test is NULL
> >> >> >>
> >> >> >> any ideas?
> >> >> >> Thanks
> >> >> >>
> >> >> >>
> >> >> >> Chris Marsh
> >> >> >> PhD Candidate
> >> >> >> chrismarsh.ca
> >> >> >>
> >> >> >> 13 Kirk Hall
> >> >> >> University of Saskatchewan
> >> >> >>
> >> >> >> On 9 November 2016 at 01:31, Cory Quammen <
> cory.quammen at kitware.com>
> >> >> >> wrote:
> >> >> >>>
> >> >> >>> Hi Chris,
> >> >> >>>
> >> >> >>> Usually we stuff this kind of data into the generic field data
> >> >> >>> (arrays
> >> >> >>> not associated with points of cells) in the data set. The VTU
> >> >> >>> reader/writer supports reading/writing field data.
> >> >> >>>
> >> >> >>> HTH,
> >> >> >>> Cory
> >> >> >>>
> >> >> >>> On Tue, Nov 8, 2016 at 6:15 PM, Chris Marsh <
> chris.marsh at usask.ca>
> >> >> >>> wrote:
> >> >> >>> > Hi,
> >> >> >>> >
> >> >> >>> > I would like to add some extra meta-data to a pvd file.
> >> >> >>> > Specifically, a
> >> >> >>> > proj4 string containing information about the coordinate system
> >> >> >>> > projection
> >> >> >>> > of the data contained in a vtu file.
> >> >> >>> >
> >> >> >>> > Is there a recommended way to do this?
> >> >> >>> >
> >> >> >>> > Cheers
> >> >> >>> > Chris
> >> >> >>> >
> >> >> >>> > _______________________________________________
> >> >> >>> > 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:
> >> >> >>> > http://public.kitware.com/mailman/listinfo/vtkusers
> >> >> >>> >
> >> >> >>>
> >> >> >>>
> >> >> >>>
> >> >> >>> --
> >> >> >>> Cory Quammen
> >> >> >>> Staff R&D Engineer
> >> >> >>> Kitware, Inc.
> >> >> >>
> >> >> >>
> >> >> >
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >> Cory Quammen
> >> >> Staff R&D Engineer
> >> >> Kitware, Inc.
> >> >
> >> >
> >>
> >>
> >>
> >> --
> >> Cory Quammen
> >> Staff R&D Engineer
> >> Kitware, Inc.
> >
> >
>
>
>
> --
> Cory Quammen
> Staff R&D Engineer
> Kitware, Inc.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161118/dca7b5c9/attachment.html>


More information about the vtkusers mailing list