marInterfaceCT.cpp

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003  Program:   wxMaracas
00004  Module:    $RCSfile: marInterfaceCT.cpp,v $
00005  Language:  C++
00006  Date:      $Date: 2009/05/14 13:55:08 $
00007  Version:   $Revision: 1.1 $
00008  
00009   Copyright: (c) 2002, 2003
00010   License:
00011   
00012    This software is distributed WITHOUT ANY WARRANTY; without even 
00013    the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014    PURPOSE.  See the above copyright notice for more information.
00015 =========================================================================*/
00016 #ifdef _MSC_VER
00017 #pragma warning ( disable : 4786 )
00018 #pragma warning ( disable : 4251 )
00019 #endif //_MSC_VER
00020 
00021 #include "marInterfaceCT.h"
00022 #include <wx/file.h>
00023 #include <wx/log.h>
00024 
00025 
00026 
00027 
00028 // ----------------------------------------------------------------------------
00029 marInterfaceCT::marInterfaceCT( )
00030 : _parameters( NULL ), _dicom( NULL ),
00031 _experiment( NULL )
00032 {
00033         m_paramFileName=MAR_DEFAULT_FILE_PARAMETERS;
00034     _parameters = new marParameters( );
00035 
00036     _experiment = new marExperimentCT( _parameters );
00037         
00038     
00039 }
00040 
00041 // ----------------------------------------------------------------------------
00042 marInterfaceCT::~marInterfaceCT( ){
00043     reset( );
00044 }
00045 
00046 // ----------------------------------------------------------------------------
00047 bool marInterfaceCT::loadParameters( std::string pFile )
00048 {
00049         std::ifstream is( pFile.c_str( ),std::ios::binary|std::ios::in);
00050 
00051 //EEDxx2.4 DEBuG
00052 //      wxLogDebug(wxString("Loading parameters from file ") 
00053 //              + wxString(pFile.c_str()));
00054         
00055         if( is==NULL )
00056         {
00057                 wxString errorMsg;
00058                 errorMsg= wxString(_T("Error : Cannot open file "))
00059                                 + wxString((wxChar*)pFile.c_str(), wxConvUTF8)
00060                                 + wxString(_T(" to load parameters"));
00061 //EEDxx2.4 DEBuG
00062 //              wxLogDebug(errorMsg);
00063                 return (false);
00064         }
00065         _parameters->reset( );
00066         if (_parameters->load( is ))
00067         {
00068                 is.close( );
00069                 return( true );
00070         }
00071         else
00072         {
00073                 is.close();
00074 //EEDxx2.4 DEBuG
00075 //              wxLogDebug(wxString("Error : Cannot load parameters from file ")
00076 //                              + wxString(pFile.c_str())
00077 //                              + wxString(": file may be corrupted"));
00078                 return (false);
00079         }
00080 }
00081 
00082 // ----------------------------------------------------------------------------
00083 bool marInterfaceCT::saveParameters( std::string pFile )
00084 {
00085         std::ofstream os(pFile.c_str( ),std::ios::binary | std::ios::out);
00086         
00087 //EEDxx2.4 DEBuG
00088 //      wxLogDebug(wxString("Saving parameters to file ") 
00089 //                      + wxString(pFile.c_str()));
00090         
00091         
00092         if( os==NULL )
00093         {
00094                 wxString errorMsg;
00095                 errorMsg= wxString(_T("Error : Cannot open file "))
00096                                 + wxString( (wxChar*)pFile.c_str(), wxConvUTF8)
00097                                 + wxString(_T(" to save parameters"));
00098 //EEDxx2.4 DEBuG
00099 //              wxLogDebug(errorMsg);
00100                 return( false );
00101         }
00102         if(_parameters->save( os ))
00103         {
00104                 os.close( );
00105                 return( true );
00106         }
00107         else
00108         {
00109                 os.close();
00110 //EEDxx2.4 DEBuG
00111 //              wxLogDebug(wxString("Error : Cannot save parameters to file ")
00112 //                              + wxString(pFile.c_str()));
00113                 return (false);
00114         }
00115 
00116 }
00117 
00118 // ----------------------------------------------------------------------------
00119 bool marInterfaceCT::initExperiment( )
00120 {
00121     _experiment->reset( );
00122     _experiment->initExperiment( _dicom->getVolume( ) );
00123     return( true );
00124         
00125 }
00126 // ----------------------------------------------------------------------------
00127 bool marInterfaceCT::saveExperiment( std::string nFile )
00128 {
00129         std::ofstream os( nFile.c_str( ),std::ios::binary | std::ios::out );
00130         
00131 //EEDxx2.4 DEBuG
00132 //      wxLogDebug(wxString("Saving experiment to file ") 
00133 //                      + wxString(nFile.c_str()));
00134         
00135         wxString errorMsg;
00136         errorMsg= wxString(_T("Cannot open file "))
00137                         + wxString((wxChar*)nFile.c_str(), wxConvUTF8)
00138                         + wxString(_T(" to save experiment"));
00139 
00140         
00141     if( os !=NULL ) {
00142                 
00143         _parameters->save( os );
00144         _dicom->save( os );
00145         _experiment->save( os );
00146                 os.close( );
00147                 return( true );
00148                 
00149     } // fi
00150 //EEDxx2.4 DEBuG
00151 //      wxLogDebug(errorMsg);
00152     return( false );
00153 }
00154 
00155 // ----------------------------------------------------------------------------
00156 bool marInterfaceCT::loadExperiment( std::string nFile )
00157 {
00158         std::ifstream is( nFile.c_str( ) ,std::ios::binary|std::ios::in );
00159         
00160 //EEDxx2.4 DEBuG
00161 //      wxLogDebug(wxString("Loading experiment from file ") 
00162 //                      + wxString(nFile.c_str()));
00163         
00164         wxString errorMsg;
00165         errorMsg= wxString(_T("Cannot open file "))
00166                         + wxString((wxChar*)nFile.c_str(), wxConvUTF8)
00167                         + wxString(_T(" to load experiment"));
00168         
00169     if( is !=NULL) {
00170                 
00171         _parameters->reset( );
00172         _dicom->reset( );
00173         _experiment->reset( );
00174                 
00175         _parameters->load( is );
00176         _dicom->load( is );
00177         _experiment->load( is );
00178                 is.close( );
00179                 return( true );
00180                 
00181     } // fi
00182 //EEDxx2.4 DEBuG
00183 //      wxLogDebug(errorMsg);
00184     return( false );
00185 }
00186 
00187 // ----------------------------------------------------------------------------
00188 void marInterfaceCT::reset( ){
00189     if( _experiment != NULL ) delete _experiment;
00190     if( _dicom != NULL ) delete _dicom;
00191     if( _parameters != NULL ) delete _parameters;
00192     _experiment = NULL;
00193     _dicom = NULL;
00194     _parameters = NULL;
00195 }
00196 // ----------------------------------------------------------------------------
00197 void marInterfaceCT::SetParamFileName(std::string pFileName) { 
00198         m_paramFileName=pFileName; 
00199 }
00200 // ----------------------------------------------------------------------------
00201 std::string  marInterfaceCT::GetParamFileName() { 
00202         return m_paramFileName;  
00203 }
00204 // ----------------------------------------------------------------------------
00205 void marInterfaceCT::SetDicom(marFilesBase *dicom) {
00206         _dicom=dicom;                            
00207 }
00208 
00209 // ----------------------------------------------------------------------------
00210 void marInterfaceCT::appendAxis( marAxis* ax )
00211 {
00212     _experiment->appendAxis(ax);
00213 }
00214 
00215 
00216 // ----------------------------------------------------------------------------
00217 marAxisCT* marInterfaceCT::getAxis( int i ) {
00218         return (marAxisCT *) _experiment->getAxis(i);
00219 }
00220 
00221 // ----------------------------------------------------------------------------
00222 void marInterfaceCT::setAxis( int i )
00223 {
00224    _experiment->setAxis(i);
00225 }
00226 
00227 // ----------------------------------------------------------------------------
00228 int marInterfaceCT::getQuantStart( ) {
00229         return _experiment->getQuantStart( );
00230 }
00231 
00232 // ----------------------------------------------------------------------------
00233 int marInterfaceCT::getQuantFinish( ) {
00234         return _experiment->getQuantFinish( );
00235 }
00236  
00237 // ----------------------------------------------------------------------------
00238 void marInterfaceCT::prepareQuantification( ) {
00239         _experiment->prepareQuantification( );
00240 }
00241 
00242 
00243 // ----------------------------------------------------------------------------
00244 vtkImageData* marInterfaceCT::getSliceImage( int i ) {
00245         return _experiment->getSliceImage( i );
00246 }
00247 
00248 // ----------------------------------------------------------------------------
00249 vtkProbeFilter* marInterfaceCT::get3DSlice( int i ) {
00250         return _experiment->get3DSlice( i );
00251 }
00252 
00253 // ----------------------------------------------------------------------------
00254 double marInterfaceCT::getTotalLength( ) {
00255         return _experiment->getTotalLength( );
00256 }
00257 
00258 // ----------------------------------------------------------------------------
00259 double marInterfaceCT::getSubAxisLength( ) {
00260         return _experiment->getSubAxisLength( );
00261 }
00262 
00263 // ----------------------------------------------------------------------------
00264 double marInterfaceCT::getReferenceArea( ) {
00265                 return _experiment->getReferenceArea( );
00266 }
00267 
00268 // ----------------------------------------------------------------------------
00269 double  marInterfaceCT::getReferenceAverDiam() {
00270         return _experiment->getReferenceAverDiam( );
00271 }
00272 
00273 // ----------------------------------------------------------------------------
00274 double marInterfaceCT::getAverageArea(int pIni, int pEnd) {
00275         return _experiment->getAverageArea(pIni,pEnd);
00276 }
00277 
00278 // ----------------------------------------------------------------------------
00279 int marInterfaceCT::getNumberOfSlices( ) {
00280         return _experiment->getNumberOfSlices( );
00281 }
00282 
00283 // ---------------------------------------------------------------------------- 
00284 int marInterfaceCT::getActualQuant( ) {
00285         return _experiment->getAxis()->getActualQuant();
00286 }
00287 
00288 // ----------------------------------------------------------------------------
00289 marExperimentCT* marInterfaceCT::GetExperiment()
00290 {
00291         return _experiment;
00292 }
00293 
00294 // ----------------------------------------------------------------------------
00295 int marInterfaceCT::getHealthySlice( ) {
00296         return _experiment->getAxis( )->getHealthySlice( );
00297 }
00298 
00299 // ----------------------------------------------------------------------------
00300 int marInterfaceCT::getHealthySliceStart( ) {
00301         return _experiment->getAxis()->getHealthySliceStart( );
00302 }
00303 
00304 // ----------------------------------------------------------------------------
00305 int marInterfaceCT::getHealthySliceEnd( ) {
00306         return _experiment->getAxis()->getHealthySliceEnd( );
00307 }
00308 
00309 // ----------------------------------------------------------------------------
00310 void marInterfaceCT::setHealthySlice( int hsS, int hs, int hsE ) {
00311         _experiment->getAxis()->setHealthySlice(hsS,hs,hsE);
00312         
00313 }
00314 // ----------------------------------------------------------------------------
00315 void marInterfaceCT::setActualQuant(int act) {
00316         _experiment->getAxis()->setActualQuant( act ) ;
00317 }
00318 
00319 // ----------------------------------------------------------------------------
00320 void marInterfaceCT::replaceContour2D(int i,int size,double *vx,double *vy) {
00321         _experiment->getAxis()->replaceContour2D(i,size,vx,vy);
00322 }
00323 
00324 void marInterfaceCT::replaceContour2D(int size,double *vx,double *vy, int type)
00325 {
00326         _experiment->replaceContour2D(size,vx,vy,type);
00327 }
00328 
00329 // ----------------------------------------------------------------------------
00330 void marInterfaceCT::EraseContour( int i ) {
00331         _experiment->getAxis()->EraseContour( i );
00332 }
00333 
00334 // ----------------------------------------------------------------------------
00335 void marInterfaceCT::ClearContours() {
00336         _experiment->ClearContours();
00337 }
00338 
00339 // ----------------------------------------------------------------------------
00340 void marInterfaceCT::RegenerateAxis() {
00341         _experiment->RegenerateAxis();
00342 }
00343 
00344 // ----------------------------------------------------------------------------
00345 void marInterfaceCT::RegenerateSignal() {
00346         _experiment->RegenerateSignal();
00347 }
00348 
00349 // ----------------------------------------------------------------------------
00350 void marInterfaceCT::RecalculateAxis() {
00351         _experiment->RegenerateAxis();
00352 }
00353 
00354 // ---------------------------------------------------------------------------- 
00355 void marInterfaceCT::getMinMax( double& min, double& max ) {
00356         _experiment->getDynData( )->getVolume( )->getMinMax( min, max );
00357 }
00358 
00359 // ---------------------------------------------------------------------------- 
00360 marContour* marInterfaceCT::getContour( int point, int contour ) {
00361         return _experiment->getContour(point,contour);
00362 }
00363 
00364 // ---------------------------------------------------------------------------- 
00365 vtkPoints*      marInterfaceCT::get3Dcontour( int point, int contour ) {
00366         return _experiment->get3Dcontour(point,contour);
00367 }
00368 
00369 // ---------------------------------------------------------------------------- 
00370 vtkPolyData* marInterfaceCT::get2Dcontour( int point, int contour ) {
00371         return _experiment->get2Dcontour(point,contour);
00372 }
00373 
00374 // ---------------------------------------------------------------------------- 
00375 vtkPoints* marInterfaceCT::get2DDiameterMin( int point, int contour ) {
00376         return _experiment->get2DDiameterMin(point,contour);
00377 }
00378 
00379 // ---------------------------------------------------------------------------- 
00380 vtkPoints* marInterfaceCT::get2DDiameterMax( int point, int contour ) {
00381         return _experiment->get2DDiameterMax(point,contour);
00382 }
00383 
00384 // ---------------------------------------------------------------------------- 
00385 marParameters* marInterfaceCT::getParameters(){
00386         return _parameters;
00387 }
00388 // ---------------------------------------------------------------------------- 
00389 marDynData* marInterfaceCT::getDynData(){
00390         return  _experiment->getDynData();
00391 }
00392 
00393 // ---------------------------------------------------------------------------- 
00394 int marInterfaceCT::getNumberOfContours(int point) {
00395         return _experiment->getNumberOfContours(point);
00396 }
00397 
00398 
00399 // ----------------------------------------------------------------------------
00400 void marInterfaceCT::updateLumenPercentage(int percentage) {
00401         _experiment->updateLumenPercentage(percentage);
00402 }
00403 
00404 // ----------------------------------------------------------------------------
00405 void marInterfaceCT::updateCalcPercentage(int percentage) {
00406         _experiment->updateCalcPercentage(percentage);
00407 }
00408 
00409 // ----------------------------------------------------------------------------
00410 void marInterfaceCT::updateDiscontinuityThreshold(int percentage) {
00411         _experiment->updateDiscontinuityThreshold(percentage);
00412         //TODO HACER RESET DEL CONTORNO
00413 }
00414 
00415 // ----------------------------------------------------------------------------
00416 int marInterfaceCT::getContourType(int point, int index)
00417 {
00418         return _experiment->getContourType(point,index);
00419 }
00420 
00421 // ----------------------------------------------------------------------------
00422 void marInterfaceCT::histogram(int point)
00423 {
00424         _experiment->histogram(point);
00425 }
00426 
00427 // ----------------------------------------------------------------------------
00428 void marInterfaceCT::setCalibration(bool calib)
00429 {
00430         _experiment->setCalibration(calib);
00431 }
00432 
00433 // ----------------------------------------------------------------------------
00434 bool marInterfaceCT::getCalibration()
00435 {
00436         return _experiment->getCalibration();
00437 }
00438 
00439 // ----------------------------------------------------------------------------
00440 void marInterfaceCT::ClearContoursPartial(int start)
00441 {
00442         _experiment->ClearContoursPartial(start);
00443 }
00444 
00445 // ----------------------------------------------------------------------------
00446 void marInterfaceCT::setStartIndex(int start)
00447 {
00448         _experiment->setStartIndex(start);
00449 }
00450 
00451 // ----------------------------------------------------------------------------
00452 int     marInterfaceCT::getPointSize()
00453 {
00454         return _experiment->getPointSize();
00455 }
00456 
00457 // ----------------------------------------------------------------------------
00458 marPoint* marInterfaceCT::getPoint(int i)
00459 {
00460         return _experiment->getPoint(i);
00461 }
00462 
00463 // ----------------------------------------------------------------------------
00464 void marInterfaceCT::markUpLumen(int point)
00465 {
00466         _experiment->markUpLumen(point);
00467 }
00468 
00469 // ----------------------------------------------------------------------------
00470 void marInterfaceCT::generateFile()
00471 {
00472         _experiment->generateFile();
00473 }
00474 
00475 // ----------------------------------------------------------------------------
00476 void marInterfaceCT::cleanContours(int type)
00477 {
00478         _experiment->cleanContours(type);
00479 }
00480 
00481 // ----------------------------------------------------------------------------
00482 marIsocontour* marInterfaceCT::loadMarIsocontour(int size, double *vx, double *vy)
00483 {
00484         return _experiment->loadMarIsocontour(size,vx,vy);
00485 }
00486 
00487 // ----------------------------------------------------------------------------
00488 double marInterfaceCT::performXOR(int type, std::vector<marIsocontour*> manual)
00489 {
00490         return _experiment->performXOR(type, manual);
00491 }
00492 
00493 // ----------------------------------------------------------------------------
00494 double marInterfaceCT::performAND(int type, std::vector<marIsocontour*> manual)
00495 {
00496         return _experiment->performAND(type, manual);
00497 }
00498 
00499 
00500 double marInterfaceCT::performUnion(int type, std::vector<marIsocontour*> manual)
00501 {
00502         return _experiment->performUnion(type, manual);
00503 }
00504 // eof - marInterfaceCT.cxx
00505 
00506 

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1