SHARE
TWEET

Untitled

a guest Jun 25th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   // Read a vtk file
  2.   //
  3.   vtkSmartPointer<vtkMultiBlockPLOT3DReader> pl3d =
  4.     vtkSmartPointer<vtkMultiBlockPLOT3DReader>::New();
  5.   pl3d->SetXYZFileName(fileName1.c_str());
  6.   pl3d->SetQFileName(fileName2.c_str());
  7.   pl3d->SetScalarFunctionNumber(100); // Density
  8.   pl3d->SetVectorFunctionNumber(202); // Momentum
  9.   pl3d->Update();
  10.  
  11.   vtkStructuredGrid* pl3dOutput =
  12.     dynamic_cast<vtkStructuredGrid*>(pl3d->GetOutput()->GetBlock(0));
  13.  
  14.   // What do we know about the data?
  15.   // Get the extent of the data: imin,imax, jmin,jmax, kmin,kmax
  16.   int extent[6] = {0, 0, 0, 0, 0, 0};
  17.   pl3dOutput->GetExtent(extent);
  18.   double scalarRange[2] = {0.0, 0.0};
  19.   pl3dOutput->GetScalarRange(scalarRange);
  20.  
  21.   // Planes are specified using a imin,imax, jmin,jmax, kmin,kmax coordinate
  22.   // specification. Min and max i,j,k values are clamped to 0 and maximum value.
  23.   // See the variable named extent for the values.
  24.   //
  25.   vtkSmartPointer<vtkStructuredGridGeometryFilter> plane =
  26.     vtkSmartPointer<vtkStructuredGridGeometryFilter>::New();
  27.   plane->SetInputData(pl3dOutput);
  28.   plane->SetExtent(10, 10, 1, extent[3], 1, extent[5]);
  29.  
  30.   vtkSmartPointer<vtkStructuredGridGeometryFilter> plane2 =
  31.     vtkSmartPointer<vtkStructuredGridGeometryFilter>::New();
  32.   plane2->SetInputData(pl3dOutput);
  33.   plane2->SetExtent(30, 30, 1, extent[3], 1, extent[5]);
  34.  
  35.   vtkSmartPointer<vtkStructuredGridGeometryFilter> plane3 =
  36.     vtkSmartPointer<vtkStructuredGridGeometryFilter>::New();
  37.   plane3->SetInputData(pl3dOutput);
  38.   plane3->SetExtent(45, 45, 1, extent[3], 1, extent[5]);
  39.  
  40.   // We use an append filter because that way we can do the warping, etc. just
  41.   // using a single pipeline and actor.
  42.   //
  43.   vtkSmartPointer<vtkAppendPolyData> appendF =
  44.     vtkSmartPointer<vtkAppendPolyData>::New();
  45.   appendF->AddInputConnection(plane->GetOutputPort());
  46.   appendF->AddInputConnection(plane2->GetOutputPort());
  47.   appendF->AddInputConnection(plane3->GetOutputPort());
  48.  
  49.   // Warp
  50.   vtkSmartPointer<vtkWarpVector> warp = vtkSmartPointer<vtkWarpVector>::New();
  51.   warp->SetInputConnection(appendF->GetOutputPort());
  52.   warp->SetScaleFactor(0.005);
  53.   warp->Update();
  54.  
  55.   vtkSmartPointer<vtkPolyDataNormals> normals =
  56.     vtkSmartPointer<vtkPolyDataNormals>::New();
  57.   normals->SetInputData(warp->GetPolyDataOutput());
  58.   normals->SetFeatureAngle(45);
  59.  
  60.   vtkSmartPointer<vtkPolyDataMapper> planeMapper =
  61.     vtkSmartPointer<vtkPolyDataMapper>::New();
  62.   planeMapper->SetInputConnection(normals->GetOutputPort());
  63.   planeMapper->SetScalarRange(scalarRange);
  64.  
  65.   vtkSmartPointer<vtkActor> planeActor = vtkSmartPointer<vtkActor>::New();
  66.   planeActor->SetMapper(planeMapper);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top