| 3094 | } |
| 3095 | |
| 3096 | int vtkMultiBlockPLOT3DReader::ReadQHeader( |
| 3097 | FILE* fp, bool checkGrid, int& nq, int& nqc, int& overflow) |
| 3098 | { |
| 3099 | int numGrid = this->GetNumberOfBlocksInternal(fp, 0); |
| 3100 | vtkDebugMacro("Q number of grids: " << numGrid); |
| 3101 | if (numGrid == 0) |
| 3102 | { |
| 3103 | return VTK_ERROR; |
| 3104 | } |
| 3105 | |
| 3106 | // If the numbers of grids still do not match, the |
| 3107 | // q file is wrong |
| 3108 | if (checkGrid && numGrid != static_cast<int>(this->Internal->Blocks.size())) |
| 3109 | { |
| 3110 | vtkErrorMacro("The number of grids between the geometry " |
| 3111 | "and the q file do not match."); |
| 3112 | return VTK_ERROR; |
| 3113 | } |
| 3114 | |
| 3115 | int bytes = this->SkipByteCount(fp); |
| 3116 | // If the header contains 2 additional ints, then we assume |
| 3117 | // that this is an Overflow file. |
| 3118 | if (bytes > 0 && bytes == (numGrid * this->Internal->Settings.NumberOfDimensions + 2) * 4) |
| 3119 | { |
| 3120 | overflow = 1; |
| 3121 | } |
| 3122 | else |
| 3123 | { |
| 3124 | overflow = 0; |
| 3125 | } |
| 3126 | for (int i = 0; i < numGrid; i++) |
| 3127 | { |
| 3128 | int n[3]; |
| 3129 | n[2] = 1; |
| 3130 | this->ReadIntBlock(fp, this->Internal->Settings.NumberOfDimensions, n); |
| 3131 | vtkDebugMacro("Q, block " << i << " dimensions: " << n[0] << " " << n[1] << " " << n[2]); |
| 3132 | |
| 3133 | if (checkGrid) |
| 3134 | { |
| 3135 | int* dims = this->Internal->Dimensions[i].Values; |
| 3136 | int extent[6] = { 0, dims[0] - 1, 0, dims[1] - 1, 0, dims[2] - 1 }; |
| 3137 | if (extent[1] != n[0] - 1 || extent[3] != n[1] - 1 || extent[5] != n[2] - 1) |
| 3138 | { |
| 3139 | this->SetErrorCode(vtkErrorCode::FileFormatError); |
| 3140 | vtkErrorMacro("Geometry and data dimensions do not match. " |
| 3141 | "Data file may be corrupt."); |
| 3142 | this->Internal->Blocks[i]->Initialize(); |
| 3143 | return VTK_ERROR; |
| 3144 | } |
| 3145 | } |
| 3146 | } |
| 3147 | if (overflow) |
| 3148 | { |
| 3149 | this->ReadIntBlock(fp, 1, &nq); |
| 3150 | this->ReadIntBlock(fp, 1, &nqc); |
| 3151 | } |
| 3152 | else |
| 3153 | { |
no test coverage detected