]> Creatis software - creaMaracasVisu.git/commitdiff
addition of file
authorJuan Prieto <Juan.Prieto@creatis.insa-lyon.fr>
Tue, 31 May 2011 19:00:50 +0000 (19:00 +0000)
committerJuan Prieto <Juan.Prieto@creatis.insa-lyon.fr>
Tue, 31 May 2011 19:00:50 +0000 (19:00 +0000)
appli/QtVTKViewer/CMakeLists.txt [new file with mode: 0644]
appli/QtVTKViewer/qtvtkviewer.cxx [new file with mode: 0644]
lib/Kernel/CMakeLists.txt [new file with mode: 0644]

diff --git a/appli/QtVTKViewer/CMakeLists.txt b/appli/QtVTKViewer/CMakeLists.txt
new file mode 100644 (file)
index 0000000..fb7198a
--- /dev/null
@@ -0,0 +1,68 @@
+#----------------------------------------------------------------------------
+# USER! : SET THE NAME OF YOUR EXECUTABLE
+# Replace 'MyExe' by the name you want to give your executable.
+# (a good policy is to give the executable the same name that the directory)
+
+#########################
+SET ( EXE_NAME   qtvtkviewer  )
+#########################
+
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# EXECUTABLE SOURCES (TO BE COMPILED)
+# EITHER LIST ALL .cxx, *.cpp, *.cc IN CURRENT DIR USING NEXT LINE:
+
+FILE(GLOB ${EXE_NAME}_SOURCES *.cxx *.cpp *.cc)
+
+# OR MANUALLY LIST YOUR FILES WITH NEXT COMMAND (WITHOUT EXTENSION)
+#  SET ( ${EXE_NAME}_SOURCES 
+#   
+#    )
+#----------------------------------------------------------------------------
+
+INCLUDE_DIRECTORIES (
+
+# USER! : Add here the directories holding th extra .h files you need
+# e.g.
+# ../../lib/<my_library_I_just_created>
+
+)
+
+#----------------------------------------------------------------------------
+# DEPENDENCIES (LIBRARIES TO LINK WITH)
+SET ( ${EXE_NAME}_LINK_LIBRARIES
+    GUIQtViewers    
+    GUIQtVolumeRenderer
+    KernelVolumeRenderer
+    KernelViewerWidgets
+    ${VTK_LIBRARIES}
+    ${QT_LIBRARIES}
+    QVTK
+  #    ${WXWIDGETS_LIBRARIES}
+  #    ${KWWidgets_LIBRARIES}
+  #    ${VTK_LIBRARIES}
+      ${ITK_LIBRARIES}
+  #    ${GDCM_LIBRARIES}
+  #    ${BOOST_LIBRARIES}
+  
+  # USER! : Add here those agmonst the various (?) PROJECT LIBRARIES
+  # you need for the current executable
+  # (If you created only one Library, don't forget it !...) 
+  
+  )
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# USER! : UNCOMMENT NEXT LINE IF YOU WANT A CONSOLE ON WINDOWS
+# NB : YOUR MAIN MUST BE ADAPTED ALSO
+#      SEE THE MACRO CREA_WXMAIN_WITH_CONSOLE IN creaWx.h
+#SET(${EXE_NAME}_CONSOLE TRUE)
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# CREATES AND INSTALLS THE EXE
+CREA_ADD_EXECUTABLE( ${EXE_NAME} )
+#----------------------------------------------------------------------------
+
+
diff --git a/appli/QtVTKViewer/qtvtkviewer.cxx b/appli/QtVTKViewer/qtvtkviewer.cxx
new file mode 100644 (file)
index 0000000..dcafe09
--- /dev/null
@@ -0,0 +1,149 @@
+
+//----------------------------------------------------------------------
+//             File:                   ann_sample.cpp
+//             Programmer:             Sunil Arya and David Mount
+//             Last modified:  03/04/98 (Release 0.1)
+//             Description:    Sample program for ANN
+//----------------------------------------------------------------------
+// Copyright (c) 1997-2005 University of Maryland and Sunil Arya and
+// David Mount.  All Rights Reserved.
+//
+// This software and related documentation is part of the Approximate
+// Nearest Neighbor Library (ANN).  This software is provided under
+// the provisions of the Lesser GNU Public License (LGPL).  See the
+// file ../ReadMe.txt for further information.
+//
+// The University of Maryland (U.M.) and the authors make no
+// representations about the suitability or fitness of this software for
+// any purpose.  It is provided "as is" without express or implied
+// warranty.
+//----------------------------------------------------------------------
+
+#include "qtvtkviewerwidget.h"
+#include <QMainWindow>
+#include <QApplication>
+
+#include "itktovtkimageimport.h"
+#include "itkImage.h"
+#include "itkRGBPixel.h"
+#include "itkImageFileReader.h"
+
+
+#include "itkvtkcolortransferfunction.h"
+
+
+#include "iostream"
+
+
+
+
+
+using namespace std;                                   // make std:: accessible
+
+
+int main(int argc, char **argv)
+{
+
+
+
+
+
+
+
+
+    if (argc < 2)
+      {
+        std::cout << "ERROR: data file name argument missing."
+                  << std::endl ;
+        return EXIT_FAILURE;
+      }
+
+    std::string inputFilename = argv[1];
+    //std::string inputFilename2 = argv[2];
+
+
+    typedef unsigned char PixelType;
+    typedef itk::RGBPixel< PixelType > RGBPixelType;
+    typedef itk::Image< RGBPixelType, 2 > RGBImageType;
+
+    typedef itk::ImageFileReader< RGBImageType > ImageReaderType ;
+    ImageReaderType::Pointer imageReader = ImageReaderType::New() ;
+    imageReader->SetFileName(inputFilename.c_str());
+    imageReader->Update();
+    RGBImageType::Pointer imagergb = imageReader->GetOutput();
+
+
+    typedef itk::ITKToVTKImageImport< RGBImageType > ITKToVTKRGBType;
+    ITKToVTKRGBType::Pointer itktovtkrgb = ITKToVTKRGBType::New();
+    itktovtkrgb->SetITKImage(imagergb);
+
+
+
+
+    typedef itk::Image< RGBPixelType, 3> RGBImage3DType;
+    RGBImage3DType::Pointer image = RGBImage3DType::New();
+    RGBImage3DType::RegionType region;
+    region.SetSize(0, 256);
+    region.SetSize(1, 256);
+    region.SetSize(2, 256);
+    region.SetIndex(0,0);
+    region.SetIndex(1,0);
+    region.SetIndex(2,0);
+
+    image->SetRegions(region);
+    image->Allocate();
+
+    typedef itk::ITKToVTKImageImport< RGBImage3DType > ITKToVTKType;
+    ITKToVTKType::Pointer itktovtk = ITKToVTKType::New();
+    itktovtk->SetITKImage(image);
+
+
+    typedef itk::Image< unsigned char, 2 > LuminanceImageType;
+    typedef itk::RGBToLuminanceImageFilter< RGBImageType, LuminanceImageType> RGBToLumType;
+    RGBToLumType::Pointer rgbtolum = RGBToLumType::New();
+    rgbtolum->SetInput(imagergb);
+    rgbtolum->Update();
+    LuminanceImageType::Pointer lumimage =  rgbtolum->GetOutput();
+
+
+    typedef itk::ITKToVTKImageImport< LuminanceImageType > ITKToVTKLuminanceType;
+    ITKToVTKLuminanceType::Pointer itktovtklum = ITKToVTKLuminanceType::New();
+    itktovtklum->SetITKImage(lumimage);
+
+
+    vtkImageData* vtkimage =itktovtklum->GetOutputVTKImage();
+
+
+
+    typedef itk::VTKColorTransferFunction< RGBImageType > VTKColorTransferType;
+    VTKColorTransferType::Pointer vtkcolortransfer = VTKColorTransferType::New();
+
+    vtkcolortransfer->SetInput(imagergb);
+    vtkcolortransfer->Update();
+    vtkColorTransferFunction* colortransfer = vtkcolortransfer->GetOutput();
+
+    QApplication app(argc, argv);
+
+
+    QMainWindow* mainwindow = new QMainWindow();
+
+    QtVTKViewerWidget *viewer = new QtVTKViewerWidget(mainwindow);
+
+    mainwindow-> setCentralWidget(viewer);
+
+
+    mainwindow->show();
+
+    viewer->setImage(vtkimage);
+    viewer->SetLookupTable((vtkLookupTable*)colortransfer);
+    int scalnum = vtkimage->GetNumberOfScalarComponents();
+
+    cout<<scalnum<<endl;
+
+
+
+
+
+    return app.exec();
+}
+
diff --git a/lib/Kernel/CMakeLists.txt b/lib/Kernel/CMakeLists.txt
new file mode 100644 (file)
index 0000000..138ea98
--- /dev/null
@@ -0,0 +1,4 @@
+# Add a ADD_SUBDIRECTORY command for each of your libraries
+ADD_SUBDIRECTORY(ITKVTK)
+ADD_SUBDIRECTORY(VTKObjects)
\ No newline at end of file