| 40 | } |
| 41 | |
| 42 | bool vtkCellGridToUnstructuredGrid::Query::Initialize() |
| 43 | { |
| 44 | this->Superclass::Initialize(); |
| 45 | this->OutputOffsets.clear(); |
| 46 | this->AttributeMap.clear(); |
| 47 | this->ConnectivityCount.clear(); |
| 48 | this->ConnectivityTransforms.clear(); |
| 49 | if (!this->Input || !this->Output) |
| 50 | { |
| 51 | vtkErrorMacro("Input or output grid is null."); |
| 52 | return false; |
| 53 | } |
| 54 | |
| 55 | // Create a new vtkPoints and initialize the point locator. |
| 56 | vtkNew<vtkPoints> points; |
| 57 | vtkNew<vtkCellArray> ugcells; |
| 58 | vtkNew<vtkUnsignedCharArray> ugtypes; |
| 59 | std::array<double, 6> bounds; |
| 60 | points->SetDataTypeToDouble(); |
| 61 | this->Input->GetBounds(bounds.data()); |
| 62 | this->Output->SetPoints(points); |
| 63 | this->Output->SetCells(ugtypes, ugcells); |
| 64 | this->Locator->SetDataSet(this->Output); |
| 65 | this->Locator->InitPointInsertion(points.GetPointer(), bounds.data()); |
| 66 | this->ConnectivityCount.clear(); |
| 67 | this->ConnectivityWeights.clear(); |
| 68 | |
| 69 | this->AttributeMap[this->Input->GetShapeAttribute()] = points->GetData(); |
| 70 | |
| 71 | for (const auto& inputAtt : this->Input->GetCellAttributeList()) |
| 72 | { |
| 73 | if (this->Input->GetShapeAttribute() == inputAtt) |
| 74 | { |
| 75 | continue; |
| 76 | } |
| 77 | |
| 78 | vtkNew<vtkDoubleArray> outputArr; |
| 79 | outputArr->SetName(inputAtt->GetName().Data().c_str()); |
| 80 | outputArr->SetNumberOfComponents(inputAtt->GetNumberOfComponents()); |
| 81 | // Note that we do not allocate memory yet. |
| 82 | this->Output->GetPointData()->AddArray(outputArr); |
| 83 | this->AttributeMap[inputAtt] = outputArr; |
| 84 | } |
| 85 | return true; |
| 86 | } |
| 87 | |
| 88 | void vtkCellGridToUnstructuredGrid::Query::StartPass() |
| 89 | { |
no test coverage detected