pfe/src/main.cc

65 lines
1.8 KiB
C++
Raw Normal View History

2022-01-31 16:55:32 +01:00
#include <vtkActor.h>
#include <vtkCamera.h>
#include <vtkCylinderSource.h>
#include <vtkNamedColors.h>
#include <vtkNew.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
2022-02-09 16:24:57 +01:00
#include <vtkVolumeMapper.h>
#include <vtkVolume.h>
#include <vtkProjectedTetrahedraMapper.h>
#include <vtkDataSetReader.h>
#include <vtkPolyDataReader.h>
#include <vtkXMLPolyDataReader.h>
2022-01-31 16:55:32 +01:00
#include <array>
2022-02-09 16:24:57 +01:00
int main(int argc, char **argv) {
if (argc != 2) {
std::cerr << "Usage: " << argv[0] << " FILE.vtk" << std::endl;
return EXIT_FAILURE;
}
2022-01-31 16:55:32 +01:00
vtkNew<vtkNamedColors> colors;
std::array<unsigned char, 4> bkg{{26, 51, 102, 255}};
colors->SetColor("BkgColor", bkg.data());
2022-02-09 16:24:57 +01:00
vtkNew<vtkXMLPolyDataReader> reader;
reader->SetFileName(argv[1]);
// vtkNew<vtkProjectedTetrahedraMapper> volumeMapper;
// volumeMapper->SetInputConnection(reader->GetOutputPort());
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputConnection(reader->GetOutputPort());
2022-01-31 16:55:32 +01:00
2022-02-09 16:24:57 +01:00
// vtkNew<vtkVolume> volume;
// volume->SetMapper(volumeMapper);
vtkNew<vtkActor> actor;
actor->SetMapper(mapper);
2022-01-31 16:55:32 +01:00
2022-02-09 16:24:57 +01:00
actor->GetProperty()->SetColor(
2022-01-31 16:55:32 +01:00
colors->GetColor4d("Tomato").GetData());
2022-02-09 16:24:57 +01:00
actor->RotateX(30.0);
actor->RotateY(-45.0);
2022-01-31 16:55:32 +01:00
vtkNew<vtkRenderer> renderer;
2022-02-09 16:24:57 +01:00
renderer->AddActor(actor);
2022-01-31 16:55:32 +01:00
renderer->SetBackground(colors->GetColor3d("BkgColor").GetData());
renderer->ResetCamera();
renderer->GetActiveCamera()->Zoom(1.5);
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->SetSize(300, 300);
renderWindow->AddRenderer(renderer);
renderWindow->SetWindowName("Cylinder");
vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
renderWindowInteractor->SetRenderWindow(renderWindow);
renderWindow->Render();
renderWindowInteractor->Start();
return EXIT_SUCCESS;
}