Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vtkActor.h>
- #include <vtkCamera.h>
- #include <vtkLineSource.h>
- #include <vtkNamedColors.h>
- #include <vtkPointData.h>
- #include <vtkPolyDataMapper.h>
- #include <vtkProperty.h>
- #include <vtkRenderWindow.h>
- #include <vtkRenderWindowInteractor.h>
- #include <vtkRenderer.h>
- #include <vtkStreamTracer.h>
- #include <vtkStructuredGrid.h>
- #include <vtkStructuredGridGeometryFilter.h>
- #include <vtkStructuredGridOutlineFilter.h>
- #include <vtkStructuredGridReader.h>
- #include <array>
- // PASIKEISK VISKA
- int main( int argc, char *argv[] )
- {
- double range[2];
- double maxVelocity = 0.0, maxTime = 0.0;
- vtkSmartPointer<vtkNamedColors> colors = vtkSmartPointer<vtkNamedColors>::New();
- vtkSmartPointer<vtkRenderer> aren = vtkSmartPointer<vtkRenderer>::New();
- vtkSmartPointer<vtkRenderWindow> renWin = vtkSmartPointer<vtkRenderWindow>::New();
- renWin->AddRenderer(aren);
- vtkSmartPointer<vtkRenderWindowInteractor> iren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
- iren->SetRenderWindow(renWin);
- //
- // Read data
- //
- vtkSmartPointer<vtkStructuredGridReader> reader = vtkSmartPointer<vtkStructuredGridReader>::New();
- reader->SetFileName("../kitchen.vtk");
- reader->Update(); //force a read to occur
- reader->GetOutput()->GetLength();
- if ( reader->GetOutput()->GetPointData()->GetScalars() )
- {
- reader->GetOutput()->GetPointData()->GetScalars()->GetRange(range);
- }
- if ( reader->GetOutput()->GetPointData()->GetVectors() )
- {
- maxVelocity = reader->GetOutput()->GetPointData()->GetVectors()->GetMaxNorm();
- maxTime = 4.0*reader->GetOutput()->GetLength()/maxVelocity ;
- }
- //
- // Outline around data
- //
- vtkSmartPointer<vtkStructuredGridOutlineFilter> outlineF = vtkSmartPointer<vtkStructuredGridOutlineFilter>::New();
- outlineF->SetInputConnection(reader->GetOutputPort());
- vtkSmartPointer<vtkPolyDataMapper> outlineMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
- outlineMapper->SetInputConnection(outlineF->GetOutputPort());
- vtkSmartPointer<vtkActor> outline = vtkSmartPointer<vtkActor>::New();
- outline->SetMapper(outlineMapper);
- outline->GetProperty()->SetColor(colors->GetColor3d("LampBlack").GetData());
- //
- // regular streamlines
- //
- vtkSmartPointer<vtkLineSource> line = vtkSmartPointer<vtkLineSource>::New();
- line->SetResolution(39);
- line->SetPoint1(0.08, 2.50, 0.71);
- line->SetPoint2(0.08, 4.50, 0.71);
- vtkSmartPointer<vtkPolyDataMapper> rakeMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
- rakeMapper->SetInputConnection(line->GetOutputPort());
- vtkSmartPointer<vtkActor> rake = vtkSmartPointer<vtkActor>::New();
- rake->SetMapper(rakeMapper);
- vtkSmartPointer<vtkStreamTracer> streamers = vtkSmartPointer<vtkStreamTracer>::New();
- streamers->SetInputConnection(reader->GetOutputPort());
- streamers->SetSourceConnection(line->GetOutputPort());
- streamers->SetMaximumPropagation(maxTime);
- streamers->SetInitialIntegrationStep(.5);
- streamers->SetMinimumIntegrationStep(.1);
- streamers->SetIntegratorType(2);
- streamers->Update();
- vtkSmartPointer<vtkPolyDataMapper> streamersMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
- streamersMapper->SetInputConnection(streamers->GetOutputPort());
- streamersMapper->SetScalarRange(range);
- vtkSmartPointer<vtkActor> lines = vtkSmartPointer<vtkActor>::New();
- lines->SetMapper(streamersMapper);
- lines->GetProperty()->SetColor(colors->GetColor3d("Black").GetData());
- aren->TwoSidedLightingOn();
- aren->AddActor(outline);
- aren->AddActor(lines);
- aren->AddActor(rake);
- aren->SetBackground(colors->GetColor3d("SlateGray").GetData());
- vtkSmartPointer<vtkCamera> aCamera = vtkSmartPointer<vtkCamera>::New();
- aren->SetActiveCamera(aCamera);
- aren->ResetCamera();
- aCamera->SetFocalPoint(3.505, 2.505, 1.255);
- aCamera->SetPosition(3.505, 24.6196, 1.255);
- aCamera->SetViewUp(0,0,1);
- aCamera->Azimuth(60);
- aCamera->Elevation(30);
- aCamera->Dolly(1.5);
- aren->ResetCameraClippingRange();
- renWin->SetSize(640, 512);
- renWin->Render();
- // interact with data
- iren->Start();
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment