| 194 | } |
| 195 | |
| 196 | std::vector<SeedT> ExtractSliceFromSeed(const vtkVector3d& seed, |
| 197 | const std::vector<vtkVector3d>& dirs, BlockT* b, const diy::Master::ProxyWithLink&) |
| 198 | { |
| 199 | auto sg = b->Input; |
| 200 | assert(vtkStructuredData::GetDataDescriptionFromExtent(sg->GetExtent()) == |
| 201 | vtkStructuredData::VTK_STRUCTURED_XYZ_GRID); |
| 202 | |
| 203 | const vtkIdType cellid = b->CellLocator->FindCell(const_cast<double*>(seed.GetData())); |
| 204 | if (cellid <= 0) |
| 205 | { |
| 206 | return std::vector<SeedT>(); |
| 207 | } |
| 208 | |
| 209 | // okay, we've determined that the seed lies in this block's grid. now we need to determine the |
| 210 | // voi to extract based on the propagation directions provided. |
| 211 | |
| 212 | // using the cell's orientation, first determine which ijk axes the propagation directions |
| 213 | // correspond to. |
| 214 | auto cell_vectors = ::GetCellOrientationVectors(b->Input->GetCell(cellid)); |
| 215 | int propagation_mask[3] = { 0, 0, 0 }; |
| 216 | for (const auto& dir : dirs) |
| 217 | { |
| 218 | assert(dir.SquaredNorm() != 0); |
| 219 | |
| 220 | double max = 0.0; |
| 221 | int axis = -1; |
| 222 | for (int cc = 0; cc < 3; ++cc) |
| 223 | { |
| 224 | const auto dot = std::abs(dir.Dot(cell_vectors[cc])); |
| 225 | if (dot > max) |
| 226 | { |
| 227 | max = dot; |
| 228 | axis = cc; |
| 229 | } |
| 230 | } |
| 231 | if (axis != -1) |
| 232 | { |
| 233 | propagation_mask[axis] = 1; |
| 234 | } |
| 235 | } |
| 236 | assert(std::accumulate(propagation_mask, propagation_mask + 3, 0) < 3); |
| 237 | |
| 238 | int ijk[3]; |
| 239 | vtkStructuredData::ComputeCellStructuredCoordsForExtent(cellid, sg->GetExtent(), ijk); |
| 240 | |
| 241 | const auto voi = ComputeVOI(sg, ijk, propagation_mask); |
| 242 | if (b->Regions.find(voi) != b->Regions.end()) |
| 243 | { |
| 244 | return std::vector<SeedT>(); |
| 245 | } |
| 246 | |
| 247 | b->Regions.insert(voi); |
| 248 | |
| 249 | vtkVector<int, 6> cell_voi; |
| 250 | vtkStructuredData::GetCellExtentFromPointExtent(voi.GetData(), cell_voi.GetData()); |
| 251 | |
| 252 | std::vector<SeedT> next_seeds; |
| 253 | for (int axis = 0; axis < 3; ++axis) |
no test coverage detected