switch to loading unstructured grids
This commit is contained in:
parent
d85c221acf
commit
ecabdfe7d9
@ -20,4 +20,5 @@ target_link_libraries(pfe PRIVATE
|
||||
VTK::RenderingVolume
|
||||
VTK::CommonDataModel
|
||||
VTK::IOLegacy
|
||||
VTK::IOXML)
|
||||
VTK::IOXML
|
||||
VTK::RenderingVolumeOpenGL2)
|
||||
|
44
src/main.cc
44
src/main.cc
@ -5,15 +5,17 @@
|
||||
#include <vtkNew.h>
|
||||
#include <vtkPolyDataMapper.h>
|
||||
#include <vtkProperty.h>
|
||||
#include <vtkVolumeProperty.h>
|
||||
#include <vtkRenderWindow.h>
|
||||
#include <vtkRenderWindowInteractor.h>
|
||||
#include <vtkRenderer.h>
|
||||
#include <vtkVolumeMapper.h>
|
||||
#include <vtkVolume.h>
|
||||
#include <vtkProjectedTetrahedraMapper.h>
|
||||
#include <vtkDataSetReader.h>
|
||||
#include <vtkOpenGLProjectedTetrahedraMapper.h>
|
||||
#include <vtkUnstructuredGridReader.h>
|
||||
#include <vtkPolyDataReader.h>
|
||||
#include <vtkXMLPolyDataReader.h>
|
||||
#include <vtkPiecewiseFunction.h>
|
||||
|
||||
#include <array>
|
||||
|
||||
@ -28,33 +30,41 @@ int main(int argc, char **argv) {
|
||||
std::array<unsigned char, 4> bkg{{26, 51, 102, 255}};
|
||||
colors->SetColor("BkgColor", bkg.data());
|
||||
|
||||
vtkNew<vtkXMLPolyDataReader> reader;
|
||||
// vtkNew<vtkXMLPolyDataReader> reader;
|
||||
vtkNew<vtkUnstructuredGridReader> reader;
|
||||
reader->SetFileName(argv[1]);
|
||||
|
||||
// vtkNew<vtkProjectedTetrahedraMapper> volumeMapper;
|
||||
// volumeMapper->SetInputConnection(reader->GetOutputPort());
|
||||
vtkNew<vtkPolyDataMapper> mapper;
|
||||
mapper->SetInputConnection(reader->GetOutputPort());
|
||||
vtkNew<vtkOpenGLProjectedTetrahedraMapper> volumeMapper;
|
||||
volumeMapper->SetInputConnection(reader->GetOutputPort());
|
||||
// vtkNew<vtkPolyDataMapper> mapper;
|
||||
// mapper->SetInputConnection(reader->GetOutputPort());
|
||||
|
||||
// vtkNew<vtkVolume> volume;
|
||||
// volume->SetMapper(volumeMapper);
|
||||
vtkNew<vtkActor> actor;
|
||||
actor->SetMapper(mapper);
|
||||
vtkNew<vtkVolume> volume;
|
||||
volume->SetMapper(volumeMapper);
|
||||
vtkNew<vtkPiecewiseFunction> transferFunction;
|
||||
transferFunction->AddPoint(-1, 100);
|
||||
transferFunction->AddPoint(0, .5);
|
||||
// transferFunction->AddPoint(1, 1);
|
||||
volume->GetProperty()->SetScalarOpacity(transferFunction);
|
||||
volume->GetProperty()->SetColor(transferFunction);
|
||||
// vtkNew<vtkActor> 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<vtkRenderer> renderer;
|
||||
renderer->AddActor(actor);
|
||||
// renderer->AddActor(actor);
|
||||
renderer->AddVolume(volume);
|
||||
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");
|
||||
renderWindow->SetWindowName("PFE");
|
||||
vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
|
||||
renderWindowInteractor->SetRenderWindow(renderWindow);
|
||||
renderWindow->Render();
|
||||
|
Loading…
Reference in New Issue
Block a user