void QmitkInteractiveTransformationWidget::SetGeometry( mitk::BaseGeometry::Pointer geometry, mitk::BaseGeometry::Pointer defaultValues )
{
  m_Geometry = geometry;
  itk::LightObject::Pointer lopointer = geometry->Clone();
  m_ResetGeometry = dynamic_cast<mitk::BaseGeometry*>(lopointer.GetPointer());

  //set default values
  if (defaultValues.IsNotNull())
    {
    //first: some conversion
    mitk::NavigationData::Pointer transformConversionHelper = mitk::NavigationData::New(defaultValues->GetIndexToWorldTransform());
    double eulerAlphaDegrees = transformConversionHelper->GetOrientation().rotation_euler_angles()[0] / vnl_math::pi * 180;
    double eulerBetaDegrees = transformConversionHelper->GetOrientation().rotation_euler_angles()[1] / vnl_math::pi * 180;
    double eulerGammaDegrees = transformConversionHelper->GetOrientation().rotation_euler_angles()[2] / vnl_math::pi * 180;

    //set translation
    OnXTranslationValueChanged(defaultValues->GetIndexToWorldTransform()->GetOffset()[0]);
    OnYTranslationValueChanged(defaultValues->GetIndexToWorldTransform()->GetOffset()[1]);
    OnZTranslationValueChanged(defaultValues->GetIndexToWorldTransform()->GetOffset()[2]);

    //set rotation
    OnXRotationValueChanged(eulerAlphaDegrees);
    OnYRotationValueChanged(eulerBetaDegrees);
    OnZRotationValueChanged(eulerGammaDegrees);
    }
  else
    {
    //reset everything
    OnXTranslationValueChanged(0);
    OnYTranslationValueChanged(0);
    OnZTranslationValueChanged(0);
    OnXRotationValueChanged(0);
    OnYRotationValueChanged(0);
    OnZRotationValueChanged(0);
    }
}
Exemplo n.º 2
0
std::vector<mitk::Point3D> mitk::GetCornerPoints(mitk::BaseGeometry::Pointer geometry, bool visualizationOffset)
{
  if (geometry == nullptr)
    mitkThrow() << "Geometry is not valid.";

  mitk::BoundingBox::ConstPointer boundingBox = geometry->GetBoundingBox();
  mitk::Point3D BBmin = boundingBox->GetMinimum();
  mitk::Point3D BBmax = boundingBox->GetMaximum();

  // use 0.5 offset because the vtkCubeSource is not center pixel based (only for visualization purpose)
  if (visualizationOffset)
  {
    BBmin -= 0.5;
    BBmax -= 0.5;
  }
  mitk::Point3D p0;
  p0[0] = BBmin[0];
  p0[1] = BBmin[1];
  p0[2] = BBmin[2]; // bottom - left - back corner
  mitk::Point3D p1;
  p1[0] = BBmin[0];
  p1[1] = BBmin[1];
  p1[2] = BBmax[2]; // top - left - back corner
  mitk::Point3D p2;
  p2[0] = BBmin[0];
  p2[1] = BBmax[1];
  p2[2] = BBmin[2]; // bottom - left - front corner
  mitk::Point3D p3;
  p3[0] = BBmin[0];
  p3[1] = BBmax[1];
  p3[2] = BBmax[2]; // top - left - front corner
  mitk::Point3D p4;
  p4[0] = BBmax[0];
  p4[1] = BBmin[1];
  p4[2] = BBmin[2]; // bottom - right - back corner
  mitk::Point3D p5;
  p5[0] = BBmax[0];
  p5[1] = BBmin[1];
  p5[2] = BBmax[2]; // top - right - back corner
  mitk::Point3D p6;
  p6[0] = BBmax[0];
  p6[1] = BBmax[1];
  p6[2] = BBmin[2]; // bottom - right - front corner
  mitk::Point3D p7;
  p7[0] = BBmax[0];
  p7[1] = BBmax[1];
  p7[2] = BBmax[2]; // top - right - front corner

  std::vector<mitk::Point3D> cornerPoints;

  cornerPoints.push_back(geometry->GetIndexToWorldTransform()->TransformPoint(p0));
  cornerPoints.push_back(geometry->GetIndexToWorldTransform()->TransformPoint(p1));
  cornerPoints.push_back(geometry->GetIndexToWorldTransform()->TransformPoint(p2));
  cornerPoints.push_back(geometry->GetIndexToWorldTransform()->TransformPoint(p3));
  cornerPoints.push_back(geometry->GetIndexToWorldTransform()->TransformPoint(p4));
  cornerPoints.push_back(geometry->GetIndexToWorldTransform()->TransformPoint(p5));
  cornerPoints.push_back(geometry->GetIndexToWorldTransform()->TransformPoint(p6));
  cornerPoints.push_back(geometry->GetIndexToWorldTransform()->TransformPoint(p7));

  return cornerPoints;
}