MantisBT - Community
View Issue Details
0025024Community[OCCT] OCCT:Foundation Classespublic2014-06-18 22:312014-11-11 12:59
khlebnikov 
bugmaster 
normalcrash 
closedfixed 
WindowsVC++ 201364 bit
[OCCT] 6.7.1 
[OCCT] 6.8.0[OCCT] 6.8.0 
bugs fclasses(002) bug25024
0025024: BSplCLib::PrepareInsertKnots reports incorrect number of poles
When using GeomFill_SectionGenerator I came across a problem which would lead to an exception or incorrect results.
This seems to be due to a bug in BSplCLib::PrepareInsertKnots which returns incorrect number of poles if one of the inserted knots coincides with the last knot of the periodic spline in which the new knots are being inserted to.

It seems that there was some code regarding this problem, but it is commented out. If I uncomment it - the problem still persists.
However if I replace the line 1744 (sigma += amult - mult;) with the following snippet - it works OK in my cases.

---
    Line 1706: (add)
 
    Standard_Integer lastKnotMult = Mults(Knots.Upper());
---
    Line 1744: (replace sigma += amult - mult;)

    if (k == Knots.Upper() && Periodic) {
        lastKnotMult = Min(Degree, mult + 2 * (amult - mult));
        sigma += 2 * lastKnotMult - 2 * Mults(Knots.Lower());
    }
    else {
        sigma += amult - mult;
    }
---
   Line 1782: (replace NbPoles = sigma - Mults(Knots.Upper());)

   NbPoles = sigma - lastKnotMult;
---

In the attachment is a minimal example for the problem (only three simple wires - an ellipse and 2 circles in BSpline form) which when put into the GeomFill_SectionGenerator with AddCurve(BRep_Tool::Curve(edge, first, last)) would fail without and work with my changes.
I'm not sure whether my solution is correct, but it seems to work on many other more complex cases.
Load the wires from the attached files
Add them into GeomFill_SectionGenerator
Call GeomFill_SectionGenerator::Perform(1e-5)
No tags attached.
zip PrepareInsertKnots_Bug.zip (3,066) 2014-06-18 22:31
https://tracker.dev.opencascade.org/
cxx BSplCLib.cxx (137,104) 2014-07-29 16:40
https://tracker.dev.opencascade.org/
? bug25024_wires.brep (7,156) 2014-08-12 10:01
https://tracker.dev.opencascade.org/
Issue History
2014-06-18 22:31khlebnikovNew Issue
2014-06-18 22:31khlebnikovAssigned To => abv
2014-06-18 22:31khlebnikovFile Added: PrepareInsertKnots_Bug.zip
2014-07-29 16:40khlebnikovFile Added: BSplCLib.cxx
2014-07-29 16:42khlebnikovNote Added: 0030474
2014-08-12 10:00abvNote Added: 0030668
2014-08-12 10:00abvStatusnew => assigned
2014-08-12 10:00abvTarget Version => 6.8.0
2014-08-12 10:01abvFile Added: bug25024_wires.brep
2014-08-12 10:01abvNote Edited: 0030668bug_revision_view_page.php?bugnote_id=30668#r7847
2014-08-12 13:20gitNote Added: 0030675
2014-08-12 13:21abvNote Added: 0030676
2014-08-12 13:21abvAssigned Toabv => ifv
2014-08-12 13:21abvStatusassigned => resolved
2014-08-13 13:03gitNote Added: 0030713
2014-08-13 13:04abvNote Added: 0030714
2014-08-14 11:55ifvNote Added: 0030744
2014-08-14 11:55ifvStatusresolved => reviewed
2014-08-15 12:00mkvAssigned Toifv => mkv
2014-08-15 12:31gitNote Added: 0030773
2014-08-18 15:32mkvNote Added: 0030838
2014-08-18 15:32gitNote Added: 0030839
2014-08-18 15:32mkvTest case number => bugs fclasses(002) bug25024
2014-08-18 15:32mkvAssigned Tomkv => bugmaster
2014-08-18 15:32mkvStatusreviewed => tested
2014-08-28 17:45bugmasterAssigned Tobugmaster => abv
2014-08-28 17:45bugmasterStatustested => feedback
2014-09-19 19:32abvAssigned Toabv => bugmaster
2014-09-19 19:32abvStatusfeedback => tested
2014-09-26 14:49bugmasterChangeset attached => occt master c1c03615
2014-09-26 14:49bugmasterStatustested => verified
2014-09-26 14:49bugmasterResolutionopen => fixed
2014-09-30 11:36gitNote Added: 0032412
2014-11-11 12:44aivFixed in Version => 6.8.0
2014-11-11 12:59aivStatusverified => closed

