[vtkusers] Extra meta data in pvd

Chris Marsh chris.marsh at usask.ca
Wed Nov 16 10:43:21 EST 2016


Hi Corry,

Sorry, I meant the former. The updated wiki looks good. Would have saved me
some effort :p

w.r.t in-code documentation, after your comment and some googling, this is
where I ended up in the docs
http://www.vtk.org/doc/nightly/html/classvtkDataObject.html#a72f64ab58126f72e048410751091011b

which lead me to
http://www.vtk.org/doc/nightly/html/classvtkFieldData.html#a888a6492210426d4ba4d358b87ab198f

>From these documents, there is no indication what the difference between
GetAbstractArray and GetArray is, other than return types. On my first pass
through, AbstractArray seems like base class (which it is) and DataArray
seems like the one that should be used. Looking at the inheritance graph
here
http://www.vtk.org/doc/nightly/html/classvtkAbstractArray.html

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.

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.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161116/3d4a9342/attachment.html>


More information about the vtkusers mailing list