[vtkusers] Regularly sample 3D unstructured tensor grid

kenichiro yoshimi rccm.kyoshimi at gmail.com
Fri Nov 24 22:49:52 EST 2017


Hi,

The standard way of retrieving PointData is not
 auto tensors = pointData->GetArray();
but
 auto tensors = pointData->GetArray(0);
 auto tensors = pointData->GetArray("array-name");
 auto tensors = pointData->GetTensors("array-name");

vtkPointData inherits from vtkDataSetAttributes and
pointData->GetArray() is trying to access the FieldData which
describes global properties of pointData, but it is null.

Thanks

2017-11-24 21:48 GMT+09:00 PetiteViking <jochen.jankowai at gmail.com>:
> Hello everyone! I've tried to find an answer to my problem in the forum for
> quite some time now but I cannot seem to find a solution. I have an
> unstructured hexahedral grid that stores one tensor per cell. What I need in
> my application though is a regulargrid so I would like to regularly sample
> the field. So far, this is what I am trying to (see code below). In one of
> the posts here I have read that vtkProbeFilter will produce output that
> corresponds to the input so I amusing a structured grid as input for which I
> have computed points. And while I manage to retreive a structured grid from
> the probeFilter, the variable tensors ends up being a nullptr. auto reader =
> vtkUnstructuredGridReader::New(); reader->SetFileName(file_.get().c_str());
> reader->Update(); auto unstructuredGrid = reader->GetOutput(); // Create a
> grid of points to interpolate over auto gridSize = glm::ivec3(32, 32, 32);
> vtkSmartPointer<vtkPoints> gridPoints =  vtkSmartPointer<vtkPoints>::New();
> for (int x = 0; x < gridSize.x; x++) {  for (int y = 0; y < gridSize.y; y++)
> {   for (int z = 0; z < gridSize.z; z++) {    gridPoints->InsertNextPoint(x,
> y, z);   }  } } // Create a dataset from the grid points
> vtkSmartPointer<vtkStructuredGrid> pointSet =
>  vtkSmartPointer<vtkStructuredGrid>::New();
> pointSet->SetDimensions(glm::value_ptr(gridSize));
> pointSet->SetPoints(gridPoints); vtkSmartPointer<vtkProbeFilter> probeFilter
> =  vtkSmartPointer<vtkProbeFilter>::New();
> probeFilter->SetSourceData(unstructuredGrid);
> probeFilter->SetInputData(pointSet); probeFilter->Update(); auto
> structuredGrid = probeFilter->GetStructuredGridOutput(); auto pointData =
> structuredGrid->GetPointData(); auto tensors =
> structuredGrid->GetPointData()->GetTensors();
> ________________________________
> Sent from the VTK - Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>


More information about the vtkusers mailing list