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

Method get_vars

IO/NetCDF/vtkXArrayAccessor.cxx:434–475  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

432}
433
434int vtkXArrayAccessor::get_vars(int vtkNotUsed(ncid), int varid, const size_t* startp,
435 const size_t* countp, const ptrdiff_t* vtkNotUsed(stridep), int vt, vtkIdType numberOfComponents,
436 vtkIdType numberOfTuples, vtkDataArray* dataArray)
437{
438 if (static_cast<size_t>(varid) >= this->Var.size())
439 return NC_ENOTVAR;
440 size_t ndims = this->VarDims[varid].size();
441 if (std::any_of(countp, countp + ndims, [](size_t val) { return val == 0; }))
442 {
443 vtkErrorMacro("Invalid countp: one of the elements is 0");
444 return NC_ERANGE;
445 }
446 char* arrayStart;
447 vtkIdType arraySize;
448 int vtkType = NetCDFTypeToVTKType(this->VarType[varid]);
449 if (vtkType != vt)
450 {
451 vtkErrorMacro("Mismatched VTKType: " << vtkType << ", " << vt);
452 return NC_ERANGE;
453 }
454
455 dataArray->SetNumberOfComponents(numberOfComponents);
456 assert(dataArray->HasStandardMemoryLayout() && "Array must have standard memory layout");
457 if (this->IsContiguous(varid, startp, countp))
458 {
459 this->GetContiguousStartSize(varid, startp, countp, arrayStart, arraySize);
460 if (arraySize != numberOfComponents * numberOfTuples)
461 {
462 vtkErrorMacro(
463 "Mismatch array size: " << arraySize << ", " << (numberOfComponents * numberOfTuples));
464 return NC_ERANGE;
465 }
466 dataArray->SetVoidArray(arrayStart, arraySize, 1);
467 }
468 else
469 {
470 dataArray->SetNumberOfTuples(numberOfTuples); // NOLINTNEXTLINE(bugprone-unsafe-functions)
471 char* dst = static_cast<char*>(dataArray->GetVoidPointer(0));
472 this->Copy(varid, startp, countp, dst);
473 }
474 return NC_NOERR;
475}
476
477int vtkXArrayAccessor::get_vars(int vtkNotUsed(ncid), int varid, const size_t* startp,
478 const size_t* countp, const ptrdiff_t* vtkNotUsed(stridep), void* ip)

Callers 2

LoadVariableMethod · 0.45
NC_get_varsFunction · 0.45

Calls 13

IsContiguousMethod · 0.95
CopyMethod · 0.95
VTKSizeofFunction · 0.85
SetVoidArrayMethod · 0.80
NetCDFTypeToVTKTypeFunction · 0.70
assertFunction · 0.50
copyFunction · 0.50
sizeMethod · 0.45
SetNumberOfComponentsMethod · 0.45
SetNumberOfTuplesMethod · 0.45

Tested by

no test coverage detected