MantisBT - Community
View Issue Details
0031848Community[OCCT] OCCT:Visualizationpublic2020-10-13 13:302020-10-24 12:41
Vico Liang 
bugmaster 
normalblock 
verifiedfixed 
[OCCT] 7.5.0 
[OCCT] 7.5.0 
Not required
0031848: [REGRESSION] Visualization - MoveTo() triggers exception "gp_Dir() - input vector has zero norm"
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.
No tags attached.
? sphere.brep (73,864) 2020-10-13 15:59
https://tracker.dev.opencascade.org/
Issue History
2020-10-13 13:30Vico LiangNew Issue
2020-10-13 13:30Vico LiangAssigned To => kgv
2020-10-13 13:31Vico LiangSeverityminor => block
2020-10-13 13:31Vico LiangTarget Version7.6.0* => 7.5.0
2020-10-13 13:31Vico LiangDescription Updatedbug_revision_view_page.php?rev_id=23760#r23760
2020-10-13 13:38kgvProduct Version => 7.5.0
2020-10-13 13:38kgvSummary[REGRESSION] - MoveTo will trigger exception: "gp_Dir() - input vector has zero norm" => [REGRESSION] Visualization - MoveTo triggers exception "gp_Dir() - input vector has zero norm"
2020-10-13 13:38kgvDescription Updatedbug_revision_view_page.php?rev_id=23761#r23761
2020-10-13 13:40kgvRelationship addedchild of 0031412
2020-10-13 13:40kgvSummary[REGRESSION] Visualization - MoveTo triggers exception "gp_Dir() - input vector has zero norm" => [REGRESSION] Visualization - MoveTo() triggers exception "gp_Dir() - input vector has zero norm"
2020-10-13 13:50kgvNote Added: 0095928
2020-10-13 13:50kgvNote Edited: 0095928bug_revision_view_page.php?bugnote_id=95928#r23763
2020-10-13 14:17gitNote Added: 0095929
2020-10-13 14:36Vico LiangNote Added: 0095932
2020-10-13 14:37Vico LiangNote Edited: 0095932bug_revision_view_page.php?bugnote_id=95932#r23766
2020-10-13 15:31Vico LiangNote Added: 0095934
2020-10-13 15:59Vico LiangFile Added: sphere.brep
2020-10-13 16:00Vico LiangNote Added: 0095935
2020-10-13 16:07gitNote Added: 0095936
2020-10-13 16:13kgvNote Added: 0095937
2020-10-13 16:26Vico LiangNote Added: 0095938
2020-10-13 18:59kgvNote Added: 0095942
2020-10-13 18:59kgvAssigned Tokgv => osa
2020-10-13 18:59kgvStatusnew => resolved
2020-10-14 09:14osaNote Added: 0095947
2020-10-14 09:14osaAssigned Toosa => bugmaster
2020-10-14 09:14osaStatusresolved => reviewed
2020-10-17 13:22bugmasterNote Added: 0096032
2020-10-17 13:22bugmasterStatusreviewed => tested
2020-10-17 13:28bugmasterTest case number => Not required
2020-10-17 13:31bugmasterChangeset attached => occt master 6eeb528c
2020-10-17 13:31bugmasterStatustested => verified
2020-10-17 13:31bugmasterResolutionopen => fixed
2020-10-24 12:41gitNote Added: 0096226

Notes
(0095928)
kgv   
2020-10-13 13:50   
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?

(0095929)
git   
2020-10-13 14:17   
Branch CR31848 has been created by kgv.

SHA-1: 930f6e77e645db33a772209e869344a84a00f762


Detailed log of new commits:

Author: kgv
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.
(0095932)
Vico Liang   
2020-10-13 14:36   
(edited on: 2020-10-13 14:37)
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.

(0095934)
Vico Liang   
2020-10-13 15:31   
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.
(0095935)
Vico Liang   
2020-10-13 16:00   
I have attached the sphere.brep. Please have a try.
(0095936)
git   
2020-10-13 16:07   
Branch CR31848 has been updated forcibly by kgv.

SHA-1: 2cc3c0285df5a9bc2901cbb1441a996cb75c3dd0
(0095937)
kgv   
2020-10-13 16:13   
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.
(0095938)
Vico Liang   
2020-10-13 16:26   
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.
(0095942)
kgv   
2020-10-13 18:59   
Patch is ready for review
- OCCT branch: CR31848.

http://jenkins-test-12.nnov.opencascade.com:8080/view/CR31848-master-KGV [^]
(0095947)
osa   
2020-10-14 09:14   
The patch was reviewed without remarks
(0096032)
bugmaster   
2020-10-17 13:22   
Combination -
OCCT branch : IR-2020-10-16
master SHA - ae9f4b64cacf0df612944b3694a3bdfa5f1f29cf
a206de37fbfa0bf71bd534ae47192bbec23b8522
Products branch : IR-2020-10-16 SHA - fcb5abe005e152f7f923f4cf6c02acb07c027cdc
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
(0096226)
git   
2020-10-24 12:41   
Branch CR31848 has been deleted by inv.

SHA-1: 2cc3c0285df5a9bc2901cbb1441a996cb75c3dd0