MCPcopy Create free account
hub / github.com/Kitware/VTK / RequestData

Method RequestData

Infovis/Core/vtkExtractSelectedGraph.cxx:120–444  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

118
119//------------------------------------------------------------------------------
120int vtkExtractSelectedGraph::RequestData(vtkInformation* vtkNotUsed(request),
121 vtkInformationVector** inputVector, vtkInformationVector* outputVector)
122{
123 vtkGraph* input = vtkGraph::GetData(inputVector[0]);
124 vtkSelection* inputSelection = vtkSelection::GetData(inputVector[1]);
125 vtkAnnotationLayers* inputAnnotations = vtkAnnotationLayers::GetData(inputVector[2]);
126 vtkGraph* output = vtkGraph::GetData(outputVector);
127
128 if (!inputSelection && !inputAnnotations)
129 {
130 vtkErrorMacro("No vtkSelection or vtkAnnotationLayers provided as input.");
131 return 0;
132 }
133
134 vtkSmartPointer<vtkSelection> selection = vtkSmartPointer<vtkSelection>::New();
135 int numSelections = 0;
136 if (inputSelection)
137 {
138 selection->DeepCopy(inputSelection);
139 numSelections++;
140 }
141
142 // If input annotations are provided, extract their selections only if
143 // they are enabled and not hidden.
144 if (inputAnnotations)
145 {
146 for (unsigned int i = 0; i < inputAnnotations->GetNumberOfAnnotations(); ++i)
147 {
148 vtkAnnotation* a = inputAnnotations->GetAnnotation(i);
149 if ((a->GetInformation()->Has(vtkAnnotation::ENABLE()) &&
150 a->GetInformation()->Get(vtkAnnotation::ENABLE()) == 0) ||
151 (a->GetInformation()->Has(vtkAnnotation::ENABLE()) &&
152 a->GetInformation()->Get(vtkAnnotation::ENABLE()) == 1 &&
153 a->GetInformation()->Has(vtkAnnotation::HIDE()) &&
154 a->GetInformation()->Get(vtkAnnotation::HIDE()) == 1))
155 {
156 continue;
157 }
158 selection->Union(a->GetSelection());
159 numSelections++;
160 }
161 }
162
163 // Handle case where there was no input selection and no enabled, non-hidden
164 // annotations
165 if (numSelections == 0)
166 {
167 output->ShallowCopy(input);
168 return 1;
169 }
170
171 // Convert the selection to an INDICES selection
172 vtkSmartPointer<vtkSelection> converted;
173 converted.TakeReference(vtkConvertSelection::ToIndexSelection(selection, input));
174 if (!converted)
175 {
176 vtkErrorMacro("Selection conversion to INDICES failed.");
177 return 0;

Callers

nothing calls this directly

Calls 15

GetSelectionListMethod · 0.80
GetNumberOfVerticesMethod · 0.80
GetVertexDataMethod · 0.80
GetEdgeDataMethod · 0.80
GetSourceVertexMethod · 0.80
GetTargetVertexMethod · 0.80
SetEdgePointsMethod · 0.80
GetDataFunction · 0.50
NewFunction · 0.50
DeepCopyMethod · 0.45
GetAnnotationMethod · 0.45

Tested by

no test coverage detected