Merge branch 'lrineau/CGAL_ImageIO-fix_VTK_6_support-lrineau' into CGAL-Qt5_support-GF

Conflicts:
	CGAL_ImageIO/demo/CGALimageIO/CMakeLists.txt
	Installation/changes.html
This commit is contained in:
Laurent Rineau 2015-07-10 18:05:25 +02:00
commit 6d892480be
9 changed files with 73 additions and 46 deletions

View File

@ -25,40 +25,30 @@ endforeach()
find_package(CGAL REQUIRED ImageIO)
include( ${CGAL_USE_FILE} )
find_package(VTK QUIET)
find_package(Qt4 QUIET)
find_package(VTK QUIET NO_MODULE)
if(QT_FOUND AND VTK_FOUND)
if(VTK_FOUND)
add_definitions(-DCGAL_USE_VTK)
include(${VTK_USE_FILE})
include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})
if(TARGET vtkRenderingQt AND TARGET vtkFiltersModeling)
find_package(VTK COMPONENTS vtkRenderingQt vtkFiltersModeling NO_MODULE)
include(${VTK_USE_FILE})
find_package(Qt${VTK_QT_VERSION} COMPONENTS QtGui)
if(NOT TARGET Qt${VTK_QT_VERSION}::QtGui)
message(STATUS "NOTICE: vtkRenderingQt needs Qt${VTK_QT_VERSION}, and will not be compiled.")
return()
endif()
if(VTK_USE_QVTK)
include_directories( ${VTK_QT_INCLUDE_DIR} )
include_directories( ${QT_INCLUDE_DIR} )
add_executable( image_to_vtk_viewer image_to_vtk_viewer.cpp )
add_to_cached_list( CGAL_EXECUTABLE_TARGETS image_to_vtk_viewer )
target_link_libraries( image_to_vtk_viewer
QVTK
vtkRendering
vtkGraphics
vtkIO
vtkCommon
${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES}
${VTK_QT_QT_LIBRARY}
${QT_LIBRARIES}
${VTK_LIBRARIES} Qt${VTK_QT_VERSION}::QtGui
)
else(VTK_USE_QVTK)
message(STATUS "NOTICE: This demo needs QVTK, and will not be compiled.")
endif(VTK_USE_QVTK)
else()
message(STATUS "NOTICE: This demo needs vtkRenderingQt and vtkFiltersModeling, and will not be compiled.")
endif()
else()
if(NOT VTK_FOUND)
message(STATUS "NOTICE: This demo needs VTK, and will not be compiled.")
endif()
if(NOT QT_FOUND)
message(STATUS "NOTICE: This demo needs Qt4, and will not be compiled.")
endif()
message(STATUS "NOTICE: This demo needs VTK, and will not be compiled.")
endif()

View File

@ -77,7 +77,7 @@ int main(int argc, char** argv)
widget.SetRenderWindow(renWin);
vtkContourFilter *skinExtractor = vtkContourFilter::New();
skinExtractor->SetInput(vtk_image);
skinExtractor->SetInputData(vtk_image);
skinExtractor->SetValue(0, isovalue);
// skinExtractor->SetComputeNormals(0);
vtkPolyDataNormals *skinNormals = vtkPolyDataNormals::New();
@ -92,7 +92,7 @@ int main(int argc, char** argv)
// An outline provides context around the data.
//
vtkOutlineFilter *outlineData = vtkOutlineFilter::New();
outlineData->SetInput(vtk_image);
outlineData->SetInputData(vtk_image);
vtkPolyDataMapper *mapOutline = vtkPolyDataMapper::New();
mapOutline->SetInputConnection(outlineData->GetOutputPort());
vtkActor *outline = vtkActor::New();

View File

@ -113,13 +113,13 @@ struct VTK_type_generator<boost::uint32_t> {
vtk_image->SetDimensions(image.xdim(),
image.ydim(),
image.zdim());
vtk_image->SetWholeExtent(0, image.xdim(),
0, image.ydim(),
0, image.zdim());
vtk_image->SetExtent(0, image.xdim()-1,
0, image.ydim()-1,
0, image.zdim()-1);
vtk_image->SetSpacing(image.vx(),
image.vy(),
image.vz());
vtk_image->SetScalarType(type);
vtk_image->AllocateScalars(type, 1);
vtk_image->GetPointData()->SetScalars(data_array);
return vtk_image;
} // end vtk_image_sharing_same_data_pointer

View File

