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

Method CoverExtent

IO/Parallel/vtkPDataSetReader.cxx:1130–1230  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1128
1129//------------------------------------------------------------------------------
1130void vtkPDataSetReader::CoverExtent(int ext[6], int* pieceMask)
1131{
1132 int bestArea;
1133 int area;
1134 int best;
1135 int cExt[6]; // Covered
1136 int rExt[6]; // Remainder piece
1137 int i, j;
1138
1139 // Pick the piece with the largest coverage.
1140 // Greedy search should be good enough.
1141 best = -1;
1142 bestArea = 0;
1143 for (i = 0; i < this->NumberOfPieces; ++i)
1144 {
1145 // Compute coverage.
1146 area = 1;
1147 for (j = 0; j < 3; ++j)
1148 { // Intersection of piece and extent to cover.
1149 cExt[j * 2] = ext[j * 2];
1150 if (this->PieceExtents[i][j * 2] > ext[j * 2])
1151 {
1152 cExt[j * 2] = this->PieceExtents[i][j * 2];
1153 }
1154 cExt[j * 2 + 1] = ext[j * 2 + 1];
1155 if (this->PieceExtents[i][j * 2 + 1] < ext[j * 2 + 1])
1156 {
1157 cExt[j * 2 + 1] = this->PieceExtents[i][j * 2 + 1];
1158 }
1159 // Compute the area for cells.
1160 if (cExt[j * 2] >= cExt[j * 2 + 1])
1161 {
1162 area = 0;
1163 }
1164 else
1165 {
1166 area *= (cExt[j * 2 + 1] - cExt[j * 2]);
1167 }
1168 }
1169 if (area > bestArea)
1170 {
1171 bestArea = area;
1172 best = i;
1173 }
1174 }
1175
1176 // It could happen if pieces do not have complete coverage.
1177 if (bestArea <= 0)
1178 {
1179 vtkErrorMacro("Incomplete coverage.");
1180 return;
1181 }
1182
1183 // Mark the chosen piece in the mask.
1184 pieceMask[best] = 1;
1185
1186 // Now recompute the coverage for the chosen piece.
1187 i = best;

Callers 2

ImageDataExecuteMethod · 0.95
StructuredGridExecuteMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected