[vtkusers] Cannot recover user defined vtkInformation from vtkUnstructuredGrid

scotsman60 doug at beachmailing.com
Sun Dec 3 20:06:04 EST 2017


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





--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


More information about the vtkusers mailing list