| 78 | //------------------------------------------------------------------------------ |
| 79 | |
| 80 | static void InsertObject(vtkObject* object, std::map<vtkObject*, vtkIdType>& object_map, |
| 81 | vtkMutableDirectedGraph* builder, vtkStringArray* vertex_class_name_array, |
| 82 | vtkVariantArray* vertex_object_array, vtkStringArray* edge_output_port_array, |
| 83 | vtkStringArray* edge_input_port_array, vtkStringArray* edge_class_name_array, |
| 84 | vtkVariantArray* edge_object_array) |
| 85 | { |
| 86 | if (!object) |
| 87 | return; |
| 88 | |
| 89 | if (object_map.count(object)) |
| 90 | return; |
| 91 | |
| 92 | // Insert pipeline algorithms ... |
| 93 | if (vtkAlgorithm* const algorithm = vtkAlgorithm::SafeDownCast(object)) |
| 94 | { |
| 95 | object_map[algorithm] = builder->AddVertex(); |
| 96 | vertex_class_name_array->InsertNextValue(algorithm->GetClassName()); |
| 97 | vertex_object_array->InsertNextValue(algorithm); |
| 98 | |
| 99 | // Recursively insert algorithm inputs ... |
| 100 | for (int i = 0; i != algorithm->GetNumberOfInputPorts(); ++i) |
| 101 | { |
| 102 | for (int j = 0; j != algorithm->GetNumberOfInputConnections(i); ++j) |
| 103 | { |
| 104 | vtkAlgorithm* const input_algorithm = algorithm->GetInputConnection(i, j)->GetProducer(); |
| 105 | InsertObject(input_algorithm, object_map, builder, vertex_class_name_array, |
| 106 | vertex_object_array, edge_output_port_array, edge_input_port_array, edge_class_name_array, |
| 107 | edge_object_array); |
| 108 | |
| 109 | builder->AddEdge(object_map[input_algorithm], object_map[algorithm]); |
| 110 | |
| 111 | vtkDataObject* input_data = |
| 112 | input_algorithm->GetOutputDataObject(algorithm->GetInputConnection(i, j)->GetIndex()); |
| 113 | edge_output_port_array->InsertNextValue( |
| 114 | vtkVariant(algorithm->GetInputConnection(i, j)->GetIndex()).ToString()); |
| 115 | edge_input_port_array->InsertNextValue(vtkVariant(i).ToString()); |
| 116 | edge_class_name_array->InsertNextValue(input_data ? input_data->GetClassName() : ""); |
| 117 | edge_object_array->InsertNextValue(input_data); |
| 118 | } |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | int vtkPipelineGraphSource::RequestData( |
| 124 | vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector) |
no test coverage detected