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

Method IntersectWithLine

Filters/FlowPaths/vtkModifiedBSPTree.cxx:598–753  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

596
597//------------------------------------------------------------------------------
598int vtkModifiedBSPTree::IntersectWithLine(const double p1[3], const double p2[3], double tol,
599 double& t, double x[3], double pcoords[3], int& subId, vtkIdType& cellId, vtkGenericCell* cell)
600{
601 this->BuildLocator();
602 if (this->mRoot == nullptr)
603 {
604 return 0;
605 }
606 BSPNode *node, *Near, *Mid, *Far;
607 double tmin, tmax, tDist, tHitCell, tBest = VTK_DOUBLE_MAX, xBest[3], pCoordsBest[3];
608 double rayDir[3], x0[3], x1[3], hitCellBoundsPosition[3], cellBounds[6], *cellBoundsPtr;
609 cellBoundsPtr = cellBounds;
610 int plane1, plane2, subIdBest = -1;
611 vtkMath::Subtract(p2, p1, rayDir);
612 vtkIdType cId, cellIdBest = -1;
613 double* bounds = this->mRoot->Bounds;
614 cellId = -1;
615
616 // Does ray pass through root BBox
617 if (vtkBox::IntersectWithLine(bounds, p1, p2, tmin, tmax, x0, x1, plane1, plane2) == 0)
618 {
619 return false;
620 }
621 std::vector<bool> cellHasBeenVisited(this->DataSet->GetNumberOfCells(), false);
622 // Ok, setup a stack and various params
623 nodestack ns;
624 // setup our axis optimized ray box edge stuff
625 int axis = BSPNode::getDominantAxis(rayDir);
626 double (*_getMinDist)(const double origin[3], const double dir[3], const double B[6]);
627 switch (axis)
628 {
629 case POS_X:
630 _getMinDist = getMinDistPOS_X;
631 break;
632 case NEG_X:
633 _getMinDist = getMinDistNEG_X;
634 break;
635 case POS_Y:
636 _getMinDist = getMinDistPOS_Y;
637 break;
638 case NEG_Y:
639 _getMinDist = getMinDistNEG_Y;
640 break;
641 case POS_Z:
642 _getMinDist = getMinDistPOS_Z;
643 break;
644 default:
645 _getMinDist = getMinDistNEG_Z;
646 break;
647 }
648 // OK, lets walk the tree and find intersections
649 ns.push(this->mRoot.get());
650 while (!ns.empty())
651 {
652 node = ns.top();
653 ns.pop();
654 // We do as few tests on the way down as possible, because our BBoxes
655 // can be quite tight and we want to reject as many boxes as possible without

Callers 3

TestBSPTreeFunction · 0.45

Calls 15

BuildLocatorMethod · 0.95
IntersectBoxFunction · 0.85
popMethod · 0.80
SetNumberOfIdsMethod · 0.80
SubtractFunction · 0.50
sortFunction · 0.50
GetNumberOfCellsMethod · 0.45
pushMethod · 0.45
getMethod · 0.45
emptyMethod · 0.45
ClassifyMethod · 0.45
GetCellBoundsMethod · 0.45

Tested by 2

TestBSPTreeFunction · 0.36