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++){
35 _visibleTissue[i] = false;
36 _representationType[i] = true;
38 _visibleVolume = false;
41 _interpolation = false;
44 _volumerendererdata = VolumeRendererData::New();
46 #if (VTK_MAJOR_VERSION <= 7)
47 _volumeMapper = vtkVolumeRayCastMapper::New();
48 _compositeFunction = vtkVolumeRayCastCompositeFunction::New();
49 _compositeFunctionMIP = vtkVolumeRayCastMIPFunction::New();
51 _volumeMapper = vtkFixedPointVolumeRayCastMapper::New();
54 _newvol = vtkVolume::New();
55 _volumeProperty = vtkVolumeProperty::New();
58 //-------------------------------------------------------------------
59 vtkClipping3DDataViewer::~vtkClipping3DDataViewer()
62 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){
64 _tissueStripper[i]->Delete();
65 _tissueMapper[i]->Delete();
66 _tissuePlanes[i]->Delete();
67 _tissueClipper[i]->Delete();
73 #if (VTK_MAJOR_VERSION <= 7)
74 _compositeFunction->Delete();
78 _volumeMapper->Delete();
79 _volumeProperty->Delete();
81 _volumePlanes->Delete();
83 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){
84 _tissue[i]-> Delete();
85 _observerS[i]-> Delete();
87 _observerV-> Delete();
90 //-------------------------------------------------------------------
91 vtkClipPolyData* vtkClipping3DDataViewer::GetTissueClipper(int id)
93 return this->_tissueClipper[id];
95 //-------------------------------------------------------------------
96 vtkPolyDataMapper* vtkClipping3DDataViewer::GetTissueMapper(int id)
98 return _tissueMapper[id];
100 //-------------------------------------------------------------------
101 vtkPlanes* vtkClipping3DDataViewer::GetTissuePlanes(int id)
103 return _tissuePlanes[id];
105 //-------------------------------------------------------------------
106 vtkStripper* vtkClipping3DDataViewer::GetTissueStripper(int id)
108 return _tissueStripper[id];
110 //-------------------------------------------------------------------
111 void vtkClipping3DDataViewer::Refresh()
113 // _volumeMapper->SetClippingPlanes(_volumePlanes);
115 // this->_volumeMapper->Update();
116 // this->_newvol->Update();
118 // _newvol->VisibilityOn();
121 // _volumeMapper = vtkVolumeRayCastMapper::New();
122 // _volumeMapper->SetInput( this->GetVtkMPRBaseData()->GetImageData() );
123 // _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
124 // _volumeMapper->SetClippingPlanes( _volumePlanes );
125 // _newvol->SetMapper(_volumeMapper );
129 //-------------------------------------------------------------------
130 void vtkClipping3DDataViewer::RefreshSurface()
133 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
135 SetIsovalue(i, (int) (GetIsovalue(i)+1) );
136 // this->GetMCubes(i)->Update();
139 //-------------------------------------------------------------------
140 void vtkClipping3DDataViewer::SetVtkMPRBaseData(vtkMPRBaseData *vtkmprbasedata)
142 _vtkmprbasedata=vtkmprbasedata;
144 //-------------------------------------------------------------------
145 vtkMPRBaseData* vtkClipping3DDataViewer::GetVtkMPRBaseData()
147 return _vtkmprbasedata;
151 //-------------------------------------------------------------------
152 void vtkClipping3DDataViewer::SetVisibleTissue(int idTissue, bool visible)
154 _visibleTissue[idTissue]=visible;
156 //-------------------------------------------------------------------
157 bool vtkClipping3DDataViewer::GetVisibleTissue(int idTissue){
158 return _visibleTissue[idTissue];
160 //-------------------------------------------------------------------
161 void vtkClipping3DDataViewer::SetRepresentationType(int idTissue, bool representationType)
163 _representationType[idTissue]=representationType;
165 //-------------------------------------------------------------------
166 bool vtkClipping3DDataViewer::GetRepresentationType(int idTissue)
168 return _representationType[idTissue];
171 //-------------------------------------------------------------------
172 vtkActor* vtkClipping3DDataViewer::GetTissueActor(int id){
176 //-------------------------------------------------------------------
177 boxSurfaceObserver *vtkClipping3DDataViewer::GetObserverS(int idObserverS)
179 return _observerS[idObserverS];
181 //-------------------------------------------------------------------
182 boxSurfaceObserver *vtkClipping3DDataViewer::GetObserverV()
187 //-------------------------------------------------------------------
188 bool vtkClipping3DDataViewer::GetVisibleVolume()
190 return _visibleVolume;
192 //-------------------------------------------------------------------
193 void vtkClipping3DDataViewer::SetVisibleVolume(bool visiblevolume)
195 _visibleVolume = visiblevolume;
198 bool vtkClipping3DDataViewer::GetVisibleVolumeBox()
200 return _visibleVolumeBox;
202 //-------------------------------------------------------------------
203 void vtkClipping3DDataViewer::SetVisibleVolumeBox(bool visibleBox)
205 _visibleVolumeBox = visibleBox;
209 //-------------------------------------------------------------------
210 void vtkClipping3DDataViewer::SetImage()
213 vtkImageData *imagedata=_vtkmprbasedata->GetImageData();
214 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
216 //EED 2017-01-01 Migration VTK7
217 #if VTK_MAJOR_VERSION <= 5
218 _mCubes[i]->SetInput( imagedata );
220 _mCubes[i]->SetInputData( imagedata );
223 //EED 2017-01-01 Migration VTK7
224 #if VTK_MAJOR_VERSION <= 5
225 _volumeMapper->SetInput( imagedata );
227 _volumeMapper->SetInputData( imagedata );
229 _volumerendererdata->SetImageData( imagedata );
232 //-------------------------------------------------------------------
233 void vtkClipping3DDataViewer::Configure_Tissue()
237 vtkImageData *imagedata=_vtkmprbasedata->GetImageData();
238 imagedata->GetScalarRange( range );
239 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
241 // Visualisation - original volume
242 _mCubes[i] = vtkMarchingCubes::New( );
244 //EED 2017-01-01 Migration VTK7
245 #if VTK_MAJOR_VERSION <= 5
246 _mCubes[i]->SetInput( imagedata );
248 _mCubes[i]->SetInputData( imagedata );
251 _mCubes[i]->SetValue( 0, range[1]*(4+i) / 8 );
252 // _mCubes[i]->SetValue( 0, 1500 );
253 _tissueStripper[i] = vtkStripper::New();
255 //EED 2017-01-01 Migration VTK7
256 #if VTK_MAJOR_VERSION <= 5
257 _tissueStripper[i]->SetInput( _mCubes[i]->GetOutput( ) );
259 _tissueStripper[i]->SetInputData( _mCubes[i]->GetOutput( ) );
262 _tissuePlanes[i] = vtkPlanes::New();
263 int x1,x2,y1,y2,z1,z2;
264 imagedata->GetExtent(x1,x2,y1,y2,z1,z2);
265 _tissuePlanes[i]->SetBounds(x1,x2,y1,y2,z1,z2);
266 _tissueClipper[i] = vtkClipPolyData::New();
267 _tissueClipper[i]->SetClipFunction( _tissuePlanes[i] );
268 _tissueClipper[i]->InsideOutOn( );
270 //EED 2017-01-01 Migration VTK7
271 #if VTK_MAJOR_VERSION <= 5
272 _tissueClipper[i]->SetInput( _tissueStripper[i]->GetOutput() );
274 _tissueClipper[i]->SetInputData( _tissueStripper[i]->GetOutput() );
277 _tissueMapper[i] = vtkPolyDataMapper::New( );
279 //EED 2017-01-01 Migration VTK7
280 #if VTK_MAJOR_VERSION <= 5
281 _tissueMapper[i]->SetInput( _tissueClipper[i]->GetOutput() );
283 _mCubes[i]->Update();
284 _tissueStripper[i]->Update();
285 _tissueClipper[i]->Update();
286 _tissueMapper[i]->SetInputData( _tissueClipper[i]->GetOutput() );
287 _tissueMapper[i]->Update();
291 _tissueMapper[i]->ScalarVisibilityOff( );
292 // _tissueMapper[i]->Update();
296 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){
298 _tissue[i] = vtkActor::New();
299 _tissue[i]->SetMapper( GetTissueMapper(i) );
300 float cr=1,cg=0.5,cb=0.5;
301 _tissue[i]->GetProperty()->SetDiffuseColor(cr/255, cg/255 , cb/255 );
302 _tissue[i]->GetProperty()->SetSpecular(.3);
303 _tissue[i]->GetProperty()->SetSpecularPower(20);
304 _tissue[i]->GetProperty()->SetOpacity(0.5);
305 if (i==0) { _tissue[i]->GetProperty()->SetColor(0.85, 0.85 , 0.85 ); }
306 if (i==1) { _tissue[i]->GetProperty()->SetColor(0, 0 , 1 ); }
307 if (i==2) { _tissue[i]->GetProperty()->SetColor(0.85, 0.20 , 0.20 ); }
308 if (i==3) { _tissue[i]->GetProperty()->SetColor(0, 1 , 0 ); }
311 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
313 _observerS[i] = boxSurfaceObserver::New();
314 _observerS[i]->SetPlanes( GetTissuePlanes(i) );
315 _observerS[i]->SetActor( _tissue[i] );
316 _observerS[i]->SetFilters( _mCubes[i], _tissueStripper[i] ,_tissueClipper[i] );
320 //-----------------------------------------------------------------------------
322 void vtkClipping3DDataViewer::Configure_Volume()
326 /** if(_newvol != NULL)
329 _volumeMapper->Delete();
330 _volumeProperty->Delete();
333 _tfun = vtkPiecewiseFunction::New();
334 _ctfun = vtkColorTransferFunction::New();
337 this->_vtkmprbasedata->GetImageData()->GetScalarRange(range);
338 double max = range[1];
341 adding the poinst of the transference function
344 greyValuesTransferenceFVector.push_back(max * 0/2); // JPR ?? 0/2
345 greyValuesTransferenceFVector.push_back(max * 1/2); // JPR ?? division entiere?
346 greyValuesTransferenceFVector.push_back(max * 2/2);
348 intensityValuesTransferenceFVector.push_back(0.0);
349 intensityValuesTransferenceFVector.push_back(1.0);
350 intensityValuesTransferenceFVector.push_back(1.0);
352 _tfun->AddPoint(max * 0/2 , 0.0);
353 _tfun->AddPoint(max * 1/2 , 1.0);
354 _tfun->AddPoint(max * 2/2 , 1.0);
357 Adding the colors to the vectors
360 redColorsOfColorTransferenceFVector.push_back(0.0);
361 redColorsOfColorTransferenceFVector.push_back(1.0);
362 redColorsOfColorTransferenceFVector.push_back(0.0);
363 redColorsOfColorTransferenceFVector.push_back(0.0);
364 redColorsOfColorTransferenceFVector.push_back(0.0);
367 greenColorsOfColorTransferenceFVector.push_back(0.0);
368 greenColorsOfColorTransferenceFVector.push_back(0.0);
369 greenColorsOfColorTransferenceFVector.push_back(0.0);
370 greenColorsOfColorTransferenceFVector.push_back(1.0);
371 greenColorsOfColorTransferenceFVector.push_back(0.2);
374 blueColorsOfColorTransferenceFVector.push_back(0.0);
375 blueColorsOfColorTransferenceFVector.push_back(0.0);
376 blueColorsOfColorTransferenceFVector.push_back(1.0);
377 blueColorsOfColorTransferenceFVector.push_back(0.0);
378 blueColorsOfColorTransferenceFVector.push_back(0.0);
380 greyValueColorsOfColorTransferenceFVector.push_back(max*0/4);
381 greyValueColorsOfColorTransferenceFVector.push_back(max*1/4);
382 greyValueColorsOfColorTransferenceFVector.push_back(max*2/4);
383 greyValueColorsOfColorTransferenceFVector.push_back(max*3/4);
384 greyValueColorsOfColorTransferenceFVector.push_back(max*4/4);
386 _ctfun->AddRGBPoint( max*0/4 , 0.0, 0.0, 0.0);
387 _ctfun->AddRGBPoint( max*1/4 , 1.0, 0.0, 0.0);
388 _ctfun->AddRGBPoint( max*2/4 , 0.0, 0.0, 1.0);
389 _ctfun->AddRGBPoint( max*3/4 , 0.0, 1.0, 0.0);
390 _ctfun->AddRGBPoint( max*4/4 , 0.0, 0.2, 0.0);
392 _volumePlanes = vtkPlanes::New();
393 // int x1,x2,y1,y2,z1,z2;
394 // vtkImageData *imagedata=_vtkmprbasedata->GetImageData();
395 // imagedata->GetExtent(x1,x2,y1,y2,z1,z2);
396 // _volumePlanes->SetBounds(x1,x2,y1,y2,z1,z2);
400 // _volumeMapper = vtkVolumeRayCastMapper::New();
403 //EED 2017-01-01 Migration VTK7
404 #if VTK_MAJOR_VERSION <= 5
405 _volumeMapper->SetInput( this->GetVtkMPRBaseData()->GetImageData() );
407 _volumeMapper->SetInputData( this->GetVtkMPRBaseData()->GetImageData() );
411 #if (VTK_MAJOR_VERSION <= 7)
412 _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
413 // _volumeMapper->SetVolumeRayCastFunction(_compositeFunctionMIP);
419 _volumeMapper->SetClippingPlanes( _volumePlanes );
420 _volumeMapper->AutoAdjustSampleDistancesOn();
422 _volumeProperty->SetInterpolationTypeToNearest();
423 //_volumeProperty = vtkVolumeProperty::New();
424 _volumeProperty->SetColor(_ctfun);
425 _volumeProperty->SetScalarOpacity( _tfun );
428 _volumeProperty->DisableGradientOpacityOn();
431 // _volumeProperty->SetInterpolationTypeToNearest();
432 // _volumeProperty->ShadeOff();
433 // _volumeProperty->SetAmbient(0.3);
434 // _volumeProperty->SetDiffuse(0.1);
435 // _volumeProperty->SetSpecular(0.8);
436 // _volumeProperty->DisableGradientOpacityOn();
438 // _newvol = vtkVolume::New();
439 _newvol->SetMapper(_volumeMapper );
440 _newvol->SetProperty(_volumeProperty );
442 _observerV = boxSurfaceObserver::New();
443 _observerV->SetPlanes( _volumePlanes );
444 _observerV->SetActor( _newvol );
446 #if (VTK_MAJOR_VERSION <= 7)
447 _observerV->SetvtkVolumeRayCastMapper( _volumeMapper );
449 _observerV->SetvtkFixedPointVolumeRayCastMapper( _volumeMapper );
453 //-----------------------------------------------------------------------------
455 void vtkClipping3DDataViewer::Configure_VolumeBox()
457 _volumerendererdata->SetImageData(_vtkmprbasedata->GetImageData());
460 vector<double> *gv = this->GetGreyValuesTransferenceFVector();
461 vector<double> *op = this->GetIntensityValuesTransferenceFVector();
463 _volumerendererdata->SetLookUpTable((vtkLookupTable*)(_ctfun));
464 _volumerendererdata->OpacityChanged(*gv, *op);
466 //_wxvtkclipping3Dview->VisibleVolumeActor( false );
467 //_volumerendererdata->ShowVolume(event.IsChecked() );
468 //_volumerendererdata->BoundingBoxChanged(event.IsChecked() );
471 //-----------------------------------------------------------------------------
473 void vtkClipping3DDataViewer::SetRenderer(vtkRenderer* renderer)
475 _volumerendererdata->SetRenderer(renderer);
479 //-----------------------------------------------------------------------------
480 void vtkClipping3DDataViewer::SetInteractor(vtkRenderWindowInteractor* interactor)
483 _volumerendererdata->SetInteractor(interactor);
487 //-----------------------------------------------------------------------------
488 void vtkClipping3DDataViewer::BoxActorChanged(bool changed)
490 vector<double> *gv = this->GetGreyValuesTransferenceFVector();
491 vector<double> *op = this->GetIntensityValuesTransferenceFVector();
493 _volumerendererdata->ShowVolume(changed);
494 _volumerendererdata->OpacityChanged(*gv, *op);
495 _volumerendererdata->BoundingBoxChanged(changed);
499 //-----------------------------------------------------------------------------
500 void vtkClipping3DDataViewer::UpdateVolumeBox(vector<double> gf, vector<double> vf, vtkColorTransferFunction* ctfun)
502 _volumerendererdata->SetLookUpTable((vtkLookupTable*)(ctfun));
503 _volumerendererdata->OpacityChanged(gf, vf);
507 //-----------------------------------------------------------------------------
508 void vtkClipping3DDataViewer::updateVolume()
511 #if (VTK_MAJOR_VERSION <= 7)
514 _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
515 _volumerendererdata->changeCompositeMIPFunction(0);
517 _volumeMapper->SetVolumeRayCastFunction(_compositeFunctionMIP);
518 _volumerendererdata->changeCompositeMIPFunction(1);
521 // ... here Composition of MIP
522 printf("EED vtkClipping3DDataViewer::updateVolume ... here Composition or MIP \n");
528 _volumeProperty->SetInterpolationTypeToLinear();
532 _volumeProperty->SetInterpolationTypeToNearest();
537 _volumeProperty->ShadeOn();
541 _volumeProperty->ShadeOff();
546 //-------------------------------------------------------------------
547 void vtkClipping3DDataViewer::Configure()
551 Configure_VolumeBox();
555 //-------------------------------------------------------------------
556 void vtkClipping3DDataViewer::SetIsovalue(int idTissue, int isoValue)
558 _mCubes[idTissue]->SetValue(0, isoValue);
559 //EED 2017-01-01 Migration VTK7
560 #if VTK_MAJOR_VERSION <= 5
563 _mCubes[idTissue]->Update();
564 _tissueStripper[idTissue]->Update();
565 _tissueClipper[idTissue]->Update();
568 //-------------------------------------------------------------------
569 double vtkClipping3DDataViewer::GetIsovalue(int idTissue)
571 return _mCubes[idTissue]->GetValue(0);
573 //-------------------------------------------------------------------
574 vtkVolume* vtkClipping3DDataViewer::GetVolumeActor()
578 //-------------------------------------------------------------------
579 #if (VTK_MAJOR_VERSION <= 7)
580 vtkVolumeRayCastMapper* vtkClipping3DDataViewer::GetVolumeMapper()
582 vtkFixedPointVolumeRayCastMapper* vtkClipping3DDataViewer::GetVolumeMapper()
585 return _volumeMapper;
587 //-------------------------------------------------------------------
588 vtkPlanes* vtkClipping3DDataViewer::GetVolumePlanes()
590 return _volumePlanes;
593 //-------------------------------------------------------------------
594 vtkMarchingCubes *vtkClipping3DDataViewer::GetMCubes(int idTissue)
596 return _mCubes[idTissue];
598 //--------------------------------------------------------------------
599 //-------------------
601 //-------------------
603 std::vector<double>* vtkClipping3DDataViewer::GetGreyValuesTransferenceFVector()
605 return &greyValuesTransferenceFVector;
607 //--------------------------------------------------------------------
608 std::vector<double>* vtkClipping3DDataViewer::GetIntensityValuesTransferenceFVector()
610 return &intensityValuesTransferenceFVector;
612 //--------------------------------------------------------------------
613 std::vector<double>* vtkClipping3DDataViewer::GetRedColorsOfColorTransferenceFVector()
615 return &redColorsOfColorTransferenceFVector;
617 //--------------------------------------------------------------------
618 std::vector<double>* vtkClipping3DDataViewer::GetGreenColorsOfColorTransferenceFVector()
620 return &greenColorsOfColorTransferenceFVector;
622 //--------------------------------------------------------------------
623 std::vector<double>* vtkClipping3DDataViewer::GetBlueColorsOfColorTransferenceFVector()
625 return &blueColorsOfColorTransferenceFVector;
627 //--------------------------------------------------------------------
628 std::vector<double>* vtkClipping3DDataViewer::GetGreyValueColorsOfColorTransferenceFVector()
630 return &greyValueColorsOfColorTransferenceFVector;
632 //--------------------------------------------------------------------
633 //--------------------------------------
634 //Getters transference function
635 //and color of the transference function
636 //---------------------------------------
637 vtkPiecewiseFunction* vtkClipping3DDataViewer::GetTransferencefunction()
641 //--------------------------------------------------------------------
642 vtkColorTransferFunction* vtkClipping3DDataViewer::GetColorTransferenceFunction()
647 //-------------------------------------------------------------------
649 void vtkClipping3DDataViewer::ReadVolumeFunctions()
652 int i=0,xi,yi,r,g,b,gValue;
653 vtkImageData *imagedata = this->_vtkmprbasedata->GetImageData();
655 HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Histogram Dialog"),imagedata);
659 int tfSize=this->greyValuesTransferenceFVector.size();
663 hDlg->erasePointsTransferenceFunction();
666 double g=greyValuesTransferenceFVector[i];
667 double in=intensityValuesTransferenceFVector[i];
668 hDlg->addPointToTransferenceFunction(g,in*100);
674 int ctfSize=this->redColorsOfColorTransferenceFVector.size();
680 double gr=greyValueColorsOfColorTransferenceFVector[i];
681 double r=redColorsOfColorTransferenceFVector[i];
682 double g=greenColorsOfColorTransferenceFVector[i];
683 double b=blueColorsOfColorTransferenceFVector[i];
684 hDlg->addColorPoint(gr,r*255,g*255,b*255);
688 //If it is smooth activate next line
689 //hDlg->updatePlotter();
690 //setting variables if the user wants to do refresh
691 hDlg->setCTF(_ctfun);
695 // when the user had changed the transference Function
697 if(hDlg->ShowModal()== wxID_OK )
699 // -- vtkPiecewiseFunction --
700 this->_tfun->RemoveAllPoints();
701 greyValuesTransferenceFVector.clear();
702 intensityValuesTransferenceFVector.clear();
704 int nTFPoints=hDlg->getSizeTransferenceFunction();
708 hDlg->getTransferenceFunctionPoint(i,xi,yi);
709 this->_tfun->AddPoint( xi , yi/100.0 );
710 greyValuesTransferenceFVector.push_back(xi);
711 intensityValuesTransferenceFVector.push_back(yi/100.0);
714 // -- vtkColorTransferFunction --
715 this->_ctfun->RemoveAllPoints ();
717 redColorsOfColorTransferenceFVector.clear();
718 greenColorsOfColorTransferenceFVector.clear();
719 blueColorsOfColorTransferenceFVector.clear();
720 greyValueColorsOfColorTransferenceFVector.clear();
722 int nCTFpoints=hDlg->getSizeBarColor();
726 hDlg->getDataBarColorPoint(i,xi,r,g,b);
727 this->_ctfun->AddRGBPoint(xi,r/255.0,g/255.0,b/255.0 );
728 redColorsOfColorTransferenceFVector.push_back(r/255.0);
729 greenColorsOfColorTransferenceFVector.push_back(g/255.0);
730 blueColorsOfColorTransferenceFVector.push_back(b/255.0);
731 greyValueColorsOfColorTransferenceFVector.push_back(xi);
735 this->_volumeMapper->Update();
736 this->_newvol->Update();
742 if(hDlg->getRefreshed())
745 //--Transference Function----
746 this->_tfun->RemoveAllPoints();
748 size=greyValuesTransferenceFVector.size();
751 double grey1=greyValuesTransferenceFVector[i];
752 double in2=intensityValuesTransferenceFVector[i];
753 this->_tfun->AddPoint( grey1 , in2 );
756 // -- vtkColorTransferFunction --
757 _ctfun->RemoveAllPoints ();
760 size=greyValueColorsOfColorTransferenceFVector.size();
763 double grey2=(greyValueColorsOfColorTransferenceFVector)[i];
764 double red =(redColorsOfColorTransferenceFVector)[i];
765 double green =(greenColorsOfColorTransferenceFVector)[i];
766 double blue = (blueColorsOfColorTransferenceFVector)[i];
767 _ctfun->AddRGBPoint(grey2,red,green,blue);
769 this->_volumeMapper->Update();
770 this->_newvol->Update();
778 void vtkClipping3DDataViewer::ReadVolumeFunctions(char *namefile)
785 FILE *ff = fopen ( namefile ,"r");
789 if (strcmp(tmp,"MAX")==0)
791 vtkImageData *vtkimagedata = this->_vtkmprbasedata->GetImageData();
792 vtkimagedata->GetScalarRange(range);
793 max = (int) (range[1]);
798 fscanf(ff,"%s",tmp); // --
800 // -- vtkPiecewiseFunction --
801 this->_tfun->RemoveAllPoints();
803 while ( strcmp(tmp,"--")!=0 )
808 this->_tfun->AddPoint( x*max , val );
812 this->_ctfun->RemoveAllPoints ();
813 // -- vtkColorTransferFunction --
824 this->_ctfun->AddRGBPoint( x*max , r,g,b );
828 this->_volumeMapper->Update();
829 this->_newvol->Update();
836 //-------------------------------------------------------------------
838 void vtkClipping3DDataViewer::ReadMeshVTK(char *namefile)
840 vtkDataSetReader *reader = vtkDataSetReader::New();
841 reader->SetFileName(namefile);
844 //EED 2017-01-01 Migration VTK7
845 #if VTK_MAJOR_VERSION <= 5
846 _tissueStripper[3]->SetInput( reader->GetPolyDataOutput() );
848 _tissueStripper[3]->SetInputData( reader->GetPolyDataOutput() );
853 void vtkClipping3DDataViewer::setColorTransferFunction(vtkColorTransferFunction* colortable){
855 _volumeProperty->SetColor(colortable);
860 void vtkClipping3DDataViewer::SetRayCasting(bool active)
862 _isRayCasting = active;
866 void vtkClipping3DDataViewer::SetMIPActive(bool active)
871 void vtkClipping3DDataViewer::SetInterpolation(bool active)
873 _interpolation = active;
876 void vtkClipping3DDataViewer::SetShade(bool active)