]> Creatis software - creaContours.git/commitdiff
#3396 Clean Contours With Empty Points
authoreduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Thu, 9 Jan 2025 07:35:23 +0000 (08:35 +0100)
committereduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Thu, 9 Jan 2025 07:35:23 +0000 (08:35 +0100)
lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx
lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h
lib/Interface_ManagerContour_NDimensions/wxVtkBaseView_SceneManager.cxx

index 65cba57c91c60e1b82d34b394155fe3a86d366f5..bacc23c4178b4f1a682d6335d569f607c2fa9274 100644 (file)
@@ -399,6 +399,10 @@ void wxContourMainFrame::createContour( int typeContour )
        std::vector<int> instantVector;
        _instantPanel->getInstant( instantVector );
 
+    //EED 2025-01-07
+    CleanContoursWithEmptyPoints();
+    
+    //EED 2024-12-28
     std::vector<std::string> lstOutlinesNames = kernelManager->getOutlinesNameAtInstant(instantVector);
     int sizeLstOutlinesNames = lstOutlinesNames.size();
 
@@ -522,7 +526,7 @@ void wxContourMainFrame::onDeleteContour()
 JCP 19 - 11 - 08*/
 }
 
-void wxContourMainFrame :: deleteContours( std::vector<std::string>  keyNamesVector )
+void wxContourMainFrame::deleteContours( std::vector<std::string>  keyNamesVector )
 {
        int i,size=keyNamesVector.size();
        for (i=0;i<size;i++)
@@ -531,24 +535,21 @@ void wxContourMainFrame :: deleteContours( std::vector<std::string>  keyNamesVec
        } // for i
 }
 
