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

Method IntersectWithLine

Filters/General/vtkOBBTree.cxx:676–901  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Take the passed line segment and intersect it with the OBB cells. This method assumes that the data set is a vtkPolyData that describes a closed surface, and the intersection points that are returned in 'points' alternate between entrance points and exit points. The return value of the function is 0 if no intersection w

Source from the content-addressed store, hash-verified

674// 1 if point 'p1' lies inside the polydata surface, or -1 if point 'p1'
675// lies outside the polydata surface.
676int vtkOBBTree::IntersectWithLine(
677 const double p1[3], const double p2[3], vtkPoints* points, vtkIdList* cellIds)
678{
679 if (this->DataSet == nullptr)
680 {
681 if (points)
682 {
683 points->SetNumberOfPoints(0);
684 }
685 if (cellIds)
686 {
687 cellIds->SetNumberOfIds(0);
688 }
689 return 0;
690 }
691 if (!this->DataSet->IsA("vtkPolyData"))
692 {
693 vtkErrorMacro("IntersectWithLine: this method requires a vtkPolyData");
694 return 0;
695 }
696
697 int rval = 0; // return value for function
698 vtkIdList* cells;
699
700 // temporary list used to sort intersections
701 int listSize = 0;
702 int listMaxSize = 10;
703 double* distanceList = new double[listMaxSize];
704 vtkIdType* cellList = new vtkIdType[listMaxSize];
705 char* senseList = new char[listMaxSize];
706
707 double point[3];
708 double distance = 0;
709 int sense = 0;
710 vtkIdType cellId;
711
712 // compute line vector from p1 to p2
713 double v12[3];
714 v12[0] = p2[0] - p1[0];
715 v12[1] = p2[1] - p1[1];
716 v12[2] = p2[2] - p1[2];
717
718 vtkOBBNode** OBBstack = new vtkOBBNode*[this->GetLevel() + 1];
719 OBBstack[0] = this->Tree;
720
721 // depth counter for stack
722 int depth = 1;
723 while (depth > 0)
724 { // simulate recursion without the overhead or limitations
725 vtkOBBNode* node = OBBstack[--depth];
726
727 // check for intersection with node
728 if (this->LineIntersectsNode(node, p1, p2))
729 {
730 if (node->Kids == nullptr)
731 { // then this is a leaf node...get Cells
732 cells = node->Cells;
733 vtkIdType numCells = cells->GetNumberOfIds();

Callers 10

InsideOrOutsideMethod · 0.95
testIntersectWithLineMethod · 0.45
IsInsideSurfaceMethod · 0.45
operator()Method · 0.45
SeekIntersectingCellsMethod · 0.45
GetInOutCellFunction · 0.45
IntersectCellsMethod · 0.45

Calls 15

LineIntersectsNodeMethod · 0.95
SetNumberOfIdsMethod · 0.80
IsAMethod · 0.80
InsertNextIdMethod · 0.80
sqrtFunction · 0.50
DotFunction · 0.50
SetNumberOfPointsMethod · 0.45
GetLevelMethod · 0.45
GetNumberOfIdsMethod · 0.45
GetIdMethod · 0.45
GetCellTypeMethod · 0.45

Tested by

no test coverage detected