------------------------------------------------------------------------------
| 1019 | |
| 1020 | //------------------------------------------------------------------------------ |
| 1021 | void vtkAlgorithm::SetNumberOfOutputPorts(int n) |
| 1022 | { |
| 1023 | // Sanity check. |
| 1024 | if (n < 0) |
| 1025 | { |
| 1026 | vtkErrorMacro("Attempt to set number of output ports to " << n); |
| 1027 | n = 0; |
| 1028 | } |
| 1029 | |
| 1030 | // We must remove all connections from ports that are removed. |
| 1031 | for (int i = n; i < this->GetNumberOfOutputPorts(); ++i) |
| 1032 | { |
| 1033 | // Get the producer and its output information for this port. |
| 1034 | vtkExecutive* producer = this->GetExecutive(); |
| 1035 | vtkInformation* info = producer->GetOutputInformation(i); |
| 1036 | |
| 1037 | // Remove all consumers' references to this producer on this port. |
| 1038 | vtkExecutive** consumers = vtkExecutive::CONSUMERS()->GetExecutives(info); |
| 1039 | int* consumerPorts = vtkExecutive::CONSUMERS()->GetPorts(info); |
| 1040 | int consumerCount = vtkExecutive::CONSUMERS()->Length(info); |
| 1041 | for (int j = 0; j < consumerCount; ++j) |
| 1042 | { |
| 1043 | vtkInformationVector* inputs = consumers[j]->GetInputInformation(consumerPorts[j]); |
| 1044 | inputs->Remove(info); |
| 1045 | } |
| 1046 | |
| 1047 | // Remove this producer's references to all consumers on this port. |
| 1048 | vtkExecutive::CONSUMERS()->Remove(info); |
| 1049 | } |
| 1050 | |
| 1051 | // Set the number of output port information objects. |
| 1052 | this->OutputPortInformation->SetNumberOfInformationObjects(n); |
| 1053 | |
| 1054 | // Set the number of connection proxy objects. |
| 1055 | this->AlgorithmInternal->Outputs.resize(n); |
| 1056 | } |
| 1057 | |
| 1058 | //------------------------------------------------------------------------------ |
| 1059 | vtkInformation* vtkAlgorithm::GetInputPortInformation(int port) |