1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
26 /*=========================================================================
29 Module: $RCSfile: marInterfaceCT.cpp,v $
31 Date: $Date: 2012/11/15 14:15:31 $
32 Version: $Revision: 1.2 $
34 Copyright: (c) 2002, 2003
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 =========================================================================*/
42 #pragma warning ( disable : 4786 )
43 #pragma warning ( disable : 4251 )
46 #include "marInterfaceCT.h"
53 // ----------------------------------------------------------------------------
54 marInterfaceCT::marInterfaceCT( )
55 : _parameters( NULL ), _dicom( NULL ),
58 m_paramFileName=MAR_DEFAULT_FILE_PARAMETERS;
59 _parameters = new marParameters( );
61 _experiment = new marExperimentCT( _parameters );
66 // ----------------------------------------------------------------------------
67 marInterfaceCT::~marInterfaceCT( ){
71 // ----------------------------------------------------------------------------
72 bool marInterfaceCT::loadParameters( std::string pFile )
74 std::ifstream is( pFile.c_str( ),std::ios::binary|std::ios::in);
77 // wxLogDebug(wxString("Loading parameters from file ")
78 // + wxString(pFile.c_str()));
83 errorMsg= wxString(_T("Error : Cannot open file "))
84 + wxString((wxChar*)pFile.c_str(), wxConvUTF8)
85 + wxString(_T(" to load parameters"));
87 // wxLogDebug(errorMsg);
90 _parameters->reset( );
91 if (_parameters->load( is ))
100 // wxLogDebug(wxString("Error : Cannot load parameters from file ")
101 // + wxString(pFile.c_str())
102 // + wxString(": file may be corrupted"));
107 // ----------------------------------------------------------------------------
108 bool marInterfaceCT::saveParameters( std::string pFile )
110 std::ofstream os(pFile.c_str( ),std::ios::binary | std::ios::out);
113 // wxLogDebug(wxString("Saving parameters to file ")
114 // + wxString(pFile.c_str()));
120 errorMsg= wxString(_T("Error : Cannot open file "))
121 + wxString( (wxChar*)pFile.c_str(), wxConvUTF8)
122 + wxString(_T(" to save parameters"));
124 // wxLogDebug(errorMsg);
127 if(_parameters->save( os ))
136 // wxLogDebug(wxString("Error : Cannot save parameters to file ")
137 // + wxString(pFile.c_str()));
143 // ----------------------------------------------------------------------------
144 bool marInterfaceCT::initExperiment( )
146 _experiment->reset( );
147 _experiment->initExperiment( _dicom->getVolume( ) );
151 // ----------------------------------------------------------------------------
152 bool marInterfaceCT::saveExperiment( std::string nFile )
154 std::ofstream os( nFile.c_str( ),std::ios::binary | std::ios::out );
157 // wxLogDebug(wxString("Saving experiment to file ")
158 // + wxString(nFile.c_str()));
161 errorMsg= wxString(_T("Cannot open file "))
162 + wxString((wxChar*)nFile.c_str(), wxConvUTF8)
163 + wxString(_T(" to save experiment"));
168 _parameters->save( os );
170 _experiment->save( os );
176 // wxLogDebug(errorMsg);
180 // ----------------------------------------------------------------------------
181 bool marInterfaceCT::loadExperiment( std::string nFile )
183 std::ifstream is( nFile.c_str( ) ,std::ios::binary|std::ios::in );
186 // wxLogDebug(wxString("Loading experiment from file ")
187 // + wxString(nFile.c_str()));
190 errorMsg= wxString(_T("Cannot open file "))
191 + wxString((wxChar*)nFile.c_str(), wxConvUTF8)
192 + wxString(_T(" to load experiment"));
196 _parameters->reset( );
198 _experiment->reset( );
200 _parameters->load( is );
202 _experiment->load( is );
208 // wxLogDebug(errorMsg);
212 // ----------------------------------------------------------------------------
213 void marInterfaceCT::reset( ){
214 if( _experiment != NULL ) delete _experiment;
215 if( _dicom != NULL ) delete _dicom;
216 if( _parameters != NULL ) delete _parameters;
221 // ----------------------------------------------------------------------------
222 void marInterfaceCT::SetParamFileName(std::string pFileName) {
223 m_paramFileName=pFileName;
225 // ----------------------------------------------------------------------------
226 std::string marInterfaceCT::GetParamFileName() {
227 return m_paramFileName;
229 // ----------------------------------------------------------------------------
230 void marInterfaceCT::SetDicom(marFilesBase *dicom) {
234 // ----------------------------------------------------------------------------
235 void marInterfaceCT::appendAxis( marAxis* ax )
237 _experiment->appendAxis(ax);
241 // ----------------------------------------------------------------------------
242 marAxisCT* marInterfaceCT::getAxis( int i ) {
243 return (marAxisCT *) _experiment->getAxis(i);
246 // ----------------------------------------------------------------------------
247 void marInterfaceCT::setAxis( int i )
249 _experiment->setAxis(i);
252 // ----------------------------------------------------------------------------
253 int marInterfaceCT::getQuantStart( ) {
254 return _experiment->getQuantStart( );
257 // ----------------------------------------------------------------------------
258 int marInterfaceCT::getQuantFinish( ) {
259 return _experiment->getQuantFinish( );
262 // ----------------------------------------------------------------------------
263 void marInterfaceCT::prepareQuantification( ) {
264 _experiment->prepareQuantification( );
268 // ----------------------------------------------------------------------------
269 vtkImageData* marInterfaceCT::getSliceImage( int i ) {
270 return _experiment->getSliceImage( i );
273 // ----------------------------------------------------------------------------
274 vtkProbeFilter* marInterfaceCT::get3DSlice( int i ) {
275 return _experiment->get3DSlice( i );
278 // ----------------------------------------------------------------------------
279 double marInterfaceCT::getTotalLength( ) {
280 return _experiment->getTotalLength( );
283 // ----------------------------------------------------------------------------
284 double marInterfaceCT::getSubAxisLength( ) {
285 return _experiment->getSubAxisLength( );
288 // ----------------------------------------------------------------------------
289 double marInterfaceCT::getReferenceArea( ) {
290 return _experiment->getReferenceArea( );
293 // ----------------------------------------------------------------------------
294 double marInterfaceCT::getReferenceAverDiam() {
295 return _experiment->getReferenceAverDiam( );
298 // ----------------------------------------------------------------------------
299 double marInterfaceCT::getAverageArea(int pIni, int pEnd) {
300 return _experiment->getAverageArea(pIni,pEnd);
303 // ----------------------------------------------------------------------------
304 int marInterfaceCT::getNumberOfSlices( ) {
305 return _experiment->getNumberOfSlices( );
308 // ----------------------------------------------------------------------------
309 int marInterfaceCT::getActualQuant( ) {
310 return _experiment->getAxis()->getActualQuant();
313 // ----------------------------------------------------------------------------
314 marExperimentCT* marInterfaceCT::GetExperiment()
319 // ----------------------------------------------------------------------------
320 int marInterfaceCT::getHealthySlice( ) {
321 return _experiment->getAxis( )->getHealthySlice( );
324 // ----------------------------------------------------------------------------
325 int marInterfaceCT::getHealthySliceStart( ) {
326 return _experiment->getAxis()->getHealthySliceStart( );
329 // ----------------------------------------------------------------------------
330 int marInterfaceCT::getHealthySliceEnd( ) {
331 return _experiment->getAxis()->getHealthySliceEnd( );
334 // ----------------------------------------------------------------------------
335 void marInterfaceCT::setHealthySlice( int hsS, int hs, int hsE ) {
336 _experiment->getAxis()->setHealthySlice(hsS,hs,hsE);
339 // ----------------------------------------------------------------------------
340 void marInterfaceCT::setActualQuant(int act) {
341 _experiment->getAxis()->setActualQuant( act ) ;
344 // ----------------------------------------------------------------------------
345 void marInterfaceCT::replaceContour2D(int i,int size,double *vx,double *vy) {
346 _experiment->getAxis()->replaceContour2D(i,size,vx,vy);
349 void marInterfaceCT::replaceContour2D(int size,double *vx,double *vy, int type)
351 _experiment->replaceContour2D(size,vx,vy,type);
354 // ----------------------------------------------------------------------------
355 void marInterfaceCT::EraseContour( int i ) {
356 _experiment->getAxis()->EraseContour( i );
359 // ----------------------------------------------------------------------------
360 void marInterfaceCT::ClearContours() {
361 _experiment->ClearContours();
364 // ----------------------------------------------------------------------------
365 void marInterfaceCT::RegenerateAxis() {
366 _experiment->RegenerateAxis();
369 // ----------------------------------------------------------------------------
370 void marInterfaceCT::RegenerateSignal() {
371 _experiment->RegenerateSignal();
374 // ----------------------------------------------------------------------------
375 void marInterfaceCT::RecalculateAxis() {
376 _experiment->RegenerateAxis();
379 // ----------------------------------------------------------------------------
380 void marInterfaceCT::getMinMax( double& min, double& max ) {
381 _experiment->getDynData( )->getVolume( )->getMinMax( min, max );
384 // ----------------------------------------------------------------------------
385 marContour* marInterfaceCT::getContour( int point, int contour ) {
386 return _experiment->getContour(point,contour);
389 // ----------------------------------------------------------------------------
390 vtkPoints* marInterfaceCT::get3Dcontour( int point, int contour ) {
391 return _experiment->get3Dcontour(point,contour);
394 // ----------------------------------------------------------------------------
395 vtkPolyData* marInterfaceCT::get2Dcontour( int point, int contour ) {
396 return _experiment->get2Dcontour(point,contour);
399 // ----------------------------------------------------------------------------
400 vtkPoints* marInterfaceCT::get2DDiameterMin( int point, int contour ) {
401 return _experiment->get2DDiameterMin(point,contour);
404 // ----------------------------------------------------------------------------
405 vtkPoints* marInterfaceCT::get2DDiameterMax( int point, int contour ) {
406 return _experiment->get2DDiameterMax(point,contour);
409 // ----------------------------------------------------------------------------
410 marParameters* marInterfaceCT::getParameters(){
413 // ----------------------------------------------------------------------------
414 marDynData* marInterfaceCT::getDynData(){
415 return _experiment->getDynData();
418 // ----------------------------------------------------------------------------
419 int marInterfaceCT::getNumberOfContours(int point) {
420 return _experiment->getNumberOfContours(point);
424 // ----------------------------------------------------------------------------
425 void marInterfaceCT::updateLumenPercentage(int percentage) {
426 _experiment->updateLumenPercentage(percentage);
429 // ----------------------------------------------------------------------------
430 void marInterfaceCT::updateCalcPercentage(int percentage) {
431 _experiment->updateCalcPercentage(percentage);
434 // ----------------------------------------------------------------------------
435 void marInterfaceCT::updateDiscontinuityThreshold(int percentage) {
436 _experiment->updateDiscontinuityThreshold(percentage);
437 //TODO HACER RESET DEL CONTORNO
440 // ----------------------------------------------------------------------------
441 int marInterfaceCT::getContourType(int point, int index)
443 return _experiment->getContourType(point,index);
446 // ----------------------------------------------------------------------------
447 void marInterfaceCT::histogram(int point)
449 _experiment->histogram(point);
452 // ----------------------------------------------------------------------------
453 void marInterfaceCT::setCalibration(bool calib)
455 _experiment->setCalibration(calib);
458 // ----------------------------------------------------------------------------
459 bool marInterfaceCT::getCalibration()
461 return _experiment->getCalibration();
464 // ----------------------------------------------------------------------------
465 void marInterfaceCT::ClearContoursPartial(int start)
467 _experiment->ClearContoursPartial(start);
470 // ----------------------------------------------------------------------------
471 void marInterfaceCT::setStartIndex(int start)
473 _experiment->setStartIndex(start);
476 // ----------------------------------------------------------------------------
477 int marInterfaceCT::getPointSize()
479 return _experiment->getPointSize();
482 // ----------------------------------------------------------------------------
483 marPoint* marInterfaceCT::getPoint(int i)
485 return _experiment->getPoint(i);
488 // ----------------------------------------------------------------------------
489 void marInterfaceCT::markUpLumen(int point)
491 _experiment->markUpLumen(point);
494 // ----------------------------------------------------------------------------
495 void marInterfaceCT::generateFile()
497 _experiment->generateFile();
500 // ----------------------------------------------------------------------------
501 void marInterfaceCT::cleanContours(int type)
503 _experiment->cleanContours(type);
506 // ----------------------------------------------------------------------------
507 marIsocontour* marInterfaceCT::loadMarIsocontour(int size, double *vx, double *vy)
509 return _experiment->loadMarIsocontour(size,vx,vy);
512 // ----------------------------------------------------------------------------
513 double marInterfaceCT::performXOR(int type, std::vector<marIsocontour*> manual)
515 return _experiment->performXOR(type, manual);
518 // ----------------------------------------------------------------------------
519 double marInterfaceCT::performAND(int type, std::vector<marIsocontour*> manual)
521 return _experiment->performAND(type, manual);
525 double marInterfaceCT::performUnion(int type, std::vector<marIsocontour*> manual)
527 return _experiment->performUnion(type, manual);
529 // eof - marInterfaceCT.cxx