| 438 | } |
| 439 | |
| 440 | vtkIdType vtkStackedTreeLayoutStrategy::FindVertex( |
| 441 | vtkTree* otree, vtkDataArray* array, float pnt[2]) |
| 442 | { |
| 443 | if (this->UseRectangularCoordinates) |
| 444 | { |
| 445 | float blimits[4]; |
| 446 | vtkIdType vertex = otree->GetRoot(); |
| 447 | if (vertex < 0) |
| 448 | { |
| 449 | return vertex; |
| 450 | } |
| 451 | vtkFloatArray* boundsInfo = vtkArrayDownCast<vtkFloatArray>(array); |
| 452 | |
| 453 | // Now try to find the vertex that contains the point |
| 454 | boundsInfo->GetTypedTuple(vertex, blimits); // Get the extents of the root |
| 455 | if (((pnt[1] > blimits[2]) && (pnt[1] < blimits[3])) && |
| 456 | ((pnt[0] > blimits[0]) && (pnt[0] < blimits[1]))) |
| 457 | { |
| 458 | // Point is at the root vertex. |
| 459 | return vertex; |
| 460 | } |
| 461 | |
| 462 | // Now traverse the children to try and find |
| 463 | // the vertex that contains the point |
| 464 | vtkIdType child; |
| 465 | VTK_CREATE(vtkTreeDFSIterator, it); |
| 466 | it->SetTree(otree); |
| 467 | it->SetStartVertex(vertex); |
| 468 | |
| 469 | while (it->HasNext()) |
| 470 | { |
| 471 | child = it->Next(); |
| 472 | boundsInfo->GetTypedTuple(child, blimits); // Get the extents of the child |
| 473 | bool beyond_radial_bounds = false; |
| 474 | bool beyond_angle_bounds = false; |
| 475 | if ((pnt[1] < blimits[2]) || (pnt[1] > blimits[3])) |
| 476 | beyond_radial_bounds = true; |
| 477 | if ((pnt[0] < blimits[0]) || (pnt[0] > blimits[1])) |
| 478 | beyond_angle_bounds = true; |
| 479 | |
| 480 | if (beyond_radial_bounds || beyond_angle_bounds) |
| 481 | { |
| 482 | continue; |
| 483 | } |
| 484 | // If we are here then the point is contained by the child |
| 485 | return child; |
| 486 | } |
| 487 | } |
| 488 | else |
| 489 | { |
| 490 | // Radial layout |
| 491 | float polar_location[2]; |
| 492 | polar_location[0] = sqrt((pnt[0] * pnt[0]) + (pnt[1] * pnt[1])); |
| 493 | polar_location[1] = vtkMath::DegreesFromRadians(atan2(pnt[1], pnt[0])); |
| 494 | if (polar_location[1] < 0) |
| 495 | polar_location[1] += 360.; |
| 496 | |
| 497 | float blimits[4]; |
nothing calls this directly
no test coverage detected