2 #include "wxMaracasSurfaceRenderingManagerDataMhd.h"
4 wxMaracasSurfaceRenderingManagerDataMhd::wxMaracasSurfaceRenderingManagerDataMhd(vtkImageData* imagedata, std::string dataname)
5 : wxMaracasSurfaceRenderingManagerData(NULL, dataname)
8 this->setVtkImageData(imagedata);
11 _maxgreylevel = getMaxLevel(imagedata);
14 _cubesFilter = vtkMarchingCubes::New();
15 _cleanFilter = vtkCleanPolyData::New();
16 _dataMapper = vtkPolyDataMapper::New();
17 vtkActor* dataActor = vtkActor::New();
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);
29 this->_prop3D = dataActor;
31 this->changeIsoValue(this->_maxgreylevel);
36 wxMaracasSurfaceRenderingManagerDataMhd::~wxMaracasSurfaceRenderingManagerDataMhd(){
37 _cubesFilter->Delete();
38 _cleanFilter->Delete();
39 _dataMapper->Delete();
44 ** changes the isovalue in a prop3D
46 void wxMaracasSurfaceRenderingManagerDataMhd::changeIsoValue(double value){
49 _cubesFilter->SetValue(0,value);
50 _cubesFilter->Update();
51 _cleanFilter->Update();
52 _dataMapper->Update();
57 int wxMaracasSurfaceRenderingManagerDataMhd::getMaxGreyLevel(){
62 ** Get's the max grey level of the image
64 int wxMaracasSurfaceRenderingManagerDataMhd::getMaxLevel(vtkImageData* img){
66 int ext[6], i, j, k,max=0;
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);
86 ** Sets the VTK image data
89 void wxMaracasSurfaceRenderingManagerDataMhd::setVtkImageData(vtkImageData* imagedata){
90 _imagedata = imagedata;