------------------------------------------------------------------------------
| 78 | |
| 79 | //------------------------------------------------------------------------------ |
| 80 | bool vtkAxisAlignedReflectionFilter::ProcessPDC(vtkPartitionedDataSetCollection* inputPDC, |
| 81 | vtkPartitionedDataSetCollection* outputPDC, double bounds[6]) |
| 82 | { |
| 83 | // get the input data assembly or generate one if not present. |
| 84 | vtkNew<vtkDataAssembly> inputAssembly; |
| 85 | if (inputPDC->GetDataAssembly()) |
| 86 | { |
| 87 | inputAssembly->DeepCopy(inputPDC->GetDataAssembly()); |
| 88 | } |
| 89 | else |
| 90 | { |
| 91 | vtkNew<vtkPartitionedDataSetCollection> tempPDC; |
| 92 | if (!vtkDataAssemblyUtilities::GenerateHierarchy(inputPDC, inputAssembly, tempPDC)) |
| 93 | { |
| 94 | vtkErrorMacro("Failed to generate hierarchy for input partitioned dataset collection."); |
| 95 | return false; |
| 96 | } |
| 97 | inputAssembly->DeepCopy(tempPDC->GetDataAssembly()); |
| 98 | } |
| 99 | inputAssembly->SetRootNodeName("Input"); |
| 100 | inputAssembly->SetAttribute(vtkDataAssembly::GetRootNode(), "label", "Input"); |
| 101 | // create a reflection assembly |
| 102 | vtkNew<vtkDataAssembly> reflectionAssembly; |
| 103 | reflectionAssembly->DeepCopy(inputAssembly); |
| 104 | reflectionAssembly->SetRootNodeName("Reflection"); |
| 105 | reflectionAssembly->SetAttribute(vtkDataAssembly::GetRootNode(), "label", "Reflection"); |
| 106 | // create the output data assembly using the input assembly optionally and reflection assembly. |
| 107 | auto outputAssembly = outputPDC->GetDataAssembly(); |
| 108 | outputAssembly->SetRootNodeName("Root"); |
| 109 | outputAssembly->SetAttribute(vtkDataAssembly::GetRootNode(), "label", "Root"); |
| 110 | // append input assembly to output assembly if requested. |
| 111 | if (this->CopyInput) |
| 112 | { |
| 113 | outputAssembly->AddSubtree(vtkDataAssembly::GetRootNode(), inputAssembly); |
| 114 | // shallow copy input to output. |
| 115 | outputPDC->vtkDataObjectTree::ShallowCopy(inputPDC); |
| 116 | } |
| 117 | outputAssembly->AddSubtree(vtkDataAssembly::GetRootNode(), reflectionAssembly); |
| 118 | |
| 119 | // traverse input PDC and process each partitioned dataset. |
| 120 | for (unsigned int i = 0, index = outputPDC->GetNumberOfPartitionedDataSets(); |
| 121 | i < inputPDC->GetNumberOfPartitionedDataSets(); ++i, ++index) |
| 122 | { |
| 123 | if (this->CheckAbort()) |
| 124 | { |
| 125 | break; |
| 126 | } |
| 127 | // reflect each partition in the partitioned dataset. |
| 128 | vtkNew<vtkPartitionedDataSet> outputPDS; |
| 129 | for (unsigned int p = 0; p < inputPDC->GetNumberOfPartitions(i); ++p) |
| 130 | { |
| 131 | auto dObj = inputPDC->GetPartitionAsDataObject(i, p); |
| 132 | if (!dObj) |
| 133 | { |
| 134 | outputPDS->SetPartition(p, nullptr); |
| 135 | continue; |
| 136 | } |
| 137 | auto outputObj = vtk::TakeSmartPointer(dObj->NewInstance()); |
no test coverage detected