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