[vtkusers] Get scalar point values from a grid surface line

madz madaramh at gmail.com
Fri Dec 27 06:54:28 EST 2013


I have an unstructured grid with which I have to extract scalar values along
a surface line in the grid and plot them in a XY chart. I used vtkCutter to
visualize the surface line and vtkProbeFilter to extract scalar values as
shown below,

		vtkSmartPointer<vtkCutter> cutter =
			vtkSmartPointer<vtkCutter>::New();
		cutter->SetInput(polydata);
		cutter->SetCutFunction(plane);


		vtkSmartPointer<vtkPolyDataMapper> cutterMapper =
			vtkSmartPointer<vtkPolyDataMapper>::New();
		cutterMapper->SetInputConnection( cutter->GetOutputPort());
		cutterMapper->ScalarVisibilityOff();

		// Create plane actor
		planeActor = vtkSmartPointer<vtkActor>::New();
		planeActor->GetProperty()->SetColor(0,1,1);
		planeActor->GetProperty()->SetLineWidth(3);
		planeActor->SetMapper(cutterMapper);

		vtkSmartPointer<vtkProbeFilter> probFilter = 
vtkSmartPointer<vtkProbeFilter>::New();
		probFilter->SetSource(polydata);
		probFilter->SetInput(cutter->GetOutput());
		probFilter->Update();

		vtkDataArray* data =
probFilter->GetOutput()->GetPointData()->GetScalars();
		vtkDoubleArray* doubleData = vtkDoubleArray::SafeDownCast (data);

		vtkDataArray* data2 = cutter->GetOutput()->GetPointData()->GetScalars();
		vtkDoubleArray* doubleData2 = vtkDoubleArray::SafeDownCast (data2);

However the code stops at probFilter->Update(); and if I comment that line
and proceed then doubleData and  doubleData2 does not contain any values. So
the problem must lie with vtkCutter. What could be the reason for this? The
polydata I use as input for the cutter has scalar values in it.

vtkDataArray* data3 = polydata->GetPointData()->GetScalars();
vtkDoubleArray* doubleData3 = vtkDoubleArray::SafeDownCast (data3);

The above code piece will result with doubleData3  filled with values.
Any help on the matter would be appreciated.
Thanks.



--
View this message in context: http://vtk.1045678.n5.nabble.com/Get-scalar-point-values-from-a-grid-surface-line-tp5725149.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list