]> Creatis software - creaMaracasVisu.git/commitdiff
Changements dans la class CutModuleMainPanel et CutModuleManager pour ajouter la...
authorRicardo Corredor <Ricardo.Corredor@creatis.insa-lyon.fr>
Wed, 24 Feb 2010 13:56:06 +0000 (13:56 +0000)
committerRicardo Corredor <Ricardo.Corredor@creatis.insa-lyon.fr>
Wed, 24 Feb 2010 13:56:06 +0000 (13:56 +0000)
lib/maracasVisuLib/src/CutModule/interface/CutModelMainPanel.cxx
lib/maracasVisuLib/src/CutModule/interface/CutModelMainPanel.h
lib/maracasVisuLib/src/CutModule/kernel/CutModelManager.cxx
lib/maracasVisuLib/src/CutModule/kernel/CutModelManager.h
lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModelPolygon.cpp

index 4594e2f733e878979a632e51ba731c6ba4893e38..a0622b4176268099f622771cdc72a894a57e2964 100644 (file)
@@ -1,17 +1,17 @@
 /*=========================================================================
 
-  Program:   wxMaracas
-  Module:    $RCSfile: CutModelMainPanel.cxx,v $
-  Language:  C++
-  Date:      $Date: 2009/12/08 13:42:48 $
-  Version:   $Revision: 1.5 $
+Program:   wxMaracas
+Module:    $RCSfile: CutModelMainPanel.cxx,v $
+Language:  C++
+Date:      $Date: 2010/02/24 13:56:06 $
+Version:   $Revision: 1.6 $
 
-  Copyright: (c) 2002, 2003
-  License:
+Copyright: (c) 2002, 2003
+License:
 
-     This software is distributed WITHOUT ANY WARRANTY; without even
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-     PURPOSE.  See the above copyright notice for more information.
+This software is distributed WITHOUT ANY WARRANTY; without even
+the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+PURPOSE.  See the above copyright notice for more information.
 
 =========================================================================*/
 
@@ -39,7 +39,8 @@ CutModelMainPanel::CutModelMainPanel( wxWindow* parent, std::string path)
 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize){
 
        cutmanager=NULL;
-       
+       _isCheck=false;
+       _isFirstTime=true;
        initialize(path);
 
 }
@@ -49,14 +50,20 @@ CutModelMainPanel::~CutModelMainPanel( ){
 }
 
 void CutModelMainPanel::initialize(std::string path){
-       
        cutmanager = new CutModelManager(path);
-
        _panelid = 0;
        _wxauimanager = new wxAuiManager(this); 
-       
+
        wxAuiPaneInfo paneinfo;
-       _wxauimanager->AddPane(new ToolBarCutModel(this),paneinfo.ToolbarPane().Top());         
+
+       //RaC 5-02-2010 Add tabs
+       _notebook = new wxAuiNotebook(this,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxAUI_NB_TOP |wxAUI_NB_TAB_MOVE | wxAUI_NB_SCROLL_BUTTONS);
+
+       _notebook->AddPage(new ToolBarCutModel(_notebook),"Cutter",true);
+       //_wxauimanager->AddPane(new ToolBarCutModel(this),paneinfo.ToolbarPane().Top());       
+       _wxauimanager->AddPane(_notebook,paneinfo.Center());
+       addPolygonCutterTab();
+       _notebook->Update();
 
        _wxauimanager->Update();
 }
@@ -72,9 +79,10 @@ CutModelMainPanel* CutModelMainPanel::getInstance(wxWindow* parent, std::string
 }
 
 /*CutModelMainPanel* CutModelMainPanel::getInstance(){
-       return instance;
+return instance;
 }*/
 
