[vtkusers] Writing an Unstructured data to a VTK file

the lily the.1.lily at hotmail.com
Fri Dec 22 07:20:44 EST 2017


Hello,

I have some arrays storing the values of the data and I want to write it as a vtk file, the data is unstructured tetrahedrons

- Three arrays (X, Y, and Z) storing the coordinates
- An array (data) storing scalar field
- An array (ptIds) storing cell connectivity

I'm trying to pass the scalar field to vtkUnstructuredGrid but I get an error:

error: no member named 'SetInputData' in
      'vtkUnstructuredGrid'

This is the code I'm using

vtkSmartPointer< vtkPoints > points = vtkSmartPointer< vtkPoints > :: New();

vtkSmartPointer< vtkFloatArray > val = vtkSmartPointer< vtkFloatArray > :: New();

val->SetNumberOfComponents(1);


for(int i=0; i < npts; i++)

{

    points->InsertNextPoint(X[i], Y[i], Z[i]);
    val->InsertTuple1(i, data[i]);

}

vtkSmartPointer<vtkUnstructuredGrid> unstructuredGrid = vtkSmartPointer<vtkUnstructuredGrid>::New();
 unstructuredGrid->SetPoints(points);
unstructuredGrid->GetPointData()->SetScalars(val);

for(int i=0; i< ntets; i++)
      unstructuredGrid->InsertNextCell(VTK_TETRA, 4, ptIds[i]);


vtkDataSetWriter *w = vtkDataSetWriter::New();
w->SetFileTypeToASCII();
w->SetInputData(unstructuredGrid);
 w->SetFileName("data.vtk");
 w->Write();



What is the correct way to pass the scalar field?



-Thanks

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://vtk.org/pipermail/vtkusers/attachments/20171222/631e53a5/attachment.html>


More information about the vtkusers mailing list