I am building a geometry module to my particle transport program.

Contrary to rendering and visualization, particle transport moves the particle a little bit each time and check if it has crossed the mesh. My question is if I need to load only the triangles close to the particle or should I load all of them.

I build a code that loads only the triangle cells in the boulding box ahead of the particle as an optimization. Is the optimization ok? Should I further optimize the code? Or should I discard all optimizations and let vtk load all triangles?

Thank you

vtkIdList* cellsWithinBounds = FindCellsInBoundingBox(resultPoint, bbdiameter);

```
// Create a list to store intersection distances
std::vector<std::pair<double, vtkIdType>> intersections;
// Process the found cell IDs as needed
for (vtkIdType i = 0; i < cellsWithinBounds->GetNumberOfIds(); ++i)
{
vtkIdType cellId = cellsWithinBounds->GetId(i);
vtkCell* cell = polyData->GetCell(cellId);
if (cell) {
// Access the intersection point
double intersectionPoint[3];
double pcoords[3];
double weights[3];
double tolerance = 1e-6; // Adjust tolerance as needed
// Find the intersection point on the triangle
if (triangle->IntersectWithLine(startPoint, resultPoint, tolerance, intersectionPoint, pcoords, weights)) {
// Calculate the distance between the query point and the intersection point
double distance = vtkMath::Distance2BetweenPoints(startPoint, intersectionPoint);
// Store the distance and cell ID in the list
intersections.emplace_back(distance, currentCellId);
}
}
}
```