]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxSTLWidget_03.cxx
#3331 creaMaracasVisu Bug New Normal - Select contour with 2 points, HelpViewerNV
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxSTLWidget_03.cxx
index cbecc1a7f8c1a57e0aee73b95aca17708eaf16ac..9e73b799e4761645ee923f766b845578070a5641 100644 (file)
@@ -1,3 +1,28 @@
+/*# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+#                        pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+#  This software is governed by the CeCILL-B license under French law and
+#  abiding by the rules of distribution of free software. You can  use,
+#  modify and/ or redistribute the software under the terms of the CeCILL-B
+#  license as circulated by CEA, CNRS and INRIA at the following URL
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability.
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------ */
+
 
 #include "vtkObjectFactory.h"
 
 wxSTLWidget_03::wxSTLWidget_03(wxWindow *parent)//, marInterface* mar)
 : wxPanel( parent, -1) 
 {
-       _wxMaracasMPR           = NULL;
+       _imagedata=NULL;
+       cast2=NULL;
+       cast3=NULL;
+       cast4=NULL; // binary segmentation result
+       _thresh=NULL;
+       _thresh2=NULL;
+       _cast=NULL;
+       _connect=NULL;
+       _connect2=NULL;
+       _2_mapfinal=NULL;
+       _2_stripfinal=NULL;
+       _2_isoMapperMC6=NULL;
+       _2_isoActorMC6=NULL;
+       _2_isoMC6=NULL; 
+       _loadSTLMapper=NULL;
+       _loadActorSTL=NULL;
+       sl_barrange_segmentation=NULL;  
+       _imageviewer3D=NULL;    
+       _wxMaracasMPR=NULL;     
+       stlInterna=NULL;
+       stlExterna=NULL;        
+       stlSliderDeltaGauss=NULL;
+       stlSliderMarchingCubes=NULL;    
+       dsm1=NULL;
+    actorInternal=NULL;
+       stlSliderOpacityInternal=NULL;    
+       dsm2=NULL; 
+    actorExternal=NULL;
+       stlSliderOpacityExternal=NULL;
+       stlExtractor=NULL;   
+       _sl_opacity_STL_file=NULL;
+       arteryImageData=NULL;
+       joiner=NULL;
+       joinMarchingCubes=NULL;
+    joinMapper=NULL; 
+       joinActor=NULL; 
        _maxSize                = 2000;
        _minSize                = 300;
-
+       
        _stlMarchingCubesLevel  = 128;
        _stlDeltaGaussLevel             = 100;
 
@@ -89,9 +149,7 @@ wxSTLWidget_03::wxSTLWidget_03(wxWindow *parent)//, marInterface* mar)
        wxBoxSizer              *sizer          = new wxBoxSizer(wxVERTICAL  );
        wxSplitterWindow        *pnlSplitter    = new wxSplitterWindow( this , -1);
        wxPanel                 *viewPanel      = CreateViewPanel(pnlSplitter);
-printf("EED wxSTLWidget_03::wxSTLWidget_03 01\n");
        wxPanel                 *controlPanel   = CreateControlPanel(pnlSplitter);
-printf("EED wxSTLWidget_03::wxSTLWidget_03 02\n");
 
        sizer           -> Add( pnlSplitter ,1,wxGROW  ,0);
        pnlSplitter     -> SetMinimumPaneSize( 150 );
@@ -101,36 +159,49 @@ printf("EED wxSTLWidget_03::wxSTLWidget_03 02\n");
 //     pnlSplitter     -> SplitVertically( viewPanel, new wxPanel(pnlSplitter,-1) , 600 );
 
        this            -> SetSizer(sizer);
-
-       // Result 2: Volume + Axis
-//     _2_prgov                = NULL;
-       _2_mapfinal             = NULL;
-       _2_stripfinal           = NULL;
-       _2_isoMapperMC6         = NULL;
-       _2_isoActorMC6          = NULL;
-       _2_isoMC6               = NULL;
-
-       //DHC STL SURFACES
-       stlInterna              = NULL;
-       stlExterna              = NULL;
-
-       _loadSTLMapper          = NULL;
-       _loadActorSTL           = NULL;
-
        
-       //JOIN REGIONS
-       arteryImageData         = NULL;
-       joinMarchingCubes       = NULL;
-    joinMapper                 = NULL; 
-       joinActor               = NULL;
-printf("EED wxSTLWidget_03::wxSTLWidget_03 03\n");
 
 
 }
 //-------------------------------------------------------------------
 wxSTLWidget_03::~wxSTLWidget_03(){
-       ResetTree2_JF();
-       Reset_vtk_STLFile();
+       //ResetTree2_JF();
+       //Reset_vtk_STLFile();
+
+       if(_imagedata!=NULL){
+               _imagedata->Delete();   
+       }       
+       if(cast2){cast2->Delete();}
+       if(cast3){cast3->Delete();}
+       if(cast4){cast4->Delete();}
+       if(_thresh){_thresh->Delete();}
+       if(_thresh2){_thresh2->Delete();}
+       if(_cast){_cast->Delete();}
+       if(_connect){_connect->Delete();}
+       if(_connect2){_connect2->Delete();}
+       if(_2_mapfinal){_2_mapfinal->Delete();}
+       if(_2_stripfinal){_2_stripfinal->Delete();}
+       if(_2_isoMapperMC6){_2_isoMapperMC6->Delete();}
+       if(_2_isoActorMC6){_2_isoActorMC6->Delete();}
+       if(_2_isoMC6){_2_isoMC6->Delete();}
+       // Load STL file
+       if(_loadSTLMapper){_loadSTLMapper->Delete();}
+       if(_loadActorSTL){_loadActorSTL->Delete();}
+       if(sl_barrange_segmentation){delete sl_barrange_segmentation;}
+       if(_imageviewer3D){delete _imageviewer3D;}      
+       if(_wxMaracasMPR){delete _wxMaracasMPR;}
+       if(stlInterna){stlInterna->Delete();}
+       if(stlExterna){stlExterna->Delete();}   
+       if(dsm1){dsm1->Delete();}
+    if(actorInternal){actorInternal->Delete();}
+       if(dsm2){dsm2->Delete();} 
+    if(actorExternal){actorExternal->Delete();}
+       //if(stlExtractor){stlExtractor->Delete();}
+       if(arteryImageData){arteryImageData->Delete();}
+       if(joiner){delete joiner;}
+       if(joinMarchingCubes){joinMarchingCubes->Delete();}
+    if(joinMapper){joinMapper->Delete(); }
+       if(joinActor){joinActor->Delete();}
 }
 //-------------------------------------------------------------------
 wxPanel* wxSTLWidget_03::CreateViewPanel(wxWindow *parent)
@@ -143,55 +214,51 @@ wxPanel* wxSTLWidget_03::CreateViewPanel(wxWindow *parent)
        //vtkImageData *imagedata;
        //imagedata = _mar->_experiment->getDynData( )->getVolume( )->castVtk();
        //imagedata->Update();  
-printf("EED wxSTLWidget_03::CreateViewPanel  01 \n");
        _wxMaracasMPR = new wxMaracasMPR( panel);//JCP 10-03-2009, new marImageData(imagedata), 1 );
-printf("EED wxSTLWidget_03::CreateViewPanel  02 \n");
        _wxMaracasMPR->ConfigureVTK();
-printf("EED wxSTLWidget_03::CreateViewPanel  03 \n");
        
        sizer->Add(     _wxMaracasMPR , 1, wxEXPAND, 0);
        panel->SetSizer(sizer);
        panel->SetAutoLayout(true);
        panel->SetSize(400,400);
        panel->Layout();
-printf("EED wxSTLWidget_03::CreateViewPanel  04 \n");
        return panel;
 }
 
 void wxSTLWidget_03::setImage(vtkImageData* img){
 
-
-       _wxMaracasMPR->setMarImage(new marImageData(img), 1);
+       _wxMaracasMPR->setImageData(img, 1);
        _wxMaracasMPR->ConfigureVTK();
+
+
+       this->ConfigureProcessing(img,0,0,0);
+       this->ConfigureSTL();
+
+       _wxMaracasMPR->Refresh();
+       
+       //this->Refresh();
 }
 //-------------------------------------------------------------------
 wxWindow* wxSTLWidget_03::CreateSelectAPointPanel(wxWindow *parent)
 {
-printf("EED wxSTLWidget_03::CreateSelectAPointPanel  01\n");
        wxPanel *panel          = new wxPanel(parent,-1);
 
-printf("EED wxSTLWidget_03::CreateSelectAPointPanel  02\n");
 
     wxFlexGridSizer *sizer = new wxFlexGridSizer(2);
-printf("EED wxSTLWidget_03::CreateSelectAPointPanel  03\n");
 
        sizer->Add(new wxStaticText(panel,-1,_T("  ")));
        sizer->Add(new wxStaticText(panel,-1,_T("  ")));
-printf("EED wxSTLWidget_03::CreateSelectAPointPanel  04\n");
 
        sizer->Add(new wxStaticText(panel,-1,_T("  ")));
        sizer->Add(new wxStaticText(panel,-1,_T("  ")));
-printf("EED wxSTLWidget_03::CreateSelectAPointPanel  05\n");
 
        sizer->Add(new wxStaticText(panel,-1,_T(" Select a 3D Point...")));
        sizer->Add(new wxStaticText(panel,-1,_T("  ")));
-printf("EED wxSTLWidget_03::CreateSelectAPointPanel  06\n");
 
        panel->SetSizer(sizer);
        panel->SetAutoLayout(true);
        panel->SetSize(400,600);
        panel->Layout();
-printf("EED wxSTLWidget_03::CreateSelectAPointPanel  07\n");
 
 
        return panel;
@@ -202,23 +269,23 @@ wxWindow* wxSTLWidget_03::CreateSegmentationPanel(wxWindow *parent)
        wxPanel *panel          = new wxPanel(parent,-1);
 
 
-       _opacity_Vol            = new wxSlider( panel, -1, 40, 0, 100                            , wxDefaultPosition, wxSize(200,40), wxSL_HORIZONTAL | wxSL_LABELS );
+       _opacity_Vol            = new wxSlider( panel, -1, 40, 0, 100                            , wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS );
        _opacity_Vol    ->SetSize(250,20);  
        /*SIL
-       _sl_maxSize                     = new wxSlider( panel, -1, 300 , 0, 2000 , wxDefaultPosition, wxSize(200,40), wxSL_HORIZONTAL  |  wxSL_AUTOTICKS | wxSL_LABELS );
-       _sl_minSize                     = new wxSlider( panel, -1, 200 , 0, 2000 , wxDefaultPosition, wxSize(200,40), wxSL_HORIZONTAL  |  wxSL_AUTOTICKS | wxSL_LABELS );
+       _sl_maxSize                     = new wxSlider( panel, -1, 300 , 0, 2000 , wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL  |  wxSL_AUTOTICKS | wxSL_LABELS );
+       _sl_minSize                     = new wxSlider( panel, -1, 200 , 0, 2000 , wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL  |  wxSL_AUTOTICKS | wxSL_LABELS );
        
-       _sl_minSizeSpin = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxSize(25,45), wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT  );
+       _sl_minSizeSpin = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxDefaultSize, wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT  );
        _sl_minSizeSpin->SetRange(1,8);
        _sl_minSizeSpin->SetValue(5);
 
-       _sl_maxSizeSpin = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxSize(25,45), wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT  );
+       _sl_maxSizeSpin = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxDefaultSize, wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT  );
        _sl_maxSizeSpin->SetRange(1,8);
        _sl_maxSizeSpin->SetValue(5);
 
        */
 
-       _sl_RangeSizeSpin = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxSize(25,45), wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT  );
+       _sl_RangeSizeSpin = new wxSlider(panel , -1,5,1,10,wxDefaultPosition ,wxDefaultSize, wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT  );
        _sl_RangeSizeSpin->SetRange(1,8);
        _sl_RangeSizeSpin->SetValue(5);
 
