14 #include "mitkIGTException.h" 16 #include "Poco/File.h" 19 #include <vtkSphereSource.h> 20 #include "vtkConeSource.h" 21 #include "vtkLineSource.h" 22 #include "vtkCylinderSource.h" 23 #include "vtkTransformPolyDataFilter.h" 24 #include <vtkAppendPolyData.h> 31 m_CalibrationFile(
"none"),
47 Self::Pointer tool =
new Self(*
this);
49 return tool.GetPointer();
63 this->
m_DataNode->SetData(dynamic_cast<mitk::BaseData*>(other.
m_DataNode->GetData()->Clone().GetPointer()));
90 vnl_vector_fixed<mitk::ScalarType,3> toolAxisVector =
m_ToolAxisOrientation.inverse().rotate(toolAxisSensorCoordinateSystem.GetVnlVector());
93 toolAxis[0] = toolAxisVector[0];
94 toolAxis[1] = toolAxisVector[1];
95 toolAxis[2] = toolAxisVector[2];
107 toolAxisFromCalibration.Normalize();
109 if (toolAxisSensorCoordinateSystem == toolAxisFromCalibration)
116 mitk::ScalarType rotationAngle = acos(toolAxisSensorCoordinateSystem*toolAxisFromCalibration);
118 mitk::Vector3D rotationAxis = itk::CrossProduct(toolAxisSensorCoordinateSystem, toolAxisFromCalibration);
120 itk::AffineTransform<mitk::ScalarType>::Pointer sensorToToolAxisOrientation = itk::AffineTransform<mitk::ScalarType>::New();
121 sensorToToolAxisOrientation->Rotate3D(rotationAxis, rotationAngle);
123 mitk::Quaternion toolAxisTransform(sensorToToolAxisOrientation->GetMatrix().GetVnlMatrix().transpose());
134 return returnValue->GetAffineTransform3D();
143 nd =
dynamic_cast<const Self *
>(data);
148 <<
typeid(data).name() <<
" to " 149 <<
typeid(
const Self *).name();
155 <<
typeid(data).name() <<
" to " 156 <<
typeid(
const Self *).name();
161 m_DataNode->SetName(nd->GetDataNode()->GetName());
162 m_DataNode->SetData(nd->GetDataNode()->GetData());
211 if (this->
m_DataNode.IsNull()) {
return nullptr; }
212 else if (this->
m_DataNode->GetData() ==
nullptr) {
return nullptr; }
223 double axisLength = 5.;
225 vtkSmartPointer<vtkSphereSource> vtkSphere = vtkSmartPointer<vtkSphereSource>::New();
226 vtkSmartPointer<vtkConeSource> vtkCone = vtkSmartPointer<vtkConeSource>::New();
227 vtkSmartPointer<vtkCylinderSource> vtkCylinder = vtkSmartPointer<vtkCylinderSource>::New();
228 vtkSmartPointer<vtkPolyData> axis = vtkSmartPointer<vtkPolyData>::New();
229 vtkSmartPointer<vtkLineSource> vtkLine = vtkSmartPointer<vtkLineSource>::New();
230 vtkSmartPointer<vtkLineSource> vtkLine2 = vtkSmartPointer<vtkLineSource>::New();
231 vtkSmartPointer<vtkLineSource> vtkLine3 = vtkSmartPointer<vtkLineSource>::New();
233 vtkSmartPointer<vtkAppendPolyData> appendPolyData = vtkSmartPointer<vtkAppendPolyData>::New();
234 vtkSmartPointer<vtkPolyData> surface = vtkSmartPointer<vtkPolyData>::New();
237 vtkCone->SetDirection(0, 1, 0);
238 vtkCone->SetHeight(1.0);
239 vtkCone->SetRadius(0.4f);
240 vtkCone->SetResolution(16);
241 vtkCone->SetCenter(0.0, axisLength, 0.0);
244 vtkCylinder->SetRadius(0.05);
245 vtkCylinder->SetHeight(axisLength);
246 vtkCylinder->SetCenter(0.0, 0.5*axisLength, 0.0);
247 vtkCylinder->Update();
249 appendPolyData->AddInputData(vtkCone->GetOutput());
250 appendPolyData->AddInputData(vtkCylinder->GetOutput());
251 appendPolyData->Update();
252 axis->DeepCopy(appendPolyData->GetOutput());
255 vtkLine->SetPoint1(-0.5, axisLength + 2., 0.0);
256 vtkLine->SetPoint2(0.0, axisLength + 1.5, 0.0);
259 vtkLine2->SetPoint1(0.5, axisLength + 2., 0.0);
260 vtkLine2->SetPoint2(-0.5, axisLength + 1., 0.0);
263 appendPolyData->AddInputData(vtkLine->GetOutput());
264 appendPolyData->AddInputData(vtkLine2->GetOutput());
265 appendPolyData->AddInputData(axis);
266 appendPolyData->Update();
267 surface->DeepCopy(appendPolyData->GetOutput());
270 vtkSmartPointer<vtkTransform> XTransform = vtkSmartPointer<vtkTransform>::New();
271 XTransform->RotateZ(-90);
272 vtkSmartPointer<vtkTransformPolyDataFilter> TrafoFilter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
273 TrafoFilter->SetTransform(XTransform);
274 TrafoFilter->SetInputData(axis);
275 TrafoFilter->Update();
278 vtkLine->SetPoint1(axisLength + 2., -0.5, 0.0);
279 vtkLine->SetPoint2(axisLength + 1., 0.5, 0.0);
282 vtkLine2->SetPoint1(axisLength + 2., 0.5, 0.0);
283 vtkLine2->SetPoint2(axisLength + 1., -0.5, 0.0);
286 appendPolyData->AddInputData(vtkLine->GetOutput());
287 appendPolyData->AddInputData(vtkLine2->GetOutput());
288 appendPolyData->AddInputData(TrafoFilter->GetOutput());
289 appendPolyData->AddInputData(surface);
290 appendPolyData->Update();
291 surface->DeepCopy(appendPolyData->GetOutput());
294 vtkSmartPointer<vtkTransform> ZTransform = vtkSmartPointer<vtkTransform>::New();
295 ZTransform->RotateX(90);
296 TrafoFilter->SetTransform(ZTransform);
297 TrafoFilter->SetInputData(axis);
298 TrafoFilter->Update();
301 vtkLine->SetPoint1(-0.5, 0.0, axisLength + 2.);
302 vtkLine->SetPoint2(0.5, 0.0, axisLength + 2.);
305 vtkLine2->SetPoint1(-0.5, 0.0, axisLength + 2.);
306 vtkLine2->SetPoint2(0.5, 0.0, axisLength + 1.);
309 vtkLine3->SetPoint1(0.5, 0.0, axisLength + 1.);
310 vtkLine3->SetPoint2(-0.5, 0.0, axisLength + 1.);
313 appendPolyData->AddInputData(vtkLine->GetOutput());
314 appendPolyData->AddInputData(vtkLine2->GetOutput());
315 appendPolyData->AddInputData(vtkLine3->GetOutput());
316 appendPolyData->AddInputData(TrafoFilter->GetOutput());
317 appendPolyData->AddInputData(surface);
318 appendPolyData->Update();
319 surface->DeepCopy(appendPolyData->GetOutput());
322 vtkSphere->SetRadius(0.5f);
323 vtkSphere->SetCenter(0.0, 0.0, 0.0);
326 appendPolyData->AddInputData(vtkSphere->GetOutput());
327 appendPolyData->AddInputData(surface);
328 appendPolyData->Update();
329 surface->DeepCopy(appendPolyData->GetOutput());
332 vtkSmartPointer<vtkTransform> ScaleTransform = vtkSmartPointer<vtkTransform>::New();
333 ScaleTransform->Scale(20., 20., 20.);
335 TrafoFilter->SetTransform(ScaleTransform);
336 TrafoFilter->SetInputData(surface);
337 TrafoFilter->Update();
339 mySphere->SetVtkPolyData(TrafoFilter->GetOutput());
346 std::stringstream _info;
348 <<
" NavigationToolType: " <<
m_Type <<
"\n" 354 <<
" Tool Axis: " <<
m_ToolAxisOrientation.inverse().rotate(vnl_vector_fixed<mitk::ScalarType,3>(0.0,0.0,-1.0))
Class for storing surfaces (vtkPolyData).
An object of this class represents an exception of the MITK-IGT module.
DataCollection - Class to facilitate loading/accessing structured data.
void FillVector3D(Tout &out, mitk::ScalarType x, mitk::ScalarType y, mitk::ScalarType z)
Data structure which stores a set of points. Superclass of mitk::Mesh.
vnl_quaternion< ScalarType > Quaternion
#define mitkThrowException(classname)