[vtkusers] probe of multiblock PLOT3D data

Hamilton Woods ghw at accutrol.com
Thu Oct 13 20:20:49 EDT 2011


I have a pair of PLOT3D files (.xyz and .q) that has more than 
one block of data.  Paraview displays the data nicely.  I can 
even do a PlotOverLine through block 1 and block 2.

When I try to probe data using VTK in C++ the data in block 
2 are missing.  If I delete the block 1 coordinates and data 
and re-fire, I am able to probe data.

Is there a trick to probing data in multiblock PLOT3D data 
that is necessary in VTK that is not necessary in Paraview?

Here is a code snippet:

	vtkPLOT3DReader* reader = vtkPLOT3DReader::New();
	reader->SetBinaryFile(0);
	reader->SetMultiGrid(1);
	reader->SetXYZFileName(geometryFile.c_str());
	reader->SetQFileName(qFile.c_str());
	reader->SetScalarFunctionNumber(100);
	reader->Update();

	vtkSmartPointer<vtkPolyData> probePolyData = 
		vtkSmartPointer<vtkPolyData>::New();
	vtkSmartPointer<vtkProbeFilter> probe = 
		vtkSmartPointer<vtkProbeFilter>::New();
	//probe->SetSource(image);
	probe->SetSourceConnection(reader->GetOutputPort());

	probePoints = vtkSmartPointer<vtkPoints>::New();

	for (iLine=0; iLine<nLines; ++iLine)
	{

		probePoints->Initialize();
		// Add some points to interpolate
		fracx = (StopPoints[iLine].x-StartPoints[iLine].x)/double(NPoints-1);
		fracy = (StopPoints[iLine].y-StartPoints[iLine].y)/double(NPoints-1);
		fracz = (StopPoints[iLine].z-StartPoints[iLine].z)/double(NPoints-1);
		for (iPoint=0; iPoint<NPoints; ++iPoint)
		{
			di = double(iPoint);
			x = StartPoints[iLine].x + di*fracx;
			y = StartPoints[iLine].y + di*fracy;
			z = StartPoints[iLine].z + di*fracz;
			probePoints->InsertNextPoint(x, y, z);
		}

		probePolyData->Initialize();
		probePolyData->SetPoints(probePoints);

		probe->SetInput(probePolyData);
		probe->Update();

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

		NumDataPoints = data->GetDataSize();
		integratedDensity = 0.0;
		//outData << iLine << endl;
		ds = sqrt(pow(fracx,2)+pow(fracy,2)+pow(fracz,2));
		s = sqrt(pow(StartPoints[iLine].x-StopPoints[iLine].x,2)
			+pow(StartPoints[iLine].y-StopPoints[iLine].y,2)
			+pow(StartPoints[iLine].z-StopPoints[iLine].z,2));
		data->GetTuple(0, val);
		rhom1 = val[0];
		for(int i = 1; i < NumDataPoints; ++i)
		{
			data->GetTuple(i, val);
			//			cout << "Interpolation using ProbeFilter ";
			//			cout << "doubleData->GetValue(" << i << "): " << val[0] << endl;
			//outData << i << "\t" << val[0] << endl;
			rho = val[0];
			integratedDensity += (rho+rhom1)*ds/2.0;
			rhom1 = rho;
		}
	}

Thanks for your help,
Hamilton Woods




More information about the vtkusers mailing list