[vtkusers] Unable to read all scalars from Cell Data in a VTK file

Cory Quammen cory.quammen at kitware.com
Mon Jan 4 23:44:04 EST 2016


On Mon, Jan 4, 2016 at 10:06 PM, amit112amit <amit112amit at yahoo.co.in>
wrote:

> Thanks a lot for your reply, Cory. ReadAllScalarsOn() and
> ReadAllVectorsOn()
> are exactly the functions that I needed to read the original version of my
> legacy VTK file. That VTK file was generated directly using C++ file output
> functions. That means there was no vtkPolyData object created and no
> vtkPolyDataWriter was used to write it. I am trying to use
> vtkPolyDataWriter
> such that I get a legacy VTK files which has multiple scalars and vectors
> listed as I showed in my original VTK file sample. But I am not able to
> find
> how.
>
> How do I add multiple scalars to a cell-data? I looked at the code for
>    vtkCellData *cd->SetScalars(<data array>);
> It removes the existing scalar array and then adds the new one.
> Whereas if I do
>    vtkCellData *cd->AddArray(<data-array>);
> when i write the file using vtkPolyDataWriter object, the added array
> appears under FIELD section instead of under SCALAR. This is what prompted
> me to think that all except the first scalar must be stored as field data
> and thus the file format I found to work.
>

Yep, that's the right way to add additional arrays in vtkCellData. You
probably don't even need to call cd->SetScalars(<data array>) to write out
all your fields. I would trust the output of vtkPolyDataWriter to be the
correct way to write the files. It might be that you happened to find a
not-quite-correct variant of the VTK legacy file format that just happens
to be read in correctly when RealAllScalars() is on.

FYI, the notion of active scalars/vectors/normals/tensors is bit
old-fashioned and VTK is moving away from the concept.

Cory


>
> Can you please help? Thanks again.
>
> Regards,
> Amit
>
>
>
>
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/Unable-to-read-all-scalars-from-Cell-Data-in-a-VTK-file-tp5735720p5735778.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> 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
R&D Engineer
Kitware, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160104/f5d54058/attachment.html>


More information about the vtkusers mailing list