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

Method IntersectWithLine

Common/DataModel/vtkCellTreeLocator.cxx:684–836  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

682//------------------------------------------------------------------------------
683template <typename T>
684int CellTree<T>::IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t,
685 double x[3], double pcoords[3], int& subId, vtkIdType& cellId, vtkGenericCell* cell)
686{
687 TCellTreeNode *node, *nearNode, *farNode;
688 double tmin, tmax, tDist, tHitCell, tBest = VTK_DOUBLE_MAX, xBest[3], pCoordsBest[3];
689 double rayDir[3], x0[3], x1[3], hitCellBoundsPosition[3];
690 int plane0, plane1, subIdBest = -1;
691 vtkMath::Subtract(p2, p1, rayDir);
692 double* bounds = this->DataBBox;
693 double cellBounds[6], *cellBoundsPtr;
694 cellBoundsPtr = cellBounds;
695 T cId, cellIdBest = -1;
696 cellId = -1;
697
698 // Does ray pass through root BBox
699 if (vtkBox::IntersectWithLine(bounds, p1, p2, tmin, tmax, x0, x1, plane0, plane1) == 0)
700 {
701 return 0; // No intersections possible, line is outside the locator
702 }
703
704 // Initialize intersection query array if necessary. This is done
705 // locally to ensure thread safety.
706 std::vector<bool> cellHasBeenVisited(this->DataSet->GetNumberOfCells(), false);
707
708 // Ok, setup a stack and various params
709 TreeNodeStack ns;
710 // setup our axis optimized ray box edge stuff
711 int axis = vtkCellTree::getDominantAxis(rayDir);
712 double (*_getMinDist)(const double origin[3], const double dir[3], const double B[6]);
713 switch (axis)
714 {
715 case POS_X:
716 _getMinDist = vtkCellTree::_getMinDistPOS_X;
717 break;
718 case NEG_X:
719 _getMinDist = vtkCellTree::_getMinDistNEG_X;
720 break;
721 case POS_Y:
722 _getMinDist = vtkCellTree::_getMinDistPOS_Y;
723 break;
724 case NEG_Y:
725 _getMinDist = vtkCellTree::_getMinDistNEG_Y;
726 break;
727 case POS_Z:
728 _getMinDist = vtkCellTree::_getMinDistPOS_Z;
729 break;
730 default:
731 _getMinDist = vtkCellTree::_getMinDistNEG_Z;
732 break;
733 }
734
735 // OK, lets walk the tree and find intersections
736 TCellTreeNode* n = &this->Nodes.front();
737 ns.push(n);
738 while (!ns.empty())
739 {
740 node = ns.top();
741 ns.pop();

Callers

nothing calls this directly

Calls 15

BuildLocatorMethod · 0.95
IntersectBoxFunction · 0.85
popMethod · 0.80
SetNumberOfIdsMethod · 0.80
SubtractFunction · 0.50
sortFunction · 0.50
GetNumberOfCellsMethod · 0.45
frontMethod · 0.45
pushMethod · 0.45
emptyMethod · 0.45
IsLeafMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected