[vtkusers] Updating scalars without recalculating vtkClipDataSet
Mirek
m.sejna at pc-progress.com
Tue May 26 07:44:38 EDT 2015
Hi,
I'm new to VTK and have a problem with updating scalar values on a clipped
mesh efficiently (without recalculating the whole mesh geometry). The
problem is described below and any advice is welcome. Thank you.
Mirek
// I have an Unstructured grid and array of values at mesh nodes
vtkSmartPointer<vtkUnstructuredGrid> pMyUGrid = ... my 3D unstructured grid
vtkSmartPointer<vtkDoubleArray> pMyValues = ... my values at mesh nodes
vtkSmartPointer<vtkPlane> pMyPlane = ... my plane used for clipping pMyUGrid
// Set pMyValues as Scalars in pMyUGrid
pMyUGrid->GetPointData()->SetScalars(pMyValues);
// Prepare a clipper
vtkSmartPointer<vtkClipDataSet> pClipper =
vtkSmartPointer<vtkClipDataSet>::New();
pClipper->SetClipFunction(pMyPlane);
pClipper->SetInputData(pMyUGrid);
// Surface filter (extracts surface mesh of pMyUGrid after clipping)
vtkSmartPointer<vtkDataSetSurfaceFilter> pSurfFilter =
vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
pSurfFilter->SetInputConnection(pClipper->GetOutputPort());
// Clip the 3D mesh and extract its surface mesh
pSurfFilter->Update();
vtkSmartPointer<vtkPolyData> pSurfMesh = pSurfFilter->GetOutput();
// Get "MyValues" at nodes of the surface mesh (some values will be
interpolated by the clipper)
vtkDoubleArray* pMyValuesOnSurface =
vtkDoubleArray::SafeDownCast(pSurfMesh->GetPointData()->GetScalars());
// This all works fine. Now I need to change pMyValues and get new scalar
values on the clipped surface mesh
vtkSmartPointer<vtkDoubleArray> pMyNewValues = ... some new values
pMyUGrid->GetPointData()->SetScalars(pMyNewValues);
pSurfFilter->Update();
pSurfMesh = pSurfFilter->GetOutput();
vtkDoubleArray* pMyNewValuesOnSurface =
vtkDoubleArray::SafeDownCast(pSurfMesh->GetPointData()->GetScalars());
This also works, however, it forces pClipper and pSurfFilter to recalculate
everything (clipping and the surface mesh), which is time-consuming and
useless. How to get updated pMyNewValuesOnSurface without recalculating
pClipper and pSurfFilter? I was trying to use vtkMergeFilter but I was not
able to figure out how to use it correctly (I just started to learn VTK), so
it did not work. I also noticed the DATA_GEOMETRY_UNMODIFIED
InformationKeyMacro but I don't know how to use it. Is there any example
explaining how to correctly solve situations like this one? I'm using VTK
6.1.0. Thank you.
--
View this message in context: http://vtk.1045678.n5.nabble.com/Updating-scalars-without-recalculating-vtkClipDataSet-tp5732007.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list