------------------------------------------------------------------------------
| 54 | |
| 55 | //------------------------------------------------------------------------------ |
| 56 | bool vtkExtractBlockUsingDataAssembly::vtkInternals::Execute(vtkPartitionedDataSetCollection* input, |
| 57 | vtkDataAssembly* assembly, const std::vector<vtkSmartPointer<vtkDataAssembly>>& assemblies_to_map, |
| 58 | vtkPartitionedDataSetCollection* output, |
| 59 | std::vector<vtkSmartPointer<vtkDataAssembly>>& mapped_assemblies, |
| 60 | vtkExtractBlockUsingDataAssembly* self) const |
| 61 | { |
| 62 | // get the collection of nodes to extract based on the user specified Selectors |
| 63 | const std::vector<std::string> selectors(this->Selectors.begin(), this->Selectors.end()); |
| 64 | const auto selected_nodes = assembly->SelectNodes(selectors); |
| 65 | |
| 66 | // build the set of dataset (or partitioned dataset indices) to pass |
| 67 | std::set<unsigned int> datasets_to_copy; |
| 68 | for (auto nodeid : selected_nodes) |
| 69 | { |
| 70 | if (self->CheckAbort()) |
| 71 | { |
| 72 | break; |
| 73 | } |
| 74 | const auto datasets = assembly->GetDataSetIndices(nodeid, |
| 75 | /*traverse_subtree=*/self->GetSelectSubtrees()); |
| 76 | datasets_to_copy.insert(datasets.begin(), datasets.end()); |
| 77 | } |
| 78 | |
| 79 | // pass the chosen datasets and build mapping from old index to new. |
| 80 | std::map<unsigned int, unsigned int> output_indices; |
| 81 | for (const auto& in_idx : datasets_to_copy) |
| 82 | { |
| 83 | if (self->CheckAbort()) |
| 84 | { |
| 85 | break; |
| 86 | } |
| 87 | const auto out_idx = output->GetNumberOfPartitionedDataSets(); |
| 88 | output->SetPartitionedDataSet(out_idx, input->GetPartitionedDataSet(in_idx)); |
| 89 | if (input->HasMetaData(in_idx)) |
| 90 | { |
| 91 | output->GetMetaData(out_idx)->Copy(input->GetMetaData(in_idx)); |
| 92 | } |
| 93 | output_indices[in_idx] = out_idx; |
| 94 | } |
| 95 | |
| 96 | vtkNew<vtkDataAssembly> outAssembly; |
| 97 | if (self->GetPruneDataAssembly()) |
| 98 | { |
| 99 | outAssembly->SubsetCopy(assembly, selected_nodes); |
| 100 | } |
| 101 | else |
| 102 | { |
| 103 | outAssembly->DeepCopy(assembly); |
| 104 | } |
| 105 | outAssembly->RemapDataSetIndices(output_indices, /*remove_unmapped=*/true); |
| 106 | output->SetDataAssembly(outAssembly); |
| 107 | |
| 108 | // now map each of the other input assemblies. |
| 109 | for (auto& iAssembly : assemblies_to_map) |
| 110 | { |
| 111 | if (self->CheckAbort()) |
| 112 | { |
| 113 | break; |
no test coverage detected