| 15 | namespace |
| 16 | { |
| 17 | bool TestPDC() |
| 18 | { |
| 19 | vtkNew<vtkPartitionedDataSetCollection> pdc; |
| 20 | pdc->Initialize(); |
| 21 | for (int cc = 0; cc < 6; ++cc) |
| 22 | { |
| 23 | vtkNew<vtkPartitionedDataSet> pd; |
| 24 | pdc->SetPartitionedDataSet(cc, pd); |
| 25 | } |
| 26 | |
| 27 | vtkNew<vtkDoubleArray> da; |
| 28 | da->SetName("SomeArray"); |
| 29 | pdc->GetFieldData()->AddArray(da); |
| 30 | |
| 31 | vtkNew<vtkDataAssembly> assembly; |
| 32 | const auto base = assembly->AddNodes({ "blocks", "faces" }); |
| 33 | const auto blocks = assembly->AddNodes({ "b0", "b1" }, base[0]); |
| 34 | const auto faces = assembly->AddNodes({ "f0", "f1" }, base[1]); |
| 35 | assembly->AddDataSetIndices(blocks[0], { 0 }); |
| 36 | assembly->AddDataSetIndices(blocks[1], { 1, 2 }); |
| 37 | assembly->AddDataSetIndices(faces[1], { 3, 4 }); |
| 38 | assembly->AddDataSetIndices(base[1], { 5 }); |
| 39 | pdc->SetDataAssembly(assembly); |
| 40 | |
| 41 | vtkNew<vtkExtractBlockUsingDataAssembly> extractor; |
| 42 | extractor->SetInputDataObject(pdc); |
| 43 | extractor->SetAssemblyName("Assembly"); |
| 44 | extractor->AddSelector("//b0"); |
| 45 | extractor->AddSelector("//faces"); |
| 46 | extractor->Update(); |
| 47 | |
| 48 | auto output = vtkPartitionedDataSetCollection::SafeDownCast(extractor->GetOutputDataObject(0)); |
| 49 | if (output->GetNumberOfPartitionedDataSets() != 4) |
| 50 | { |
| 51 | vtkLogF(ERROR, "Incorrect partitioned-datasets, expected=%d, got=%d!", 4, |
| 52 | static_cast<int>(output->GetNumberOfPartitionedDataSets())); |
| 53 | return false; |
| 54 | } |
| 55 | |
| 56 | if (output->GetPartitionedDataSet(0) != pdc->GetPartitionedDataSet(0) || |
| 57 | output->GetPartitionedDataSet(1) != pdc->GetPartitionedDataSet(3) || |
| 58 | output->GetPartitionedDataSet(2) != pdc->GetPartitionedDataSet(4) || |
| 59 | output->GetPartitionedDataSet(3) != pdc->GetPartitionedDataSet(5)) |
| 60 | { |
| 61 | vtkLogF(ERROR, "Incorrect blocks extracted!"); |
| 62 | return false; |
| 63 | } |
| 64 | |
| 65 | if (!output->GetFieldData()->GetArray("SomeArray")) |
| 66 | { |
| 67 | vtkLogF(ERROR, "Missing field data arrays!"); |
| 68 | return false; |
| 69 | } |
| 70 | |
| 71 | return true; |
| 72 | } |
| 73 | |
| 74 | bool TestAMR() |
no test coverage detected