@ -6,7 +6,7 @@ find_package( ZLIB )
#option(WITH_VTK "Add VTK support to libCGAL_ImageIO." OFF)
if(WITH_VTK)
find_package(VTK QUIET)
find_package(VTK COMPONENTS vtkImagingCore vtkIOImage vtkFiltersImaging NO_MODULE REQUIRED)
endif(WITH_VTK)
if(OPENGL_FOUND)
@ -31,11 +31,10 @@ if(OPENGL_FOUND)
message(STATUS "VTK-${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}.${VTK_BUILD_VERSION} found. Build VTK support in ${CGAL_ImageIO_BASENAME}.")
include( ${VTK_USE_FILE} )
cache_set(CGAL_ImageIO_3RD_PARTY_DEFINITIONS ${CGAL_ImageIO_3RD_PARTY_DEFINITIONS} -DCGAL_USE_VTK ${VTK_REQUIRED_CXX_FLAGS})
cache_set(CGAL_ImageIO_3RD_PARTY_DEFINITIONS ${CGAL_ImageIO_3RD_PARTY_DEFINITIONS} -DCGAL_USE_VTK)
cache_set(CGAL_ImageIO_3RD_PARTY_INCLUDE_DIRS ${CGAL_ImageIO_3RD_PARTY_INCLUDE_DIRS} ${VTK_INCLUDE_DIRS} )
cache_set(CGAL_ImageIO_3RD_PARTY_LIBRARIES_DIRS ${CGAL_ImageIO_3RD_PARTY_LIBRARIES_DIRS} ${VTK_LIBRARY_DIRS} )
cache_set(CGAL_ImageIO_3RD_PARTY_LIBRARIES_DIRS ${CGAL_ImageIO_3RD_PARTY_LIBRARIES_DIRS} ${vtkImagingCore_RUNTIME_LIBRARY_DIRS} ${vtkImagingCore_LIBRARY_DIRS} ${vtkIOImage_RUNTIME_LIBRARY_DIRS} ${vtkIOImage_LIBRARY_DIRS} ${vtkFiltersImaging_RUNTIME_LIBRARY_DIRS} ${vtkFiltersImaging_LIBRARY_DIRS})
cache_set(CGAL_ImageIO_3RD_PARTY_LIBRARIES ${CGAL_ImageIO_3RD_PARTY_LIBRARIES} ${VTK_LIBRARIES} )
else()
message(STATUS "VTK not found.")
endif()

View File

@ -197,7 +197,6 @@ Image_3::read_vtk_image_data(vtkImageData* vtk_image)
image->vx = spacing[0];
image->vy = spacing[1];
image->vz = spacing[2];
vtk_image->Update();
image->endianness = ::_getEndianness();
int vtk_type = vtk_image->GetScalarType();
if(vtk_type == VTK_SIGNED_CHAR) vtk_type = VTK_CHAR;

View File

@ -31,6 +31,7 @@ LC_CTYPE=en_US.UTF-8
*/10 21-22 * * * setarch i686 $HOME/CGAL/Scripts/developer_scripts/autotest_cgal_with_cmake
# Launch our Docker testsuite, at 2:36 am
23 23 * * * docker pull -a docker.io/cgal/testsuite-docker
36 2 * * * cd /home/lrineau/Git/cgal-testsuite-dockerfiles && time ./test_cgal.py --use-fedora-selinux-policy --force-rm --max-cpus 10 --container-cpus 5 --jobs 6 --upload-results --images $(docker images | awk '/docker.io\/cgal\/testsuite-docker/ {print $1 ":" $2}')

View File

@ -19,7 +19,7 @@ COMPILERS_localhost="$COMPILERS_localhost x86-64_Linux-Fedora19_g++-4.8"
COMPILERS_localhost="$COMPILERS_localhost x86-64_Linux-Fedora19_g++-4.8_MATCHING-BUG-6"
COMPILERS_localhost="$COMPILERS_localhost x86-64_Linux-Fedora19_g++-4.8_Release"
#COMPILERS_localhost="$COMPILERS_localhost x86-64_Linux-Fedora19_g++-4.5-branch_Release"
COMPILERS_localhost="$COMPILERS_localhost x86-64_Linux-Fedora19_g++-4.8_CXX0X"
#COMPILERS_localhost="$COMPILERS_localhost x86-64_Linux-Fedora19_g++-4.8_CXX0X"
COMPILERS_localhost="$COMPILERS_localhost x86-64_Linux-Fedora19_g++-4.8_CXXDEBUG"
COMPILERS_localhost="$COMPILERS_localhost x86-64_Linux-Fedora19_IntelCompiler-14.0-with-g++-4.8-STL"
COMPILERS_localhost="$COMPILERS_localhost x86-64_Linux-Fedora19_IntelCompiler-14.0-with-g++-4.8-STL_strict-ansi"

