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