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 <vtkStructuredGrid.h>
- #include <vtkStructuredGridGeometryFilter.h>
- #include <vtkStructuredGridOutlineFilter.h>
- #include <vtkStructuredGridReader.h>
- #include <array>
- #include <vtkPointDataToCellData.h>
- #include<vtkWarpVector.h>
- #include <vtkThreshold.h>
- #include <vtkDataSetMapper.h>
- #include <vtkDataSetReader.h>
- #include <vtkDataSetSurfaceFilter.h>
- #include <vtkLookUpTable.h>
- int main(int argc, char* argv[])
- {
- 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);
- vtkSmartPointer<vtkDataSetReader> reader =
- vtkSmartPointer<vtkDataSetReader>::New();
- reader->SetFileName("../kitchen.vtk");
- reader->SetScalarsName("c13");
- reader->SetVectorsName("vectors");
- reader->Update();
- reader->Update(); //force a read to occur
- reader->GetOutput()->GetLength();
- vtkSmartPointer<vtkLookupTable> grayScaleLut =
- vtkSmartPointer<vtkLookupTable>::New();
- grayScaleLut->SetHueRange(0, 0);
- grayScaleLut->SetSaturationRange(0, 0);
- grayScaleLut->SetValueRange(0.2, 1.0);
- grayScaleLut->SetNumberOfColors(256);
- grayScaleLut->SetHueRange(0.0, 0.667);
- grayScaleLut->Build();
- grayScaleLut->SetVectorModeToMagnitude();
- grayScaleLut->SetVectorMode(vtkScalarsToColors::MAGNITUDE);
- vtkSmartPointer<vtkDataSetSurfaceFilter> surface = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
- surface->SetInputConnection(reader->GetOutputPort());
- vtkSmartPointer<vtkPolyDataMapper> surfaceMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
- surfaceMapper->SetInputConnection(surface->GetOutputPort());
- surfaceMapper->SetLookupTable(grayScaleLut);
- vtkSmartPointer<vtkActor> surfaceactor = vtkSmartPointer<vtkActor>::New();
- surfaceactor->SetMapper(surfaceMapper);
- surfaceactor->GetProperty()->SetColor(colors->GetColor3d("LampBlack").GetData());
- vtkPointDataToCellData* p2c = vtkPointDataToCellData::New();
- p2c->SetInputConnection(reader->GetOutputPort());
- p2c->PassPointDataOn();
- vtkWarpVector* warp = vtkWarpVector::New();
- warp->SetInputConnection(p2c->GetOutputPort());
- vtkThreshold* thresh = vtkThreshold::New();
- thresh->SetInputConnection(warp->GetOutputPort());
- thresh->ThresholdBetween(0,1);
- thresh->SetInputArrayToProcess(0, 0, 0, 0, "c13");
- thresh->SetAllScalars(1);
- vtkDataSetMapper* mapper = vtkDataSetMapper::New();
- mapper->SetInputConnection(thresh->GetOutputPort());
- mapper->SetLookupTable(grayScaleLut);
- vtkActor* readerActor = vtkActor::New();
- readerActor->SetMapper(mapper);
- //
- // linijų rezoliucija
- //
- vtkSmartPointer<vtkLineSource> line = vtkSmartPointer<vtkLineSource>::New();
- line->SetResolution(8);
- vtkSmartPointer<vtkActor> lines = vtkSmartPointer<vtkActor>::New();
- lines->GetProperty()->SetColor(colors->GetColor3d("Black").GetData());
- aren->TwoSidedLightingOn();
- // pridedamos linijos
- aren->AddActor(surfaceactor);
- // fono spalva
- aren->SetBackground(colors->GetColor3d("SlateGray").GetData());
- vtkSmartPointer<vtkCamera> aCamera = vtkSmartPointer<vtkCamera>::New();
- aren->SetActiveCamera(aCamera);
- aren->ResetCamera();
- // kameros nustatymai
- 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();
- iren->Start();
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment