Skip to content
Snippets Groups Projects
Commit 2d477d62 authored by Dan Lipsa's avatar Dan Lipsa
Browse files

Deal with 0 dimensions

parent 29d5db76
No related branches found
No related tags found
No related merge requests found
......@@ -299,7 +299,11 @@ int vtkNetCDFReader::RequestInformation(vtkInformation* vtkNotUsed(request),
for (int i = 0; i < 3; i++)
{
this->WholeExtent[2 * i] = 0;
if (i < this->LoadingDimensions->GetNumberOfTuples())
vtkIdType ndims = this->LoadingDimensions->GetNumberOfTuples();
// if there are 0 dimensions
// generate an empty image with (0, -1, 0 -1, 0, -1)
int maxExtent = ndims > 0 ? 0 : -1;
if (i < ndims)
{
size_t dimlength;
// Remember that netCDF arrays are indexed backward from VTK images.
......@@ -312,7 +316,7 @@ int vtkNetCDFReader::RequestInformation(vtkInformation* vtkNotUsed(request),
}
else
{
this->WholeExtent[2 * i + 1] = 0;
this->WholeExtent[2 * i + 1] = maxExtent;
}
}
vtkDebugMacro(<< "Whole extents: " << this->WholeExtent[0] << ", " << this->WholeExtent[1] << ", "
......
......@@ -323,9 +323,9 @@ void vtkXArrayAccessor::PrintVarValue(
bool vtkXArrayAccessor::IsContiguous(int varid, const size_t* startp, const size_t* countp)
{
// the last dim is the most rapidly varying
size_t ndims = this->VarDims[varid].size();
size_t contiguousDims = 0;
for (int i = static_cast<int>(ndims - 1); i >= 0; --i)
int ndims = static_cast<int>(this->VarDims[varid].size());
int contiguousDims = 0;
for (int i = ndims - 1; i >= 0; --i)
{
if (startp[i] == 0 && countp[i] == this->DimLen[this->VarDims[varid][i]])
{
......@@ -343,11 +343,14 @@ std::vector<size_t> vtkXArrayAccessor::GetDimIncrement(int varid)
{
size_t ndims = this->VarDims[varid].size();
std::vector<size_t> dimIncrement;
dimIncrement.resize(ndims);
dimIncrement[ndims - 1] = 1;
for (size_t i = ndims - 1; i >= 1; --i)
if (ndims > 0)
{
dimIncrement[i - 1] = dimIncrement[i] * this->DimLen[this->VarDims[varid][i]];
dimIncrement.resize(ndims);
dimIncrement[ndims - 1] = 1;
for (size_t i = ndims - 1; i >= 1; --i)
{
dimIncrement[i - 1] = dimIncrement[i] * this->DimLen[this->VarDims[varid][i]];
}
}
return dimIncrement;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment