52 if (m_Renderer.IsNull())
54 itkExceptionMacro(<<
"Renderer was not properly set");
58 unsigned int numberOfInputs = this->GetNumberOfInputs();
59 if (numberOfInputs == 0)
63 for (
unsigned int i = 0; i < numberOfInputs ; ++i)
77 if (numberOfInputs == 0 || !this->GetInput()->IsDataValid())
81 Point3D slicePosition = this->GetInput()->GetPosition();
86 Vector3D transformedTipOffset;
87 transformedTipOffset.SetVnlVector(orientation.rotate(m_TipOffset.GetVnlVector()).as_ref());
89 slicePosition += transformedTipOffset;
91 mitk::SliceNavigationController::Pointer snc = m_Renderer->GetSliceNavigationController();
93 if (Axial == m_ViewDirection)
95 snc->SetViewDirection(mitk::AnatomicalPlane::Axial);
96 snc->SelectSliceByPoint(slicePosition);
98 else if (Sagittal == m_ViewDirection)
100 snc->SetViewDirection(mitk::AnatomicalPlane::Sagittal);
101 snc->SelectSliceByPoint(slicePosition);
103 else if (Coronal == m_ViewDirection)
105 snc->SetViewDirection(mitk::AnatomicalPlane::Coronal);
106 snc->SelectSliceByPoint(slicePosition);
108 else if (AxialOblique == m_ViewDirection || SagittalOblique == m_ViewDirection)
110 const int slicingPlaneXAxis = AxialOblique == m_ViewDirection ? 0 : 2;
113 const mitk::PlaneGeometry::TransformType::MatrixType &m =
114 m_Renderer->GetCurrentWorldPlaneGeometry()->GetIndexToWorldTransform()->GetMatrix();
119 Vector3D slicingPlaneYAxisVector;
120 slicingPlaneYAxisVector.SetVnlVector(orientation.rotate(m_ToolTrajectory.GetVnlVector()).as_ref());
125 slicingPlaneYAxisVector[slicingPlaneXAxis] = 0.0;
131 if ( m(slicingPlaneXAxis,0) == 0.0 ||
133 (slicingPlaneXAxis != 0 && slicingPlaneYAxisVector[0] == 0.0) ||
134 (slicingPlaneXAxis != 1 && slicingPlaneYAxisVector[1] == 0.0) ||
135 (slicingPlaneXAxis != 2 && slicingPlaneYAxisVector[2] == 0.0) )
143 if ( (m(1,1) > 0) != (slicingPlaneYAxisVector[1] > 0) )
145 slicingPlaneYAxisVector *= -1;
148 Vector3D slicingPlaneXAxisVector;
149 slicingPlaneXAxisVector.Fill(0.0);
153 slicingPlaneXAxisVector[slicingPlaneXAxis] = m(slicingPlaneXAxis,0) > 0 ? 1.0 : -1.0;
156 FillVector3D(origin, 0.0, 0.0, 0.0);
157 snc->ReorientSlices(origin, slicingPlaneXAxisVector, slicingPlaneYAxisVector);
158 snc->SelectSliceByPoint(slicePosition);
160 else if (Oblique == m_ViewDirection)
162 Vector3D slicingPlaneNormalVector;
163 slicingPlaneNormalVector.SetVnlVector(orientation.rotate(m_ToolTrajectory.GetVnlVector()).as_ref());
167 const mitk::PlaneGeometry::TransformType::MatrixType &m =
168 m_Renderer->GetCurrentWorldPlaneGeometry()->GetIndexToWorldTransform()->GetMatrix();
169 mitk::Vector3D currentSlicingPlaneUpVector;
170 mitk::FillVector3D(currentSlicingPlaneUpVector, m[0][1], m[1][1], m[2][1]);
171 mitk::Vector3D worldUpVector = m_WorldVerticalVector;
172 if (angle(worldUpVector.GetVnlVector(), currentSlicingPlaneUpVector.GetVnlVector()) > vnl_math::pi_over_2 )
177 mitk::PlaneGeometry::Pointer slicingPlane = mitk::PlaneGeometry::New();
179 FillVector3D(origin, 0.0, 0.0, 0.0);
180 slicingPlane->InitializePlane(origin, slicingPlaneNormalVector);
185 mitk::Vector3D slicingPlaneUpVector;
186 if ( slicingPlane->Project(worldUpVector, slicingPlaneUpVector) )
192 itk::Vector<double,3> slicingPlaneUpVector_double;
193 FillVector3D(slicingPlaneUpVector_double,
194 slicingPlaneUpVector[0], slicingPlaneUpVector[1], slicingPlaneUpVector[2]);
195 itk::Vector<double,3> slicingPlaneNormalVector_double;
196 FillVector3D(slicingPlaneNormalVector_double,
197 slicingPlaneNormalVector[0], slicingPlaneNormalVector[1], slicingPlaneNormalVector[2]);
198 itk::Vector<double,3> slicingPlaneRightVector_double = itk::CrossProduct(slicingPlaneUpVector_double,
199 slicingPlaneNormalVector_double);
201 mitk::Vector3D slicingPlaneRightVector;
202 mitk::FillVector3D(slicingPlaneRightVector,
203 slicingPlaneRightVector_double[0], slicingPlaneRightVector_double[1], slicingPlaneRightVector_double[2]);
204 mitk::FillVector3D(slicingPlaneUpVector,
205 slicingPlaneUpVector_double[0], slicingPlaneUpVector_double[1], slicingPlaneUpVector_double[2]);
207 snc->ReorientSlices(origin, slicingPlaneRightVector, slicingPlaneUpVector);
208 snc->SelectSliceByPoint(slicePosition);
213 MITK_ERROR <<
"Unsupported ViewDirection: " << m_ViewDirection;
216 m_Renderer->RequestUpdate();