IsConvex() of "vtkPolyhedron" may give wrong result?

My vtk version is 9.1, C++.
I use vtkUnstructrudeGrid to store my data, and pick one vtkCell from the ugrid, translate to vtkPolyhedron, check if IsConvex().

put an example below, the right result of IsConvex() is true but I got false:

# vtk DataFile Version 5.1
vtk output
ASCII
DATASET UNSTRUCTURED_GRID
POINTS 6 float
-41.6027 0 10.2556 -37.5 0 10.6045 -41.8135 0 13.8533 
-41.6027 4 10.2556 -37.5 4 10.6045 -41.8135 4 13.8533 

CELLS 2 24
OFFSETS vtktypeint64
0 24 
CONNECTIVITY vtktypeint64
5 3 0 1 2 4 0 3 4 
1 4 1 4 5 2 4 0 2 
5 3 3 3 5 4 
CELL_TYPES 1
42


Guess it’s a precision bug

Indeed, it was a bug in the algorithm, and I have fixed it.
The IsConvex() function uses the algorithm from Devillers et al. I learned this algorithm from Determining Convexity of Polyhedra and tried to fix the bug. When determining “the upper face must not be vertical,” one should not use the face center (based on specific points), but should instead rely on the plane itself. Therefore, I modified the code as follows:

    // 3. We get the z component of the normal of the highest face
    //    If this is null, the face is in the vertical plane
    for (int i=0;i<3;++i){
        c0[i] = c0[i]-c[i];
        c1[i] = c1[i]-c[i];
    }
    tmp0 = c0[2]-dot(c0,n)*n[2] > c1[2]-dot(c1,n)*n[2] ? n0[2] : n1[2];
    if (std::abs(tmp0) < eps)
    {
      continue;
    }

The bug can only cause errors if the polyhedron has a vertical face, so it has been well hidden so far

Can your proposed patch be sum up to :

tmp0 = c0p[2]- vtkMath::Dot(c0p,n)*n[2] > c1p[2]-vtkMath::Dot(c1p,n)*n[2] ? n0[2] : n1[2];

Have you submitted a merge request ?

no