[vtkusers] [vtk-developers] vtkThreshold bug

Dean Inglis dean.inglis at camris.ca
Mon Nov 17 12:38:34 EST 2008


Hi Chris,

thanks for clarifying.  I wanted AllScalars to be
off to do what I need.  I was confusing "any" with all.

Dean

On 17-11-08 05:49, Dean Inglis wrote:
>
> there is a bug in vtkThreshold
>
>  
>
> scenario:
>
> AllScalars is on
>
>  
>
>       if (this->AllScalars)
>
>         {
>
>         keepCell = 1;
>
>         for ( i=0; keepCell && (i < numCellPts); i++)
>
>           {
>
>           ptId = cellPts->GetId(i);
>
>           keepCell = this->EvaluateComponents( inScalars, ptId );
>
>           }
>
>         }
>
>  
>
>  
>
> If the first and only point of a cell 
>
> fails the inclusion test but the remaining points do not,
>
> the test for AllScalars will fail since local ivar keepCell is initialized
>
> to 1 before the first test occurs.
>
>  
>
If the first point fails, the loop is only executed once, and at the end 
of it keepCell is set to 0, and the cell is not included. The point of 
AllScalars is that ALL points must pass the test. This is exactly what 
happens, and this is also what the documentation says should happen.
>
> suggested fix:
>
>  
>
>       if (this->AllScalars)
>
>         {
>
>         keepCell = 0;
>
>         for ( i=0; i < numCellPts; i++)
>
>           {
>
>           ptId = cellPts->GetId(i);
>
>           keepCell += this->EvaluateComponents( inScalars, ptId );
>
>           }
>
>         keepCell = (keepCell == 0)?0:1;
>
>         }
>
>  
>
> Are there are any objections to submission of the
>
> above fix.
>
>  
>
>
This makes the AllScalars == 1 case behave just like the AllScalars == 0 
case, except it loops over all cell points instead of stopping when a 
point passing the test is found.

I suggest you just set AllScalars to 0 instead.

- Chris
_______________________________________________
vtk-developers mailing list
vtk-developers at vtk.org
http://www.vtk.org/mailman/listinfo/vtk-developers




More information about the vtkusers mailing list