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: marInterface.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.
41 =========================================================================*/
43 #pragma warning ( disable : 4786 )
44 #pragma warning ( disable : 4251 )
47 #include "marInterface.h"
54 // ----------------------------------------------------------------------------
55 marInterface::marInterface( )
56 : _parameters( NULL ), _dicom( NULL ),
59 m_paramFileName=MAR_DEFAULT_FILE_PARAMETERS;
60 _parameters = new marParameters( );
61 //EED _dicom = new marGdcmDicom( _parameters );
62 _experiment = new marExperiment( _parameters );
64 // loadParameters( ); //PS !!! dangereux de faire des op�rations d'E/S
65 // dans des constructeurs
68 // ----------------------------------------------------------------------------
69 marInterface::~marInterface( ){
73 // ----------------------------------------------------------------------------
74 bool marInterface::loadParameters( std::string pFile )
76 std::ifstream is( pFile.c_str( ),std::ios::binary|std::ios::in);
79 // wxLogDebug(wxString("Loading parameters from file ")
80 // + wxString(pFile.c_str()));
85 errorMsg= wxString(_T("Error : Cannot open file "))
86 + wxString( pFile.c_str(), wxConvUTF8 )
87 + wxString(_T(" to load parameters"));
89 // wxLogDebug(errorMsg);
92 _parameters->reset( );
93 if (_parameters->load( is ))
102 // wxLogDebug(wxString("Error : Cannot load parameters from file ")
103 // + wxString(pFile.c_str())
104 // + wxString(": file may be corrupted"));
109 // ----------------------------------------------------------------------------
110 bool marInterface::saveParameters( std::string pFile )
112 std::ofstream os(pFile.c_str( ),std::ios::binary | std::ios::out);
115 // wxLogDebug(wxString("Saving parameters to file ")
116 // + wxString(pFile.c_str()));
122 errorMsg= wxString(_T("Error : Cannot open file "))
123 + wxString(pFile.c_str(), wxConvUTF8)
124 + wxString(_T(" to save parameters"));
126 // wxLogDebug(errorMsg);
129 if(_parameters->save( os ))
138 // wxLogDebug(wxString("Error : Cannot save parameters to file ")
139 // + wxString(pFile.c_str()));
145 // ----------------------------------------------------------------------------
146 bool marInterface::initExperiment( )
148 _experiment->reset( );
149 _experiment->initExperiment( _dicom->getVolume( ) );
153 // ----------------------------------------------------------------------------
154 bool marInterface::saveExperiment( std::string nFile )
156 std::ofstream os( nFile.c_str( ),std::ios::binary | std::ios::out );
159 // wxLogDebug(wxString("Saving experiment to file ")
160 // + wxString(nFile.c_str()));
163 errorMsg= wxString(_T("Cannot open file "))
164 + wxString(nFile.c_str(), wxConvUTF8)
165 + wxString(_T(" to save experiment"));
170 _parameters->save( os );
172 _experiment->save( os );
178 // wxLogDebug(errorMsg);
182 // ----------------------------------------------------------------------------
183 bool marInterface::loadExperiment( std::string nFile )
185 std::ifstream is( nFile.c_str( ) ,std::ios::binary|std::ios::in );
188 // wxLogDebug(wxString("Loading experiment from file ")
189 // + wxString(nFile.c_str()));
192 errorMsg= wxString(_T("Cannot open file "))
193 + wxString(nFile.c_str(), wxConvUTF8)
194 + wxString(_T(" to load experiment"));
198 _parameters->reset( );
200 _experiment->reset( );
202 _parameters->load( is );
204 _experiment->load( is );
210 // wxLogDebug(errorMsg);
214 // ----------------------------------------------------------------------------
215 void marInterface::reset( )
217 if( _dicom != NULL ) delete _dicom;
218 if( _experiment != NULL ) delete _experiment;
219 if( _parameters != NULL ) delete _parameters;
225 // ----------------------------------------------------------------------------
226 void marInterface::SetParamFileName(std::string pFileName)
228 m_paramFileName=pFileName;
230 // ----------------------------------------------------------------------------
231 std::string marInterface::GetParamFileName()
233 return m_paramFileName;
235 // ----------------------------------------------------------------------------
236 void marInterface::SetDicom(marFilesBase *dicom)
242 // eof - interface.cxx
246 void marInterface::SetVolumeData(int dimX,int dimY,int dimZ, float spacingX, float spacingY, float spacingZ, unsigned short * pixels)
249 _dicom->SetVolumeData(dimX,dimY,dimZ,spacingX,spacingY,spacingZ,pixels);