[vtkusers] Get interpolated scalar values from Polydata

madz madaramh at gmail.com
Wed Mar 25 04:05:51 EDT 2015


This is what I have tried so far,

int main( )
{

	vtkSmartPointer<vtkGenericEnSightReader> reader3  = 
vtkSmartPointer<vtkGenericEnSightReader>::New();
	reader3->SetCaseFileName("C:\\Users\\Sutra03\\Desktop\\Ensight
Files\\mycase\\CFX_001_ensight.case");
	reader3->Update();

	vtkSmartPointer<vtkCompositeDataGeometryFilter> compositeFilter =
vtkSmartPointer<vtkCompositeDataGeometryFilter>::New();
	compositeFilter->SetInputConnection(reader3->GetOutputPort());
	compositeFilter->Update();

	vtkSmartPointer<vtkCleanPolyData> cleanFilter =
vtkSmartPointer<vtkCleanPolyData>::New();
	cleanFilter->SetInput(compositeFilter->GetOutput());
	cleanFilter->Update();

	vtkSmartPointer<vtkPolyData> source = cleanFilter->GetOutput();

	vtkSmartPointer<vtkXMLPolyDataReader> readerVTP =
vtkSmartPointer<vtkXMLPolyDataReader>::New();
	readerVTP->SetFileName("C:\\Program Files (x86)\\Concepts\\CTAADS
8.2.0.194\\Files\\test.vtp");//test34567
	readerVTP->Update();

	
	vtkSmartPointer<vtkCleanPolyData> cleanFilter2 =
vtkSmartPointer<vtkCleanPolyData>::New();
	cleanFilter2->SetInput(readerVTP->GetOutput());
	cleanFilter2->Update();

	vtkSmartPointer<vtkTriangleFilter> tri=
vtkSmartPointer<vtkTriangleFilter>::New();
	tri->SetInput(cleanFilter2->GetOutput());

	vtkSmartPointer<vtkPolyData> input = tri->GetOutput();

	vtkSmartPointer<vtkProbeFilter> probe =
vtkSmartPointer<vtkProbeFilter>::New();
	probe->SetInput(input);
	probe->SetSource(source);
	probe->Update();

	vtkSmartPointer<vtkPolyData> output = probe->GetPolyDataOutput();

	vtkSmartPointer<vtkDataArray> arr =
output->GetPointData()->GetArray("Pressure");
	output->GetPointData()->SetScalars(arr);

	vtkSmartPointer<vtkLookupTable> colorLookupTable =
vtkSmartPointer<vtkLookupTable>::New();

	colorLookupTable->SetTableRange(8969.34, 10595.8);
	double vmin,vmax;
	colorLookupTable->GetHueRange(vmin,vmax);
	if(vmin!=vmax)
	{
		colorLookupTable->SetHueRange(0.6667,0.0);
	}
	colorLookupTable->Build();


	vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
	mapper->SetInput(output);
	mapper->SetScalarModeToUsePointData();
	mapper->SetScalarRange(8969.34, 10595.8);
	mapper->SetLookupTable(colorLookupTable);
	mapper->Update();

	vtkSmartPointer<vtkActor> actor =  vtkSmartPointer<vtkActor>::New();
	actor->GetProperty()->SetRepresentationToWireframe();
	actor->GetProperty()->SetColor(1,1,1);
	actor->SetMapper(mapper);


	vtkSmartPointer<vtkRenderer> renderer = 
vtkSmartPointer<vtkRenderer>::New();
	vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
	renderWindow->AddRenderer(renderer);
	vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
	renderWindowInteractor->SetRenderWindow(renderWindow);

	renderer->AddActor(actor);
	renderer->SetBackground(.3, .6, .3); // Background color green

	renderWindow->Render();
	renderWindowInteractor->Start();


	return EXIT_SUCCESS;

}

It gives an output like the following image;


<http://vtk.1045678.n5.nabble.com/file/n5731148/output.png> 

The source looks like the following;

<http://vtk.1045678.n5.nabble.com/file/n5731148/source.png> 

It seems like most points of the output does not get an interpolated scalar
value, How can I fix this? (The two polydata overlaps each other)




--
View this message in context: http://vtk.1045678.n5.nabble.com/Get-interpolated-scalar-values-from-Polydata-tp5731033p5731148.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list