------------------------------------------------------------------------------
| 509 | |
| 510 | //------------------------------------------------------------------------------ |
| 511 | int vtkConvertSelection::Convert(vtkSelection* input, vtkDataObject* data, vtkSelection* output) |
| 512 | { |
| 513 | unsigned int checkAbortInterval = |
| 514 | std::min(input->GetNumberOfNodes() / 10 + 1, (unsigned int)1000); |
| 515 | for (unsigned int n = 0; n < input->GetNumberOfNodes(); ++n) |
| 516 | { |
| 517 | if (n % checkAbortInterval == 0 && this->CheckAbort()) |
| 518 | { |
| 519 | break; |
| 520 | } |
| 521 | vtkSelectionNode* inputNode = input->GetNode(n); |
| 522 | vtkNew<vtkSelectionNode> outputNode; |
| 523 | |
| 524 | outputNode->ShallowCopy(inputNode); |
| 525 | outputNode->SetContentType(this->OutputType); |
| 526 | |
| 527 | // If it is the same type, we are done |
| 528 | if (inputNode->GetContentType() != vtkSelectionNode::VALUES && |
| 529 | inputNode->GetContentType() != vtkSelectionNode::THRESHOLDS && |
| 530 | inputNode->GetContentType() == this->OutputType) |
| 531 | { |
| 532 | output->Union(outputNode); |
| 533 | continue; |
| 534 | } |
| 535 | |
| 536 | // If the input is a values or thresholds selection, we need array names |
| 537 | // on the selection arrays to perform the selection. |
| 538 | if (inputNode->GetContentType() == vtkSelectionNode::VALUES || |
| 539 | inputNode->GetContentType() == vtkSelectionNode::THRESHOLDS) |
| 540 | { |
| 541 | vtkFieldData* selData = inputNode->GetSelectionData(); |
| 542 | for (int i = 0; i < selData->GetNumberOfArrays(); i++) |
| 543 | { |
| 544 | if (!selData->GetAbstractArray(i)->GetName()) |
| 545 | { |
| 546 | vtkErrorMacro("Array name must be specified for values or thresholds selection."); |
| 547 | return 0; |
| 548 | } |
| 549 | } |
| 550 | } |
| 551 | |
| 552 | // If the output is a threshold selection, we need exactly one array name. |
| 553 | if (this->OutputType == vtkSelectionNode::THRESHOLDS && |
| 554 | (this->ArrayNames == nullptr || this->ArrayNames->GetNumberOfValues() != 1)) |
| 555 | { |
| 556 | vtkErrorMacro("One array name must be specified for thresholds selection."); |
| 557 | return 0; |
| 558 | } |
| 559 | |
| 560 | // If the output is a values selection, we need at lease one array name. |
| 561 | if (this->OutputType == vtkSelectionNode::VALUES && |
| 562 | (this->ArrayNames == nullptr || this->ArrayNames->GetNumberOfValues() == 0)) |
| 563 | { |
| 564 | vtkErrorMacro("At least one array name must be specified for values selection."); |
| 565 | return 0; |
| 566 | } |
| 567 | |
| 568 | // If we are converting a thresholds or values selection to |
no test coverage detected