1 /*=========================================================================
4 Module: $RCSfile: marInterfaceCT.cpp,v $
6 Date: $Date: 2009/05/14 13:55:08 $
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.
15 =========================================================================*/
17 #pragma warning ( disable : 4786 )
18 #pragma warning ( disable : 4251 )
21 #include "marInterfaceCT.h"
28 // ----------------------------------------------------------------------------
29 marInterfaceCT::marInterfaceCT( )
30 : _parameters( NULL ), _dicom( NULL ),
33 m_paramFileName=MAR_DEFAULT_FILE_PARAMETERS;
34 _parameters = new marParameters( );
36 _experiment = new marExperimentCT( _parameters );
41 // ----------------------------------------------------------------------------
42 marInterfaceCT::~marInterfaceCT( ){
46 // ----------------------------------------------------------------------------
47 bool marInterfaceCT::loadParameters( std::string pFile )
49 std::ifstream is( pFile.c_str( ),std::ios::binary|std::ios::in);
52 // wxLogDebug(wxString("Loading parameters from file ")
53 // + wxString(pFile.c_str()));
58 errorMsg= wxString(_T("Error : Cannot open file "))
59 + wxString((wxChar*)pFile.c_str(), wxConvUTF8)
60 + wxString(_T(" to load parameters"));
62 // wxLogDebug(errorMsg);
65 _parameters->reset( );
66 if (_parameters->load( is ))
75 // wxLogDebug(wxString("Error : Cannot load parameters from file ")
76 // + wxString(pFile.c_str())
77 // + wxString(": file may be corrupted"));
82 // ----------------------------------------------------------------------------
83 bool marInterfaceCT::saveParameters( std::string pFile )
85 std::ofstream os(pFile.c_str( ),std::ios::binary | std::ios::out);
88 // wxLogDebug(wxString("Saving parameters to file ")
89 // + wxString(pFile.c_str()));
95 errorMsg= wxString(_T("Error : Cannot open file "))
96 + wxString( (wxChar*)pFile.c_str(), wxConvUTF8)
97 + wxString(_T(" to save parameters"));
99 // wxLogDebug(errorMsg);
102 if(_parameters->save( os ))
111 // wxLogDebug(wxString("Error : Cannot save parameters to file ")
112 // + wxString(pFile.c_str()));
118 // ----------------------------------------------------------------------------
119 bool marInterfaceCT::initExperiment( )
121 _experiment->reset( );
122 _experiment->initExperiment( _dicom->getVolume( ) );
126 // ----------------------------------------------------------------------------
127 bool marInterfaceCT::saveExperiment( std::string nFile )
129 std::ofstream os( nFile.c_str( ),std::ios::binary | std::ios::out );
132 // wxLogDebug(wxString("Saving experiment to file ")
133 // + wxString(nFile.c_str()));
136 errorMsg= wxString(_T("Cannot open file "))
137 + wxString((wxChar*)nFile.c_str(), wxConvUTF8)
138 + wxString(_T(" to save experiment"));
143 _parameters->save( os );
145 _experiment->save( os );
151 // wxLogDebug(errorMsg);
155 // ----------------------------------------------------------------------------
156 bool marInterfaceCT::loadExperiment( std::string nFile )
158 std::ifstream is( nFile.c_str( ) ,std::ios::binary|std::ios::in );
161 // wxLogDebug(wxString("Loading experiment from file ")
162 // + wxString(nFile.c_str()));
165 errorMsg= wxString(_T("Cannot open file "))
166 + wxString((wxChar*)nFile.c_str(), wxConvUTF8)
167 + wxString(_T(" to load experiment"));
171 _parameters->reset( );
173 _experiment->reset( );
175 _parameters->load( is );
177 _experiment->load( is );
183 // wxLogDebug(errorMsg);
187 // ----------------------------------------------------------------------------
188 void marInterfaceCT::reset( ){
189 if( _experiment != NULL ) delete _experiment;
190 if( _dicom != NULL ) delete _dicom;
191 if( _parameters != NULL ) delete _parameters;
196 // ----------------------------------------------------------------------------
197 void marInterfaceCT::SetParamFileName(std::string pFileName) {
198 m_paramFileName=pFileName;
200 // ----------------------------------------------------------------------------
201 std::string marInterfaceCT::GetParamFileName() {
202 return m_paramFileName;
204 // ----------------------------------------------------------------------------
205 void marInterfaceCT::SetDicom(marFilesBase *dicom) {
209 // ----------------------------------------------------------------------------
210 void marInterfaceCT::appendAxis( marAxis* ax )
212 _experiment->appendAxis(ax);
216 // ----------------------------------------------------------------------------
217 marAxisCT* marInterfaceCT::getAxis( int i ) {
218 return (marAxisCT *) _experiment->getAxis(i);
221 // ----------------------------------------------------------------------------
222 void marInterfaceCT::setAxis( int i )
224 _experiment->setAxis(i);
227 // ----------------------------------------------------------------------------
228 int marInterfaceCT::getQuantStart( ) {
229 return _experiment->getQuantStart( );
232 // ----------------------------------------------------------------------------
233 int marInterfaceCT::getQuantFinish( ) {
234 return _experiment->getQuantFinish( );
237 // ----------------------------------------------------------------------------
238 void marInterfaceCT::prepareQuantification( ) {
239 _experiment->prepareQuantification( );
243 // ----------------------------------------------------------------------------
244 vtkImageData* marInterfaceCT::getSliceImage( int i ) {
245 return _experiment->getSliceImage( i );
248 // ----------------------------------------------------------------------------
249 vtkProbeFilter* marInterfaceCT::get3DSlice( int i ) {
250 return _experiment->get3DSlice( i );
253 // ----------------------------------------------------------------------------
254 double marInterfaceCT::getTotalLength( ) {
255 return _experiment->getTotalLength( );
258 // ----------------------------------------------------------------------------
259 double marInterfaceCT::getSubAxisLength( ) {
260 return _experiment->getSubAxisLength( );
263 // ----------------------------------------------------------------------------
264 double marInterfaceCT::getReferenceArea( ) {
265 return _experiment->getReferenceArea( );
268 // ----------------------------------------------------------------------------
269 double marInterfaceCT::getReferenceAverDiam() {
270 return _experiment->getReferenceAverDiam( );
273 // ----------------------------------------------------------------------------
274 double marInterfaceCT::getAverageArea(int pIni, int pEnd) {
275 return _experiment->getAverageArea(pIni,pEnd);
278 // ----------------------------------------------------------------------------
279 int marInterfaceCT::getNumberOfSlices( ) {
280 return _experiment->getNumberOfSlices( );
283 // ----------------------------------------------------------------------------
284 int marInterfaceCT::getActualQuant( ) {
285 return _experiment->getAxis()->getActualQuant();
288 // ----------------------------------------------------------------------------
289 marExperimentCT* marInterfaceCT::GetExperiment()
294 // ----------------------------------------------------------------------------
295 int marInterfaceCT::getHealthySlice( ) {
296 return _experiment->getAxis( )->getHealthySlice( );
299 // ----------------------------------------------------------------------------
300 int marInterfaceCT::getHealthySliceStart( ) {
301 return _experiment->getAxis()->getHealthySliceStart( );
304 // ----------------------------------------------------------------------------
305 int marInterfaceCT::getHealthySliceEnd( ) {
306 return _experiment->getAxis()->getHealthySliceEnd( );
309 // ----------------------------------------------------------------------------
310 void marInterfaceCT::setHealthySlice( int hsS, int hs, int hsE ) {
311 _experiment->getAxis()->setHealthySlice(hsS,hs,hsE);
314 // ----------------------------------------------------------------------------
315 void marInterfaceCT::setActualQuant(int act) {
316 _experiment->getAxis()->setActualQuant( act ) ;
319 // ----------------------------------------------------------------------------
320 void marInterfaceCT::replaceContour2D(int i,int size,double *vx,double *vy) {
321 _experiment->getAxis()->replaceContour2D(i,size,vx,vy);
324 void marInterfaceCT::replaceContour2D(int size,double *vx,double *vy, int type)
326 _experiment->replaceContour2D(size,vx,vy,type);
329 // ----------------------------------------------------------------------------
330 void marInterfaceCT::EraseContour( int i ) {
331 _experiment->getAxis()->EraseContour( i );
334 // ----------------------------------------------------------------------------
335 void marInterfaceCT::ClearContours() {
336 _experiment->ClearContours();
339 // ----------------------------------------------------------------------------
340 void marInterfaceCT::RegenerateAxis() {
341 _experiment->RegenerateAxis();
344 // ----------------------------------------------------------------------------
345 void marInterfaceCT::RegenerateSignal() {
346 _experiment->RegenerateSignal();
349 // ----------------------------------------------------------------------------
350 void marInterfaceCT::RecalculateAxis() {
351 _experiment->RegenerateAxis();
354 // ----------------------------------------------------------------------------
355 void marInterfaceCT::getMinMax( double& min, double& max ) {
356 _experiment->getDynData( )->getVolume( )->getMinMax( min, max );
359 // ----------------------------------------------------------------------------
360 marContour* marInterfaceCT::getContour( int point, int contour ) {
361 return _experiment->getContour(point,contour);
364 // ----------------------------------------------------------------------------
365 vtkPoints* marInterfaceCT::get3Dcontour( int point, int contour ) {
366 return _experiment->get3Dcontour(point,contour);
369 // ----------------------------------------------------------------------------
370 vtkPolyData* marInterfaceCT::get2Dcontour( int point, int contour ) {
371 return _experiment->get2Dcontour(point,contour);
374 // ----------------------------------------------------------------------------
375 vtkPoints* marInterfaceCT::get2DDiameterMin( int point, int contour ) {
376 return _experiment->get2DDiameterMin(point,contour);
379 // ----------------------------------------------------------------------------
380 vtkPoints* marInterfaceCT::get2DDiameterMax( int point, int contour ) {
381 return _experiment->get2DDiameterMax(point,contour);
384 // ----------------------------------------------------------------------------
385 marParameters* marInterfaceCT::getParameters(){
388 // ----------------------------------------------------------------------------
389 marDynData* marInterfaceCT::getDynData(){
390 return _experiment->getDynData();
393 // ----------------------------------------------------------------------------
394 int marInterfaceCT::getNumberOfContours(int point) {
395 return _experiment->getNumberOfContours(point);
399 // ----------------------------------------------------------------------------
400 void marInterfaceCT::updateLumenPercentage(int percentage) {
401 _experiment->updateLumenPercentage(percentage);
404 // ----------------------------------------------------------------------------
405 void marInterfaceCT::updateCalcPercentage(int percentage) {
406 _experiment->updateCalcPercentage(percentage);
409 // ----------------------------------------------------------------------------
410 void marInterfaceCT::updateDiscontinuityThreshold(int percentage) {
411 _experiment->updateDiscontinuityThreshold(percentage);
412 //TODO HACER RESET DEL CONTORNO
415 // ----------------------------------------------------------------------------
416 int marInterfaceCT::getContourType(int point, int index)
418 return _experiment->getContourType(point,index);
421 // ----------------------------------------------------------------------------
422 void marInterfaceCT::histogram(int point)
424 _experiment->histogram(point);
427 // ----------------------------------------------------------------------------
428 void marInterfaceCT::setCalibration(bool calib)
430 _experiment->setCalibration(calib);
433 // ----------------------------------------------------------------------------
434 bool marInterfaceCT::getCalibration()
436 return _experiment->getCalibration();
439 // ----------------------------------------------------------------------------
440 void marInterfaceCT::ClearContoursPartial(int start)
442 _experiment->ClearContoursPartial(start);
445 // ----------------------------------------------------------------------------
446 void marInterfaceCT::setStartIndex(int start)
448 _experiment->setStartIndex(start);
451 // ----------------------------------------------------------------------------
452 int marInterfaceCT::getPointSize()
454 return _experiment->getPointSize();
457 // ----------------------------------------------------------------------------
458 marPoint* marInterfaceCT::getPoint(int i)
460 return _experiment->getPoint(i);
463 // ----------------------------------------------------------------------------
464 void marInterfaceCT::markUpLumen(int point)
466 _experiment->markUpLumen(point);
469 // ----------------------------------------------------------------------------
470 void marInterfaceCT::generateFile()
472 _experiment->generateFile();
475 // ----------------------------------------------------------------------------
476 void marInterfaceCT::cleanContours(int type)
478 _experiment->cleanContours(type);
481 // ----------------------------------------------------------------------------
482 marIsocontour* marInterfaceCT::loadMarIsocontour(int size, double *vx, double *vy)
484 return _experiment->loadMarIsocontour(size,vx,vy);
487 // ----------------------------------------------------------------------------
488 double marInterfaceCT::performXOR(int type, std::vector<marIsocontour*> manual)
490 return _experiment->performXOR(type, manual);
493 // ----------------------------------------------------------------------------
494 double marInterfaceCT::performAND(int type, std::vector<marIsocontour*> manual)
496 return _experiment->performAND(type, manual);
500 double marInterfaceCT::performUnion(int type, std::vector<marIsocontour*> manual)
502 return _experiment->performUnion(type, manual);
504 // eof - marInterfaceCT.cxx