------------------------------------------------------------------------------
| 508 | |
| 509 | //------------------------------------------------------------------------------ |
| 510 | vtkExtractSelection::EvaluationResult vtkExtractSelection::EvaluateSelection( |
| 511 | vtkDataObject* dataObject, vtkDataObject::AttributeTypes association, vtkSelection* selection, |
| 512 | std::map<std::string, vtkSmartPointer<vtkSelector>>& selectors) |
| 513 | { |
| 514 | auto fieldData = dataObject->GetAttributes(association); |
| 515 | if (!fieldData) |
| 516 | { |
| 517 | return EvaluationResult::NONE; |
| 518 | } |
| 519 | |
| 520 | // Iterate over operators and set up a map from selection node name to insidedness |
| 521 | // array. |
| 522 | std::map<std::string, vtkSignedCharArray*> arrayMap; |
| 523 | for (const auto& nodeSelector : selectors) |
| 524 | { |
| 525 | auto name = nodeSelector.first; |
| 526 | auto insidednessArray = vtkSignedCharArray::SafeDownCast(fieldData->GetArray(name.c_str())); |
| 527 | auto node = selection->GetNode(name); |
| 528 | if (insidednessArray != nullptr && node->GetProperties()->Has(vtkSelectionNode::INVERSE()) && |
| 529 | node->GetProperties()->Get(vtkSelectionNode::INVERSE())) |
| 530 | { |
| 531 | ::InvertSelection(insidednessArray); |
| 532 | } |
| 533 | arrayMap[name] = insidednessArray; |
| 534 | } |
| 535 | |
| 536 | // Evaluate the map of insidedness arrays |
| 537 | std::array<signed char, 2> range; |
| 538 | auto blockInsidedness = selection->Evaluate(arrayMap, range); |
| 539 | if (blockInsidedness) |
| 540 | { |
| 541 | blockInsidedness->SetName("__vtkInsidedness__"); |
| 542 | if (range[0] == 0 && range[1] == 0) |
| 543 | { |
| 544 | return EvaluationResult::NONE; |
| 545 | } |
| 546 | else if (range[0] == 1 && range[1] == 1) |
| 547 | { |
| 548 | fieldData->AddArray(blockInsidedness); |
| 549 | return EvaluationResult::ALL; |
| 550 | } |
| 551 | else |
| 552 | { |
| 553 | fieldData->AddArray(blockInsidedness); |
| 554 | return EvaluationResult::MIXED; |
| 555 | } |
| 556 | } |
| 557 | else |
| 558 | { |
| 559 | return EvaluationResult::INVALID; |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | //------------------------------------------------------------------------------ |
| 564 | vtkSmartPointer<vtkUnsignedCharArray> vtkExtractSelection::EvaluateColorArrayInSelection( |
no test coverage detected