]> Creatis software - creaContours.git/commitdiff
Clean code
authoreduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Tue, 1 Oct 2024 08:43:15 +0000 (10:43 +0200)
committereduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Tue, 1 Oct 2024 08:43:15 +0000 (10:43 +0200)
bbtk/bbs/boxes/ContourReferenceStep.bbg
bbtk/bbs/boxes/ContourReferenceStep.bbs
bbtk/src/bbcreaContourswxContourMainFrame_tool.cxx
bbtk/src/bbcreaContourswxContourMainFrame_tool.h
lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx
lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx
lib/Interface_ManagerContour_NDimensions/wxVtkBaseView_SceneManager.cxx

index 2530287664e4820ebb94da7cb069c3897015959d..de1cf1e35f99f314842ed87153be8f1fa25355ad 100644 (file)
@@ -11,7 +11,7 @@ EXPORTFORMAT:0
 COMPLEXBOX:TRUE
 COMPLEXBOXNAME:ContourReferenceStep
 PACKAGENAME:creaContours
-COMPLEXOUTPUTS:3
+COMPLEXOUTPUTS:4
 COMPLEX_PORT
 _widget
 -63.491296:-134.823351:-900.000000
@@ -24,6 +24,10 @@ COMPLEX_PORT
 _iaxis
 44.663851:-138.928196:-900.000000
 FIN_COMPLEX_PORT
+COMPLEX_PORT
+_step
+-23.031012:-136.184078:-900.000000
+FIN_COMPLEX_PORT
 COMPLEXINPUTS:11
 COMPLEX_PORT
 _point
@@ -383,8 +387,8 @@ FIN_BOX
 BOX
 std:ConcatStrings:Box317
 ISEXEC:FALSE
--81.729138:71.218704:-900.000000
--58.969138:68.718704:-900.000000
+-60.909644:59.923021:-900.000000
+-38.149644:57.423021:-900.000000
 FIN_BOX
 BOX
 std:StringSelect:Box318
@@ -694,7 +698,7 @@ ISEXEC:FALSE
 PORT
 Type:"2"
 FIN_BOX
-CONNECTIONS:136
+CONNECTIONS:137
 CONNECTION
 Box86:Widget:Box84:Widget2
 NumberOfControlPoints:0
@@ -1103,4 +1107,7 @@ NumberOfControlPoints:0
 CONNECTION
 Box97:Out:Box436:In
 NumberOfControlPoints:0
+CONNECTION
+Box317:Out:_step:_step
+NumberOfControlPoints:0
 APP_END
index 76812cc69b0094f234e2f8e0e5449151e7e2890e..29b57ddfc5c1d17b010b8c9333628813a3308cee 100644 (file)
@@ -389,6 +389,7 @@ input _point Box77.In " "
 output _widget Box456.Widget " "
 output _initExec Box448.BoxChange " "
 output _iaxis Box288.Out " "
+output _step Box317.Out " "
 
 
 endefine
index aa05239e7eea5c372e24a728bde5a97b60448ef3..b393ecd1e241481ceb8984f98a48af4a1e6313a4 100644 (file)
@@ -38,7 +38,7 @@ void wxContourMainFrame_tool::Process()
             if (bbGetInputImage()!=NULL)
             {
                 std::vector<double> param1=bbGetInputParam1();
-                if (param1.size()==6) 
+                if (param1.size()==6)
                 {
                     int     step        = param1[0];
                     double  isovalue    = param1[1];
@@ -53,6 +53,37 @@ void wxContourMainFrame_tool::Process()
                 }// size
             }  // if Image
         } // Type==1
+
+        if (bbGetInputType()==2)
+        {
+            if (bbGetInputImage()!=NULL)
+            {
+                std::vector<double> param1=bbGetInputParam1();
+                if (param1.size()==3)
+                {
+                    double  isovalue    = param1[0];
+                    int     sampling    = param1[1];
+                    int     method      = param1[2];
+                    
+
+                    std::vector<int> tempVector;
+                    wxContourMainFrame::getInstance()->getInstantVector( tempVector );
+                    int step            = 1;
+                    int min             = tempVector[1] ;
+                    int max             = tempVector[1] ;
+
+                    wxContourMainFrame::getInstance()->onDeleteContoursActSlice();
+                    wxContourMainFrame::getInstance()->onSegmentationAllSlices2(step ,isovalue,sampling,method,min,max, bbGetInputImage() ); // step,isovalue,sampling,method
+                } else {
+                    printf("BBTK warnning!!  wxContourMainFrame_tool box. In Type=1 the Param1 es not complite \n");
+                }// size
+            }  // if Image
+        } // Type==1
+
+        
+
+        
+        
     }
     
 }
