[vtk-developers] vtkDataSetWriter, several data sets?

Nico Schlömer nico.schloemer at gmail.com
Wed Nov 25 05:58:22 EST 2009


Hi all,

being relatively unexperienced with VTK, I'm kind of struggling with its 
C++ interface now so after I searched the mailing lists I thought I 
might post my (trivial?) problem here.

What I'd like to do is create a VTK data file (e.g., 
vtkStructuredPoints) containing *two* datasets. What I find highly 
confusing is that the SCALARS NAME property is a property of the writer 
(e.g., vtkDataSetWriter), which suggests that only one data set per 
writer is admissible. Would I have to call writer->Write() twice?
On the other hand,

I would use components, too, but it seems I can't connect components to 
different LOOKUP_TABLEs.

Anyways, hints or examples for any of the two cases would be highly 
appreciated!

Cheers,
Nico


PS. Below my attempt on structuredPoints with components. -- Works 
alright except for the fact that I can't specify the LOOKUP_TABLE 
separately for each component.
========================== *snip* ==========================
    vtkSmartPointer<vtkImageAppendComponents> imageAppend = 
vtkImageAppendComponents::New();

    vtkSmartPointer<vtkDataSetWriter> writer = vtkDataSetWriter::New();
    writer->SetFileName("myfile.vtk");
    writer->SetHeader("myheader");
    writer->SetFileTypeToASCII();
    writer->SetScalarsName("x");

    for (unsigned int k=0; k<numVectors; k++ ) {
      vtkSmartPointer<vtkStructuredPoints> spData = 
vtkStructuredPoints::New();
      spData->SetDimensions(Nx + 1, Nx + 1, 1);
      spData->SetOrigin(0, 0, 0);
      spData->SetSpacing(h, h, 0);
      // [...] setup scalars
      spData->GetPointData()->SetScalars(scalars);

      imageAppend->AddInput(spData);
    }

    writer->SetInputConnection(imageAppend->GetOutputPort());
    writer->Update();
    writer->Write();
========================== *snap* ==========================



More information about the vtk-developers mailing list