View Issue Details

IDProjectCategoryView StatusLast Update
0032649CommunityOCCT:Modeling Algorithmspublic2023-02-03 04:55
Reporterxuzhongxing Assigned Toinv 
PrioritynormalSeveritytrivial 
Status closedResolutionfixed 
PlatformLinuxOSUbuntu 
Product Version7.6.0 
Target Version7.6.1Fixed in Version7.7.0 
Summary0032649: Modeling Algorithms - Bug in BRepLib::EnsureNormalConsistency()
DescriptionA var name typo:
diff --git a/src/BRepLib/BRepLib.cxx b/src/BRepLib/BRepLib.cxx
index 18733f8563..d89ecb4c1f 100644
--- a/src/BRepLib/BRepLib.cxx
+++ b/src/BRepLib/BRepLib.cxx
@@ -2423,7 +2423,7 @@ Standard_Boolean BRepLib::
 
       gp_Vec3f aNorm1f, aNorm2f;
       aPT1->Normal (aFNodF1, aNorm1f);
- aPT1->Normal (aFNodF2, aNorm2f);
+ aPT2->Normal (aFNodF2, aNorm2f);
       const gp_XYZ aNorm1 (aNorm1f.x(), aNorm1f.y(), aNorm1f.z());
       const gp_XYZ aNorm2 (aNorm2f.x(), aNorm2f.y(), aNorm2f.z());
       const Standard_Real aDot = aNorm1 * aNorm2;
Steps To ReproduceNone
TagsNo tags attached.
Test case numberNot required

Attached Files

  • snapshot.png (5,756 bytes)

Relationships

child of 0032133 closedbugmaster Open CASCADE Modeling Data - Restriction of access to internal arrays for Poly_Triangulation, revision of API 

Activities

git

2021-11-04 08:18

administrator   ~0105046

Branch CR0032649 has been created by xuzhongxing.

SHA-1: fccbbbf1500da7fe1554086d2ba316dfe671d06b


Detailed log of new commits:

Author: Xu Zhongxing
Date: Thu Nov 4 13:15:49 2021 +0800

    0032649: Bug in BRepLib::EnsureNormalConsistency()
    
    Fix a typo in variable name.

msv

2021-11-04 18:31

developer   ~0105047

Test job http://jenkins-test-occt/view/CR0032649-master-MSV/view/COMPARE/

msv

2021-11-04 18:33

developer   ~0105048

Hi Xu Zhongxing,
Thank you very much for the registered bug and the patch.

msv

2021-11-04 20:42

developer   ~0105049

For integration:
occt - CR0032649
products - none

kgv

2021-11-08 09:21

developer   ~0105057

Dear Xu,

you have specified the severity of the bug as "crash".
I wonder in which scenario does it crash for you?

Mikhail,
we have just a single test case using command "correctnormals" (bugs/modalg_6/bug27391).
Would it make any sense adding an image dump to it?

msv

2021-11-08 09:50

developer   ~0105058

It has no sense, as the shape in that test is not changed by the command correctnormals. That test case is just to check for no crash in case if polygons on triangulations do not match.

xuzhongxing

2021-11-11 11:08

reporter   ~0105105

Last edited: 2021-11-11 11:11

This bug computes wrong normals. It alone does not necessarily cause crash. Its consequences depend on what the normals are used to do. In some cases, it causes errors in rendering.

But the bug is obvious.

kgv

2021-11-11 11:15

developer   ~0105106

Thanks for clarifying.

xuzhongxing

2021-11-11 11:23

reporter   ~0105107

But I do not think this is trivial. It should be a major bug.

kgv

2021-11-11 11:37

developer   ~0105109

Last edited: 2021-11-11 11:39

> But I do not think this is trivial.
> It should be a major bug.
So far, we do not have a well-defined criteria for bug severity levels.
Most bugs use "minor" level (default) even when impact is pretty high.

BRepLib::EnsureNormalConsistency() is not used (much) in OCCT itself nor in applications that I've seen so far.
I don't even understand yet in which context this function might be / should be used at all.

There are even no test cases for this functionality.
It would be helpful if you would contribute your scenario (e.g. representative model) that could be used for regression testing in future.

xuzhongxing

2021-11-11 11:46

reporter   ~0105111

I spotted it by looking at the image rendered.

I created a simple cube, triangulated it, calculated the normals of triangles with BRepLib::EnsureNormalConsistency(), and rendered it with OpenGL. Then I saw some triangles had wrong lighting. I printed the normals of each triangle and found some of them are wrong.

kgv

2021-11-11 11:55

developer   ~0105113

> I created a simple cube, triangulated it,
> calculated the normals of triangles with BRepLib::EnsureNormalConsistency()
From description, BRepLib::EnsureNormalConsistency() is supposed to correct existing normals, not to create them.
OCCT visualization classes rely on StdPrs_ToolTriangulatedShape::ComputeNormals() for computing normals.

xuzhongxing

2021-11-11 12:18

reporter   ~0105116

Thank you. I will try StdPrs_ToolTriangulatedShape::ComputeNormals().

msv

2021-11-11 13:05

developer   ~0105123