index f5fc404637b34f233f4a51fb1429bec86387a5d1..927fced12aa113e8e54f2158eda0e820c1442515 100644 (file)
@@ -38,8 +38,8 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(wxContourMainFrame_tool,bbtk::AtomicBlackBox);
   BBTK_AUTHOR("InfoDev");
   BBTK_DESCRIPTION("No Description.");
   BBTK_CATEGORY("empty");
-  BBTK_INPUT(wxContourMainFrame_tool,Type,"(default 0) Type 0:nothing  1:Isovalue segmentation of Image",int,"");
-  BBTK_INPUT(wxContourMainFrame_tool,Param1,"List of parameters  Type1:[step,isovalue,sampling,method,min,max] ", std::vector<double>,"");
+  BBTK_INPUT(wxContourMainFrame_tool,Type,"(default 0) Type 0:nothing  1:Isovalue segmentation of Image   2:Isovalue segmentation actual slice",int,"");
+  BBTK_INPUT(wxContourMainFrame_tool,Param1,"List of parameters  Type1:[step,isovalue,sampling,method,min,max] Replace all old contours     Type2:[isovalue,sampling,method,iSlice] Replace acutal slice    ", std::vector<double>,"");
   BBTK_INPUT(wxContourMainFrame_tool,Image,"Image", vtkImageData*,"");
 //  BBTK_OUTPUT(wxContourMainFrame_tool,Out,"First output",double,"");
 BBTK_END_DESCRIBE_BLACK_BOX(wxContourMainFrame_tool);
index 888e51f73d4667e880cb2de76254a5a9f0bf9ad5..55bd7ec6d6988c1e430dee7445102545e6498f1c 100644 (file)
@@ -131,14 +131,12 @@ char wxContourMainFrame::COPY = 'C';
                _contourextractdata                     = NULL;
 }
 
-
 void wxContourMainFrame::changeImage(int id, vtkImageData *img)
 {
     if ( id<_images.size() ) _images[id]=img;
     kernelManager->changeImage(id,img);
     _theViewPanel->changeImage(img);
 //    updateInstantImageData();
-    
 }
 
 void wxContourMainFrame::configure(std::vector<vtkImageData*> imgs)
@@ -168,8 +166,7 @@ void wxContourMainFrame::configure(std::vector<vtkImageData*> imgs)
        this->configurePanels( );
 }
 
