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

Method FindPoint

Common/DataModel/vtkImageData.cxx:312–354  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

310
311//------------------------------------------------------------------------------
312vtkIdType vtkImageData::FindPoint(double x[3])
313{
314 //
315 // Ensure valid spacing
316 //
317 const double* spacing = this->Spacing;
318 vtkIdType dims[3];
319 this->GetDimensions(dims);
320 std::string ijkLabels[3] = { "I", "J", "K" };
321 for (int i = 0; i < 3; i++)
322 {
323 if (spacing[i] == 0.0 && dims[i] > 1)
324 {
325 vtkWarningMacro("Spacing along the " << ijkLabels[i] << " axis is 0.");
326 return -1;
327 }
328 }
329
330 //
331 // Compute the ijk location
332 //
333 const int* extent = this->GetExtent();
334 int loc[3];
335 double ijk[3];
336 this->TransformPhysicalPointToContinuousIndex(x, ijk);
337 loc[0] = vtkMath::Floor(ijk[0] + 0.5);
338 loc[1] = vtkMath::Floor(ijk[1] + 0.5);
339 loc[2] = vtkMath::Floor(ijk[2] + 0.5);
340 if (loc[0] < extent[0] || loc[0] > extent[1] || loc[1] < extent[2] || loc[1] > extent[3] ||
341 loc[2] < extent[4] || loc[2] > extent[5])
342 {
343 return -1;
344 }
345 // since point id is relative to the first point actually stored
346 loc[0] -= extent[0];
347 loc[1] -= extent[2];
348 loc[2] -= extent[4];
349
350 //
351 // From this location get the point id
352 //
353 return loc[2] * dims[0] * dims[1] + loc[1] * dims[0] + loc[0];
354}
355
356//------------------------------------------------------------------------------
357vtkIdType vtkImageData::FindCell(double x[3], vtkCell* vtkNotUsed(cell),

Callers

nothing calls this directly

Calls 3

GetDimensionsMethod · 0.45
GetExtentMethod · 0.45

Tested by

no test coverage detected