Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Read a vtk file
- //
- vtkSmartPointer<vtkMultiBlockPLOT3DReader> pl3d =
- vtkSmartPointer<vtkMultiBlockPLOT3DReader>::New();
- pl3d->SetXYZFileName(fileName1.c_str());
- pl3d->SetQFileName(fileName2.c_str());
- pl3d->SetScalarFunctionNumber(100); // Density
- pl3d->SetVectorFunctionNumber(202); // Momentum
- pl3d->Update();
- vtkStructuredGrid* pl3dOutput =
- dynamic_cast<vtkStructuredGrid*>(pl3d->GetOutput()->GetBlock(0));
- // What do we know about the data?
- // Get the extent of the data: imin,imax, jmin,jmax, kmin,kmax
- int extent[6] = {0, 0, 0, 0, 0, 0};
- pl3dOutput->GetExtent(extent);
- double scalarRange[2] = {0.0, 0.0};
- pl3dOutput->GetScalarRange(scalarRange);
- // Planes are specified using a imin,imax, jmin,jmax, kmin,kmax coordinate
- // specification. Min and max i,j,k values are clamped to 0 and maximum value.
- // See the variable named extent for the values.
- //
- vtkSmartPointer<vtkStructuredGridGeometryFilter> plane =
- vtkSmartPointer<vtkStructuredGridGeometryFilter>::New();
- plane->SetInputData(pl3dOutput);
- plane->SetExtent(10, 10, 1, extent[3], 1, extent[5]);
- vtkSmartPointer<vtkStructuredGridGeometryFilter> plane2 =
- vtkSmartPointer<vtkStructuredGridGeometryFilter>::New();
- plane2->SetInputData(pl3dOutput);
- plane2->SetExtent(30, 30, 1, extent[3], 1, extent[5]);
- vtkSmartPointer<vtkStructuredGridGeometryFilter> plane3 =
- vtkSmartPointer<vtkStructuredGridGeometryFilter>::New();
- plane3->SetInputData(pl3dOutput);
- plane3->SetExtent(45, 45, 1, extent[3], 1, extent[5]);
- // We use an append filter because that way we can do the warping, etc. just
- // using a single pipeline and actor.
- //
- vtkSmartPointer<vtkAppendPolyData> appendF =
- vtkSmartPointer<vtkAppendPolyData>::New();
- appendF->AddInputConnection(plane->GetOutputPort());
- appendF->AddInputConnection(plane2->GetOutputPort());
- appendF->AddInputConnection(plane3->GetOutputPort());
- // Warp
- vtkSmartPointer<vtkWarpVector> warp = vtkSmartPointer<vtkWarpVector>::New();
- warp->SetInputConnection(appendF->GetOutputPort());
- warp->SetScaleFactor(0.005);
- warp->Update();
- vtkSmartPointer<vtkPolyDataNormals> normals =
- vtkSmartPointer<vtkPolyDataNormals>::New();
- normals->SetInputData(warp->GetPolyDataOutput());
- normals->SetFeatureAngle(45);
- vtkSmartPointer<vtkPolyDataMapper> planeMapper =
- vtkSmartPointer<vtkPolyDataMapper>::New();
- planeMapper->SetInputConnection(normals->GetOutputPort());
- planeMapper->SetScalarRange(scalarRange);
- vtkSmartPointer<vtkActor> planeActor = vtkSmartPointer<vtkActor>::New();
- planeActor->SetMapper(planeMapper);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement