[vtkusers] Re: file format conversion (XML <-> simple legacy format)

Amy Squillacote amy.squillacote at kitware.com
Thu May 25 14:04:22 EDT 2006


Hi M.B.,

Using the legacy VTK writers (e.g., vtkPolyDataWriter, 
vtkUnstructuredGridWriter, etc.), if you want to have more than one 
scalar, vector, etc. array, arrays beyond the first one must be 
stored in field data. Try calling GetNumberOfFieldDataInFile(); it 
should account for your "missing" arrays.

(At the time these writers were written, this mirrored the structure 
of vtkPointData / vtkCellData.) Using the VTK XML writers, you can 
certainly store more than one of any given type of array.

- Amy

At 01:20 PM 5/25/2006, Martin Baumann wrote:
>Is it generally possible to save more than one scalar / vector into 
>one file using vtk's writers?
>It seems to me as if one could only save ONE scalar / vector.
>
>Regards, M.B.
>
>
>Martin Baumann schrieb:
>
>>Hi,
>>
>>I just realized, that I have the same problem using 
>>vtkUnstructuredGridReader and vtkUnstructuredGridWriter:
>>
>>  // read orginal file
>>  vtkUnstructuredGridReader*    _grid_reader      = 
>> vtkUnstructuredGridReader::New();
>>  _grid_reader->SetFileName(in_file.c_str());
>>  _grid_reader->Update();
>>  cout << "#Points : " << 
>> _grid_reader->GetOutput()->GetNumberOfPoints() << endl;
>>  cout << "#Scalars: " << _grid_reader->GetNumberOfScalarsInFile() << endl;
>>
>>  // writer new file
>>  vtkUnstructuredGridWriter* _grid_writer  = 
>> vtkUnstructuredGridWriter::New();
>>  _grid_writer->SetFileName("camembert.new.hvs");
>>  _grid_writer->SetInput(_grid_reader->GetOutput());
>>  _grid_writer->Write();
>>
>>  // read new file
>>  _grid_reader->SetFileName("camembert.new.hvs");
>>  _grid_reader->Update();
>>  cout << "#Points : " << 
>> _grid_reader->GetOutput()->GetNumberOfPoints() << endl;
>>  cout << "#Scalars: " << _grid_reader->GetNumberOfScalarsInFile() << endl;
>>
>>
>>This makes the following output:
>>
>>  #Points : 400
>>  #Scalars: 3
>>  #Points : 400
>>  #Scalars: 1
>>
>>Hmmm....
>>
>>Regards, M.B.
>>_______________________________________________________________
>>SMS schreiben mit WEB.DE FreeMail - einfach, schnell und
>>kostenguenstig. Jetzt gleich testen! http://f.web.de/?mc=021192
>>
>>_______________________________________________
>>This is the private VTK discussion list. Please keep messages 
>>on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>>Follow this link to subscribe/unsubscribe:
>>http://www.vtk.org/mailman/listinfo/vtkusers
>>
>>
>_______________________________________________
>This is the private VTK discussion list. Please keep messages 
>on-topic. Check the 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