]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxSTLWidget_03.cxx
0086b270c85615599405758faccd49caad32f3cf
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxSTLWidget_03.cxx
1
2 #include "vtkObjectFactory.h"
3
4 #include "vtkActor.h"
5 #include "vtkCylinderSource.h"
6 #include "vtkPolyDataMapper.h"
7 #include "vtkRenderer.h"
8 #include "vtkRenderWindow.h"
9 #include "vtkRenderWindowInteractor.h"
10 #include "vtkProperty.h"
11 #include "vtkCamera.h"
12 #include "vtkPoints.h"
13 #include "vtkCellArray.h"
14 #include "vtkPolyData.h"
15 #include "vtkPolyDataMapper.h"
16 #include "vtkPolyDataWriter.h"
17 #include "vtkPolyDataReader.h"
18 #include "vtkImageReader.h"
19 #include "vtkImageViewer.h"
20 #include "vtkImageViewer2.h"
21 #include "vtkImageToStructuredPoints.h"
22 #include <vtkImageThreshold.h> 
23 #include "vtkImageWriter.h"
24
25
26 #include "vtkExtractVOI.h"
27 #include "vtkImageClip.h"
28 #include "vtkImageResample.h"
29 #include "vtkImageThreshold.h"
30 #include "vtkImageCast.h"
31 #include "vtkImageSeedConnectivity.h"
32 #include "vtkImageData.h"
33 #include "vtkMarchingCubes.h"
34 #include "vtkImageReslice.h"
35 #include "vtkTransform.h"
36 #include "vtkSphereSource.h"
37 #include "vtkDoubleArray.h"
38 #include "vtkPointData.h"
39 #include "vtkCommand.h"
40 #include "vtkCallbackCommand.h"
41 #include "vtkImageResample.h"
42 #include "vtkMath.h"
43 #include "vtkStripper.h"
44 #include <vtkSTLReader.h> 
45 #include "vtkMetaImageWriter.h"
46
47
48 #include "vtkTriangleFilter.h"
49 #include "vtkSTLWriter.h"
50 #include "vtkPolyDataConnectivityFilter.h"
51 #include "vtkClosePolyData.h"
52 #include "vtkAppendFilter.h"
53
54 #include "wxSTLWidget_03.h"
55
56 #include <wx/splitter.h>
57
58 #include <wx/filedlg.h>
59
60
61
62 //-------------------------------------------------------------------
63 //-------------------------------------------------------------------
64 //-------------------------------------------------------------------
65 wxSTLWidget_03::wxSTLWidget_03(wxWindow *parent)//, marInterface* mar)
66 : wxPanel( parent, -1) 
67 {
68         _imagedata=NULL;
69         cast2=NULL;
70         cast3=NULL;
71         cast4=NULL; // binary segmentation result
72         _thresh=NULL;
73         _thresh2=NULL;
74         _cast=NULL;
75         _connect=NULL;
76         _connect2=NULL;
77         _2_mapfinal=NULL;
78         _2_stripfinal=NULL;
79         _2_isoMapperMC6=NULL;
80         _2_isoActorMC6=NULL;
81         _2_isoMC6=NULL; 
82         _loadSTLMapper=NULL;
83         _loadActorSTL=NULL;
84         sl_barrange_segmentation=NULL;  
85         _imageviewer3D=NULL;    
86         _wxMaracasMPR=NULL;     
87         stlInterna=NULL;
88         stlExterna=NULL;        
89         stlSliderDeltaGauss=NULL;
90         stlSliderMarchingCubes=NULL;    
91         dsm1=NULL;
92     actorInternal=NULL;
93         stlSliderOpacityInternal=NULL;    
94         dsm2=NULL; 
95     actorExternal=NULL;
96         stlSliderOpacityExternal=NULL;
97         stlExtractor=NULL;   
98         _sl_opacity_STL_file=NULL;
99         arteryImageData=NULL;
100         joiner=NULL;
101         joinMarchingCubes=NULL;
102     joinMapper=NULL; 
103         joinActor=NULL; 
104         _maxSize                = 2000;
105         _minSize                = 300;
106         
107         _stlMarchingCubesLevel  = 128;
108         _stlDeltaGaussLevel             = 100;
109
110         /*_mar=new marInterface();      
111         _mar->_parameters->setRescaleSlope( mar->_parameters->getRescaleSlope() );
112         _mar->_parameters->setRescaleIntercept( mar->_parameters->getRescaleIntercept() );
113         _mar->_parameters->setIntParam( marParameters::e_voxel_type, marParameters::VOX_TYPE_MINIMUM );
114         _mar->_parameters->setDoubleParam( marParameters::e_voxel_x_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_x_dimension) );
115         _mar->_parameters->setDoubleParam( marParameters::e_voxel_y_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_y_dimension) );
116         _mar->_parameters->setDoubleParam( marParameters::e_voxel_z_dimension, mar->_parameters->getDoubleParam(marParameters::e_voxel_z_dimension) );
117         int voi[6];
118         mar->_experiment->getVOI( voi );
119         _mar->_experiment->setVOI( voi );
120         _mar->SetDicom(mar->_dicom);
121         _mar->initExperiment( );*/
122          
123
124         wxBoxSizer              *sizer          = new wxBoxSizer(wxVERTICAL  );
125         wxSplitterWindow        *pnlSplitter    = new wxSplitterWindow( this , -1);
126         wxPanel                 *viewPanel      = CreateViewPanel(pnlSplitter);
127         wxPanel                 *controlPanel   = CreateControlPanel(pnlSplitter);
128
129         sizer           -> Add( pnlSplitter ,1,wxGROW  ,0);
130         pnlSplitter     -> SetMinimumPaneSize( 150 );
131         pnlSplitter     -> SplitVertically( viewPanel, controlPanel, 600 );
132
133 //      pnlSplitter     -> SplitVertically( new wxPanel(pnlSplitter,-1), new wxPanel(pnlSplitter,-1) , 600 );
134 //      pnlSplitter     -> SplitVertically( viewPanel, new wxPanel(pnlSplitter,-1) , 600 );
135
136         this            -> SetSizer(sizer);
137         
138
139
140 }
141 //-------------------------------------------------------------------
142 wxSTLWidget_03::~wxSTLWidget_03(){
143         //ResetTree2_JF();
144         //Reset_vtk_STLFile();
145
146         if(_imagedata!=NULL){
147                 _imagedata->Delete();   
148         }       
149         if(cast2){cast2->Delete();}
150         if(cast3){cast3->Delete();}
151         if(cast4){cast4->Delete();}
152         if(_thresh){_thresh->Delete();}
153         if(_thresh2){_thresh2->Delete();}
154         if(_cast){_cast->Delete();}
155         if(_connect){_connect->Delete();}
156         if(_connect2){_connect2->Delete();}
157         if(_2_mapfinal){_2_mapfinal->Delete();}
158         if(_2_stripfinal){_2_stripfinal->Delete();}
159         if(_2_isoMapperMC6){_2_isoMapperMC6->Delete();}
160         if(_2_isoActorMC6){_2_isoActorMC6->Delete();}
161         if(_2_isoMC6){_2_isoMC6->Delete();}
162         // Load STL file
163         if(_loadSTLMapper){_loadSTLMapper->Delete();}
164         if(_loadActorSTL){_loadActorSTL->Delete();}
165         if(sl_barrange_segmentation){delete sl_barrange_segmentation;}
166         if(_imageviewer3D){delete _imageviewer3D;}      
167         if(_wxMaracasMPR){delete _wxMaracasMPR;}
168         if(stlInterna){stlInterna->Delete();}
169         if(stlExterna){stlExterna->Delete();}   
170         if(dsm1){dsm1->Delete();}
171     if(actorInternal){actorInternal->Delete();}
172         if(dsm2){dsm2->Delete();} 
173     if(actorExternal){actorExternal->Delete();}
174         //if(stlExtractor){stlExtractor->Delete();}
175         if(arteryImageData){arteryImageData->Delete();}
176         if(joiner){delete joiner;}
177         if(joinMarchingCubes){joinMarchingCubes->Delete();}
178     if(joinMapper){joinMapper->Delete(); }
179         if(joinActor){joinActor->Delete();}
180 }
181 //-------------------------------------------------------------------
182 wxPanel* wxSTLWidget_03::CreateViewPanel(wxWindow *parent)
183 {
184         wxPanel *panel          =       new wxPanel(parent,-1);
185     wxBoxSizer *sizer   =       new wxBoxSizer(wxVERTICAL);
186
187
188    // MPR
189         //vtkImageData *imagedata;
190         //imagedata = _mar->_experiment->getDynData( )->getVolume( )->castVtk();
191         //imagedata->Update();  
192         _wxMaracasMPR = new wxMaracasMPR( panel);//JCP 10-03-2009, new marImageData(imagedata), 1 );
193         _wxMaracasMPR->ConfigureVTK();
194         
195         sizer->Add(     _wxMaracasMPR , 1, wxEXPAND, 0);
196         panel->SetSizer(sizer);
197         panel->SetAutoLayout(true);
198         panel->SetSize(400,400);
199         panel->Layout();
200         return panel;
201 }
202
203 void wxSTLWidget_03::setImage(vtkImageData* img){
204
205         _wxMaracasMPR->setImageData(img, 1);
206         _wxMaracasMPR->ConfigureVTK();
207
208
209         this->ConfigureProcessing(img,0,0,0);
210         this->ConfigureSTL();
211
212         _wxMaracasMPR->Refresh();
213         
214         //this->Refresh();
215 }
216 //-------------------------------------------------------------------
217 wxWindow* wxSTLWidget_03::CreateSelectAPointPanel(wxWindow *parent)
218 {
219         wxPanel *panel          = new wxPanel(parent,-1);
220
221
222     wxFlexGridSizer *sizer = new wxFlexGridSizer(2);
223
224         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
225         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
226
227         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
228         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
229
230         sizer->Add(new wxStaticText(panel,-1,_T(" Select a 3D Point...")));
231         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
232
233         panel->SetSizer(sizer);
234         panel->SetAutoLayout(true);
235         panel->SetSize(400,600);
236         panel->Layout();
237
238
239         return panel;
240 }
241 //-------------------------------------------------------------------
242 wxWindow* wxSTLWidget_03::CreateSegmentationPanel(wxWindow *parent)
243 {
244         wxPanel *panel          = new wxPanel(parent,-1);
245
246
247         _opacity_Vol            = new wxSlider( panel, -1, 40, 0, 100                            , wxDefaultPosition, wxSize(200,40), wxSL_HORIZONTAL | wxSL_LABELS );
248         _opacity_Vol    ->SetSize(250,20);  
249         /*SIL
250         _sl_maxSize                     = new wxSlider( panel, -1, 300 , 0, 2000 , wxDefaultPosition, wxSize(200,40), wxSL_HORIZONTAL  |  wxSL_AUTOTICKS | wxSL_LABELS );
251         _sl_minSize                     = new wxSlider( panel, -1, 200 , 0, 2000 , wxDefaultPosition, wxSize(200,40), wxSL_HORIZONTAL  |  wxSL_AUTOTICKS | wxSL_LABELS );
252         
253         _sl_minSizeSpin = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxSize(25,45), wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT  );
254         _sl_minSizeSpin->SetRange(1,8);
255         _sl_minSizeSpin->SetValue(5);
256
257         _sl_maxSizeSpin = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxSize(25,45), wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT  );
258         _sl_maxSizeSpin->SetRange(1,8);
259         _sl_maxSizeSpin->SetValue(5);
260
261         */
262
263         _sl_RangeSizeSpin = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxSize(25,45), wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT  );
264         _sl_RangeSizeSpin->SetRange(1,8);
265         _sl_RangeSizeSpin->SetValue(5);
266
267
268         //SIL//
269         sl_barrange_segmentation = new mBarRange(panel, 300,70);
270         sl_barrange_segmentation -> setVisibleLabels ( true );
271         sl_barrange_segmentation -> setIfWithActualDrawed( false );
272         sl_barrange_segmentation -> setActiveStateTo ( true );
273         sl_barrange_segmentation -> setRepresentedValues (0,  2000);
274         sl_barrange_segmentation -> setDeviceBlitStart (10,10);
275         sl_barrange_segmentation -> setDeviceEndMargin(10);
276         parent->SetBackgroundColour(wxColour(255,255,255));
277         sl_barrange_segmentation-> setBackgroundColor( wxColour(255,255,255 ));
278
279
280         wxButton *btnExtract                            = new wxButton(panel,-1,_T("Segmentation"));
281         wxButton *btnSaveBinaryFile                     = new wxButton(panel,-1,_T("Save Binary File"));
282
283 //SIL// Connect(_sl_minSizeSpin->GetId()        , wxEVT_COMMAND_SLIDER_UPDATED   , (wxObjectEventFunction) &wxSTLWidget_03::OnMinSpin ); 
284 //SIL// Connect(_sl_maxSizeSpin->GetId()        , wxEVT_COMMAND_SLIDER_UPDATED   , (wxObjectEventFunction) &wxSTLWidget_03::OnMaxSpin ); 
285         Connect(_opacity_Vol->GetId()           , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &wxSTLWidget_03::OnOpacity_Vol                                        ); 
286         Connect(btnExtract->GetId()                     , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &wxSTLWidget_03::OnBtnExtraction                                      ); 
287         Connect(btnSaveBinaryFile->GetId()      , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &wxSTLWidget_03::OnBtnSaveBinaryFile                          ); 
288
289         //SIL//
290         Connect(_sl_RangeSizeSpin->GetId()      , wxEVT_COMMAND_SLIDER_UPDATED   , (wxObjectEventFunction) &wxSTLWidget_03::OnRangeSpin ); 
291         Connect(sl_barrange_segmentation->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction)  &wxSTLWidget_03::OnStartChanged_range );
292         Connect(sl_barrange_segmentation->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction)  &wxSTLWidget_03::OnEndChanged_range );      
293         Connect(sl_barrange_segmentation->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction)  &wxSTLWidget_03::OnBarMoved_range );
294
295     wxFlexGridSizer *sizer = new wxFlexGridSizer(2);
296
297         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
298         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
299
300
301         sizer->Add(new wxStaticText(panel,-1,_T("  - - -  Segmentation - - - ")));
302         sizer->Add(new wxStaticText(panel,-1,_T("  "))); 
303         
304
305         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
306         sizer->Add(new wxStaticText(panel,-1,_T("  "))); 
307
308         /*sizer->Add(new wxStaticText(panel,-1,_T(" Threshold min")));
309         sizer->Add(new wxStaticText(panel,-1,_T("  "))); 
310         sizer->Add(_sl_minSizeSpin, 1, wxALL|wxEXPAND, 0);*/
311         //sizer->Add(_sl_minSize, 1, wxALL|wxEXPAND, 0);
312
313         sizer->Add(new wxStaticText(panel,-1,_T(" Threshold min-max")));
314         sizer->Add(new wxStaticText(panel,-1,_T("  "))); 
315         sizer->Add(_sl_RangeSizeSpin, 1, wxALL|wxEXPAND, 0);
316         sizer->Add(sl_barrange_segmentation,3,wxALL|wxGROW,0 );
317         
318         //SIL//sizer->Add(new wxStaticText(panel,-1,_T(" Threshold max")));
319         //SIL//sizer->Add(new wxStaticText(panel,-1,_T("  "))); 
320         //SIL// sizer->Add(_sl_maxSizeSpin, 1, wxALL|wxEXPAND, 0);
321         //SIL//sizer->Add(_sl_maxSize, 1, wxALL|wxEXPAND, 0);
322         
323         sizer->Add(btnExtract);
324         sizer->Add(new wxStaticText(panel,-1,_T(" ")));
325
326         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
327         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
328         sizer->Add(new wxStaticText(panel,-1,_T("Opacity - Result Volume")));
329         sizer->Add(_opacity_Vol);
330
331         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
332         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
333         sizer->Add(btnSaveBinaryFile);
334         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
335         
336         panel->SetSizer(sizer);
337         panel->SetAutoLayout(true);
338         panel->SetSize(400,600);
339         panel->Layout();
340
341         return panel;
342 }
343 //-------------------------------------------------
344 wxWindow* wxSTLWidget_03::CreateSmoothingPanel(wxWindow *parent)
345 {
346         wxPanel *panel          = new wxPanel(parent,-1);
347
348         stlSliderDeltaGauss     = new wxSlider( panel, -1, (int)(_stlDeltaGaussLevel) , 0, 300 , wxDefaultPosition, wxSize(200,40), wxSL_HORIZONTAL | wxSL_LABELS );
349         stlSliderMarchingCubes= new wxSlider( panel, -1, (int)(_stlMarchingCubesLevel) , 0, 256 , wxDefaultPosition, wxSize(200,40), wxSL_HORIZONTAL | wxSL_LABELS );
350         stlSliderOpacityInternal = new wxSlider(panel, -1, 100,0,100, wxDefaultPosition, wxSize(200,40), wxSL_HORIZONTAL | wxSL_LABELS);
351         stlSliderOpacityExternal = new wxSlider(panel, -1, 100,0,100, wxDefaultPosition, wxSize(200,40), wxSL_HORIZONTAL | wxSL_LABELS);
352         wxButton *btnFileSTL = new wxButton(panel,-1,_T("Generate STL files"));
353
354         Connect(btnFileSTL->GetId()                             , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &wxSTLWidget_03::OnBtnCreateFileSTL                   );
355         Connect(stlSliderDeltaGauss->GetId()    , wxEVT_SCROLL_THUMBRELEASE             , (wxObjectEventFunction) &wxSTLWidget_03::OnChangeSTLGaussLevel                );
356         Connect(stlSliderMarchingCubes->GetId() , wxEVT_SCROLL_THUMBRELEASE             , (wxObjectEventFunction) &wxSTLWidget_03::OnChangeSTLMarchingCubesLevel);
357         Connect(stlSliderOpacityInternal->GetId(), wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxSTLWidget_03::OnOpacitySTLInternal                 );
358         Connect(stlSliderOpacityExternal->GetId(), wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxSTLWidget_03::OnOpacitySTLExternal                 );
359
360
361     wxFlexGridSizer *sizer = new wxFlexGridSizer(2);
362
363         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
364         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
365
366         sizer->Add(new wxStaticText(panel,-1,_T("-- Smoothing --")));
367         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
368         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
369         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
370         
371         sizer->Add(new wxStaticText(panel,-1,_T(" Delta Gauss")));
372         sizer->Add(stlSliderDeltaGauss);
373
374         sizer->Add(new wxStaticText(panel,-1,_T(" Marching Cubes Level")));
375         sizer->Add(stlSliderMarchingCubes);
376
377         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
378         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
379         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
380         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
381
382         sizer->Add(new wxStaticText(panel, -1,_T(" Opacity STL Internal")));
383         sizer->Add(stlSliderOpacityInternal);
384
385         sizer->Add(new wxStaticText(panel, -1,_T(" Opacity STL External")));
386         sizer->Add(stlSliderOpacityExternal);
387
388         sizer->Add(btnFileSTL);
389         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
390
391
392         panel->SetSizer(sizer);
393         panel->SetAutoLayout(true);
394         panel->SetSize(400,600);
395         panel->Layout();
396         return panel;
397 }
398 //-------------------------------------------------
399 wxWindow* wxSTLWidget_03::CreateReadSTLFilePanel(wxWindow *parent)
400 {
401         wxPanel *panel          = new wxPanel(parent,-1);
402
403         wxButton *btnReadSTLFile                        = new wxButton(panel,-1,_T("Read STL File"));
404         wxButton *btnEraseReadSTLFile           = new wxButton(panel,-1,_T("Erase STL File"));
405         _sl_opacity_STL_file                            = new wxSlider( panel, -1, 100 , 0, 100 , wxDefaultPosition, wxSize(200,40), wxSL_HORIZONTAL | wxSL_LABELS );
406
407         Connect(btnReadSTLFile->GetId()                 , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &wxSTLWidget_03::OnBtnSTLFileLoad                     ); 
408         Connect(btnEraseReadSTLFile->GetId()    , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &wxSTLWidget_03::OnBtnSTLFileErase                    ); 
409         Connect(_sl_opacity_STL_file->GetId()   , wxEVT_SCROLL_THUMBRELEASE     , (wxObjectEventFunction) &wxSTLWidget_03::OnOpacitySTLFile                             ); 
410
411
412     wxFlexGridSizer *sizer = new wxFlexGridSizer(2);
413
414         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
415         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
416         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
417         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
418
419         sizer->Add(new wxStaticText(panel,-1,_T("-- Read STL File --")));
420         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
421
422         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
423         sizer->Add(new wxStaticText(panel,-1,_T("  ")));
424
425         sizer->Add(btnReadSTLFile );
426         sizer->Add(btnEraseReadSTLFile );
427         sizer->Add(new wxStaticText(panel, -1,_T(" Opacity STL File")));
428         sizer->Add(_sl_opacity_STL_file);
429
430
431         panel->SetSizer(sizer);
432         panel->SetAutoLayout(true);
433         panel->SetSize(400,600);
434         panel->Layout();
435         return panel;
436 }
437 //-------------------------------------------------------------------
438 wxPanel* wxSTLWidget_03::CreateControlPanel(wxWindow *parent)
439 {
440         wxPanel *panel                  = new wxPanel(parent,-1);
441
442         wxNotebook *noteBook    = new wxNotebook(panel, -1);
443         noteBook->AddPage(CreateSelectAPointPanel(noteBook),_T("0 ->") );
444         noteBook->AddPage(CreateSegmentationPanel(noteBook),_T("1 ->") );
445         noteBook->AddPage(CreateSmoothingPanel(noteBook)   ,_T("2 ->") );
446         noteBook->AddPage(CreateReadSTLFilePanel(noteBook) ,_T("3 "  ) );
447         noteBook->SetSelection(0);
448         noteBook->SetSize(350,250);
449     wxFlexGridSizer *sizer = new wxFlexGridSizer(2);
450         sizer->Add(noteBook);
451         panel->SetSizer(sizer);
452         panel->SetAutoLayout(true);
453         panel->SetSize(400,600);
454         panel->Layout();
455
456         return panel;
457 }
458 //------------------------------------------------------------------------
459 void wxSTLWidget_03::Refresh()
460 {
461         if (_wxMaracasMPR!=NULL){
462                 _wxMaracasMPR->RefreshView();
463         }
464 }
465
466 //------------------------------------------------------------------------
467
468
469 void wxSTLWidget_03::ConfigureProcessing(vtkImageData *img, int x, int y, int z)
470 {
471     wxBusyCursor wait;
472
473         _imagedata=img;
474
475
476         double puntoactualprov[3];
477         puntoactualprov[0] = x;
478         puntoactualprov[1] = y;
479         puntoactualprov[2] = z;
480
481         double espprin[3];
482         int extprin[6];                         
483         
484         _imagedata->GetSpacing(espprin);
485         _imagedata->GetExtent(extprin);
486
487
488 // MAZV 27 sep 2006
489 //      puntoactualprov[0]=puntoactualprov[0]*espprin[0];
490 //      puntoactualprov[1]=puntoactualprov[1]*espprin[1];
491 //      puntoactualprov[2]=puntoactualprov[2]*espprin[2];
492         
493     _imagedata->GetScalarRange( _range );
494
495         // Update Controls
496         //SIL//
497         /*_sl_minSize->SetRange( (int)(_range[0]), (int)( _range[1]) );
498         _sl_minSize->SetValue( (int)(_range[1]/4) );
499
500         _sl_maxSize->SetRange( (int)(_range[0]) , (int)(_range[1]));
501         _sl_maxSize->SetValue( (int)(_range[1]/2) );*/
502
503         //SIL//
504         minRangeValue = _range[0];
505         maxRangeValue = _range[1];
506
507         sl_barrange_segmentation ->setRepresentedValues(minRangeValue, maxRangeValue);
508         sl_barrange_segmentation ->SetStart((int)(maxRangeValue/4));
509         sl_barrange_segmentation ->SetEnd((int)(maxRangeValue/2));
510         sl_barrange_segmentation -> RefreshForce();     
511         lastResizeRef_Value = ( maxRangeValue - minRangeValue)/2;       
512
513 // MAZV 27 sep 2006
514 //      _highthreshold->SetRange(_range[0], _range[1]);
515 //      _highthreshold->SetValue( _range[1] );
516
517 //      _zslice->SetRange(extprin[4], extprin[5]);
518 //      _zslice->SetValue(extprin[5]/2);
519     
520         if(_thresh==NULL){
521                 _thresh = vtkImageThreshold::New();
522                 //_thresh->ReleaseDataFlagOff();
523                 _thresh->SetInValue(255);
524                 _thresh->SetOutputScalarTypeToUnsignedShort();
525                 _thresh->SetOutValue(0);
526                 //_thresh->ThresholdBetween(_sl_minSize->GetValue(), _range[1]);
527                 //SIL//
528                 _cast = vtkImageCast::New();
529                 _cast->SetInput(_thresh->GetOutput());
530                 _cast->SetOutputScalarTypeToUnsignedChar();
531
532                 _connect = vtkImageSeedConnectivity::New();
533                 _connect->SetInput(_cast->GetOutput());
534                 _connect->SetInputConnectValue(255);
535                 _connect->SetOutputConnectedValue(255);
536                 _connect->SetOutputUnconnectedValue(0);
537
538                 cast3 = vtkImageCast::New();
539                 cast3->SetInput(_connect->GetOutput());
540                 cast3->SetOutputScalarTypeToUnsignedShort();
541
542                 _thresh2 = vtkImageThreshold::New();
543                 //_thresh2->ReleaseDataFlagOff();
544                 _thresh2->SetInValue(255);
545                 _thresh2->SetOutputScalarTypeToUnsignedShort();
546                 _thresh2->SetOutValue(0);
547                 //SIL//_thresh2->ThresholdBetween(_sl_minSize->GetValue(), _sl_maxSize->GetValue());
548
549                 cast2 = vtkImageCast::New();
550                 cast2->SetInput(_thresh2->GetOutput());
551                 cast2->SetOutputScalarTypeToUnsignedChar();
552                 _connect2 = vtkImageSeedConnectivity::New();
553                 _connect2->SetInput(cast2->GetOutput());
554                 _connect2->SetInputConnectValue(255);
555                 _connect2->SetOutputConnectedValue(255);
556                 _connect2->SetOutputUnconnectedValue(0);
557
558                 cast4 = vtkImageCast::New();
559                 cast4->SetInput(_connect2->GetOutput());
560                 cast4->SetOutputScalarTypeToUnsignedShort();
561         }
562         _thresh->RemoveAllInputs();
563         _thresh->SetInput(_imagedata);  
564         _thresh->ThresholdBetween(sl_barrange_segmentation->GetStart(), sl_barrange_segmentation->GetEnd());    
565         _thresh->Update();
566         
567         _cast->Update();  
568         
569
570         _connect->RemoveAllSeeds();
571         _connect->AddSeed((int)(puntoactualprov[0]), (int)(puntoactualprov[1]), (int)(puntoactualprov[2]));
572         //_connect->Update();   
573         //cast3->Update();
574 //SIL// 
575         _thresh2->RemoveAllInputs();
576         _thresh2->SetInput(_imagedata); 
577         _thresh2->ThresholdBetween(sl_barrange_segmentation->GetStart(), sl_barrange_segmentation->GetEnd());
578         _thresh2->Update();
579         cast2->Update();
580         _connect2->RemoveAllSeeds();
581         _connect2->AddSeed( (int)(puntoactualprov[0]), (int)(puntoactualprov[1]), (int)(puntoactualprov[2]));
582         //_connect2->Update();  
583         //cast4->Update();
584 }
585
586 //------------------------------------------------------------------------
587
588
589
590 void wxSTLWidget_03::ConfigureVTK()
591 {
592         wxBusyCursor wait;
593 //      vtkImageData    *imagedata              = _mar->_experiment->getDynData( )->getVolume( )->castVtk();
594         //marImageData  *marimagedata;//                = _mar->_experiment->getDynData( )->GetMarImageData();
595         
596         //CONFIGURACION ADICIONAL
597         this->ConfigureSTL();
598         //this->ConfigureProcessing(marimagedata,0,0,0);
599         
600 }
601
602 //------------------------------------------------------------------------
603
604 void wxSTLWidget_03::ResetTree2_JF()
605 {
606         // Remove 
607
608         try{
609
610                 
611
612                 // Delete 
613         //      if (_2_prgov            ) {     _2_prgov                -> Delete(); }
614                 if (_2_mapfinal         ) {     _2_mapfinal             -> Delete(); }
615                 if (_2_stripfinal       ) {     _2_stripfinal   -> Delete(); }
616                 if (_2_isoMapperMC6     ) {     _2_isoMapperMC6 -> Delete(); }
617                 if (_2_isoActorMC6      ) {     _2_isoActorMC6  -> Delete(); }
618                 if (_2_isoMC6           ) {     _2_isoMC6               -> Delete(); }
619
620                 // Init
621         //      _2_prgov                = NULL;
622                 _2_mapfinal             = NULL;
623                 _2_stripfinal   = NULL;
624                 _2_isoMapperMC6 = NULL;
625                 _2_isoActorMC6  = NULL;
626                 _2_isoMC6               = NULL;
627
628                 
629                 //vtkRenderer *ren = _wxMaracasMPR->GetWxvtkmpr3Dview_BB()->GetWxvtk3Dbaseview()->GetRenderer();
630
631                 /*if (_2_isoActorMC6){
632                         ren->RemoveActor(_2_isoActorMC6);
633                 }
634                 if (_2_stripfinal){
635                         ren->RemoveActor(_2_stripfinal);
636                 }*/
637
638                 
639         }catch(char* e){
640                 std::cout<<e<<std::endl;
641         }
642 }
643
644
645
646
647
648
649 //------------------------------------------------------------------------
650 void wxSTLWidget_03::ExtractSurface(int x, int y, int z)
651 {
652         
653         double opacityvol               = ((double)_opacity_Vol->GetValue())/100;
654 //      vtkImageData *imagedata = _mar->_experiment->getDynData( )->getVolume( )->castVtk();
655
656         double  puntoactualprov[3];
657         double  espprin[3];
658         int             extprin[6];                             
659
660
661         puntoactualprov[0]      =       x;
662         puntoactualprov[1]      =       y;
663         puntoactualprov[2]      =       z;
664         
665         _imagedata->UpdateInformation();
666         _imagedata->SetUpdateExtent(_imagedata->GetWholeExtent());
667         _imagedata->Update();
668
669         _imagedata->GetSpacing(espprin);
670         _imagedata->GetExtent(extprin);
671
672
673
674
675         _connect->RemoveAllSeeds ();
676         _connect->AddSeed( (int)(puntoactualprov[0] ), (int)(puntoactualprov[1]) ,(int)( puntoactualprov[2]) );
677         _connect->Update();
678         cast3->Update();
679
680
681
682         _thresh->ThresholdBetween(3000, 3002 );
683         _thresh2->ThresholdBetween(3000, 3001);
684 //      _thresh->Update();
685 //      _thresh2->Update();
686
687         _thresh->ThresholdBetween(_minSize, _range[1] );
688         _thresh->Update();
689
690         _thresh2->ThresholdBetween(_minSize, _maxSize);
691         _thresh2->Update();
692
693         cast2->Update();
694         _connect2->RemoveAllSeeds ();
695         _connect2->AddSeed( (int)(puntoactualprov[0]) , (int)(puntoactualprov[1]) , (int)(puntoactualprov[2]) );
696         _connect2->Update();
697         cast4->Update();
698
699
700
701
702         // Visualisation - result volume
703    
704     _2_isoMC6 = vtkMarchingCubes::New();
705         _2_isoMC6->SetInput(cast4->GetOutput());
706
707     _2_isoMC6->SetValue(0, 128);
708         _2_isoMC6->Update();
709
710         _2_isoMapperMC6 = vtkPolyDataMapper::New();
711     _2_isoMapperMC6->SetInput(_2_isoMC6->GetOutput());
712     _2_isoMapperMC6->ScalarVisibilityOff();
713     _2_isoMapperMC6->ImmediateModeRenderingOn();
714
715         vtkRenderer *ren = _wxMaracasMPR->GetWxvtkmpr3Dview_BB()->GetWxvtk3Dbaseview()->GetRenderer();
716
717         if (_2_isoActorMC6!=NULL)
718         {
719                 ren->RemoveActor(_2_isoActorMC6);
720         }
721
722
723         _2_isoActorMC6 = vtkActor::New();
724     _2_isoActorMC6->SetMapper(_2_isoMapperMC6);
725     _2_isoActorMC6->GetProperty()->SetColor(1.0, 1.0, 0.5);
726     _2_isoActorMC6->GetProperty()->SetOpacity( opacityvol );
727     
728         // Interface Update
729
730         ren->AddActor(_2_isoActorMC6);
731
732 }
733
734 //------------------------------------------------------------------------
735 void wxSTLWidget_03::OnOpacity_Vol(wxScrollEvent& event)
736 {
737         if (_2_isoActorMC6!=NULL){
738                 double value = ((double)_opacity_Vol->GetValue())/100;
739                 _2_isoActorMC6->GetProperty( )->SetOpacity( value );
740                 Refresh();
741         }
742 }
743 //------------------------------------------------------------------------
744
745 void wxSTLWidget_03::OnMinSpin          (       wxScrollEvent &          event           )      
746 {
747         /*wxSlider *sl_A=_sl_minSize;
748         wxSlider *sl_B=_sl_minSizeSpin;
749         int value = sl_A->GetValue();
750         int delta=(int)pow( 4 , sl_B->GetValue() );
751         int min=value - delta/2;
752         int max=value + delta/2;
753         if (min<0)
754         {
755                 min=0;
756                 max=delta;
757         }
758         sl_A->SetRange(min,max);
759
760
761         */
762 }
763
764 //------------------------------------------------------------------------
765
766 void wxSTLWidget_03::OnMaxSpin          (       wxScrollEvent &          event           )      
767 {
768         /*wxSlider *sl_A=_sl_maxSize;
769         wxSlider *sl_B=_sl_maxSizeSpin;
770         int value = sl_A->GetValue();
771         int delta = (int)pow( 4 , sl_B->GetValue() );
772         int min=value - delta/2;
773         int max=value + delta/2;
774         if (min<0)
775         {
776                 min=0;
777                 max=delta;
778         }
779         sl_A->SetRange(min,max);*/      
780 }
781
782 //------------------------------------------------------------------------
783
784 void wxSTLWidget_03::OnRangeSpin        (       wxScrollEvent &          event           )      
785 {
786         wxSlider *sl_B=_sl_RangeSizeSpin;
787
788         int value = lastResizeRef_Value;
789         int delta = (int)pow((double) 4 , (double)sl_B->GetValue() );
790         int startResized = value - delta/2;
791         int endResized = value + delta/2;
792
793         if( startResized < minRangeValue )
794                 startResized = minRangeValue;
795
796         if( endResized > maxRangeValue )
797                 endResized = maxRangeValue;
798
799         sl_barrange_segmentation->setRepresentedValues(startResized,endResized);
800         sl_barrange_segmentation -> RefreshForce();     
801 }
802
803 //------------------------------------------------------------------------
804 void wxSTLWidget_03:: OnStartChanged_range(wxCommandEvent& event)
805 {
806         lastResizeRef_Value = sl_barrange_segmentation->GetStart();
807 }
808 //------------------------------------------------------------------------
809 void wxSTLWidget_03:: OnEndChanged_range(wxCommandEvent& event)
810 {
811         lastResizeRef_Value = sl_barrange_segmentation->GetEnd();   
812 }
813 //------------------------------------------------------------------------
814 void wxSTLWidget_03:: OnBarMoved_range(wxCommandEvent& event)
815 {
816         lastResizeRef_Value = (sl_barrange_segmentation->GetEnd() - sl_barrange_segmentation->GetStart())/2 ;
817 }
818 //------------------------------------------------------------------------
819
820 void wxSTLWidget_03::OnBtnSaveBinaryFile(wxCommandEvent& event)
821 {
822         wxString dirSTL;// = _mar->_parameters->getStringParam( 
823     //marParameters::e_installation_directory ); 
824         dirSTL = ( dirSTL == _T("NO_DIRECTORY") ) ? wxGetHomeDir( ) : dirSTL;
825         wxFileDialog dialog( this, _T("Choose a directory..."), ( !dirSTL.IsEmpty( ) )?
826         dirSTL: wxGetHomeDir( ) );
827
828         if( dialog.ShowModal( ) == wxID_OK ) 
829         {
830                 vtkMetaImageWriter  *writer= vtkMetaImageWriter::New();
831                 writer->SetFileName( dialog.GetPath().mb_str(wxConvUTF8) );     
832                 writer->SetInput(cast4->GetOutput());
833                 writer->Write();
834                 writer->Delete();
835         }
836 }
837
838 //------------------------------------------------------------------------
839 void wxSTLWidget_03::OnBtnExtraction(wxCommandEvent& event)
840 {
841         /*wxBusyCursor wait;
842         _minSize = _sl_minSize->GetValue();
843         _maxSize = _sl_maxSize->GetValue();
844
845         double px=_wxMaracasMPR->GetVtkMPRBaseData()->GetX();
846         double py=_wxMaracasMPR->GetVtkMPRBaseData()->GetY();
847         double pz=_wxMaracasMPR->GetVtkMPRBaseData()->GetZ();
848         ExtractSurface((int)(px),(int)(py),(int)(pz));
849         generateSTLSurfaces(); //DHC: AFTER SEGMENTATION THE TREE, THE STL SURFACES ARE CALCULATED.
850
851         Refresh();
852 */
853         //SIL//
854         wxBusyCursor wait;
855         _minSize = sl_barrange_segmentation->GetStart();
856         _maxSize = sl_barrange_segmentation->GetEnd();
857
858         double px=_wxMaracasMPR->GetVtkMPRBaseData()->GetX();
859         double py=_wxMaracasMPR->GetVtkMPRBaseData()->GetY();
860         double pz=_wxMaracasMPR->GetVtkMPRBaseData()->GetZ();
861         ExtractSurface((int)(px),(int)(py),(int)(pz));
862         generateSTLSurfaces(); //DHC: AFTER SEGMENTATION THE TREE, THE STL SURFACES ARE CALCULATED.
863
864         Refresh();
865 }
866
867 //------------------------------------------------------------------------
868 void wxSTLWidget_03::OnOpacitySTLFile(wxScrollEvent& event)
869 {
870         if (_loadActorSTL!=NULL)
871         {
872                 double value = ((double)_sl_opacity_STL_file->GetValue())/100;
873                 _loadActorSTL->GetProperty( )->SetOpacity( value );
874                 Refresh();
875         }
876 }
877 //------------------------------------------------------------------------
878 void wxSTLWidget_03::Reset_vtk_STLFile()
879 {
880         // Remove
881         try{
882                 vtkRenderer *ren = _wxMaracasMPR->GetWxvtkmpr3Dview_BB()->GetWxvtk3Dbaseview()->GetRenderer();
883                 if (_loadActorSTL){
884                         ren->RemoveActor(_loadActorSTL);
885                 }
886
887                 // Delete 
888                 if (_loadSTLMapper              ) {     _loadSTLMapper          -> Delete(); }
889                 if (_loadActorSTL               ) {     _loadActorSTL           -> Delete(); }
890
891                 // Init
892                 _loadSTLMapper          = NULL;
893                 _loadActorSTL           = NULL;
894         }catch(char * e){
895                 std::cout<<e<<std::endl;
896         }
897
898 }
899 //------------------------------------------------------------------------
900 void wxSTLWidget_03::OnBtnSTLFileErase(wxCommandEvent& event)
901 {
902         Reset_vtk_STLFile();
903         Refresh();
904 }
905 //------------------------------------------------------------------------
906 void wxSTLWidget_03::OnBtnSTLFileLoad(wxCommandEvent& event)
907 {
908         wxString dirSTL;// = _mar->_parameters->getStringParam( 
909     //marParameters::e_installation_directory ); 
910         dirSTL = ( dirSTL == _T("NO_DIRECTORY") ) ? wxGetHomeDir( ) : dirSTL;
911         wxFileDialog dialog( this, _T("Choose a directory..."), ( !dirSTL.IsEmpty( ) )?
912         dirSTL: wxGetHomeDir( ) );
913
914         if( dialog.ShowModal( ) == wxID_OK ) 
915         {
916                 Reset_vtk_STLFile();
917                 vtkSTLReader *imgReader= vtkSTLReader::New();
918                 imgReader->SetFileName( dialog.GetPath().mb_str(wxConvUTF8) );  
919                 _loadSTLMapper = vtkPolyDataMapper::New();
920                 _loadSTLMapper->SetInput(imgReader->GetOutput());
921                 _loadActorSTL = vtkActor::New();
922                 _loadActorSTL->SetMapper(_loadSTLMapper);
923                 _loadActorSTL->GetProperty()->SetColor( 1, 0, 0);
924                 _loadActorSTL->GetProperty()->SetOpacity( 0.5 );
925                 vtkRenderer *ren = _wxMaracasMPR->GetWxvtkmpr3Dview_BB()->GetWxvtk3Dbaseview()->GetRenderer();
926                 ren->AddActor(_loadActorSTL);
927                 imgReader->Delete();
928         }
929         //By default *always* update e_installation_directory:
930         //_mar->_parameters->setStringParam( marParameters::e_installation_directory, dialog.GetPath( ) ); 
931         //_mar->saveParameters( );
932 }
933
934
935
936 // ------------------------------------------------------------------------
937 // END JOIN FUNCTIONS - DHC
938 // ------------------------------------------------------------------------
939
940 // ------------------------------------------------------------------------
941 // START STL FUNCTIONS - DHC
942 // ------------------------------------------------------------------------
943
944 void wxSTLWidget_03::ConfigureSTL()
945 {
946
947         if(stlExterna == NULL){
948                 stlExterna = vtkPolyData::New();
949                 stlInterna = vtkPolyData::New();
950
951                 dsm1 = vtkPolyDataMapper ::New();
952                 dsm1->SetInput (stlInterna); 
953                 dsm1->ScalarVisibilityOff();
954
955                 actorInternal = vtkActor::New();
956                 actorInternal->SetMapper (dsm1);
957                 actorInternal->GetProperty()->SetColor (0,1,0);
958
959                 dsm2 = vtkPolyDataMapper ::New();
960                 dsm2->SetInput (stlExterna);
961                 dsm2->ScalarVisibilityOff();
962
963                 actorExternal= vtkActor::New();
964                 actorExternal->SetMapper (dsm2);
965                 actorExternal->GetProperty()->SetRepresentationToWireframe();
966
967         //    vtkRenderer *ren = _maracasSurfaceWidget->GetVtk3DSurfaceWidget()->GetRenderer();
968                 vtkRenderer *ren = _wxMaracasMPR->GetWxvtkmpr3Dview_BB()->GetWxvtk3Dbaseview()->GetRenderer();
969                 ren->AddActor(actorInternal);
970                 ren->AddActor(actorExternal);
971
972                 stlExtractor = new vtkSTLExtractor();  
973
974         }
975
976         
977 }
978
979 void wxSTLWidget_03::generateSTLSurfaces()
980 {
981 // EED 09Janvier2007
982 //      stlExtractor->setVolume(_2_prgov->GetVolumen());
983
984         stlExtractor->setVolume(cast4->GetOutput());
985
986         stlExtractor->setSigmaLevel(_stlDeltaGaussLevel);
987         stlExtractor->setMarchingCubesLevel(_stlMarchingCubesLevel);
988         stlExtractor->calculate();
989         stlInterna->DeepCopy(stlExtractor->getInnerSurface());
990         stlExterna->DeepCopy(stlExtractor->getOuterSurface());
991 }
992
993
994 void wxSTLWidget_03::OnOpacitySTLExternal(wxScrollEvent& event){
995         double value = ((double)stlSliderOpacityExternal->GetValue())/100;
996     actorExternal->GetProperty( )->SetOpacity( value );
997         Refresh();
998 }
999
1000
1001 void wxSTLWidget_03::OnOpacitySTLInternal(wxScrollEvent& event){
1002         double value = ((double)stlSliderOpacityInternal->GetValue())/100;
1003     actorInternal->GetProperty( )->SetOpacity( value );
1004         Refresh();
1005 }
1006
1007 void wxSTLWidget_03::OnBtnCreateFileSTL(wxCommandEvent& event)
1008 {
1009
1010         wxString dirSTL;// = _mar->_parameters->getStringParam( 
1011     //marParameters::e_installation_directory ); 
1012         dirSTL = ( dirSTL == _T("NO_DIRECTORY") ) ? wxGetHomeDir( ) : dirSTL;
1013
1014         
1015 //      wxDirDialog dialog( this, "Choose a directory...", ( !dirSTL.IsEmpty( ) )?dirSTL: wxGetHomeDir( ) );
1016         wxFileDialog dialog( this, _T("Choose a directory..."), dirSTL , _T(""), _T("*.*"), wxSAVE );
1017
1018
1019         if( dialog.ShowModal( ) == wxID_OK ) 
1020         {
1021            
1022         
1023                 // ------------------------------------------------------------------------
1024                 //  1.  GENERATE STL FILES
1025                 // ------------------------------------------------------------------------
1026 //              const char* fileprefix = "c:\\Creatis\\";
1027                 std::string prefix ( dialog.GetPath().mb_str(wxConvUTF8) );
1028                 std::string filename;
1029
1030                 // 1.1. Se hace un filtro triangular puesto que el stl writer solo recibe poligonos triangulares.
1031
1032         vtkTriangleFilter *filtro = vtkTriangleFilter::New();
1033                 filtro->SetInput(stlInterna);
1034                 vtkPolyDataConnectivityFilter *pdcf = vtkPolyDataConnectivityFilter::New();
1035         pdcf->SetInput( filtro->GetOutput() );
1036         vtkClosePolyData *cpd = vtkClosePolyData::New();
1037         cpd->SetInput( pdcf->GetOutput() );
1038
1039                 // 1.2 se escribe a disco el archivo stl de la superficie interna
1040         cpd->Update();
1041         vtkSTLWriter *writerI = vtkSTLWriter::New();
1042         writerI->SetInput( cpd->GetOutput() );
1043 //        prefix = fileprefix;
1044                 filename=prefix+"_internal.stl";
1045         writerI->SetFileName(filename.c_str());
1046         writerI->SetFileTypeToASCII();
1047         writerI->Write();
1048         writerI->Delete();
1049
1050                 // 1.3 se escribe a disco el archivo stl de la superficie externa
1051                 filtro->SetInput(stlExterna);
1052         cpd->Update();
1053         vtkSTLWriter *writerE = vtkSTLWriter::New();
1054         writerE->SetInput( cpd->GetOutput() );
1055 //        prefix = fileprefix;
1056                 filename=prefix+"_external.stl";
1057         writerE->SetFileName( filename.c_str() );
1058         writerE->SetFileTypeToASCII();
1059         writerE->Write();
1060         writerE->Delete();
1061    
1062         filtro->Delete();
1063         cpd->Delete();
1064         pdcf->Delete();
1065         }
1066
1067         //By default *always* update e_installation_directory:
1068         //_mar->_parameters->setStringParam( marParameters::e_installation_directory, dialog.GetPath( ) ); 
1069         //_mar->saveParameters( );
1070 }
1071
1072
1073 void wxSTLWidget_03::OnChangeSTLGaussLevel(wxScrollEvent& event)
1074 {
1075         wxBusyCursor wait;
1076         _stlDeltaGaussLevel  = ((double)stlSliderDeltaGauss->GetValue())/100;
1077         generateSTLSurfaces();
1078         Refresh();
1079 }
1080
1081
1082 void wxSTLWidget_03::OnChangeSTLMarchingCubesLevel(wxScrollEvent& event)
1083 {
1084         wxBusyCursor wait;
1085         _stlMarchingCubesLevel = ((double)stlSliderMarchingCubes->GetValue());
1086         generateSTLSurfaces();
1087         Refresh();
1088         
1089 }
1090
1091
1092 // ------------------------------------------------------------------------
1093 // END STL FUNCTIONS - DHC
1094 // ------------------------------------------------------------------------
1095
1096
1097
1098
1099
1100
1101