------------------------------------------------------------------------------
| 226 | |
| 227 | //------------------------------------------------------------------------------ |
| 228 | void vtkOctreePointLocator::DivideRegion(vtkOctreePointLocatorNode* node, int* ordering, int level) |
| 229 | { |
| 230 | if (!this->DivideTest(node->GetNumberOfPoints(), level)) |
| 231 | { |
| 232 | return; |
| 233 | } |
| 234 | if (level >= this->Level) |
| 235 | { |
| 236 | this->Level = level + 1; |
| 237 | } |
| 238 | |
| 239 | node->CreateChildNodes(); |
| 240 | int numberOfPoints = node->GetNumberOfPoints(); |
| 241 | vtkDataSet* ds = this->GetDataSet(); |
| 242 | |
| 243 | std::vector<int> points[7]; |
| 244 | int i; |
| 245 | int subOctantNumberOfPoints[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
| 246 | for (i = 0; i < numberOfPoints; i++) |
| 247 | { |
| 248 | int index = node->GetSubOctantIndex(ds->GetPoint(ordering[i]), 0); |
| 249 | if (index) |
| 250 | { |
| 251 | points[index - 1].push_back(ordering[i]); |
| 252 | } |
| 253 | else |
| 254 | { |
| 255 | ordering[subOctantNumberOfPoints[0]] = ordering[i]; |
| 256 | } |
| 257 | subOctantNumberOfPoints[index]++; |
| 258 | } |
| 259 | int counter = 0; |
| 260 | int sizeOfInt = sizeof(int); |
| 261 | for (i = 0; i < 7; i++) |
| 262 | { |
| 263 | counter += subOctantNumberOfPoints[i]; |
| 264 | if (!points[i].empty()) |
| 265 | { |
| 266 | memcpy(ordering + counter, points[i].data(), subOctantNumberOfPoints[i + 1] * sizeOfInt); |
| 267 | } |
| 268 | } |
| 269 | counter = 0; |
| 270 | for (i = 0; i < 8; i++) |
| 271 | { |
| 272 | node->GetChild(i)->SetNumberOfPoints(subOctantNumberOfPoints[i]); |
| 273 | this->DivideRegion(node->GetChild(i), ordering + counter, level + 1); |
| 274 | counter += subOctantNumberOfPoints[i]; |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | //------------------------------------------------------------------------------ |
| 279 | void vtkOctreePointLocator::BuildLocator() |
no test coverage detected