Add more VTK readers for the VTK image example

This commit is contained in:
Mael Rouxel-Labbé 2024-03-05 13:01:56 +01:00
parent ff0d56db46
commit 4bfbb83d7c
2 changed files with 18 additions and 2 deletions

View File

@ -12,14 +12,14 @@ include(CGAL_Eigen3_support)
find_package(TBB QUIET) find_package(TBB QUIET)
include(CGAL_TBB_support) include(CGAL_TBB_support)
find_package(VTK QUIET COMPONENTS vtkImagingGeneral vtkIOImage vtkIOXML vtkIOLegacy NO_MODULE) find_package(VTK QUIET COMPONENTS vtkImagingGeneral vtkIOImage vtkIOXML vtkIOXML vtkIOMINC vtkIOLegacy NO_MODULE)
if(VTK_FOUND) if(VTK_FOUND)
if(VTK_USE_FILE) if(VTK_USE_FILE)
include(${VTK_USE_FILE}) include(${VTK_USE_FILE})
endif() endif()
if("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION VERSION_GREATER 5) if("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION VERSION_GREATER 5)
message(STATUS "VTK was found") message(STATUS "VTK was found")
if(TARGET VTK::ImagingGeneral AND TARGET VTK::IOImage AND TARGET VTK::IOXML AND TARGET VTK::IOLegacy) if(TARGET VTK::ImagingGeneral AND TARGET VTK::IOImage AND TARGET VTK::IOXML AND VTK::IOMINC AND TARGET VTK::IOLegacy)
set(VTK_LIBRARIES VTK::ImagingGeneral VTK::IOImage VTK::IOXML VTK::IOLegacy) set(VTK_LIBRARIES VTK::ImagingGeneral VTK::IOImage VTK::IOXML VTK::IOLegacy)
endif() endif()
else() else()

View File

@ -18,6 +18,8 @@
#include <vtkMetaImageReader.h> #include <vtkMetaImageReader.h>
#include <vtkXMLImageDataReader.h> #include <vtkXMLImageDataReader.h>
#include <vtkTIFFReader.h> #include <vtkTIFFReader.h>
#include <vtkNrrdReader.h>
#include <vtkMINCImageReader.h>
#include <iostream> #include <iostream>
#include <vector> #include <vector>
@ -124,6 +126,20 @@ int main(int argc, char* argv[])
reader->Update(); reader->Update();
image = CGAL::IO::read_vtk_image_data(reader->GetOutput()); image = CGAL::IO::read_vtk_image_data(reader->GetOutput());
} }
else if(ext == "nrrd")
{
vtkNew<vtkNrrdReader> reader;
reader->SetFileName(argv[1]);
reader->Update();
image = CGAL::IO::read_vtk_image_data(reader->GetOutput());
}
else if(ext == "mnc")
{
vtkNew<vtkMINCImageReader> reader;
reader->SetFileName(argv[1]);
reader->Update();
image = CGAL::IO::read_vtk_image_data(reader->GetOutput());
}
else else
{ {
std::cerr << "Error: Unsupported file format" << std::endl; std::cerr << "Error: Unsupported file format" << std::endl;