Copie de wxSTLWidget_03.cxx

Go to the documentation of this file.
00001 
00002 #include "vtkObjectFactory.h"
00003 
00004 #include "vtkActor.h"
00005 #include "vtkCylinderSource.h"
00006 #include "vtkPolyDataMapper.h"
00007 #include "vtkRenderer.h"
00008 #include "vtkRenderWindow.h"
00009 #include "vtkRenderWindowInteractor.h"
00010 #include "vtkProperty.h"
00011 #include "vtkCamera.h"
00012 #include "vtkPoints.h"
00013 #include "vtkCellArray.h"
00014 #include "vtkPolyData.h"
00015 #include "vtkPolyDataMapper.h"
00016 #include "vtkPolyDataWriter.h"
00017 #include "vtkPolyDataReader.h"
00018 #include "vtkImageReader.h"
00019 #include "vtkImageViewer.h"
00020 #include "vtkImageViewer2.h"
00021 #include "vtkImageToStructuredPoints.h"
00022 #include <vtkImageThreshold.h> 
00023 #include "vtkImageWriter.h"
00024 
00025 
00026 #include "vtkExtractVOI.h"
00027 #include "vtkImageClip.h"
00028 #include "vtkImageResample.h"
00029 #include "vtkImageThreshold.h"
00030 #include "vtkImageCast.h"
00031 #include "vtkImageSeedConnectivity.h"
00032 #include "vtkImageData.h"
00033 #include "vtkMarchingCubes.h"
00034 #include "vtkImageReslice.h"
00035 #include "vtkTransform.h"
00036 #include "vtkSphereSource.h"
00037 #include "vtkDoubleArray.h"
00038 #include "vtkPointData.h"
00039 #include "vtkCommand.h"
00040 #include "vtkCallbackCommand.h"
00041 #include "vtkImageResample.h"
00042 #include "vtkMath.h"
00043 #include "vtkStripper.h"
00044 #include <vtkSTLReader.h> 
00045 #include "vtkMetaImageWriter.h"
00046 
00047 
00048 #include "vtkTriangleFilter.h"
00049 #include "vtkSTLWriter.h"
00050 #include "vtkPolyDataConnectivityFilter.h"
00051 #include "vtkClosePolyData.h"
00052 #include "vtkAppendFilter.h"
00053 
00054 #include "wxSTLWidget_03.h"
00055 
00056 #include <wx/splitter.h>
00057 
00058 #include <wx/filedlg.h>
00059 
00060 
00061 
00062 //-------------------------------------------------------------------
00063 //-------------------------------------------------------------------
00064 //-------------------------------------------------------------------
00065 wxSTLWidget_03::wxSTLWidget_03(wxWindow *parent, marInterface* mar)
00066 : wxPanel( parent, -1) 
00067 {
00068         _wxMaracasMPR           = NULL;
00069         _maxSize                = 2000;
00070         _minSize                = 300;
00071 
00072         _stlMarchingCubesLevel  = 128;
00073         _stlDeltaGaussLevel             = 100;
00074 
00075         _mar=new marInterface();        
00076         _mar->_parameters->setRescaleSlope( mar->_parameters->getRescaleSlope() );
00077         _mar->_parameters->setRescaleIntercept( mar->_parameters->getRescaleIntercept() );
00078         _mar->_parameters->setIntParam( marParameters::e_voxel_type, marParameters::VOX_TYPE_MINIMUM );
00079         _mar->_parameters->setDoubleParam( marParameters::e_voxel_x_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_x_dimension) );
00080         _mar->_parameters->setDoubleParam( marParameters::e_voxel_y_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_y_dimension) );
00081         _mar->_parameters->setDoubleParam( marParameters::e_voxel_z_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_z_dimension) );
00082         int voi[6];
00083         mar->_experiment->getVOI( voi );
00084         _mar->_experiment->setVOI( voi );
00085         _mar->SetDicom(mar->_dicom);
00086         _mar->initExperiment( );
00087          
00088 
00089         wxBoxSizer              *sizer          = new wxBoxSizer(wxVERTICAL  );
00090         wxSplitterWindow        *pnlSplitter    = new wxSplitterWindow( this , -1);
00091         wxPanel                 *viewPanel      = CreateViewPanel(pnlSplitter);
00092 printf("EED wxSTLWidget_03::wxSTLWidget_03 01\n");
00093         wxPanel                 *controlPanel   = CreateControlPanel(pnlSplitter);
00094 printf("EED wxSTLWidget_03::wxSTLWidget_03 02\n");
00095 
00096         sizer           -> Add( pnlSplitter ,1,wxGROW  ,0);
00097         pnlSplitter     -> SetMinimumPaneSize( 150 );
00098         pnlSplitter     -> SplitVertically( viewPanel, controlPanel, 600 );
00099 
00100 //      pnlSplitter     -> SplitVertically( new wxPanel(pnlSplitter,-1), new wxPanel(pnlSplitter,-1) , 600 );
00101 //      pnlSplitter     -> SplitVertically( viewPanel, new wxPanel(pnlSplitter,-1) , 600 );
00102 
00103         this            -> SetSizer(sizer);
00104 
00105         // Result 2: Volume + Axis
00106 //      _2_prgov                = NULL;
00107         _2_mapfinal             = NULL;
00108         _2_stripfinal           = NULL;
00109         _2_isoMapperMC6         = NULL;
00110         _2_isoActorMC6          = NULL;
00111         _2_isoMC6               = NULL;
00112 
00113         //DHC STL SURFACES
00114         stlInterna              = NULL;
00115         stlExterna              = NULL;
00116 
00117         _loadSTLMapper          = NULL;
00118         _loadActorSTL           = NULL;
00119 
00120         
00121         //JOIN REGIONS
00122         arteryImageData         = NULL;
00123         joinMarchingCubes       = NULL;
00124     joinMapper                  = NULL; 
00125         joinActor               = NULL;
00126 printf("EED wxSTLWidget_03::wxSTLWidget_03 03\n");
00127 
00128 
00129 }
00130 //-------------------------------------------------------------------
00131 wxSTLWidget_03::~wxSTLWidget_03(){
00132         ResetTree2_JF();
00133         Reset_vtk_STLFile();
00134 }
00135 //-------------------------------------------------------------------
00136 wxPanel* wxSTLWidget_03::CreateViewPanel(wxWindow *parent)
00137 {
00138         wxPanel *panel          =       new wxPanel(parent,-1);
00139     wxBoxSizer *sizer   =       new wxBoxSizer(wxVERTICAL);
00140 
00141 
00142    // MPR
00143         vtkImageData *imagedata;
00144         imagedata = _mar->_experiment->getDynData( )->getVolume( )->castVtk();
00145         imagedata->Update();    
00146 printf("EED wxSTLWidget_03::CreateViewPanel  01 \n");
00147         _wxMaracasMPR = new wxMaracasMPR( panel, new marImageData(imagedata), _mar->_parameters->getVoxelSize() );
00148 printf("EED wxSTLWidget_03::CreateViewPanel  02 \n");
00149         _wxMaracasMPR->ConfigureVTK();
00150 printf("EED wxSTLWidget_03::CreateViewPanel  03 \n");
00151         
00152         sizer->Add(     _wxMaracasMPR , 1, wxEXPAND, 0);
00153         panel->SetSizer(sizer);
00154         panel->SetAutoLayout(true);
00155         panel->SetSize(400,400);
00156         panel->Layout();
00157 printf("EED wxSTLWidget_03::CreateViewPanel  04 \n");
00158         return panel;
00159 }
00160 //-------------------------------------------------------------------
00161 wxWindow* wxSTLWidget_03::CreateSelectAPointPanel(wxWindow *parent)
00162 {
00163 printf("EED wxSTLWidget_03::CreateSelectAPointPanel  01\n");
00164         wxPanel *panel          = new wxPanel(parent,-1);
00165 
00166 printf("EED wxSTLWidget_03::CreateSelectAPointPanel  02\n");
00167 
00168     wxFlexGridSizer *sizer = new wxFlexGridSizer(2);
00169 printf("EED wxSTLWidget_03::CreateSelectAPointPanel  03\n");
00170 
00171         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00172         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00173 printf("EED wxSTLWidget_03::CreateSelectAPointPanel  04\n");
00174 
00175         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00176         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00177 printf("EED wxSTLWidget_03::CreateSelectAPointPanel  05\n");
00178 
00179         sizer->Add(new wxStaticText(panel,-1,_T(" Select a 3D Point...")));
00180         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00181 printf("EED wxSTLWidget_03::CreateSelectAPointPanel  06\n");
00182 
00183         panel->SetSizer(sizer);
00184         panel->SetAutoLayout(true);
00185         panel->SetSize(400,600);
00186         panel->Layout();
00187 printf("EED wxSTLWidget_03::CreateSelectAPointPanel  07\n");
00188 
00189 
00190         return panel;
00191 }
00192 //-------------------------------------------------------------------
00193 wxWindow* wxSTLWidget_03::CreateSegmentationPanel(wxWindow *parent)
00194 {
00195         wxPanel *panel          = new wxPanel(parent,-1);
00196 
00197 
00198         _opacity_Vol            = new wxSlider( panel, -1, 40, 0, 100                            , wxDefaultPosition, wxSize(200,40), wxSL_HORIZONTAL | wxSL_LABELS );
00199         _opacity_Vol    ->SetSize(250,20);  
00200         /*SIL
00201         _sl_maxSize                     = new wxSlider( panel, -1, 300 , 0, 2000 , wxDefaultPosition, wxSize(200,40), wxSL_HORIZONTAL  |  wxSL_AUTOTICKS | wxSL_LABELS );
00202         _sl_minSize                     = new wxSlider( panel, -1, 200 , 0, 2000 , wxDefaultPosition, wxSize(200,40), wxSL_HORIZONTAL  |  wxSL_AUTOTICKS | wxSL_LABELS );
00203         
00204         _sl_minSizeSpin = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxSize(25,45), wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT  );
00205         _sl_minSizeSpin->SetRange(1,8);
00206         _sl_minSizeSpin->SetValue(5);
00207 
00208         _sl_maxSizeSpin = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxSize(25,45), wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT  );
00209         _sl_maxSizeSpin->SetRange(1,8);
00210         _sl_maxSizeSpin->SetValue(5);
00211 
00212         */
00213 
00214         _sl_RangeSizeSpin = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxSize(25,45), wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT  );
00215         _sl_RangeSizeSpin->SetRange(1,8);
00216         _sl_RangeSizeSpin->SetValue(5);
00217 
00218 
00219         //SIL//
00220         sl_barrange_segmentation = new mBarRange(panel, 300,70);
00221         sl_barrange_segmentation -> setVisibleLabels ( true );
00222         sl_barrange_segmentation -> setIfWithActualDrawed( false );
00223         sl_barrange_segmentation -> setActiveStateTo ( true );
00224         sl_barrange_segmentation -> setRepresentedValues (0,  2000);
00225         sl_barrange_segmentation -> setDeviceBlitStart (10,10);
00226         sl_barrange_segmentation -> setDeviceEndMargin(10);
00227         parent->SetBackgroundColour(wxColour(255,255,255));
00228         sl_barrange_segmentation-> setBackgroundColor( wxColour(255,255,255 ));
00229 
00230 
00231         wxButton *btnExtract                            = new wxButton(panel,-1,_T("Segmentation"));
00232         wxButton *btnSaveBinaryFile                     = new wxButton(panel,-1,_T("Save Binary File"));
00233 
00234 //SIL// Connect(_sl_minSizeSpin->GetId()        , wxEVT_COMMAND_SLIDER_UPDATED   , (wxObjectEventFunction) &wxSTLWidget_03::OnMinSpin ); 
00235 //SIL// Connect(_sl_maxSizeSpin->GetId()        , wxEVT_COMMAND_SLIDER_UPDATED   , (wxObjectEventFunction) &wxSTLWidget_03::OnMaxSpin ); 
00236         Connect(_opacity_Vol->GetId()           , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &wxSTLWidget_03::OnOpacity_Vol                                        ); 
00237         Connect(btnExtract->GetId()                     , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &wxSTLWidget_03::OnBtnExtraction                                      ); 
00238         Connect(btnSaveBinaryFile->GetId()      , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &wxSTLWidget_03::OnBtnSaveBinaryFile                          ); 
00239 
00240         //SIL//
00241         Connect(_sl_RangeSizeSpin->GetId()      , wxEVT_COMMAND_SLIDER_UPDATED   , (wxObjectEventFunction) &wxSTLWidget_03::OnRangeSpin ); 
00242         Connect(sl_barrange_segmentation->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction)  &wxSTLWidget_03::OnStartChanged_range );
00243         Connect(sl_barrange_segmentation->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction)  &wxSTLWidget_03::OnEndChanged_range );      
00244         Connect(sl_barrange_segmentation->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction)  &wxSTLWidget_03::OnBarMoved_range );
00245 
00246     wxFlexGridSizer *sizer = new wxFlexGridSizer(2);
00247 
00248         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00249         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00250 
00251 
00252         sizer->Add(new wxStaticText(panel,-1,_T("  - - -  Segmentation - - - ")));
00253         sizer->Add(new wxStaticText(panel,-1,_T("  "))); 
00254         
00255 
00256         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00257         sizer->Add(new wxStaticText(panel,-1,_T("  "))); 
00258 
00259         /*sizer->Add(new wxStaticText(panel,-1,_T(" Threshold min")));
00260         sizer->Add(new wxStaticText(panel,-1,_T("  "))); 
00261         sizer->Add(_sl_minSizeSpin, 1, wxALL|wxEXPAND, 0);*/
00262         //sizer->Add(_sl_minSize, 1, wxALL|wxEXPAND, 0);
00263 
00264         sizer->Add(new wxStaticText(panel,-1,_T(" Threshold min-max")));
00265         sizer->Add(new wxStaticText(panel,-1,_T("  "))); 
00266         sizer->Add(_sl_RangeSizeSpin, 1, wxALL|wxEXPAND, 0);
00267         sizer->Add(sl_barrange_segmentation,3,wxALL|wxGROW,0 );
00268         
00269         //SIL//sizer->Add(new wxStaticText(panel,-1,_T(" Threshold max")));
00270         //SIL//sizer->Add(new wxStaticText(panel,-1,_T("  "))); 
00271         //SIL// sizer->Add(_sl_maxSizeSpin, 1, wxALL|wxEXPAND, 0);
00272         //SIL//sizer->Add(_sl_maxSize, 1, wxALL|wxEXPAND, 0);
00273         
00274         sizer->Add(btnExtract);
00275         sizer->Add(new wxStaticText(panel,-1,_T(" ")));
00276 
00277         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00278         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00279         sizer->Add(new wxStaticText(panel,-1,_T("Opacity - Result Volume")));
00280         sizer->Add(_opacity_Vol);
00281 
00282         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00283         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00284         sizer->Add(btnSaveBinaryFile);
00285         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00286         
00287         panel->SetSizer(sizer);
00288         panel->SetAutoLayout(true);
00289         panel->SetSize(400,600);
00290         panel->Layout();
00291 
00292         return panel;
00293 }
00294 //-------------------------------------------------
00295 wxWindow* wxSTLWidget_03::CreateSmoothingPanel(wxWindow *parent)
00296 {
00297         wxPanel *panel          = new wxPanel(parent,-1);
00298 
00299         stlSliderDeltaGauss     = new wxSlider( panel, -1, (int)(_stlDeltaGaussLevel) , 0, 300 , wxDefaultPosition, wxSize(200,40), wxSL_HORIZONTAL | wxSL_LABELS );
00300         stlSliderMarchingCubes= new wxSlider( panel, -1, (int)(_stlMarchingCubesLevel) , 0, 256 , wxDefaultPosition, wxSize(200,40), wxSL_HORIZONTAL | wxSL_LABELS );
00301         stlSliderOpacityInternal = new wxSlider(panel, -1, 100,0,100, wxDefaultPosition, wxSize(200,40), wxSL_HORIZONTAL | wxSL_LABELS);
00302         stlSliderOpacityExternal = new wxSlider(panel, -1, 100,0,100, wxDefaultPosition, wxSize(200,40), wxSL_HORIZONTAL | wxSL_LABELS);
00303         wxButton *btnFileSTL = new wxButton(panel,-1,_T("Generate STL files"));
00304 
00305         Connect(btnFileSTL->GetId()                             , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &wxSTLWidget_03::OnBtnCreateFileSTL                   );
00306         Connect(stlSliderDeltaGauss->GetId()    , wxEVT_SCROLL_THUMBRELEASE             , (wxObjectEventFunction) &wxSTLWidget_03::OnChangeSTLGaussLevel                );
00307         Connect(stlSliderMarchingCubes->GetId() , wxEVT_SCROLL_THUMBRELEASE             , (wxObjectEventFunction) &wxSTLWidget_03::OnChangeSTLMarchingCubesLevel);
00308         Connect(stlSliderOpacityInternal->GetId(), wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxSTLWidget_03::OnOpacitySTLInternal                 );
00309         Connect(stlSliderOpacityExternal->GetId(), wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxSTLWidget_03::OnOpacitySTLExternal                 );
00310 
00311 
00312     wxFlexGridSizer *sizer = new wxFlexGridSizer(2);
00313 
00314         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00315         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00316 
00317         sizer->Add(new wxStaticText(panel,-1,_T("-- Smoothing --")));
00318         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00319         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00320         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00321         
00322         sizer->Add(new wxStaticText(panel,-1,_T(" Delta Gauss")));
00323         sizer->Add(stlSliderDeltaGauss);
00324 
00325         sizer->Add(new wxStaticText(panel,-1,_T(" Marching Cubes Level")));
00326         sizer->Add(stlSliderMarchingCubes);
00327 
00328         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00329         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00330         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00331         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00332 
00333         sizer->Add(new wxStaticText(panel, -1,_T(" Opacity STL Internal")));
00334         sizer->Add(stlSliderOpacityInternal);
00335 
00336         sizer->Add(new wxStaticText(panel, -1,_T(" Opacity STL External")));
00337         sizer->Add(stlSliderOpacityExternal);
00338 
00339         sizer->Add(btnFileSTL);
00340         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00341 
00342 
00343         panel->SetSizer(sizer);
00344         panel->SetAutoLayout(true);
00345         panel->SetSize(400,600);
00346         panel->Layout();
00347         return panel;
00348 }
00349 //-------------------------------------------------
00350 wxWindow* wxSTLWidget_03::CreateReadSTLFilePanel(wxWindow *parent)
00351 {
00352         wxPanel *panel          = new wxPanel(parent,-1);
00353 
00354         wxButton *btnReadSTLFile                        = new wxButton(panel,-1,_T("Read STL File"));
00355         wxButton *btnEraseReadSTLFile           = new wxButton(panel,-1,_T("Erase STL File"));
00356         _sl_opacity_STL_file                            = new wxSlider( panel, -1, 100 , 0, 100 , wxDefaultPosition, wxSize(200,40), wxSL_HORIZONTAL | wxSL_LABELS );
00357 
00358         Connect(btnReadSTLFile->GetId()                 , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &wxSTLWidget_03::OnBtnSTLFileLoad                     ); 
00359         Connect(btnEraseReadSTLFile->GetId()    , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &wxSTLWidget_03::OnBtnSTLFileErase                    ); 
00360         Connect(_sl_opacity_STL_file->GetId()   , wxEVT_SCROLL_THUMBRELEASE     , (wxObjectEventFunction) &wxSTLWidget_03::OnOpacitySTLFile                             ); 
00361 
00362 
00363     wxFlexGridSizer *sizer = new wxFlexGridSizer(2);
00364 
00365         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00366         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00367         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00368         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00369 
00370         sizer->Add(new wxStaticText(panel,-1,_T("-- Read STL File --")));
00371         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00372 
00373         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00374         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
00375 
00376         sizer->Add(btnReadSTLFile );
00377         sizer->Add(btnEraseReadSTLFile );
00378         sizer->Add(new wxStaticText(panel, -1,_T(" Opacity STL File")));
00379         sizer->Add(_sl_opacity_STL_file);
00380 
00381 
00382         panel->SetSizer(sizer);
00383         panel->SetAutoLayout(true);
00384         panel->SetSize(400,600);
00385         panel->Layout();
00386         return panel;
00387 }
00388 //-------------------------------------------------------------------
00389 wxPanel* wxSTLWidget_03::CreateControlPanel(wxWindow *parent)
00390 {
00391 printf("EED wxSTLWidget_03::CreateControlPanel 01\n");
00392         wxPanel *panel                  = new wxPanel(parent,-1);
00393 
00394         wxNotebook *noteBook    = new wxNotebook(panel, -1);
00395 printf("EED wxSTLWidget_03::CreateControlPanel 02\n");
00396         noteBook->AddPage(CreateSelectAPointPanel(noteBook),_T("0 ->") );
00397 printf("EED wxSTLWidget_03::CreateControlPanel 03\n");
00398         noteBook->AddPage(CreateSegmentationPanel(noteBook),_T("1 ->") );
00399 printf("EED wxSTLWidget_03::CreateControlPanel 04\n");
00400         noteBook->AddPage(CreateSmoothingPanel(noteBook)   ,_T("2 ->") );
00401 printf("EED wxSTLWidget_03::CreateControlPanel 05\n");
00402         noteBook->AddPage(CreateReadSTLFilePanel(noteBook) ,_T("3 "  ) );
00403 printf("EED wxSTLWidget_03::CreateControlPanel 06\n");
00404         noteBook->SetSelection(0);
00405         noteBook->SetSize(350,250);
00406     wxFlexGridSizer *sizer = new wxFlexGridSizer(2);
00407         sizer->Add(noteBook);
00408         panel->SetSizer(sizer);
00409         panel->SetAutoLayout(true);
00410         panel->SetSize(400,600);
00411         panel->Layout();
00412 
00413 printf("EED wxSTLWidget_03::CreateControlPanel 07\n");
00414         return panel;
00415 }
00416 //------------------------------------------------------------------------
00417 void wxSTLWidget_03::Refresh()
00418 {
00419         if (_wxMaracasMPR!=NULL){
00420                 _wxMaracasMPR->RefreshView();
00421         }
00422 }
00423 
00424 //------------------------------------------------------------------------
00425 
00426 
00427 void wxSTLWidget_03::ConfigureProcessing(marImageData *marimagedata, int x, int y, int z)
00428 {
00429     wxBusyCursor wait;
00430 
00431         _imagedata=marimagedata->GetImageData(); // image t=0
00432         _imagedata->UpdateInformation();
00433         _imagedata->SetUpdateExtent(_imagedata->GetWholeExtent());
00434         _imagedata->Update();
00435 
00436 
00437         double puntoactualprov[3];
00438         puntoactualprov[0] = x;
00439         puntoactualprov[1] = y;
00440         puntoactualprov[2] = z;
00441 
00442         double espprin[3];
00443         int extprin[6];                         
00444         
00445         _imagedata->GetSpacing(espprin);
00446         _imagedata->GetExtent(extprin);
00447 
00448 
00449 // MAZV 27 sep 2006
00450 //      puntoactualprov[0]=puntoactualprov[0]*espprin[0];
00451 //      puntoactualprov[1]=puntoactualprov[1]*espprin[1];
00452 //      puntoactualprov[2]=puntoactualprov[2]*espprin[2];
00453         
00454     _imagedata->GetScalarRange( _range );
00455 
00456         // Update Controls
00457         //SIL//
00458         /*_sl_minSize->SetRange( (int)(_range[0]), (int)( _range[1]) );
00459         _sl_minSize->SetValue( (int)(_range[1]/4) );
00460 
00461         _sl_maxSize->SetRange( (int)(_range[0]) , (int)(_range[1]));
00462         _sl_maxSize->SetValue( (int)(_range[1]/2) );*/
00463 
00464         //SIL//
00465         minRangeValue = _range[0];
00466         maxRangeValue = _range[1];
00467 
00468         sl_barrange_segmentation ->setRepresentedValues(minRangeValue, maxRangeValue);
00469         sl_barrange_segmentation ->SetStart((int)(maxRangeValue/4));
00470         sl_barrange_segmentation ->SetEnd((int)(maxRangeValue/2));
00471         sl_barrange_segmentation -> RefreshForce();     
00472         lastResizeRef_Value = ( maxRangeValue - minRangeValue)/2;       
00473 
00474 // MAZV 27 sep 2006
00475 //      _highthreshold->SetRange(_range[0], _range[1]);
00476 //      _highthreshold->SetValue( _range[1] );
00477 
00478 //      _zslice->SetRange(extprin[4], extprin[5]);
00479 //      _zslice->SetValue(extprin[5]/2);
00480         
00481         _thresh = vtkImageThreshold::New();
00482         _thresh->SetInput(_imagedata);
00483         //_thresh->ReleaseDataFlagOff();
00484         _thresh->SetInValue(255);
00485         _thresh->SetOutputScalarTypeToUnsignedShort();
00486         _thresh->SetOutValue(0);
00487         //_thresh->ThresholdBetween(_sl_minSize->GetValue(), _range[1]);
00488         //SIL//
00489         _thresh->ThresholdBetween(sl_barrange_segmentation->GetStart(), sl_barrange_segmentation->GetEnd()); 
00490 
00491         vtkImageCast *cast = vtkImageCast::New();
00492         cast->SetInput(_thresh->GetOutput());
00493         cast->SetOutputScalarTypeToUnsignedChar();
00494         cast->Update();
00495 
00496   
00497         _connect = vtkImageSeedConnectivity::New();
00498         _connect->SetInput(cast->GetOutput());
00499         _connect->SetInputConnectValue(255);
00500         _connect->SetOutputConnectedValue(255);
00501         _connect->SetOutputUnconnectedValue(0);
00502         _connect->AddSeed((int)(puntoactualprov[0]), (int)(puntoactualprov[1]), (int)(puntoactualprov[2]));
00503 //      _connect->Update();
00504 
00505         cast3 = vtkImageCast::New();
00506         cast3->SetInput(_connect->GetOutput());
00507         cast3->SetOutputScalarTypeToUnsignedShort();
00508         cast3->Update();
00509 //SIL//
00510         
00511         _thresh2 = vtkImageThreshold::New();
00512         _thresh2->SetInput(_imagedata);
00513         //_thresh2->ReleaseDataFlagOff();
00514         _thresh2->SetInValue(255);
00515         _thresh2->SetOutputScalarTypeToUnsignedShort();
00516         _thresh2->SetOutValue(0);
00517         //SIL//_thresh2->ThresholdBetween(_sl_minSize->GetValue(), _sl_maxSize->GetValue());
00518         _thresh2->ThresholdBetween(sl_barrange_segmentation->GetStart(), sl_barrange_segmentation->GetEnd());
00519         
00520         cast2 = vtkImageCast::New();
00521         cast2->SetInput(_thresh2->GetOutput());
00522         cast2->SetOutputScalarTypeToUnsignedChar();
00523         cast2->Update();
00524 
00525         _connect2 = vtkImageSeedConnectivity::New();
00526         _connect2->SetInput(cast2->GetOutput());
00527         _connect2->SetInputConnectValue(255);
00528         _connect2->SetOutputConnectedValue(255);
00529         _connect2->SetOutputUnconnectedValue(0);
00530         _connect2->AddSeed( (int)(puntoactualprov[0]), (int)(puntoactualprov[1]), (int)(puntoactualprov[2]));
00531         _connect2->Update();
00532 
00533         cast4 = vtkImageCast::New();
00534         cast4->SetInput(_connect2->GetOutput());
00535         cast4->SetOutputScalarTypeToUnsignedShort();
00536         cast4->Update();
00537 }
00538 
00539 //------------------------------------------------------------------------
00540 
00541 
00542 
00543 void wxSTLWidget_03::ConfigureVTK()
00544 {
00545         wxBusyCursor wait;
00546 //      vtkImageData    *imagedata              = _mar->_experiment->getDynData( )->getVolume( )->castVtk();
00547         marImageData    *marimagedata           = _mar->_experiment->getDynData( )->GetMarImageData();
00548         
00549         //CONFIGURACION ADICIONAL
00550         this->ConfigureSTL();
00551         this->ConfigureProcessing(marimagedata,0,0,0);
00552         
00553 }
00554 
00555 //------------------------------------------------------------------------
00556 
00557 void wxSTLWidget_03::ResetTree2_JF()
00558 {
00559         // Remove 
00560         vtkRenderer *ren = _wxMaracasMPR->GetWxvtkmpr3Dview_BB()->GetWxvtk3Dbaseview()->GetRenderer();
00561 
00562     if (_2_isoActorMC6){
00563                 ren->RemoveActor(_2_isoActorMC6);
00564         }
00565     if (_2_stripfinal){
00566                 ren->RemoveActor(_2_stripfinal);
00567         }
00568 
00569         // Delete 
00570 //      if (_2_prgov            ) {     _2_prgov                -> Delete(); }
00571         if (_2_mapfinal         ) {     _2_mapfinal             -> Delete(); }
00572         if (_2_stripfinal       ) {     _2_stripfinal   -> Delete(); }
00573         if (_2_isoMapperMC6     ) {     _2_isoMapperMC6 -> Delete(); }
00574         if (_2_isoActorMC6      ) {     _2_isoActorMC6  -> Delete(); }
00575         if (_2_isoMC6           ) {     _2_isoMC6               -> Delete(); }
00576 
00577         // Init
00578 //      _2_prgov                = NULL;
00579         _2_mapfinal             = NULL;
00580         _2_stripfinal   = NULL;
00581         _2_isoMapperMC6 = NULL;
00582         _2_isoActorMC6  = NULL;
00583         _2_isoMC6               = NULL;
00584 }
00585 
00586 
00587 
00588 
00589 
00590 
00591 //------------------------------------------------------------------------
00592 void wxSTLWidget_03::ExtractSurface(int x, int y, int z)
00593 {
00594         
00595         double opacityvol               = ((double)_opacity_Vol->GetValue())/100;
00596 //      vtkImageData *imagedata = _mar->_experiment->getDynData( )->getVolume( )->castVtk();
00597 
00598         double  puntoactualprov[3];
00599         double  espprin[3];
00600         int             extprin[6];                             
00601 
00602 
00603         puntoactualprov[0]      =       x;
00604         puntoactualprov[1]      =       y;
00605         puntoactualprov[2]      =       z;
00606         
00607         _imagedata->UpdateInformation();
00608         _imagedata->SetUpdateExtent(_imagedata->GetWholeExtent());
00609         _imagedata->Update();
00610 
00611         _imagedata->GetSpacing(espprin);
00612         _imagedata->GetExtent(extprin);
00613 
00614 
00615 
00616 
00617         _connect->RemoveAllSeeds ();
00618         _connect->AddSeed( (int)(puntoactualprov[0] ), (int)(puntoactualprov[1]) ,(int)( puntoactualprov[2]) );
00619         _connect->Update();
00620         cast3->Update();
00621 
00622 
00623 
00624         _thresh->ThresholdBetween(3000, 3002 );
00625         _thresh2->ThresholdBetween(3000, 3001);
00626 //      _thresh->Update();
00627 //      _thresh2->Update();
00628 
00629         _thresh->ThresholdBetween(_minSize, _range[1] );
00630         _thresh->Update();
00631 
00632         _thresh2->ThresholdBetween(_minSize, _maxSize);
00633         _thresh2->Update();
00634 
00635         cast2->Update();
00636         _connect2->RemoveAllSeeds ();
00637         _connect2->AddSeed( (int)(puntoactualprov[0]) , (int)(puntoactualprov[1]) , (int)(puntoactualprov[2]) );
00638         _connect2->Update();
00639         cast4->Update();
00640 
00641 
00642 
00643 
00644         // Visualisation - result volume
00645    
00646     _2_isoMC6 = vtkMarchingCubes::New();
00647         _2_isoMC6->SetInput(cast4->GetOutput());
00648 
00649     _2_isoMC6->SetValue(0, 128);
00650         _2_isoMC6->Update();
00651 
00652         _2_isoMapperMC6 = vtkPolyDataMapper::New();
00653     _2_isoMapperMC6->SetInput(_2_isoMC6->GetOutput());
00654     _2_isoMapperMC6->ScalarVisibilityOff();
00655     _2_isoMapperMC6->ImmediateModeRenderingOn();
00656 
00657         vtkRenderer *ren = _wxMaracasMPR->GetWxvtkmpr3Dview_BB()->GetWxvtk3Dbaseview()->GetRenderer();
00658 
00659         if (_2_isoActorMC6!=NULL)
00660         {
00661                 ren->RemoveActor(_2_isoActorMC6);
00662         }
00663 
00664 
00665         _2_isoActorMC6 = vtkActor::New();
00666     _2_isoActorMC6->SetMapper(_2_isoMapperMC6);
00667     _2_isoActorMC6->GetProperty()->SetColor(1.0, 1.0, 0.5);
00668     _2_isoActorMC6->GetProperty()->SetOpacity( opacityvol );
00669     
00670         // Interface Update
00671 
00672         ren->AddActor(_2_isoActorMC6);
00673 
00674 }
00675 
00676 //------------------------------------------------------------------------
00677 void wxSTLWidget_03::OnOpacity_Vol(wxScrollEvent& event)
00678 {
00679         if (_2_isoActorMC6!=NULL){
00680                 double value = ((double)_opacity_Vol->GetValue())/100;
00681                 _2_isoActorMC6->GetProperty( )->SetOpacity( value );
00682                 Refresh();
00683         }
00684 }
00685 //------------------------------------------------------------------------
00686 
00687 void wxSTLWidget_03::OnMinSpin          (       wxScrollEvent &          event           )      
00688 {
00689         /*wxSlider *sl_A=_sl_minSize;
00690         wxSlider *sl_B=_sl_minSizeSpin;
00691         int value = sl_A->GetValue();
00692         int delta=(int)pow( 4 , sl_B->GetValue() );
00693         int min=value - delta/2;
00694         int max=value + delta/2;
00695         if (min<0)
00696         {
00697                 min=0;
00698                 max=delta;
00699         }
00700         sl_A->SetRange(min,max);
00701 
00702 
00703         */
00704 }
00705 
00706 //------------------------------------------------------------------------
00707 
00708 void wxSTLWidget_03::OnMaxSpin          (       wxScrollEvent &          event           )      
00709 {
00710         /*wxSlider *sl_A=_sl_maxSize;
00711         wxSlider *sl_B=_sl_maxSizeSpin;
00712         int value = sl_A->GetValue();
00713         int delta = (int)pow( 4 , sl_B->GetValue() );
00714         int min=value - delta/2;
00715         int max=value + delta/2;
00716         if (min<0)
00717         {
00718                 min=0;
00719                 max=delta;
00720         }
00721         sl_A->SetRange(min,max);*/      
00722 }
00723 
00724 //------------------------------------------------------------------------
00725 
00726 void wxSTLWidget_03::OnRangeSpin        (       wxScrollEvent &          event           )      
00727 {
00728         wxSlider *sl_B=_sl_RangeSizeSpin;
00729 
00730         int value = lastResizeRef_Value;
00731         int delta = (int)pow( 4 , sl_B->GetValue() );
00732         int startResized = value - delta/2;
00733         int endResized = value + delta/2;
00734 
00735         if( startResized < minRangeValue )
00736                 startResized = minRangeValue;
00737 
00738         if( endResized > maxRangeValue )
00739                 endResized = maxRangeValue;
00740 
00741         sl_barrange_segmentation->setRepresentedValues(startResized,endResized);
00742         sl_barrange_segmentation -> RefreshForce();     
00743 }
00744 
00745 //------------------------------------------------------------------------
00746 void wxSTLWidget_03:: OnStartChanged_range(wxCommandEvent& event)
00747 {
00748         lastResizeRef_Value = sl_barrange_segmentation->GetStart();
00749 }
00750 //------------------------------------------------------------------------
00751 void wxSTLWidget_03:: OnEndChanged_range(wxCommandEvent& event)
00752 {
00753         lastResizeRef_Value = sl_barrange_segmentation->GetEnd();   
00754 }
00755 //------------------------------------------------------------------------
00756 void wxSTLWidget_03:: OnBarMoved_range(wxCommandEvent& event)
00757 {
00758         lastResizeRef_Value = (sl_barrange_segmentation->GetEnd() - sl_barrange_segmentation->GetStart())/2 ;
00759 }
00760 //------------------------------------------------------------------------
00761 
00762 void wxSTLWidget_03::OnBtnSaveBinaryFile(wxCommandEvent& event)
00763 {
00764         wxString dirSTL = _mar->_parameters->getStringParam( 
00765     marParameters::e_installation_directory ); 
00766         dirSTL = ( dirSTL == _T("NO_DIRECTORY") ) ? wxGetHomeDir( ) : dirSTL;
00767         wxFileDialog dialog( this, _T("Choose a directory..."), ( !dirSTL.IsEmpty( ) )?
00768         dirSTL: wxGetHomeDir( ) );
00769 
00770         if( dialog.ShowModal( ) == wxID_OK ) 
00771         {
00772                 vtkMetaImageWriter  *writer= vtkMetaImageWriter::New();
00773                 writer->SetFileName( dialog.GetPath().mb_str(wxConvUTF8) );     
00774                 writer->SetInput(cast4->GetOutput());
00775                 writer->Write();
00776                 writer->Delete();
00777         }
00778 }
00779 
00780 //------------------------------------------------------------------------
00781 void wxSTLWidget_03::OnBtnExtraction(wxCommandEvent& event)
00782 {
00783         /*wxBusyCursor wait;
00784         _minSize = _sl_minSize->GetValue();
00785         _maxSize = _sl_maxSize->GetValue();
00786 
00787         double px=_wxMaracasMPR->GetVtkMPRBaseData()->GetX();
00788         double py=_wxMaracasMPR->GetVtkMPRBaseData()->GetY();
00789         double pz=_wxMaracasMPR->GetVtkMPRBaseData()->GetZ();
00790         ExtractSurface((int)(px),(int)(py),(int)(pz));
00791         generateSTLSurfaces(); //DHC: AFTER SEGMENTATION THE TREE, THE STL SURFACES ARE CALCULATED.
00792 
00793         Refresh();
00794 */
00795         //SIL//
00796         wxBusyCursor wait;
00797         _minSize = sl_barrange_segmentation->GetStart();
00798         _maxSize = sl_barrange_segmentation->GetEnd();
00799 
00800         double px=_wxMaracasMPR->GetVtkMPRBaseData()->GetX();
00801         double py=_wxMaracasMPR->GetVtkMPRBaseData()->GetY();
00802         double pz=_wxMaracasMPR->GetVtkMPRBaseData()->GetZ();
00803         ExtractSurface((int)(px),(int)(py),(int)(pz));
00804         generateSTLSurfaces(); //DHC: AFTER SEGMENTATION THE TREE, THE STL SURFACES ARE CALCULATED.
00805 
00806         Refresh();
00807 }
00808 
00809 //------------------------------------------------------------------------
00810 void wxSTLWidget_03::OnOpacitySTLFile(wxScrollEvent& event)
00811 {
00812         if (_loadActorSTL!=NULL)
00813         {
00814                 double value = ((double)_sl_opacity_STL_file->GetValue())/100;
00815                 _loadActorSTL->GetProperty( )->SetOpacity( value );
00816                 Refresh();
00817         }
00818 }
00819 //------------------------------------------------------------------------
00820 void wxSTLWidget_03::Reset_vtk_STLFile()
00821 {
00822         // Remove
00823         vtkRenderer *ren = _wxMaracasMPR->GetWxvtkmpr3Dview_BB()->GetWxvtk3Dbaseview()->GetRenderer();
00824     if (_loadActorSTL){
00825                 ren->RemoveActor(_loadActorSTL);
00826         }
00827 
00828         // Delete 
00829         if (_loadSTLMapper              ) {     _loadSTLMapper          -> Delete(); }
00830         if (_loadActorSTL               ) {     _loadActorSTL           -> Delete(); }
00831 
00832         // Init
00833         _loadSTLMapper          = NULL;
00834         _loadActorSTL           = NULL;
00835 
00836 }
00837 //------------------------------------------------------------------------
00838 void wxSTLWidget_03::OnBtnSTLFileErase(wxCommandEvent& event)
00839 {
00840         Reset_vtk_STLFile();
00841         Refresh();
00842 }
00843 //------------------------------------------------------------------------
00844 void wxSTLWidget_03::OnBtnSTLFileLoad(wxCommandEvent& event)
00845 {
00846         wxString dirSTL = _mar->_parameters->getStringParam( 
00847     marParameters::e_installation_directory ); 
00848         dirSTL = ( dirSTL == _T("NO_DIRECTORY") ) ? wxGetHomeDir( ) : dirSTL;
00849         wxFileDialog dialog( this, _T("Choose a directory..."), ( !dirSTL.IsEmpty( ) )?
00850         dirSTL: wxGetHomeDir( ) );
00851 
00852         if( dialog.ShowModal( ) == wxID_OK ) 
00853         {
00854                 Reset_vtk_STLFile();
00855                 vtkSTLReader *imgReader= vtkSTLReader::New();
00856                 imgReader->SetFileName( dialog.GetPath().mb_str(wxConvUTF8) );  
00857                 _loadSTLMapper = vtkPolyDataMapper::New();
00858                 _loadSTLMapper->SetInput(imgReader->GetOutput());
00859                 _loadActorSTL = vtkActor::New();
00860                 _loadActorSTL->SetMapper(_loadSTLMapper);
00861                 _loadActorSTL->GetProperty()->SetColor( 1, 0, 0);
00862                 _loadActorSTL->GetProperty()->SetOpacity( 0.5 );
00863                 vtkRenderer *ren = _wxMaracasMPR->GetWxvtkmpr3Dview_BB()->GetWxvtk3Dbaseview()->GetRenderer();
00864                 ren->AddActor(_loadActorSTL);
00865                 imgReader->Delete();
00866         }
00867         //By default *always* update e_installation_directory:
00868         _mar->_parameters->setStringParam( marParameters::e_installation_directory, dialog.GetPath( ) ); 
00869         _mar->saveParameters( );
00870 }
00871 
00872 
00873 
00874 // ------------------------------------------------------------------------
00875 // END JOIN FUNCTIONS - DHC
00876 // ------------------------------------------------------------------------
00877 
00878 // ------------------------------------------------------------------------
00879 // START STL FUNCTIONS - DHC
00880 // ------------------------------------------------------------------------
00881 
00882 void wxSTLWidget_03::ConfigureSTL()
00883 {
00884         stlExterna = vtkPolyData::New();
00885         stlInterna = vtkPolyData::New();
00886 
00887         dsm1 = vtkPolyDataMapper ::New();
00888     dsm1->SetInput (stlInterna); 
00889     dsm1->ScalarVisibilityOff();
00890 
00891     actorInternal = vtkActor::New();
00892     actorInternal->SetMapper (dsm1);
00893     actorInternal->GetProperty()->SetColor (0,1,0);
00894 
00895     dsm2 = vtkPolyDataMapper ::New();
00896     dsm2->SetInput (stlExterna);
00897     dsm2->ScalarVisibilityOff();
00898 
00899     actorExternal= vtkActor::New();
00900     actorExternal->SetMapper (dsm2);
00901     actorExternal->GetProperty()->SetRepresentationToWireframe();
00902 
00903 //    vtkRenderer *ren = _maracasSurfaceWidget->GetVtk3DSurfaceWidget()->GetRenderer();
00904         vtkRenderer *ren = _wxMaracasMPR->GetWxvtkmpr3Dview_BB()->GetWxvtk3Dbaseview()->GetRenderer();
00905     ren->AddActor(actorInternal);
00906     ren->AddActor(actorExternal);
00907 
00908         stlExtractor = new vtkSTLExtractor();  
00909 }
00910 
00911 void wxSTLWidget_03::generateSTLSurfaces()
00912 {
00913 // EED 09Janvier2007
00914 //      stlExtractor->setVolume(_2_prgov->GetVolumen());
00915 
00916         stlExtractor->setVolume(cast4->GetOutput());
00917 
00918         stlExtractor->setSigmaLevel(_stlDeltaGaussLevel);
00919         stlExtractor->setMarchingCubesLevel(_stlMarchingCubesLevel);
00920         stlExtractor->calculate();
00921         stlInterna->DeepCopy(stlExtractor->getInnerSurface());
00922         stlExterna->DeepCopy(stlExtractor->getOuterSurface());
00923 }
00924 
00925 
00926 void wxSTLWidget_03::OnOpacitySTLExternal(wxScrollEvent& event){
00927         double value = ((double)stlSliderOpacityExternal->GetValue())/100;
00928     actorExternal->GetProperty( )->SetOpacity( value );
00929         Refresh();
00930 }
00931 
00932 
00933 void wxSTLWidget_03::OnOpacitySTLInternal(wxScrollEvent& event){
00934         double value = ((double)stlSliderOpacityInternal->GetValue())/100;
00935     actorInternal->GetProperty( )->SetOpacity( value );
00936         Refresh();
00937 }
00938 
00939 void wxSTLWidget_03::OnBtnCreateFileSTL(wxCommandEvent& event)
00940 {
00941 
00942         wxString dirSTL = _mar->_parameters->getStringParam( 
00943     marParameters::e_installation_directory ); 
00944         dirSTL = ( dirSTL == _T("NO_DIRECTORY") ) ? wxGetHomeDir( ) : dirSTL;
00945 
00946         
00947 //      wxDirDialog dialog( this, "Choose a directory...", ( !dirSTL.IsEmpty( ) )?dirSTL: wxGetHomeDir( ) );
00948         wxFileDialog dialog( this, _T("Choose a directory..."), dirSTL , _T(""), _T("*.*"), wxSAVE );
00949 
00950 
00951         if( dialog.ShowModal( ) == wxID_OK ) 
00952         {
00953            
00954         
00955                 // ------------------------------------------------------------------------
00956                 //  1.  GENERATE STL FILES
00957                 // ------------------------------------------------------------------------
00958 //              const char* fileprefix = "c:\\Creatis\\";
00959                 std::string prefix ( dialog.GetPath().mb_str(wxConvUTF8) );
00960                 std::string filename;
00961 
00962                 // 1.1. Se hace un filtro triangular puesto que el stl writer solo recibe poligonos triangulares.
00963 
00964         vtkTriangleFilter *filtro = vtkTriangleFilter::New();
00965                 filtro->SetInput(stlInterna);
00966                 vtkPolyDataConnectivityFilter *pdcf = vtkPolyDataConnectivityFilter::New();
00967         pdcf->SetInput( filtro->GetOutput() );
00968         vtkClosePolyData *cpd = vtkClosePolyData::New();
00969         cpd->SetInput( pdcf->GetOutput() );
00970 
00971                 // 1.2 se escribe a disco el archivo stl de la superficie interna
00972         cpd->Update();
00973         vtkSTLWriter *writerI = vtkSTLWriter::New();
00974         writerI->SetInput( cpd->GetOutput() );
00975 //        prefix = fileprefix;
00976                 filename=prefix+"_internal.stl";
00977         writerI->SetFileName(filename.c_str());
00978         writerI->SetFileTypeToASCII();
00979         writerI->Write();
00980         writerI->Delete();
00981 
00982                 // 1.3 se escribe a disco el archivo stl de la superficie externa
00983                 filtro->SetInput(stlExterna);
00984         cpd->Update();
00985         vtkSTLWriter *writerE = vtkSTLWriter::New();
00986         writerE->SetInput( cpd->GetOutput() );
00987 //        prefix = fileprefix;
00988                 filename=prefix+"_external.stl";
00989         writerE->SetFileName( filename.c_str() );
00990         writerE->SetFileTypeToASCII();
00991         writerE->Write();
00992         writerE->Delete();
00993    
00994         filtro->Delete();
00995         cpd->Delete();
00996         pdcf->Delete();
00997         }
00998 
00999         //By default *always* update e_installation_directory:
01000         _mar->_parameters->setStringParam( marParameters::e_installation_directory, dialog.GetPath( ) ); 
01001         _mar->saveParameters( );
01002 }
01003 
01004 
01005 void wxSTLWidget_03::OnChangeSTLGaussLevel(wxScrollEvent& event)
01006 {
01007         wxBusyCursor wait;
01008         _stlDeltaGaussLevel  = ((double)stlSliderDeltaGauss->GetValue())/100;
01009         generateSTLSurfaces();
01010         Refresh();
01011 }
01012 
01013 
01014 void wxSTLWidget_03::OnChangeSTLMarchingCubesLevel(wxScrollEvent& event)
01015 {
01016         wxBusyCursor wait;
01017         _stlMarchingCubesLevel = ((double)stlSliderMarchingCubes->GetValue());
01018         generateSTLSurfaces();
01019         Refresh();
01020         
01021 }
01022 
01023 
01024 // ------------------------------------------------------------------------
01025 // END STL FUNCTIONS - DHC
01026 // ------------------------------------------------------------------------
01027 
01028 
01029 
01030 
01031 
01032 
01033 

Generated on Wed Jul 29 16:35:26 2009 for creaMaracasVisu_lib by  doxygen 1.5.3