From cc9dd25626089b66646bab3d454e07a2bf2c624a Mon Sep 17 00:00:00 2001 From: Romulo Pinho Date: Fri, 22 Apr 2011 13:19:20 +0200 Subject: [PATCH] clitk mesh tools Addition of clitk tools to generate meshes from binary images and to visualize meshes --- tools/CMakeLists.txt | 398 ++++++++++++++++--------------- tools/clitkBinaryImageToMesh.cxx | 122 ++++++++++ tools/clitkBinaryImageToMesh.ggo | 11 + tools/clitkMeshViewer.cxx | 313 ++++++++++++++++++++++++ 4 files changed, 650 insertions(+), 194 deletions(-) create mode 100644 tools/clitkBinaryImageToMesh.cxx create mode 100644 tools/clitkBinaryImageToMesh.ggo create mode 100644 tools/clitkMeshViewer.cxx diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index c46ba3a..0294055 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -25,236 +25,246 @@ WRAP_GGO(clitkMedianImageFilter_GGO_C clitkMedianImageFilter.ggo) ADD_LIBRARY(clitkMedianImageFilterLib clitkMedianImageGenericFilter.cxx ${clitkMedianImageFilter_GGO_C}) IF (CLITK_BUILD_TOOLS) - WRAP_GGO(clitkDicomInfo_GGO_C clitkDicomInfo.ggo) - ADD_EXECUTABLE(clitkDicomInfo clitkDicomInfo.cxx ${clitkDicomInfo_GGO_C}) - TARGET_LINK_LIBRARIES(clitkDicomInfo clitkCommon ${ITK_LIBRARIES}) + WRAP_GGO(clitkDicomInfo_GGO_C clitkDicomInfo.ggo) + ADD_EXECUTABLE(clitkDicomInfo clitkDicomInfo.cxx ${clitkDicomInfo_GGO_C}) + TARGET_LINK_LIBRARIES(clitkDicomInfo clitkCommon ${ITK_LIBRARIES}) - WRAP_GGO(clitkDicom2Image_GGO_C clitkDicom2Image.ggo) - ADD_EXECUTABLE(clitkDicom2Image clitkDicom2Image.cxx ${clitkDicom2Image_GGO_C}) - TARGET_LINK_LIBRARIES(clitkDicom2Image clitkCommon ${ITK_LIBRARIES}) + WRAP_GGO(clitkDicom2Image_GGO_C clitkDicom2Image.ggo) + ADD_EXECUTABLE(clitkDicom2Image clitkDicom2Image.cxx ${clitkDicom2Image_GGO_C}) + TARGET_LINK_LIBRARIES(clitkDicom2Image clitkCommon ${ITK_LIBRARIES}) - WRAP_GGO(clitkImageInfo_GGO_C clitkImageInfo.ggo) - ADD_EXECUTABLE(clitkImageInfo clitkImageInfo.cxx ${clitkImageInfo_GGO_C}) - TARGET_LINK_LIBRARIES(clitkImageInfo clitkCommon ${ITK_LIBRARIES}) + WRAP_GGO(clitkImageInfo_GGO_C clitkImageInfo.ggo) + ADD_EXECUTABLE(clitkImageInfo clitkImageInfo.cxx ${clitkImageInfo_GGO_C}) + TARGET_LINK_LIBRARIES(clitkImageInfo clitkCommon ${ITK_LIBRARIES}) - ADD_EXECUTABLE(clitkImageConvert clitkImageConvert.cxx) - TARGET_LINK_LIBRARIES(clitkImageConvert clitkImageConvertLib clitkCommon ${ITK_LIBRARIES}) + ADD_EXECUTABLE(clitkImageConvert clitkImageConvert.cxx) + TARGET_LINK_LIBRARIES(clitkImageConvert clitkImageConvertLib clitkCommon ${ITK_LIBRARIES}) - ADD_EXECUTABLE(clitkBinarizeImage clitkBinarizeImage.cxx) - TARGET_LINK_LIBRARIES(clitkBinarizeImage clitkBinarizeImageLib clitkCommon ${ITK_LIBRARIES}) + ADD_EXECUTABLE(clitkBinarizeImage clitkBinarizeImage.cxx) + TARGET_LINK_LIBRARIES(clitkBinarizeImage clitkBinarizeImageLib clitkCommon ${ITK_LIBRARIES}) - WRAP_GGO(clitkVFResample_GGO_C clitkVFResample.ggo) - ADD_EXECUTABLE(clitkVFResample clitkVFResample.cxx clitkVFResampleGenericFilter.cxx ${clitkVFResample_GGO_C}) - TARGET_LINK_LIBRARIES(clitkVFResample clitkCommon ${ITK_LIBRARIES}) + WRAP_GGO(clitkVFResample_GGO_C clitkVFResample.ggo) + ADD_EXECUTABLE(clitkVFResample clitkVFResample.cxx clitkVFResampleGenericFilter.cxx ${clitkVFResample_GGO_C}) + TARGET_LINK_LIBRARIES(clitkVFResample clitkCommon ${ITK_LIBRARIES}) - WRAP_GGO(clitkImageCreate_GGO_C clitkImageCreate.ggo) - ADD_EXECUTABLE(clitkImageCreate clitkImageCreate.cxx ${clitkImageCreate_GGO_C}) - TARGET_LINK_LIBRARIES(clitkImageCreate clitkCommon ${ITK_LIBRARIES}) + WRAP_GGO(clitkImageCreate_GGO_C clitkImageCreate.ggo) + ADD_EXECUTABLE(clitkImageCreate clitkImageCreate.cxx ${clitkImageCreate_GGO_C}) + TARGET_LINK_LIBRARIES(clitkImageCreate clitkCommon ${ITK_LIBRARIES}) - WRAP_GGO(clitkZeroVF_GGO_C clitkZeroVF.ggo) - ADD_EXECUTABLE(clitkZeroVF clitkZeroVF.cxx ${clitkZeroVF_GGO_C} clitkZeroVFGenericFilter.cxx) - TARGET_LINK_LIBRARIES(clitkZeroVF clitkCommon ${ITK_LIBRARIES}) + WRAP_GGO(clitkZeroVF_GGO_C clitkZeroVF.ggo) + ADD_EXECUTABLE(clitkZeroVF clitkZeroVF.cxx ${clitkZeroVF_GGO_C} clitkZeroVFGenericFilter.cxx) + TARGET_LINK_LIBRARIES(clitkZeroVF clitkCommon ${ITK_LIBRARIES}) - WRAP_GGO(clitkImageExtractLine_GGO_C clitkImageExtractLine.ggo) - ADD_EXECUTABLE(clitkImageExtractLine clitkImageExtractLine.cxx ${clitkImageExtractLine_GGO_C}) - TARGET_LINK_LIBRARIES(clitkImageExtractLine clitkCommon ${ITK_LIBRARIES}) + WRAP_GGO(clitkImageExtractLine_GGO_C clitkImageExtractLine.ggo) + ADD_EXECUTABLE(clitkImageExtractLine clitkImageExtractLine.cxx ${clitkImageExtractLine_GGO_C}) + TARGET_LINK_LIBRARIES(clitkImageExtractLine clitkCommon ${ITK_LIBRARIES}) - WRAP_GGO(clitkSplitImage_GGO_C clitkSplitImage.ggo) - ADD_EXECUTABLE(clitkSplitImage clitkSplitImage.cxx clitkSplitImageGenericFilter.cxx ${clitkSplitImage_GGO_C}) - TARGET_LINK_LIBRARIES(clitkSplitImage clitkCommon ${ITK_LIBRARIES} ) + WRAP_GGO(clitkSplitImage_GGO_C clitkSplitImage.ggo) + ADD_EXECUTABLE(clitkSplitImage clitkSplitImage.cxx clitkSplitImageGenericFilter.cxx ${clitkSplitImage_GGO_C}) + TARGET_LINK_LIBRARIES(clitkSplitImage clitkCommon ${ITK_LIBRARIES} ) - WRAP_GGO(clitkVFMerge_GGO_C clitkVFMerge.ggo) - ADD_EXECUTABLE(clitkVFMerge clitkVFMerge.cxx ${clitkVFMerge_GGO_C}) - TARGET_LINK_LIBRARIES(clitkVFMerge clitkCommon ${ITK_LIBRARIES}) + WRAP_GGO(clitkVFMerge_GGO_C clitkVFMerge.ggo) + ADD_EXECUTABLE(clitkVFMerge clitkVFMerge.cxx ${clitkVFMerge_GGO_C}) + TARGET_LINK_LIBRARIES(clitkVFMerge clitkCommon ${ITK_LIBRARIES}) - WRAP_GGO(clitkWriteDicomSeries_GGO_C clitkWriteDicomSeries.ggo) - ADD_EXECUTABLE(clitkWriteDicomSeries clitkWriteDicomSeries.cxx ${clitkWriteDicomSeries_GGO_C}) - TARGET_LINK_LIBRARIES(clitkWriteDicomSeries clitkCommon ${ITK_LIBRARIES} ) + WRAP_GGO(clitkWriteDicomSeries_GGO_C clitkWriteDicomSeries.ggo) + ADD_EXECUTABLE(clitkWriteDicomSeries clitkWriteDicomSeries.cxx ${clitkWriteDicomSeries_GGO_C}) + TARGET_LINK_LIBRARIES(clitkWriteDicomSeries clitkCommon ${ITK_LIBRARIES} ) - WRAP_GGO(clitkAverageTemporalDimension_GGO_C clitkAverageTemporalDimension.ggo) - ADD_EXECUTABLE(clitkAverageTemporalDimension clitkAverageTemporalDimension.cxx ${clitkAverageTemporalDimension_GGO_C}) - TARGET_LINK_LIBRARIES(clitkAverageTemporalDimension clitkCommon ${ITK_LIBRARIES} ) + WRAP_GGO(clitkAverageTemporalDimension_GGO_C clitkAverageTemporalDimension.ggo) + ADD_EXECUTABLE(clitkAverageTemporalDimension clitkAverageTemporalDimension.cxx ${clitkAverageTemporalDimension_GGO_C}) + TARGET_LINK_LIBRARIES(clitkAverageTemporalDimension clitkCommon ${ITK_LIBRARIES} ) - WRAP_GGO(clitkMedianTemporalDimension_GGO_C clitkMedianTemporalDimension.ggo) - ADD_EXECUTABLE(clitkMedianTemporalDimension clitkMedianTemporalDimension.cxx - ${clitkMedianTemporalDimension_GGO_C}) - TARGET_LINK_LIBRARIES(clitkMedianTemporalDimension clitkCommon ${ITK_LIBRARIES} ) + WRAP_GGO(clitkMedianTemporalDimension_GGO_C clitkMedianTemporalDimension.ggo) + ADD_EXECUTABLE(clitkMedianTemporalDimension clitkMedianTemporalDimension.cxx + ${clitkMedianTemporalDimension_GGO_C}) + TARGET_LINK_LIBRARIES(clitkMedianTemporalDimension clitkCommon ${ITK_LIBRARIES} ) - WRAP_GGO(clitkWarpImage_GGO_C clitkWarpImage.ggo) - ADD_EXECUTABLE(clitkWarpImage clitkWarpImage.cxx ${clitkWarpImage_GGO_C} clitkWarpImageGenericFilter.cxx) - TARGET_LINK_LIBRARIES(clitkWarpImage clitkCommon ${ITK_LIBRARIES}) + WRAP_GGO(clitkWarpImage_GGO_C clitkWarpImage.ggo) + ADD_EXECUTABLE(clitkWarpImage clitkWarpImage.cxx ${clitkWarpImage_GGO_C} clitkWarpImageGenericFilter.cxx) + TARGET_LINK_LIBRARIES(clitkWarpImage clitkCommon ${ITK_LIBRARIES}) - WRAP_GGO(clitkInvertVF_GGO_C clitkInvertVF.ggo) - ADD_EXECUTABLE(clitkInvertVF clitkInvertVF.cxx ${clitkInvertVF_GGO_C}) - TARGET_LINK_LIBRARIES(clitkInvertVF clitkCommon ${ITK_LIBRARIES} ) + WRAP_GGO(clitkInvertVF_GGO_C clitkInvertVF.ggo) + ADD_EXECUTABLE(clitkInvertVF clitkInvertVF.cxx ${clitkInvertVF_GGO_C}) + TARGET_LINK_LIBRARIES(clitkInvertVF clitkCommon ${ITK_LIBRARIES} ) - WRAP_GGO(clitkAffineTransform_GGO_C clitkAffineTransform.ggo) - ADD_EXECUTABLE(clitkAffineTransform clitkAffineTransform.cxx ${clitkAffineTransform_GGO_C}) - TARGET_LINK_LIBRARIES(clitkAffineTransform clitkCommon ${ITK_LIBRARIES} ) + WRAP_GGO(clitkAffineTransform_GGO_C clitkAffineTransform.ggo) + ADD_EXECUTABLE(clitkAffineTransform clitkAffineTransform.cxx ${clitkAffineTransform_GGO_C}) + TARGET_LINK_LIBRARIES(clitkAffineTransform clitkCommon ${ITK_LIBRARIES} ) - WRAP_GGO(clitkSetBackground_GGO_C clitkSetBackground.ggo) - ADD_EXECUTABLE(clitkSetBackground clitkSetBackground.cxx clitkSetBackgroundGenericFilter.cxx ${clitkSetBackground_GGO_C}) - TARGET_LINK_LIBRARIES(clitkSetBackground clitkCommon ${ITK_LIBRARIES}) + WRAP_GGO(clitkSetBackground_GGO_C clitkSetBackground.ggo) + ADD_EXECUTABLE(clitkSetBackground clitkSetBackground.cxx clitkSetBackgroundGenericFilter.cxx ${clitkSetBackground_GGO_C}) + TARGET_LINK_LIBRARIES(clitkSetBackground clitkCommon ${ITK_LIBRARIES}) - WRAP_GGO(clitkGuerreroVentilation_GGO_C clitkGuerreroVentilation.ggo) - ADD_EXECUTABLE(clitkGuerreroVentilation clitkGuerreroVentilation.cxx clitkGuerreroVentilationGenericFilter.cxx ${clitkGuerreroVentilation_GGO_C}) - TARGET_LINK_LIBRARIES(clitkGuerreroVentilation clitkCommon ${ITK_LIBRARIES}) + WRAP_GGO(clitkGuerreroVentilation_GGO_C clitkGuerreroVentilation.ggo) + ADD_EXECUTABLE(clitkGuerreroVentilation clitkGuerreroVentilation.cxx clitkGuerreroVentilationGenericFilter.cxx ${clitkGuerreroVentilation_GGO_C}) + TARGET_LINK_LIBRARIES(clitkGuerreroVentilation clitkCommon ${ITK_LIBRARIES}) - WRAP_GGO(clitkGammaIndex_GGO_C clitkGammaIndex.ggo) - ADD_EXECUTABLE(clitkGammaIndex clitkGammaIndex.cxx ${clitkGammaIndex_GGO_C}) - TARGET_LINK_LIBRARIES(clitkGammaIndex vtkCommon vtkFiltering vtkGraphics vtkIO vtkImaging) + WRAP_GGO(clitkGammaIndex_GGO_C clitkGammaIndex.ggo) + ADD_EXECUTABLE(clitkGammaIndex clitkGammaIndex.cxx ${clitkGammaIndex_GGO_C}) + TARGET_LINK_LIBRARIES(clitkGammaIndex vtkCommon vtkFiltering vtkGraphics vtkIO vtkImaging) - ADD_EXECUTABLE(clitkImageArithm clitkImageArithm.cxx) - TARGET_LINK_LIBRARIES(clitkImageArithm clitkImageArithmImageLib clitkCommon ${ITK_LIBRARIES} ) + ADD_EXECUTABLE(clitkImageArithm clitkImageArithm.cxx) + TARGET_LINK_LIBRARIES(clitkImageArithm clitkImageArithmImageLib clitkCommon ${ITK_LIBRARIES} ) - WRAP_GGO(clitkUnsharpMask_GGO_C clitkUnsharpMask.ggo) - ADD_EXECUTABLE(clitkUnsharpMask clitkUnsharpMask.cxx ${clitkUnsharpMask_GGO_C}) - TARGET_LINK_LIBRARIES(clitkUnsharpMask clitkCommon ${ITK_LIBRARIES} ) + WRAP_GGO(clitkUnsharpMask_GGO_C clitkUnsharpMask.ggo) + ADD_EXECUTABLE(clitkUnsharpMask clitkUnsharpMask.cxx ${clitkUnsharpMask_GGO_C}) + TARGET_LINK_LIBRARIES(clitkUnsharpMask clitkCommon ${ITK_LIBRARIES} ) - WRAP_GGO(clitkFooImage_GGO_C clitkFooImage.ggo) - ADD_EXECUTABLE(clitkFooImage clitkFooImage.cxx ${clitkFooImage_GGO_C}) - TARGET_LINK_LIBRARIES(clitkFooImage clitkCommon ${ITK_LIBRARIES} ) + WRAP_GGO(clitkFooImage_GGO_C clitkFooImage.ggo) + ADD_EXECUTABLE(clitkFooImage clitkFooImage.cxx ${clitkFooImage_GGO_C}) + TARGET_LINK_LIBRARIES(clitkFooImage clitkCommon ${ITK_LIBRARIES} ) - WRAP_GGO(clitkMedianImageFilter_GGO_C clitkMedianImageFilter.ggo) - ADD_EXECUTABLE(clitkMedianImageFilter clitkMedianImageFilter.cxx ${clitkMedianImageFilter_GGO_C}) - TARGET_LINK_LIBRARIES(clitkMedianImageFilter clitkCommon ${ITK_LIBRARIES}) + WRAP_GGO(clitkMedianImageFilter_GGO_C clitkMedianImageFilter.ggo) + ADD_EXECUTABLE(clitkMedianImageFilter clitkMedianImageFilter.cxx ${clitkMedianImageFilter_GGO_C}) + TARGET_LINK_LIBRARIES(clitkMedianImageFilter clitkCommon ${ITK_LIBRARIES}) - ADD_EXECUTABLE(clitkResampleImage clitkResampleImage.cxx) - TARGET_LINK_LIBRARIES(clitkResampleImage clitkResampleImageLib clitkCommon ${ITK_LIBRARIES}) + ADD_EXECUTABLE(clitkResampleImage clitkResampleImage.cxx) + TARGET_LINK_LIBRARIES(clitkResampleImage clitkResampleImageLib clitkCommon ${ITK_LIBRARIES}) - WRAP_GGO(clitkMinMaxMask_GGO_C clitkMinMaxMask.ggo) - ADD_EXECUTABLE(clitkMinMaxMask clitkMinMaxMask.cxx ${clitkMinMaxMask_GGO_C}) - TARGET_LINK_LIBRARIES(clitkMinMaxMask clitkCommon ${ITK_LIBRARIES} ) + WRAP_GGO(clitkMinMaxMask_GGO_C clitkMinMaxMask.ggo) + ADD_EXECUTABLE(clitkMinMaxMask clitkMinMaxMask.cxx ${clitkMinMaxMask_GGO_C}) + TARGET_LINK_LIBRARIES(clitkMinMaxMask clitkCommon ${ITK_LIBRARIES} ) - # WRAP_GGO(clitkAutoCrop_GGO_C clitkAutoCrop.ggo) - # ADD_EXECUTABLE(clitkAutoCrop clitkAutoCrop.cxx ${clitkAutoCrop_GGO_C}) - # TARGET_LINK_LIBRARIES(clitkAutoCrop clitkCommon ${ITK_LIBRARIES} ) + # WRAP_GGO(clitkAutoCrop_GGO_C clitkAutoCrop.ggo) + # ADD_EXECUTABLE(clitkAutoCrop clitkAutoCrop.cxx ${clitkAutoCrop_GGO_C}) + # TARGET_LINK_LIBRARIES(clitkAutoCrop clitkCommon ${ITK_LIBRARIES} ) - WRAP_GGO(clitkDicomRTStruct2BinaryImage_GGO_C clitkDicomRTStruct2BinaryImage.ggo) - ADD_EXECUTABLE(clitkDicomRTStruct2BinaryImage clitkDicomRTStruct2BinaryImage.cxx ${clitkDicomRTStruct2BinaryImage_GGO_C}) - TARGET_LINK_LIBRARIES(clitkDicomRTStruct2BinaryImage clitkDicomRTStruct clitkCommon ${ITK_LIBRARIES} ) + WRAP_GGO(clitkDicomRTStruct2BinaryImage_GGO_C clitkDicomRTStruct2BinaryImage.ggo) + ADD_EXECUTABLE(clitkDicomRTStruct2BinaryImage clitkDicomRTStruct2BinaryImage.cxx ${clitkDicomRTStruct2BinaryImage_GGO_C}) + TARGET_LINK_LIBRARIES(clitkDicomRTStruct2BinaryImage clitkDicomRTStruct clitkCommon ${ITK_LIBRARIES} ) - WRAP_GGO(clitkImageLog_GGO_C clitkImageLog.ggo) - ADD_EXECUTABLE(clitkImageLog clitkImageLog.cxx ${clitkImageLog_GGO_C}) - TARGET_LINK_LIBRARIES(clitkImageLog ${ITK_LIBRARIES} clitkCommon) + WRAP_GGO(clitkImageLog_GGO_C clitkImageLog.ggo) + ADD_EXECUTABLE(clitkImageLog clitkImageLog.cxx ${clitkImageLog_GGO_C}) + TARGET_LINK_LIBRARIES(clitkImageLog ${ITK_LIBRARIES} clitkCommon) - WRAP_GGO(clitkFilter_GGO_C clitkFilter.ggo) - ADD_EXECUTABLE(clitkFilter clitkFilter.cxx clitkFilterGenericFilter.cxx ${clitkFilter_GGO_C}) - TARGET_LINK_LIBRARIES(clitkFilter ${ITK_LIBRARIES} clitkCommon) + WRAP_GGO(clitkFilter_GGO_C clitkFilter.ggo) + ADD_EXECUTABLE(clitkFilter clitkFilter.cxx clitkFilterGenericFilter.cxx ${clitkFilter_GGO_C}) + TARGET_LINK_LIBRARIES(clitkFilter ${ITK_LIBRARIES} clitkCommon) - WRAP_GGO(clitkConeBeamProjectImage_GGO_C clitkConeBeamProjectImage.ggo) - ADD_EXECUTABLE(clitkConeBeamProjectImage clitkConeBeamProjectImage.cxx clitkConeBeamProjectImageGenericFilter.cxx ${clitkConeBeamProjectImage_GGO_C}) - TARGET_LINK_LIBRARIES(clitkConeBeamProjectImage ${ITK_LIBRARIES} clitkCommon ) + WRAP_GGO(clitkConeBeamProjectImage_GGO_C clitkConeBeamProjectImage.ggo) + ADD_EXECUTABLE(clitkConeBeamProjectImage clitkConeBeamProjectImage.cxx clitkConeBeamProjectImageGenericFilter.cxx ${clitkConeBeamProjectImage_GGO_C}) + TARGET_LINK_LIBRARIES(clitkConeBeamProjectImage ${ITK_LIBRARIES} clitkCommon ) - WRAP_GGO(clitkComposeVF_GGO_C clitkComposeVF.ggo) - ADD_EXECUTABLE(clitkComposeVF clitkComposeVFGenericFilter.cxx clitkComposeVF.cxx ${clitkComposeVF_GGO_C}) - TARGET_LINK_LIBRARIES(clitkComposeVF ${ITK_LIBRARIES} clitkCommon) + WRAP_GGO(clitkComposeVF_GGO_C clitkComposeVF.ggo) + ADD_EXECUTABLE(clitkComposeVF clitkComposeVFGenericFilter.cxx clitkComposeVF.cxx ${clitkComposeVF_GGO_C}) + TARGET_LINK_LIBRARIES(clitkComposeVF ${ITK_LIBRARIES} clitkCommon) - WRAP_GGO(clitkMergeSequence_GGO_C clitkMergeSequence.ggo) - ADD_EXECUTABLE(clitkMergeSequence clitkMergeSequence.cxx clitkMergeSequenceGenericFilter.cxx ${clitkMergeSequence_GGO_C}) - TARGET_LINK_LIBRARIES(clitkMergeSequence ${ITK_LIBRARIES} clitkCommon) + WRAP_GGO(clitkMergeSequence_GGO_C clitkMergeSequence.ggo) + ADD_EXECUTABLE(clitkMergeSequence clitkMergeSequence.cxx clitkMergeSequenceGenericFilter.cxx ${clitkMergeSequence_GGO_C}) + TARGET_LINK_LIBRARIES(clitkMergeSequence ${ITK_LIBRARIES} clitkCommon) - WRAP_GGO(clitkBackProjectImage_GGO_C clitkBackProjectImage.ggo) - ADD_EXECUTABLE(clitkBackProjectImage clitkBackProjectImage.cxx clitkBackProjectImageGenericFilter.cxx ${clitkBackProjectImage_GGO_C}) - TARGET_LINK_LIBRARIES(clitkBackProjectImage ${ITK_LIBRARIES} clitkCommon ) + WRAP_GGO(clitkBackProjectImage_GGO_C clitkBackProjectImage.ggo) + ADD_EXECUTABLE(clitkBackProjectImage clitkBackProjectImage.cxx clitkBackProjectImageGenericFilter.cxx ${clitkBackProjectImage_GGO_C}) + TARGET_LINK_LIBRARIES(clitkBackProjectImage ${ITK_LIBRARIES} clitkCommon ) - ADD_EXECUTABLE(clitkCropImage clitkCropImage.cxx ${clitkCropImage_GGO_C}) - TARGET_LINK_LIBRARIES(clitkCropImage clitkCropImageLib clitkCommon ${ITK_LIBRARIES}) + ADD_EXECUTABLE(clitkCropImage clitkCropImage.cxx ${clitkCropImage_GGO_C}) + TARGET_LINK_LIBRARIES(clitkCropImage clitkCropImageLib clitkCommon ${ITK_LIBRARIES}) + + # WRAP_GGO(clitkExtractSlice_GGO_C clitkExtractSlice.ggo) + # ADD_EXECUTABLE(clitkExtractSlice clitkExtractSlice.cxx clitkExtractSliceGenericFilter.cxx ${clitkExtractSlice_GGO_C}) + # TARGET_LINK_LIBRARIES(clitkExtractSlice clitkCommon ${ITK_LIBRARIES}) + + WRAP_GGO(clitkFlipImage_GGO_C clitkFlipImage.ggo) + ADD_EXECUTABLE(clitkFlipImage clitkFlipImage.cxx clitkFlipImageGenericFilter.cxx ${clitkFlipImage_GGO_C}) + TARGET_LINK_LIBRARIES(clitkFlipImage clitkCommon ${ITK_LIBRARIES}) + + WRAP_GGO(clitkMirrorPadImage_GGO_C clitkMirrorPadImage.ggo) + ADD_EXECUTABLE(clitkMirrorPadImage clitkMirrorPadImage.cxx clitkMirrorPadImageGenericFilter.cxx ${clitkMirrorPadImage_GGO_C}) + TARGET_LINK_LIBRARIES(clitkMirrorPadImage clitkCommon ${ITK_LIBRARIES}) + + WRAP_GGO(clitkImageMoment_GGO_C clitkImageMoment.ggo) + ADD_EXECUTABLE(clitkImageMoment clitkImageMoment.cxx clitkImageMomentGenericFilter.cxx ${clitkImageMoment_GGO_C}) + TARGET_LINK_LIBRARIES(clitkImageMoment clitkCommon ${ITK_LIBRARIES}) + + WRAP_GGO(clitkImageStatistics_GGO_C clitkImageStatistics.ggo) + ADD_EXECUTABLE(clitkImageStatistics clitkImageStatistics.cxx clitkImageStatisticsGenericFilter.cxx ${clitkImageStatistics_GGO_C}) + TARGET_LINK_LIBRARIES(clitkImageStatistics clitkCommon ${ITK_LIBRARIES}) + + WRAP_GGO(clitkSetOrigin_GGO_C clitkSetOrigin.ggo) + ADD_EXECUTABLE(clitkSetOrigin clitkSetOrigin.cxx clitkSetOriginGenericFilter.cxx ${clitkSetOrigin_GGO_C}) + TARGET_LINK_LIBRARIES(clitkSetOrigin clitkCommon ${ITK_LIBRARIES} ) + + WRAP_GGO(clitkGetOrigin_GGO_C clitkGetOrigin.ggo) + ADD_EXECUTABLE(clitkGetOrigin clitkGetOrigin.cxx clitkGetOriginGenericFilter.cxx ${clitkGetOrigin_GGO_C}) + TARGET_LINK_LIBRARIES(clitkGetOrigin clitkCommon ${ITK_LIBRARIES} ) + + WRAP_GGO(clitkGetDirection_GGO_C clitkGetDirection.ggo) + ADD_EXECUTABLE(clitkGetDirection clitkGetDirection.cxx clitkGetDirectionGenericFilter.cxx ${clitkGetDirection_GGO_C}) + TARGET_LINK_LIBRARIES(clitkGetDirection clitkCommon ${ITK_LIBRARIES}) + + WRAP_GGO(clitkSetDirection_GGO_C clitkSetDirection.ggo) + ADD_EXECUTABLE(clitkSetDirection clitkSetDirection.cxx clitkSetDirectionGenericFilter.cxx ${clitkSetDirection_GGO_C}) + TARGET_LINK_LIBRARIES(clitkSetDirection clitkCommon ${ITK_LIBRARIES}) + + WRAP_GGO(clitkGetSize_GGO_C clitkGetSize.ggo) + ADD_EXECUTABLE(clitkGetSize clitkGetSize.cxx clitkGetSizeGenericFilter.cxx ${clitkGetSize_GGO_C}) + TARGET_LINK_LIBRARIES(clitkGetSize clitkCommon ${ITK_LIBRARIES}) + + WRAP_GGO(clitkGetSpacing_GGO_C clitkGetSpacing.ggo) + ADD_EXECUTABLE(clitkGetSpacing clitkGetSpacing.cxx clitkGetSpacingGenericFilter.cxx ${clitkGetSpacing_GGO_C}) + TARGET_LINK_LIBRARIES(clitkGetSpacing clitkCommon ${ITK_LIBRARIES}) + + WRAP_GGO(clitkSetSpacing_GGO_C clitkSetSpacing.ggo) + ADD_EXECUTABLE(clitkSetSpacing clitkSetSpacing.cxx clitkSetSpacingGenericFilter.cxx ${clitkSetSpacing_GGO_C}) + TARGET_LINK_LIBRARIES(clitkSetSpacing clitkCommon ${ITK_LIBRARIES}) + + WRAP_GGO(clitkCombineImage_GGO_C clitkCombineImage.ggo) + ADD_EXECUTABLE(clitkCombineImage clitkCombineImage.cxx clitkCombineImageGenericFilter.cxx ${clitkCombineImage_GGO_C}) + TARGET_LINK_LIBRARIES(clitkCombineImage clitkCommon ${ITK_LIBRARIES}) + + WRAP_GGO(clitkPermuteAxes_GGO_C clitkPermuteAxes.ggo) + ADD_EXECUTABLE(clitkPermuteAxes clitkPermuteAxes.cxx clitkPermuteAxesGenericFilter.cxx ${clitkPermuteAxes_GGO_C}) + TARGET_LINK_LIBRARIES(clitkPermuteAxes clitkCommon ${ITK_LIBRARIES}) + + WRAP_GGO(clitkChangeImageOrientation_GGO_C clitkChangeImageOrientation.ggo) + ADD_EXECUTABLE(clitkChangeImageOrientation clitkChangeImageOrientation.cxx clitkChangeImageOrientationGenericFilter.cxx ${clitkChangeImageOrientation_GGO_C}) + TARGET_LINK_LIBRARIES(clitkChangeImageOrientation clitkCommon ${ITK_LIBRARIES}) + + WRAP_GGO(clitkVFConvert_GGO_C clitkVFConvert.ggo) + ADD_EXECUTABLE(clitkVFConvert clitkVFConvert.cxx clitkVFConvertGenericFilter.cxx ${clitkVFConvert_GGO_C}) + TARGET_LINK_LIBRARIES(clitkVFConvert ${ITK_LIBRARIES} clitkCommon ) - # WRAP_GGO(clitkExtractSlice_GGO_C clitkExtractSlice.ggo) - # ADD_EXECUTABLE(clitkExtractSlice clitkExtractSlice.cxx clitkExtractSliceGenericFilter.cxx ${clitkExtractSlice_GGO_C}) - # TARGET_LINK_LIBRARIES(clitkExtractSlice clitkCommon ${ITK_LIBRARIES}) + WRAP_GGO(clitkImageToVectorImage_GGO_C clitkImageToVectorImage.ggo) + ADD_EXECUTABLE(clitkImageToVectorImage clitkImageToVectorImage.cxx clitkImageToVectorImageGenericFilter.cxx ${clitkImageToVectorImage_GGO_C}) + TARGET_LINK_LIBRARIES(clitkImageToVectorImage clitkCommon ${ITK_LIBRARIES}) + + WRAP_GGO(clitkVectorImageToImage_GGO_C clitkVectorImageToImage.ggo) + ADD_EXECUTABLE(clitkVectorImageToImage clitkVectorImageToImage.cxx clitkVectorImageToImageGenericFilter.cxx ${clitkVectorImageToImage_GGO_C}) + TARGET_LINK_LIBRARIES(clitkVectorImageToImage clitkCommon ${ITK_LIBRARIES}) + + WRAP_GGO(clitkBSplineCoefficientsToValues_GGO_C clitkBSplineCoefficientsToValues.ggo) + ADD_EXECUTABLE(clitkBSplineCoefficientsToValues clitkBSplineCoefficientsToValues.cxx clitkBSplineCoefficientsToValuesGenericFilter.cxx ${clitkBSplineCoefficientsToValues_GGO_C}) + TARGET_LINK_LIBRARIES(clitkBSplineCoefficientsToValues clitkCommon ${ITK_LIBRARIES}) + + WRAP_GGO(clitkValuesToBSplineCoefficients_GGO_C clitkValuesToBSplineCoefficients.ggo) + ADD_EXECUTABLE(clitkValuesToBSplineCoefficients clitkValuesToBSplineCoefficients.cxx clitkValuesToBSplineCoefficientsGenericFilter.cxx ${clitkValuesToBSplineCoefficients_GGO_C}) + TARGET_LINK_LIBRARIES(clitkValuesToBSplineCoefficients clitkCommon ${ITK_LIBRARIES}) + + ADD_EXECUTABLE(clitkMIP clitkMIP.cxx clitkMIPGenericFilter.cxx) + TARGET_LINK_LIBRARIES(clitkMIP clitkMIPLib clitkCommon ${ITK_LIBRARIES}) + + WRAP_GGO(clitkRelativePosition_GGO_C clitkRelativePosition.ggo) + ADD_EXECUTABLE(clitkRelativePosition clitkRelativePosition.cxx ${clitkRelativePosition_GGO_C}) + TARGET_LINK_LIBRARIES(clitkRelativePosition clitkCommon ${ITK_LIBRARIES}) + + WRAP_GGO(clitkTransformLandmarks_GGO_C clitkTransformLandmarks.ggo) + ADD_EXECUTABLE(clitkTransformLandmarks clitkTransformLandmarks.cxx ${clitkTransformLandmarks_GGO_C}) + TARGET_LINK_LIBRARIES(clitkTransformLandmarks clitkCommon ${ITK_LIBRARIES}) + + WRAP_GGO(clitkLineProfile_GGO_C clitkLineProfile.ggo) + ADD_EXECUTABLE(clitkLineProfile clitkLineProfile.cxx clitkLineProfileGenericFilter.cxx ${clitkLineProfile_GGO_C}) + TARGET_LINK_LIBRARIES(clitkLineProfile clitkCommon ${ITK_LIBRARIES}) + + IF(CLITK_EXPERIMENTAL) - WRAP_GGO(clitkFlipImage_GGO_C clitkFlipImage.ggo) - ADD_EXECUTABLE(clitkFlipImage clitkFlipImage.cxx clitkFlipImageGenericFilter.cxx ${clitkFlipImage_GGO_C}) - TARGET_LINK_LIBRARIES(clitkFlipImage clitkCommon ${ITK_LIBRARIES}) - - WRAP_GGO(clitkMirrorPadImage_GGO_C clitkMirrorPadImage.ggo) - ADD_EXECUTABLE(clitkMirrorPadImage clitkMirrorPadImage.cxx clitkMirrorPadImageGenericFilter.cxx ${clitkMirrorPadImage_GGO_C}) - TARGET_LINK_LIBRARIES(clitkMirrorPadImage clitkCommon ${ITK_LIBRARIES}) - - WRAP_GGO(clitkImageMoment_GGO_C clitkImageMoment.ggo) - ADD_EXECUTABLE(clitkImageMoment clitkImageMoment.cxx clitkImageMomentGenericFilter.cxx ${clitkImageMoment_GGO_C}) - TARGET_LINK_LIBRARIES(clitkImageMoment clitkCommon ${ITK_LIBRARIES}) - - WRAP_GGO(clitkImageStatistics_GGO_C clitkImageStatistics.ggo) - ADD_EXECUTABLE(clitkImageStatistics clitkImageStatistics.cxx clitkImageStatisticsGenericFilter.cxx ${clitkImageStatistics_GGO_C}) - TARGET_LINK_LIBRARIES(clitkImageStatistics clitkCommon ${ITK_LIBRARIES}) - - WRAP_GGO(clitkSetOrigin_GGO_C clitkSetOrigin.ggo) - ADD_EXECUTABLE(clitkSetOrigin clitkSetOrigin.cxx clitkSetOriginGenericFilter.cxx ${clitkSetOrigin_GGO_C}) - TARGET_LINK_LIBRARIES(clitkSetOrigin clitkCommon ${ITK_LIBRARIES} ) - - WRAP_GGO(clitkGetOrigin_GGO_C clitkGetOrigin.ggo) - ADD_EXECUTABLE(clitkGetOrigin clitkGetOrigin.cxx clitkGetOriginGenericFilter.cxx ${clitkGetOrigin_GGO_C}) - TARGET_LINK_LIBRARIES(clitkGetOrigin clitkCommon ${ITK_LIBRARIES} ) - - WRAP_GGO(clitkGetDirection_GGO_C clitkGetDirection.ggo) - ADD_EXECUTABLE(clitkGetDirection clitkGetDirection.cxx clitkGetDirectionGenericFilter.cxx ${clitkGetDirection_GGO_C}) - TARGET_LINK_LIBRARIES(clitkGetDirection clitkCommon ${ITK_LIBRARIES}) - - WRAP_GGO(clitkSetDirection_GGO_C clitkSetDirection.ggo) - ADD_EXECUTABLE(clitkSetDirection clitkSetDirection.cxx clitkSetDirectionGenericFilter.cxx ${clitkSetDirection_GGO_C}) - TARGET_LINK_LIBRARIES(clitkSetDirection clitkCommon ${ITK_LIBRARIES}) - - WRAP_GGO(clitkGetSize_GGO_C clitkGetSize.ggo) - ADD_EXECUTABLE(clitkGetSize clitkGetSize.cxx clitkGetSizeGenericFilter.cxx ${clitkGetSize_GGO_C}) - TARGET_LINK_LIBRARIES(clitkGetSize clitkCommon ${ITK_LIBRARIES}) - - WRAP_GGO(clitkGetSpacing_GGO_C clitkGetSpacing.ggo) - ADD_EXECUTABLE(clitkGetSpacing clitkGetSpacing.cxx clitkGetSpacingGenericFilter.cxx ${clitkGetSpacing_GGO_C}) - TARGET_LINK_LIBRARIES(clitkGetSpacing clitkCommon ${ITK_LIBRARIES}) - - WRAP_GGO(clitkSetSpacing_GGO_C clitkSetSpacing.ggo) - ADD_EXECUTABLE(clitkSetSpacing clitkSetSpacing.cxx clitkSetSpacingGenericFilter.cxx ${clitkSetSpacing_GGO_C}) - TARGET_LINK_LIBRARIES(clitkSetSpacing clitkCommon ${ITK_LIBRARIES}) - - WRAP_GGO(clitkCombineImage_GGO_C clitkCombineImage.ggo) - ADD_EXECUTABLE(clitkCombineImage clitkCombineImage.cxx clitkCombineImageGenericFilter.cxx ${clitkCombineImage_GGO_C}) - TARGET_LINK_LIBRARIES(clitkCombineImage clitkCommon ${ITK_LIBRARIES}) - - WRAP_GGO(clitkPermuteAxes_GGO_C clitkPermuteAxes.ggo) - ADD_EXECUTABLE(clitkPermuteAxes clitkPermuteAxes.cxx clitkPermuteAxesGenericFilter.cxx ${clitkPermuteAxes_GGO_C}) - TARGET_LINK_LIBRARIES(clitkPermuteAxes clitkCommon ${ITK_LIBRARIES}) - - WRAP_GGO(clitkChangeImageOrientation_GGO_C clitkChangeImageOrientation.ggo) - ADD_EXECUTABLE(clitkChangeImageOrientation clitkChangeImageOrientation.cxx clitkChangeImageOrientationGenericFilter.cxx ${clitkChangeImageOrientation_GGO_C}) - TARGET_LINK_LIBRARIES(clitkChangeImageOrientation clitkCommon ${ITK_LIBRARIES}) - - WRAP_GGO(clitkVFConvert_GGO_C clitkVFConvert.ggo) - ADD_EXECUTABLE(clitkVFConvert clitkVFConvert.cxx clitkVFConvertGenericFilter.cxx ${clitkVFConvert_GGO_C}) - TARGET_LINK_LIBRARIES(clitkVFConvert ${ITK_LIBRARIES} clitkCommon ) - - WRAP_GGO(clitkImageToVectorImage_GGO_C clitkImageToVectorImage.ggo) - ADD_EXECUTABLE(clitkImageToVectorImage clitkImageToVectorImage.cxx clitkImageToVectorImageGenericFilter.cxx ${clitkImageToVectorImage_GGO_C}) - TARGET_LINK_LIBRARIES(clitkImageToVectorImage clitkCommon ${ITK_LIBRARIES}) - - WRAP_GGO(clitkVectorImageToImage_GGO_C clitkVectorImageToImage.ggo) - ADD_EXECUTABLE(clitkVectorImageToImage clitkVectorImageToImage.cxx clitkVectorImageToImageGenericFilter.cxx ${clitkVectorImageToImage_GGO_C}) - TARGET_LINK_LIBRARIES(clitkVectorImageToImage clitkCommon ${ITK_LIBRARIES}) - - WRAP_GGO(clitkBSplineCoefficientsToValues_GGO_C clitkBSplineCoefficientsToValues.ggo) - ADD_EXECUTABLE(clitkBSplineCoefficientsToValues clitkBSplineCoefficientsToValues.cxx clitkBSplineCoefficientsToValuesGenericFilter.cxx ${clitkBSplineCoefficientsToValues_GGO_C}) - TARGET_LINK_LIBRARIES(clitkBSplineCoefficientsToValues clitkCommon ${ITK_LIBRARIES}) - - WRAP_GGO(clitkValuesToBSplineCoefficients_GGO_C clitkValuesToBSplineCoefficients.ggo) - ADD_EXECUTABLE(clitkValuesToBSplineCoefficients clitkValuesToBSplineCoefficients.cxx clitkValuesToBSplineCoefficientsGenericFilter.cxx ${clitkValuesToBSplineCoefficients_GGO_C}) - TARGET_LINK_LIBRARIES(clitkValuesToBSplineCoefficients clitkCommon ${ITK_LIBRARIES}) - - ADD_EXECUTABLE(clitkMIP clitkMIP.cxx clitkMIPGenericFilter.cxx) - TARGET_LINK_LIBRARIES(clitkMIP clitkMIPLib clitkCommon ${ITK_LIBRARIES}) - - WRAP_GGO(clitkRelativePosition_GGO_C clitkRelativePosition.ggo) - ADD_EXECUTABLE(clitkRelativePosition clitkRelativePosition.cxx ${clitkRelativePosition_GGO_C}) - TARGET_LINK_LIBRARIES(clitkRelativePosition clitkCommon ${ITK_LIBRARIES}) - - WRAP_GGO(clitkTransformLandmarks_GGO_C clitkTransformLandmarks.ggo) - ADD_EXECUTABLE(clitkTransformLandmarks clitkTransformLandmarks.cxx ${clitkTransformLandmarks_GGO_C}) - TARGET_LINK_LIBRARIES(clitkTransformLandmarks clitkCommon ${ITK_LIBRARIES}) - - WRAP_GGO(clitkLineProfile_GGO_C clitkLineProfile.ggo) - ADD_EXECUTABLE(clitkLineProfile clitkLineProfile.cxx clitkLineProfileGenericFilter.cxx ${clitkLineProfile_GGO_C}) - TARGET_LINK_LIBRARIES(clitkLineProfile clitkCommon ${ITK_LIBRARIES}) + WRAP_GGO(clitkBinaryImageToMesh_GGO_C clitkBinaryImageToMesh.ggo) + ADD_EXECUTABLE(clitkBinaryImageToMesh clitkBinaryImageToMesh.cxx ${clitkBinaryImageToMesh_GGO_C}) + TARGET_LINK_LIBRARIES(clitkBinaryImageToMesh ${ITK_LIBRARIES} vtkCommon vtkRendering) + + ADD_EXECUTABLE(clitkMeshViewer clitkMeshViewer.cxx) + TARGET_LINK_LIBRARIES(clitkMeshViewer vtkCommon vtkRendering) + ENDIF(CLITK_EXPERIMENTAL) ENDIF(CLITK_BUILD_TOOLS) diff --git a/tools/clitkBinaryImageToMesh.cxx b/tools/clitkBinaryImageToMesh.cxx new file mode 100644 index 0000000..463fa45 --- /dev/null +++ b/tools/clitkBinaryImageToMesh.cxx @@ -0,0 +1,122 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================*/ +#include "clitkBinaryImageToMesh_ggo.h" +#include "clitkImageToImageGenericFilter.h" + +#include "vtkMetaImageReader.h" +#include "vtkContourFilter.h" +#include "vtkDecimatePro.h" +#include "vtkPolyDataMapper.h" +#include "vtkRenderer.h" +#include "vtkRenderWindow.h" +#include "vtkActor.h" +#include "vtkCamera.h" +#include "vtkOBJExporter.h" +#include "vtkRenderWindowInteractor.h" +#include "vtkSmartPointer.h" + +#include "itksys/SystemTools.hxx" + +void run(const args_info_clitkBinaryImageToMesh& argsInfo); + +int main(int argc, char** argv) +{ + GGO(clitkBinaryImageToMesh, args_info); + + run(args_info); + + return EXIT_SUCCESS; +} + +void run(const args_info_clitkBinaryImageToMesh& argsInfo) +{ + std::string file = argsInfo.input_arg; + + vtkSmartPointer pbmp_reader = vtkMetaImageReader::New(); + pbmp_reader->SetFileName(file.c_str()); + pbmp_reader->Update(); + + printf("Filtering...\n"); + vtkSmartPointer pcontour = vtkContourFilter::New(); + pcontour->SetValue(0, 0.5); + pcontour->SetInputConnection(pbmp_reader->GetOutputPort()); + + vtkSmartPointer psurface = vtkDecimatePro::New(); + psurface->SetInputConnection(pcontour->GetOutputPort()); + + vtkSmartPointer skinMapper = vtkPolyDataMapper::New(); + skinMapper->SetInputConnection(psurface->GetOutputPort()); + skinMapper->ScalarVisibilityOff(); + + vtkSmartPointer skin = vtkActor::New(); + skin->SetMapper(skinMapper); + + vtkSmartPointer aCamera = vtkCamera::New(); + aCamera->SetViewUp (0, 0, -1); + aCamera->SetPosition (0, 1, 0); + aCamera->SetFocalPoint (0, 0, 0); + aCamera->ComputeViewPlaneNormal(); + aCamera->Dolly(1.5); + + vtkSmartPointer aRenderer = vtkRenderer::New(); + aRenderer->AddActor(skin); + aRenderer->SetActiveCamera(aCamera); + aRenderer->ResetCamera (); + aRenderer->SetBackground(0,0,0); + aRenderer->ResetCameraClippingRange (); + + vtkSmartPointer renWin = vtkRenderWindow::New(); + renWin->AddRenderer(aRenderer); + renWin->SetSize(640, 480); + + vtkSmartPointer pwriter2 = vtkOBJExporter::New(); + pwriter2->SetRenderWindow(renWin); + + std::string output; + if (argsInfo.output_given) { + output = argsInfo.output_arg; + if (itksys::SystemTools::FileIsDirectory(output.c_str())) { + file = itksys::SystemTools::GetFilenameName(file.c_str()); + file = itksys::SystemTools::GetFilenameWithoutExtension(file.c_str()); + file = itksys::SystemTools::CollapseFullPath(file.c_str(), output.c_str()); + } + else { + file = output; + } + } + else { + file = itksys::SystemTools::GetFilenameWithoutExtension(file); + } + pwriter2->SetFilePrefix(file.c_str()); + pwriter2->Write(); + + vtkSmartPointer iren = vtkRenderWindowInteractor::New(); + iren->SetRenderWindow(renWin); + + skinMapper->Update(); + bool interact = argsInfo.view_flag; + if (interact) + { + iren->Initialize(); + iren->Start(); + } + else + renWin->Render(); +} + + diff --git a/tools/clitkBinaryImageToMesh.ggo b/tools/clitkBinaryImageToMesh.ggo new file mode 100644 index 0000000..d04462d --- /dev/null +++ b/tools/clitkBinaryImageToMesh.ggo @@ -0,0 +1,11 @@ +#File clitkBinaryImageToMesh.ggo +package "clitkBinaryImageToMesh" +version "1.0" +purpose "Get the HU profile along the given line. Output to stdout." + +option "config" - "Config file" string no +option "verbose" v "Verbose" flag off + +option "input" i "Input image" string yes +option "output" o "Output mesh file prefix (if empty, use input file's base name as prefix; if a directoy, output to it using input file's base name as prefix; otherwise, use given name as prefix" string no +option "view" - "View result" flag off diff --git a/tools/clitkMeshViewer.cxx b/tools/clitkMeshViewer.cxx new file mode 100644 index 0000000..a56275a --- /dev/null +++ b/tools/clitkMeshViewer.cxx @@ -0,0 +1,313 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================*/ + +#include "vtkOBJReader.h" +#include "vtkPolyDataMapper.h" +#include "vtkRenderer.h" +#include "vtkRenderWindow.h" +#include "vtkActor.h" +#include "vtkCamera.h" +#include "vtkRenderWindowInteractor.h" +#include "vtkSmartPointer.h" +#include "vtkCommand.h" +#include "vtkAnimationCue.h" +#include "vtkAnimationScene.h" +#include "vtkProperty.h" +#include "vtkInteractorStyle.h" + +#include +#include +#include + +typedef vtkSmartPointer ObjReaderType; +typedef vtkSmartPointer MapperType; +typedef vtkSmartPointer ActorType; + + +void run(int argc, char** argv); + +// Adapted from vtkAnimationCue example... +class CueAnimator +{ +public: + CueAnimator(std::vector& rActors) : m_Fps(1), m_LastTick(0), m_CurrentActor(0), m_rActors(rActors) { + } + + ~CueAnimator() { + } + + void SetFps(double fps) { + m_Fps = fps; + } + + void StartCue(vtkAnimationCue::AnimationCueInfo *vtkNotUsed(info), + vtkRenderer *ren) + { + std::cout << "StartCue" << std::endl; + m_LastTick = 0; + m_rActors[0]->SetVisibility(1); + + for (unsigned int i = 1; i < m_rActors.size(); i++) { + m_rActors[i]->SetVisibility(0); + } + + } + + void Tick(vtkAnimationCue::AnimationCueInfo *info, + vtkRenderer *ren) + { + std::cout << "Tick AT:" << info->AnimationTime << " DT:" << info->DeltaTime << " CT:" << info->ClockTime << std::endl; + if (info->AnimationTime - m_LastTick < 1/m_Fps) + return; + + m_LastTick = info->AnimationTime; + + m_rActors[m_CurrentActor]->SetVisibility(0); + + ++m_CurrentActor; + m_CurrentActor %= m_rActors.size(); + + m_rActors[m_CurrentActor]->SetVisibility(1); + + ren->Render(); + } + + void EndCue(vtkAnimationCue::AnimationCueInfo *vtkNotUsed(info), + vtkRenderer *ren) + { + std::cout << "EndCue" << std::endl; + } + +protected: + + double m_Fps; + double m_LastTick; + int m_CurrentActor; + std::vector& m_rActors; +}; + +class vtkAnimationCueObserver : public vtkCommand +{ +public: + static vtkAnimationCueObserver *New() + { + return new vtkAnimationCueObserver; + } + + virtual void Execute(vtkObject *vtkNotUsed(caller), + unsigned long event, + void *calldata) + { + if(this->Animator!=0 && this->Renderer!=0) + { + vtkAnimationCue::AnimationCueInfo *info= + static_cast(calldata); + switch(event) + { + case vtkCommand::StartAnimationCueEvent: + this->Animator->StartCue(info,this->Renderer); + break; + case vtkCommand::EndAnimationCueEvent: + this->Animator->EndCue(info,this->Renderer); + break; + case vtkCommand::AnimationCueTickEvent: + this->Animator->Tick(info,this->Renderer); + break; + } + } + if(this->RenWin!=0) + { + this->RenWin->Render(); + } + } + + vtkRenderer *Renderer; + vtkRenderWindow *RenWin; + CueAnimator *Animator; + +protected: + vtkAnimationCueObserver() + { + this->Renderer=0; + this->Animator=0; + this->RenWin=0; + } +}; + +class vtkWindowObserver : public vtkCommand +{ +public: + static vtkWindowObserver *New() + { + return new vtkWindowObserver; + } + + virtual void Execute(vtkObject *caller, + unsigned long event, + void *calldata) + { + vtkRenderWindowInteractor *isi = dynamic_cast(caller); + std::cout << "Execute" << std::endl; + switch (event) + { + case vtkCommand::KeyPressEvent: + { + std::string key = isi->GetKeySym(); + std::cout << key[0] << std::endl; + switch (key[0]) + { + case 'P': + case 'p': + if (this->m_Scene) + this->m_Scene->Play(); + break; + + case 'M': + case 'm': + if (this->m_Scene) + this->m_Scene->Stop(); + break; + + default: + break; + } + } + + default: + break; + + } + + } + + vtkAnimationScene* m_Scene; + + protected: + + vtkWindowObserver() : m_Scene(0) {} +}; + +int main(int argc, char** argv) +{ + if (argc == 0) + std::cout << "Usage: clitkMeshViewer FILE1 FILE2 ..." << std::endl; + + run(argc, argv); + + return EXIT_SUCCESS; +} + +void run(int argc, char** argv) +{ + std::vector objs; + std::vector mappers; + std::vector actors; + + int nfiles = argc; + std::string animate = argv[argc-1]; + if (animate == "--animate") + nfiles = argc-1; + + vtkSmartPointer aRenderer = vtkRenderer::New(); + for (int i = 1; i < nfiles; i++) { + std::string file = argv[i]; + + std::cout << "Reading " << file << std::endl; + + vtkSmartPointer preader = vtkOBJReader::New(); + preader->SetFileName(file.c_str()); + preader->Update(); + objs.push_back(preader); + + vtkSmartPointer skinMapper = vtkPolyDataMapper::New(); + skinMapper->SetInputConnection(preader->GetOutputPort()); + skinMapper->ScalarVisibilityOff(); + mappers.push_back(skinMapper); + + vtkSmartPointer skin = vtkActor::New(); + skin->SetMapper(skinMapper); + actors.push_back(skin); + + aRenderer->AddActor(skin); + } + + vtkSmartPointer aCamera = vtkCamera::New(); + aCamera->SetViewUp (0, 0, -1); + aCamera->SetPosition (0, 1, 0); + aCamera->SetFocalPoint (0, 0, 0); + aCamera->ComputeViewPlaneNormal(); + aCamera->Dolly(1.5); + + aRenderer->SetActiveCamera(aCamera); + aRenderer->ResetCamera (); + aRenderer->SetBackground(0,0,0); + aRenderer->ResetCameraClippingRange (); + + vtkSmartPointer renWin = vtkRenderWindow::New(); + renWin->AddRenderer(aRenderer); + renWin->SetSize(640, 480); + + vtkSmartPointer iren = vtkRenderWindowInteractor::New(); + iren->SetRenderWindow(renWin); + iren->Initialize(); + + vtkSmartPointer scene; + vtkSmartPointer cue1; + vtkSmartPointer anim_observer; + vtkSmartPointer window_observer; + CueAnimator animator(actors); + + double fps = 5; + animator.SetFps(fps); + + if (animate == "--animate") { + // Create an Animation Scene + scene=vtkAnimationScene::New(); + scene->SetModeToRealTime(); + + scene->SetLoop(1); + scene->SetTimeModeToRelative(); + scene->SetStartTime(0); + scene->SetEndTime(actors.size()/fps); + + // Create an Animation Cue. + cue1=vtkAnimationCue::New(); + cue1->SetTimeModeToRelative(); + cue1->SetStartTime(0); + cue1->SetEndTime(actors.size()/fps); + scene->AddCue(cue1); + + // Create Cue anim_observer. + anim_observer=vtkAnimationCueObserver::New(); + anim_observer->Renderer=aRenderer; + anim_observer->Animator=&animator; + anim_observer->RenWin=renWin; + cue1->AddObserver(vtkCommand::StartAnimationCueEvent,anim_observer); + cue1->AddObserver(vtkCommand::EndAnimationCueEvent,anim_observer); + cue1->AddObserver(vtkCommand::AnimationCueTickEvent,anim_observer); + + window_observer = vtkWindowObserver::New(); + window_observer->m_Scene = scene; + iren->AddObserver(vtkCommand::KeyPressEvent, window_observer); + + } + + iren->Start(); +} + + -- 2.47.1