+
 void CutModelMainPanel::setImageData(vtkImageData* img){
        try{
                checkInvariant();
@@ -94,7 +102,7 @@ void CutModelMainPanel::setInteractor(vtkRenderWindowInteractor* interactor){
 }
 
 void CutModelMainPanel::setRenderer(vtkRenderer* renderer){
-    try{
+       try{
                checkInvariant();
                cutmanager->setRenderer(renderer);
        }catch(CutModelException e){
@@ -114,7 +122,7 @@ void CutModelMainPanel::showErrorDialog(std::string str){
 }
 
 void CutModelMainPanel::RemoveActor(int id){
-     try{
+       try{
                checkInvariant();
 
                if(!this->IsBeingDeleted()){
@@ -136,8 +144,53 @@ void CutModelMainPanel::RemoveActor(int id){
        }
 }
 
+//RaC
+void CutModelMainPanel::onCheckChanged(){
+
+       if(_isFirstTime==true){
+               _isFirstTime=false;
+               cutmanager->InitializePolygonInteractorStyle();
+       }
+
+       if(_isCheck==false)
+       {       
+               _isCheck=true;
+               //Draw Polygon
+
+               cutmanager->ParallelProjectionOn();
+               btnExecutePolygonCut->Enable(false);
+               _notebook->GetPage(0)->Enable(false);
+               _radioinsideout->Enable(false);
+               lblMessagePolygon->SetLabel("Drawing polygon...");
+       }
+       else
+       {       
+               _isCheck=false;
+               //Finish Drawing
+               cout<<"Finish Drawing"<<endl;
+               cutmanager->ParallelProjectionOff();
+               btnExecutePolygonCut->Enable(true);
+               _notebook->GetPage(0)->Enable(true);
+               _radioinsideout->Enable(true);
+               lblMessagePolygon->SetLabel("Contour saved! Click on Execute Cut");
+       }
+
+       cutmanager->UpdatePolygon(_isCheck);
+
+}
+
+
+//RaC
+void CutModelMainPanel::onExecuteCutPolygon(){
+       //Cuts Polygon
+       cutmanager->ExecuteCutPolygon(_radioinsideout->GetSelection());
+       lblMessagePolygon->SetLabel("No contour drawed");
+
+}
+
+
 void CutModelMainPanel::onAddCutModel(){
-    try{
+       try{
                checkInvariant();
 
                int id = addNewViewPanel();             
@@ -155,7 +208,7 @@ void CutModelMainPanel::ShowCurrentPanel(int id){
        for(int i = 0; i < viewpanels.size();i++){              
                if(viewpanels[i]->getId()==id){
                        _wxauimanager->GetPane(viewpanels[i]).Show(true);
-            cutmanager->RefreshActor(id);
+                       cutmanager->RefreshActor(id);
                }else{
                        _wxauimanager->GetPane(viewpanels[i]).Show(false);
                }
@@ -163,25 +216,25 @@ void CutModelMainPanel::ShowCurrentPanel(int id){
        _wxauimanager->Update();
 }
 int CutModelMainPanel::addNewViewPanel()throw( CutModelException){
-       
+
        CutModelView* viewpanel = new CutModelView(this,cutmanager->getImageRange());
 
        wxAuiPaneInfo paneinfo0;
        _wxauimanager->AddPane(viewpanel, paneinfo0.DefaultPane().DestroyOnClose().Centre());   
-       
+
        viewpanel->setId(_panelid);
        viewpanels.push_back(viewpanel);        
 
        return viewpanel->getId();
-       
-       
+
+
 }
 CutModelView* CutModelMainPanel::getModelView(int id)throw( CutModelException){
 
        CutModelView* current = NULL;
        for(int i = 0; i < viewpanels.size();i++){
                if(viewpanels[i]->getId()==id){
-            current = viewpanels[i];
+                       current = viewpanels[i];
                }
        }
        if(current == NULL){
@@ -198,7 +251,7 @@ void CutModelMainPanel::onUndo(){
        }catch(CutModelException e){
                showErrorDialog(e.getCause());
        }
-       
+
 }
 
 void CutModelMainPanel::onRedo(){
@@ -210,7 +263,7 @@ void CutModelMainPanel::onRedo(){
        }catch(CutModelException e){
                showErrorDialog(e.getCause());
        }
-       
+
 }
 
 void CutModelMainPanel::changeOpacity(int id,int opacity){
@@ -224,7 +277,7 @@ void CutModelMainPanel::changeOpacity(int id,int opacity){
 }
 
 void CutModelMainPanel::ShowViewBox(int id,bool check){
-    try{
+       try{
                checkInvariant();               
                cutmanager->ShowViewBox(id, check);
 
@@ -244,12 +297,12 @@ void CutModelMainPanel::changeColor(int id,double r,double g,double b){
        }catch(CutModelException e){
                showErrorDialog(e.getCause());
        }
-       
+
 }
 void CutModelMainPanel::ChangeShape(int id,int selection){
        try{
                checkInvariant();
-               
+
                cutmanager->ChangeShape(id, selection);
 
        }catch(CutModelException e){
@@ -257,9 +310,9 @@ void CutModelMainPanel::ChangeShape(int id,int selection){
        }
 }
 void CutModelMainPanel::updateActorDirection(int id){
-    try{
+       try{
                checkInvariant();
-               
+
                cutmanager->updateActorDirection(id);
 
        }catch(CutModelException e){
@@ -284,7 +337,7 @@ void CutModelMainPanel::ExecuteAll(){
 
 }
 vtkImageData* CutModelMainPanel::GetResultImage(){
-    try{
+       try{
                checkInvariant();
                return cutmanager->GetResultImage();
        }catch(CutModelException e){
@@ -310,7 +363,7 @@ void CutModelMainPanel::SaveCutModelData(std::string filename){
 }
 
 void CutModelMainPanel::LoadCutModelData(std::string filename){
-    cutmanager->LoadCutModelData(filename);
+       cutmanager->LoadCutModelData(filename);
 }
 
 void CutModelMainPanel::SetType(int type){
@@ -321,13 +374,53 @@ int CutModelMainPanel::GetType(){
        return _type;
 }
 
+void CutModelMainPanel::addPolygonCutterTab(){
+       wxPanel *panel = new wxPanel(_notebook);
+       panel->SetAutoLayout(true);
+       wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); 
+       panel->SetSizer(sizer);
+       sizer->AddSpacer(20);
+
+       wxCheckBox *item = new wxCheckBox(panel,10,"Draw Polygon",wxDefaultPosition,wxDefaultSize,0,wxDefaultValidator,"");
+       item->SetValue(false);
+       Connect(item->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)(&PolygonCutterEventHandlerCutModel::onCheckChanged));
+       sizer->Add(item, 0, wxALIGN_LEFT);
+
+       lblMessagePolygon = new wxStaticText(panel,30,"No contour drawed",wxDefaultPosition,wxDefaultSize,0,"");
+       sizer->Add(lblMessagePolygon, 0, wxALIGN_LEFT);
+
+       wxString choices0[2];
+       choices0[0] = _T("inside");
+       choices0[1] = _T("outside");
+       _radioinsideout = new  wxRadioBox(panel,-1,_T(""), wxDefaultPosition, wxDefaultSize,2,choices0);
+       sizer->Add(_radioinsideout, wxALIGN_LEFT);
+
+       btnExecutePolygonCut = new wxButton(panel,20,"Execute Cut",wxDefaultPosition,wxDefaultSize,0,wxDefaultValidator,"");
+       Connect(btnExecutePolygonCut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)(&PolygonCutterEventHandlerCutModel::onExecuteCutPolygon));  
+       sizer->Add(btnExecutePolygonCut, 0, wxALIGN_LEFT);
+
+
+       _notebook->AddPage(panel, "Polygon Cutter", false);
+
+}
+
+
+void PolygonCutterEventHandlerCutModel::onCheckChanged(wxCommandEvent& event){
+       CutModelMainPanel::getInstance()->onCheckChanged();
+}
+
+void PolygonCutterEventHandlerCutModel::onExecuteCutPolygon(wxCommandEvent& event){
+       CutModelMainPanel::getInstance()->onExecuteCutPolygon();
+}
+
+
+
 /**
 **
 **/
 ToolBarCutModel::ToolBarCutModel(wxWindow * parent)
 : wxToolBar(parent, -1, wxDefaultPosition, wxDefaultSize)
 {
-
        wxBitmap bitmap10(Add_xpm);
        this->AddTool(10, wxString(_T("Add")),bitmap10);
 
index 96891b2061d1b0928b750c5b4a4ce1a6144550d7..e291c8b7469abb333fc581a0726058a11a9cfa53 100644 (file)
@@ -1,17 +1,17 @@
 /*=========================================================================
 
-  Program:   wxMaracas
-  Module:    $RCSfile: CutModelMainPanel.h,v $
-  Language:  C++
-  Date:      $Date: 2009/12/08 13:42:48 $
-  Version:   $Revision: 1.4 $
+Program:   wxMaracas
+Module:    $RCSfile: CutModelMainPanel.h,v $
+Language:  C++
+Date:      $Date: 2010/02/24 13:56:06 $
+Version:   $Revision: 1.5 $
 
-  Copyright: (c) 2002, 2003
-  License:
+Copyright: (c) 2002, 2003
+License:
 
-     This software is distributed WITHOUT ANY WARRANTY; without even
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-     PURPOSE.  See the above copyright notice for more information.
+This software is distributed WITHOUT ANY WARRANTY; without even
+the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+PURPOSE.  See the above copyright notice for more information.
 
 =========================================================================*/
 
@@ -23,6 +23,7 @@
 #include <wx/treebook.h>
 #include "wx/aui/aui.h"
 #include <wx/toolbar.h>
+
 #include <iostream>
 #include "marTypes.h"
 
 #include "vtkImageData.h"
 #include "vtkRenderWindowInteractor.h"
 
+//RaC 02-2010 Add tabs
+#include <wx/aui/auibook.h>
+#include <wx/panel.h>
+#include <wx/checkbox.h>
+#include <wx/button.h>
+#include <wx/sizer.h>
+#include <wx/stattext.h>
+#include <wx/radiobox.h>
+
+
 
 class  creaMaracasVisu_EXPORT  CutModelMainPanel : public wxPanel
 {
 
 public:
-       
-    ~CutModelMainPanel( );
+
+       ~CutModelMainPanel( );
 
        static CutModelMainPanel* getInstance(wxWindow* parent=NULL, std::string path ="");
 
@@ -54,6 +65,12 @@ public:
 
        void initialize(std::string path);
 
+       //RaC PolygonCutter changes
+       void onCheckChanged();
+       void onExecuteCutPolygon();
+       void UpdatePolygon(bool isChecked);
+       void UpdatePolygon();
+
        void onAddCutModel();
 
        void onUndo();
@@ -65,7 +82,7 @@ public:
        void ShowViewBox(int id,bool check);
 
        void ChangeShape(int id,int selection);
-       
+
        void changeColor(int id,double r,double g,double b);
 
        void updateActorDirection(int id);
@@ -88,7 +105,7 @@ public:
 
        int GetType();
 
-       
+
 private:
 
        CutModelMainPanel( wxWindow* parent, std::string path);
@@ -109,39 +126,65 @@ private:
 
        wxAuiManager* _wxauimanager;
 
+       int addNewViewPanel()throw( CutModelException);
+
+       CutModelView* getModelView(int id)throw( CutModelException);
+
+       int _panelid;
+
+       int _type;
+
+       //RaC 02-2010 Add tabs
+       wxAuiNotebook* _notebook;
+
+       //RaC Adds Tab to cut a prism with the polygon as the base
+       void addPolygonCutterTab();
 
-        int addNewViewPanel()throw( CutModelException);
+       bool _isCheck;
 
-        CutModelView* getModelView(int id)throw( CutModelException);
+       bool _isFirstTime;
 
-        int _panelid;
+       wxButton *btnExecutePolygonCut;
+       wxStaticText* lblMessagePolygon;
+       wxRadioBox* _radioinsideout;
 
-        int _type;
 };
 
 
 class ToolBarEventHandlerCutModel : public wxEvtHandler{
 
-       public:
-               ToolBarEventHandlerCutModel();
-               ~ToolBarEventHandlerCutModel();
+public:
+       ToolBarEventHandlerCutModel();
+       ~ToolBarEventHandlerCutModel();
+
+       void onAdd(wxCommandEvent& event);
+
+       void onUndo(wxCommandEvent& event);
 
-               void onAdd(wxCommandEvent& event);
+       void onRedo(wxCommandEvent& event);
 
-               void onUndo(wxCommandEvent& event);
+       void onExecuteAll(wxCommandEvent& event);
 
-               void onRedo(wxCommandEvent& event);
+private:
 
-               void onExecuteAll(wxCommandEvent& event);
+       DECLARE_EVENT_TABLE()
+};
 
-       private:
+class PolygonCutterEventHandlerCutModel : public wxEvtHandler{
+public:
+
+       PolygonCutterEventHandlerCutModel(): wxEvtHandler(){};
+       ~PolygonCutterEventHandlerCutModel(){};
+
+       void onCheckChanged(wxCommandEvent& event);
+       void onExecuteCutPolygon(wxCommandEvent& event);
+
+};
 
-               DECLARE_EVENT_TABLE()
-       };
 
 class ToolBarCutModel : public wxToolBar{
 
-       
+
 public:
        ToolBarCutModel(wxWindow * parent);
        ~ToolBarCutModel(void);
index 9cec5c6fefa0bd524b55ade0166508cae0e3265a..23fdee919684fd55f50cd605c4693fb95dff47a1 100644 (file)
@@ -1,17 +1,17 @@
 /*=========================================================================
 
-  Program:   wxMaracas
-  Module:    $RCSfile: CutModelManager.cxx,v $
-  Language:  C++
-  Date:      $Date: 2010/02/08 15:20:22 $
-  Version:   $Revision: 1.6 $
+Program:   wxMaracas
+Module:    $RCSfile: CutModelManager.cxx,v $
+Language:  C++
+Date:      $Date: 2010/02/24 13:56:08 $
+Version:   $Revision: 1.7 $
 
-  Copyright: (c) 2002, 2003
-  License:
+Copyright: (c) 2002, 2003
+License:
 
-     This software is distributed WITHOUT ANY WARRANTY; without even
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-     PURPOSE.  See the above copyright notice for more information.
+This software is distributed WITHOUT ANY WARRANTY; without even
+the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+PURPOSE.  See the above copyright notice for more information.
 
 =========================================================================*/
 #include "CutModelManager.h"
@@ -27,11 +27,11 @@ CutModelManager::CutModelManager(std::string path){
        _interactor = NULL;     
        _render = NULL;
        _currentaction=0;
-       
+
 }
 CutModelManager::~CutModelManager(){
        std::string files = _path;
-    files+="/infounrd_0_fig_0.info";   
+       files+="/infounrd_0_fig_0.info";        
        remove(files.c_str());  
        _vectordata.clear();
        _img = NULL;
@@ -41,6 +41,10 @@ CutModelManager::~CutModelManager(){
 }
 
 
+vtkImageData* CutModelManager::getImageData(){
+       return _img2;
+}
+
 void CutModelManager::setImageData(vtkImageData* img){
        int type = CutModelMainPanel::getInstance()->GetType();
        if( type == 0)
@@ -48,7 +52,7 @@ void CutModelManager::setImageData(vtkImageData* img){
                _img = img;
 
                if(_img2!=NULL){
-               _img2->Delete();
+                       _img2->Delete();
                }
                _img2 = vtkImageData::New();
                _img2->SetExtent(_img->GetExtent());
@@ -84,7 +88,7 @@ void CutModelManager::setRenderer(vtkRenderer* renderer){
 void CutModelManager::onAddCutModel(int id, vtkCommand* observer) throw( CutModelException){
        checkInvariant();
 
-       
+
        CutModelData* data = new CutModelData(id,_interactor, observer, _img);
        _vectordata.push_back(data);
 
@@ -146,7 +150,7 @@ CutModelData* CutModelManager::getCutModelData(int id)throw( CutModelException){
                }
        }
        if(current ==NULL){
-               
+
                throw CutModelException("Data not found");
        }
        return current;
@@ -156,7 +160,7 @@ void CutModelManager::updateActorDirection(int id)throw( CutModelException){
        checkInvariant();
        CutModelData* current = getCutModelData(id);
        current->udapteActorDirection();
-       
+
 }
 
 void CutModelManager::changeColor(int id,double r,double g,double b)throw( CutModelException){
@@ -167,29 +171,29 @@ void CutModelManager::changeColor(int id,double r,double g,double b)throw( CutMo
        _render->Render();
 }
 void CutModelManager::RemoveActor(int id)throw( CutModelException){
-       
-               checkInvariant();
-
-               CutModelData* current = getCutModelData(id);
-               for(int i = 0; i < _vectordata.size()-1;i++){
-                       if(_vectordata[i]->getId()==id){                                
-                               for(int j = i; j < _vectordata.size()-1;j++){
-                    _vectordata[j]=_vectordata[j+1];
-                               }
-                               i = _vectordata.size();
+
+       checkInvariant();
+
+       CutModelData* current = getCutModelData(id);
+       for(int i = 0; i < _vectordata.size()-1;i++){
+               if(_vectordata[i]->getId()==id){                                
+                       for(int j = i; j < _vectordata.size()-1;j++){
+                               _vectordata[j]=_vectordata[j+1];
                        }
+                       i = _vectordata.size();
                }
-               _render->RemoveViewProp(current->getActor());           
-               //_render->RemoveViewProp(current->get
-               delete current;
-               _vectordata.pop_back();
-               _render->Render();
-       
+       }
+       _render->RemoveViewProp(current->getActor());           
+       //_render->RemoveViewProp(current->get
+       delete current;
+       _vectordata.pop_back();
+       _render->Render();
+
 }
 
 void CutModelManager::ExecuteCut(int id, double* range, bool isinside)throw( CutModelException){
-    checkInvariant();
-               
+       checkInvariant();
+
        CutModelData* current = getCutModelData(id);
        current->ExecuteCut(range, isinside,_img2);
 
@@ -204,12 +208,12 @@ void CutModelManager::ExecuteCut(int id, double* range, bool isinside)throw( Cut
 }
 
 vtkImageData* CutModelManager::GetResultImage(){
-        checkInvariant();
-     return _img2;
+       checkInvariant();
+       return _img2;
 }
 
 void CutModelManager::RefreshActor(int id){
-     checkInvariant();
+       checkInvariant();
        CutModelData* current = getCutModelData(id);    
        _render->RemoveActor(current->getActor());
        _render->AddActor(current->getActor()); 
@@ -219,24 +223,24 @@ void CutModelManager::RefreshActor(int id){
 
 void CutModelManager::SaveCutModelData(std::string filename)throw( CutModelException){ 
 
-       
+
        throw CutModelException("not implemented");
-       
-       
-       
-       
+
+
+
+
 }
 
 
 
 void CutModelManager::LoadCutModelData(std::string filename)throw( CutModelException){
-       
+
        throw CutModelException("not implemented");
-       
+
 }
 
 CutModelSaveBinInfo* CutModelManager::AddActionUndo(int idc, UNDOTYPE type)throw( CutModelException){
-       
+
        for(int i = _undoredo.size()-1; i > _currentaction;i--){
                delete _undoredo[i];
                _undoredo.pop_back();           
@@ -252,12 +256,12 @@ CutModelSaveBinInfo* CutModelManager::AddActionUndo(int idc, UNDOTYPE type)throw
 
        _currentaction++;// = _undoredo.size();
        //std::cout<<"current index "<<_currentaction;
-               
+
        return cutmodel;
 }
 
 int CutModelManager::Undo()    throw( CutModelException){
- //&& _currentaction < _undoredo.size()
      //&& _currentaction < _undoredo.size()
        if(_currentaction > 0){
                int tempaction = _currentaction-1;
                CutModelSaveBinInfo* currentundo = _undoredo[tempaction];
@@ -305,3 +309,98 @@ int CutModelManager::Redo()        throw( CutModelException){
        }
        return -1;
 }
+
+void CutModelManager::ParallelProjectionOn(){
+       _render->GetActiveCamera()->ParallelProjectionOn();
+}
+
+void CutModelManager::ParallelProjectionOff(){
+       _render->GetActiveCamera()->ParallelProjectionOff();
+}
+
+
+//RaC
+void CutModelManager::UpdatePolygon(bool mode)
+{
+       if(mode)
+       {
+               cutterstyle->Delete();
+               cutterstyle = vtkInteractorStyleCutter::New();
+
+               cutterstyle->SetInteractor ( _interactor );
+               _interactor ->SetInteractorStyle( cutterstyle );
+       }
+       else
+       {
+               cutterstyle->VisibilityOff();
+
+               loop = vtkImplicitSelectionLoop::New();
+               mapper = vtkPolyDataMapper::New();
+               if(cutterstyle->Finished())
+               {
+                       if(actor3D != NULL)
+                       {
+                               _render->RemoveActor(actor3D);
+                       }
+
+                       loop->SetLoop( cutterstyle->GetLoopPoints() );
+                       loop->SetNormal( cutterstyle->GetDirection());
+
+
+                       /// Printing Points
+                       int numPoints = cutterstyle->GetLoopPoints()->GetNumberOfPoints();
+                       contourDirection = cutterstyle->GetDirection();
+
+                       contourPoints = cutterstyle->GetLoopPoints();
+
+                       _polygonCutter = new CutModelPolygon();
+
+                       cout<<"RaC ContourDrawer::Update Printing points"<<endl;
+                       for(int t=0;t<numPoints;t++)
+                       {
+                               double point[3];
+                               cutterstyle->GetLoopPoints()->GetPoint(t,point);
+                               cout<<"Initial Point:"<<t<<" XX:"<<point[0]<<" YY:"<<point[1]<<" ZZ:"<<point[2]<<endl;
+                       }
+                       cout<<endl;
+
+                       sample = vtkSampleFunction::New();
+
+                       sample->SetImplicitFunction(loop);
+                       sample->CappingOn();                    
+
+                       contour = vtkContourFilter::New();
+                       contour->SetInput((vtkDataObject *)sample->GetOutput());
+                       contour->SetValue(0,1);
+
+                       actor = contour->GetOutput();
+
+                       actor3D = vtkActor::New();                      
+                       mapper->SetInput(actor);                         
+                       mapper->SetScalarModeToUseCellData();
+                       actor3D->SetMapper( mapper);
+                       _render->AddActor(actor3D);                     
+               }               
+
+               interactorstyle->SetInteractor (  _interactor );
+               _interactor->SetInteractorStyle( interactorstyle );
+       } 
+
+       _interactor->Render();
+       _render->ResetCameraClippingRange();
+}
+void CutModelManager::ExecuteCutPolygon(bool inOutCut){
+
+       _polygonCutter->setInImage(_img2);
+       _polygonCutter->setPoints(contourPoints);
+       _polygonCutter->setDirection(contourDirection);
+       _polygonCutter->processOutImage(inOutCut);
+}
+
+void CutModelManager::InitializePolygonInteractorStyle(){
+
+       cutterstyle = vtkInteractorStyleCutter::New();          
+       interactorstyle = vtkInteractorStyleTrackballCamera ::New();
+       interactorstyle->SetInteractor (  _interactor );
+       _interactor->SetInteractorStyle( interactorstyle );
+}
index 3d84c8f3c48f453ba77c03cea9c9fe688fffd341..abc8d3e95686142707cf1d225f6da9b39aa95075 100644 (file)
@@ -1,17 +1,17 @@
 /*=========================================================================
 
-  Program:   wxMaracas
-  Module:    $RCSfile: CutModelManager.h,v $
-  Language:  C++
-  Date:      $Date: 2009/12/08 13:42:39 $
-  Version:   $Revision: 1.4 $
-
-  Copyright: (c) 2002, 2003
-  License:
-  
-     This software is distributed WITHOUT ANY WARRANTY; without even 
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
-     PURPOSE.  See the above copyright notice for more information.
+Program:   wxMaracas
+Module:    $RCSfile: CutModelManager.h,v $
+Language:  C++
+Date:      $Date: 2010/02/24 13:56:08 $
+Version:   $Revision: 1.5 $
+
+Copyright: (c) 2002, 2003
+License:
+
+This software is distributed WITHOUT ANY WARRANTY; without even 
+the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+PURPOSE.  See the above copyright notice for more information.
 
 =========================================================================*/
 
 #include "vtkImageData.h"
 #include "vtkRenderWindowInteractor.h"
 #include "vtkRenderer.h"
+#include "wxVtkBaseView.h"
+#include "wxVtk3DBaseView.h"
 #include <vtkPolyDataWriter.h>
 
 #include "CutModelException.h"
 #include "CutModelData.h"
 #include "CutModelSaveBinInfo.h"
 
+#include "vtkPoints.h"
+#include "CutModelPolygon.h"
+#include "vtkInteractorStyleTrackballCamera.h"
+#include "vtkInteractorStyleCutter.h"
+#include "wxVTKRenderWindowInteractor.h"
+#include "vtkImplicitSelectionLoop.h"
+#include "vtkPolyDataMapper.h"
+#include "vtkSampleFunction.h"
+#include "vtkContourFilter.h"
+#include "vtkPolyData.h"
+#include "vtkActor.h"
+
 
 
 class CutModelManager  {
@@ -44,10 +58,14 @@ public:
 
        void setImageData(vtkImageData* img);
 
+       vtkImageData* getImageData();
+
        void setInteractor(vtkRenderWindowInteractor* interactor);
 
        void setRenderer(vtkRenderer* renderer);
-       
+
+       void setBaseView(wxVtkBaseView* baseView);
+
        void onAddCutModel(int id, vtkCommand* observer) throw( CutModelException);
 
        double* getImageRange()throw( CutModelException);
@@ -80,8 +98,18 @@ public:
 
        int Redo()throw( CutModelException);
 
+       void ParallelProjectionOn();
+
+       void ParallelProjectionOff();
+
+       void UpdatePolygon(bool mode);
+
+       void ExecuteCutPolygon(bool inOutCut);
+
+       void InitializePolygonInteractorStyle();
+
 private:
-       
+
        int _currentaction;
 
        void checkInvariant() throw( CutModelException);
@@ -94,7 +122,19 @@ private:
        std::vector<CutModelData*> _vectordata;
        std::vector<CutModelSaveBinInfo*> _undoredo;
        CutModelData* getCutModelData(int id)throw( CutModelException);
-       
+
+       CutModelPolygon* _polygonCutter;
+       vtkPoints *contourPoints ;
+       double *contourDirection;       
+       vtkInteractorStyleTrackballCamera *interactorstyle;
+       vtkInteractorStyleCutter *cutterstyle;
+       vtkContourFilter *contour;
+       vtkSampleFunction *sample;
+       vtkPolyData *actor;
+       vtkActor *actor3D;
+       vtkImplicitSelectionLoop *loop;
+       vtkPolyDataMapper *mapper;
+
 };
 
 #endif 
index 422e0936245b08adacef5bd27b43c383966084d0..dead6db868955deba9bd041ea289ae60ec4e45f4 100644 (file)
@@ -104,8 +104,6 @@ int ContourExtractData::AnalisisContourInsideV2(int x, int y, int iContour )
        int result      = 0;
        int i;
 
-       //cout<<"RaC ContourExtractData::AnalisisContourInsideV2-iContour:"<<iContour<<" y:"<<y<<endl; 
-
        int nps=_lstlstlstVecX1[iContour][y].size();
 
        double x1,y1,x2,y2;
index 7ed909728ec9f4f950dc1ad61876926a787f487f..0639b0c611e012aecb665b68f660aeae0fcafe3a 100644 (file)
@@ -226,7 +226,6 @@ bool manualContourBaseControler::OnRightButtonDown()
 
                SetCompleteCreation( true );
                SetKeyBoardMoving( false );
-               cout<<"RaC manualContourBaseControler::OnRightButtonDown"<<endl;
                this->GetManualContourModel()->SetCloseContour(true);
                MouseClickRight(X,Y);
        }
index 6019ffb17280cb475e485f99c4fcc076b34034dd..1cab0da8940ec9a88cd802426ec995a2e30f19e1 100644 (file)
@@ -39,7 +39,6 @@ int manualContourModelPolygon::GetTypeModel() //virtual
 //----------------------------------------------------------------
 void manualContourModelPolygon::GetSpline_i_Point(int i, double *x, double *y, double *z) // virtual
 {
-       //cout<<"RaC manualContourModelPolygon::GetSpline_i_Point lstPoints:"<<_lstPoints.size()<<" pointsSpline:"<<GetNumberOfPointsSpline()<<endl;
        if(i>=_lstPoints.size())
        {
                i=0;