marInterface.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifdef _MSC_VER
00018 #pragma warning ( disable : 4786 )
00019 #pragma warning ( disable : 4251 )
00020 #endif //_MSC_VER
00021
00022 #include "marInterface.h"
00023 #include <wx/file.h>
00024 #include <wx/log.h>
00025
00026
00027
00028
00029
00030 marInterface::marInterface( )
00031 : _parameters( NULL ), _dicom( NULL ),
00032 _experiment( NULL )
00033 {
00034 m_paramFileName=MAR_DEFAULT_FILE_PARAMETERS;
00035 _parameters = new marParameters( );
00036
00037 _experiment = new marExperiment( _parameters );
00038
00039
00040
00041 }
00042
00043
00044 marInterface::~marInterface( ){
00045 reset( );
00046 }
00047
00048
00049 bool marInterface::loadParameters( std::string pFile )
00050 {
00051 std::ifstream is( pFile.c_str( ),std::ios::binary|std::ios::in);
00052
00053
00054
00055
00056
00057 if( is==NULL )
00058 {
00059 wxString errorMsg;
00060 errorMsg= wxString(_T("Error : Cannot open file "))
00061 + wxString( pFile.c_str(), wxConvUTF8 )
00062 + wxString(_T(" to load parameters"));
00063
00064
00065 return (false);
00066 }
00067 _parameters->reset( );
00068 if (_parameters->load( is ))
00069 {
00070 is.close( );
00071 return( true );
00072 }
00073 else
00074 {
00075 is.close();
00076
00077
00078
00079
00080 return (false);
00081 }
00082 }
00083
00084
00085 bool marInterface::saveParameters( std::string pFile )
00086 {
00087 std::ofstream os(pFile.c_str( ),std::ios::binary | std::ios::out);
00088
00089
00090
00091
00092
00093
00094 if( os==NULL )
00095 {
00096 wxString errorMsg;
00097 errorMsg= wxString(_T("Error : Cannot open file "))
00098 + wxString(pFile.c_str(), wxConvUTF8)
00099 + wxString(_T(" to save parameters"));
00100
00101
00102 return( false );
00103 }
00104 if(_parameters->save( os ))
00105 {
00106 os.close( );
00107 return( true );
00108 }
00109 else
00110 {
00111 os.close();
00112
00113
00114
00115 return (false);
00116 }
00117
00118 }
00119
00120
00121 bool marInterface::initExperiment( )
00122 {
00123 _experiment->reset( );
00124 _experiment->initExperiment( _dicom->getVolume( ) );
00125 return( true );
00126
00127 }
00128
00129 bool marInterface::saveExperiment( std::string nFile )
00130 {
00131 std::ofstream os( nFile.c_str( ),std::ios::binary | std::ios::out );
00132
00133
00134
00135
00136
00137 wxString errorMsg;
00138 errorMsg= wxString(_T("Cannot open file "))
00139 + wxString(nFile.c_str(), wxConvUTF8)
00140 + wxString(_T(" to save experiment"));
00141
00142
00143 if( os !=NULL ) {
00144
00145 _parameters->save( os );
00146 _dicom->save( os );
00147 _experiment->save( os );
00148 os.close( );
00149 return( true );
00150
00151 }
00152
00153
00154 return( false );
00155 }
00156
00157
00158 bool marInterface::loadExperiment( std::string nFile )
00159 {
00160 std::ifstream is( nFile.c_str( ) ,std::ios::binary|std::ios::in );
00161
00162
00163
00164
00165
00166 wxString errorMsg;
00167 errorMsg= wxString(_T("Cannot open file "))
00168 + wxString(nFile.c_str(), wxConvUTF8)
00169 + wxString(_T(" to load experiment"));
00170
00171 if( is !=NULL) {
00172
00173 _parameters->reset( );
00174 _dicom->reset( );
00175 _experiment->reset( );
00176
00177 _parameters->load( is );
00178 _dicom->load( is );
00179 _experiment->load( is );
00180 is.close( );
00181 return( true );
00182
00183 }
00184
00185
00186 return( false );
00187 }
00188
00189
00190 void marInterface::reset( )
00191 {
00192 if( _dicom != NULL ) delete _dicom;
00193 if( _experiment != NULL ) delete _experiment;
00194 if( _parameters != NULL ) delete _parameters;
00195
00196 _dicom = NULL;
00197 _experiment = NULL;
00198 _parameters = NULL;
00199 }
00200
00201 void marInterface::SetParamFileName(std::string pFileName)
00202 {
00203 m_paramFileName=pFileName;
00204 }
00205
00206 std::string marInterface::GetParamFileName()
00207 {
00208 return m_paramFileName;
00209 }
00210
00211 void marInterface::SetDicom(marFilesBase *dicom)
00212 {
00213 _dicom=dicom;
00214 }
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227