Question

I am displaying a vtkUNiformGrid in Paraview, which contains (besides other things) 3-component flow vector in each point. When I display the dataset with volume rendering, it displays just fines. However, when I add Arrow glyph to the very same data, they do show the same data but elsewhere, smaller and in multiple copies (9 in number). Perhaps an images shows better what I mean: screenshot

I am a bit at loss as to where to look. Did I screw something up? Other ideas?

Was it helpful?

Solution 2

Just for the record, the cause was actually writing data into the vtkDoubleArray in a wrong way -- the array has 3 components and the indices were actually 1/3 of what they should have been, with x/y/z values interspersed (that gives the 3x3 pattern in the lower third, as I realized); I was assuming the components were stored contiguously, which is apparently not the case.

The old code was something like this:

auto flow=vtkSmartPointer<vtkDoubleArray>::New();
flow->SetNumberOfComponents(3);

auto grid=vtkSmartPointer<vtkUniformGrid>::New();
grid->SetDimensions(...);
grid->GetPointData()->AddArray(flow);

for(int i:{0,1,2}) flow->FillComponent(i,0);

for(ijk: ... /* traverses the grid, each point potentially more than once */ ){
   vtkIdType dataId=grid->ComputePointId(ijk);
   // XXX: this is what caused troubles:
   double* f0=flow->GetPointer(dataId);
   f[0]+=dx;
   f[1]+=dy;
   f[2]+=dz;
}

The correct version of the loop body is:

double f[3];
flow->GetTupleValue(dataId,f); // copy the data
f[0]+=dx;
f[1]+=dy;
f[2]+=dz;
flow->SetTupleValue(dataId,f);

Both scalar and vector datasets are now matching: screenshot-improved

OTHER TIPS

To help you debug, open a 2nd layout window and select Spreadsheet View, and look at the source on which you are applying the glyph filter. Is the vector data that you're trying to plot under PointData? Then check in the glyph filter properties that the Vectors drop down box indicates the array that you're trying to plot.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top