[vtkusers] Extra meta data in pvd

Cory Quammen cory.quammen at kitware.com
Wed Nov 16 10:23:38 EST 2016


> 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.


More information about the vtkusers mailing list