]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasSurfaceRenderingManagerDataMhd.cxx
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxMaracasSurfaceRenderingManagerDataMhd.cxx
1
2 #include "wxMaracasSurfaceRenderingManagerDataMhd.h"
3
4 wxMaracasSurfaceRenderingManagerDataMhd::wxMaracasSurfaceRenderingManagerDataMhd(vtkImageData* imagedata, std::string dataname)
5 : wxMaracasSurfaceRenderingManagerData(NULL, dataname)
6 {
7
8         this->setVtkImageData(imagedata);
9         _dataname = dataname;
10         
11         _maxgreylevel = getMaxLevel(imagedata);
12         _prop3D=NULL;                   
13
14         _cubesFilter = vtkMarchingCubes::New();
15         _cleanFilter = vtkCleanPolyData::New();         
16         _dataMapper = vtkPolyDataMapper::New();
17         vtkActor* dataActor = vtkActor::New();
18         
19         _cubesFilter->SetInput(this->_imagedata);
20         _cubesFilter->ComputeGradientsOn ();
21         _cubesFilter->ComputeScalarsOn ();
22         _cubesFilter->SetNumberOfContours( 1 );
23         _cleanFilter->SetInput ( _cubesFilter->GetOutput() );
24         _dataMapper->SetInput(_cleanFilter->GetOutput());
25         _dataMapper->ScalarVisibilityOff();
26         _dataMapper->ImmediateModeRenderingOn();
27         dataActor->SetMapper(_dataMapper);      
28
29         this->_prop3D = dataActor;
30
31         this->changeIsoValue(this->_maxgreylevel);      
32
33
34 }
35
36 wxMaracasSurfaceRenderingManagerDataMhd::~wxMaracasSurfaceRenderingManagerDataMhd(){    
37         _cubesFilter->Delete();
38         _cleanFilter->Delete();
39         _dataMapper->Delete();
40 }
41         
42
43 /**
44 **      changes the isovalue in a prop3D
45 **/
46 void wxMaracasSurfaceRenderingManagerDataMhd::changeIsoValue(double value){     
47                 
48    
49     _cubesFilter->SetValue(0,value);            
50         _cubesFilter->Update();    
51         _cleanFilter->Update();
52         _dataMapper->Update();  
53         
54         
55         
56 }
57 int wxMaracasSurfaceRenderingManagerDataMhd::getMaxGreyLevel(){
58         return _maxgreylevel;
59 }
60
61 /**
62         ** Get's the max grey level of the image
63         **/
64 int wxMaracasSurfaceRenderingManagerDataMhd::getMaxLevel(vtkImageData* img){
65
66         int ext[6], i, j, k,max=0;
67         img->GetExtent(ext);
68
69         for(i = ext[0]; i < ext[1];i++){
70                 for(j = ext[2]; j < ext[3];j++){
71                         for(k = ext[4]; k < ext[5];k++){
72                 unsigned short* ptr = (unsigned short*)img->GetScalarPointer(i,j,k);
73                                 int temp = (int)*ptr;
74                                 if(temp > max){
75                     max = temp;
76                                 }
77                         }
78                 }
79         }
80         return max;
81
82
83 }
84
85 /**
86 **      Sets the VTK image data
87 **/
88
89 void wxMaracasSurfaceRenderingManagerDataMhd::setVtkImageData(vtkImageData* imagedata){
90         _imagedata = imagedata;
91 }
92