Commit dfb490ce authored by Ken Martin's avatar Ken Martin

fix two issues with probing/finding cells

First issue is that a tolerance squared was being passed
into a function needing distance. Needed a sqrt.
The second issue is that the default computed tolerance for
the proble filter was absurd and wasn't computed at all
just hardcoded to max double which causes numerous overflows
and incorrect behavior. Changed the logic to look at some
actual cells and compute a tolerance from them.
parent ae29d26a
......@@ -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 = (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