-void wxContourMainFrame :: deleteContour( std::string theKeyName )
+void wxContourMainFrame::deleteContour( std::string theKeyName )
 {
        /*
        manualContourModel                      * cModel;
        manualViewBaseContour           * cViewer;
        manualContourBaseControler      * cControler;
-
        ContourWrap_ViewControl *conwrapviewControl =  _theViewPanel->getSceneManager()->getContourWrap_ViewControlOf( theKeyName );
        cControler      = conwrapviewControl->getControler();*/
-
+    
        //JCP 21 - 11 - 2008
        bool isedit = _theViewPanel->isEditableCControler(theKeyName);
        bool ispartofstaticlst = kernelManager->IsPartOfStaticList(theKeyName);
-
        if (isedit  && ispartofstaticlst)
        {
                _theViewPanel->removeFromScene(theKeyName);
-
                kernelManager->deleteCModel(theKeyName);
                //_theViewPanel->getSceneManager()->removeFromScene( theKeyName );
                //cViewer               = conwrapviewControl->getViewer();
@@ -563,42 +564,57 @@ void wxContourMainFrame :: deleteContour( std::string theKeyName )
 
 void wxContourMainFrame::onDeleteContoursActSlice()
 {
+    //EED 2025-01-07
+    CleanContoursWithEmptyPoints();
+    
        //JCP 20-10-08 Undo redo implementation
        saveState();
        //JCP 20-10-08 Undo redo implementation
-
        std::vector<int> tempVector;
        getInstantVector( tempVector );
        deleteContours( getOutlinesName( tempVector[1] ) );
 //     deleteContours( (std::vector<std::string>)_theViewPanel->getSceneManager()->GetlstContoursNameActualSlice() );
 }
 
-void wxContourMainFrame::onDeleteAllContours(){
+void wxContourMainFrame::CleanContoursWithEmptyPoints()
+{
+    std::vector<int> tempVector;
+    getInstantVector( tempVector );
+//    std::vector<std::string> keyNamesVector = getOutlinesName( tempVector[1] );
+    std::vector<std::string> keyNamesVector = kernelManager->GetLstNameThings();
+    int i,size=keyNamesVector.size();
+    for ( i=0 ; i<size ; i++ )
+    {
+        manualBaseModel* manualModel = kernelManager->getOutlineByKeyName( keyNamesVector[i] );
+        if ( manualModel->GetSizeLstPoints()==0 )
+        {
+            deleteContour( keyNamesVector[i] );
+        } // if
+    } // for i
+}
+
+void wxContourMainFrame::onDeleteAllContours()
+{
        //JCP 20-10-08 Undo redo implementation
        saveState();
        deleteAllContours();
 }
 
-void wxContourMainFrame::deleteAllContours(){
+void wxContourMainFrame::deleteAllContours()
+{
        //JCP 20-10-08 Undo redo implementation
-
        wxBusyCursor wait;
        std::vector<int> tempVector;
        _instantPanel->getInstant( tempVector );
-
 //JCP --08-09-2008 When using a diferent interface the _mbarrangeDeleteAll might not be initialize
 //             the values in GetStart and GetEnd will then not be initialize also.
 //             We use instead the values given when initializing the _deletepanel.
-
        //int minZ = _mbarrangeDeleteAll->GetStart();
        //int maxZ = _mbarrangeDeleteAll->GetEnd();
        int minZ, maxZ;
-
        minZ = 0;
        maxZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
-
 //JCP --08-09-2008
-
        _theViewPanel->getSceneManager()->removeSceneContours( );
        _theViewPanel->getSceneManager()->removeAllOutlines();
        kernelManager->removeAllOutlines();
@@ -1043,7 +1059,9 @@ void wxContourMainFrame::onSave()
 //AD: 29-05-09
 void wxContourMainFrame::saveFileWithContours( std::string filename )
 {
-
+    //EED 2025-01-07
+    CleanContoursWithEmptyPoints();
+    
        FILE *pFile=fopen(filename.c_str(),"w+");
 
 //CMRU 03-09-09-----------------------------------------------------------------------------------------------
index 12e07e1e6f7ec27e9b38bfaeee2127c4071379e9..b4b3ad5f675f60099e07c9a61ed83683b775f44f 100644 (file)
@@ -331,14 +331,14 @@ class wxContourMainFrame : public wxPanel {
        void    SetXY(int x,int y);
     void    ResetCamera();
 
-    void SetMaxContoursByInstant(int max);
+    void    CleanContoursWithEmptyPoints();
+    void    SetMaxContoursByInstant(int max);
     
 private:
        //------------------------------------------------------------------------------------------------------------
        //  Private methods
        //------------------------------------------------------------------------------------------------------------
 
-
        //------------------------------------------------------------------------------------------------------------
        // Attributtes
        //------------------------------------------------------------------------------------------------------------
@@ -395,9 +395,7 @@ private:
 
     void saveState();
     void loadState(std::string filename);
-
 //     void loadContours( FILE *pFile, bool staticContour );
-
        void saveFileWithContours( std::string filename );
        void onLoadContours(std::string fileNameContourROI, bool interactiveInterface);
        void SetZForAllContours(int pz);
@@ -415,12 +413,9 @@ private:
        std::string                 _imageLocation;
        std::string                 _fileLocation;
 //------------------------------------------------------------------------------------------------------------
-
        wxFrame                                         *_frameShowResultImages;
-
 //EED 2025-01-01
     int                         _maxContoursByInstant;
-
 };
 
 #endif
index 58338755e78f0011f2bebad92c0d649596e4ad17..c484a8b01c9f46be35c2449298545c8d52e3007d 100644 (file)
@@ -179,6 +179,7 @@ wxDEFINE_EVENT(wxEVT_CHANGED_DEEP, wxCommandEvent);
                        _lastInteraction->getControler()->SetActive( false );
                        this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
                }
+        
                manualContourBaseControler *manContourControl;
                manualViewBaseContour           *manViewerContour;
                // Creating the view manualViewContour and the manualContourControler
@@ -227,9 +228,9 @@ wxDEFINE_EVENT(wxEVT_CHANGED_DEEP, wxCommandEvent);
                        manViewerContour        = new manualViewContour();
                }
 
-        _lastInteraction = insertWrap( theKeyName, manContourControl, manViewerContour );
-               _lastInteractionName = theKeyName;
-               //Configuring the relations between the contour members representation                  
+        _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 );
@@ -249,7 +250,8 @@ wxDEFINE_EVENT(wxEVT_CHANGED_DEEP, wxCommandEvent);
                manContourControl->CreateNewManualContour();
                manViewerContour->RefreshContour();                     
                addToScene( theKeyName );
-       }
+}
+
 //------------------------------------------------------------------------------------------------------------
 void wxVtkBaseView_SceneManager :: configureSelectionROI( double * spc )
 {