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

Martin Baumann mailsgetlost at web.de
Thu May 25 18:04:27 EDT 2006


Hi Amy,

as I read legacy files and write xml files this is good news.
I still cannot see a function that lets me append data on a xml file.

  vtkXMLUnstructuredGridWriter* _xml_grid_writer = 
vtkXMLUnstructuredGridWriter::New();

  _grid_reader->SetScalarsName("Data1");
  _grid_reader->Update();

  _xml_grid_writer->SetFileName("camenbert.hvs.xml");
  _xml_grid_writer->SetInput(_grid_reader->GetOutput());
  _xml_grid_writer->SetDataModeToAscii();
  _xml_grid_writer->Write();

  _grid_reader->SetScalarsName("Data2");
  _grid_reader->Update();

  _xml_grid_writer->Write(); // WRONG

By the last command the file is overwritten and only contains Data2.
How can the data be appended to the file?

Regards, M.B.


Amy Squillacote schrieb:

> 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
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060526/1f5bb654/attachment.htm>


More information about the vtkusers mailing list