------------------------------------------------------------------------------
| 122 | |
| 123 | //------------------------------------------------------------------------------ |
| 124 | int vtkGraphAnnotationLayersFilter::RequestData(vtkInformation* vtkNotUsed(request), |
| 125 | vtkInformationVector** inputVector, vtkInformationVector* outputVector) |
| 126 | { |
| 127 | // Get the input and output. |
| 128 | vtkInformation* inGraphInfo = inputVector[0]->GetInformationObject(0); |
| 129 | vtkInformation* inLayersInfo = inputVector[1]->GetInformationObject(0); |
| 130 | |
| 131 | vtkGraph* graph = vtkGraph::SafeDownCast(inGraphInfo->Get(vtkDataObject::DATA_OBJECT())); |
| 132 | vtkPoints* inputPoints = graph->GetPoints(); |
| 133 | vtkAnnotationLayers* layers = |
| 134 | vtkAnnotationLayers::SafeDownCast(inLayersInfo->Get(vtkDataObject::DATA_OBJECT())); |
| 135 | |
| 136 | vtkInformation* outInfo0 = outputVector->GetInformationObject(0); |
| 137 | vtkInformation* outInfo1 = outputVector->GetInformationObject(1); |
| 138 | |
| 139 | vtkPolyData* outputHull = vtkPolyData::SafeDownCast(outInfo0->Get(vtkDataObject::DATA_OBJECT())); |
| 140 | vtkPolyData* outputOutline = |
| 141 | vtkPolyData::SafeDownCast(outInfo1->Get(vtkDataObject::DATA_OBJECT())); |
| 142 | |
| 143 | this->HullAppend->RemoveAllInputs(); |
| 144 | this->OutlineAppend->RemoveAllInputs(); |
| 145 | |
| 146 | unsigned numberOfAnnotations = layers->GetNumberOfAnnotations(); |
| 147 | |
| 148 | // Generate one hull/polydata per selection node |
| 149 | vtkIdType hullId = 0; |
| 150 | for (unsigned annotationId = 0; annotationId < numberOfAnnotations; ++annotationId) |
| 151 | { |
| 152 | vtkAnnotation* annotation = layers->GetAnnotation(annotationId); |
| 153 | if (annotation->GetInformation()->Get(vtkAnnotation::ENABLE()) == 0) |
| 154 | { |
| 155 | continue; |
| 156 | } |
| 157 | |
| 158 | vtkSelection* selection = annotation->GetSelection(); |
| 159 | unsigned numberOfSelectionNodes = selection->GetNumberOfNodes(); |
| 160 | |
| 161 | for (unsigned selectionNodeId = 0; selectionNodeId < numberOfSelectionNodes; ++selectionNodeId) |
| 162 | { |
| 163 | vtkSmartPointer<vtkPoints> hullPoints = vtkSmartPointer<vtkPoints>::New(); |
| 164 | |
| 165 | hullId++; |
| 166 | vtkSelectionNode* selectionNode = selection->GetNode(selectionNodeId); |
| 167 | if (selectionNode->GetFieldType() != vtkSelectionNode::VERTEX) |
| 168 | { |
| 169 | continue; |
| 170 | } |
| 171 | vtkIdTypeArray* vertexIds = |
| 172 | vtkArrayDownCast<vtkIdTypeArray>(selectionNode->GetSelectionList()); |
| 173 | |
| 174 | // Get points from graph |
| 175 | vtkIdType numberOfNodePoints = vertexIds->GetNumberOfTuples(); |
| 176 | if (numberOfNodePoints == 0) |
| 177 | { |
| 178 | continue; |
| 179 | } |
| 180 | for (vtkIdType i = 0; i < numberOfNodePoints; ++i) |
| 181 | { |
nothing calls this directly
no test coverage detected