Another small bug/feature (and it's "hiding")

During the normal vector calculation of a sphere, at the north poles the result is incorrect sometimes:

BRepPrimAPI_MakeSphere S(3);

Eventhough I've increased the deivation the error remained. Finally I've found that, it's related to that, the U,V parameter of the subject point of triangulation is out of the bound (maxu, maxv, minu, minv) and one of the partial derivative is inverted (or sg like that).

Ok, I know, it's an epsilon related question, but i have a fear that, this might occure in other cases as well.

So with a small "hack" the hiding of the actual bug/feature:

In StdPrs_ToolShadedShape::Normal:

if (hasUV && !GS.IsNull()) {
// ...
Standard_Real u1,u2,v1,v2;
GS->Bounds(u1,u2,v1,v2);

const TColgp_Array1OfPnt2d& UVNodes = T->UVNodes();
//if (!S.GetType() == GeomAbs_Plane) { // OCC bug??? gzp
if (S.GetType() != GeomAbs_Plane) {
for (i = UVNodes.Lower(); i U = UVNodes(i).X();
V = UVNodes(i).Y();

U = min(max(U,u1),u2);
V = min(max(V,v1),v2);

//...

Michael Cook's picture

Hi Ernest,

I just noticed the flaw that you mention here. Whenever I try and create a sphere a few facets at one of the poles get inverted. I tried using the ShapeFix_Solid functionality to reorient the faces of the sphere but it doesn't work.

I don't quite understand the fix that you propose here. Could you explain it to me?

Thanks,
Mike