------------------------------------------------------------------------------
| 1159 | |
| 1160 | //------------------------------------------------------------------------------ |
| 1161 | int vtkKdTree::SelectCutDirection(vtkKdNode* kd) |
| 1162 | { |
| 1163 | int dim = 0, i; |
| 1164 | |
| 1165 | int xdir = 1 << vtkKdTree::XDIM; |
| 1166 | int ydir = 1 << vtkKdTree::YDIM; |
| 1167 | int zdir = 1 << vtkKdTree::ZDIM; |
| 1168 | |
| 1169 | // determine direction in which to divide this region |
| 1170 | |
| 1171 | if (this->ValidDirections == xdir) |
| 1172 | { |
| 1173 | dim = vtkKdTree::XDIM; |
| 1174 | } |
| 1175 | else if (this->ValidDirections == ydir) |
| 1176 | { |
| 1177 | dim = vtkKdTree::YDIM; |
| 1178 | } |
| 1179 | else if (this->ValidDirections == zdir) |
| 1180 | { |
| 1181 | dim = vtkKdTree::ZDIM; |
| 1182 | } |
| 1183 | else |
| 1184 | { |
| 1185 | // divide in the longest direction, for more compact regions |
| 1186 | |
| 1187 | double diff[3], dataBounds[6], maxdiff; |
| 1188 | kd->GetDataBounds(dataBounds); |
| 1189 | |
| 1190 | for (i = 0; i < 3; i++) |
| 1191 | { |
| 1192 | diff[i] = dataBounds[i * 2 + 1] - dataBounds[i * 2]; |
| 1193 | } |
| 1194 | |
| 1195 | maxdiff = -1.0; |
| 1196 | |
| 1197 | if ((this->ValidDirections & xdir) && (diff[vtkKdTree::XDIM] > maxdiff)) |
| 1198 | { |
| 1199 | dim = vtkKdTree::XDIM; |
| 1200 | maxdiff = diff[vtkKdTree::XDIM]; |
| 1201 | } |
| 1202 | |
| 1203 | if ((this->ValidDirections & ydir) && (diff[vtkKdTree::YDIM] > maxdiff)) |
| 1204 | { |
| 1205 | dim = vtkKdTree::YDIM; |
| 1206 | maxdiff = diff[vtkKdTree::YDIM]; |
| 1207 | } |
| 1208 | |
| 1209 | if ((this->ValidDirections & zdir) && (diff[vtkKdTree::ZDIM] > maxdiff)) |
| 1210 | { |
| 1211 | dim = vtkKdTree::ZDIM; |
| 1212 | } |
| 1213 | } |
| 1214 | return dim; |
| 1215 | } |
| 1216 | |
| 1217 | //------------------------------------------------------------------------------ |
| 1218 | int vtkKdTree::DivideTest(int size, int level) |
no test coverage detected