-
-       wxContourMainFrame* wxContourMainFrame::getInstance(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector<vtkImageData*> images, long style,std::string datadir )
+wxContourMainFrame* wxContourMainFrame::getInstance(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector<vtkImageData*> images, long style,std::string datadir )
        {
                if(instance == NULL)
                {
@@ -178,22 +175,22 @@ void wxContourMainFrame::configure(std::vector<vtkImageData*> imgs)
                return instance;
        }
 
-       std::vector<vtkImageData*> wxContourMainFrame::getVectImages()
+std::vector<vtkImageData*> wxContourMainFrame::getVectImages()
        {
                return kernelManager->getVectImages();
        }
 
-       wxContourMainFrame* wxContourMainFrame::getInstance()
+wxContourMainFrame* wxContourMainFrame::getInstance()
        {
                return instance;
        }
 
-       void wxContourMainFrame::resetInstance()
+void wxContourMainFrame::resetInstance()
        {
                instance->Destroy();
        }
 
-       wxContourMainFrame::~wxContourMainFrame()
+wxContourMainFrame::~wxContourMainFrame()
        {
                delete _contourextractdata;
                deleteAllContours();
@@ -1758,7 +1755,6 @@ void wxContourMainFrame::SegmentationOneSlice( int x, int y, int z, double isova
 #else
        imageReslice->Update();
 #endif
-
        imagedata = imageReslice->GetOutput();
 //EED 2017-01-01 Migration VTK7
 #if VTK_MAJOR_VERSION <= 5
@@ -1767,7 +1763,6 @@ void wxContourMainFrame::SegmentationOneSlice( int x, int y, int z, double isova
 #else
        // ..
 #endif
-
        vtkContourFilter* cntVTK = vtkContourFilter::New( );
 //EED 2017-01-01 Migration VTK7
 #if VTK_MAJOR_VERSION <= 5
@@ -1775,7 +1770,6 @@ void wxContourMainFrame::SegmentationOneSlice( int x, int y, int z, double isova
 #else
        cntVTK->SetInputData( imagedata );
 #endif
-
        cntVTK->SetNumberOfContours( 1 );
        //cntVTK->SetValue( 0, vmin );
 //             cntVTK->SetValue( 0, (range[1]*thr/100) );
@@ -1783,7 +1777,6 @@ void wxContourMainFrame::SegmentationOneSlice( int x, int y, int z, double isova
 //     cntVTK->SetValue( 1, vmax );
        cntVTK->Update( );
        cntVTK->UpdateInformation();
-
        vtkCleanPolyData* cpd = vtkCleanPolyData::New( );
 //EED 2017-01-01 Migration VTK7
 #if VTK_MAJOR_VERSION <= 5
@@ -1794,30 +1787,23 @@ void wxContourMainFrame::SegmentationOneSlice( int x, int y, int z, double isova
        cpd->ConvertLinesToPointsOff( );
        cpd->Update( );
        cpd->UpdateInformation();
-
        vtkPolyDataConnectivityFilter* conn = vtkPolyDataConnectivityFilter::New( );
-
 //     conn->SetExtractionModeToPointSeededRegions();
 //     conn->SetExtractionModeToCellSeededRegions();
 //     conn->SetExtractionModeToSpecifiedRegions();
 //     conn->SetExtractionModeToLargestRegion();
 //     conn->SetExtractionModeToAllRegions();
-
        conn->SetExtractionModeToClosestPointRegion();
-
        //conn->SetMaxRecursionDepth( 3000 );
-
 //EED 2017-01-01 Migration VTK7
 #if VTK_MAJOR_VERSION <= 5
        conn->SetInput( cpd->GetOutput( ) );
 #else
        conn->SetInputData( cpd->GetOutput( ) );
 #endif
-
        conn->SetClosestPoint( x, y, 0 );
        conn->Update( );
        conn->UpdateInformation();
-
        vtkCleanPolyData* cpd2 = vtkCleanPolyData::New( );
 //EED 2017-01-01 Migration VTK7
 #if VTK_MAJOR_VERSION <= 5
@@ -1841,10 +1827,7 @@ vtkstripper->SetJoinContiguousSegments(true);
 #endif
        vtkstripper->Update();
        vtkstripper->UpdateInformation();
-
-
        vtkPolyData* polyDataResult =  vtkstripper->GetOutput();
-
 //EED 2017-01-01 Migration VTK7
 #if VTK_MAJOR_VERSION <= 5
        polyDataResult->Update( );
index e8eca002e5f3e8844f9488b72897a30425799e9c..7bd55c5d098c85f8ef72792d2133ae3d9c587663 100644 (file)
@@ -194,6 +194,7 @@ DEFINE_EVENT_TYPE( wxINSTANT_CHANGE )
        void wxContourViewPanel::changeImage(vtkImageData* img)
     {
                theViewPanel->SetImage(img);
+        img->GetSpacing(last_spacing);
        }
 
        wxVtkMPR2DView * wxContourViewPanel::GetwxVtkMPR2DView()
index 1f6a2cfe61e802f42bd13e1e2b2a00eb00463fac..58338755e78f0011f2bebad92c0d649596e4ad17 100644 (file)
@@ -81,7 +81,7 @@ wxDEFINE_EVENT(wxEVT_UNSELECTED_ROI_POINT, wxCommandEvent);
 wxDEFINE_EVENT(wxEVT_CHANGED_DEEP, wxCommandEvent);
 
 
-       wxVtkBaseView_SceneManager :: wxVtkBaseView_SceneManager( wxVtkBaseView * theWxBaseViewToManage, wxEvtHandler * theEventHandler, double * spc )
+       wxVtkBaseView_SceneManager::wxVtkBaseView_SceneManager( wxVtkBaseView * theWxBaseViewToManage, wxEvtHandler * theEventHandler, double * spc )
        {
                _lastInteraction                                = NULL;
                _lastInteractionName                    = "";
@@ -111,7 +111,7 @@ wxDEFINE_EVENT(wxEVT_CHANGED_DEEP, wxCommandEvent);
        }
 
        //------------------------------------------------------------------------------------------------------------
-       wxVtkBaseView_SceneManager :: ~wxVtkBaseView_SceneManager()
+       wxVtkBaseView_SceneManager::~wxVtkBaseView_SceneManager()
        {
                std::map <std::string, ContourWrap_ViewControl *>::iterator iter = _contours_ViewControl->begin(); 
                int size = _contours_ViewControl->size();
@@ -136,7 +136,7 @@ wxDEFINE_EVENT(wxEVT_CHANGED_DEEP, wxCommandEvent);
        //------------------------------------------------------------------------------------------------------------
        //  Methods for sending events
        //------------------------------------------------------------------------------------------------------------
-       void wxVtkBaseView_SceneManager :: sendEnvent( WXTYPE theEventType, std::string text )
+       void wxVtkBaseView_SceneManager::sendEnvent( WXTYPE theEventType, std::string text )
        {
                if ( _eventHandler != NULL )
                {
@@ -149,19 +149,19 @@ wxDEFINE_EVENT(wxEVT_CHANGED_DEEP, wxCommandEvent);
        //------------------------------------------------------------------------------------------------------------
        //  Attributes getters and setters
        //------------------------------------------------------------------------------------------------------------
-       void wxVtkBaseView_SceneManager :: setWxEventHandler( wxEvtHandler * theEventHandler )
+       void wxVtkBaseView_SceneManager::setWxEventHandler( wxEvtHandler * theEventHandler )
        {
                _eventHandler = theEventHandler;
        }
 
        //------------------------------------------------------------------------------------------------------------
-       void wxVtkBaseView_SceneManager :: setWxVtkViewBase( wxVtkBaseView * theBaseView )
+       void wxVtkBaseView_SceneManager::setWxVtkViewBase( wxVtkBaseView * theBaseView )
        {
                _wxVtk_BaseView = theBaseView;
        }
 
        //------------------------------------------------------------------------------------------------------------
-       wxVtkBaseView * wxVtkBaseView_SceneManager :: getWxVtkViewBase()
+       wxVtkBaseView * wxVtkBaseView_SceneManager::getWxVtkViewBase()
        {
                return _wxVtk_BaseView;
        }
@@ -227,32 +227,25 @@ wxDEFINE_EVENT(wxEVT_CHANGED_DEEP, wxCommandEvent);
                        manViewerContour        = new manualViewContour();
                }
 
-
-
         _lastInteraction = insertWrap( theKeyName, manContourControl, manViewerContour );
                _lastInteractionName = theKeyName;
-
                //Configuring the relations between the contour members representation                  
                manViewerContour->SetModel( manModelContour );
                manViewerContour->SetWxVtkBaseView( _wxVtk_BaseView );
                manViewerContour->SetRange( _widthOfControlPoint );
-               manViewerContour->SetZ( -900 ); 
-
+               manViewerContour->SetZ( -900 );
                manViewerContour->SetSpacing(spc);
-
                manViewerContour->SetColorNormalContour(0, 0, 1);
                manViewerContour->SetColorEditContour(0.5, 0.5, 0.5);
                manViewerContour->SetColorSelectContour(1, 0.8, 0);
                manViewerContour->SetWidthLine(_widthOfContour);
-
                manContourControl->SetModelView( manModelContour , manViewerContour );
                manContourControl->Configure();
                int i,sizeLstPoints = manModelContour->GetSizeLstPoints();
                for ( i=0; i<sizeLstPoints; i++ )
                {
                        manViewerContour->AddPoint();
-               }
-
+               } // for i
                manContourControl->CreateNewManualContour();
                manViewerContour->RefreshContour();                     
                addToScene( theKeyName );