00001
00002 #include "vtkMPR3DDataViewer.h"
00003
00004
00005 vtkMPR3DDataViewer::vtkMPR3DDataViewer()
00006 {
00007 _visiblePosition[0]=false;
00008 _visiblePosition[1]=false;
00009 _visiblePosition[2]=false;
00010 _ctfun = NULL;
00011 _vtkmprbasedata=NULL;
00012
00013 _ctfun=NULL;
00014 _saggitalColors=NULL;
00015 _saggital=NULL;
00016 _axialColors=NULL;
00017 _axial=NULL;
00018 _coronalColors=NULL;
00019 _coronal=NULL;
00020 _mapOutline=NULL;
00021 _outline=NULL;
00022 _outlineData=NULL;
00023 }
00024
00025 vtkMPR3DDataViewer::~vtkMPR3DDataViewer()
00026 {
00027 _outlineData-> Delete();
00028 _mapOutline-> Delete();
00029 _outline-> Delete();
00030
00031
00032
00033
00034 if (_ctfun) _ctfun->Delete();
00035 if (_saggitalColors) _saggitalColors ->Delete();
00036 if (_saggital) _saggital->Delete();
00037 if (_axialColors) _axialColors->Delete();
00038 if (_axial) _axial->Delete();
00039 if (_coronalColors) _coronalColors->Delete();
00040 if (_coronal) _coronal->Delete();
00041
00042 }
00043
00044 vtkActor* vtkMPR3DDataViewer::GetOutlineActor()
00045 {
00046 return _outline;
00047 }
00048
00049 vtkImageActor* vtkMPR3DDataViewer::GetImageActor(int id)
00050 {
00051 vtkImageActor *tmpVtkActor=NULL;
00052 if (id==0){
00053 tmpVtkActor = GetvtkActor_saggital();
00054 }
00055 if (id==1){
00056 tmpVtkActor = GetvtkActor_coronal();
00057 }
00058 if (id==2){
00059 tmpVtkActor = GetvtkActor_axial();
00060 }
00061 return tmpVtkActor;
00062 }
00063
00064 void vtkMPR3DDataViewer::Refresh()
00065 {
00066 int x = (int)(_vtkmprbasedata->GetX());
00067 int y = (int)(_vtkmprbasedata->GetY());
00068 int z = (int)(_vtkmprbasedata->GetZ());
00069 SetPositionX( x );
00070 SetPositionY( y );
00071 SetPositionZ( z );
00072 }
00073
00074 void vtkMPR3DDataViewer::SetVtkMPRBaseData(vtkMPRBaseData *vtkmprbasedata)
00075 {
00076 _vtkmprbasedata=vtkmprbasedata;
00077 }
00078
00079 vtkMPRBaseData* vtkMPR3DDataViewer::GetVtkMPRBaseData()
00080 {
00081 return _vtkmprbasedata;
00082 }
00083
00084
00085 vtkColorTransferFunction *vtkMPR3DDataViewer::GetvtkColorTransferFunction()
00086 {
00087 return _ctfun;
00088 }
00089
00090
00091 std::vector<double>* vtkMPR3DDataViewer::GetctFunVectorPoint()
00092 {
00093 return &_ctFunVectorPoint;
00094 }
00095
00096 std::vector<double>* vtkMPR3DDataViewer::GetctFunVectorRed()
00097 {
00098 return &_ctFunVectorRed;
00099 }
00100
00101
00102 std::vector<double>* vtkMPR3DDataViewer::GetctFunVectorGreen()
00103 {
00104 return &_ctFunVectorGreen;
00105 }
00106
00107
00108 std::vector<double>* vtkMPR3DDataViewer::GetctFunVectorBlue()
00109 {
00110 return &_ctFunVectorBlue;
00111 }
00112
00113
00114 void vtkMPR3DDataViewer::Configure()
00115 {
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 double range[2];
00143 _vtkmprbasedata->GetImageData()->GetScalarRange(range);
00144 double max = range[1];
00145
00146 _ctFunVectorPoint.clear();
00147 _ctFunVectorPoint.push_back(max*0/4);
00148 _ctFunVectorPoint.push_back(max*1/4);
00149 _ctFunVectorPoint.push_back(max*2/4);
00150 _ctFunVectorPoint.push_back(max*3/4);
00151 _ctFunVectorPoint.push_back(max*4/4);
00152
00153 _ctFunVectorRed.clear();
00154 _ctFunVectorRed.push_back(0.0);
00155 _ctFunVectorRed.push_back(1.0);
00156 _ctFunVectorRed.push_back(0.0);
00157 _ctFunVectorRed.push_back(0.0);
00158 _ctFunVectorRed.push_back(0.0);
00159
00160 _ctFunVectorGreen.clear();
00161 _ctFunVectorGreen.push_back(0.0);
00162 _ctFunVectorGreen.push_back(0.0);
00163 _ctFunVectorGreen.push_back(0.0);
00164 _ctFunVectorGreen.push_back(1.0);
00165 _ctFunVectorGreen.push_back(0.2);
00166
00167 _ctFunVectorBlue.clear();
00168 _ctFunVectorBlue.push_back(0.0);
00169 _ctFunVectorBlue.push_back(0.0);
00170 _ctFunVectorBlue.push_back(1.0);
00171 _ctFunVectorBlue.push_back(0.0);
00172 _ctFunVectorBlue.push_back(0.0);
00173
00174
00175 if(_ctfun==NULL){
00176 _ctfun = vtkColorTransferFunction::New();
00177 }
00178 _ctfun->RemoveAllPoints();
00179
00180 int i,size=_ctFunVectorPoint.size();
00181 for (i=0;i<size;i++)
00182 {
00183 _ctfun->AddRGBPoint( _ctFunVectorPoint[i] , _ctFunVectorRed[i],_ctFunVectorGreen[i],_ctFunVectorBlue[i]);
00184
00185 }
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203 if(_saggitalColors==NULL){
00204 _saggitalColors = vtkImageMapToColors::New();
00205 }
00206 _saggitalColors->RemoveAllInputs();
00207
00208 _saggitalColors->SetInput( _vtkmprbasedata->GetImageData() );
00209
00210
00211 _saggitalColors->SetLookupTable(_ctfun);
00212
00213
00214 if(_saggital==NULL){
00215 _saggital = vtkImageActor::New();
00216 _saggital->SetInput(_saggitalColors->GetOutput());
00217 }
00218
00219
00220
00221
00222
00223
00224
00225
00226 if(_axialColors==NULL){
00227 _axialColors = vtkImageMapToColors::New();
00228 }
00229
00230 _axialColors->RemoveAllInputs();
00231 _axialColors->SetInput( _vtkmprbasedata->GetImageData() );
00232
00233 _axialColors->SetLookupTable(_ctfun);
00234
00235 if(_axial==NULL){
00236 _axial = vtkImageActor::New();
00237 _axial->SetInput(_axialColors->GetOutput());
00238 }
00239
00240
00241
00242
00243
00244
00245 if(_coronalColors==NULL){
00246 _coronalColors = vtkImageMapToColors::New();
00247 }
00248 _coronalColors->RemoveAllInputs();
00249 _coronalColors->SetInput( _vtkmprbasedata->GetImageData() );
00250
00251 _coronalColors->SetLookupTable(_ctfun);
00252
00253 if(_coronal==NULL){
00254 _coronal = vtkImageActor::New();
00255 _coronal->SetInput(_coronalColors->GetOutput());
00256 }
00257
00258
00259
00260
00261
00262 if(_outlineData==NULL){
00263 _outlineData = vtkOutlineFilter::New();
00264 }
00265 _outlineData->RemoveAllInputs();
00266 _outlineData->SetInput((vtkDataSet *) _vtkmprbasedata->GetImageData() );
00267
00268 if(_mapOutline==NULL){
00269 _mapOutline = vtkPolyDataMapper::New();
00270 _mapOutline->SetInput(_outlineData->GetOutput());
00271 }
00272 _mapOutline->Update();
00273
00274
00275 if(_outline==NULL){
00276 _outline = vtkActor::New();
00277 _outline->SetMapper(_mapOutline);
00278 _outline->GetProperty()->SetColor(0,0,0);
00279 }
00280
00281
00282
00283 int ext[6];
00284 _vtkmprbasedata->GetImageData()->GetExtent(ext);
00285
00286
00287
00288
00289 }
00290
00291
00292 vtkImageActor * vtkMPR3DDataViewer::GetvtkActor_saggital()
00293 {
00294 return _saggital;
00295 }
00296
00297 vtkImageActor * vtkMPR3DDataViewer::GetvtkActor_coronal()
00298 {
00299 return _coronal;
00300 }
00301
00302 vtkImageActor * vtkMPR3DDataViewer::GetvtkActor_axial()
00303 {
00304 return _axial;
00305 }
00306
00307
00308 void vtkMPR3DDataViewer::SetPositionX(int pos){
00309 int x1,x2,y1,y2,z1,z2;
00310 _vtkmprbasedata->GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2);
00311 _saggital->SetDisplayExtent( pos , pos , y1 ,y2 , z1 , z2 );
00312 }
00313
00314 void vtkMPR3DDataViewer::SetPositionY(int pos){
00315 int x1,x2,y1,y2,z1,z2;
00316 _vtkmprbasedata->GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2);
00317 _coronal->SetDisplayExtent(x1,x2, pos,pos, z1,z2);
00318 }
00319
00320 void vtkMPR3DDataViewer::SetPositionZ(int pos){
00321 int x1,x2,y1,y2,z1,z2;
00322 _vtkmprbasedata->GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2);
00323 _axial->SetDisplayExtent(x1,x2, y1,y2, pos,pos);
00324 }
00325
00326 void vtkMPR3DDataViewer::SetVisiblePosition(int idPosition, bool visible)
00327 {
00328 _visiblePosition[idPosition]=visible;
00329 }
00330
00331 bool vtkMPR3DDataViewer::GetVisiblePosition(int idPosition)
00332 {
00333 return _visiblePosition[idPosition];
00334 }
00335
00336 void vtkMPR3DDataViewer::setColorTransferFunction(vtkColorTransferFunction* colortable){
00337 _saggitalColors->SetLookupTable(colortable);
00338 _coronalColors->SetLookupTable(colortable);
00339 _axialColors->SetLookupTable(colortable);
00340 }
00341