1 /*=========================================================================
4 Module: $RCSfile: marInterface.cpp,v $
6 Date: $Date: 2008/10/31 16:32:55 $
7 Version: $Revision: 1.1 $
9 Copyright: (c) 2002, 2003
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.
16 =========================================================================*/
18 #pragma warning ( disable : 4786 )
19 #pragma warning ( disable : 4251 )
22 #include "marInterface.h"
29 // ----------------------------------------------------------------------------
30 marInterface::marInterface( )
31 : _parameters( NULL ), _dicom( NULL ),
34 m_paramFileName=MAR_DEFAULT_FILE_PARAMETERS;
35 _parameters = new marParameters( );
36 //EED _dicom = new marGdcmDicom( _parameters );
37 _experiment = new marExperiment( _parameters );
39 // loadParameters( ); //PS !!! dangereux de faire des opérations d'E/S
40 // dans des constructeurs
43 // ----------------------------------------------------------------------------
44 marInterface::~marInterface( ){
48 // ----------------------------------------------------------------------------
49 bool marInterface::loadParameters( std::string pFile )
51 std::ifstream is( pFile.c_str( ),std::ios::binary|std::ios::in);
54 // wxLogDebug(wxString("Loading parameters from file ")
55 // + wxString(pFile.c_str()));
60 errorMsg= wxString(_T("Error : Cannot open file "))
61 + wxString( pFile.c_str(), wxConvUTF8 )
62 + wxString(_T(" to load parameters"));
64 // wxLogDebug(errorMsg);
67 _parameters->reset( );
68 if (_parameters->load( is ))
77 // wxLogDebug(wxString("Error : Cannot load parameters from file ")
78 // + wxString(pFile.c_str())
79 // + wxString(": file may be corrupted"));
84 // ----------------------------------------------------------------------------
85 bool marInterface::saveParameters( std::string pFile )
87 std::ofstream os(pFile.c_str( ),std::ios::binary | std::ios::out);
90 // wxLogDebug(wxString("Saving parameters to file ")
91 // + wxString(pFile.c_str()));
97 errorMsg= wxString(_T("Error : Cannot open file "))
98 + wxString(pFile.c_str(), wxConvUTF8)
99 + wxString(_T(" to save parameters"));
101 // wxLogDebug(errorMsg);
104 if(_parameters->save( os ))
113 // wxLogDebug(wxString("Error : Cannot save parameters to file ")
114 // + wxString(pFile.c_str()));
120 // ----------------------------------------------------------------------------
121 bool marInterface::initExperiment( )
123 _experiment->reset( );
124 _experiment->initExperiment( _dicom->getVolume( ) );
128 // ----------------------------------------------------------------------------
129 bool marInterface::saveExperiment( std::string nFile )
131 std::ofstream os( nFile.c_str( ),std::ios::binary | std::ios::out );
134 // wxLogDebug(wxString("Saving experiment to file ")
135 // + wxString(nFile.c_str()));
138 errorMsg= wxString(_T("Cannot open file "))
139 + wxString(nFile.c_str(), wxConvUTF8)
140 + wxString(_T(" to save experiment"));
145 _parameters->save( os );
147 _experiment->save( os );
153 // wxLogDebug(errorMsg);
157 // ----------------------------------------------------------------------------
158 bool marInterface::loadExperiment( std::string nFile )
160 std::ifstream is( nFile.c_str( ) ,std::ios::binary|std::ios::in );
163 // wxLogDebug(wxString("Loading experiment from file ")
164 // + wxString(nFile.c_str()));
167 errorMsg= wxString(_T("Cannot open file "))
168 + wxString(nFile.c_str(), wxConvUTF8)
169 + wxString(_T(" to load experiment"));
173 _parameters->reset( );
175 _experiment->reset( );
177 _parameters->load( is );
179 _experiment->load( is );
185 // wxLogDebug(errorMsg);
189 // ----------------------------------------------------------------------------
190 void marInterface::reset( )
192 if( _dicom != NULL ) delete _dicom;
193 if( _experiment != NULL ) delete _experiment;
194 if( _parameters != NULL ) delete _parameters;
200 // ----------------------------------------------------------------------------
201 void marInterface::SetParamFileName(std::string pFileName)
203 m_paramFileName=pFileName;
205 // ----------------------------------------------------------------------------
206 std::string marInterface::GetParamFileName()
208 return m_paramFileName;
210 // ----------------------------------------------------------------------------
211 void marInterface::SetDicom(marFilesBase *dicom)
217 // eof - interface.cxx
221 void marInterface::SetVolumeData(int dimX,int dimY,int dimZ, float spacingX, float spacingY, float spacingZ, unsigned short * pixels)
224 _dicom->SetVolumeData(dimX,dimY,dimZ,spacingX,spacingY,spacingZ,pixels);