------------------------------------------------------------------------------
| 1066 | |
| 1067 | //------------------------------------------------------------------------------ |
| 1068 | int vtkHyperTreeGridSource::InitializeFromBitsDescriptor() |
| 1069 | { |
| 1070 | // Verify that grid and material specifications are consistent |
| 1071 | if (this->UseMask && !this->LevelZeroMaterialIndex && |
| 1072 | this->MaskBits->GetNumberOfValues() != this->DescriptorBits->GetNumberOfValues()) |
| 1073 | { |
| 1074 | vtkErrorMacro(<< "Material mask is used but has length " << this->MaskBits->GetNumberOfValues() |
| 1075 | << " != " << this->DescriptorBits->GetNumberOfValues() |
| 1076 | << " which is the length of the grid descriptor."); |
| 1077 | |
| 1078 | return 0; |
| 1079 | } |
| 1080 | |
| 1081 | // Calculate total level 0 grid size |
| 1082 | vtkIdType nTotal = 1; |
| 1083 | if (this->LevelZeroMaterialIndex) |
| 1084 | { |
| 1085 | nTotal = static_cast<vtkIdType>(this->LevelZeroMaterialMap.size()); |
| 1086 | } |
| 1087 | else |
| 1088 | { |
| 1089 | for (unsigned int idim = 0; idim < 3; ++idim) |
| 1090 | { |
| 1091 | if (this->Dimensions[idim] != 1) |
| 1092 | { |
| 1093 | nTotal *= static_cast<vtkIdType>(this->Dimensions[idim] - 1); |
| 1094 | } |
| 1095 | } |
| 1096 | } |
| 1097 | |
| 1098 | // Parse descriptor and material mask if used |
| 1099 | this->LevelBitsIndex.clear(); |
| 1100 | this->LevelBitsIndex.push_back(0); |
| 1101 | vtkIdType nRefined = 0; |
| 1102 | vtkIdType nNextLevel = nTotal; |
| 1103 | vtkIdType nCurrentLevelCount = 0; |
| 1104 | vtkIdType descSize = this->DescriptorBits->GetNumberOfTuples(); |
| 1105 | unsigned int nCurrentLevel = this->LevelZeroMaterialIndex ? 1 : 0; |
| 1106 | |
| 1107 | for (vtkIdType i = 0; i < descSize; ++i) |
| 1108 | { |
| 1109 | if (nCurrentLevelCount >= nNextLevel) |
| 1110 | { |
| 1111 | nNextLevel = nRefined * this->BlockSize; |
| 1112 | nRefined = 0; |
| 1113 | nCurrentLevelCount = 0; |
| 1114 | ++nCurrentLevel; |
| 1115 | this->LevelBitsIndex.push_back(i); |
| 1116 | } |
| 1117 | nRefined += this->DescriptorBits->GetValue(i); |
| 1118 | |
| 1119 | ++nCurrentLevelCount; |
| 1120 | } |
| 1121 | |
| 1122 | this->LevelBitsIndexCnt = this->LevelBitsIndex; |
| 1123 | |
| 1124 | // Verify and append last level string |
| 1125 | if (nCurrentLevelCount != nNextLevel) |
no test coverage detected