------------------------------------------------------------------------------
| 93 | |
| 94 | //------------------------------------------------------------------------------ |
| 95 | int vtkPointsMatchingTransformFilter::RequestData(vtkInformation* vtkNotUsed(request), |
| 96 | vtkInformationVector** inputVector, vtkInformationVector* outputVector) |
| 97 | { |
| 98 | vtkSmartPointer<vtkPointSet> input = vtkPointSet::GetData(inputVector[0]); |
| 99 | vtkSmartPointer<vtkPointSet> output = vtkPointSet::GetData(outputVector); |
| 100 | if (!input) |
| 101 | { |
| 102 | vtkErrorMacro(<< "Invalid or missing input"); |
| 103 | return 0; |
| 104 | } |
| 105 | |
| 106 | // Build transform matrix |
| 107 | vtkNew<vtkMatrix4x4> srcInv; |
| 108 | srcInv->DeepCopy(this->SourceMatrix); |
| 109 | if (std::abs(srcInv->Determinant()) < 10e-4) |
| 110 | { |
| 111 | vtkWarningMacro("Source matrix is not invertible. Source points are likely coplanar."); |
| 112 | output->ShallowCopy(input); |
| 113 | return 1; |
| 114 | } |
| 115 | srcInv->Invert(); |
| 116 | vtkNew<vtkMatrix4x4> transformMatrix; |
| 117 | vtkMatrix4x4::Multiply4x4(this->TargetMatrix, srcInv, transformMatrix); |
| 118 | |
| 119 | if (this->RigidTransform) |
| 120 | { |
| 121 | vtkSmartPointer<vtkMatrix3x3> rotation = ::ExtractRotationFromMatrix4x4(transformMatrix); |
| 122 | rotation = ::PolarDecomposition(rotation); |
| 123 | ::SetRotationInMatrix4x4(rotation, transformMatrix); |
| 124 | } |
| 125 | |
| 126 | // Apply the transform |
| 127 | vtkNew<vtkTransform> transform; |
| 128 | transform->SetMatrix(transformMatrix); |
| 129 | vtkNew<vtkTransformFilter> transformFilter; |
| 130 | transformFilter->SetInputData(input); |
| 131 | transformFilter->SetTransform(transform); |
| 132 | transformFilter->Update(); |
| 133 | |
| 134 | output->ShallowCopy(transformFilter->GetOutput()); |
| 135 | return 1; |
| 136 | } |
| 137 | |
| 138 | //------------------------------------------------------------------------------ |
| 139 | void vtkPointsMatchingTransformFilter::SetSourcePoint1(double x, double y, double z) |
nothing calls this directly
no test coverage detected