2 #include "wxMaracasSurfaceRenderingManagerDataMhd.h"
3 #include "vtkStripper.h"
5 wxMaracasSurfaceRenderingManagerDataMhd::wxMaracasSurfaceRenderingManagerDataMhd(vtkImageData* imagedata, std::string dataname, vtkRenderWindowInteractor* interactor)
6 : wxMaracasSurfaceRenderingManagerData(NULL, dataname)
9 this->setVtkImageData(imagedata);
12 _maxgreylevel = getMaxLevel(imagedata);
15 _cubesFilter = vtkMarchingCubes::New();
16 _cubesFilter->SetInput(this->_imagedata);
17 _cubesFilter->ComputeGradientsOn ();
18 _cubesFilter->ComputeScalarsOn ();
19 _cubesFilter->SetNumberOfContours( 1 );
20 _cleanFilter = vtkCleanPolyData::New();
21 _cleanFilter->SetInput ( _cubesFilter->GetOutput() );
23 _dataMapper = vtkPolyDataMapper::New( );
24 _dataMapper->ScalarVisibilityOff( );
25 _dataMapper->ImmediateModeRenderingOn();
29 _boxWidgetS1 = vtkBoxWidget::New();
30 _boxWidgetS1->SetInteractor( interactor );
31 _boxWidgetS1->SetPlaceFactor(1.25);
33 _boxWidgetS1->SetInput( this->_imagedata );
34 _boxWidgetS1->PlaceWidget();
35 //_boxWidgetS1->AddObserver( vtkCommand::InteractionEvent , _vtkclipping3Ddataviewer->GetObserverS(i) );
36 _boxWidgetS1->HandlesOn ();
39 vtkStripper* striper = vtkStripper::New();
40 striper->SetInput( _cleanFilter->GetOutput() );
41 //striper->SetInput( _cubesFilter->GetOutput() );
44 _boxWidgetS1->SetInput(striper->GetOutput());
45 _boxWidgetS1->PlaceWidget();
47 _tissuePlanes = vtkPlanes::New();
49 int x1,x2,y1,y2,z1,z2;
50 this->_imagedata->GetExtent(x1,x2,y1,y2,z1,z2);
51 _tissuePlanes->SetBounds (x1,x2,y1,y2,z1,z2);
53 _boxWidgetS1->GetPlanes( _tissuePlanes );
55 _tissueClipper = vtkClipPolyData::New();
56 _tissueClipper->SetInput( striper->GetOutput() );
57 _tissueClipper->SetClipFunction( _tissuePlanes );
58 _tissueClipper->InsideOutOn( );
59 _dataMapper->SetInput( _tissueClipper->GetOutput() );
62 _dataMapper->SetInput(_cleanFilter->GetOutput());
65 vtkActor* dataActor = vtkActor::New();
66 dataActor->SetMapper(_dataMapper);
67 this->_prop3D = dataActor;
71 this->changeIsoValue(this->_maxgreylevel);
76 wxMaracasSurfaceRenderingManagerDataMhd::~wxMaracasSurfaceRenderingManagerDataMhd(){
77 _cubesFilter->Delete();
78 _cleanFilter->Delete();
79 _dataMapper->Delete();
82 void wxMaracasSurfaceRenderingManagerDataMhd::UpdateSurface(){
83 _cubesFilter->Update();
84 _cleanFilter->Update();
85 _dataMapper->Update();
88 ** changes the isovalue in a prop3D
90 void wxMaracasSurfaceRenderingManagerDataMhd::changeIsoValue(double value){
93 _cubesFilter->SetValue(0,value);
94 _cubesFilter->Update();
95 _cleanFilter->Update();
96 _dataMapper->Update();
101 int wxMaracasSurfaceRenderingManagerDataMhd::getMaxGreyLevel(){
102 return _maxgreylevel;
106 ** Get's the max grey level of the image
108 int wxMaracasSurfaceRenderingManagerDataMhd::getMaxLevel(vtkImageData* img){
110 int ext[6], i, j, k,max=0;
113 for(i = ext[0]; i < ext[1];i++){
114 for(j = ext[2]; j < ext[3];j++){
115 for(k = ext[4]; k < ext[5];k++){
116 unsigned short* ptr = (unsigned short*)img->GetScalarPointer(i,j,k);
117 int temp = (int)*ptr;
130 ** Sets the VTK image data
133 void wxMaracasSurfaceRenderingManagerDataMhd::setVtkImageData(vtkImageData* imagedata){
134 _imagedata = imagedata;