View File

@ -329,6 +329,16 @@ void Volume::only_in()
#include <vtkDICOMImageReader.h>
#include <vtkImageReader.h>
#include <vtkImageGaussianSmooth.h>
#include <vtkDemandDrivenPipeline.h>
Volume::~Volume()
{
if(vtk_reader) vtk_reader->Delete();
if(vtk_image) vtk_image->Delete();
if(dicom_reader) dicom_reader->Delete();
if(executive) executive->Delete();
if(smoother) smoother->Delete();
}
bool Volume::opendir(const QString& dirname)
{
@ -342,15 +352,21 @@ bool Volume::opendir(const QString& dirname)
}
else
{
vtkDICOMImageReader* dicom_reader = vtkDICOMImageReader::New();
dicom_reader = vtkDICOMImageReader::New();
dicom_reader->SetDirectoryName(dirname.toUtf8());
vtkImageGaussianSmooth* smoother = vtkImageGaussianSmooth::New();
executive =
vtkDemandDrivenPipeline::SafeDownCast(dicom_reader->GetExecutive());
if (executive)
{
executive->SetReleaseDataFlag(0, 0); // where 0 is the port index
}
smoother = vtkImageGaussianSmooth::New();
smoother->SetStandardDeviations(1., 1., 1.);
smoother->SetInputConnection(dicom_reader->GetOutputPort());
smoother->Update();
vtkImageData* vtk_image = smoother->GetOutput();
dicom_reader->SetReleaseDataFlag(false);
vtk_image->SetReleaseDataFlag(false);
vtk_image = smoother->GetOutput();
vtk_image->Print(std::cerr);
if(!m_image.read_vtk_image_data(vtk_image))
{
@ -365,7 +381,8 @@ bool Volume::opendir(const QString& dirname)
finish_open();
result = true;
}
dicom_reader->Delete();
// if(executive) executive->Delete();
// dicom_reader->Delete();
// smoother->Delete();
}
return result;
@ -391,7 +408,7 @@ bool Volume::open_vtk(const QString& filename)
}
else
{
vtkImageReader* vtk_reader = vtkImageReader::New();
vtk_reader = vtkImageReader::New();
vtk_reader->SetFileName(filename.toUtf8());
vtk_reader->SetDataScalarTypeToUnsignedChar();
vtk_reader->SetDataExtent(0, 249, 0, 249, 0, 124);
@ -399,7 +416,7 @@ bool Volume::open_vtk(const QString& filename)
vtk_reader->SetFileDimensionality(3);
vtk_reader->Update();
vtk_reader->Print(std::cerr);
vtkImageData* vtk_image = vtk_reader->GetOutput();
vtk_image = vtk_reader->GetOutput();
vtk_image->Print(std::cerr);
if(!m_image.read_vtk_image_data(vtk_image))
{
@ -485,6 +502,10 @@ bool Volume::open_xt(const QString& filename)
}
#else // CGAL_USE_VTK
Volume::~Volume()
{
}
bool Volume::opendir(const QString&)
{
return false;

View File

@ -21,6 +21,14 @@
#include <QString>
#include <QFileInfo>
#ifdef CGAL_USE_VTK
class vtkImageReader;
class vtkImageData;
class vtkDICOMImageReader;
class vtkDemandDrivenPipeline;
class vtkImageGaussianSmooth;
#endif // CGAL_USE_VTK
class QTreeWidgetItem;
// kernel
@ -83,7 +91,7 @@ class Volume : public Surface
Q_OBJECT
public:
Volume(MainWindow* mw);
~Volume() {}
~Volume();
private:
Binary_image m_image;
@ -142,6 +150,15 @@ private:
bool m_view_mc; // that boolean is here even with if
// CGAL_SURFACE_MESH_DEMO_USE_MARCHING_CUBE
// is not defined.
#ifdef CGAL_USE_VTK
vtkImageReader* vtk_reader;
vtkImageData* vtk_image;
vtkDICOMImageReader* dicom_reader;
vtkDemandDrivenPipeline* executive;
vtkImageGaussianSmooth* smoother;
#endif // CGAL_USE_VTK
public Q_SLOTS:
void display_marchin_cube();