Commit 8dabd53e authored by Ken Martin's avatar Ken Martin Committed by Kitware Robot

Merge topic 'improve_find_cell'

dfb490ce fix two issues with probing/finding cells
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !5620
parents 0a9fb2bd dfb490ce
Pipeline #138534 running with stage
......@@ -312,7 +312,7 @@ vtkIdType vtkPointSet::FindCell(double x[3], vtkCell *cell,
this->GetPoint(ptId, ptCoord);
VTK_CREATE(vtkIdList, coincidentPtIds);
coincidentPtIds->Allocate(8, 100);
this->Locator->FindPointsWithinRadius(tol2, ptCoord, coincidentPtIds);
this->Locator->FindPointsWithinRadius(sqrt(tol2), ptCoord, coincidentPtIds);
coincidentPtIds->DeleteId(ptId); // Already searched this one.
for (vtkIdType i = 0; i < coincidentPtIds->GetNumberOfIds(); i++)
{
......
......@@ -399,8 +399,30 @@ void vtkProbeFilter::ProbeEmptyPoints(vtkDataSet *input,
char* maskArray = this->MaskPoints->GetPointer(0);
tol2 = this->ComputeTolerance ? VTK_DOUBLE_MAX :
(this->Tolerance * this->Tolerance);
if (this->ComputeTolerance)
{
// to compute a reasonable starting tolerance we use
// a fraction of the largest cell length we come across
// out of the first few cells. Tolerance is meant
// to be an epsilon for cases such as probing 2D
// cells where the XYZ may be a tad off the surface
// but "close enough"
double sLength2 = 0;
for (vtkIdType i = 0; i < 20 && i < source->GetNumberOfCells(); i++)
{
double cLength2 = source->GetCell(i)->GetLength2();
if (sLength2 < cLength2)
{
sLength2 = cLength2;
}
}
// use 1% of the diagonal (1% has to be squared)
tol2 = sLength2 * CELL_TOLERANCE_FACTOR_SQR;
}
else
{
tol2 = (this->Tolerance * this->Tolerance);
}
// vtkPointSet based datasets do not have an implicit structure to their
// points. A cell locator performs better here than using the dataset's
......
......@@ -165,7 +165,7 @@ public:
/**
* Set whether to use the Tolerance field or precompute the tolerance.
* When on, the tolerance will be computed and the field
* value is ignored. Off by default.
* value is ignored. On by default.
*/
vtkSetMacro(ComputeTolerance, bool);
vtkBooleanMacro(ComputeTolerance, bool);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment