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 =========================================================================*/
30 #include "marImageData.h"
32 // ----------------------------------------------------------------------------------------------
33 marImageData::marImageData(vtkImageData *imagedata)
45 AddImageData(imagedata);
48 // ----------------------------------------------------------------------------------------------
49 marImageData::~marImageData()
51 int i,size=_imagedataLST.size();
54 // _imagedataLST[i]->Delete();
56 _imagedataLST.clear();
59 // ----------------------------------------------------------------------------------------------
60 void marImageData::SetSpcOriginal(double spc[3])
62 this->_spcOriginal[0]=spc[0];
63 this->_spcOriginal[1]=spc[1];
64 this->_spcOriginal[2]=spc[2];
66 // ----------------------------------------------------------------------------------------------
67 void marImageData::SetVoiOriginal(int voi[6])
72 this->_voiOriginal[i] = voi[i];
75 // ----------------------------------------------------------------------------------------------
76 void marImageData::AddImageData(vtkImageData *imagedata)
79 _imagedataLST.push_back( imagedata );
82 // ----------------------------------------------------------------------------------------------
83 void marImageData::GetSpcOriginal(double spc[3])
85 spc[0] = this->_spcOriginal[0];
86 spc[1] = this->_spcOriginal[1];
87 spc[2] = this->_spcOriginal[2];
89 // ----------------------------------------------------------------------------------------------
90 void marImageData::GetVoiOriginal(int voi[6])
95 voi[i] = this->_voiOriginal[i];
98 // ----------------------------------------------------------------------------------------------
99 vtkImageData *marImageData::GetImageDataT(int t)
101 if(_imagedataLST.size() > t){
102 return _imagedataLST[t];
106 // ----------------------------------------------------------------------------------------------
107 vtkImageData *marImageData::GetImageData()
109 if(_imagedataLST.size()>0){
110 return _imagedataLST[0];
115 void marImageData::removeImageData(int index)
117 if(index < _imagedataLST.size())
120 /*vtkImageData* img = _imagedataLST[index];
121 if(img->GetReferenceCount()>1){
122 img->SetReferenceCount(img->GetReferenceCount()-1);
125 for(int i = index; i < _imagedataLST.size()-1; i++)
127 _imagedataLST[i] = _imagedataLST[i+1];
129 _imagedataLST.pop_back();
133 // ----------------------------------------------------------------------------------------------
134 int marImageData::GetXOriginal(int value)
136 double min=_spcOriginal[0];
137 if (_spcOriginal[1]<min)
139 min = _spcOriginal[1];
141 if (_spcOriginal[2]<min)
143 min = _spcOriginal[2];
145 double result = value / ( _spcOriginal[0] / min ) ;
146 result=result + _voiOriginal[0];
149 // ----------------------------------------------------------------------------------------------
150 int marImageData::GetYOriginal(int value)
152 double min=_spcOriginal[0];
153 if (_spcOriginal[1]<min)
155 min = _spcOriginal[1];
157 if (_spcOriginal[2]<min)
159 min = _spcOriginal[2];
161 double result = value / ( _spcOriginal[1] / min ) ;
162 result=result + _voiOriginal[2];
165 // ----------------------------------------------------------------------------------------------
166 int marImageData::GetZOriginal(int value)
168 double min=_spcOriginal[0];
169 if (_spcOriginal[1]<min)
171 min = _spcOriginal[1];
173 if (_spcOriginal[2]<min)
175 min = _spcOriginal[2];
177 double result = value / ( _spcOriginal[2] / min ) ;
178 result=result + _voiOriginal[4];
181 // ----------------------------------------------------------------------------------------------
182 int marImageData::GetMaxT()
184 return _imagedataLST.size();