------------------------------------------------------------------------------
| 76 | |
| 77 | //------------------------------------------------------------------------------ |
| 78 | int vtkAddMembershipArray::RequestData( |
| 79 | vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector* outputVector) |
| 80 | { |
| 81 | vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); |
| 82 | vtkDataObject* input = inInfo->Get(vtkDataObject::DATA_OBJECT()); |
| 83 | vtkSelection* inputSelection = vtkSelection::GetData(inputVector[1]); |
| 84 | vtkAnnotationLayers* inputAnnotations = vtkAnnotationLayers::GetData(inputVector[2]); |
| 85 | vtkInformation* outputInfo = outputVector->GetInformationObject(0); |
| 86 | vtkDataObject* output = outputInfo->Get(vtkDataObject::DATA_OBJECT()); |
| 87 | vtkGraph* graph = vtkGraph::SafeDownCast(output); |
| 88 | vtkTable* table = vtkTable::SafeDownCast(output); |
| 89 | |
| 90 | output->ShallowCopy(input); |
| 91 | |
| 92 | if (!inputSelection) |
| 93 | { |
| 94 | if (!this->InputArrayName || !this->InputValues) |
| 95 | return 1; |
| 96 | |
| 97 | vtkDataSetAttributes* ds = nullptr; |
| 98 | switch (this->FieldType) |
| 99 | { |
| 100 | case vtkAddMembershipArray::VERTEX_DATA: |
| 101 | if (graph) |
| 102 | { |
| 103 | ds = graph->GetVertexData(); |
| 104 | } |
| 105 | break; |
| 106 | case vtkAddMembershipArray::EDGE_DATA: |
| 107 | if (graph) |
| 108 | { |
| 109 | ds = graph->GetEdgeData(); |
| 110 | } |
| 111 | break; |
| 112 | case vtkAddMembershipArray::ROW_DATA: |
| 113 | if (table) |
| 114 | { |
| 115 | ds = table->GetRowData(); |
| 116 | } |
| 117 | break; |
| 118 | } |
| 119 | |
| 120 | if (!ds) |
| 121 | { |
| 122 | vtkErrorMacro("Unsupported input field type."); |
| 123 | return 0; |
| 124 | } |
| 125 | |
| 126 | vtkIntArray* vals = vtkIntArray::New(); |
| 127 | vals->SetNumberOfTuples(ds->GetNumberOfTuples()); |
| 128 | vals->SetNumberOfComponents(1); |
| 129 | vals->SetName(this->OutputArrayName); |
| 130 | vals->FillComponent(0, 0); |
| 131 | |
| 132 | vtkAbstractArray* inputArray = ds->GetAbstractArray(this->InputArrayName); |
| 133 | if (inputArray && this->InputValues) |
| 134 | { |
| 135 | for (vtkIdType i = 0; i < inputArray->GetNumberOfTuples(); ++i) |
nothing calls this directly
no test coverage detected