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