DiscussionsIssue archiveOCCT:Visualization

Archived issue #0031848

[REGRESSION] Visualization - MoveTo() triggers exception "gp_Dir() - input vector has zero norm"

CommunityOCCT:Visualizationclosed12 public notes

Search issues

Description

Create a sphere, and then move mouse to the pole points(south or north) will trigger exception "gp_Dir() - input vector has zero norm".

After digging into code, the issue occurs in below function:

gp_Vec (aPnts[aNearestEdgeIdx1], aPnts[aNearestEdgeIdx2]) is a zero vector, which can't be converted to a direction.

Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
                                                         const gp_Pnt& thePnt2,
                                                         const gp_Pnt& thePnt3,
                                                         Select3D_TypeOfSensitivity theSensType,
                                                         const SelectMgr_ViewClipRange& theClipRange,
                                                         SelectBasics_PickResult& thePickResult) const
{

    // BUG: line 716 throw exception: "gp_Dir() - input vector has zero norm"
    // line 716
    if (myViewRayDir.IsParallel (gp_Vec (aPnts[aNearestEdgeIdx1], aPnts[aNearestEdgeIdx2]), Precision::Angular()))
    {
      aNearestEdgeIdx2 = aNearestEdgeIdx1 == 0 ? 2 : aNearestEdgeIdx1 - 1;
    }

}

inline gp_Dir::gp_Dir (const gp_Vec& V)
{
  const gp_XYZ& XYZ = V.XYZ();
  Standard_Real X = XYZ.X();
  Standard_Real Y = XYZ.Y();
  Standard_Real Z = XYZ.Z();
  Standard_Real D = sqrt(X * X + Y * Y + Z * Z);
  Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "gp_Dir() - input vector has zero norm");
  coord.SetX(X / D);
  coord.SetY(Y / D);
  coord.SetZ(Z / D);
}


There is just occur on version 7.5.0 BETA.

Public activity

12 archived notes

Participants are labeled by their role within this record.

01Commenter 2
Vico, while I see the location of the issue, I'm unable to reproduce it with generated sphere.

Could you please attach the sample triangulated model?

02Commenter 3
Branch [archived branch] has been created by Commenter 2.

[revision removed]


Detailed log of new commits:

Author: Commenter 2
Date: Tue Oct 13 14:20:18 2020 +0300

    0031848: [REGRESSION] Visualization - MoveTo() triggers exception "gp_Dir() - input vector has zero norm"
    
    SelectMgr_RectangularFrustum::Overlaps() - added zero magnitude check.
03Author
This issue just occurs on ios release version. It works well on debug. I'm also curious about this issue. The triangulation generated from Prs3d_ToolCylinder and Prs3d_ToolSphere have the issue. I think there might be relation with the triangulation generated.

04Author
I use Select3D_SensitiveTriangulation which build from Prs3d_ToolCylinder and Prs3d_ToolSphere. There must be something changed, since this works well in previous version occt.
05Author
I have attached the Attachment 1 (BREP). Please have a try.
06Commenter 3
Branch [archived branch] has been updated forcibly by Commenter 2.

[revision removed]
07Commenter 2
Vico, if problem is well-reproducible in your environment - could you please verify that patch in CR31848 fixes the issue?

If it happens only in Release builds for iOS, I'm afraid it wouldn't be easy reproducing the same on desktop, as there might be some bias from specific floating point CPU features affecting results. Although it could be possible generating a synthetic data reproducing just specific error.
08Author
I have updated the patch. It works now.
I can see there is a triangle with two coincident vertices from debug trace. But it just occurs on ios.
09Commenter 2
Patch is ready for review
- OCCT branch: [archived branch]

http://jenkins-test-12.nnov.opencascade.com:8080/view/CR31848-master-KGV
10Commenter 10
The patch was reviewed without remarks
11Commenter 1
Combination -
OCCT branch : [archived branch]
master SHA - [revision removed]
[revision removed]
Products branch : [archived branch] SHA - [revision removed]
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Debian80-64:
OCCT
Total CPU difference: 18027.820000000127 / 18057.130000000117 [-0.16%]
Products
Total CPU difference: 12174.330000000093 / 12182.170000000115 [-0.06%]
Windows-64-VC14:
OCCT
Total CPU difference: 19740.03125 / 19746.828125 [-0.03%]
Products
Total CPU difference: 13564.71875 / 13586.625 [-0.16%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention
12Commenter 3
Branch [archived branch] has been deleted by Participant.

[revision removed]