[vtkusers] Cannot recover user defined vtkInformation from vtkUnstructuredGrid

David Gobbi david.gobbi at gmail.com
Sun Dec 3 20:52:33 EST 2017


A key can only be constructed once per session (i.e. once per program
execution).
So it seems that you should be able to make a module that defines your keys,
or use vtkInformationKeyLookup.Find(name, location) to verify that the key
doesn't already exist before you create it.


On Sun, Dec 3, 2017 at 6:06 PM, scotsman60 <doug at beachmailing.com> wrote:

> David,
>
> Thanks for this suggestion - unfortunately it doesn't seem to work.
>
> I have never found recreating a key with exactly the same parameters to
> work
> and (I think there's a post on here about this). I always introspect the
> vtkInformation object, get the keys and then use the keys recovered form
> the
> vtkInformation to get the values,
>
>                 info = self.mesh.GetCellData().
> GetArray(i).GetInformation()
>
>                 info_iterator = vtk.vtkInformationIterator()
>                 info_iterator.SetInformation(info)
>                 info_iterator.InitTraversal ()
>
>                 key = info_iterator.GetCurrentKey()
>
>                 quantity= info.Get(key)
>
>
>
> David Gobbi wrote
> > Before you load the data, re-make the keys so that VTK will register them
> > as valid keys:
> >
> > quantity_key = keys.MakeKey(vtk.vtkInformationStringKey, "Quantity",
> "1")
> > increment_key = keys.MakeKey(vtk.vtkInformationIntegerKey, "Increment",
> > "2")
> > # the keys are defined now, so you should be able to load the data
> >
> >
> > On Sun, Dec 3, 2017 at 4:00 PM, scotsman60 <
>
> > doug@
>
> > > wrote:
> >
> >> Hello!!
> >>
> >> I'm using the Python API to vtk and I'm unable to import custom
> >> vtkInformation from a vtkUnstructuredGrid.
> >>
> >> First of all I'm associating custom information to CellData in a
> >> vtkUnstructuredGrid using the following code - where self.mesh is the
> >> vtkUnstructuredGrid
> >>
> >>     #Add the information keys
> >>     info = densityScalars.GetInformation()
> >>
> >>     # First the Quantity type
> >>     quantity_key = keys.MakeKey(vtk.vtkInformationStringKey,
> "Quantity",
> >> "1")
> >>     quantity_key.Set(info, "Topology Density")
> >>
> >>     #Now the Increment number
> >>     increment_key = keys.MakeKey(vtk.vtkInformationIntegerKey,
> >> "Increment",
> >> "2")
> >>     increment_key.Set(info, increment)
> >>
> >>
> >>     #Add the array to the mesh
> >>     self.mesh.GetCellData().AddArray(densityScalars)
> >>
> >>
> >> Later I save the vtkUnstructuredGrid using vtkUnstructuredGridWriter,
> >> then
> >> Import it into a new Python session (Basically my program uses the
> >> vtkUnstructuredGrid as its persistence mechanism.........)
> >>
> >> When I read the grid using vtkUnstructuredGridReader I get a whole bunch
> >> of
> >> warnings from vtk
> >>
> >>     Warning: In ..\IO\Legacy\vtkDataReader.cxx, line 2668
> >>     vtkUnstructuredGridReader (00000000044D7520): Could not locate key
> >> 2::Increment. Is the module
> >>     in which it is defined linked?
> >>
> >>     Warning: In ..\IO\Legacy\vtkDataReader.cxx, line 2907
> >>     vtkUnstructuredGridReader (00000000044D7520): Ignoring line in
> >> INFORMATION block: DATA 1
> >>
> >>     Warning: In ..\IO\Legacy\vtkDataReader.cxx, line 2668
> >>     vtkUnstructuredGridReader (00000000044D7520): Could not locate key
> >> 2::Increment. Is the module
> >>     in which it is defined linked?
> >>
> >>     Warning: In ..\IO\Legacy\vtkDataReader.cxx, line 2907
> >>     vtkUnstructuredGridReader (00000000044D7520): Ignoring line in
> >> INFORMATION block: DATA 2
> >>
> >>     Warning: In ..\IO\Legacy\vtkDataReader.cxx, line 2668
> >>     vtkUnstructuredGridReader (00000000044D7520): Could not locate key
> >> 1::Quantity. Is the module in
> >>     which it is defined linked?
> >>
> >>     Warning: In ..\IO\Legacy\vtkDataReader.cxx, line 2907
> >>     vtkUnstructuredGridReader (00000000044D7520): Ignoring line in
> >> INFORMATION block: DATA
> >>     Topology%20Density
> >>
> >>
> >> Any ideas on what's going on here?
> >>
> >> Thanks in advance,
> >>
> >> Doug
> >>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171203/f316acdc/attachment.html>


More information about the vtkusers mailing list