| 85 | */ |
| 86 | template <typename DataSetT> |
| 87 | bool StructuredExecuteWithBlanking( |
| 88 | DataSetT* input, vtkPolyData* output, vtkDataSetSurfaceFilter* self) |
| 89 | { |
| 90 | if (input == nullptr) |
| 91 | { |
| 92 | return false; |
| 93 | } |
| 94 | |
| 95 | int inExtent[6]; |
| 96 | input->GetExtent(inExtent); |
| 97 | if (vtkStructuredData::GetDataDimension(inExtent) != 3 || !input->HasAnyBlankCells()) |
| 98 | { |
| 99 | // no need to use this logic for non 3D cells or if no blanking is provided. |
| 100 | return false; |
| 101 | } |
| 102 | |
| 103 | vtkLogScopeF(TRACE, "StructuredExecuteWithBlanking (fastMode=%d)", (int)self->GetFastMode()); |
| 104 | vtkNew<vtkPoints> points; |
| 105 | points->Allocate(input->GetNumberOfPoints() / 2); |
| 106 | output->AllocateEstimate(input->GetNumberOfCells(), 4); |
| 107 | output->SetPoints(points); |
| 108 | |
| 109 | // Extracts a either the min (or max) face along the `axis` for the cell |
| 110 | // identified by `cellId` in the input dataset. |
| 111 | auto getFace = [&inExtent](const int ijk[3], const int axis, bool minFace) |
| 112 | { |
| 113 | const int iAxis = (axis + 1) % 3; |
| 114 | const int jAxis = (axis + 2) % 3; |
| 115 | |
| 116 | int ptIjk[3] = { ijk[0], ijk[1], ijk[2] }; |
| 117 | if (!minFace) |
| 118 | { |
| 119 | ++ptIjk[axis]; |
| 120 | } |
| 121 | |
| 122 | std::array<vtkIdType, 4> face; |
| 123 | face[0] = vtkStructuredData::ComputePointIdForExtent(inExtent, ptIjk); |
| 124 | |
| 125 | ++ptIjk[iAxis]; |
| 126 | face[1] = vtkStructuredData::ComputePointIdForExtent(inExtent, ptIjk); |
| 127 | |
| 128 | ++ptIjk[jAxis]; |
| 129 | face[2] = vtkStructuredData::ComputePointIdForExtent(inExtent, ptIjk); |
| 130 | |
| 131 | --ptIjk[iAxis]; |
| 132 | face[3] = vtkStructuredData::ComputePointIdForExtent(inExtent, ptIjk); |
| 133 | |
| 134 | if (minFace) |
| 135 | { |
| 136 | // invert face order to get an outside pointing normal. |
| 137 | return std::array<vtkIdType, 4>({ face[0], face[3], face[2], face[1] }); |
| 138 | } |
| 139 | |
| 140 | return face; |
| 141 | }; |
| 142 | |
| 143 | // Passes data arrays. Also adds `originalIds` the output if `arrayName` |
| 144 | // non-null. |
no test coverage detected