MCPcopy Create free account
hub / github.com/Kitware/VTK / ExtractSliceFromSeed

Function ExtractSliceFromSeed

Filters/ParallelDIY2/vtkExtractSubsetWithSeed.cxx:196–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196std::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)

Callers 1

RequestDataMethod · 0.85

Calls 15

ComputeVOIFunction · 0.85
GetFaceCenterFunction · 0.85
GetPropagationVectorsFunction · 0.85
assertFunction · 0.50
absFunction · 0.50
GetExtentMethod · 0.45
FindCellMethod · 0.45
GetDataMethod · 0.45
GetCellMethod · 0.45
DotMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected