1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
27 #include "vtkClipping3DDataViewer.h"
28 #include "vtkDataSetReader.h"
29 #include "vtkProperty.h"
31 vtkClipping3DDataViewer::vtkClipping3DDataViewer()
34 for (i=0; i<VTKMPRDATA_MAXTISSUE; i++)
36 _visibleTissue[i] = false;
37 _representationType[i] = true;
39 _visibleVolume = false;
42 _interpolation = false;
45 _volumerendererdata = VolumeRendererData::New();
47 #if (VTK_MAJOR_VERSION <= 7)
48 _volumeMapper = vtkVolumeRayCastMapper::New();
49 _compositeFunction = vtkVolumeRayCastCompositeFunction::New();
50 _compositeFunctionMIP = vtkVolumeRayCastMIPFunction::New();
52 _volumeMapper = vtkFixedPointVolumeRayCastMapper::New();
55 _newvol = vtkVolume::New();
56 _volumeProperty = vtkVolumeProperty::New();
59 //-------------------------------------------------------------------
60 vtkClipping3DDataViewer::~vtkClipping3DDataViewer()
63 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){
65 _tissueStripper[i]->Delete();
66 _tissueMapper[i]->Delete();
67 _tissuePlanes[i]->Delete();
68 _tissueClipper[i]->Delete();
74 #if (VTK_MAJOR_VERSION <= 7)
75 _compositeFunction->Delete();
79 _volumeMapper->Delete();
80 _volumeProperty->Delete();
82 _volumePlanes->Delete();
84 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){
85 _tissue[i]-> Delete();
86 _observerS[i]-> Delete();
88 _observerV-> Delete();
91 //-------------------------------------------------------------------
92 vtkClipPolyData* vtkClipping3DDataViewer::GetTissueClipper(int id)
94 return this->_tissueClipper[id];
96 //-------------------------------------------------------------------
97 vtkPolyDataMapper* vtkClipping3DDataViewer::GetTissueMapper(int id)
99 return _tissueMapper[id];
101 //-------------------------------------------------------------------
102 vtkPlanes* vtkClipping3DDataViewer::GetTissuePlanes(int id)
104 return _tissuePlanes[id];
106 //-------------------------------------------------------------------
107 vtkStripper* vtkClipping3DDataViewer::GetTissueStripper(int id)
109 return _tissueStripper[id];
111 //-------------------------------------------------------------------
112 void vtkClipping3DDataViewer::Refresh()
114 // _volumeMapper->SetClippingPlanes(_volumePlanes);
116 // this->_volumeMapper->Update();
117 // this->_newvol->Update();
119 // _newvol->VisibilityOn();
122 // _volumeMapper = vtkVolumeRayCastMapper::New();
123 // _volumeMapper->SetInput( this->GetVtkMPRBaseData()->GetImageData() );
124 // _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
125 // _volumeMapper->SetClippingPlanes( _volumePlanes );
126 // _newvol->SetMapper(_volumeMapper );
130 //-------------------------------------------------------------------
131 void vtkClipping3DDataViewer::RefreshSurface()
134 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
136 SetIsovalue(i, (int) (GetIsovalue(i)+1) );
137 // this->GetMCubes(i)->Update();
140 //-------------------------------------------------------------------
141 void vtkClipping3DDataViewer::SetVtkMPRBaseData(vtkMPRBaseData *vtkmprbasedata)
143 _vtkmprbasedata=vtkmprbasedata;
145 //-------------------------------------------------------------------
146 vtkMPRBaseData* vtkClipping3DDataViewer::GetVtkMPRBaseData()
148 return _vtkmprbasedata;
152 //-------------------------------------------------------------------
153 void vtkClipping3DDataViewer::SetVisibleTissue(int idTissue, bool visible)
155 _visibleTissue[idTissue]=visible;
157 //-------------------------------------------------------------------
158 bool vtkClipping3DDataViewer::GetVisibleTissue(int idTissue){
159 return _visibleTissue[idTissue];
161 //-------------------------------------------------------------------
162 void vtkClipping3DDataViewer::SetRepresentationType(int idTissue, bool representationType)
164 _representationType[idTissue]=representationType;
166 //-------------------------------------------------------------------
167 bool vtkClipping3DDataViewer::GetRepresentationType(int idTissue)
169 return _representationType[idTissue];
172 //-------------------------------------------------------------------
173 vtkActor* vtkClipping3DDataViewer::GetTissueActor(int id){
177 //-------------------------------------------------------------------
178 boxSurfaceObserver *vtkClipping3DDataViewer::GetObserverS(int idObserverS)
180 return _observerS[idObserverS];
182 //-------------------------------------------------------------------
183 boxSurfaceObserver *vtkClipping3DDataViewer::GetObserverV()
188 //-------------------------------------------------------------------
189 bool vtkClipping3DDataViewer::GetVisibleVolume()
191 return _visibleVolume;
193 //-------------------------------------------------------------------
194 void vtkClipping3DDataViewer::SetVisibleVolume(bool visiblevolume)
196 _visibleVolume = visiblevolume;
199 bool vtkClipping3DDataViewer::GetVisibleVolumeBox()
201 return _visibleVolumeBox;
203 //-------------------------------------------------------------------
204 void vtkClipping3DDataViewer::SetVisibleVolumeBox(bool visibleBox)
206 _visibleVolumeBox = visibleBox;
210 //-------------------------------------------------------------------
211 void vtkClipping3DDataViewer::SetImage()
214 vtkImageData *imagedata=_vtkmprbasedata->GetImageData();
215 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
217 //EED 2017-01-01 Migration VTK7
218 #if VTK_MAJOR_VERSION <= 5
219 _mCubes[i]->SetInput( imagedata );
221 _mCubes[i]->SetInputData( imagedata );
224 //EED 2017-01-01 Migration VTK7
225 #if VTK_MAJOR_VERSION <= 5
226 _volumeMapper->SetInput( imagedata );
228 _volumeMapper->SetInputData( imagedata );
230 _volumerendererdata->SetImageData( imagedata );
233 //-------------------------------------------------------------------
234 void vtkClipping3DDataViewer::Configure_Tissue()
238 vtkImageData *imagedata=_vtkmprbasedata->GetImageData();
239 imagedata->GetScalarRange( range );
240 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
242 // Visualisation - original volume
243 _mCubes[i] = vtkMarchingCubes::New( );
245 //EED 2017-01-01 Migration VTK7
246 #if VTK_MAJOR_VERSION <= 5
247 _mCubes[i]->SetInput( imagedata );
249 _mCubes[i]->SetInputData( imagedata );
252 _mCubes[i]->SetValue( 0, range[1]*(4+i) / 8 );
253 // _mCubes[i]->SetValue( 0, 1500 );
254 _tissueStripper[i] = vtkStripper::New();
256 //EED 2017-01-01 Migration VTK7
257 #if VTK_MAJOR_VERSION <= 5
258 _tissueStripper[i]->SetInput( _mCubes[i]->GetOutput( ) );
260 _tissueStripper[i]->SetInputData( _mCubes[i]->GetOutput( ) );
263 _tissuePlanes[i] = vtkPlanes::New();
264 int x1,x2,y1,y2,z1,z2;
265 imagedata->GetExtent(x1,x2,y1,y2,z1,z2);
266 _tissuePlanes[i]->SetBounds(x1,x2,y1,y2,z1,z2);
267 _tissueClipper[i] = vtkClipPolyData::New();
268 _tissueClipper[i]->SetClipFunction( _tissuePlanes[i] );
269 _tissueClipper[i]->InsideOutOn( );
271 //EED 2017-01-01 Migration VTK7
272 #if VTK_MAJOR_VERSION <= 5
273 _tissueClipper[i]->SetInput( _tissueStripper[i]->GetOutput() );
275 _tissueClipper[i]->SetInputData( _tissueStripper[i]->GetOutput() );
278 _tissueMapper[i] = vtkPolyDataMapper::New( );
280 //EED 2017-01-01 Migration VTK7
281 #if VTK_MAJOR_VERSION <= 5
282 _tissueMapper[i]->SetInput( _tissueClipper[i]->GetOutput() );
284 _mCubes[i]->Update();
285 _tissueStripper[i]->Update();
286 _tissueClipper[i]->Update();
287 _tissueMapper[i]->SetInputData( _tissueClipper[i]->GetOutput() );
288 _tissueMapper[i]->Update();
292 _tissueMapper[i]->ScalarVisibilityOff( );
293 // _tissueMapper[i]->Update();
297 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){
299 _tissue[i] = vtkActor::New();
300 _tissue[i]->SetMapper( GetTissueMapper(i) );
301 float cr=1,cg=0.5,cb=0.5;
302 _tissue[i]->GetProperty()->SetDiffuseColor(cr/255, cg/255 , cb/255 );
303 _tissue[i]->GetProperty()->SetSpecular(.3);
304 _tissue[i]->GetProperty()->SetSpecularPower(20);
305 _tissue[i]->GetProperty()->SetOpacity(0.5);
306 if (i==0) { _tissue[i]->GetProperty()->SetColor(0.85, 0.85 , 0.85 ); }
307 if (i==1) { _tissue[i]->GetProperty()->SetColor(0, 0 , 1 ); }
308 if (i==2) { _tissue[i]->GetProperty()->SetColor(0.85, 0.20 , 0.20 ); }
309 if (i==3) { _tissue[i]->GetProperty()->SetColor(0, 1 , 0 ); }
312 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
314 _observerS[i] = boxSurfaceObserver::New();
315 _observerS[i]->SetPlanes( GetTissuePlanes(i) );
316 _observerS[i]->SetActor( _tissue[i] );
317 _observerS[i]->SetFilters( _mCubes[i], _tissueStripper[i] ,_tissueClipper[i] );
321 //-----------------------------------------------------------------------------
323 void vtkClipping3DDataViewer::Configure_Volume()
327 /** if(_newvol != NULL)
330 _volumeMapper->Delete();
331 _volumeProperty->Delete();
334 _tfun = vtkPiecewiseFunction::New();
335 _ctfun = vtkColorTransferFunction::New();
338 this->_vtkmprbasedata->GetImageData()->GetScalarRange(range);
339 double max = range[1];
342 adding the poinst of the transference function
345 greyValuesTransferenceFVector.push_back(max * 0/2); // JPR ?? 0/2
346 greyValuesTransferenceFVector.push_back(max * 1/2); // JPR ?? division entiere?
347 greyValuesTransferenceFVector.push_back(max * 2/2);
349 intensityValuesTransferenceFVector.push_back(0.0);
350 intensityValuesTransferenceFVector.push_back(1.0);
351 intensityValuesTransferenceFVector.push_back(1.0);
353 _tfun->AddPoint(max * 0/2 , 0.0);
354 _tfun->AddPoint(max * 1/2 , 1.0);
355 _tfun->AddPoint(max * 2/2 , 1.0);
358 Adding the colors to the vectors
361 redColorsOfColorTransferenceFVector.push_back(0.0);
362 redColorsOfColorTransferenceFVector.push_back(1.0);
363 redColorsOfColorTransferenceFVector.push_back(0.0);
364 redColorsOfColorTransferenceFVector.push_back(0.0);
365 redColorsOfColorTransferenceFVector.push_back(0.0);
368 greenColorsOfColorTransferenceFVector.push_back(0.0);
369 greenColorsOfColorTransferenceFVector.push_back(0.0);
370 greenColorsOfColorTransferenceFVector.push_back(0.0);
371 greenColorsOfColorTransferenceFVector.push_back(1.0);
372 greenColorsOfColorTransferenceFVector.push_back(0.2);
375 blueColorsOfColorTransferenceFVector.push_back(0.0);
376 blueColorsOfColorTransferenceFVector.push_back(0.0);
377 blueColorsOfColorTransferenceFVector.push_back(1.0);
378 blueColorsOfColorTransferenceFVector.push_back(0.0);
379 blueColorsOfColorTransferenceFVector.push_back(0.0);
381 greyValueColorsOfColorTransferenceFVector.push_back(max*0/4);
382 greyValueColorsOfColorTransferenceFVector.push_back(max*1/4);
383 greyValueColorsOfColorTransferenceFVector.push_back(max*2/4);
384 greyValueColorsOfColorTransferenceFVector.push_back(max*3/4);
385 greyValueColorsOfColorTransferenceFVector.push_back(max*4/4);
387 _ctfun->AddRGBPoint( max*0/4 , 0.0, 0.0, 0.0);
388 _ctfun->AddRGBPoint( max*1/4 , 1.0, 0.0, 0.0);
389 _ctfun->AddRGBPoint( max*2/4 , 0.0, 0.0, 1.0);
390 _ctfun->AddRGBPoint( max*3/4 , 0.0, 1.0, 0.0);
391 _ctfun->AddRGBPoint( max*4/4 , 0.0, 0.2, 0.0);
393 _volumePlanes = vtkPlanes::New();
394 // int x1,x2,y1,y2,z1,z2;
395 // vtkImageData *imagedata=_vtkmprbasedata->GetImageData();
396 // imagedata->GetExtent(x1,x2,y1,y2,z1,z2);
397 // _volumePlanes->SetBounds(x1,x2,y1,y2,z1,z2);
401 // _volumeMapper = vtkVolumeRayCastMapper::New();
404 //EED 2017-01-01 Migration VTK7
405 #if VTK_MAJOR_VERSION <= 5
406 _volumeMapper->SetInput( this->GetVtkMPRBaseData()->GetImageData() );
408 _volumeMapper->SetInputData( this->GetVtkMPRBaseData()->GetImageData() );
412 #if (VTK_MAJOR_VERSION <= 7)
413 _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
414 // _volumeMapper->SetVolumeRayCastFunction(_compositeFunctionMIP);
420 _volumeMapper->SetClippingPlanes( _volumePlanes );
421 _volumeMapper->AutoAdjustSampleDistancesOn();
423 _volumeProperty->SetInterpolationTypeToNearest();
424 //_volumeProperty = vtkVolumeProperty::New();
425 _volumeProperty->SetColor(_ctfun);
426 _volumeProperty->SetScalarOpacity( _tfun );
429 _volumeProperty->DisableGradientOpacityOn();
432 // _volumeProperty->SetInterpolationTypeToNearest();
433 // _volumeProperty->ShadeOff();
434 // _volumeProperty->SetAmbient(0.3);
435 // _volumeProperty->SetDiffuse(0.1);
436 // _volumeProperty->SetSpecular(0.8);
437 // _volumeProperty->DisableGradientOpacityOn();
439 // _newvol = vtkVolume::New();
440 _newvol->SetMapper(_volumeMapper );
441 _newvol->SetProperty(_volumeProperty );
443 _observerV = boxSurfaceObserver::New();
444 _observerV->SetPlanes( _volumePlanes );
445 _observerV->SetActor( _newvol );
447 #if (VTK_MAJOR_VERSION <= 7)
448 _observerV->SetvtkVolumeRayCastMapper( _volumeMapper );
450 _observerV->SetvtkFixedPointVolumeRayCastMapper( _volumeMapper );
454 //-----------------------------------------------------------------------------
456 void vtkClipping3DDataViewer::Configure_VolumeBox()
458 _volumerendererdata->SetImageData(_vtkmprbasedata->GetImageData());
461 vector<double> *gv = this->GetGreyValuesTransferenceFVector();
462 vector<double> *op = this->GetIntensityValuesTransferenceFVector();
464 _volumerendererdata->SetLookUpTable((vtkLookupTable*)(_ctfun));
465 _volumerendererdata->OpacityChanged(*gv, *op);
467 //_wxvtkclipping3Dview->VisibleVolumeActor( false );
468 //_volumerendererdata->ShowVolume(event.IsChecked() );
469 //_volumerendererdata->BoundingBoxChanged(event.IsChecked() );
472 //-----------------------------------------------------------------------------
474 void vtkClipping3DDataViewer::SetRenderer(vtkRenderer* renderer)
476 _volumerendererdata->SetRenderer(renderer);
480 //-----------------------------------------------------------------------------
481 void vtkClipping3DDataViewer::SetInteractor(vtkRenderWindowInteractor* interactor)
484 _volumerendererdata->SetInteractor(interactor);
488 //-----------------------------------------------------------------------------
489 void vtkClipping3DDataViewer::BoxActorChanged(bool changed)
491 vector<double> *gv = this->GetGreyValuesTransferenceFVector();
492 vector<double> *op = this->GetIntensityValuesTransferenceFVector();
494 _volumerendererdata->ShowVolume(changed);
495 _volumerendererdata->OpacityChanged(*gv, *op);
496 _volumerendererdata->BoundingBoxChanged(changed);
500 //-----------------------------------------------------------------------------
501 void vtkClipping3DDataViewer::UpdateVolumeBox(vector<double> gf, vector<double> vf, vtkColorTransferFunction* ctfun)
503 _volumerendererdata->SetLookUpTable((vtkLookupTable*)(ctfun));
504 _volumerendererdata->OpacityChanged(gf, vf);
508 //-----------------------------------------------------------------------------
509 void vtkClipping3DDataViewer::updateVolume()
512 #if (VTK_MAJOR_VERSION <= 7)
515 _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
516 _volumerendererdata->changeCompositeMIPFunction(0);
518 _volumeMapper->SetVolumeRayCastFunction(_compositeFunctionMIP);
519 _volumerendererdata->changeCompositeMIPFunction(1);
522 // ... here Composition of MIP
523 printf("EED vtkClipping3DDataViewer::updateVolume ... here Composition or MIP \n");
529 _volumeProperty->SetInterpolationTypeToLinear();
533 _volumeProperty->SetInterpolationTypeToNearest();
538 _volumeProperty->ShadeOn();
542 _volumeProperty->ShadeOff();
547 //-------------------------------------------------------------------
548 void vtkClipping3DDataViewer::Configure()
552 Configure_VolumeBox();
556 //-------------------------------------------------------------------
557 void vtkClipping3DDataViewer::SetIsovalue(int idTissue, int isoValue)
559 _mCubes[idTissue]->SetValue(0, isoValue);
560 //EED 2017-01-01 Migration VTK7
561 #if VTK_MAJOR_VERSION <= 5
564 _mCubes[idTissue]->Update();
565 _tissueStripper[idTissue]->Update();
566 _tissueClipper[idTissue]->Update();
569 //-------------------------------------------------------------------
570 double vtkClipping3DDataViewer::GetIsovalue(int idTissue)
572 return _mCubes[idTissue]->GetValue(0);
574 //-------------------------------------------------------------------
575 vtkVolume* vtkClipping3DDataViewer::GetVolumeActor()
579 //-------------------------------------------------------------------
580 #if (VTK_MAJOR_VERSION <= 7)
581 vtkVolumeRayCastMapper* vtkClipping3DDataViewer::GetVolumeMapper()
583 vtkFixedPointVolumeRayCastMapper* vtkClipping3DDataViewer::GetVolumeMapper()
586 return _volumeMapper;
588 //-------------------------------------------------------------------
589 vtkPlanes* vtkClipping3DDataViewer::GetVolumePlanes()
591 return _volumePlanes;
594 //-------------------------------------------------------------------
595 vtkMarchingCubes *vtkClipping3DDataViewer::GetMCubes(int idTissue)
597 return _mCubes[idTissue];
599 //--------------------------------------------------------------------
600 //-------------------
602 //-------------------
604 std::vector<double>* vtkClipping3DDataViewer::GetGreyValuesTransferenceFVector()
606 return &greyValuesTransferenceFVector;
608 //--------------------------------------------------------------------
609 std::vector<double>* vtkClipping3DDataViewer::GetIntensityValuesTransferenceFVector()
611 return &intensityValuesTransferenceFVector;
613 //--------------------------------------------------------------------
614 std::vector<double>* vtkClipping3DDataViewer::GetRedColorsOfColorTransferenceFVector()
616 return &redColorsOfColorTransferenceFVector;
618 //--------------------------------------------------------------------
619 std::vector<double>* vtkClipping3DDataViewer::GetGreenColorsOfColorTransferenceFVector()
621 return &greenColorsOfColorTransferenceFVector;
623 //--------------------------------------------------------------------
624 std::vector<double>* vtkClipping3DDataViewer::GetBlueColorsOfColorTransferenceFVector()
626 return &blueColorsOfColorTransferenceFVector;
628 //--------------------------------------------------------------------
629 std::vector<double>* vtkClipping3DDataViewer::GetGreyValueColorsOfColorTransferenceFVector()
631 return &greyValueColorsOfColorTransferenceFVector;
633 //--------------------------------------------------------------------
634 //--------------------------------------
635 //Getters transference function
636 //and color of the transference function
637 //---------------------------------------
638 vtkPiecewiseFunction* vtkClipping3DDataViewer::GetTransferencefunction()
642 //--------------------------------------------------------------------
643 vtkColorTransferFunction* vtkClipping3DDataViewer::GetColorTransferenceFunction()
648 //-------------------------------------------------------------------
650 void vtkClipping3DDataViewer::ReadVolumeFunctions()
653 int i=0,xi,yi,r,g,b,gValue;
654 vtkImageData *imagedata = this->_vtkmprbasedata->GetImageData();
656 HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Histogram Dialog"),imagedata);
660 int tfSize=this->greyValuesTransferenceFVector.size();
664 hDlg->erasePointsTransferenceFunction();
667 double g=greyValuesTransferenceFVector[i];
668 double in=intensityValuesTransferenceFVector[i];
669 hDlg->addPointToTransferenceFunction(g,in*100);
675 int ctfSize=this->redColorsOfColorTransferenceFVector.size();
681 double gr=greyValueColorsOfColorTransferenceFVector[i];
682 double r=redColorsOfColorTransferenceFVector[i];
683 double g=greenColorsOfColorTransferenceFVector[i];
684 double b=blueColorsOfColorTransferenceFVector[i];
685 hDlg->addColorPoint(gr,r*255,g*255,b*255);
689 //If it is smooth activate next line
690 //hDlg->updatePlotter();
691 //setting variables if the user wants to do refresh
692 hDlg->setCTF(_ctfun);
696 // when the user had changed the transference Function
698 if(hDlg->ShowModal()== wxID_OK )
700 // -- vtkPiecewiseFunction --
701 this->_tfun->RemoveAllPoints();
702 greyValuesTransferenceFVector.clear();
703 intensityValuesTransferenceFVector.clear();
705 int nTFPoints=hDlg->getSizeTransferenceFunction();
709 hDlg->getTransferenceFunctionPoint(i,xi,yi);
710 this->_tfun->AddPoint( xi , yi/100.0 );
711 greyValuesTransferenceFVector.push_back(xi);
712 intensityValuesTransferenceFVector.push_back(yi/100.0);
715 // -- vtkColorTransferFunction --
716 this->_ctfun->RemoveAllPoints ();
718 redColorsOfColorTransferenceFVector.clear();
719 greenColorsOfColorTransferenceFVector.clear();
720 blueColorsOfColorTransferenceFVector.clear();
721 greyValueColorsOfColorTransferenceFVector.clear();
723 int nCTFpoints=hDlg->getSizeBarColor();
727 hDlg->getDataBarColorPoint(i,xi,r,g,b);
728 this->_ctfun->AddRGBPoint(xi,r/255.0,g/255.0,b/255.0 );
729 redColorsOfColorTransferenceFVector.push_back(r/255.0);
730 greenColorsOfColorTransferenceFVector.push_back(g/255.0);
731 blueColorsOfColorTransferenceFVector.push_back(b/255.0);
732 greyValueColorsOfColorTransferenceFVector.push_back(xi);
736 this->_volumeMapper->Update();
737 this->_newvol->Update();
743 if(hDlg->getRefreshed())
746 //--Transference Function----
747 this->_tfun->RemoveAllPoints();
749 size=greyValuesTransferenceFVector.size();
752 double grey1=greyValuesTransferenceFVector[i];
753 double in2=intensityValuesTransferenceFVector[i];
754 this->_tfun->AddPoint( grey1 , in2 );
757 // -- vtkColorTransferFunction --
758 _ctfun->RemoveAllPoints ();
761 size=greyValueColorsOfColorTransferenceFVector.size();
764 double grey2=(greyValueColorsOfColorTransferenceFVector)[i];
765 double red =(redColorsOfColorTransferenceFVector)[i];
766 double green =(greenColorsOfColorTransferenceFVector)[i];
767 double blue = (blueColorsOfColorTransferenceFVector)[i];
768 _ctfun->AddRGBPoint(grey2,red,green,blue);
770 this->_volumeMapper->Update();
771 this->_newvol->Update();
779 void vtkClipping3DDataViewer::ReadVolumeFunctions(char *namefile)
786 FILE *ff = fopen ( namefile ,"r");
790 if (strcmp(tmp,"MAX")==0)
792 vtkImageData *vtkimagedata = this->_vtkmprbasedata->GetImageData();
793 vtkimagedata->GetScalarRange(range);
794 max = (int) (range[1]);
799 fscanf(ff,"%s",tmp); // --
801 // -- vtkPiecewiseFunction --
802 this->_tfun->RemoveAllPoints();
804 while ( strcmp(tmp,"--")!=0 )
809 this->_tfun->AddPoint( x*max , val );
813 this->_ctfun->RemoveAllPoints ();
814 // -- vtkColorTransferFunction --
825 this->_ctfun->AddRGBPoint( x*max , r,g,b );
829 this->_volumeMapper->Update();
830 this->_newvol->Update();
837 //-------------------------------------------------------------------
839 void vtkClipping3DDataViewer::ReadMeshVTK(char *namefile)
841 vtkDataSetReader *reader = vtkDataSetReader::New();
842 reader->SetFileName(namefile);
845 //EED 2017-01-01 Migration VTK7
846 #if VTK_MAJOR_VERSION <= 5
847 _tissueStripper[3]->SetInput( reader->GetPolyDataOutput() );
849 _tissueStripper[3]->SetInputData( reader->GetPolyDataOutput() );
854 void vtkClipping3DDataViewer::setColorTransferFunction(vtkColorTransferFunction* colortable){
856 _volumeProperty->SetColor(colortable);
861 void vtkClipping3DDataViewer::SetRayCasting(bool active)
863 _isRayCasting = active;
867 void vtkClipping3DDataViewer::SetMIPActive(bool active)
872 void vtkClipping3DDataViewer::SetInterpolation(bool active)
874 _interpolation = active;
877 void vtkClipping3DDataViewer::SetShade(bool active)