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

Method RecursiveSearch

Common/DataModel/vtkHyperTreeGridGeometricLocator.cxx:89–141  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

87
88//------------------------------------------------------------------------------
89vtkIdType vtkHyperTreeGridGeometricLocator::RecursiveSearch(
90 vtkHyperTreeGridNonOrientedGeometryCursor* cursor, const double pt[3])
91{
92 if (cursor->IsMasked() ||
93 (this->HTG->HasAnyGhostCells() &&
94 this->HTG->GetGhostCells()->GetTuple1(cursor->GetGlobalNodeIndex())))
95 {
96 return -1;
97 }
98 if (this->CheckLeafOrChildrenMasked(cursor))
99 {
100 return cursor->GetGlobalNodeIndex();
101 }
102
103 const double* origin = cursor->GetOrigin();
104 if (origin == nullptr)
105 {
106 vtkErrorMacro("Cursor has no origin");
107 return -1;
108 }
109 const double* size = cursor->GetSize();
110 if (size == nullptr)
111 {
112 vtkErrorMacro("Cursor has no size");
113 return -1;
114 }
115
116 double normalizedPt[3];
117 for (unsigned int d = 0; d < 3; d++)
118 {
119 normalizedPt[d] = (size[d] == 0.0) ? 0.0 : (pt[d] - origin[d]) / size[d];
120 }
121
122 const unsigned int bf = this->HTG->GetBranchFactor();
123 const unsigned int dim = this->HTG->GetDimension();
124 // Reorder the point according to the actual orientation of the HTG.
125 // This is because this->FindChildIndex only process the first dimension
126 // as this make the algorithm easier.
127 if (dim == 1)
128 {
129 std::swap(normalizedPt[0], normalizedPt[this->HTG->GetOrientation()]);
130 }
131 else if (dim == 2)
132 {
133 unsigned int axisx, axisy;
134 this->HTG->Get2DAxes(axisx, axisy);
135 std::swap(normalizedPt[0], normalizedPt[axisx]);
136 std::swap(normalizedPt[1], normalizedPt[axisy]);
137 }
138 vtkIdType childIndex = this->FindChildIndex(dim, bf, normalizedPt);
139 cursor->ToChild(childIndex);
140 return this->RecursiveSearch(cursor, pt);
141}
142
143//------------------------------------------------------------------------------
144vtkIdType vtkHyperTreeGridGeometricLocator::FindCell(const double point[3], double tol,

Callers 1

SearchMethod · 0.95

Calls 13

FindChildIndexMethod · 0.95
GetTuple1Method · 0.80
GetGhostCellsMethod · 0.80
swapFunction · 0.50
IsMaskedMethod · 0.45
HasAnyGhostCellsMethod · 0.45
GetGlobalNodeIndexMethod · 0.45
GetOriginMethod · 0.45
GetSizeMethod · 0.45
GetDimensionMethod · 0.45
GetOrientationMethod · 0.45

Tested by

no test coverage detected