I could reproduce bad visualization after applying the wrong version of EnsureNormalConsistency.
The following script to reproduce:
box a 10 10 10
incmesh a 0.1
correctnormals a
vinit
vdefaults -autotriang 0
vdisplay a
vsetdispmode 1

The result is in the attached picture.

msv

2021-11-11 13:06

developer  

snapshot.png (5,756 bytes)

xuzhongxing

2021-11-11 15:45

reporter   ~0105132

StdPrs_ToolTriangulatedShape::ComputeNormals() works fine. I will use this in my code.

xuzhongxing

2021-11-19 05:00

reporter   ~0105260

Is this ready to be merged?

kgv

2021-11-19 10:04

developer   ~0105263

> Is this ready to be merged?

Patches in REVIEWED state are going to be pushed to the "master" branch within the next integration series (weekly).
https://dev.opencascade.org/doc/overview/html/occt_contribution__contribution_workflow.html#occt_contribution_workflow_integrate

bugmaster

2021-11-21 12:30

administrator   ~0105281

Combination -
OCCT branch : IR-2021-11-19
master SHA - ea0ffd6efe2e05d9764495fa0a877ab75ab5f4e9
49e51745631c52b6c452c65adae4d6dfa21a1b1e
Products branch : IR-2021-11-19 SHA - 24ac02cc67913557271bc70687b86b53e78f9c44
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: 17763.090000000444 / 17742.320000000425 [+0.12%]
Products
Total CPU difference: 11658.550000000125 / 11669.660000000133 [-0.10%]
Windows-64-VC14:
OCCT
Total CPU difference: 19745.71875 / 19762.140625 [-0.08%]
Products
Total CPU difference: 13066.0625 / 12843.21875 [+1.74%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention

git

2021-11-21 13:00

administrator   ~0105296

Branch CR0032649 has been deleted by mnt.

SHA-1: fccbbbf1500da7fe1554086d2ba316dfe671d06b

Related Changesets

occt: master 97e80b8c

2021-11-04 05:15:49

xuzhongxing


Committer: inv Details Diff
0032649: Bug in BRepLib::EnsureNormalConsistency()

Fix a typo in variable name.
Affected Issues
0032649
mod - src/BRepLib/BRepLib.cxx Diff File

Issue History

Date Modified Username Field Change
2021-11-04 08:14 xuzhongxing New Issue
2021-11-04 08:14 xuzhongxing Assigned To => msv
2021-11-04 08:18 git Note Added: 0105046
2021-11-04 18:20 msv Relationship added child of 0032133
2021-11-04 18:27 msv Category OCCT:Modeling Data => OCCT:Modeling Algorithms
2021-11-04 18:27 msv Product Version => 7.6.0
2021-11-04 18:27 msv Target Version => 7.7.0
2021-11-04 18:27 msv Summary Bug in BRepLib::EnsureNormalConsistency() => Modeling Algorithms - Bug in BRepLib::EnsureNormalConsistency()
2021-11-04 18:31 msv Note Added: 0105047
2021-11-04 18:33 msv Note Added: 0105048
2021-11-04 18:35 msv Status new => resolved
2021-11-04 18:35 msv Steps to Reproduce Updated
2021-11-04 20:42 msv Note Added: 0105049
2021-11-04 20:42 msv Assigned To msv => bugmaster
2021-11-04 20:42 msv Status resolved => reviewed
2021-11-08 09:21 kgv Note Added: 0105057
2021-11-08 09:50 msv Note Added: 0105058
2021-11-11 11:08 xuzhongxing Note Added: 0105105
2021-11-11 11:11 xuzhongxing Note Edited: 0105105
2021-11-11 11:15 kgv Severity crash => trivial
2021-11-11 11:15 kgv Note Added: 0105106
2021-11-11 11:23 xuzhongxing Note Added: 0105107
2021-11-11 11:37 kgv Note Added: 0105109
2021-11-11 11:37 kgv Note Edited: 0105109
2021-11-11 11:38 kgv Note Edited: 0105109
2021-11-11 11:39 kgv Note Edited: 0105109
2021-11-11 11:39 kgv Target Version 7.7.0 => 7.6.1
2021-11-11 11:46 xuzhongxing Note Added: 0105111
2021-11-11 11:55 kgv Note Added: 0105113
2021-11-11 12:18 xuzhongxing Note Added: 0105116
2021-11-11 13:05 msv Note Added: 0105123
2021-11-11 13:06 msv File Added: snapshot.png
2021-11-11 15:45 xuzhongxing Note Added: 0105132
2021-11-19 05:00 xuzhongxing Note Added: 0105260
2021-11-19 10:04 kgv Note Added: 0105263
2021-11-21 12:27 bugmaster Status reviewed => tested
2021-11-21 12:30 bugmaster Note Added: 0105281
2021-11-21 12:46 inv Changeset attached => occt master 97e80b8c
2021-11-21 12:46 inv Assigned To bugmaster => inv
2021-11-21 12:46 inv Status tested => verified
2021-11-21 12:46 inv Resolution open => fixed
2021-11-21 13:00 git Note Added: 0105296
2021-11-21 13:51 smoskvin Test case number => Not required
2023-02-03 04:55 vglukhik Status verified => closed
2023-02-03 04:55 vglukhik Fixed in Version => 7.7.0