@@ -395,19 +462,13 @@ wxWindow* wxSTLWidget_03::CreateReadSTLFilePanel(wxWindow *parent)
 //-------------------------------------------------------------------
 wxPanel* wxSTLWidget_03::CreateControlPanel(wxWindow *parent)
 {
-printf("EED wxSTLWidget_03::CreateControlPanel 01\n");
        wxPanel *panel                  = new wxPanel(parent,-1);
 
        wxNotebook *noteBook    = new wxNotebook(panel, -1);
-printf("EED wxSTLWidget_03::CreateControlPanel 02\n");
        noteBook->AddPage(CreateSelectAPointPanel(noteBook),_T("0 ->") );
-printf("EED wxSTLWidget_03::CreateControlPanel 03\n");
        noteBook->AddPage(CreateSegmentationPanel(noteBook),_T("1 ->") );
-printf("EED wxSTLWidget_03::CreateControlPanel 04\n");
        noteBook->AddPage(CreateSmoothingPanel(noteBook)   ,_T("2 ->") );
-printf("EED wxSTLWidget_03::CreateControlPanel 05\n");
        noteBook->AddPage(CreateReadSTLFilePanel(noteBook) ,_T("3 "  ) );
-printf("EED wxSTLWidget_03::CreateControlPanel 06\n");
        noteBook->SetSelection(0);
        noteBook->SetSize(350,250);
     wxFlexGridSizer *sizer = new wxFlexGridSizer(2);
@@ -417,7 +478,6 @@ printf("EED wxSTLWidget_03::CreateControlPanel 06\n");
        panel->SetSize(400,600);
        panel->Layout();
 
-printf("EED wxSTLWidget_03::CreateControlPanel 07\n");
        return panel;
 }
 //------------------------------------------------------------------------
