[vtkusers] Attaching additional metadata information to vtkDoubleArray

David E DeMarle dave.demarle at kitware.com
Mon Feb 6 18:56:36 EST 2012


Add #include "vtkInformationDoubleVectorKey.h" and #2 should work.

David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909



On Mon, Feb 6, 2012 at 1:21 PM, Alexander Pletzer <pletzer at txcorp.com> wrote:
> Hi VTK'ians,
>
> I'm trying to figure out how additional (metadata) information can be
> attached to vtk objects such as vtkDoubleArray. Specifically I would like to
> attach a vector of 3 doubles.
> It looks like vtkInformation acts as a hash map and is designed for that
> purpose. Although it is straightforward to access the vtkInformation pointer
> to the array using the GetInformation method, I've been unable to set
> key/value pairs to the vtkInformation object, mainly because I cannot figure
> out how to build the key, see code below.
>
> Thanks in advance for any help!
>
> Cheers,
>
> --Alex
>
> // vtk includes
> #include <vtkDoubleArray.h>
> #include <vtkInformation.h>
>
> // std includes
> #include <iostream>
>
>
> int main() {
> // creation of a simple array
> vtkDoubleArray* array = vtkDoubleArray::New();
> array->SetName("array");
> array->SetNumberOfComponents(1);
> array->SetNumberOfTuples(2);
> array->SetValue(0, 1.);
> array->SetValue(1, 2.);
>
> access the pointer to the info
> vtkInformation* info = array->GetInformation();
>
> // don't know how to create the key and values
>
> // THIS WON'T COMPILE
> vtkInformationDoubleVectorKey *key = vtkInformationDoubleVectorKey::New();
> /// error: no New
>
> // THIS WON'T COMPILE
> const char *name = "mykey";
> const char *location = "";
> int length = 3;
> vtkInformationDoubleVectorKey *key = new vtkInformationDoubleVectorKey(name,
> location,
> length); // invalid use of incomplete type ‘struct
> vtkInformationDoubleVectorKey’
>
> // build values
> double values[] = {1., 2., 3.};
>
> // Once I have key and values built, I want to call....
> info->Set(key, values, 3);
>
> info->Print(std::cout);
> array->Delete();
> }
>
>
>
>
> std::cout << "array has info " << array->HasInformation() << '\n';
>
> _______________________________________________
> 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
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers



More information about the vtkusers mailing list