15#include <mitkTransferFunction.h>
16#include <mitkTransferFunctionProperty.h>
20#include <mitkSmartPointerProperty.h>
21#include <mitkRenderingManager.h>
29 m_ToFDistanceImageToSurfaceFilter(nullptr),
30 m_ToFImageGrabber(nullptr),
31 m_CameraIntrinsics(nullptr),
46 m_Controls =
new Ui::QmitkToFSurfaceGenerationWidgetControls;
69 return m_ToFDistanceImageToSurfaceFilter;
74 this->
m_Controls->m_TextureGroupBox->setVisible(checked);
75 this->
m_Controls->m_TriangulationThresholdSpinbox->setVisible(checked);
76 this->
m_Controls->m_ReconstructionCombobox->setVisible(checked);
77 this->
m_Controls->m_RepresentationCombobox->setVisible(checked);
79 this->
m_Controls->label_2->setVisible(checked);
80 this->
m_Controls->label_3->setVisible(checked);
84 mitk::ToFImageGrabber::Pointer grabber,
85 mitk::CameraIntrinsics::Pointer intrinsics,
86 mitk::DataNode::Pointer surface,
89 bool showAdvancedOptions)
91 m_ToFDistanceImageToSurfaceFilter = filter;
92 m_ToFImageGrabber = grabber;
93 m_CameraIntrinsics = intrinsics;
97 bool hasSurface =
false;
98 m_ToFImageGrabber->GetCameraDevice()->GetBoolProperty(
"HasSurface", hasSurface);
101 this->m_Surface = mitk::Surface::New();
105 this->m_Surface = this->m_ToFDistanceImageToSurfaceFilter->GetOutput(0);
108 m_SurfaceNode = surface;
109 m_SurfaceNode->SetData(m_Surface);
111 this->FindReconstructionModeProperty();
112 m_Controls->m_ShowAdvancedOptionsCheckbox->setChecked(showAdvancedOptions);
114 m_Controls->m_Compute3DDataCheckbox->setChecked(generateSurface);
121 MITK_ERROR <<
"QmitkToFSurfaceGenerationWidget is not active - please call QmitkToFSurfaceGenerationWidget::Initialize() first";
130 this->m_ToFDistanceImageToSurfaceFilter->SetTriangulationThreshold( this->
m_Controls->m_TriangulationThresholdSpinbox->value() );
131 this->m_ToFImageGrabber->GetCameraDevice()->SetFloatProperty(
"TriangulationThreshold", this->
m_Controls->m_TriangulationThresholdSpinbox->value());
159 MITK_ERROR <<
"ReconstructionModeType does not exist or is not known in QmitkToFSurfaceGenerationWidget.";
163 this->m_ToFDistanceImageToSurfaceFilter->SetReconstructionMode( type );
171 bool generateTriangularMesh =
false;
174 generateTriangularMesh =
true;
176 this->m_ToFDistanceImageToSurfaceFilter->SetGenerateTriangularMesh(generateTriangularMesh);
177 this->m_ToFImageGrabber->GetCameraDevice()->SetBoolProperty(
"GenerateTriangularMesh", generateTriangularMesh);
179 this->m_ToFDistanceImageToSurfaceFilter->SetTriangulationThreshold( this->
m_Controls->m_TriangulationThresholdSpinbox->value() );
180 this->m_ToFImageGrabber->GetCameraDevice()->SetFloatProperty(
"TriangulationThreshold", this->
m_Controls->m_TriangulationThresholdSpinbox->value());
181 this->
m_Controls->m_TriangulationThresholdSpinbox->setEnabled(generateTriangularMesh);
189 if(m_ToFImageGrabber->GetBoolProperty(
"HasRGBImage"))
194 this->m_SurfaceNode->SetProperty(
"Surface.Texture",mitk::SmartPointerProperty::New(this->m_ToFImageGrabber->GetOutput(3)));
197 this->m_SurfaceNode->GetPropertyList()->DeleteProperty(
"Surface.Texture");
205 if(m_SurfaceNode.IsNotNull())
207 this->m_SurfaceNode->SetBoolProperty(
"scalar visibility", checked);
216 if (
m_Controls->m_Compute3DDataCheckbox->isChecked())
218 bool hasSurface =
false;
219 this->m_ToFImageGrabber->GetCameraDevice()->GetBoolProperty(
"HasSurface", hasSurface);
222 mitk::SmartPointerProperty::Pointer surfaceProp =
dynamic_cast< mitk::SmartPointerProperty *
>(this->m_ToFImageGrabber->GetCameraDevice()->GetProperty(
"ToFSurface"));
223 this->m_Surface->SetVtkPolyData(
dynamic_cast< mitk::Surface*
>( surfaceProp->GetSmartPointer().GetPointer() )->GetVtkPolyData() );
227 this->m_Surface = m_ToFDistanceImageToSurfaceFilter->GetOutput(0);
231 this->m_Surface->Update();
244 MITK_DEBUG <<
"OnSurfaceCheckboxChecked true";
245 this->m_SurfaceNode->SetData(this->m_Surface);
250 mitk::RenderingManager::GetInstance()->InitializeViews(this->m_Surface->GetTimeGeometry(), mitk::RenderingManager::REQUEST_UPDATE_3DWINDOWS);
254 m_Camera3d->SetPosition(0,0,0);
255 m_Camera3d->SetViewUp(0,-1,0);
256 m_Camera3d->SetFocalPoint(0,0,1);
257 if (this->m_CameraIntrinsics.IsNotNull())
264 m_Camera3d->SetViewAngle(45);
266 m_Camera3d->SetClippingRange(1, 10000);
270void QmitkToFSurfaceGenerationWidget::FindReconstructionModeProperty()
272 bool KinectReconstructionMode =
false;
273 m_ToFImageGrabber->GetCameraDevice()->GetBoolProperty(
"KinectReconstructionMode",KinectReconstructionMode);
274 if(KinectReconstructionMode)
278 m_Controls->m_ReconstructionCombobox->setDisabled(
true);
279 m_Controls->m_ReconstructionCombobox->setCurrentIndex(2);
283 m_Controls->m_ReconstructionCombobox->setEnabled(
true);
ReconstructionModeType
The ReconstructionModeType enum: Defines the reconstruction mode, if using no interpixeldistances and...
@ WithOutInterPixelDistance
static ToFScalarType CalculateViewAngle(mitk::CameraIntrinsics::Pointer intrinsics, unsigned int dimX)
Calculates the horizontal view angle of the camera with the given intrinsics.