MCPcopy Create free account
hub / github.com/MITK/MITK / ExecuteOperation

Method ExecuteOperation

Modules/Core/src/DataManagement/mitkPlaneGeometry.cpp:716–783  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

714 }
715
716 void PlaneGeometry::ExecuteOperation(Operation *operation)
717 {
718 vtkTransform *transform = vtkTransform::New();
719 transform->SetMatrix(this->GetVtkMatrix());
720
721 switch (operation->GetOperationType())
722 {
723 case OpORIENT:
724 {
725 auto *planeOp = dynamic_cast<mitk::PlaneOperation *>(operation);
726 if (planeOp == nullptr)
727 {
728 return;
729 }
730
731 Point3D center = planeOp->GetPoint();
732
733 Vector3D orientationVector = planeOp->GetNormal();
734 Vector3D defaultVector;
735 FillVector3D(defaultVector, 0.0, 0.0, 1.0);
736
737 Vector3D rotationAxis = itk::CrossProduct(orientationVector, defaultVector);
738 // double rotationAngle = acos( orientationVector[2] / orientationVector.GetNorm() );
739
740 double rotationAngle = atan2((double)rotationAxis.GetNorm(), (double)(orientationVector * defaultVector));
741 rotationAngle *= 180.0 / vnl_math::pi;
742
743 transform->PostMultiply();
744 transform->Identity();
745 transform->Translate(center[0], center[1], center[2]);
746 transform->RotateWXYZ(rotationAngle, rotationAxis[0], rotationAxis[1], rotationAxis[2]);
747 transform->Translate(-center[0], -center[1], -center[2]);
748 break;
749 }
750 case OpRESTOREPLANEPOSITION:
751 {
752 auto *op = dynamic_cast<mitk::RestorePlanePositionOperation *>(operation);
753 if (op == nullptr)
754 {
755 return;
756 }
757
758 AffineTransform3D::Pointer transform2 = AffineTransform3D::New();
759 Matrix3D matrix;
760 matrix.GetVnlMatrix().set_column(0, op->GetTransform()->GetMatrix().GetVnlMatrix().get_column(0));
761 matrix.GetVnlMatrix().set_column(1, op->GetTransform()->GetMatrix().GetVnlMatrix().get_column(1));
762 matrix.GetVnlMatrix().set_column(2, op->GetTransform()->GetMatrix().GetVnlMatrix().get_column(2));
763 transform2->SetMatrix(matrix);
764 Vector3D offset = op->GetTransform()->GetOffset();
765 transform2->SetOffset(offset);
766
767 this->SetIndexToWorldTransform(transform2);
768 ScalarType bounds[6] = {0, op->GetWidth(), 0, op->GetHeight(), 0, 1};
769 this->SetBounds(bounds);
770 this->Modified();
771 transform->Delete();
772 return;
773 }

Callers

nothing calls this directly

Calls 15

FillVector3DFunction · 0.85
SetMatrixMethod · 0.80
GetOperationTypeMethod · 0.80
GetVnlMatrixMethod · 0.80
GetMatrixMethod · 0.80
GetTransformMethod · 0.80
GetOffsetMethod · 0.80
GetWidthMethod · 0.80
NewFunction · 0.50
GetVtkMatrixMethod · 0.45
GetPointMethod · 0.45
GetNormalMethod · 0.45

Tested by

no test coverage detected