]> Creatis software - creaMaracasVisu.git/commitdiff
addition of image stencil to surface rendering
authorJuan Prieto <Juan.Prieto@creatis.insa-lyon.fr>
Fri, 11 May 2012 11:46:36 +0000 (11:46 +0000)
committerJuan Prieto <Juan.Prieto@creatis.insa-lyon.fr>
Fri, 11 May 2012 11:46:36 +0000 (11:46 +0000)
25 files changed:
CMakeLists.txt
appli/QtVTKViewer/qtvtkviewer.cxx
lib/GUI/Base/SurfaceRenderer/wxMaracasSurfaceRenderingManager.cxx
lib/GUI/Base/SurfaceRenderer/wxMaracasSurfaceRenderingManager.h
lib/GUI/Qt/SurfaceRenderer/qtsurfacerenderer.cxx
lib/GUI/Qt/SurfaceRenderer/qtsurfacerenderer.h
lib/GUI/Qt/SurfaceRenderer/qtsurfacerendererpanel.cxx
lib/GUI/Qt/SurfaceRenderer/qtsurfacerendererpanel.h
lib/GUI/Qt/SurfaceRenderer/qtsurfacerendererpanel.ui
lib/GUI/Qt/Viewers/CMakeLists.txt
lib/GUI/Qt/Viewers/qtvtkviewer.cpp
lib/GUI/Qt/Viewers/qtvtkviewerwidget.cxx
lib/GUI/Qt/Viewers/qtvtkviewerwidget.ui
lib/GUI/Qt/VolumeRenderer/qtvolumerendererpanel.cxx
lib/GUI/Wx/SurfaceRenderer/wxMaracasSurfaceRendering.cxx
lib/Kernel/VTKObjects/SurfaceRenderer/surfacerenderingimagestencilexport.cxx [new file with mode: 0644]
lib/Kernel/VTKObjects/SurfaceRenderer/surfacerenderingimagestencilexport.h [new file with mode: 0644]
lib/Kernel/VTKObjects/SurfaceRenderer/wxMaracasSurfaceRenderingManagerData.cxx
lib/Kernel/VTKObjects/SurfaceRenderer/wxMaracasSurfaceRenderingManagerData.h
lib/Kernel/VTKObjects/SurfaceRenderer/wxMaracasSurfaceRenderingManagerDataMhd.cxx
lib/Kernel/VTKObjects/SurfaceRenderer/wxMaracasSurfaceRenderingManagerDataMhd.h
lib/Kernel/VTKObjects/VolumeRenderer/volumerenderermanagerdata.cxx
lib/maracasVisuLib/CMakeLists.txt
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h

index 3f2f6cfa66b7a6d6c6b7acebca83197afe3f1e7a..e1df889b9955a07bf11cf1d8e230d091ce32b3f1 100644 (file)
@@ -102,7 +102,8 @@ INCLUDE_DIRECTORIES(
 
 
 #JCP Ubuntu this file not found glibconfig.h, config of wxgtk goes wrong somewhere
-INCLUDE_DIRECTORIES(/usr/lib/x86_64-linux-gnu/glib-2.0/include/)
+INCLUDE_DIRECTORIES(/usr/lib/x86_64-linux-gnu/gtk-2.0/include/)
+LINK_DIRECTORIES(/usr/lib/x86_64-linux-gnu/)
 #JCP Ubuntu this file not found glibconfig.h, config of wxgtk goes wrong somewhere
 
 ADD_SUBDIRECTORY(install)
index fb6abc8a840bd3c3e03f8906a6cf0d9724130314..63becde95e41f8160319da3219f291f7b7ce8a61 100644 (file)
@@ -61,9 +61,9 @@ int main(int argc, char **argv)
     QtVTKViewerWidget *viewer = new QtVTKViewerWidget(mainwindow);
 
     mainwindow-> setCentralWidget(viewer);
+    mainwindow->setMinimumSize(1024, 768);
 
-
-    mainwindow->show();
+    mainwindow->showMaximized();
 
     if(img)
         viewer->setImage(img);
index ac816f6241cfcf4f38b6a1d7198f8422a9b01877..d60ea625517b2252843e78d2e709c3a4c22ae205 100644 (file)
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: wxMaracasSurfaceRenderingManager.cxx,v $
   Language:  C++
-  Date:      $Date: 2011/10/05 16:26:55 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2012/05/11 11:46:37 $
+  Version:   $Revision: 1.3 $
 
   Copyright: (c) 2002, 2003
   License:
      PURPOSE.  See the above copyright notice for more information.
 
 =========================================================================*/
+
 #include "wxMaracasSurfaceRenderingManager.h"
 #include "wxMaracasSurfaceRenderingManagerDataMhd.h"
 
-
-#include "vtkPLYReader.h"
-#include "vtkSmartPointer.h"
-
 /**
 **     Start of the manager class
 **/
@@ -28,6 +25,7 @@ wxMaracasSurfaceRenderingManager::wxMaracasSurfaceRenderingManager(){
        _renderer = NULL;
        _interactor = NULL;
        _idCount=0;
+        image = 0;
 }
 wxMaracasSurfaceRenderingManager::~wxMaracasSurfaceRenderingManager(){
 }
@@ -87,6 +85,35 @@ int wxMaracasSurfaceRenderingManager::addProp3D(int idTP, vtkProp3D* prop3D, std
        }
        return -1;
 }
