------------------------------------------------------------------------------
| 484 | |
| 485 | //------------------------------------------------------------------------------ |
| 486 | void vtkModifiedBSPTree::GenerateRepresentation(int level, vtkPolyData* pd) |
| 487 | { |
| 488 | this->BuildLocator(); |
| 489 | if (this->mRoot == nullptr) |
| 490 | { |
| 491 | return; |
| 492 | } |
| 493 | nodestack ns; |
| 494 | boxlist bl; |
| 495 | BSPNode* node; |
| 496 | ns.push(this->mRoot.get()); |
| 497 | // lets walk the tree and get all the level n node boxes |
| 498 | while (!ns.empty()) |
| 499 | { |
| 500 | node = ns.top(); |
| 501 | ns.pop(); |
| 502 | if (node->depth == level) |
| 503 | { |
| 504 | bl.emplace_back(node->Bounds); |
| 505 | } |
| 506 | else |
| 507 | { |
| 508 | if (node->mChild[0]) |
| 509 | { |
| 510 | ns.push(node->mChild[0]); |
| 511 | if (node->mChild[1]) |
| 512 | { |
| 513 | ns.push(node->mChild[1]); |
| 514 | } |
| 515 | ns.push(node->mChild[2]); |
| 516 | } |
| 517 | else if (level == -1) |
| 518 | { |
| 519 | bl.emplace_back(node->Bounds); |
| 520 | } |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | // Ok, now create cube(oid)s and stuff'em into a polydata thingy |
| 525 | vtkAppendPolyData* polys = vtkAppendPolyData::New(); |
| 526 | size_t s = bl.size(); |
| 527 | for (size_t i = 0; i < s; i++) |
| 528 | { |
| 529 | vtkCubeSource* cube = vtkCubeSource::New(); |
| 530 | cube->SetBounds(bl[i].bounds); |
| 531 | cube->Update(); |
| 532 | polys->AddInputConnection(cube->GetOutputPort()); |
| 533 | cube->Delete(); |
| 534 | } |
| 535 | polys->Update(); |
| 536 | pd->SetPoints(polys->GetOutput()->GetPoints()); |
| 537 | pd->SetPolys(polys->GetOutput()->GetPolys()); |
| 538 | polys->Delete(); |
| 539 | } |
| 540 | |
| 541 | //------------------------------------------------------------------------------ |
| 542 | void vtkModifiedBSPTree::GenerateRepresentationLeafs(vtkPolyData* pd) |