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++)
66 _tissueStripper[i]->Delete();
67 _tissueMapper[i]->Delete();
68 _tissuePlanes[i]->Delete();
69 _tissueClipper[i]->Delete();
75 #if (VTK_MAJOR_VERSION <= 7)
76 _compositeFunction->Delete();
80 _volumeMapper->Delete();
81 _volumeProperty->Delete();
83 _volumePlanes->Delete();
85 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){
86 _tissue[i]-> Delete();
87 _observerS[i]-> Delete();
89 _observerV-> Delete();
92 //-------------------------------------------------------------------
93 vtkClipPolyData* vtkClipping3DDataViewer::GetTissueClipper(int id)
95 return this->_tissueClipper[id];
97 //-------------------------------------------------------------------
98 vtkPolyDataMapper* vtkClipping3DDataViewer::GetTissueMapper(int id)
100 return _tissueMapper[id];
102 //-------------------------------------------------------------------
103 vtkPlanes* vtkClipping3DDataViewer::GetTissuePlanes(int id)
105 return _tissuePlanes[id];
107 //-------------------------------------------------------------------
108 vtkStripper* vtkClipping3DDataViewer::GetTissueStripper(int id)
110 return _tissueStripper[id];
112 //-------------------------------------------------------------------
113 void vtkClipping3DDataViewer::Refresh()
115 // _volumeMapper->SetClippingPlanes(_volumePlanes);
117 // this->_volumeMapper->Update();
118 // this->_newvol->Update();
120 // _newvol->VisibilityOn();
123 // _volumeMapper = vtkVolumeRayCastMapper::New();
124 // _volumeMapper->SetInput( this->GetVtkMPRBaseData()->GetImageData() );
125 // _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
126 // _volumeMapper->SetClippingPlanes( _volumePlanes );
127 // _newvol->SetMapper(_volumeMapper );
131 //-------------------------------------------------------------------
132 void vtkClipping3DDataViewer::RefreshSurface()
135 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
137 SetIsovalue(i, (int) (GetIsovalue(i)+1) );
138 // this->GetMCubes(i)->Update();
141 //-------------------------------------------------------------------
142 void vtkClipping3DDataViewer::SetVtkMPRBaseData(vtkMPRBaseData *vtkmprbasedata)
144 _vtkmprbasedata=vtkmprbasedata;
146 //-------------------------------------------------------------------
147 vtkMPRBaseData* vtkClipping3DDataViewer::GetVtkMPRBaseData()
149 return _vtkmprbasedata;
153 //-------------------------------------------------------------------
154 void vtkClipping3DDataViewer::SetVisibleTissue(int idTissue, bool visible)
156 _visibleTissue[idTissue]=visible;
158 //-------------------------------------------------------------------
159 bool vtkClipping3DDataViewer::GetVisibleTissue(int idTissue){
160 return _visibleTissue[idTissue];
162 //-------------------------------------------------------------------
163 void vtkClipping3DDataViewer::SetRepresentationType(int idTissue, bool representationType)
165 _representationType[idTissue]=representationType;
167 //-------------------------------------------------------------------
168 bool vtkClipping3DDataViewer::GetRepresentationType(int idTissue)
170 return _representationType[idTissue];
173 //-------------------------------------------------------------------
174 vtkActor* vtkClipping3DDataViewer::GetTissueActor(int id){
178 //-------------------------------------------------------------------
179 boxSurfaceObserver *vtkClipping3DDataViewer::GetObserverS(int idObserverS)
181 return _observerS[idObserverS];
183 //-------------------------------------------------------------------
184 boxSurfaceObserver *vtkClipping3DDataViewer::GetObserverV()
189 //-------------------------------------------------------------------
190 bool vtkClipping3DDataViewer::GetVisibleVolume()
192 return _visibleVolume;
194 //-------------------------------------------------------------------
195 void vtkClipping3DDataViewer::SetVisibleVolume(bool visiblevolume)
197 _visibleVolume = visiblevolume;
200 bool vtkClipping3DDataViewer::GetVisibleVolumeBox()
202 return _visibleVolumeBox;
204 //-------------------------------------------------------------------
205 void vtkClipping3DDataViewer::SetVisibleVolumeBox(bool visibleBox)
207 _visibleVolumeBox = visibleBox;
211 //-------------------------------------------------------------------
212 void vtkClipping3DDataViewer::SetImage()
215 vtkImageData *imagedata=_vtkmprbasedata->GetImageData();
216 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
218 //EED 2017-01-01 Migration VTK7
219 #if VTK_MAJOR_VERSION <= 5
220 _mCubes[i]->SetInput( imagedata );
222 _mCubes[i]->SetInputData( imagedata );
225 //EED 2017-01-01 Migration VTK7
226 #if VTK_MAJOR_VERSION <= 5
227 _volumeMapper->SetInput( imagedata );
229 _volumeMapper->SetInputData( imagedata );
231 _volumerendererdata->SetImageData( imagedata );
234 //-------------------------------------------------------------------
235 void vtkClipping3DDataViewer::Configure_Tissue()
239 vtkImageData *imagedata=_vtkmprbasedata->GetImageData();
240 imagedata->GetScalarRange( range );
241 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
243 // Visualisation - original volume
244 _mCubes[i] = vtkMarchingCubes::New( );
246 //EED 2017-01-01 Migration VTK7
247 #if VTK_MAJOR_VERSION <= 5
248 _mCubes[i]->SetInput( imagedata );
250 _mCubes[i]->SetInputData( imagedata );
253 _mCubes[i]->SetValue( 0, range[1]*(4+i) / 8 );
254 // _mCubes[i]->SetValue( 0, 1500 );
255 _tissueStripper[i] = vtkStripper::New();
257 //EED 2017-01-01 Migration VTK7
258 #if VTK_MAJOR_VERSION <= 5
259 _tissueStripper[i]->SetInput( _mCubes[i]->GetOutput( ) );
261 _tissueStripper[i]->SetInputData( _mCubes[i]->GetOutput( ) );
264 _tissuePlanes[i] = vtkPlanes::New();
265 int x1,x2,y1,y2,z1,z2;
266 imagedata->GetExtent(x1,x2,y1,y2,z1,z2);
267 _tissuePlanes[i]->SetBounds(x1,x2,y1,y2,z1,z2);
268 _tissueClipper[i] = vtkClipPolyData::New();
269 _tissueClipper[i]->SetClipFunction( _tissuePlanes[i] );
270 _tissueClipper[i]->InsideOutOn( );
272 //EED 2017-01-01 Migration VTK7
273 #if VTK_MAJOR_VERSION <= 5
274 _tissueClipper[i]->SetInput( _tissueStripper[i]->GetOutput() );
276 _tissueClipper[i]->SetInputData( _tissueStripper[i]->GetOutput() );
279 _tissueMapper[i] = vtkPolyDataMapper::New( );
281 //EED 2017-01-01 Migration VTK7
282 #if VTK_MAJOR_VERSION <= 5
283 _tissueMapper[i]->SetInput( _tissueClipper[i]->GetOutput() );
285 _mCubes[i]->Update();
286 _tissueStripper[i]->Update();
287 _tissueClipper[i]->Update();
288 _tissueMapper[i]->SetInputData( _tissueClipper[i]->GetOutput() );
289 _tissueMapper[i]->Update();
293 _tissueMapper[i]->ScalarVisibilityOff( );
294 // _tissueMapper[i]->Update();
298 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){
300 _tissue[i] = vtkActor::New();
301 _tissue[i]->SetMapper( GetTissueMapper(i) );
302 float cr=1,cg=0.5,cb=0.5;
303 _tissue[i]->GetProperty()->SetDiffuseColor(cr/255, cg/255 , cb/255 );
304 _tissue[i]->GetProperty()->SetSpecular(.3);
305 _tissue[i]->GetProperty()->SetSpecularPower(20);
306 _tissue[i]->GetProperty()->SetOpacity(0.5);
307 if (i==0) { _tissue[i]->GetProperty()->SetColor(0.85, 0.85 , 0.85 ); }
308 if (i==1) { _tissue[i]->GetProperty()->SetColor(0, 0 , 1 ); }
309 if (i==2) { _tissue[i]->GetProperty()->SetColor(0.85, 0.20 , 0.20 ); }
310 if (i==3) { _tissue[i]->GetProperty()->SetColor(0, 1 , 0 ); }
313 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
315 _observerS[i] = boxSurfaceObserver::New();
316 _observerS[i]->SetPlanes( GetTissuePlanes(i) );
317 _observerS[i]->SetActor( _tissue[i] );
318 _observerS[i]->SetFilters( _mCubes[i], _tissueStripper[i] ,_tissueClipper[i] );
322 //-----------------------------------------------------------------------------
324 void vtkClipping3DDataViewer::Configure_Volume()
328 /** if(_newvol != NULL)
331 _volumeMapper->Delete();
332 _volumeProperty->Delete();
335 _tfun = vtkPiecewiseFunction::New();
336 _ctfun = vtkColorTransferFunction::New();
339 this->_vtkmprbasedata->GetImageData()->GetScalarRange(range);
340 double max = range[1];
343 adding the poinst of the transference function
346 greyValuesTransferenceFVector.push_back(max * 0/2); // JPR ?? 0/2
347 greyValuesTransferenceFVector.push_back(max * 1/2); // JPR ?? division entiere?
348 greyValuesTransferenceFVector.push_back(max * 2/2);
350 intensityValuesTransferenceFVector.push_back(0.0);
351 intensityValuesTransferenceFVector.push_back(1.0);
352 intensityValuesTransferenceFVector.push_back(1.0);
354 _tfun->AddPoint(max * 0/2 , 0.0);
355 _tfun->AddPoint(max * 1/2 , 1.0);
356 _tfun->AddPoint(max * 2/2 , 1.0);
359 Adding the colors to the vectors
362 redColorsOfColorTransferenceFVector.push_back(0.0);
363 redColorsOfColorTransferenceFVector.push_back(1.0);
364 redColorsOfColorTransferenceFVector.push_back(0.0);
365 redColorsOfColorTransferenceFVector.push_back(0.0);
366 redColorsOfColorTransferenceFVector.push_back(0.0);
369 greenColorsOfColorTransferenceFVector.push_back(0.0);
370 greenColorsOfColorTransferenceFVector.push_back(0.0);
371 greenColorsOfColorTransferenceFVector.push_back(0.0);
372 greenColorsOfColorTransferenceFVector.push_back(1.0);
373 greenColorsOfColorTransferenceFVector.push_back(0.2);
376 blueColorsOfColorTransferenceFVector.push_back(0.0);
377 blueColorsOfColorTransferenceFVector.push_back(0.0);
378 blueColorsOfColorTransferenceFVector.push_back(1.0);
379 blueColorsOfColorTransferenceFVector.push_back(0.0);
380 blueColorsOfColorTransferenceFVector.push_back(0.0);
382 greyValueColorsOfColorTransferenceFVector.push_back(max*0/4);
383 greyValueColorsOfColorTransferenceFVector.push_back(max*1/4);
384 greyValueColorsOfColorTransferenceFVector.push_back(max*2/4);
385 greyValueColorsOfColorTransferenceFVector.push_back(max*3/4);
386 greyValueColorsOfColorTransferenceFVector.push_back(max*4/4);
388 _ctfun->AddRGBPoint( max*0/4 , 0.0, 0.0, 0.0);
389 _ctfun->AddRGBPoint( max*1/4 , 1.0, 0.0, 0.0);
390 _ctfun->AddRGBPoint( max*2/4 , 0.0, 0.0, 1.0);
391 _ctfun->AddRGBPoint( max*3/4 , 0.0, 1.0, 0.0);
392 _ctfun->AddRGBPoint( max*4/4 , 0.0, 0.2, 0.0);
394 _volumePlanes = vtkPlanes::New();
395 // int x1,x2,y1,y2,z1,z2;
396 // vtkImageData *imagedata=_vtkmprbasedata->GetImageData();
397 // imagedata->GetExtent(x1,x2,y1,y2,z1,z2);
398 // _volumePlanes->SetBounds(x1,x2,y1,y2,z1,z2);
402 // _volumeMapper = vtkVolumeRayCastMapper::New();
405 //EED 2017-01-01 Migration VTK7
406 #if VTK_MAJOR_VERSION <= 5
407 _volumeMapper->SetInput( this->GetVtkMPRBaseData()->GetImageData() );
409 _volumeMapper->SetInputData( this->GetVtkMPRBaseData()->GetImageData() );
413 #if (VTK_MAJOR_VERSION <= 7)
414 _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
415 // _volumeMapper->SetVolumeRayCastFunction(_compositeFunctionMIP);
421 _volumeMapper->SetClippingPlanes( _volumePlanes );
422 _volumeMapper->AutoAdjustSampleDistancesOn();
424 _volumeProperty->SetInterpolationTypeToNearest();
425 //_volumeProperty = vtkVolumeProperty::New();
426 _volumeProperty->SetColor(_ctfun);
427 _volumeProperty->SetScalarOpacity( _tfun );
430 _volumeProperty->DisableGradientOpacityOn();
433 // _volumeProperty->SetInterpolationTypeToNearest();
434 // _volumeProperty->ShadeOff();
435 // _volumeProperty->SetAmbient(0.3);
436 // _volumeProperty->SetDiffuse(0.1);
437 // _volumeProperty->SetSpecular(0.8);
438 // _volumeProperty->DisableGradientOpacityOn();
440 // _newvol = vtkVolume::New();
441 _newvol->SetMapper(_volumeMapper );
442 _newvol->SetProperty(_volumeProperty );
444 _observerV = boxSurfaceObserver::New();
445 _observerV->SetPlanes( _volumePlanes );
446 _observerV->SetActor( _newvol );
448 #if (VTK_MAJOR_VERSION <= 7)
449 _observerV->SetvtkVolumeRayCastMapper( _volumeMapper );
451 _observerV->SetvtkFixedPointVolumeRayCastMapper( _volumeMapper );
455 //-----------------------------------------------------------------------------
457 void vtkClipping3DDataViewer::Configure_VolumeBox()
459 _volumerendererdata->SetImageData(_vtkmprbasedata->GetImageData());
462 vector<double> *gv = this->GetGreyValuesTransferenceFVector();
463 vector<double> *op = this->GetIntensityValuesTransferenceFVector();
465 _volumerendererdata->SetLookUpTable((vtkLookupTable*)(_ctfun));
466 _volumerendererdata->OpacityChanged(*gv, *op);
468 //_wxvtkclipping3Dview->VisibleVolumeActor( false );
469 //_volumerendererdata->ShowVolume(event.IsChecked() );
470 //_volumerendererdata->BoundingBoxChanged(event.IsChecked() );
473 //-----------------------------------------------------------------------------
475 void vtkClipping3DDataViewer::SetRenderer(vtkRenderer* renderer)
477 _volumerendererdata->SetRenderer(renderer);
481 //-----------------------------------------------------------------------------
482 void vtkClipping3DDataViewer::SetInteractor(vtkRenderWindowInteractor* interactor)
485 _volumerendererdata->SetInteractor(interactor);
489 //-----------------------------------------------------------------------------
490 void vtkClipping3DDataViewer::BoxActorChanged(bool changed)
492 vector<double> *gv = this->GetGreyValuesTransferenceFVector();
493 vector<double> *op = this->GetIntensityValuesTransferenceFVector();
495 _volumerendererdata->ShowVolume(changed);
496 _volumerendererdata->OpacityChanged(*gv, *op);
497 _volumerendererdata->BoundingBoxChanged(changed);
501 //-----------------------------------------------------------------------------
502 void vtkClipping3DDataViewer::UpdateVolumeBox(vector<double> gf, vector<double> vf, vtkColorTransferFunction* ctfun)
504 _volumerendererdata->SetLookUpTable((vtkLookupTable*)(ctfun));
505 _volumerendererdata->OpacityChanged(gf, vf);
509 //-----------------------------------------------------------------------------
510 void vtkClipping3DDataViewer::updateVolume()
513 #if (VTK_MAJOR_VERSION <= 7)
516 _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
517 _volumerendererdata->changeCompositeMIPFunction(0);
519 _volumeMapper->SetVolumeRayCastFunction(_compositeFunctionMIP);
520 _volumerendererdata->changeCompositeMIPFunction(1);
523 // ... here Composition of MIP
524 printf("EED vtkClipping3DDataViewer::updateVolume ... here Composition or MIP \n");
530 _volumeProperty->SetInterpolationTypeToLinear();
532 _volumeProperty->SetInterpolationTypeToNearest();
533 } // if _interpolation
537 _volumeProperty->ShadeOn();
539 _volumeProperty->ShadeOff();
544 //-------------------------------------------------------------------
545 void vtkClipping3DDataViewer::Configure()
549 Configure_VolumeBox();
553 //-------------------------------------------------------------------
554 void vtkClipping3DDataViewer::SetIsovalue(int idTissue, int isoValue)
556 _mCubes[idTissue]->SetValue(0, isoValue);
557 //EED 2017-01-01 Migration VTK7
558 #if VTK_MAJOR_VERSION <= 5
561 _mCubes[idTissue]->Update();
562 _tissueStripper[idTissue]->Update();
563 _tissueClipper[idTissue]->Update();
566 //-------------------------------------------------------------------
567 double vtkClipping3DDataViewer::GetIsovalue(int idTissue)
569 return _mCubes[idTissue]->GetValue(0);
571 //-------------------------------------------------------------------
572 vtkVolume* vtkClipping3DDataViewer::GetVolumeActor()
576 //-------------------------------------------------------------------
577 #if (VTK_MAJOR_VERSION <= 7)
578 vtkVolumeRayCastMapper* vtkClipping3DDataViewer::GetVolumeMapper()
580 vtkFixedPointVolumeRayCastMapper* vtkClipping3DDataViewer::GetVolumeMapper()
583 return _volumeMapper;
585 //-------------------------------------------------------------------
586 vtkPlanes* vtkClipping3DDataViewer::GetVolumePlanes()
588 return _volumePlanes;
591 //-------------------------------------------------------------------
592 vtkMarchingCubes *vtkClipping3DDataViewer::GetMCubes(int idTissue)
594 return _mCubes[idTissue];
596 //--------------------------------------------------------------------
597 //-------------------
599 //-------------------
601 std::vector<double>* vtkClipping3DDataViewer::GetGreyValuesTransferenceFVector()
603 return &greyValuesTransferenceFVector;
605 //--------------------------------------------------------------------
606 std::vector<double>* vtkClipping3DDataViewer::GetIntensityValuesTransferenceFVector()
608 return &intensityValuesTransferenceFVector;
610 //--------------------------------------------------------------------
611 std::vector<double>* vtkClipping3DDataViewer::GetRedColorsOfColorTransferenceFVector()
613 return &redColorsOfColorTransferenceFVector;
615 //--------------------------------------------------------------------
616 std::vector<double>* vtkClipping3DDataViewer::GetGreenColorsOfColorTransferenceFVector()
618 return &greenColorsOfColorTransferenceFVector;
620 //--------------------------------------------------------------------
621 std::vector<double>* vtkClipping3DDataViewer::GetBlueColorsOfColorTransferenceFVector()
623 return &blueColorsOfColorTransferenceFVector;
625 //--------------------------------------------------------------------
626 std::vector<double>* vtkClipping3DDataViewer::GetGreyValueColorsOfColorTransferenceFVector()
628 return &greyValueColorsOfColorTransferenceFVector;
630 //--------------------------------------------------------------------
631 //--------------------------------------
632 //Getters transference function
633 //and color of the transference function
634 //---------------------------------------
635 vtkPiecewiseFunction* vtkClipping3DDataViewer::GetTransferencefunction()
639 //--------------------------------------------------------------------
640 vtkColorTransferFunction* vtkClipping3DDataViewer::GetColorTransferenceFunction()
645 //-------------------------------------------------------------------
647 void vtkClipping3DDataViewer::ReadVolumeFunctions()
650 int i=0,xi,yi,r,g,b,gValue;
651 vtkImageData *imagedata = this->_vtkmprbasedata->GetImageData();
653 HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Histogram Dialog"),imagedata);
657 int tfSize=this->greyValuesTransferenceFVector.size();
661 hDlg->erasePointsTransferenceFunction();
664 double g=greyValuesTransferenceFVector[i];
665 double in=intensityValuesTransferenceFVector[i];
666 hDlg->addPointToTransferenceFunction(g,in*100);
672 int ctfSize=this->redColorsOfColorTransferenceFVector.size();
678 double gr=greyValueColorsOfColorTransferenceFVector[i];
679 double r=redColorsOfColorTransferenceFVector[i];
680 double g=greenColorsOfColorTransferenceFVector[i];
681 double b=blueColorsOfColorTransferenceFVector[i];
682 hDlg->addColorPoint(gr,r*255,g*255,b*255);
686 //If it is smooth activate next line
687 //hDlg->updatePlotter();
688 //setting variables if the user wants to do refresh
689 hDlg->setCTF(_ctfun);
693 // when the user had changed the transference Function
695 if(hDlg->ShowModal()== wxID_OK )
697 // -- vtkPiecewiseFunction --
698 this->_tfun->RemoveAllPoints();
699 greyValuesTransferenceFVector.clear();
700 intensityValuesTransferenceFVector.clear();
702 int nTFPoints=hDlg->getSizeTransferenceFunction();
706 hDlg->getTransferenceFunctionPoint(i,xi,yi);
707 this->_tfun->AddPoint( xi , yi/100.0 );
708 greyValuesTransferenceFVector.push_back(xi);
709 intensityValuesTransferenceFVector.push_back(yi/100.0);
712 // -- vtkColorTransferFunction --
713 this->_ctfun->RemoveAllPoints ();
715 redColorsOfColorTransferenceFVector.clear();
716 greenColorsOfColorTransferenceFVector.clear();
717 blueColorsOfColorTransferenceFVector.clear();
718 greyValueColorsOfColorTransferenceFVector.clear();
720 int nCTFpoints=hDlg->getSizeBarColor();
724 hDlg->getDataBarColorPoint(i,xi,r,g,b);
725 this->_ctfun->AddRGBPoint(xi,r/255.0,g/255.0,b/255.0 );
726 redColorsOfColorTransferenceFVector.push_back(r/255.0);
727 greenColorsOfColorTransferenceFVector.push_back(g/255.0);
728 blueColorsOfColorTransferenceFVector.push_back(b/255.0);
729 greyValueColorsOfColorTransferenceFVector.push_back(xi);
733 this->_volumeMapper->Update();
734 this->_newvol->Update();
740 if(hDlg->getRefreshed())
743 //--Transference Function----
744 this->_tfun->RemoveAllPoints();
746 size=greyValuesTransferenceFVector.size();
749 double grey1=greyValuesTransferenceFVector[i];
750 double in2=intensityValuesTransferenceFVector[i];
751 this->_tfun->AddPoint( grey1 , in2 );
754 // -- vtkColorTransferFunction --
755 _ctfun->RemoveAllPoints ();
758 size=greyValueColorsOfColorTransferenceFVector.size();
761 double grey2=(greyValueColorsOfColorTransferenceFVector)[i];
762 double red =(redColorsOfColorTransferenceFVector)[i];
763 double green =(greenColorsOfColorTransferenceFVector)[i];
764 double blue = (blueColorsOfColorTransferenceFVector)[i];
765 _ctfun->AddRGBPoint(grey2,red,green,blue);
767 this->_volumeMapper->Update();
768 this->_newvol->Update();
776 void vtkClipping3DDataViewer::ReadVolumeFunctions(char *namefile)
783 FILE *ff = fopen ( namefile ,"r");
787 if (strcmp(tmp,"MAX")==0)
789 vtkImageData *vtkimagedata = this->_vtkmprbasedata->GetImageData();
790 vtkimagedata->GetScalarRange(range);
791 max = (int) (range[1]);
796 fscanf(ff,"%s",tmp); // --
798 // -- vtkPiecewiseFunction --
799 this->_tfun->RemoveAllPoints();
801 while ( strcmp(tmp,"--")!=0 )
806 this->_tfun->AddPoint( x*max , val );
810 this->_ctfun->RemoveAllPoints ();
811 // -- vtkColorTransferFunction --
822 this->_ctfun->AddRGBPoint( x*max , r,g,b );
826 this->_volumeMapper->Update();
827 this->_newvol->Update();
834 //-------------------------------------------------------------------
836 void vtkClipping3DDataViewer::ReadMeshVTK(char *namefile)
838 vtkDataSetReader *reader = vtkDataSetReader::New();
839 reader->SetFileName(namefile);
842 //EED 2017-01-01 Migration VTK7
843 #if VTK_MAJOR_VERSION <= 5
844 _tissueStripper[3]->SetInput( reader->GetPolyDataOutput() );
846 _tissueStripper[3]->SetInputData( reader->GetPolyDataOutput() );
851 void vtkClipping3DDataViewer::setColorTransferFunction(vtkColorTransferFunction* colortable){
853 _volumeProperty->SetColor(colortable);
858 void vtkClipping3DDataViewer::SetRayCasting(bool active)
860 _isRayCasting = active;
864 void vtkClipping3DDataViewer::SetMIPActive(bool active)
869 void vtkClipping3DDataViewer::SetInterpolation(bool active)
871 _interpolation = active;
874 void vtkClipping3DDataViewer::SetShade(bool active)