From b790e40646f48f8cac2377aa3aca9b9b5ee5cf92 Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Tue, 1 Oct 2024 10:43:15 +0200 Subject: [PATCH] Clean code --- bbtk/bbs/boxes/ContourReferenceStep.bbg | 15 ++++++--- bbtk/bbs/boxes/ContourReferenceStep.bbs | 1 + .../bbcreaContourswxContourMainFrame_tool.cxx | 33 ++++++++++++++++++- .../bbcreaContourswxContourMainFrame_tool.h | 4 +-- .../wxContourMainFrame.cxx | 27 +++------------ .../wxContourViewPanel.cxx | 1 + .../wxVtkBaseView_SceneManager.cxx | 23 +++++-------- 7 files changed, 60 insertions(+), 44 deletions(-) diff --git a/bbtk/bbs/boxes/ContourReferenceStep.bbg b/bbtk/bbs/boxes/ContourReferenceStep.bbg index 2530287..de1cf1e 100644 --- a/bbtk/bbs/boxes/ContourReferenceStep.bbg +++ b/bbtk/bbs/boxes/ContourReferenceStep.bbg @@ -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 diff --git a/bbtk/bbs/boxes/ContourReferenceStep.bbs b/bbtk/bbs/boxes/ContourReferenceStep.bbs index 76812cc..29b57dd 100644 --- a/bbtk/bbs/boxes/ContourReferenceStep.bbs +++ b/bbtk/bbs/boxes/ContourReferenceStep.bbs @@ -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 diff --git a/bbtk/src/bbcreaContourswxContourMainFrame_tool.cxx b/bbtk/src/bbcreaContourswxContourMainFrame_tool.cxx index aa05239..b393ecd 100644 --- a/bbtk/src/bbcreaContourswxContourMainFrame_tool.cxx +++ b/bbtk/src/bbcreaContourswxContourMainFrame_tool.cxx @@ -38,7 +38,7 @@ void wxContourMainFrame_tool::Process() if (bbGetInputImage()!=NULL) { std::vector 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 param1=bbGetInputParam1(); + if (param1.size()==3) + { + double isovalue = param1[0]; + int sampling = param1[1]; + int method = param1[2]; + + + std::vector 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 + + + + + } } diff --git a/bbtk/src/bbcreaContourswxContourMainFrame_tool.h b/bbtk/src/bbcreaContourswxContourMainFrame_tool.h index f5fc404..927fced 100644 --- a/bbtk/src/bbcreaContourswxContourMainFrame_tool.h +++ b/bbtk/src/bbcreaContourswxContourMainFrame_tool.h @@ -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,""); + 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,""); BBTK_INPUT(wxContourMainFrame_tool,Image,"Image", vtkImageData*,""); // BBTK_OUTPUT(wxContourMainFrame_tool,Out,"First output",double,""); BBTK_END_DESCRIBE_BLACK_BOX(wxContourMainFrame_tool); diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx index 888e51f..55bd7ec 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx +++ b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx @@ -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 imgs) @@ -168,8 +166,7 @@ void wxContourMainFrame::configure(std::vector imgs) this->configurePanels( ); } - - wxContourMainFrame* wxContourMainFrame::getInstance(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector images, long style,std::string datadir ) +wxContourMainFrame* wxContourMainFrame::getInstance(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector images, long style,std::string datadir ) { if(instance == NULL) { @@ -178,22 +175,22 @@ void wxContourMainFrame::configure(std::vector imgs) return instance; } - std::vector wxContourMainFrame::getVectImages() +std::vector 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( ); diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx b/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx index e8eca00..7bd55c5 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx +++ b/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx @@ -194,6 +194,7 @@ DEFINE_EVENT_TYPE( wxINSTANT_CHANGE ) void wxContourViewPanel::changeImage(vtkImageData* img) { theViewPanel->SetImage(img); + img->GetSpacing(last_spacing); } wxVtkMPR2DView * wxContourViewPanel::GetwxVtkMPR2DView() diff --git a/lib/Interface_ManagerContour_NDimensions/wxVtkBaseView_SceneManager.cxx b/lib/Interface_ManagerContour_NDimensions/wxVtkBaseView_SceneManager.cxx index 1f6a2cf..5833875 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxVtkBaseView_SceneManager.cxx +++ b/lib/Interface_ManagerContour_NDimensions/wxVtkBaseView_SceneManager.cxx @@ -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 ::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; iAddPoint(); - } - + } // for i manContourControl->CreateNewManualContour(); manViewerContour->RefreshContour(); addToScene( theKeyName ); -- 2.47.1