Notes
(0030474)
khlebnikov   
2014-07-29 16:42   
I have added a more proper bugfix - it seems to work flawlessly for me - the fix I proposed originally doesn't work correctly in some cases. The attached file contains the necessary modifications both to PrepareInsertKnots and to InsertKnots. I didn't check it for the case where the "Add" flag is specified as it is of no interest for me now. The fix should be similar to the Add == false case.
(0030668)
abv   
2014-08-12 10:00   
(edited on: 2014-08-12 10:01)
DRAW reproducer:

restore bug25024_wires.brep w
explode w
thrusections r 0 0 w_1 w_2

Note that the problem is caused by wire w_1 when thusection works in "ruled" mode; the command works fine if w_3 is added, but fails again if second '0' is changed to '1' (ruled mode). Another problem with w_1 is that it cannot be displayed in axo viewer, perhaps because of edge range shifted w.r.t. the basis curve range.

(0030675)
git   
2014-08-12 13:20   
Branch CR25024 has been created by abv.

SHA-1: 658ec7243cc0e3b070d33534b03a2396a175b8f8


This branch includes the following new commits:

       new 658ec72 0025024: BSplCLib::PrepareInsertKnots reports incorrect number of poles


Detailed log of new commits:

commit 658ec7243cc0e3b070d33534b03a2396a175b8f8
Author: abv
Date: Tue Aug 12 13:20:08 2014 +0400

    0025024: BSplCLib::PrepareInsertKnots reports incorrect number of poles
(0030676)
abv   
2014-08-12 13:21   
Proposed fix pushed to CR25024, please review
(0030713)
git   
2014-08-13 13:03   
Branch CR25024 has been updated by abv.

SHA-1: c5e8cbdab010f8cb9e92b9275d8c8e0e4a97e78f


      from 658ec72 0025024: BSplCLib::PrepareInsertKnots reports incorrect number of poles
       new c5e8cbd Added test bugs fclasses bug25024


Detailed log of new commits:

commit c5e8cbdab010f8cb9e92b9275d8c8e0e4a97e78f
Author: abv
Date: Wed Aug 13 13:03:25 2014 +0400

    Added test bugs fclasses bug25024

(0030714)
abv   
2014-08-13 13:04   
I have run complete tests with this fix (vc10 x64); no regressions are reported
(0030744)
ifv   
2014-08-14 11:55   
Ok
(0030773)
git   
2014-08-15 12:31   
Branch CR25024 has been updated forcibly by mkv.

SHA-1: 3da1afd014d2a672ffe7a4d6a32971918e253f72
(0030838)
mkv   
2014-08-18 15:32   
Dear BugMaster,

Branch CR25024 from occt git-repository (and master from products git-repository) was compiled on Linux and Windows platforms and tested.
SHA-1: 3da1afd014d2a672ffe7a4d6a32971918e253f72

Number of compiler warnings:

occt component :
Linux: 15 (15 on master)
Windows: 0 (0 on master)

products component :
Linux: 11 (11 on master)
Windows: 1 (1 on master)

Regressions/Differences:
No regressions/differences

Testing cases:
http://occt-tests/CR25024-master-occt/Windows-32-VC10/bugs/fclasses/bug25024.html [^]
bugs fclasses(002) bug25024: OK

Testing on Linux:
Total MEMORY difference: 351937856 / 351893124
Total CPU difference: 47990.08999999982 / 45953.80000000014

Testing on Windows:
Total MEMORY difference: 239618288 / 239728968
Total CPU difference: 33844.015625 / 32650.4375

There are no differences in images found by testdiff.
(0030839)
git   
2014-08-18 15:32   
Branch CR25024 has been updated by mkv.

SHA-1: f9b9c242cfadf6065cc1064ef1f7d95c3e1975b4


      from 3da1afd Added test bugs fclasses bug25024
       new f9b9c24 Test case for issue CR25024


Detailed log of new commits:

commit f9b9c242cfadf6065cc1064ef1f7d95c3e1975b4
Author: mkv
Date: Mon Aug 18 15:30:01 2014 +0400

    Test case for issue CR25024

(0032412)
git   
2014-09-30 11:36   
Branch CR25024 has been deleted by inv.

SHA-1: f9b9c242cfadf6065cc1064ef1f7d95c3e1975b4