MCPcopy Create free account
hub / github.com/Kitware/VTK / Execute

Method Execute

Filters/Extraction/vtkExtractBlockUsingDataAssembly.cxx:56–121  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

54
55//------------------------------------------------------------------------------
56bool 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;

Callers 1

RequestDataMethod · 0.45

Calls 15

SelectNodesMethod · 0.80
CheckAbortMethod · 0.80
GetDataSetIndicesMethod · 0.80
SetPartitionedDataSetMethod · 0.80
GetPartitionedDataSetMethod · 0.80
SubsetCopyMethod · 0.80
RemapDataSetIndicesMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
HasMetaDataMethod · 0.45

Tested by

no test coverage detected