@@ -431,14 +491,11 @@ void wxSTLWidget_03::Refresh()
 //------------------------------------------------------------------------
 
 
-void wxSTLWidget_03::ConfigureProcessing(marImageData *marimagedata, int x, int y, int z)
+void wxSTLWidget_03::ConfigureProcessing(vtkImageData *img, int x, int y, int z)
 {
     wxBusyCursor wait;
 
-       _imagedata=marimagedata->GetImageData(); // image t=0
-       _imagedata->UpdateInformation();
-       _imagedata->SetUpdateExtent(_imagedata->GetWholeExtent());
-       _imagedata->Update();
+       _imagedata=img;
 
 
        double puntoactualprov[3];
@@ -484,63 +541,115 @@ void wxSTLWidget_03::ConfigureProcessing(marImageData *marimagedata, int x, int
 
 //     _zslice->SetRange(extprin[4], extprin[5]);
 //     _zslice->SetValue(extprin[5]/2);
-       
-       _thresh = vtkImageThreshold::New();
-       _thresh->SetInput(_imagedata);
-       //_thresh->ReleaseDataFlagOff();
-       _thresh->SetInValue(255);
-       _thresh->SetOutputScalarTypeToUnsignedShort();
-       _thresh->SetOutValue(0);
-       //_thresh->ThresholdBetween(_sl_minSize->GetValue(), _range[1]);
-       //SIL//
-       _thresh->ThresholdBetween(sl_barrange_segmentation->GetStart(), sl_barrange_segmentation->GetEnd()); 
-
-       vtkImageCast *cast = vtkImageCast::New();
-       cast->SetInput(_thresh->GetOutput());
-       cast->SetOutputScalarTypeToUnsignedChar();
-       cast->Update();
-
-  
-       _connect = vtkImageSeedConnectivity::New();
-       _connect->SetInput(cast->GetOutput());
-       _connect->SetInputConnectValue(255);
-       _connect->SetOutputConnectedValue(255);
-       _connect->SetOutputUnconnectedValue(0);
+    
+       if(_thresh==NULL){
+               _thresh = vtkImageThreshold::New();
+               //_thresh->ReleaseDataFlagOff();
+               _thresh->SetInValue(255);
+               _thresh->SetOutputScalarTypeToUnsignedShort();
+               _thresh->SetOutValue(0);
+               //_thresh->ThresholdBetween(_sl_minSize->GetValue(), _range[1]);
+               //SIL//
+               _cast = vtkImageCast::New();
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+               _cast->SetInput(_thresh->GetOutput());
+#else
+               _cast->SetInputData(_thresh->GetOutput());
+#endif
+
+               _cast->SetOutputScalarTypeToUnsignedChar();
+
+               _connect = vtkImageSeedConnectivity::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+               _connect->SetInput(_cast->GetOutput());
+#else
+               _connect->SetInputData(_cast->GetOutput());
+#endif
+               _connect->SetInputConnectValue(255);
+               _connect->SetOutputConnectedValue(255);
+               _connect->SetOutputUnconnectedValue(0);
+
+               cast3 = vtkImageCast::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+               cast3->SetInput(_connect->GetOutput());
+#else
+               cast3->SetInputData(_connect->GetOutput());
+#endif
+               cast3->SetOutputScalarTypeToUnsignedShort();
+
+               _thresh2 = vtkImageThreshold::New();
+               //_thresh2->ReleaseDataFlagOff();
+               _thresh2->SetInValue(255);
+               _thresh2->SetOutputScalarTypeToUnsignedShort();
+               _thresh2->SetOutValue(0);
+               //SIL//_thresh2->ThresholdBetween(_sl_minSize->GetValue(), _sl_maxSize->GetValue());
+
+               cast2 = vtkImageCast::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+               cast2->SetInput(_thresh2->GetOutput());
+#else
+               cast2->SetInputData(_thresh2->GetOutput());
+#endif
+               cast2->SetOutputScalarTypeToUnsignedChar();
+               _connect2 = vtkImageSeedConnectivity::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+               _connect2->SetInput(cast2->GetOutput());
+#else
+               _connect2->SetInputData(cast2->GetOutput());
+#endif
+               _connect2->SetInputConnectValue(255);
+               _connect2->SetOutputConnectedValue(255);
+               _connect2->SetOutputUnconnectedValue(0);
+
+               cast4 = vtkImageCast::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+               cast4->SetInput(_connect2->GetOutput());
+#else
+               cast4->SetInputData(_connect2->GetOutput());
+#endif
+               cast4->SetOutputScalarTypeToUnsignedShort();
+       }
+       _thresh->RemoveAllInputs();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+       _thresh->SetInput(_imagedata);  
+#else
+       _thresh->SetInputData(_imagedata);      
+#endif
+       _thresh->ThresholdBetween(sl_barrange_segmentation->GetStart(), sl_barrange_segmentation->GetEnd());    
+       _thresh->Update();
+       
+       _cast->Update();  
+       
+
+       _connect->RemoveAllSeeds();
        _connect->AddSeed((int)(puntoactualprov[0]), (int)(puntoactualprov[1]), (int)(puntoactualprov[2]));
-//     _connect->Update();
+       //_connect->Update();   
+       //cast3->Update();
+//SIL//        
+       _thresh2->RemoveAllInputs();
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+       _thresh2->SetInput(_imagedata); 
+#else
+       _thresh2->SetInputData(_imagedata);     
+#endif
 
-       cast3 = vtkImageCast::New();
-       cast3->SetInput(_connect->GetOutput());
-       cast3->SetOutputScalarTypeToUnsignedShort();
-       cast3->Update();
-//SIL//
-       
-       _thresh2 = vtkImageThreshold::New();
-       _thresh2->SetInput(_imagedata);
-       //_thresh2->ReleaseDataFlagOff();
-       _thresh2->SetInValue(255);
-       _thresh2->SetOutputScalarTypeToUnsignedShort();
-       _thresh2->SetOutValue(0);
-       //SIL//_thresh2->ThresholdBetween(_sl_minSize->GetValue(), _sl_maxSize->GetValue());
        _thresh2->ThresholdBetween(sl_barrange_segmentation->GetStart(), sl_barrange_segmentation->GetEnd());
-       
-       cast2 = vtkImageCast::New();
-       cast2->SetInput(_thresh2->GetOutput());
-       cast2->SetOutputScalarTypeToUnsignedChar();
+       _thresh2->Update();
        cast2->Update();
-
-       _connect2 = vtkImageSeedConnectivity::New();
-       _connect2->SetInput(cast2->GetOutput());
-       _connect2->SetInputConnectValue(255);
-       _connect2->SetOutputConnectedValue(255);
-       _connect2->SetOutputUnconnectedValue(0);
+       _connect2->RemoveAllSeeds();
        _connect2->AddSeed( (int)(puntoactualprov[0]), (int)(puntoactualprov[1]), (int)(puntoactualprov[2]));
-       _connect2->Update();
-
-       cast4 = vtkImageCast::New();
-       cast4->SetInput(_connect2->GetOutput());
-       cast4->SetOutputScalarTypeToUnsignedShort();
-       cast4->Update();
+       //_connect2->Update();  
+       //cast4->Update();
 }
 
 //------------------------------------------------------------------------
@@ -551,11 +660,11 @@ void wxSTLWidget_03::ConfigureVTK()
 {
        wxBusyCursor wait;
 //     vtkImageData    *imagedata              = _mar->_experiment->getDynData( )->getVolume( )->castVtk();
-       marImageData    *marimagedata;//                = _mar->_experiment->getDynData( )->GetMarImageData();
+       //marImageData  *marimagedata;//                = _mar->_experiment->getDynData( )->GetMarImageData();
        
        //CONFIGURACION ADICIONAL
        this->ConfigureSTL();
-       this->ConfigureProcessing(marimagedata,0,0,0);
+       //this->ConfigureProcessing(marimagedata,0,0,0);
        
 }
 
@@ -564,30 +673,41 @@ void wxSTLWidget_03::ConfigureVTK()
 void wxSTLWidget_03::ResetTree2_JF()
 {
        // Remove 
-       vtkRenderer *ren = _wxMaracasMPR->GetWxvtkmpr3Dview_BB()->GetWxvtk3Dbaseview()->GetRenderer();
 
-    if (_2_isoActorMC6){
-               ren->RemoveActor(_2_isoActorMC6);
+       try{
+
+               
+
+               // Delete 
+       //      if (_2_prgov            ) {     _2_prgov                -> Delete(); }
+               if (_2_mapfinal         ) {     _2_mapfinal             -> Delete(); }
+               if (_2_stripfinal       ) {     _2_stripfinal   -> Delete(); }
+               if (_2_isoMapperMC6     ) {     _2_isoMapperMC6 -> Delete(); }
+               if (_2_isoActorMC6      ) {     _2_isoActorMC6  -> Delete(); }
+               if (_2_isoMC6           ) {     _2_isoMC6               -> Delete(); }
+
+               // Init
+       //      _2_prgov                = NULL;
+               _2_mapfinal             = NULL;
+               _2_stripfinal   = NULL;
+               _2_isoMapperMC6 = NULL;
+               _2_isoActorMC6  = NULL;
+               _2_isoMC6               = NULL;
+
+               
+               //vtkRenderer *ren = _wxMaracasMPR->GetWxvtkmpr3Dview_BB()->GetWxvtk3Dbaseview()->GetRenderer();
+
+               /*if (_2_isoActorMC6){
+                       ren->RemoveActor(_2_isoActorMC6);
+               }
+               if (_2_stripfinal){
+                       ren->RemoveActor(_2_stripfinal);
+               }*/
+
+               
+       }catch(char* e){
+               std::cout<<e<<std::endl;
        }
-    if (_2_stripfinal){
-               ren->RemoveActor(_2_stripfinal);
-       }
-
-       // Delete 
-//     if (_2_prgov            ) {     _2_prgov                -> Delete(); }
-       if (_2_mapfinal         ) {     _2_mapfinal             -> Delete(); }
-       if (_2_stripfinal       ) {     _2_stripfinal   -> Delete(); }
-       if (_2_isoMapperMC6     ) {     _2_isoMapperMC6 -> Delete(); }
-       if (_2_isoActorMC6      ) {     _2_isoActorMC6  -> Delete(); }
-       if (_2_isoMC6           ) {     _2_isoMC6               -> Delete(); }
-
-       // Init
-//     _2_prgov                = NULL;
-       _2_mapfinal             = NULL;
-       _2_stripfinal   = NULL;
-       _2_isoMapperMC6 = NULL;
-       _2_isoActorMC6  = NULL;
-       _2_isoMC6               = NULL;
 }
 
 
@@ -611,9 +731,14 @@ void wxSTLWidget_03::ExtractSurface(int x, int y, int z)
        puntoactualprov[1]      =       y;
        puntoactualprov[2]      =       z;
        
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
        _imagedata->UpdateInformation();
        _imagedata->SetUpdateExtent(_imagedata->GetWholeExtent());
        _imagedata->Update();
+#else
+       // ..
+#endif
 
        _imagedata->GetSpacing(espprin);
        _imagedata->GetExtent(extprin);
@@ -651,13 +776,26 @@ void wxSTLWidget_03::ExtractSurface(int x, int y, int z)
        // Visualisation - result volume
    
     _2_isoMC6 = vtkMarchingCubes::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
        _2_isoMC6->SetInput(cast4->GetOutput());
+#else
+       _2_isoMC6->SetInputData(cast4->GetOutput());
+#endif
 
     _2_isoMC6->SetValue(0, 128);
        _2_isoMC6->Update();
 
        _2_isoMapperMC6 = vtkPolyDataMapper::New();
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
     _2_isoMapperMC6->SetInput(_2_isoMC6->GetOutput());
+#else
+    _2_isoMapperMC6->SetInputData(_2_isoMC6->GetOutput());
+#endif
+
+
     _2_isoMapperMC6->ScalarVisibilityOff();
     _2_isoMapperMC6->ImmediateModeRenderingOn();
 
@@ -735,7 +873,7 @@ void wxSTLWidget_03::OnRangeSpin    (       wxScrollEvent &          event           )
        wxSlider *sl_B=_sl_RangeSizeSpin;
 
        int value = lastResizeRef_Value;
-       int delta = (int)pow( 4 , sl_B->GetValue() );
+       int delta = (int)pow((double) 4 , (double)sl_B->GetValue() );
        int startResized = value - delta/2;
        int endResized = value + delta/2;
 
@@ -778,7 +916,12 @@ void wxSTLWidget_03::OnBtnSaveBinaryFile(wxCommandEvent& event)
        {
                vtkMetaImageWriter  *writer= vtkMetaImageWriter::New();
                writer->SetFileName( dialog.GetPath().mb_str(wxConvUTF8) );     
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
                writer->SetInput(cast4->GetOutput());
+#else
+               writer->SetInputData(cast4->GetOutput());
+#endif
                writer->Write();
                writer->Delete();
        }
@@ -827,19 +970,23 @@ void wxSTLWidget_03::OnOpacitySTLFile(wxScrollEvent& event)
 void wxSTLWidget_03::Reset_vtk_STLFile()
 {
        // Remove
-       vtkRenderer *ren = _wxMaracasMPR->GetWxvtkmpr3Dview_BB()->GetWxvtk3Dbaseview()->GetRenderer();
-    if (_loadActorSTL){
-               ren->RemoveActor(_loadActorSTL);
+       try{
+               vtkRenderer *ren = _wxMaracasMPR->GetWxvtkmpr3Dview_BB()->GetWxvtk3Dbaseview()->GetRenderer();
+               if (_loadActorSTL){
+                       ren->RemoveActor(_loadActorSTL);
+               }
+
+               // Delete 
+               if (_loadSTLMapper              ) {     _loadSTLMapper          -> Delete(); }
+               if (_loadActorSTL               ) {     _loadActorSTL           -> Delete(); }
+
+               // Init
+               _loadSTLMapper          = NULL;
+               _loadActorSTL           = NULL;
+       }catch(char * e){
+               std::cout<<e<<std::endl;
        }
 
-       // Delete 
-       if (_loadSTLMapper              ) {     _loadSTLMapper          -> Delete(); }
-       if (_loadActorSTL               ) {     _loadActorSTL           -> Delete(); }
-
-       // Init
-       _loadSTLMapper          = NULL;
-       _loadActorSTL           = NULL;
-
 }
 //------------------------------------------------------------------------
 void wxSTLWidget_03::OnBtnSTLFileErase(wxCommandEvent& event)
@@ -862,7 +1009,12 @@ void wxSTLWidget_03::OnBtnSTLFileLoad(wxCommandEvent& event)
                vtkSTLReader *imgReader= vtkSTLReader::New();
                imgReader->SetFileName( dialog.GetPath().mb_str(wxConvUTF8) );  
                _loadSTLMapper = vtkPolyDataMapper::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
                _loadSTLMapper->SetInput(imgReader->GetOutput());
+#else
+               _loadSTLMapper->SetInputData(imgReader->GetOutput());
+#endif
                _loadActorSTL = vtkActor::New();
                _loadActorSTL->SetMapper(_loadSTLMapper);
                _loadActorSTL->GetProperty()->SetColor( 1, 0, 0);
@@ -888,31 +1040,49 @@ void wxSTLWidget_03::OnBtnSTLFileLoad(wxCommandEvent& event)
 
 void wxSTLWidget_03::ConfigureSTL()
 {
-       stlExterna = vtkPolyData::New();
-       stlInterna = vtkPolyData::New();
 
-       dsm1 = vtkPolyDataMapper ::New();
-    dsm1->SetInput (stlInterna); 
-    dsm1->ScalarVisibilityOff();
+       if(stlExterna == NULL){
+               stlExterna = vtkPolyData::New();
+               stlInterna = vtkPolyData::New();
 
-    actorInternal = vtkActor::New();
-    actorInternal->SetMapper (dsm1);
-    actorInternal->GetProperty()->SetColor (0,1,0);
+               dsm1 = vtkPolyDataMapper ::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+               dsm1->SetInput(stlInterna); 
+#else
+               dsm1->SetInputData(stlInterna); 
+#endif
+               dsm1->ScalarVisibilityOff();
 
-    dsm2 = vtkPolyDataMapper ::New();
-    dsm2->SetInput (stlExterna);
-    dsm2->ScalarVisibilityOff();
+               actorInternal = vtkActor::New();
+               actorInternal->SetMapper (dsm1);
+               actorInternal->GetProperty()->SetColor (0,1,0);
 
-    actorExternal= vtkActor::New();
-    actorExternal->SetMapper (dsm2);
-    actorExternal->GetProperty()->SetRepresentationToWireframe();
+               dsm2 = vtkPolyDataMapper ::New();
 
-//    vtkRenderer *ren = _maracasSurfaceWidget->GetVtk3DSurfaceWidget()->GetRenderer();
-       vtkRenderer *ren = _wxMaracasMPR->GetWxvtkmpr3Dview_BB()->GetWxvtk3Dbaseview()->GetRenderer();
-    ren->AddActor(actorInternal);
-    ren->AddActor(actorExternal);
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+               dsm2->SetInput(stlExterna);
+#else
+               dsm2->SetInputData(stlExterna);
+#endif
 
-       stlExtractor = new vtkSTLExtractor();  
+               dsm2->ScalarVisibilityOff();
+
+               actorExternal= vtkActor::New();
+               actorExternal->SetMapper (dsm2);
+               actorExternal->GetProperty()->SetRepresentationToWireframe();
+
+       //    vtkRenderer *ren = _maracasSurfaceWidget->GetVtk3DSurfaceWidget()->GetRenderer();
+               vtkRenderer *ren = _wxMaracasMPR->GetWxvtkmpr3Dview_BB()->GetWxvtk3Dbaseview()->GetRenderer();
+               ren->AddActor(actorInternal);
+               ren->AddActor(actorExternal);
+
+               stlExtractor = new vtkSTLExtractor();  
+
+       }
+
+       
 }
 
 void wxSTLWidget_03::generateSTLSurfaces()
@@ -952,7 +1122,14 @@ void wxSTLWidget_03::OnBtnCreateFileSTL(wxCommandEvent& event)
 
        
 //     wxDirDialog dialog( this, "Choose a directory...", ( !dirSTL.IsEmpty( ) )?dirSTL: wxGetHomeDir( ) );
+
+
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
        wxFileDialog dialog( this, _T("Choose a directory..."), dirSTL , _T(""), _T("*.*"), wxSAVE );
+#else
+       wxFileDialog dialog( this, _T("Choose a directory..."), dirSTL , _T(""), _T("*.*"), wxFD_SAVE );
+#endif
 
 
        if( dialog.ShowModal( ) == wxID_OK ) 
@@ -968,17 +1145,29 @@ void wxSTLWidget_03::OnBtnCreateFileSTL(wxCommandEvent& event)
 
                // 1.1. Se hace un filtro triangular puesto que el stl writer solo recibe poligonos triangulares.
 
-        vtkTriangleFilter *filtro = vtkTriangleFilter::New();
+        vtkClosePolyData                               *cpd    = vtkClosePolyData::New();
+        vtkTriangleFilter                              *filtro = vtkTriangleFilter::New();
+               vtkPolyDataConnectivityFilter   *pdcf   = vtkPolyDataConnectivityFilter::New();
+
+               // 1.2 se escribe a disco el archivo stl de la superficie interna
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
                filtro->SetInput(stlInterna);
-               vtkPolyDataConnectivityFilter *pdcf = vtkPolyDataConnectivityFilter::New();
         pdcf->SetInput( filtro->GetOutput() );
-        vtkClosePolyData *cpd = vtkClosePolyData::New();
         cpd->SetInput( pdcf->GetOutput() );
-
-               // 1.2 se escribe a disco el archivo stl de la superficie interna
         cpd->Update();
+#else
+               filtro->SetInputData(stlInterna);
+        pdcf->SetInputData( filtro->GetOutput() );
+        cpd->SetInputData( pdcf->GetOutput() );
+#endif
         vtkSTLWriter *writerI = vtkSTLWriter::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
         writerI->SetInput( cpd->GetOutput() );
+#else
+        writerI->SetInputData( cpd->GetOutput() );
+#endif
 //        prefix = fileprefix;
                filename=prefix+"_internal.stl";
         writerI->SetFileName(filename.c_str());
@@ -987,10 +1176,20 @@ void wxSTLWidget_03::OnBtnCreateFileSTL(wxCommandEvent& event)
         writerI->Delete();
 
                // 1.3 se escribe a disco el archivo stl de la superficie externa
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
                filtro->SetInput(stlExterna);
+#else
+               filtro->SetInputData(stlExterna);
+#endif
         cpd->Update();
         vtkSTLWriter *writerE = vtkSTLWriter::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
         writerE->SetInput( cpd->GetOutput() );
+#else
+        writerE->SetInputData( cpd->GetOutput() );
+#endif
 //        prefix = fileprefix;
                filename=prefix+"_external.stl";
         writerE->SetFileName( filename.c_str() );