CPnts_AbscissaPoint either inaccurate or slow

Hi,

I have been using CPnts_AbscissaPoint to compute the interpolation parameters of points in certain distances on my curves. The commands were

CPnts_AbscissaPoint pointOnCurveAlgorithm;
pointOnCurveAlgorithm.Init(curve, tolerance);
pointOnCurveAlgorithm.Perform(distance, referenceParameter, tolerance);

Recently I have found out that for some B-spline curves the results may suffer from heavy computation errors. It is visible to the naked eye that for example the computed middle point of a curve is not in the middle.

Fortunately there is also an advanced computation method which leads to the correct results in such cases:

CPnts_AbscissaPoint pointOnCurveAlgorithm;
pointOnCurveAlgorithm.Init(curve, tolerance);
pointOnCurveAlgorithm.AdvPerform(distance, referenceParameter, curve.LastParameter(), tolerance);

But sometimes the method AdvPerform takes excessively more time than the Perform method, even though I set the tolerance to 1.0e-2, which seems not very strict to me.

Does anybody know tricks to speed up this calculation while still keeping its accuracy?

Thank you very much,
Benjamin

Benjamin Bihler's picture

It might be that I have found the answer to my question: the parameter Ui of AdvPerform seems to be a first guess for the solution. I came to this conclusion because of the variable naming in math_FunctionRoot where Ui is passed to. When I give

referenceParameter + distance * (curve.LastParameter() - referenceParameter) / curveLength

as first guess (?) instead of curve.LastParameter(), the method is much quicker and finds the expected solution even in questionable cases.

Can anyone confirm that Ui is a first guess?

To be honest: AdvPerform (and also the Perform method taking an Ui) is really a terribly documented method! Since the Init methods take U1 and U2 and there these parameters seem to be boundaries it is really hard to guess the meaning of Ui! :-(

Forum supervisor's picture

Dear Benjamin,

thank you for your report about AdvPerform.
As you might know, Open CASCADE Technology (OCCT) is a huge library, and it is difficult to keep the description of each and every method up-to-date and detailed. So, we definitely agree that still there are methods that remain poorly documented.
At the same time, we are glad to use this opportunity to remind that OCCT, including its documentation, is available in Open Source.
So we welcome you, as a scrupulous Open Source Community member, to improve OCCT documentation. Please visit http://dev.opencascade.org/index.php?q=home/get_involved where you can read how you could contribute to the improvement of OCCT.
We see that you have already done some investigation on this issue, so we encourage you to share you understanding with us and the whole Open Source Community via updating OCCT documentation.
Thank you once again!

Sincerely,
Forum Supervisor

Benjamin Bihler's picture

Hi!

I really appreciate your great work and the huge list of features of Open CASCADE.

When it comes to documentation I am hesitating a little bit. Let's stay at the AdvPerform example: it SEEMS to me that the paramter Ui is a first guess, but since I am not really sure I have asked the second question here. Does any of the Open CASCADE employees know this exactly (for example because he has implemented these functions himself)? Or would you also have to rely on some code research for completing the documentation.

If the first was the case, then it would be more reliable if you completed the documentation yourself. If the latter was the case, then also the community could do that.

Thank you for your answer.

Benjamin

Forum supervisor's picture

Dear Benjamin,
It is rather the second case. Therefore we suggest to make your changes
(based on your guess), submit the commit and let us review it, accepting or correcting your understanding.
It is just the normal contribution workflow that we advise to all the community, independently of what you are fixing - source code or documentation.

Best regards
Forum Supervisor

Benjamin Bihler's picture

Hi!

I have made another discovery: for some curves that have been created by several calls to the Add method of GeomConvert_CompCurveToBSplineCurve, the CPnts_AbscissaPoint::AdvPerform computation time can be decreased by a factor of about 1.0e5, if the parameter WithRatio of GeomConvert_CompCurveToBSplineCurve::Add is set to Standard_True. Therefore it seems to me as if the CPnts_AbscissaPoint algorithms work much more efficiently, if the parameterization of the curve is more uniform.

Should this be reported as a bug? (I don't think so.)

Should it be documented somewhere? Now it is documented in this forum! Is there another suitable place?

Sincerely,

Benjamin Bihler

Forum supervisor's picture

Dear Benjamin,

The parameter WithRatio of GeomConvert_CompCurveToBSplineCurve::Add is set to Standard_True by default.
So, we don't see here the problem. But we agree that the documentation misses explanation of this parameter.
Naturally it would be nice to document (first) meaning of this parameter and (then) possible implications of its use.
And for this kind of update the usual practice is to register an issue in bug tracker. As you already investigated that point
we suggest you to contribute it in OCCT in a usual way.

Best regards
FSR