]> 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     _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
170
171 bool vtkClipping3DDataViewer::GetVisibleVolumeBox()
172 {
173         return _visibleVolumeBox;
174 }
175 //-------------------------------------------------------------------
176 void vtkClipping3DDataViewer::SetVisibleVolumeBox(bool visibleBox)
177 {
178         _visibleVolumeBox = visibleBox;
179 }
180
181
182
183 //-------------------------------------------------------------------
184 void vtkClipping3DDataViewer::Configure_Tissue()
185 {
186
187         double range[2];
188         int i;
189         for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){
190                 // Visualisation - original volume
191                 vtkImageData *imagedata=_vtkmprbasedata->GetImageData();
192                 imagedata->GetScalarRange( range );
193                 _mCubes[i] = vtkMarchingCubes::New( );
194                 _mCubes[i]->SetInput( imagedata );
195
196                 _mCubes[i]->SetValue( 0, range[1]*(4+i) / 8 );
197 //              _mCubes[i]->SetValue( 0, 1500 );
198
199             _tissueStripper[i] = vtkStripper::New();
200             _tissueStripper[i]->SetInput( _mCubes[i]->GetOutput( ) );
201
202
203
204                 _tissuePlanes[i]  = vtkPlanes::New();
205
206                 int x1,x2,y1,y2,z1,z2;
207                 imagedata->GetExtent(x1,x2,y1,y2,z1,z2);
208                 _tissuePlanes[i]->SetBounds  (x1,x2,y1,y2,z1,z2);
209
210                 _tissueClipper[i] = vtkClipPolyData::New();
211                 _tissueClipper[i]->SetInput( _tissueStripper[i]->GetOutput() );
212                 _tissueClipper[i]->SetClipFunction( _tissuePlanes[i] );
213                 _tissueClipper[i]->InsideOutOn( );
214
215                 _tissueMapper[i] = vtkPolyDataMapper::New( );
216                 _tissueMapper[i]->SetInput( _tissueClipper[i]->GetOutput() );
217                 _tissueMapper[i]->ScalarVisibilityOff( );
218 //              _tissueMapper[i]->Update();
219
220         }
221
222
223
224         // vtkActor tissue
225         for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){
226                 // tissue
227                 _tissue[i] = vtkActor::New();
228                 _tissue[i]->SetMapper( GetTissueMapper(i) );
229                 float cr=1,cg=0.5,cb=0.5;
230                 _tissue[i]->GetProperty()->SetDiffuseColor(cr/255, cg/255   , cb/255   );
231                 _tissue[i]->GetProperty()->SetSpecular(.3);
232                 _tissue[i]->GetProperty()->SetSpecularPower(20);
233                 _tissue[i]->GetProperty()->SetOpacity(0.5);
234                 if (i==0) _tissue[i]->GetProperty()->SetColor(0.85, 0.85   , 0.85   );
235                 if (i==1) _tissue[i]->GetProperty()->SetColor(0, 0  ,  1  );
236                 if (i==2) _tissue[i]->GetProperty()->SetColor(0.85, 0.20   , 0.20   );
237                 if (i==3) _tissue[i]->GetProperty()->SetColor(0, 1   , 0   );
238         }
239
240         for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
241         {
242                 _observerS[i] = boxSurfaceObserver::New();
243                 _observerS[i]->SetPlanes( GetTissuePlanes(i) );
244                 _observerS[i]->SetActor( _tissue[i] );
245         }
246
247 }
248
249 //-----------------------------------------------------------------------------
250
251 void vtkClipping3DDataViewer::Configure_Volume()
252 {
253   // Volume
254
255
256
257  /** if(_newvol != NULL)
258   {
259     _newvol->Delete();
260     _volumeMapper->Delete();
261     _volumeProperty->Delete();
262   }*/
263
264
265
266   _tfun = vtkPiecewiseFunction::New();
267   _ctfun = vtkColorTransferFunction::New();
268
269         double range[2];
270         this->_vtkmprbasedata->GetImageData()->GetScalarRange(range);
271         double max = range[1];
272
273         /*
274         adding the poinst of the transference function
275         */
276         //X
277         greyValuesTransferenceFVector.push_back(max * 0/2);  // JPR ?? 0/2
278         greyValuesTransferenceFVector.push_back(max * 1/2);  // JPR ?? division entiere?
279         greyValuesTransferenceFVector.push_back(max * 2/2);
280         //Y
281         intensityValuesTransferenceFVector.push_back(0.0);
282         intensityValuesTransferenceFVector.push_back(1.0);
283         intensityValuesTransferenceFVector.push_back(1.0);
284
285         _tfun->AddPoint(max * 0/2 , 0.0);
286         _tfun->AddPoint(max * 1/2 , 1.0);
287         _tfun->AddPoint(max * 2/2 , 1.0);
288
289         /*
290                 Adding the colors to the vectors
291         */
292         //RED
293         redColorsOfColorTransferenceFVector.push_back(0.0);
294         redColorsOfColorTransferenceFVector.push_back(1.0);
295         redColorsOfColorTransferenceFVector.push_back(0.0);
296         redColorsOfColorTransferenceFVector.push_back(0.0);
297         redColorsOfColorTransferenceFVector.push_back(0.0);
298
299         //GREEN
300         greenColorsOfColorTransferenceFVector.push_back(0.0);
301         greenColorsOfColorTransferenceFVector.push_back(0.0);
302         greenColorsOfColorTransferenceFVector.push_back(0.0);
303         greenColorsOfColorTransferenceFVector.push_back(1.0);
304         greenColorsOfColorTransferenceFVector.push_back(0.2);
305
306         //BLUE
307         blueColorsOfColorTransferenceFVector.push_back(0.0);
308         blueColorsOfColorTransferenceFVector.push_back(0.0);
309         blueColorsOfColorTransferenceFVector.push_back(1.0);
310         blueColorsOfColorTransferenceFVector.push_back(0.0);
311         blueColorsOfColorTransferenceFVector.push_back(0.0);
312         //GREY VALUE
313         greyValueColorsOfColorTransferenceFVector.push_back(max*0/4);
314         greyValueColorsOfColorTransferenceFVector.push_back(max*1/4);
315         greyValueColorsOfColorTransferenceFVector.push_back(max*2/4);
316         greyValueColorsOfColorTransferenceFVector.push_back(max*3/4);
317         greyValueColorsOfColorTransferenceFVector.push_back(max*4/4);
318
319         _ctfun->AddRGBPoint( max*0/4 , 0.0, 0.0, 0.0);
320         _ctfun->AddRGBPoint( max*1/4 , 1.0, 0.0, 0.0);
321         _ctfun->AddRGBPoint( max*2/4 , 0.0, 0.0, 1.0);
322         _ctfun->AddRGBPoint( max*3/4 , 0.0, 1.0, 0.0);
323         _ctfun->AddRGBPoint( max*4/4 , 0.0, 0.2, 0.0);
324
325   _volumePlanes  = vtkPlanes::New();
326 //      int x1,x2,y1,y2,z1,z2;
327 //      vtkImageData *imagedata=_vtkmprbasedata->GetImageData();
328 //      imagedata->GetExtent(x1,x2,y1,y2,z1,z2);
329 //      _volumePlanes->SetBounds(x1,x2,y1,y2,z1,z2);
330
331         // EED 13/03/2011
332
333
334
335  // _volumeMapper = vtkVolumeRayCastMapper::New();
336         _volumeMapper->SetInput( this->GetVtkMPRBaseData()->GetImageData() );
337
338
339
340     _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
341
342
343    // _volumeMapper->SetVolumeRayCastFunction(_compositeFunctionMIP);
344
345 //
346
347         _volumeMapper->SetClippingPlanes( _volumePlanes );
348         _volumeMapper->AutoAdjustSampleDistancesOn();
349
350     _volumeProperty->SetInterpolationTypeToNearest();
351     //_volumeProperty = vtkVolumeProperty::New();
352         _volumeProperty->SetColor(_ctfun);
353         _volumeProperty->SetScalarOpacity( _tfun );
354
355 // EED 31/03/2008
356
357         _volumeProperty->DisableGradientOpacityOn();
358
359
360
361 //      _
362
363
364 //      _
365
366
367 //      _volumeProperty->SetInterpolationTypeToNearest();
368 //      _volumeProperty->ShadeOff();
369 //      _volumeProperty->SetAmbient(0.3);
370 //      _volumeProperty->SetDiffuse(0.1);
371 //      _volumeProperty->SetSpecular(0.8);
372 //      _volumeProperty->DisableGradientOpacityOn();
373
374  // _newvol = vtkVolume::New();
375         _newvol->SetMapper(_volumeMapper );
376         _newvol->SetProperty(_volumeProperty );
377
378   _observerV = boxSurfaceObserver::New();
379         _observerV->SetPlanes( _volumePlanes );
380         _observerV->SetActor( _newvol );
381         _observerV->SetvtkVolumeRayCastMapper( _volumeMapper );
382 }
383
384
385 void vtkClipping3DDataViewer::Configure_VolumeBox()
386 {
387     cout<<"JPRG::vtkClipping3DDataViewer::Configure_VolumeBox()"<<endl;
388
389         _volumerendererdata->SetImageData(_vtkmprbasedata->GetImageData());
390
391
392     vector<double> *gv = this->GetGreyValuesTransferenceFVector();
393     vector<double> *op = this->GetIntensityValuesTransferenceFVector();
394
395
396     _volumerendererdata->SetLookUpTable((vtkLookupTable*)(_ctfun));
397     _volumerendererdata->OpacityChanged(*gv, *op);
398
399     //_wxvtkclipping3Dview->VisibleVolumeActor( false );
400     //_volumerendererdata->ShowVolume(event.IsChecked() );
401        //_volumerendererdata->BoundingBoxChanged(event.IsChecked() );
402 }
403
404 void vtkClipping3DDataViewer::SetRenderer(vtkRenderer* renderer)
405 {
406     _volumerendererdata->SetRenderer(renderer);
407
408 }
409
410 void vtkClipping3DDataViewer::SetInteractor(vtkRenderWindowInteractor* interactor)
411 {
412
413     _volumerendererdata->SetInteractor(interactor);
414 }
415
416
417 void vtkClipping3DDataViewer::BoxActorChanged(bool changed)
418 {
419     vector<double> *gv = this->GetGreyValuesTransferenceFVector();
420     vector<double> *op = this->GetIntensityValuesTransferenceFVector();
421
422    _volumerendererdata->ShowVolume(changed);
423     _volumerendererdata->OpacityChanged(*gv, *op);
424     _volumerendererdata->BoundingBoxChanged(changed);
425
426 }
427
428 void vtkClipping3DDataViewer::UpdateVolumeBox(vector<double> gf, vector<double> vf, vtkColorTransferFunction* ctfun)
429 {
430         _volumerendererdata->SetLookUpTable((vtkLookupTable*)(ctfun));
431         _volumerendererdata->OpacityChanged(gf, vf);
432 }
433
434
435 void vtkClipping3DDataViewer::updateVolume()
436 {
437
438     if(_isRayCasting)
439     {
440         _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
441         _volumerendererdata->changeCompositeMIPFunction(0);
442     }
443     else if(_isMIP)
444     {
445         _volumeMapper->SetVolumeRayCastFunction(_compositeFunctionMIP);
446         _volumerendererdata->changeCompositeMIPFunction(1);
447     }
448
449     if(_interpolation)
450     {
451         _volumeProperty->SetInterpolationTypeToLinear();
452     }
453     else
454     {
455         _volumeProperty->SetInterpolationTypeToNearest();
456     }
457
458     if(_shade)
459     {
460         _volumeProperty->ShadeOn();
461     }
462     else
463     {
464         _volumeProperty->ShadeOff();
465     }
466
467 }
468
469 //-------------------------------------------------------------------
470 void vtkClipping3DDataViewer::Configure()
471 {
472         Configure_Tissue();
473         Configure_Volume();
474     Configure_VolumeBox();
475   // An outline provides context around the data.
476   //
477         _outlineData = vtkOutlineFilter::New();
478     _outlineData->SetInput((vtkDataSet *) _vtkmprbasedata->GetImageData() );
479         _mapOutline = vtkPolyDataMapper::New();
480     _mapOutline->SetInput(_outlineData->GetOutput());
481         _outline = vtkActor::New();
482     _outline->SetMapper(_mapOutline);
483     _outline->GetProperty()->SetColor(0,0,0);
484 }
485
486
487 //-------------------------------------------------------------------
488 void vtkClipping3DDataViewer::SetIsovalue(int idTissue, int isoValue)
489 {
490         _mCubes[idTissue]->SetValue(0, isoValue);
491 }
492 //-------------------------------------------------------------------
493 double vtkClipping3DDataViewer::GetIsovalue(int idTissue)
494 {
495         return _mCubes[idTissue]->GetValue(0);
496 }
497 //-------------------------------------------------------------------
498 vtkVolume* vtkClipping3DDataViewer::GetVolumeActor()
499 {
500    return _newvol;
501 }
502 //-------------------------------------------------------------------
503 vtkVolumeRayCastMapper* vtkClipping3DDataViewer::GetVolumeMapper(){
504         return _volumeMapper;
505 }
506 //-------------------------------------------------------------------
507 vtkPlanes* vtkClipping3DDataViewer::GetVolumePlanes()
508 {
509         return _volumePlanes;
510 }
511
512 //-------------------------------------------------------------------
513 vtkMarchingCubes *vtkClipping3DDataViewer::GetMCubes(int idTissue)
514 {
515         return _mCubes[idTissue];
516 }
517 //--------------------------------------------------------------------
518 //-------------------
519 //Getters Vectors
520 //-------------------
521
522 std::vector<double>*    vtkClipping3DDataViewer::GetGreyValuesTransferenceFVector()
523 {
524         return &greyValuesTransferenceFVector;
525 }
526 //--------------------------------------------------------------------
527 std::vector<double>*    vtkClipping3DDataViewer::GetIntensityValuesTransferenceFVector()
528 {
529         return &intensityValuesTransferenceFVector;
530 }
531 //--------------------------------------------------------------------
532 std::vector<double>*    vtkClipping3DDataViewer::GetRedColorsOfColorTransferenceFVector()
533 {
534         return &redColorsOfColorTransferenceFVector;
535 }
536 //--------------------------------------------------------------------
537 std::vector<double>*    vtkClipping3DDataViewer::GetGreenColorsOfColorTransferenceFVector()
538 {
539         return &greenColorsOfColorTransferenceFVector;
540 }
541 //--------------------------------------------------------------------
542 std::vector<double>*    vtkClipping3DDataViewer::GetBlueColorsOfColorTransferenceFVector()
543 {
544         return &blueColorsOfColorTransferenceFVector;
545 }
546 //--------------------------------------------------------------------
547 std::vector<double>*    vtkClipping3DDataViewer::GetGreyValueColorsOfColorTransferenceFVector()
548 {
549         return &greyValueColorsOfColorTransferenceFVector;
550 }
551 //--------------------------------------------------------------------
552 //--------------------------------------
553 //Getters transference function
554 //and color of the transference function
555 //---------------------------------------
556 vtkPiecewiseFunction* vtkClipping3DDataViewer::GetTransferencefunction()
557 {
558         return this->_tfun;
559 }
560 //--------------------------------------------------------------------
561 vtkColorTransferFunction* vtkClipping3DDataViewer::GetColorTransferenceFunction()
562 {
563         return this->_ctfun;
564 }
565
566 //-------------------------------------------------------------------
567
568 void vtkClipping3DDataViewer::ReadVolumeFunctions()
569 {
570 /*
571         int i=0,xi,yi,r,g,b,gValue;
572         vtkImageData *imagedata = this->_vtkmprbasedata->GetImageData();
573
574         HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Histogram Dialog"),imagedata);
575         //
576         // put in a method
577         //
578         int tfSize=this->greyValuesTransferenceFVector.size();
579                 if(tfSize>0)
580                 {
581                         int i=0,y;
582                         hDlg->erasePointsTransferenceFunction();
583                         while(i<tfSize)
584                         {
585                                 double g=greyValuesTransferenceFVector[i];
586                                 double in=intensityValuesTransferenceFVector[i];
587                                 hDlg->addPointToTransferenceFunction(g,in*100);
588                                 i++;
589                         }
590
591                 }
592
593         int ctfSize=this->redColorsOfColorTransferenceFVector.size();
594         if(ctfSize>0)
595         {
596                 int i=0,y;
597                         while(i<ctfSize)
598                         {
599                                 double gr=greyValueColorsOfColorTransferenceFVector[i];
600                                 double r=redColorsOfColorTransferenceFVector[i];
601                                 double g=greenColorsOfColorTransferenceFVector[i];
602                                 double b=blueColorsOfColorTransferenceFVector[i];
603                                 hDlg->addColorPoint(gr,r*255,g*255,b*255);
604                                 i++;
605                         }
606         }
607         //If it is smooth activate next line
608         //hDlg->updatePlotter();
609         //setting variables if the user wants to do refresh
610         hDlg->setCTF(_ctfun);
611         hDlg->setTF(_tfun);
612
613         //
614         // when the user had changed the transference Function
615         //
616         if(hDlg->ShowModal()== wxID_OK )
617         {
618                         // -- vtkPiecewiseFunction --
619                         this->_tfun->RemoveAllPoints();
620                         greyValuesTransferenceFVector.clear();
621                         intensityValuesTransferenceFVector.clear();
622
623                         int nTFPoints=hDlg->getSizeTransferenceFunction();
624                         i=0;
625                         while(i<nTFPoints)
626                         {
627                                 hDlg->getTransferenceFunctionPoint(i,xi,yi);
628                                 this->_tfun->AddPoint( xi , yi/100.0 );
629                                 greyValuesTransferenceFVector.push_back(xi);
630                                 intensityValuesTransferenceFVector.push_back(yi/100.0);
631                                 i++;
632                         }
633                         // -- vtkColorTransferFunction  --
634                         this->_ctfun->RemoveAllPoints ();
635                         //clean colors
636                         redColorsOfColorTransferenceFVector.clear();
637                         greenColorsOfColorTransferenceFVector.clear();
638                         blueColorsOfColorTransferenceFVector.clear();
639                         greyValueColorsOfColorTransferenceFVector.clear();
640
641                         int nCTFpoints=hDlg->getSizeBarColor();
642                         i=0;
643                         while(i<nCTFpoints)
644                         {
645                                 hDlg->getDataBarColorPoint(i,xi,r,g,b);
646                                 this->_ctfun->AddRGBPoint(xi,r/255.0,g/255.0,b/255.0 );
647                                 redColorsOfColorTransferenceFVector.push_back(r/255.0);
648                                 greenColorsOfColorTransferenceFVector.push_back(g/255.0);
649                                 blueColorsOfColorTransferenceFVector.push_back(b/255.0);
650                                 greyValueColorsOfColorTransferenceFVector.push_back(xi);
651                                 i++;
652                         }
653
654                         this->_volumeMapper->Update();
655                         this->_newvol->Update();
656         }
657
658         else
659         {
660
661                 if(hDlg->getRefreshed())
662                 {
663                         int i=0,size;
664                         //--Transference Function----
665                         this->_tfun->RemoveAllPoints();
666                         i=0;
667                         size=greyValuesTransferenceFVector.size();
668                         for(i=0;i<size;i++)
669                         {
670                                 double grey1=greyValuesTransferenceFVector[i];
671                                 double  in2=intensityValuesTransferenceFVector[i];
672                                 this->_tfun->AddPoint( grey1 , in2 );
673                         }
674
675                         // -- vtkColorTransferFunction  --
676                         _ctfun->RemoveAllPoints ();
677
678                         i=0;
679                         size=greyValueColorsOfColorTransferenceFVector.size();
680                         for(i=0;i<size;i++)
681                         {
682                                 double grey2=(greyValueColorsOfColorTransferenceFVector)[i];
683                                 double red =(redColorsOfColorTransferenceFVector)[i];
684                                 double green =(greenColorsOfColorTransferenceFVector)[i];
685                                 double blue = (blueColorsOfColorTransferenceFVector)[i];
686                                 _ctfun->AddRGBPoint(grey2,red,green,blue);
687                         }
688                         this->_volumeMapper->Update();
689                         this->_newvol->Update();
690                  }
691
692         }
693         hDlg->Destroy();
694 */
695 }
696 /*
697 void vtkClipping3DDataViewer::ReadVolumeFunctions(char *namefile)
698 {
699         char tmp[256];
700         short int       max;
701         double          range[2];
702         double          x,val,r,g,b;
703
704         FILE *ff = fopen ( namefile ,"r");
705
706         // --  MAX  --
707         fscanf(ff,"%s",tmp);
708         if (strcmp(tmp,"MAX")==0)
709         {
710                 vtkImageData *vtkimagedata              = this->_vtkmprbasedata->GetImageData();
711                 vtkimagedata->GetScalarRange(range);
712                 max = (int) (range[1]);
713         } else {
714                 max = atoi(tmp);
715         }
716
717         fscanf(ff,"%s",tmp);   // --
718
719         // -- vtkPiecewiseFunction --
720         this->_tfun->RemoveAllPoints();
721         fscanf(ff,"%s",tmp);
722         while ( strcmp(tmp,"--")!=0 )
723         {
724                 x=atof(tmp);
725                 fscanf(ff,"%s",tmp);
726                 val=atof(tmp);
727                 this->_tfun->AddPoint( x*max , val );
728                 fscanf(ff,"%s",tmp);
729         }
730
731         this->_ctfun->RemoveAllPoints ();
732         // -- vtkColorTransferFunction  --
733         while ( !feof(ff))
734         {
735                 fscanf(ff,"%s",tmp);
736                 x=atof(tmp);
737                 fscanf(ff,"%s",tmp);
738                 r=atof(tmp);
739                 fscanf(ff,"%s",tmp);
740                 g=atof(tmp);
741                 fscanf(ff,"%s",tmp);
742                 b=atof(tmp);
743                 this->_ctfun->AddRGBPoint( x*max , r,g,b );
744         }
745
746
747         this->_volumeMapper->Update();
748         this->_newvol->Update();
749
750
751         fclose(ff);
752 }
753 */
754
755 //-------------------------------------------------------------------
756 // EED 23 Mai 2007
757 void vtkClipping3DDataViewer::ReadMeshVTK(char *namefile)
758 {
759         vtkDataSetReader *reader = vtkDataSetReader::New();
760         reader->SetFileName(namefile);
761         reader->Update();
762         _tissueStripper[3]->SetInput( reader->GetPolyDataOutput()  );
763 }
764
765 void vtkClipping3DDataViewer::setColorTransferFunction(vtkColorTransferFunction* colortable){
766
767         _volumeProperty->SetColor(colortable);
768
769 }
770
771
772 void vtkClipping3DDataViewer::SetRayCasting(bool active)
773 {
774     _isRayCasting   =   active;
775
776 }
777
778 void vtkClipping3DDataViewer::SetMIPActive(bool active)
779 {
780     _isMIP  = active;
781 }
782
783 void vtkClipping3DDataViewer::SetInterpolation(bool active)
784 {
785     _interpolation = active;
786 }
787
788 void vtkClipping3DDataViewer::SetShade(bool active)
789 {
790     _shade  =   active;
791 }
792