+
+/**
+**     Adds a polydata and creates the prop3D (actor) to the manager and returns the identifier
+**/
+/**
+**     Adds a polydata and creates the prop3D (actor) to the manager and returns the identifier
+**/
+int wxMaracasSurfaceRenderingManager::addProp3D(int idTP, std::string filename, std::string dataname){
+
+
+    wxMaracasSurfaceRenderingManagerData* data = new wxMaracasSurfaceRenderingManagerData(filename, _interactor);
+    if(dataname.compare("") != 0)
+        data->setDataname(dataname);
+
+    prop3Dvect.push_back(data);
+    _renderer->AddActor(data->getProp3D());
+    if(idTP == -1)
+    {
+            data->setId(_idCount);
+            _idCount++;
+    }
+    else
+    {
+            data->setId(idTP);
+    }
+    return data->getId();
+
+}
+
 int wxMaracasSurfaceRenderingManager::addPropMHD(int idTP, vtkImageData* imagedata, std::string dataname) throw(char*){
        checkInvariant();
        if(imagedata != NULL){                
@@ -113,7 +140,7 @@ int wxMaracasSurfaceRenderingManager::addPropMHD(int idTP, vtkImageData* imageda
 /**
 **     adds or removes an actor depending of the bool value
 **/
-void wxMaracasSurfaceRenderingManager::addRemoveActor(int propid, bool addremove)  throw(char*){
+bool wxMaracasSurfaceRenderingManager::addRemoveActor(int propid, bool addremove)  throw(char*){
        checkInvariant();
        
         wxMaracasSurfaceRenderingManagerData* data = this->getViewData(propid);
@@ -124,12 +151,14 @@ void wxMaracasSurfaceRenderingManager::addRemoveActor(int propid, bool addremove
                        _renderer->RemoveViewProp(data->getProp3D());
                }
                _renderer->Render();
+                return true;
         }else {
             if(addremove && propid == 0 && image){
                 addPropMHD(0, image, "id0");
+                return true;
             }
-            return;
         }
+        return false;
 }
 /**
 **     adds or removes the surface box depending of the bool value
@@ -194,7 +223,7 @@ void wxMaracasSurfaceRenderingManager::changeIsoValue(int propid, double min, do
         _renderer->Render();
 }
 
-vtkProp3D* wxMaracasSurfaceRenderingManager:: getProp3D(std::string filename){
+/*vtkProp3D* wxMaracasSurfaceRenderingManager:: getProp3D(std::string filename){
        if(filename.compare("")!= 0){
 
             vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();
@@ -210,6 +239,11 @@ vtkProp3D* wxMaracasSurfaceRenderingManager:: getProp3D(std::string filename){
                 plyreader->SetFileName(filename.c_str());
                 plyreader->Update();
                 polydata->DeepCopy(plyreader->GetOutput());
+            }else if(ext.compare(VTK)==0){
+                vtkSmartPointer<vtkPolyDataReader> polyreader =vtkSmartPointer<vtkPolyDataReader>::New();
+                polyreader->SetFileName(filename.c_str());
+                polyreader->Update();
+                polydata->DeepCopy(polyreader->GetOutput());
             }
 
             vtkSmartPointer<vtkPolyDataMapper> dataMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
@@ -221,7 +255,7 @@ vtkProp3D* wxMaracasSurfaceRenderingManager:: getProp3D(std::string filename){
             return dataActor;
        }       
        return NULL;
-}
+}*/
 
 vtkImageData* wxMaracasSurfaceRenderingManager::getImageData(std::string filename){
        if(filename.compare("")!= 0){   
@@ -251,17 +285,16 @@ void wxMaracasSurfaceRenderingManager::checkInvariant()  throw(char*){
 }
 
 wxMaracasSurfaceRenderingManagerData* wxMaracasSurfaceRenderingManager::getViewData(int id) throw(char*){
-    int i;
+    int i = 0;
     for(i = 0; i < (int)(prop3Dvect.size());i++){
             if(prop3Dvect[i]->getId() == id){
                     return prop3Dvect[i];
             }
-    }
-    return 0;
+    }    
 #ifndef USE_QT
     throw "id not found in the data";
 #else
-    return NULL;
+    return 0;
 #endif
 
 
@@ -335,5 +368,14 @@ void wxMaracasSurfaceRenderingManager::saveProp3DSTL(int propid,const char* file
 }
 
 void wxMaracasSurfaceRenderingManager::loadProp3DSTL(const char* filename){
-    this->addProp3D(-1, this->getProp3D(filename), filename);
+    this->addProp3D(-1, filename);
+}
+
+void wxMaracasSurfaceRenderingManager::exportImageStencil(int propid,const char* filename){
+    checkInvariant();
+
+    wxMaracasSurfaceRenderingManagerData* data = this->getViewData(propid);
+    if(data && data->getProp3D()!=NULL){
+            data->exportImageStencil(filename);
+    }
 }
index 63427972a6c9e3709e1004675c94df63005c9814..abaaf4653b12caf7a5c22ea9c30fd7e1811da0ae 100644 (file)
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: wxMaracasSurfaceRenderingManager.h,v $
   Language:  C++
-  Date:      $Date: 2011/10/05 16:26:55 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2012/05/11 11:46:37 $
+  Version:   $Revision: 1.3 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -55,6 +55,12 @@ public:
        **      Adds a prop3D to the manager and returns the identifier
        **/
        int addProp3D(int idTP, vtkProp3D* prop3D, std::string dataname) throw (char*);
+
+        /**
+        **     Adds a polydata and creates the prop3D (actor) to the manager and returns the identifier
+        **/
+        int addProp3D(int idTP, std::string filename, std::string dataname = "");
+
        /**
        **      Adds a prop3D to the manager and returns the identifier
        **/
@@ -74,7 +80,7 @@ public:
        /**
        **      loads a prop3D from a nSTL file
        **/
-       vtkProp3D* getProp3D(std::string filename);
+        //vtkProp3D* getProp3D(std::string filename);
 
        /**
        **      loads a MHD file to convert it into an actor
@@ -91,7 +97,7 @@ public:
        /**
        **      adds or removes an actor depending of the bool value
        **/
-       void addRemoveActor(int propid, bool addremove)throw(char*);
+        bool addRemoveActor(int propid, bool addremove)throw(char*);
        /**
        **
        **/
@@ -137,6 +143,7 @@ public:
         void loadProp3DSTL(const char* filename);
 
 
+        void exportImageStencil(int propid,const char* filename);
        
 private:       
        std::vector<wxMaracasSurfaceRenderingManagerData*> prop3Dvect;
index 2907ce7184117886e89f4337100720ac0ecc4289..94de7618272ee121eb5bffd7885d608f1dca820f 100644 (file)
@@ -13,13 +13,25 @@ QtSurfaceRenderer::QtSurfaceRenderer(QWidget *parent) :
     this->ui->tabWidgetSurface->removeTab(1);
     this->ui->tabWidgetSurface->removeTab(0);
 
-
     QtSurfaceRendererPanel* surfacepanel = new QtSurfaceRendererPanel(this);
     this->ui->tabWidgetSurface->addTab(surfacepanel, QString("Surface Rendering"));
 
     Renderer = 0;
     Interactor = 0;
 }
+void QtSurfaceRenderer::SetRenderer(vtkRenderer* render){
+    Renderer = render;
+    this->ui->tabWidgetSurface->setCurrentIndex(0);
+    QtSurfaceRendererPanel* surfacepanel = (QtSurfaceRendererPanel*)this->ui->tabWidgetSurface->currentWidget();
+    surfacepanel->setRenderer(Renderer);
+}
+
+void QtSurfaceRenderer::SetInteractor(vtkRenderWindowInteractor* interactor){
+    Interactor = interactor;
+    this->ui->tabWidgetSurface->setCurrentIndex(0);
+    QtSurfaceRendererPanel* surfacepanel = (QtSurfaceRendererPanel*)this->ui->tabWidgetSurface->currentWidget();
+    surfacepanel->setInteractor(Interactor);
+}
 
 QtSurfaceRenderer::~QtSurfaceRenderer()
 {
@@ -28,9 +40,7 @@ QtSurfaceRenderer::~QtSurfaceRenderer()
 
 void QtSurfaceRenderer::SetImageData(vtkImageData* img){
     this->ui->tabWidgetSurface->setCurrentIndex(0);
-    QtSurfaceRendererPanel* surfacepanel = (QtSurfaceRendererPanel*)this->ui->tabWidgetSurface->currentWidget();    
-    surfacepanel->setInteractor(Interactor);
-    surfacepanel->setRenderer(Renderer);
+    QtSurfaceRendererPanel* surfacepanel = (QtSurfaceRendererPanel*)this->ui->tabWidgetSurface->currentWidget();
     surfacepanel->setImageData(img);
 }
 
index 6ffe36ea086689f8e138dbe150c5c69a632ea9f9..d4ad18ce11d1b302b89d0a168a514e1c4db97024 100644 (file)
@@ -17,8 +17,8 @@ public:
 
     ~QtSurfaceRenderer();
 
-    vtkSetMacro(Renderer, vtkRenderer*);
-    vtkSetMacro(Interactor, vtkRenderWindowInteractor*);
+    void SetRenderer(vtkRenderer* render);
+    void SetInteractor(vtkRenderWindowInteractor* interactor);
 
     void SetImageData(vtkImageData* img);
 private slots:
index b675aa60a52ecda699b47c195e6f0cbc8faf6437..0c431b4e68145b193d1f83ee56e03ff96ef815d2 100644 (file)
@@ -18,8 +18,13 @@ QtSurfaceRendererPanel::QtSurfaceRendererPanel(QWidget *parent) :
 
 
     this->ui->pushButtonColorChooser->setIcon(QIcon(Color_xpm));
-    this->ui->pushButtonSave->setIcon(QIcon(Save_xpm));
+    //this->ui->pushButtonSave->setIcon(QIcon(Save_xpm));
     this->ui->pushButtonOpen->setIcon(QIcon(OpenImage_xpm));
+
+    this->ui->comboBoxSave->addItem(QIcon(Save_xpm), QString(""));
+    this->ui->comboBoxSave->addItem(QString("Save surface"));
+    this->ui->comboBoxSave->addItem(QString("Export image stencil"));
+    _ImageSet = false;
 }
 
 QtSurfaceRendererPanel::~QtSurfaceRendererPanel()
@@ -34,6 +39,7 @@ void QtSurfaceRendererPanel::setImageData(vtkImageData* img){
     this->ui->horizontalSliderMaxIso->setRange(range[0], range[1]);
 
     wxMaracasSurfaceRenderingManager::setImageData(img);
+    _ImageSet = true;
 }
 
 void QtSurfaceRendererPanel::on_OpacitySlider_valueChanged(int value)
@@ -77,8 +83,9 @@ void QtSurfaceRendererPanel::on_pushButtonColorChooser_clicked()
 
 void QtSurfaceRendererPanel::on_checkBox_clicked(bool checked)
 {
-    this->addRemoveActor(0, checked);
-    if(!checked){
+    if(!this->addRemoveActor(0, checked)){
+        this->ui->checkBox->setChecked(false);
+    }else if(!checked){
         this->ui->checkBoxBoundingBox->setCheckState(Qt::Unchecked);
         this->on_checkBoxBoundingBox_clicked(false);
     }
@@ -106,22 +113,23 @@ void QtSurfaceRendererPanel::on_horizontalSliderMinIso_sliderReleased()
 }
 
 void QtSurfaceRendererPanel::onIsoValueChanged(){
-    this->changeIsoValue(0, this->ui->horizontalSliderMinIso->value(), this->ui->horizontalSliderMaxIso->value());
+    if(_ImageSet)
+        this->changeIsoValue(0, this->ui->horizontalSliderMinIso->value(), this->ui->horizontalSliderMaxIso->value());
 }
 
-void QtSurfaceRendererPanel::on_pushButtonSave_clicked()
+/*void QtSurfaceRendererPanel::on_pushButtonSave_clicked()
 {
     QString filename = QFileDialog::getSaveFileName(this,
                                                     tr("Save Mesh File"),
                                                     QDir::currentPath(),
-                                                    tr("Mesh files (*.stl *.ply)") );
+                                                    tr("Mesh files (*.stl *.ply *.vtk)") );
 
     if( !filename.isNull() ){
         //filename.append(".stl");
         this->saveProp3DSTL(0, filename.toStdString().c_str());
     }
 
-}
+}*/
 
 void QtSurfaceRendererPanel::on_checkBoxBoundingBox_clicked(bool checked)
 {
@@ -136,9 +144,37 @@ void QtSurfaceRendererPanel::on_pushButtonOpen_clicked(bool checked)
 
 void QtSurfaceRendererPanel::on_pushButtonOpen_clicked()
 {
-    QString filename = QFileDialog::getOpenFileName(this, tr("Load Mesh File"), QDir::currentPath(),  tr("Mesh files (*.stl *.ply)"));
+    QString filename = QFileDialog::getOpenFileName(this, tr("Load Mesh File"), QDir::currentPath(),  tr("Mesh files (*.stl *.ply *.vtk)"));
 
     if(!filename.isNull()){
         this->loadProp3DSTL(filename.toStdString().c_str());
+        this->ui->checkBox->setCheckState(Qt::Checked);
+    }
+}
+
+void QtSurfaceRendererPanel::on_comboBoxSave_activated(int index)
+{
+    if(index == 1){
+        QString filename = QFileDialog::getSaveFileName(this,
+                                                        tr("Save Mesh File"),
+                                                        QDir::currentPath(),
+                                                        tr("Mesh files (*.stl *.ply *.vtk)") );
+
+        if( !filename.isNull() ){
+            //filename.append(".stl");
+            this->saveProp3DSTL(0, filename.toStdString().c_str());
+        }
+    }else if(index == 2){
+
+        QString filename = QFileDialog::getSaveFileName(this,
+                                                        tr("Save Image File"),
+                                                        QDir::currentPath(),
+                                                        tr("Meta Image file (*.mhd)") );
+
+        if( !filename.isNull() ){
+
+            this->exportImageStencil(0, filename.toStdString().c_str());
+        }
     }
+    this->ui->comboBoxSave->setCurrentIndex(0);
 }
index d583d1103c53048b7ec31beacb67bab9f6bb601b..019c79d915587d9b5b310bc7eb67513a97b5ebe3 100644 (file)
@@ -35,7 +35,7 @@ private slots:
 
     void on_horizontalSliderMinIso_sliderReleased();
 
-    void on_pushButtonSave_clicked();
+    //void on_pushButtonSave_clicked();
 
     void on_checkBoxBoundingBox_clicked(bool checked);
 
@@ -44,11 +44,15 @@ private slots:
     void on_pushButtonOpen_clicked();
 
 
+    void on_comboBoxSave_activated(int index);
+
 private:
     Ui::QtSurfaceRendererPanel *ui;
 
 
     void onIsoValueChanged();
+
+    bool _ImageSet;
 };
 
 #endif // QTSURFACERENDERERPANEL_H
index 2af643ba709b5199f204e428e105c4d5d968dc01..2d64a86883c32abf9101009e6bf75648a1265c67 100644 (file)
@@ -6,15 +6,15 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>197</width>
-    <height>299</height>
+    <width>252</width>
+    <height>362</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>Form</string>
   </property>
   <layout class="QGridLayout" name="gridLayout_3">
-   <item row="0" column="0">
+   <item row="0" column="0" colspan="2">
     <widget class="QCheckBox" name="checkBox">
      <property name="text">
       <string>Show</string>
     </widget>
    </item>
    <item row="1" column="1">
-    <widget class="QPushButton" name="pushButtonSave">
+    <widget class="QComboBox" name="comboBoxSave">
      <property name="enabled">
       <bool>false</bool>
      </property>
-     <property name="text">
-      <string/>
+     <property name="toolTip">
+      <string>Save current surface or export an image using stencil</string>
      </property>
-     <property name="icon">
-      <iconset>
-       <normaloff>../../../../data/Icons/Save.xpm</normaloff>../../../../data/Icons/Save.xpm</iconset>
+     <property name="editable">
+      <bool>false</bool>
+     </property>
+     <property name="currentIndex">
+      <number>-1</number>
+     </property>
+     <property name="maxVisibleItems">
+      <number>2</number>
      </property>
     </widget>
    </item>
      <y>18</y>
     </hint>
     <hint type="destinationlabel">
-     <x>136</x>
-     <y>21</y>
+     <x>242</x>
+     <y>30</y>
     </hint>
    </hints>
   </connection>
   <connection>
    <sender>checkBox</sender>
    <signal>toggled(bool)</signal>
-   <receiver>pushButtonSave</receiver>
+   <receiver>OpacitySlider</receiver>
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>56</x>
-     <y>20</y>
+     <x>43</x>
+     <y>19</y>
     </hint>
     <hint type="destinationlabel">
-     <x>216</x>
-     <y>50</y>
+     <x>83</x>
+     <y>170</y>
     </hint>
    </hints>
   </connection>
   <connection>
    <sender>checkBox</sender>
    <signal>toggled(bool)</signal>
-   <receiver>OpacitySlider</receiver>
+   <receiver>horizontalSliderMinIso</receiver>
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>43</x>
-     <y>19</y>
+     <x>36</x>
+     <y>15</y>
     </hint>
     <hint type="destinationlabel">
-     <x>73</x>
-     <y>125</y>
+     <x>38</x>
+     <y>283</y>
     </hint>
    </hints>
   </connection>
   <connection>
    <sender>checkBox</sender>
    <signal>toggled(bool)</signal>
-   <receiver>horizontalSliderMinIso</receiver>
+   <receiver>horizontalSliderMaxIso</receiver>
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>36</x>
-     <y>15</y>
+     <x>42</x>
+     <y>22</y>
     </hint>
     <hint type="destinationlabel">
-     <x>28</x>
-     <y>367</y>
+     <x>102</x>
+     <y>351</y>
     </hint>
    </hints>
   </connection>
   <connection>
    <sender>checkBox</sender>
    <signal>toggled(bool)</signal>
-   <receiver>horizontalSliderMaxIso</receiver>
+   <receiver>comboBoxSave</receiver>
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>42</x>
-     <y>22</y>
+     <x>88</x>
+     <y>19</y>
     </hint>
     <hint type="destinationlabel">
-     <x>92</x>
-     <y>434</y>
+     <x>126</x>
+     <y>53</y>
     </hint>
    </hints>
   </connection>
index 37ab67d585e68a507aea2626ffe403d2d6e5f6bc..a03c68f2ccdd07a9299e899e17500d632e7e7c06 100644 (file)
@@ -89,9 +89,9 @@ IF ( BUILD_${LIBRARY_NAME} )
     ${QT_LIBRARIES}
     QVTK
 
-#EED    GUIQtVolumeRenderer
-#EED    GUIQtSurfaceRenderer
-#EED    KernelViewerWidgets
+    GUIQtVolumeRenderer
+    GUIQtSurfaceRenderer
+    KernelViewerWidgets
 
   # If this library must link against other libraries 
   # USER! : Add here any extra Library you need
index d4c0685c25f922ab1d882a13a0953e371a671a64..9320d60026ef2896531e2e759033734055a1eb4a 100644 (file)
@@ -7,7 +7,8 @@ QtVTKViewer::QtVTKViewer(QWidget* parent)
 {
 
 
-    this->GetRenderWindow()->AddRenderer(vtkRenderer::New());
+    vtkRenderer* renderer = vtkRenderer::New();
+    this->GetRenderWindow()->AddRenderer(renderer);
     this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->SetBackground(1,1,1);
 
     SuperImagePlaneWidget::initialize(this->GetRenderWindow()->GetInteractor());
index 7229daa1dac9ceb50c47be70ca5cb7542ce7443c..1f10cdf2d40ec9753beae8e6d31130326b595b11 100644 (file)
@@ -29,6 +29,7 @@ vtkRenderer* QtVTKViewerWidget::getRenderer(){
 void QtVTKViewerWidget::setImage(vtkImageData* img){
 
 
+    ui->checkBoxShowPlanes->setChecked(true);
     ui->_qtvtkviewer->setImage(img);
     ui->m_VolumeRender->SetImageData(img);
     ui->m_SurfaceRender->SetImageData(img);
index d7d8ae42207ed5964bbfb52deb96c05a9ee22f3c..6c5eeb9eab2e15ab3b8d6062137305e5243c3fc3 100644 (file)
       <attribute name="label">
        <string>Image Widget</string>
       </attribute>
-      <widget class="QWidget" name="">
+      <widget class="QWidget" name="layoutWidget">
        <property name="geometry">
         <rect>
          <x>0</x>
          <y>20</y>
          <width>201</width>
-         <height>246</height>
+         <height>260</height>
         </rect>
        </property>
        <layout class="QVBoxLayout" name="verticalLayout">
@@ -56,7 +56,7 @@
            <string>Show Planes</string>
           </property>
           <property name="checked">
-           <bool>true</bool>
+           <bool>false</bool>
           </property>
           <property name="tristate">
            <bool>false</bool>
        <verstretch>0</verstretch>
       </sizepolicy>
      </property>
-     <zorder>toolBox</zorder>
-     <zorder>toolBox</zorder>
-     <zorder>toolBox</zorder>
     </widget>
    </item>
   </layout>
index 779621ca178337e664a4aa1c8d7ce2f2c05920e5..ea511546d50fbc141ba76dcf4c498bb56d8439e1 100644 (file)
@@ -39,11 +39,15 @@ void QtVolumeRendererPanel::on_opacitySlider_valueChanged(int value)
 
         double* range = ImageData->GetScalarRange();
         vector<double> greylevel;
-        greylevel.push_back(0);        
-        greylevel.push_back(1);
+        greylevel.push_back(0);  //first grey level
+        //greylevel.push_back(1);
+        greylevel.push_back(10);
+        greylevel.push_back(20);
         greylevel.push_back(range[1]);
 
         vector<double> vectvalue;
+        vectvalue.push_back(0);  //first opacity value
+        //vectvalue.push_back(value/100.0);
         vectvalue.push_back(0);
         vectvalue.push_back(value/100.0);
         vectvalue.push_back(value/100.0);
index 429734e728feddc098ee95a93f648b67777bb183..2c1c56c3b7895c365e67fa2cd951af57f5f366c0 100644 (file)
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: wxMaracasSurfaceRendering.cxx,v $
   Language:  C++
-  Date:      $Date: 2011/06/28 16:56:16 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2012/05/11 11:46:39 $
+  Version:   $Revision: 1.2 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -196,14 +196,22 @@ void wxMaracasSurfaceRendering::addPropMHD(vtkImageData* imgdata, std::string da
 }
 
 void wxMaracasSurfaceRendering::loadProp3D(wxString filename, wxString dataname){
-       std::string s = std::string(filename.mb_str());
-       vtkProp3D* prop3D = surrendmanager->getProp3D(s);
+        std::string fn = std::string(filename.mb_str());
+        std::string dn = std::string(dataname.mb_str());
+
+        int id = surrendmanager->addProp3D(-1, fn, dn);
+
+        if(id!=-1){
+                wxMaracasSurfaceRenderingPanel* controlpan = new wxMaracasSurfaceRenderingProp3D(this, id, false, -1);
+                addSurfaceRenderingPanel(controlpan, dn);
+        }
+        /*vtkProp3D* prop3D = surrendmanager->getProp3D(s);
        if(prop3D != NULL){
                s = std::string(dataname.mb_str() );
                this->addProp3D(prop3D,s);
        }else{
                //TODO msj to the user indicating error in file
-       }
+        }*/
 }
 
 void wxMaracasSurfaceRendering::addProp3D(vtkProp3D* prop3D, std::string dataname){
diff --git a/lib/Kernel/VTKObjects/SurfaceRenderer/surfacerenderingimagestencilexport.cxx b/lib/Kernel/VTKObjects/SurfaceRenderer/surfacerenderingimagestencilexport.cxx
new file mode 100644 (file)
index 0000000..ec92d05
--- /dev/null
@@ -0,0 +1,70 @@
+#include "surfacerenderingimagestencilexport.h"
+
+#include "vtkObjectFactory.h"
+#include "vtkMetaImageWriter.h"
+
+#include "math.h"
+
+vtkStandardNewMacro(SurfaceRenderingImageStencilExport)
+
+SurfaceRenderingImageStencilExport::SurfaceRenderingImageStencilExport()
+{    
+    ImageOutput = 0;
+}
+
+SurfaceRenderingImageStencilExport::~SurfaceRenderingImageStencilExport(){
+
+    if(ImageOutput){
+        ImageOutput->Delete();
+    }
+}
+
+void SurfaceRenderingImageStencilExport::Update(){
+    this->Execute(0);
+}
+
+void SurfaceRenderingImageStencilExport::Execute(vtkImageData *data){
+
+    vtkPolyData* polydata = (vtkPolyData*)this->GetInput();
+
+    vtkSmartPointer<vtkPolyDataToImageStencil> polytostencil = vtkSmartPointer<vtkPolyDataToImageStencil>::New();
+    polytostencil->SetInput(polydata);
+    polytostencil->Update();
+
+    double *bounds = polydata->GetBounds();
+    vtkSmartPointer<vtkImageData> imagein = vtkSmartPointer<vtkImageData>::New();
+
+    imagein->SetExtent(bounds[0] - 1, bounds[1] + 1, bounds[2] - 1, bounds[3] + 1, bounds[4] - 1, bounds[5] + 1);
+    imagein->SetScalarTypeToUnsignedShort();    
+    imagein->AllocateScalars();
+
+
+    int* extent = imagein->GetExtent();
+
+    for (int x = extent[0]; x <= extent[1]; x++){
+        for (int y = extent[2]; y <= extent[3]; y++){
+            for (int z  =extent[4]; z <= extent[5]; z++){
+                unsigned short* pixel = static_cast<unsigned short*>(imagein->GetScalarPointer(x,y,z));
+                *pixel = 0;
+            }
+        }
+    }
+
+    vtkSmartPointer<vtkImageStencil> stencil = vtkSmartPointer<vtkImageStencil>::New();
+    stencil->SetInput(imagein);
+    stencil->SetStencil(polytostencil->GetOutput());
+    stencil->ReverseStencilOn();
+    stencil->SetBackgroundValue(128);
+    stencil->Update();
+
+    if(ImageOutput){
+        ImageOutput->Delete();
+    }
+    ImageOutput = vtkImageData::New();
+    ImageOutput->DeepCopy(stencil->GetOutput());
+
+}
+
+vtkImageData* SurfaceRenderingImageStencilExport::GetOutput(){
+    return ImageOutput;
+}
diff --git a/lib/Kernel/VTKObjects/SurfaceRenderer/surfacerenderingimagestencilexport.h b/lib/Kernel/VTKObjects/SurfaceRenderer/surfacerenderingimagestencilexport.h
new file mode 100644 (file)
index 0000000..fc63b39
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef SURFACERENDERINGIMAGESTENCILEXPORT_H
+#define SURFACERENDERINGIMAGESTENCILEXPORT_H
+
+#include <vtkDataSetToImageFilter.h>
+#include <vtkSmartPointer.h>
+#include <vtkPolyDataToImageStencil.h>
+#include <vtkImageStencil.h>
+#include <vtkImageData.h>
+#include <vtkPolyData.h>
+
+class SurfaceRenderingImageStencilExport : public vtkDataSetToImageFilter
+{
+public:
+    static SurfaceRenderingImageStencilExport *New();
+
+    vtkTypeMacro(SurfaceRenderingImageStencilExport,vtkDataSetToImageFilter)
+
+    virtual void Update();
+    vtkImageData* GetOutput();
+protected:
+
+    virtual void Execute(vtkImageData *data);
+
+private:
+
+    SurfaceRenderingImageStencilExport();
+    ~SurfaceRenderingImageStencilExport();
+
+    vtkImageData* ImageOutput;
+};
+
+#endif // SURFACERENDERINGIMAGESTENCILEXPORT_H
index 510ec5c53b3ddb681a14a2664e0f5c8c8304205d..1faca334ff3ff0f0de4c59db40e4a7caa5633f59 100644 (file)
@@ -4,6 +4,12 @@
 #include <vtkSmartPointer.h>
 #include "vtkSTLWriter.h"
 #include "vtkPLYWriter.h"
+#include "vtkPolyDataWriter.h"
+#include "surfacerenderingimagestencilexport.h"
+#include "vtkMetaImageWriter.h"
+#include "vtkPolyDataReader.h"
+#include "vtkPLYReader.h"
+#include "vtkSmartPointer.h"
 
 /********************************************************************************************
 ** Start of data viewmanagerData
@@ -27,6 +33,49 @@ wxMaracasSurfaceRenderingManagerData::wxMaracasSurfaceRenderingManagerData(vtkPr
        _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(3) );*/
 }
 
+wxMaracasSurfaceRenderingManagerData::wxMaracasSurfaceRenderingManagerData(string filename, vtkRenderWindowInteractor*  interactor){
+
+    _prop3D = getProp3D(filename);
+    _dataname = filename;
+    _boxWidgetS1=NULL;
+
+    initializeBoxWidget(interactor);
+}
+
+vtkProp3D* wxMaracasSurfaceRenderingManagerData::getProp3D(std::string filename){
+
+    if(filename.compare("")!= 0){
+
+        vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();
+        std::string ext = filename.substr(filename.find_last_of("."), 4);
+        if(ext.compare(STL)==0){
+            vtkSmartPointer<vtkSTLReader> STLReader=vtkSmartPointer<vtkSTLReader>::New();
+            STLReader->SetFileName(filename.c_str());
+            STLReader->Update();
+            polydata->DeepCopy(STLReader->GetOutput());
+
+        }else if(ext.compare(PLY)==0){
+            vtkSmartPointer<vtkPLYReader> plyreader =vtkSmartPointer<vtkPLYReader>::New();
+            plyreader->SetFileName(filename.c_str());
+            plyreader->Update();
+            polydata->DeepCopy(plyreader->GetOutput());
+        }else if(ext.compare(VTK)==0){
+            vtkSmartPointer<vtkPolyDataReader> polyreader =vtkSmartPointer<vtkPolyDataReader>::New();
+            polyreader->SetFileName(filename.c_str());
+            polyreader->Update();
+            polydata->DeepCopy(polyreader->GetOutput());
+        }
+
+        _dataMapper = vtkPolyDataMapper::New();
+        _dataMapper->SetInput(polydata);
+
+        vtkActor* dataActor = vtkActor::New();
+        dataActor->SetMapper(_dataMapper);
+        dataActor->GetProperty()->SetOpacity(1);
+        return dataActor;
+    }
+    return NULL;
+}
 
 wxMaracasSurfaceRenderingManagerData::~wxMaracasSurfaceRenderingManagerData(){
        
@@ -124,13 +173,20 @@ void wxMaracasSurfaceRenderingManagerData::saveProp3DSTL(const char* filename){
               plywriter->SetFileName(filename);
               plywriter->SetInput(_dataMapper->GetInput());
               plywriter->Write();
-        }else if(ext.compare(PLY) == 0){
+        }else if(ext.compare(STL) == 0){
             vtkSmartPointer<vtkSTLWriter> stlWriter =
             vtkSmartPointer<vtkSTLWriter>::New();
               stlWriter->SetFileName(filename);
               stlWriter->SetInput(_dataMapper->GetInput());
               stlWriter->SetFileTypeToBinary();
               stlWriter->Write();
+        }else if(ext.compare(VTK) == 0){
+            vtkSmartPointer<vtkPolyDataWriter> polydataWriter =
+            vtkSmartPointer<vtkPolyDataWriter>::New();
+              polydataWriter->SetFileName(filename);
+              polydataWriter->SetInput(_dataMapper->GetInput());
+              polydataWriter->SetFileTypeToBinary();
+              polydataWriter->Write();
         }else{
             cout<<"unsupported format"<<endl;
         }
@@ -141,6 +197,23 @@ void wxMaracasSurfaceRenderingManagerData::enableBoxWidget(bool enable){
 
 }
 
+void wxMaracasSurfaceRenderingManagerData::exportImageStencil(const char* filename){
+    if(_dataMapper){
+        vtkSmartPointer< SurfaceRenderingImageStencilExport> stencilexport = vtkSmartPointer< SurfaceRenderingImageStencilExport >::New();
+        stencilexport->SetInput( _dataMapper->GetInput());
+        stencilexport->Update();
+        vtkImageData* imgstencil = stencilexport->GetOutput();
+
+        vtkSmartPointer<vtkMetaImageWriter> metawriter = vtkSmartPointer<vtkMetaImageWriter>::New();
+        metawriter->SetFileName(filename);
+        metawriter->SetInput(imgstencil);
+        metawriter->Write();
+    }else{
+        cout<<"No poly data set to data mapper."<<endl;
+    }
+
+}
+
 
 
 
index 150524566adcf1e455be19790ee139d5b22bfe58..9b962c29a827e13aaee13abf6365c1e83567cd1c 100644 (file)
 
 #define PLY  ".ply"
 #define STL  ".stl"
+#define VTK  ".vtk"
 
+using namespace std;
 
 class wxMaracasSurfaceRenderingManagerData {
 
 public:
        wxMaracasSurfaceRenderingManagerData(vtkProp3D* _prop3Dvect, std::string dataname="", vtkRenderWindowInteractor*  interactor=NULL);     
+        wxMaracasSurfaceRenderingManagerData(string filename, vtkRenderWindowInteractor*  interactor);
        ~wxMaracasSurfaceRenderingManagerData();        
        
        /**
@@ -74,6 +77,9 @@ public:
 
         virtual void enableBoxWidget(bool enable);
 
+        void exportImageStencil(const char* filename);
+
+        vtkProp3D* getProp3D(std::string filename);
 protected:
         vtkPolyDataMapper* _dataMapper;
        /**
index 3deb86ef088541c86dd48093bcd77fbbdacbe309..0ba06f641df984c3adb5a07aefc1fb6bdb53bf11 100644 (file)
@@ -14,14 +14,27 @@ wxMaracasSurfaceRenderingManagerDataMhd::wxMaracasSurfaceRenderingManagerDataMhd
        _maxgreylevel = getMaxLevel(imagedata);
        _prop3D=NULL;                   
 
+        _tresholdFilter = vtkImageThreshold::New();
+        _tresholdFilter->SetInput(this->_imagedata);
+        _tresholdFilter->SetInValue(255);        
+        _tresholdFilter->SetOutValue(0);
+
+
        _cubesFilter = vtkMarchingCubes::New(); 
-       _cubesFilter->SetInput(this->_imagedata);               
-       _cubesFilter->ComputeGradientsOn ();
-       _cubesFilter->ComputeScalarsOn ();
-       _cubesFilter->SetNumberOfContours( 1 );
+        _cubesFilter->SetInput(_tresholdFilter->GetOutput());
+        //_cubesFilter->ComputeGradientsOn();
+        _cubesFilter->ComputeScalarsOn();
+        _cubesFilter->ComputeNormalsOn();
+        _cubesFilter->SetNumberOfContours( 1 );
        _cleanFilter = vtkCleanPolyData::New();         
        _cleanFilter->SetInput ( _cubesFilter->GetOutput() );
 
+        _smooth = vtkSmoothPolyDataFilter::New();
+        _smooth->SetInput(_cleanFilter->GetOutput());
+        _smooth->SetNumberOfIterations(6);
+        _smooth->SetRelaxationFactor(0.3);
+        //_smooth->FeatureEdgeSmoothingOff();
+
        _dataMapper = vtkPolyDataMapper::New( );
        _dataMapper->ScalarVisibilityOff( );
        _dataMapper->ImmediateModeRenderingOn();
@@ -38,8 +51,8 @@ wxMaracasSurfaceRenderingManagerDataMhd::wxMaracasSurfaceRenderingManagerDataMhd
             boxSurfaceObserver* observer = boxSurfaceObserver::New();
 
             vtkStripper* striper = vtkStripper::New();
-            striper->SetInput( _cleanFilter->GetOutput() );
-            //striper->SetInput( _cubesFilter->GetOutput() );
+            striper->SetInput( _smooth->GetOutput() );
+            //striper->SetInput( _cleanFilter->GetOutput() );
 
             striper->Update();
             _boxWidgetS1->SetInput(striper->GetOutput());
@@ -69,13 +82,17 @@ wxMaracasSurfaceRenderingManagerDataMhd::wxMaracasSurfaceRenderingManagerDataMhd
             _boxWidgetS1->HandlesOn ();
             _boxWidgetS1->EnabledOff();
        }else{          
-               _dataMapper->SetInput(_cleanFilter->GetOutput());                               
+                //_dataMapper->SetInput(_cleanFilter->GetOutput());
+            _dataMapper->SetInput(_smooth->GetOutput());
        }
        
        dataActor->SetMapper(_dataMapper);      
-       this->_prop3D = dataActor;
+        float cr=1,cg=0.5,cb=0.5;
+        dataActor->GetProperty()->SetDiffuseColor(1,0.5,0.5   );
+        dataActor->GetProperty()->SetSpecular(.3);
+        dataActor->GetProperty()->SetSpecularPower(20);
 
-       
+        this->_prop3D = dataActor;
        
 
        this->changeIsoValue(this->_maxgreylevel);      
@@ -116,7 +133,10 @@ void wxMaracasSurfaceRenderingManagerDataMhd::UpdateSurface()
 void wxMaracasSurfaceRenderingManagerDataMhd::changeIsoValue(double value){    
                
    
-    _cubesFilter->SetValue(0,value);           
+    _tresholdFilter->ThresholdByLower(value);
+    _tresholdFilter->Update();
+
+    _cubesFilter->SetValue(0,255);
        _cubesFilter->Update();    
        _cleanFilter->Update();
        _dataMapper->Update();  
@@ -129,8 +149,9 @@ void wxMaracasSurfaceRenderingManagerDataMhd::changeIsoValue(double value){
 **/
 void wxMaracasSurfaceRenderingManagerDataMhd::changeIsoValue(double min, double max){
 
-
-    _cubesFilter->SetValue(min,max);
+    _tresholdFilter->ThresholdBetween(min, max);
+    _tresholdFilter->Update();
+    _cubesFilter->SetValue(0,255);
         _cubesFilter->Update();
         _cleanFilter->Update();
         _dataMapper->Update();
index 44320dbed33eee945500688bd0f3b978b2062f85..de2165d9a0852b00fcf20d8eebde2d9a196e5dca 100644 (file)
@@ -11,6 +11,8 @@
 #include "vtkImageData.h"
 #include "vtkClipPolyData.h"
 #include "vtkPlanes.h"
+#include "vtkImageThreshold.h"
+#include "vtkSmoothPolyDataFilter.h"
 
 class wxMaracasSurfaceRenderingManagerDataMhd : public wxMaracasSurfaceRenderingManagerData  {
 
@@ -67,6 +69,8 @@ private:
         vtkCleanPolyData* _cleanFilter;
        vtkClipPolyData* _tissueClipper;
        vtkPlanes* _tissuePlanes;
+        vtkImageThreshold * _tresholdFilter;
+        vtkSmoothPolyDataFilter* _smooth;
        
        /**
        ** Get's the max grey level of the image
index 21047faad34ed15eb61bcac0072a537643bea345..ba51a3c7434584407673e9fbb6d0a88489ef5113 100644 (file)
@@ -47,9 +47,12 @@ void VolumeRendererManagerData::Initialize(vtkImageData* vol, std::string datana
 
     _volumeProperty = vtkVolumeProperty::New();
     _volumeProperty->SetInterpolationTypeToLinear();
-    //_volumeProperty->ShadeOn();
-    _volumeProperty->DisableGradientOpacityOn();    
-    _tfun = vtkPiecewiseFunction::New();
+    _volumeProperty->ShadeOn();
+    _volumeProperty->SetAmbient(3);
+    _volumeProperty->SetDiffuse(0.2);
+    _volumeProperty->SetSpecular(0.5);
+    //_volumeProperty->DisableGradientOpacityOn();
+    _tfun = vtkPiecewiseFunction::New();    
     _volumeProperty->SetScalarOpacity(_tfun );
     _ctfun = vtkColorTransferFunction::New();
 
@@ -147,10 +150,10 @@ VolumeRendererManagerData::~VolumeRendererManagerData()
 }
 void VolumeRendererManagerData::SetIndependentComponents(bool independent){
 
-    if(!independent){
-        _volumeProperty->IndependentComponentsOff();
-    }else{
+    if(independent){
         _volumeProperty->IndependentComponentsOn();
+    }else{
+        _volumeProperty->IndependentComponentsOff();
     }
 }
 
index 9ffe5868c6ce793c458624cdc0dacbd32cd65623..8943f402974a805ed9d195cc336ba502b52c33c8 100644 (file)
@@ -182,12 +182,13 @@ FILE(GLOB ${LIBRARY_NAME}_HEADERS_CUTMODULE src/CutModule/interface/*.h src/CutM
   SET(${LIBRARY_NAME}_INSTALL_FOLDER ${LIBRARY_NAME})
 
   SET(${LIBRARY_NAME}_LIBRARIES 
-            ${LIBRARY_NAME}
+
              BaseVolumeRenderer
              BaseSurfaceRenderer
              KernelVolumeRenderer
              KernelViewerWidgets
              KernelSurfaceRenderer
+             ${LIBRARY_NAME}
        )
 
 #  SET(${LIBRARY_NAME}_LIBRARIES ${LIBRARY_NAME}
index 55694ac4baf6064b94143b3f7e39bf140dfa7684..4f10303b07c884b0cbb15436f7f988d8f5331db0 100644 (file)
@@ -3,9 +3,14 @@
 
 #include "BrushFilter.h"
 #include "FillFilter.h"
+
+//#include "regionStructUR.h"
+//#include "imageUndoRedo.h"
+
 #include "imageModificationManager.h"
 #include "imageUndoRedo.h"
 
+
 class ManualPaintModel {
 public:
        ManualPaintModel();
index f2406be7de51df235d04df0325808df71c91a1bc..3725be5a1c8b08dc65ae5e2ae87c7207b29808c0 100644 (file)
@@ -2,8 +2,12 @@
 #define _BASE_FILTER_MANUAL_PAINT_H_
 
 #include <vtkImageData.h>
+
+//#include "regionStructUR.h"
+
 #include "imageModificationManager.h"
 
+
 class baseFilterManualPaint {
 
 public: