DiscussionsIssue archiveOCCT:Modeling Data

Archived issue #0023050

Geom2d_BSplineCurve InsertPoleAfter

CommunityOCCT:Modeling Dataassigned1 public note

Search issues

Description

File Geom2d_BSplineCurve.cxx, line 539.
function InsertPoleAfter(const Standard_Integer Index,
 const gp_Pnt2d& P,
 const Standard_Real Weight) ;

calling this method cause a run time error.
1- at line 561 the for loop:(wrong implementation)
for (i = 1; i < nbknots; i++) {
    newknots (i) = cknots(i);
  }

2- at line 565:(wrong implementation)
newknots (nbknots+1) = 2 * newknots (nbknots) - newknots(nbknots-1);
since newknots just holding a garbage.

3- at line 575:(run time error)
newmults (nbknots+1) = cmults(nbknots+1);
at this line causes a run time error because (cmults size = nbknots) and access
cmults(nbknots+1) makes an error.

Solution:
1- for (i = 1; i <= nbknots; i++) { //changed from < only to <=
    newknots (i) = cknots(i);
  }

2- newknots (nbknots+1) = 2 * cknots (nbknots) - cknots(nbknots-1);
// instead of newknots

3- newmults (nbknots+1) = cmults(nbknots); // instead of +1

Additional information

- I found this bug at November 2011, sorry for delay.
- For method IncreaseDegree at Geom2d_BSplineCurve it calls static method
IncreassDegree from BSplCLib while the BSplCLib cdl file documented that you use this method only for BezierCurve. so what kind of BsplineCurve I need to test that method because it gives run time error sometimes as well or garbage results.
Thanks in advance.

       Author
  

Public activity

1 archived note

Participants are labeled by their role within this record.

01Commenter 1
Note that method InsertPoleAfter() of Geom2d_BSplineCurve is not used anywhere in OCCT; even tests call only corresponding methods of bezier curves (see GeomliteTest_CurveCommands.cxx, command insertpole). Thus we need to extend this command for testing this function, and create a test case, before integrating the fix.

The general question is whether this method is needed for bspline at all. In bezier curves, it adds a pole by increasing degree, and this is the only way to add more degrees of freedom for bezier. In bspline, adding degrees of freedom should be rather achieved by calling InsertKnots().