------------------------------------------------------------------------------
| 77 | |
| 78 | //------------------------------------------------------------------------------ |
| 79 | int vtkImageDataToUniformGrid::RequestData( |
| 80 | vtkInformation*, vtkInformationVector**, vtkInformationVector* outV) |
| 81 | { |
| 82 | vtkDataObject* input = this->GetInput(); |
| 83 | vtkInformation* outInfo = outV->GetInformationObject(0); |
| 84 | vtkDataObject* output = outInfo->Get(vtkDataObject::DATA_OBJECT()); |
| 85 | |
| 86 | vtkInformation* inArrayInfo = this->GetInputArrayInformation(0); |
| 87 | if (!inArrayInfo) |
| 88 | { |
| 89 | vtkErrorMacro("Problem getting array to process."); |
| 90 | return 0; |
| 91 | } |
| 92 | int association = -1; |
| 93 | if (!inArrayInfo->Has(vtkDataObject::FIELD_ASSOCIATION())) |
| 94 | { |
| 95 | vtkErrorMacro("Unable to query field association for the scalar."); |
| 96 | return 0; |
| 97 | } |
| 98 | association = inArrayInfo->Get(vtkDataObject::FIELD_ASSOCIATION()); |
| 99 | |
| 100 | const char* arrayName = inArrayInfo->Get(vtkDataObject::FIELD_NAME()); |
| 101 | if (!arrayName) |
| 102 | { |
| 103 | vtkErrorMacro("Problem getting array name to process."); |
| 104 | return 0; |
| 105 | } |
| 106 | |
| 107 | if (vtkImageData* inImageData = vtkImageData::SafeDownCast(input)) |
| 108 | { |
| 109 | return this->Process(inImageData, association, arrayName, vtkUniformGrid::SafeDownCast(output)); |
| 110 | } |
| 111 | vtkDataObjectTree* inMB = vtkDataObjectTree::SafeDownCast(input); |
| 112 | vtkDataObjectTree* outMB = vtkDataObjectTree::SafeDownCast(output); |
| 113 | outMB->CopyStructure(inMB); |
| 114 | vtkDataObjectTreeIterator* iter = inMB->NewTreeIterator(); |
| 115 | iter->VisitOnlyLeavesOn(); |
| 116 | iter->TraverseSubTreeOn(); |
| 117 | for (iter->GoToFirstItem(); !iter->IsDoneWithTraversal(); iter->GoToNextItem()) |
| 118 | { |
| 119 | if (this->CheckAbort()) |
| 120 | { |
| 121 | break; |
| 122 | } |
| 123 | if (vtkImageData* inImageData = vtkImageData::SafeDownCast(iter->GetCurrentDataObject())) |
| 124 | { |
| 125 | vtkNew<vtkUniformGrid> outUniformGrid; |
| 126 | if (this->Process(inImageData, association, arrayName, outUniformGrid) != VTK_OK) |
| 127 | { |
| 128 | iter->Delete(); |
| 129 | return VTK_ERROR; |
| 130 | } |
| 131 | outMB->SetDataSetFrom(iter, outUniformGrid); |
| 132 | } |
| 133 | else |
| 134 | { // not a uniform grid so we just shallow copy from input to output |
| 135 | outMB->SetDataSetFrom(iter, iter->GetCurrentDataObject()); |
| 136 | } |
nothing calls this directly
no test coverage detected