| 39 | } |
| 40 | |
| 41 | int vtkMatrixMathFilter::RequestData(vtkInformation* vtkNotUsed(request), |
| 42 | vtkInformationVector** inputVector, vtkInformationVector* outputVector) |
| 43 | { |
| 44 | // get the info objects |
| 45 | vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); |
| 46 | vtkInformation* outInfo = outputVector->GetInformationObject(0); |
| 47 | |
| 48 | // get the input and output |
| 49 | vtkDataSet* in = vtkDataSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); |
| 50 | vtkDataSet* out = vtkDataSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); |
| 51 | |
| 52 | // Copy input to get a start point |
| 53 | out->CopyStructure(in); |
| 54 | |
| 55 | int association = vtkDataObject::FIELD_ASSOCIATION_NONE; |
| 56 | vtkDataArray* inTensors = this->GetInputArrayToProcess(0, inputVector, association); |
| 57 | |
| 58 | bool const pointQuality = vtkDataObject::FIELD_ASSOCIATION_POINTS == association; |
| 59 | bool const cellQuality = vtkDataObject::FIELD_ASSOCIATION_CELLS == association; |
| 60 | if (!pointQuality && !cellQuality) |
| 61 | { |
| 62 | vtkWarningMacro("Unknown association " << association); |
| 63 | return 1; |
| 64 | } |
| 65 | |
| 66 | vtkIdType const nCells = in->GetNumberOfCells(); |
| 67 | vtkIdType const nPoints = in->GetNumberOfPoints(); |
| 68 | if ((pointQuality && 0 == nPoints) || (cellQuality && 0 == nCells)) |
| 69 | { |
| 70 | vtkWarningMacro("No data to work."); |
| 71 | return 1; |
| 72 | } |
| 73 | |
| 74 | // Allocate storage for the computation |
| 75 | vtkSmartPointer<vtkDoubleArray> quality = vtkSmartPointer<vtkDoubleArray>::New(); |
| 76 | // Set different number of component and name depending on the quality |
| 77 | switch (this->GetOperation()) |
| 78 | { |
| 79 | case DETERMINANT: |
| 80 | quality->SetName("Determinant"); |
| 81 | quality->SetNumberOfComponents(1); |
| 82 | break; |
| 83 | case EIGENVALUE: |
| 84 | quality->SetName("Eigenvalue"); |
| 85 | quality->SetNumberOfComponents(3); |
| 86 | break; |
| 87 | case EIGENVECTOR: |
| 88 | quality->SetName("Eigenvector"); |
| 89 | quality->SetNumberOfComponents(9); |
| 90 | break; |
| 91 | case INVERSE: |
| 92 | quality->SetName("Inverse"); |
| 93 | quality->SetNumberOfComponents(9); |
| 94 | break; |
| 95 | default: |
| 96 | vtkWarningMacro("Bad Operation (" << this->GetOperation() << ")"); |
| 97 | return 1; |
| 98 | } |
nothing calls this directly
no test coverage detected