]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/kernel/include/marInterfaceCT.cpp
BUG macOs
[creaMaracasVisu.git] / lib / maracasVisuLib / src / kernel / include / marInterfaceCT.cpp
1 /*=========================================================================
2
3  Program:   wxMaracas
4  Module:    $RCSfile: marInterfaceCT.cpp,v $
5  Language:  C++
6  Date:      $Date: 2009/05/14 13:55:08 $
7  Version:   $Revision: 1.1 $
8  
9   Copyright: (c) 2002, 2003
10   License:
11   
12    This software is distributed WITHOUT ANY WARRANTY; without even 
13    the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14    PURPOSE.  See the above copyright notice for more information.
15 =========================================================================*/
16 #ifdef _MSC_VER
17 #pragma warning ( disable : 4786 )
18 #pragma warning ( disable : 4251 )
19 #endif //_MSC_VER
20
21 #include "marInterfaceCT.h"
22 #include <wx/file.h>
23 #include <wx/log.h>
24
25
26
27
28 // ----------------------------------------------------------------------------
29 marInterfaceCT::marInterfaceCT( )
30 : _parameters( NULL ), _dicom( NULL ),
31 _experiment( NULL )
32 {
33         m_paramFileName=MAR_DEFAULT_FILE_PARAMETERS;
34     _parameters = new marParameters( );
35
36     _experiment = new marExperimentCT( _parameters );
37         
38     
39 }
40
41 // ----------------------------------------------------------------------------
42 marInterfaceCT::~marInterfaceCT( ){
43     reset( );
44 }
45
46 // ----------------------------------------------------------------------------
47 bool marInterfaceCT::loadParameters( std::string pFile )
48 {
49         std::ifstream is( pFile.c_str( ),std::ios::binary|std::ios::in);
50
51 //EEDxx2.4 DEBuG
52 //      wxLogDebug(wxString("Loading parameters from file ") 
53 //              + wxString(pFile.c_str()));
54         
55         if( is==NULL )
56         {
57                 wxString errorMsg;
58                 errorMsg= wxString(_T("Error : Cannot open file "))
59                                 + wxString((wxChar*)pFile.c_str(), wxConvUTF8)
60                                 + wxString(_T(" to load parameters"));
61 //EEDxx2.4 DEBuG
62 //              wxLogDebug(errorMsg);
63                 return (false);
64         }
65         _parameters->reset( );
66         if (_parameters->load( is ))
67         {
68                 is.close( );
69                 return( true );
70         }
71         else
72         {
73                 is.close();
74 //EEDxx2.4 DEBuG
75 //              wxLogDebug(wxString("Error : Cannot load parameters from file ")
76 //                              + wxString(pFile.c_str())
77 //                              + wxString(": file may be corrupted"));
78                 return (false);
79         }
80 }
81
82 // ----------------------------------------------------------------------------
83 bool marInterfaceCT::saveParameters( std::string pFile )
84 {
85         std::ofstream os(pFile.c_str( ),std::ios::binary | std::ios::out);
86         
87 //EEDxx2.4 DEBuG
88 //      wxLogDebug(wxString("Saving parameters to file ") 
89 //                      + wxString(pFile.c_str()));
90         
91         
92         if( os==NULL )
93         {
94                 wxString errorMsg;
95                 errorMsg= wxString(_T("Error : Cannot open file "))
96                                 + wxString( (wxChar*)pFile.c_str(), wxConvUTF8)
97                                 + wxString(_T(" to save parameters"));
98 //EEDxx2.4 DEBuG
99 //              wxLogDebug(errorMsg);
100                 return( false );
101         }
102         if(_parameters->save( os ))
103         {
104                 os.close( );
105                 return( true );
106         }
107         else
108         {
109                 os.close();
110 //EEDxx2.4 DEBuG
111 //              wxLogDebug(wxString("Error : Cannot save parameters to file ")
112 //                              + wxString(pFile.c_str()));
113                 return (false);
114         }
115
116 }
117
118 // ----------------------------------------------------------------------------
119 bool marInterfaceCT::initExperiment( )
120 {
121     _experiment->reset( );
122     _experiment->initExperiment( _dicom->getVolume( ) );
123     return( true );
124         
125 }
126 // ----------------------------------------------------------------------------
127 bool marInterfaceCT::saveExperiment( std::string nFile )
128 {
129         std::ofstream os( nFile.c_str( ),std::ios::binary | std::ios::out );
130         
131 //EEDxx2.4 DEBuG
132 //      wxLogDebug(wxString("Saving experiment to file ") 
133 //                      + wxString(nFile.c_str()));
134         
135         wxString errorMsg;
136         errorMsg= wxString(_T("Cannot open file "))
137                         + wxString((wxChar*)nFile.c_str(), wxConvUTF8)
138                         + wxString(_T(" to save experiment"));
139
140         
141     if( os !=NULL ) {
142                 
143         _parameters->save( os );
144         _dicom->save( os );
145         _experiment->save( os );
146                 os.close( );
147                 return( true );
148                 
149     } // fi
150 //EEDxx2.4 DEBuG
151 //      wxLogDebug(errorMsg);
152     return( false );
153 }
154
155 // ----------------------------------------------------------------------------
156 bool marInterfaceCT::loadExperiment( std::string nFile )
157 {
158         std::ifstream is( nFile.c_str( ) ,std::ios::binary|std::ios::in );
159         
160 //EEDxx2.4 DEBuG
161 //      wxLogDebug(wxString("Loading experiment from file ") 
162 //                      + wxString(nFile.c_str()));
163         
164         wxString errorMsg;
165         errorMsg= wxString(_T("Cannot open file "))
166                         + wxString((wxChar*)nFile.c_str(), wxConvUTF8)
167                         + wxString(_T(" to load experiment"));
168         
169     if( is !=NULL) {
170                 
171         _parameters->reset( );
172         _dicom->reset( );
173         _experiment->reset( );
174                 
175         _parameters->load( is );
176         _dicom->load( is );
177         _experiment->load( is );
178                 is.close( );
179                 return( true );
180                 
181     } // fi
182 //EEDxx2.4 DEBuG
183 //      wxLogDebug(errorMsg);
184     return( false );
185 }
186
187 // ----------------------------------------------------------------------------
188 void marInterfaceCT::reset( ){
189     if( _experiment != NULL ) delete _experiment;
190     if( _dicom != NULL ) delete _dicom;
191     if( _parameters != NULL ) delete _parameters;
192     _experiment = NULL;
193     _dicom = NULL;
194     _parameters = NULL;
195 }
196 // ----------------------------------------------------------------------------
197 void marInterfaceCT::SetParamFileName(std::string pFileName) { 
198         m_paramFileName=pFileName; 
199 }
200 // ----------------------------------------------------------------------------
201 std::string  marInterfaceCT::GetParamFileName() { 
202         return m_paramFileName;  
203 }
204 // ----------------------------------------------------------------------------
205 void marInterfaceCT::SetDicom(marFilesBase *dicom) {
206         _dicom=dicom;                            
207 }
208
209 // ----------------------------------------------------------------------------
210 void marInterfaceCT::appendAxis( marAxis* ax )
211 {
212     _experiment->appendAxis(ax);
213 }
214
215
216 // ----------------------------------------------------------------------------
217 marAxisCT* marInterfaceCT::getAxis( int i ) {
218         return (marAxisCT *) _experiment->getAxis(i);
219 }
220
221 // ----------------------------------------------------------------------------
222 void marInterfaceCT::setAxis( int i )
223 {
224    _experiment->setAxis(i);
225 }
226
227 // ----------------------------------------------------------------------------
228 int marInterfaceCT::getQuantStart( ) {
229         return _experiment->getQuantStart( );
230 }
231
232 // ----------------------------------------------------------------------------
233 int marInterfaceCT::getQuantFinish( ) {
234         return _experiment->getQuantFinish( );
235 }
236  
237 // ----------------------------------------------------------------------------
238 void marInterfaceCT::prepareQuantification( ) {
239         _experiment->prepareQuantification( );
240 }
241
242
243 // ----------------------------------------------------------------------------
244 vtkImageData* marInterfaceCT::getSliceImage( int i ) {
245         return _experiment->getSliceImage( i );
246 }
247
248 // ----------------------------------------------------------------------------
249 vtkProbeFilter* marInterfaceCT::get3DSlice( int i ) {
250         return _experiment->get3DSlice( i );
251 }
252
253 // ----------------------------------------------------------------------------
254 double marInterfaceCT::getTotalLength( ) {
255         return _experiment->getTotalLength( );
256 }
257
258 // ----------------------------------------------------------------------------
259 double marInterfaceCT::getSubAxisLength( ) {
260         return _experiment->getSubAxisLength( );
261 }
262
263 // ----------------------------------------------------------------------------
264 double marInterfaceCT::getReferenceArea( ) {
265                 return _experiment->getReferenceArea( );
266 }
267
268 // ----------------------------------------------------------------------------
269 double  marInterfaceCT::getReferenceAverDiam() {
270         return _experiment->getReferenceAverDiam( );
271 }
272
273 // ----------------------------------------------------------------------------
274 double marInterfaceCT::getAverageArea(int pIni, int pEnd) {
275         return _experiment->getAverageArea(pIni,pEnd);
276 }
277
278 // ----------------------------------------------------------------------------
279 int marInterfaceCT::getNumberOfSlices( ) {
280         return _experiment->getNumberOfSlices( );
281 }
282
283 // ---------------------------------------------------------------------------- 
284 int marInterfaceCT::getActualQuant( ) {
285         return _experiment->getAxis()->getActualQuant();
286 }
287
288 // ----------------------------------------------------------------------------
289 marExperimentCT* marInterfaceCT::GetExperiment()
290 {
291         return _experiment;
292 }
293
294 // ----------------------------------------------------------------------------
295 int marInterfaceCT::getHealthySlice( ) {
296         return _experiment->getAxis( )->getHealthySlice( );
297 }
298
299 // ----------------------------------------------------------------------------
300 int marInterfaceCT::getHealthySliceStart( ) {
301         return _experiment->getAxis()->getHealthySliceStart( );
302 }
303
304 // ----------------------------------------------------------------------------
305 int marInterfaceCT::getHealthySliceEnd( ) {
306         return _experiment->getAxis()->getHealthySliceEnd( );
307 }
308
309 // ----------------------------------------------------------------------------
310 void marInterfaceCT::setHealthySlice( int hsS, int hs, int hsE ) {
311         _experiment->getAxis()->setHealthySlice(hsS,hs,hsE);
312         
313 }
314 // ----------------------------------------------------------------------------
315 void marInterfaceCT::setActualQuant(int act) {
316         _experiment->getAxis()->setActualQuant( act ) ;
317 }
318
319 // ----------------------------------------------------------------------------
320 void marInterfaceCT::replaceContour2D(int i,int size,double *vx,double *vy) {
321         _experiment->getAxis()->replaceContour2D(i,size,vx,vy);
322 }
323
324 void marInterfaceCT::replaceContour2D(int size,double *vx,double *vy, int type)
325 {
326         _experiment->replaceContour2D(size,vx,vy,type);
327 }
328
329 // ----------------------------------------------------------------------------
330 void marInterfaceCT::EraseContour( int i ) {
331         _experiment->getAxis()->EraseContour( i );
332 }
333
334 // ----------------------------------------------------------------------------
335 void marInterfaceCT::ClearContours() {
336         _experiment->ClearContours();
337 }
338
339 // ----------------------------------------------------------------------------
340 void marInterfaceCT::RegenerateAxis() {
341         _experiment->RegenerateAxis();
342 }
343
344 // ----------------------------------------------------------------------------
345 void marInterfaceCT::RegenerateSignal() {
346         _experiment->RegenerateSignal();
347 }
348
349 // ----------------------------------------------------------------------------
350 void marInterfaceCT::RecalculateAxis() {
351         _experiment->RegenerateAxis();
352 }
353
354 // ---------------------------------------------------------------------------- 
355 void marInterfaceCT::getMinMax( double& min, double& max ) {
356         _experiment->getDynData( )->getVolume( )->getMinMax( min, max );
357 }
358
359 // ---------------------------------------------------------------------------- 
360 marContour* marInterfaceCT::getContour( int point, int contour ) {
361         return _experiment->getContour(point,contour);
362 }
363
364 // ---------------------------------------------------------------------------- 
365 vtkPoints*      marInterfaceCT::get3Dcontour( int point, int contour ) {
366         return _experiment->get3Dcontour(point,contour);
367 }
368
369 // ---------------------------------------------------------------------------- 
370 vtkPolyData* marInterfaceCT::get2Dcontour( int point, int contour ) {
371         return _experiment->get2Dcontour(point,contour);
372 }
373
374 // ---------------------------------------------------------------------------- 
375 vtkPoints* marInterfaceCT::get2DDiameterMin( int point, int contour ) {
376         return _experiment->get2DDiameterMin(point,contour);
377 }
378
379 // ---------------------------------------------------------------------------- 
380 vtkPoints* marInterfaceCT::get2DDiameterMax( int point, int contour ) {
381         return _experiment->get2DDiameterMax(point,contour);
382 }
383
384 // ---------------------------------------------------------------------------- 
385 marParameters* marInterfaceCT::getParameters(){
386         return _parameters;
387 }
388 // ---------------------------------------------------------------------------- 
389 marDynData* marInterfaceCT::getDynData(){
390         return  _experiment->getDynData();
391 }
392
393 // ---------------------------------------------------------------------------- 
394 int marInterfaceCT::getNumberOfContours(int point) {
395         return _experiment->getNumberOfContours(point);
396 }
397
398
399 // ----------------------------------------------------------------------------
400 void marInterfaceCT::updateLumenPercentage(int percentage) {
401         _experiment->updateLumenPercentage(percentage);
402 }
403
404 // ----------------------------------------------------------------------------
405 void marInterfaceCT::updateCalcPercentage(int percentage) {
406         _experiment->updateCalcPercentage(percentage);
407 }
408
409 // ----------------------------------------------------------------------------
410 void marInterfaceCT::updateDiscontinuityThreshold(int percentage) {
411         _experiment->updateDiscontinuityThreshold(percentage);
412         //TODO HACER RESET DEL CONTORNO
413 }
414
415 // ----------------------------------------------------------------------------
416 int marInterfaceCT::getContourType(int point, int index)
417 {
418         return _experiment->getContourType(point,index);
419 }
420
421 // ----------------------------------------------------------------------------
422 void marInterfaceCT::histogram(int point)
423 {
424         _experiment->histogram(point);
425 }
426
427 // ----------------------------------------------------------------------------
428 void marInterfaceCT::setCalibration(bool calib)
429 {
430         _experiment->setCalibration(calib);
431 }
432
433 // ----------------------------------------------------------------------------
434 bool marInterfaceCT::getCalibration()
435 {
436         return _experiment->getCalibration();
437 }
438
439 // ----------------------------------------------------------------------------
440 void marInterfaceCT::ClearContoursPartial(int start)
441 {
442         _experiment->ClearContoursPartial(start);
443 }
444
445 // ----------------------------------------------------------------------------
446 void marInterfaceCT::setStartIndex(int start)
447 {
448         _experiment->setStartIndex(start);
449 }
450
451 // ----------------------------------------------------------------------------
452 int     marInterfaceCT::getPointSize()
453 {
454         return _experiment->getPointSize();
455 }
456
457 // ----------------------------------------------------------------------------
458 marPoint* marInterfaceCT::getPoint(int i)
459 {
460         return _experiment->getPoint(i);
461 }
462
463 // ----------------------------------------------------------------------------
464 void marInterfaceCT::markUpLumen(int point)
465 {
466         _experiment->markUpLumen(point);
467 }
468
469 // ----------------------------------------------------------------------------
470 void marInterfaceCT::generateFile()
471 {
472         _experiment->generateFile();
473 }
474
475 // ----------------------------------------------------------------------------
476 void marInterfaceCT::cleanContours(int type)
477 {
478         _experiment->cleanContours(type);
479 }
480
481 // ----------------------------------------------------------------------------
482 marIsocontour* marInterfaceCT::loadMarIsocontour(int size, double *vx, double *vy)
483 {
484         return _experiment->loadMarIsocontour(size,vx,vy);
485 }
486
487 // ----------------------------------------------------------------------------
488 double marInterfaceCT::performXOR(int type, std::vector<marIsocontour*> manual)
489 {
490         return _experiment->performXOR(type, manual);
491 }
492
493 // ----------------------------------------------------------------------------
494 double marInterfaceCT::performAND(int type, std::vector<marIsocontour*> manual)
495 {
496         return _experiment->performAND(type, manual);
497 }
498
499
500 double marInterfaceCT::performUnion(int type, std::vector<marIsocontour*> manual)
501 {
502         return _experiment->performUnion(type, manual);
503 }
504 // eof - marInterfaceCT.cxx
505
506