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

Method FindRegion

Filters/General/vtkLoopBooleanPolyDataFilter.cxx:169–263  ·  view source on GitHub ↗

Flood fill algorithm to find region of mesh separated by intersection lines

Source from the content-addressed store, hash-verified

167
168// Flood fill algorithm to find region of mesh separated by intersection lines
169int vtkLoopBooleanPolyDataFilter::Impl::FindRegion(
170 int inputIndex, int fillnumber, int start, int fill)
171{
172 vtkDebugWithObjectMacro(this->ParentFilter, << "Finding region with fill " << fillnumber
173 << " of mesh " << inputIndex << " with cellID "
174 << this->CheckCells->GetId(0));
175
176 // Id List to store neighbor cells for each set of nodes and a cell
177 vtkSmartPointer<vtkIdList> neighbors = vtkSmartPointer<vtkIdList>::New();
178 vtkSmartPointer<vtkIdList> tmp = vtkSmartPointer<vtkIdList>::New();
179
180 vtkIdType numCheckCells;
181 // Get neighboring cell for each pair of points in current cell
182 // While there are still cells to be checked, find neighbor cells
183 while ((numCheckCells = this->CheckCells->GetNumberOfIds()) > 0)
184 {
185 for (int c = 0; c < numCheckCells; c++)
186 {
187 vtkIdType cellId = this->CheckCells->GetId(c);
188 // Get the three points of the cell
189 const vtkIdType* pts = nullptr;
190 vtkIdType npts = 0;
191 this->Mesh[inputIndex]->GetCellPoints(cellId, npts, pts);
192 if (this->Checked[inputIndex][cellId] == 0)
193 {
194 // Mark cell as checked and insert the fillnumber value to cell
195 if (fill)
196 {
197 this->BooleanArray[inputIndex]->InsertValue(cellId, fillnumber);
198 }
199 this->Checked[inputIndex][cellId] = 1;
200 for (int i = 0; i < npts; i++)
201 {
202 vtkIdType p1 = pts[i];
203 // Get the cells attached to each point
204 this->Mesh[inputIndex]->GetPointCells(p1, neighbors);
205 vtkIdType numNeighbors = neighbors->GetNumberOfIds();
206
207 // For each neighboring cell
208 for (int j = 0; j < numNeighbors; j++)
209 {
210 // If this cell is close to a boundary
211 if (this->BoundaryCellArray[inputIndex]->GetValue(neighbors->GetId(j)))
212 {
213 // If this cell hasn't been checked already
214 if (this->CheckedCarefully[inputIndex][neighbors->GetId(j)] == 0)
215 {
216 // Add this cell to the careful check cells list and run
217 // the region finding tip toe code
218 this->CheckCellsCareful->InsertNextId(neighbors->GetId(j));
219 if (fill)
220 {
221 this->FindRegionTipToe(inputIndex, fillnumber, 1);
222 }
223 else
224 {
225 this->FindRegionTipToe(inputIndex, fillnumber, 0);
226 }

Callers 2

GetBooleanRegionsMethod · 0.95
RunLoopTestMethod · 0.95

Calls 10

FindRegionTipToeMethod · 0.95
InsertNextIdMethod · 0.80
NewFunction · 0.50
GetIdMethod · 0.45
GetNumberOfIdsMethod · 0.45
GetCellPointsMethod · 0.45
InsertValueMethod · 0.45
GetPointCellsMethod · 0.45
GetValueMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected