------------------------------------------------------------------------------
| 82 | |
| 83 | //------------------------------------------------------------------------------ |
| 84 | void vtkAbstractInterpolatedVelocityField::Initialize(vtkCompositeDataSet* compDS, int initStrategy) |
| 85 | { |
| 86 | // Clear the datasets info, subclasses may want to put stuff into it. |
| 87 | this->DataSetsInfo.clear(); |
| 88 | |
| 89 | // See whether the subclass should take over the initialization process. |
| 90 | if (this->SelfInitialize()) |
| 91 | { |
| 92 | return; |
| 93 | } |
| 94 | |
| 95 | // Proceed to initialize the composite dataset |
| 96 | this->InitializationState = initStrategy; |
| 97 | |
| 98 | // Obtain this find cell strategy or create the default one as necessary |
| 99 | vtkSmartPointer<vtkFindCellStrategy> strategy = this->FindCellStrategy; |
| 100 | vtkFindCellStrategy* strategyClone; |
| 101 | if (strategy == nullptr) |
| 102 | { |
| 103 | strategy = vtkSmartPointer<vtkClosestPointStrategy>::New(); // default strategy if not provided |
| 104 | } |
| 105 | |
| 106 | // These are the datasets to process from the input to the filter. |
| 107 | auto datasets = vtkCompositeDataSet::GetDataSets(compDS); |
| 108 | |
| 109 | // For each dataset in the list of datasets, make sure a FindCell |
| 110 | // strategy has been defined and initialized. The potential for composite |
| 111 | // datasets which may contain instances of (vtkPointSet) make the process |
| 112 | // more complex. We only care about find cell strategies if the dataset is |
| 113 | // a vtkPointSet because the other dataset types (e.g., volumes) have their |
| 114 | // own built-in FindCell() methods. |
| 115 | vtkDataArray* vectors; |
| 116 | for (auto& dataset : datasets) |
| 117 | { |
| 118 | if (!this->VectorsSelection) // if a selection is not specified, |
| 119 | { |
| 120 | // use the first one in the point set (this is a behavior for backward compatibility) |
| 121 | vectors = dataset->GetPointData()->GetVectors(nullptr); |
| 122 | } |
| 123 | else |
| 124 | { |
| 125 | vectors = |
| 126 | dataset->GetAttributesAsFieldData(this->VectorsType)->GetArray(this->VectorsSelection); |
| 127 | } |
| 128 | |
| 129 | strategyClone = nullptr; |
| 130 | if (vtkPointSet::SafeDownCast(dataset)) |
| 131 | { |
| 132 | strategyClone = strategy->NewInstance(); |
| 133 | } |
| 134 | this->AddToDataSetsInfo(dataset, strategyClone, vectors); |
| 135 | } // for all datasets of composite dataset |
| 136 | |
| 137 | // Now initialize the new strategies |
| 138 | for (auto& datasetInfo : this->DataSetsInfo) |
| 139 | { |
| 140 | if (auto pointSet = vtkPointSet::SafeDownCast(datasetInfo.DataSet)) |
| 141 | { |
no test coverage detected