]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.cxx
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / vtkClipping3DDataViewer.cxx
1
2 #include "vtkClipping3DDataViewer.h"
3 #include "vtkDataSetReader.h"
4 #include "vtkProperty.h"
5
6 vtkClipping3DDataViewer::vtkClipping3DDataViewer()
7 {
8         int i;
9         for (i=0; i<VTKMPRDATA_MAXTISSUE; i++){
10                 _visibleTissue[i]               = false;
11                 _representationType[i]  = true;
12         }
13         _visibleVolume=false;
14         _isRayCasting=true;
15     _isMIP=false;
16         _interpolation=false;
17         _shade=false;
18
19     _volumeMapper = vtkVolumeRayCastMapper::New();
20     _newvol = vtkVolume::New();
21     _volumeProperty = vtkVolumeProperty::New();
22     _compositeFunction = vtkVolumeRayCastCompositeFunction::New();
23          _compositeFunctionMIP = vtkVolumeRayCastMIPFunction::New();
24
25 }
26 //-------------------------------------------------------------------
27 vtkClipping3DDataViewer::~vtkClipping3DDataViewer()
28 {
29         int i;
30         for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){
31                 _mCubes[i]->Delete();
32                 _tissueStripper[i]->Delete();
33                 _tissueMapper[i]->Delete();
34                 _tissuePlanes[i]->Delete();
35                 _tissueClipper[i]->Delete();
36         }
37         _outlineData->Delete();
38         _mapOutline->Delete();
39         _outline->Delete();
40         // Volume
41         _tfun->Delete();
42         _ctfun->Delete();
43         _compositeFunction->Delete();
44         _volumeMapper->Delete();
45         _volumeProperty->Delete();
46         _newvol->Delete();
47         _volumePlanes->Delete();
48
49         for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){
50                 _tissue[i]-> Delete();
51                 _observerS[i]-> Delete();
52         }
53         _observerV-> Delete();
54 }
55 //-------------------------------------------------------------------
56 vtkActor* vtkClipping3DDataViewer::GetOutlineActor()
57 {
58         return _outline;
59 }
60 //-------------------------------------------------------------------
61 vtkClipPolyData* vtkClipping3DDataViewer::GetTissueClipper(int id)
62 {
63         return this->_tissueClipper[id];
64 }
65 //-------------------------------------------------------------------
66 vtkPolyDataMapper* vtkClipping3DDataViewer::GetTissueMapper(int id)
67 {
68         return _tissueMapper[id];
69 }
70 //-------------------------------------------------------------------
71 vtkPlanes* vtkClipping3DDataViewer::GetTissuePlanes(int id)
72 {
73         return _tissuePlanes[id];
74 }
75 //-------------------------------------------------------------------
76 vtkStripper* vtkClipping3DDataViewer::GetTissueStripper(int id)
77 {
78         return _tissueStripper[id];
79 }
80 //-------------------------------------------------------------------
81 void vtkClipping3DDataViewer::Refresh()
82 {
83 //      _volumeMapper->SetClippingPlanes(_volumePlanes);
84
85 //      this->_volumeMapper->Update();
86 //      this->_newvol->Update();
87
88 //      _newvol->VisibilityOn();
89
90
91 // _volumeMapper = vtkVolumeRayCastMapper::New();
92 //      _volumeMapper->SetInput( this->GetVtkMPRBaseData()->GetImageData() );
93 //      _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
94 //      _volumeMapper->SetClippingPlanes( _volumePlanes );
95 //      _newvol->SetMapper(_volumeMapper );
96
97
98 }
99 //-------------------------------------------------------------------
100 void vtkClipping3DDataViewer::RefreshSurface()
101 {
102         int i;
103         for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
104         {
105                 SetIsovalue(i, (int) (GetIsovalue(i)+1) );
106 //              this->GetMCubes(i)->Update();
107         }
108 }
109 //-------------------------------------------------------------------
110 void vtkClipping3DDataViewer::SetVtkMPRBaseData(vtkMPRBaseData *vtkmprbasedata)
111 {
112         _vtkmprbasedata=vtkmprbasedata;
113 }
114 //-------------------------------------------------------------------
115 vtkMPRBaseData* vtkClipping3DDataViewer::GetVtkMPRBaseData()
116 {
117         return _vtkmprbasedata;
118 }
119
120
121 //-------------------------------------------------------------------
122 void vtkClipping3DDataViewer::SetVisibleTissue(int idTissue, bool visible)
123 {
124         _visibleTissue[idTissue]=visible;
125 }
126 //-------------------------------------------------------------------
127 bool vtkClipping3DDataViewer::GetVisibleTissue(int idTissue){
128         return _visibleTissue[idTissue];
129 }
130 //-------------------------------------------------------------------
131 void vtkClipping3DDataViewer::SetRepresentationType(int idTissue, bool representationType)
132 {
133         _representationType[idTissue]=representationType;
134 }
135 //-------------------------------------------------------------------
136 bool vtkClipping3DDataViewer::GetRepresentationType(int idTissue)
137 {
138         return _representationType[idTissue];
139 }
140
141 //-------------------------------------------------------------------
142 vtkActor* vtkClipping3DDataViewer::GetTissueActor(int id){
143         return _tissue[id];
144 }
145
146 //-------------------------------------------------------------------
147 boxSurfaceObserver *vtkClipping3DDataViewer::GetObserverS(int idObserverS)
148 {
149         return _observerS[idObserverS];
150 }
151 //-------------------------------------------------------------------
152 boxSurfaceObserver *vtkClipping3DDataViewer::GetObserverV()
153 {
154         return _observerV;
155 }
156
157 //-------------------------------------------------------------------
158 bool vtkClipping3DDataViewer::GetVisibleVolume()
159 {
160         return _visibleVolume;
161 }
162 //-------------------------------------------------------------------
163 void vtkClipping3DDataViewer::SetVisibleVolume(bool visiblevolume)
164 {
165         _visibleVolume = visiblevolume;
166 }
167
168
169 //-------------------------------------------------------------------
170 void vtkClipping3DDataViewer::Configure_Tissue()
171 {
172
173         double range[2];
174         int i;
175         for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){
176                 // Visualisation - original volume
177                 vtkImageData *imagedata=_vtkmprbasedata->GetImageData();
178                 imagedata->GetScalarRange( range );
179                 _mCubes[i] = vtkMarchingCubes::New( );
180                 _mCubes[i]->SetInput( imagedata );
181
182                 _mCubes[i]->SetValue( 0, range[1]*(4+i) / 8 );
183 //              _mCubes[i]->SetValue( 0, 1500 );
184
185             _tissueStripper[i] = vtkStripper::New();
186             _tissueStripper[i]->SetInput( _mCubes[i]->GetOutput( ) );
187
188
189
190                 _tissuePlanes[i]  = vtkPlanes::New();
191
192                 int x1,x2,y1,y2,z1,z2;
193                 imagedata->GetExtent(x1,x2,y1,y2,z1,z2);
194                 _tissuePlanes[i]->SetBounds  (x1,x2,y1,y2,z1,z2);
195
196                 _tissueClipper[i] = vtkClipPolyData::New();
197                 _tissueClipper[i]->SetInput( _tissueStripper[i]->GetOutput() );
198                 _tissueClipper[i]->SetClipFunction( _tissuePlanes[i] );
199                 _tissueClipper[i]->InsideOutOn( );
200
201                 _tissueMapper[i] = vtkPolyDataMapper::New( );
202                 _tissueMapper[i]->SetInput( _tissueClipper[i]->GetOutput() );
203                 _tissueMapper[i]->ScalarVisibilityOff( );
204 //              _tissueMapper[i]->Update();
205
206         }
207
208
209
210         // vtkActor tissue
211         for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){
212                 // tissue
213                 _tissue[i] = vtkActor::New();
214                 _tissue[i]->SetMapper( GetTissueMapper(i) );
215                 float cr=1,cg=0.5,cb=0.5;
216                 _tissue[i]->GetProperty()->SetDiffuseColor(cr/255, cg/255   , cb/255   );
217                 _tissue[i]->GetProperty()->SetSpecular(.3);
218                 _tissue[i]->GetProperty()->SetSpecularPower(20);
219                 _tissue[i]->GetProperty()->SetOpacity(0.5);
220                 if (i==0) _tissue[i]->GetProperty()->SetColor(0.85, 0.85   , 0.85   );
221                 if (i==1) _tissue[i]->GetProperty()->SetColor(0, 0  ,  1  );
222                 if (i==2) _tissue[i]->GetProperty()->SetColor(0.85, 0.20   , 0.20   );
223                 if (i==3) _tissue[i]->GetProperty()->SetColor(0, 1   , 0   );
224         }
225
226         for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
227         {
228                 _observerS[i] = boxSurfaceObserver::New();
229                 _observerS[i]->SetPlanes( GetTissuePlanes(i) );
230                 _observerS[i]->SetActor( _tissue[i] );
231         }
232
233 }
234
235 //-----------------------------------------------------------------------------
236
237 void vtkClipping3DDataViewer::Configure_Volume()
238 {
239   // Volume
240
241
242
243  /** if(_newvol != NULL)
244   {
245     _newvol->Delete();
246     _volumeMapper->Delete();
247     _volumeProperty->Delete();
248   }*/
249
250
251
252   _tfun = vtkPiecewiseFunction::New();
253   _ctfun = vtkColorTransferFunction::New();
254
255         double range[2];
256         this->_vtkmprbasedata->GetImageData()->GetScalarRange(range);
257         double max = range[1];
258
259         /*
260         adding the poinst of the transference function
261         */
262         //X
263         greyValuesTransferenceFVector.push_back(max * 0/2);  // JPR ?? 0/2
264         greyValuesTransferenceFVector.push_back(max * 1/2);  // JPR ?? division entiere?
265         greyValuesTransferenceFVector.push_back(max * 2/2);
266         //Y
267         intensityValuesTransferenceFVector.push_back(0.0);
268         intensityValuesTransferenceFVector.push_back(1.0);
269         intensityValuesTransferenceFVector.push_back(1.0);
270
271         _tfun->AddPoint(max * 0/2 , 0.0);
272         _tfun->AddPoint(max * 1/2 , 1.0);
273         _tfun->AddPoint(max * 2/2 , 1.0);
274
275         /*
276                 Adding the colors to the vectors
277         */
278         //RED
279         redColorsOfColorTransferenceFVector.push_back(0.0);
280         redColorsOfColorTransferenceFVector.push_back(1.0);
281         redColorsOfColorTransferenceFVector.push_back(0.0);
282         redColorsOfColorTransferenceFVector.push_back(0.0);
283         redColorsOfColorTransferenceFVector.push_back(0.0);
284
285         //GREEN
286         greenColorsOfColorTransferenceFVector.push_back(0.0);
287         greenColorsOfColorTransferenceFVector.push_back(0.0);
288         greenColorsOfColorTransferenceFVector.push_back(0.0);
289         greenColorsOfColorTransferenceFVector.push_back(1.0);
290         greenColorsOfColorTransferenceFVector.push_back(0.2);
291
292         //BLUE
293         blueColorsOfColorTransferenceFVector.push_back(0.0);
294         blueColorsOfColorTransferenceFVector.push_back(0.0);
295         blueColorsOfColorTransferenceFVector.push_back(1.0);
296         blueColorsOfColorTransferenceFVector.push_back(0.0);
297         blueColorsOfColorTransferenceFVector.push_back(0.0);
298         //GREY VALUE
299         greyValueColorsOfColorTransferenceFVector.push_back(max*0/4);
300         greyValueColorsOfColorTransferenceFVector.push_back(max*1/4);
301         greyValueColorsOfColorTransferenceFVector.push_back(max*2/4);
302         greyValueColorsOfColorTransferenceFVector.push_back(max*3/4);
303         greyValueColorsOfColorTransferenceFVector.push_back(max*4/4);
304
305         _ctfun->AddRGBPoint( max*0/4 , 0.0, 0.0, 0.0);
306         _ctfun->AddRGBPoint( max*1/4 , 1.0, 0.0, 0.0);
307         _ctfun->AddRGBPoint( max*2/4 , 0.0, 0.0, 1.0);
308         _ctfun->AddRGBPoint( max*3/4 , 0.0, 1.0, 0.0);
309         _ctfun->AddRGBPoint( max*4/4 , 0.0, 0.2, 0.0);
310
311   _volumePlanes  = vtkPlanes::New();
312 //      int x1,x2,y1,y2,z1,z2;
313 //      vtkImageData *imagedata=_vtkmprbasedata->GetImageData();
314 //      imagedata->GetExtent(x1,x2,y1,y2,z1,z2);
315 //      _volumePlanes->SetBounds(x1,x2,y1,y2,z1,z2);
316
317         // EED 13/03/2011
318
319
320
321  // _volumeMapper = vtkVolumeRayCastMapper::New();
322         _volumeMapper->SetInput( this->GetVtkMPRBaseData()->GetImageData() );
323
324
325
326     _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
327
328
329    // _volumeMapper->SetVolumeRayCastFunction(_compositeFunctionMIP);
330
331 //
332
333         _volumeMapper->SetClippingPlanes( _volumePlanes );
334         _volumeMapper->AutoAdjustSampleDistancesOn();
335
336     _volumeProperty->SetInterpolationTypeToNearest();
337     //_volumeProperty = vtkVolumeProperty::New();
338         _volumeProperty->SetColor(_ctfun);
339         _volumeProperty->SetScalarOpacity( _tfun );
340
341 // EED 31/03/2008
342
343         _volumeProperty->DisableGradientOpacityOn();
344
345
346
347 //      _
348
349
350 //      _
351
352
353 //      _volumeProperty->SetInterpolationTypeToNearest();
354 //      _volumeProperty->ShadeOff();
355 //      _volumeProperty->SetAmbient(0.3);
356 //      _volumeProperty->SetDiffuse(0.1);
357 //      _volumeProperty->SetSpecular(0.8);
358 //      _volumeProperty->DisableGradientOpacityOn();
359
360  // _newvol = vtkVolume::New();
361         _newvol->SetMapper(_volumeMapper );
362         _newvol->SetProperty(_volumeProperty );
363
364   _observerV = boxSurfaceObserver::New();
365         _observerV->SetPlanes( _volumePlanes );
366         _observerV->SetActor( _newvol );
367         _observerV->SetvtkVolumeRayCastMapper( _volumeMapper );
368 }
369
370 void vtkClipping3DDataViewer::updateVolume()
371 {
372
373     if(_isRayCasting)
374     {
375         cout<<"JPRG::vtkClipping3DDataViewer::Configure_Volume::isRayCasting"<<endl;
376         _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
377     }
378     else if(_isMIP)
379     {
380         cout<<"JPRG::vtkClipping3DDataViewer::Configure_Volume::isMIP"<<endl;
381
382         _volumeMapper->SetVolumeRayCastFunction(_compositeFunctionMIP);
383     }
384
385     if(_interpolation)
386     {
387         _volumeProperty->SetInterpolationTypeToLinear();
388     }
389     else
390     {
391         _volumeProperty->SetInterpolationTypeToNearest();
392     }
393
394     if(_shade)
395     {
396         _volumeProperty->ShadeOn();
397     }
398     else
399     {
400         _volumeProperty->ShadeOff();
401     }
402
403 }
404
405 //-------------------------------------------------------------------
406 void vtkClipping3DDataViewer::Configure()
407 {
408         Configure_Tissue();
409         Configure_Volume();
410
411   // An outline provides context around the data.
412   //
413         _outlineData = vtkOutlineFilter::New();
414     _outlineData->SetInput((vtkDataSet *) _vtkmprbasedata->GetImageData() );
415         _mapOutline = vtkPolyDataMapper::New();
416     _mapOutline->SetInput(_outlineData->GetOutput());
417         _outline = vtkActor::New();
418     _outline->SetMapper(_mapOutline);
419     _outline->GetProperty()->SetColor(0,0,0);
420 }
421
422
423 //-------------------------------------------------------------------
424 void vtkClipping3DDataViewer::SetIsovalue(int idTissue, int isoValue)
425 {
426         _mCubes[idTissue]->SetValue(0, isoValue);
427 }
428 //-------------------------------------------------------------------
429 double vtkClipping3DDataViewer::GetIsovalue(int idTissue)
430 {
431         return _mCubes[idTissue]->GetValue(0);
432 }
433 //-------------------------------------------------------------------
434 vtkVolume* vtkClipping3DDataViewer::GetVolumeActor()
435 {
436    return _newvol;
437 }
438 //-------------------------------------------------------------------
439 vtkVolumeRayCastMapper* vtkClipping3DDataViewer::GetVolumeMapper(){
440         return _volumeMapper;
441 }
442 //-------------------------------------------------------------------
443 vtkPlanes* vtkClipping3DDataViewer::GetVolumePlanes()
444 {
445         return _volumePlanes;
446 }
447
448 //-------------------------------------------------------------------
449 vtkMarchingCubes *vtkClipping3DDataViewer::GetMCubes(int idTissue)
450 {
451         return _mCubes[idTissue];
452 }
453 //--------------------------------------------------------------------
454 //-------------------
455 //Getters Vectors
456 //-------------------
457
458 std::vector<double>*    vtkClipping3DDataViewer::GetGreyValuesTransferenceFVector()
459 {
460         return &greyValuesTransferenceFVector;
461 }
462 //--------------------------------------------------------------------
463 std::vector<double>*    vtkClipping3DDataViewer::GetIntensityValuesTransferenceFVector()
464 {
465         return &intensityValuesTransferenceFVector;
466 }
467 //--------------------------------------------------------------------
468 std::vector<double>*    vtkClipping3DDataViewer::GetRedColorsOfColorTransferenceFVector()
469 {
470         return &redColorsOfColorTransferenceFVector;
471 }
472 //--------------------------------------------------------------------
473 std::vector<double>*    vtkClipping3DDataViewer::GetGreenColorsOfColorTransferenceFVector()
474 {
475         return &greenColorsOfColorTransferenceFVector;
476 }
477 //--------------------------------------------------------------------
478 std::vector<double>*    vtkClipping3DDataViewer::GetBlueColorsOfColorTransferenceFVector()
479 {
480         return &blueColorsOfColorTransferenceFVector;
481 }
482 //--------------------------------------------------------------------
483 std::vector<double>*    vtkClipping3DDataViewer::GetGreyValueColorsOfColorTransferenceFVector()
484 {
485         return &greyValueColorsOfColorTransferenceFVector;
486 }
487 //--------------------------------------------------------------------
488 //--------------------------------------
489 //Getters transference function
490 //and color of the transference function
491 //---------------------------------------
492 vtkPiecewiseFunction* vtkClipping3DDataViewer::GetTransferencefunction()
493 {
494         return this->_tfun;
495 }
496 //--------------------------------------------------------------------
497 vtkColorTransferFunction* vtkClipping3DDataViewer::GetColorTransferenceFunction()
498 {
499         return this->_ctfun;
500 }
501
502 //-------------------------------------------------------------------
503
504 void vtkClipping3DDataViewer::ReadVolumeFunctions()
505 {
506 /*
507         int i=0,xi,yi,r,g,b,gValue;
508         vtkImageData *imagedata = this->_vtkmprbasedata->GetImageData();
509
510         HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Histogram Dialog"),imagedata);
511         //
512         // put in a method
513         //
514         int tfSize=this->greyValuesTransferenceFVector.size();
515                 if(tfSize>0)
516                 {
517                         int i=0,y;
518                         hDlg->erasePointsTransferenceFunction();
519                         while(i<tfSize)
520                         {
521                                 double g=greyValuesTransferenceFVector[i];
522                                 double in=intensityValuesTransferenceFVector[i];
523                                 hDlg->addPointToTransferenceFunction(g,in*100);
524                                 i++;
525                         }
526
527                 }
528
529         int ctfSize=this->redColorsOfColorTransferenceFVector.size();
530         if(ctfSize>0)
531         {
532                 int i=0,y;
533                         while(i<ctfSize)
534                         {
535                                 double gr=greyValueColorsOfColorTransferenceFVector[i];
536                                 double r=redColorsOfColorTransferenceFVector[i];
537                                 double g=greenColorsOfColorTransferenceFVector[i];
538                                 double b=blueColorsOfColorTransferenceFVector[i];
539                                 hDlg->addColorPoint(gr,r*255,g*255,b*255);
540                                 i++;
541                         }
542         }
543         //If it is smooth activate next line
544         //hDlg->updatePlotter();
545         //setting variables if the user wants to do refresh
546         hDlg->setCTF(_ctfun);
547         hDlg->setTF(_tfun);
548
549         //
550         // when the user had changed the transference Function
551         //
552         if(hDlg->ShowModal()== wxID_OK )
553         {
554                         // -- vtkPiecewiseFunction --
555                         this->_tfun->RemoveAllPoints();
556                         greyValuesTransferenceFVector.clear();
557                         intensityValuesTransferenceFVector.clear();
558
559                         int nTFPoints=hDlg->getSizeTransferenceFunction();
560                         i=0;
561                         while(i<nTFPoints)
562                         {
563                                 hDlg->getTransferenceFunctionPoint(i,xi,yi);
564                                 this->_tfun->AddPoint( xi , yi/100.0 );
565                                 greyValuesTransferenceFVector.push_back(xi);
566                                 intensityValuesTransferenceFVector.push_back(yi/100.0);
567                                 i++;
568                         }
569                         // -- vtkColorTransferFunction  --
570                         this->_ctfun->RemoveAllPoints ();
571                         //clean colors
572                         redColorsOfColorTransferenceFVector.clear();
573                         greenColorsOfColorTransferenceFVector.clear();
574                         blueColorsOfColorTransferenceFVector.clear();
575                         greyValueColorsOfColorTransferenceFVector.clear();
576
577                         int nCTFpoints=hDlg->getSizeBarColor();
578                         i=0;
579                         while(i<nCTFpoints)
580                         {
581                                 hDlg->getDataBarColorPoint(i,xi,r,g,b);
582                                 this->_ctfun->AddRGBPoint(xi,r/255.0,g/255.0,b/255.0 );
583                                 redColorsOfColorTransferenceFVector.push_back(r/255.0);
584                                 greenColorsOfColorTransferenceFVector.push_back(g/255.0);
585                                 blueColorsOfColorTransferenceFVector.push_back(b/255.0);
586                                 greyValueColorsOfColorTransferenceFVector.push_back(xi);
587                                 i++;
588                         }
589
590                         this->_volumeMapper->Update();
591                         this->_newvol->Update();
592         }
593
594         else
595         {
596
597                 if(hDlg->getRefreshed())
598                 {
599                         int i=0,size;
600                         //--Transference Function----
601                         this->_tfun->RemoveAllPoints();
602                         i=0;
603                         size=greyValuesTransferenceFVector.size();
604                         for(i=0;i<size;i++)
605                         {
606                                 double grey1=greyValuesTransferenceFVector[i];
607                                 double  in2=intensityValuesTransferenceFVector[i];
608                                 this->_tfun->AddPoint( grey1 , in2 );
609                         }
610
611                         // -- vtkColorTransferFunction  --
612                         _ctfun->RemoveAllPoints ();
613
614                         i=0;
615                         size=greyValueColorsOfColorTransferenceFVector.size();
616                         for(i=0;i<size;i++)
617                         {
618                                 double grey2=(greyValueColorsOfColorTransferenceFVector)[i];
619                                 double red =(redColorsOfColorTransferenceFVector)[i];
620                                 double green =(greenColorsOfColorTransferenceFVector)[i];
621                                 double blue = (blueColorsOfColorTransferenceFVector)[i];
622                                 _ctfun->AddRGBPoint(grey2,red,green,blue);
623                         }
624                         this->_volumeMapper->Update();
625                         this->_newvol->Update();
626                  }
627
628         }
629         hDlg->Destroy();
630 */
631 }
632 /*
633 void vtkClipping3DDataViewer::ReadVolumeFunctions(char *namefile)
634 {
635         char tmp[256];
636         short int       max;
637         double          range[2];
638         double          x,val,r,g,b;
639
640         FILE *ff = fopen ( namefile ,"r");
641
642         // --  MAX  --
643         fscanf(ff,"%s",tmp);
644         if (strcmp(tmp,"MAX")==0)
645         {
646                 vtkImageData *vtkimagedata              = this->_vtkmprbasedata->GetImageData();
647                 vtkimagedata->GetScalarRange(range);
648                 max = (int) (range[1]);
649         } else {
650                 max = atoi(tmp);
651         }
652
653         fscanf(ff,"%s",tmp);   // --
654
655         // -- vtkPiecewiseFunction --
656         this->_tfun->RemoveAllPoints();
657         fscanf(ff,"%s",tmp);
658         while ( strcmp(tmp,"--")!=0 )
659         {
660                 x=atof(tmp);
661                 fscanf(ff,"%s",tmp);
662                 val=atof(tmp);
663                 this->_tfun->AddPoint( x*max , val );
664                 fscanf(ff,"%s",tmp);
665         }
666
667         this->_ctfun->RemoveAllPoints ();
668         // -- vtkColorTransferFunction  --
669         while ( !feof(ff))
670         {
671                 fscanf(ff,"%s",tmp);
672                 x=atof(tmp);
673                 fscanf(ff,"%s",tmp);
674                 r=atof(tmp);
675                 fscanf(ff,"%s",tmp);
676                 g=atof(tmp);
677                 fscanf(ff,"%s",tmp);
678                 b=atof(tmp);
679                 this->_ctfun->AddRGBPoint( x*max , r,g,b );
680         }
681
682
683         this->_volumeMapper->Update();
684         this->_newvol->Update();
685
686
687         fclose(ff);
688 }
689 */
690
691 //-------------------------------------------------------------------
692 // EED 23 Mai 2007
693 void vtkClipping3DDataViewer::ReadMeshVTK(char *namefile)
694 {
695         vtkDataSetReader *reader = vtkDataSetReader::New();
696         reader->SetFileName(namefile);
697         reader->Update();
698         _tissueStripper[3]->SetInput( reader->GetPolyDataOutput()  );
699 }
700
701 void vtkClipping3DDataViewer::setColorTransferFunction(vtkColorTransferFunction* colortable){
702
703         _volumeProperty->SetColor(colortable);
704
705 }
706
707
708 void vtkClipping3DDataViewer::SetRayCasting(bool active)
709 {
710     _isRayCasting   =   active;
711
712 }
713
714 void vtkClipping3DDataViewer::SetMIPActive(bool active)
715 {
716     _isMIP  = active;
717 }
718
719 void vtkClipping3DDataViewer::SetInterpolation(bool active)
720 {
721     _interpolation = active;
722 }
723
724 void vtkClipping3DDataViewer::SetShade(bool active)
725 {
726     _shade  =   active;
727 }
728