From ecabdfe7d9072d75d71654bfa8ab27ba24d21735 Mon Sep 17 00:00:00 2001 From: ccolin Date: Thu, 10 Feb 2022 19:38:48 +0100 Subject: [PATCH] switch to loading unstructured grids --- CMakeLists.txt | 3 ++- src/main.cc | 44 +++++++++++++++++++++++++++----------------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef3f017..c0c2ed7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,4 +20,5 @@ target_link_libraries(pfe PRIVATE VTK::RenderingVolume VTK::CommonDataModel VTK::IOLegacy - VTK::IOXML) + VTK::IOXML + VTK::RenderingVolumeOpenGL2) diff --git a/src/main.cc b/src/main.cc index 4da2aa3..9b7af79 100644 --- a/src/main.cc +++ b/src/main.cc @@ -5,15 +5,17 @@ #include #include #include +#include #include #include #include #include #include -#include -#include +#include +#include #include #include +#include #include @@ -28,33 +30,41 @@ int main(int argc, char **argv) { std::array bkg{{26, 51, 102, 255}}; colors->SetColor("BkgColor", bkg.data()); - vtkNew reader; + // vtkNew reader; + vtkNew reader; reader->SetFileName(argv[1]); - // vtkNew volumeMapper; - // volumeMapper->SetInputConnection(reader->GetOutputPort()); - vtkNew mapper; - mapper->SetInputConnection(reader->GetOutputPort()); + vtkNew volumeMapper; + volumeMapper->SetInputConnection(reader->GetOutputPort()); + // vtkNew mapper; + // mapper->SetInputConnection(reader->GetOutputPort()); - // vtkNew volume; - // volume->SetMapper(volumeMapper); - vtkNew actor; - actor->SetMapper(mapper); + vtkNew volume; + volume->SetMapper(volumeMapper); + vtkNew transferFunction; + transferFunction->AddPoint(-1, 100); + transferFunction->AddPoint(0, .5); + // transferFunction->AddPoint(1, 1); + volume->GetProperty()->SetScalarOpacity(transferFunction); + volume->GetProperty()->SetColor(transferFunction); + // vtkNew actor; + // actor->SetMapper(mapper); - actor->GetProperty()->SetColor( - colors->GetColor4d("Tomato").GetData()); - actor->RotateX(30.0); - actor->RotateY(-45.0); + // actor->GetProperty()->SetColor( + // colors->GetColor4d("Tomato").GetData()); + // actor->RotateX(30.0); + // actor->RotateY(-45.0); vtkNew renderer; - renderer->AddActor(actor); + // renderer->AddActor(actor); + renderer->AddVolume(volume); renderer->SetBackground(colors->GetColor3d("BkgColor").GetData()); renderer->ResetCamera(); renderer->GetActiveCamera()->Zoom(1.5); vtkNew renderWindow; renderWindow->SetSize(300, 300); renderWindow->AddRenderer(renderer); - renderWindow->SetWindowName("Cylinder"); + renderWindow->SetWindowName("PFE"); vtkNew renderWindowInteractor; renderWindowInteractor->SetRenderWindow(renderWindow); renderWindow->Render();