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