# GeomAPI_PointsToBSpline: correlation between the number of poles and the number of raw points

Hi All,

I am using GeomAPI_PointsToBSpline to fit a set of 3D points into a b-spline curve and the result looks reasonably well (Thanks to Roman for his comments).  During the process, I found a pretty interesting thing: the number of poles of the resulting b-spline curve is always similar (or equal) to the number of the raw points (keep the rest of the parameters the same for GeomAPI_PointsToBSpline's constructor).  This leads to a problem: the fit b-spline curve would have different set of poles, knots...with different sampling rates of raw data.  For example, for the same nominal curve, I would get two different set of poles, knots..., for the actual curve (fit curve),  when I have 20 or 25 raw points, even if the two actual curves visually look almost identical.

My understanding (my hope) was, if I keep the rest of parameters such as degrees, tolerance, continuity... the same, the shape of the b-spline should be decided by the poles, and if the final shape of the b-spline is similar, the poles should be similar (at least, the number of poles should be the same).  Apparently OCC didn't do that way.   Is this possible to achieve in OCC?

Any suggestions will be greatly appreciated.  Thanks.

Jim Hi Jim,

if you talk about spline interpolation AFAIK you always use all support points - no matter whether you need them or not. An alternative could be curve approximation with GeomLib::BuildCurve3d(...). If you have two spline interpolations that have different support point numbers but are geometrically the same, I guess that their approximation curve should be identical.

Benjamin Hi Benjamin,

Thanks for your comments.  I was talking about spline approximation.  It is definitely reasonable (and expected) that all support points (i.e. the input 3D points I guess) are used during the fitting of a b-spline curve.  What I didn't expect was that the properties such as the poles... of the resulting b-spline are so closely related to the number of the input points when using GeomAPI_PointsToBSpline. In linear algebra, when fitting a set of points into a line, we would get the same (or very similar) linear equation whether you are using 5 or 6 points (let's say we sample the same data twice).  I was hoping to get a similar result when it comes to b-spline fitting of 3D points in OCC.

Can you please elaborate a bit more on how to use GeomLib::BuildCurve3d in this case?

Thanks,

Jim I use it like this:

``````Handle(Geom_BSplineCurve) result;
double maxDeviation;
double averageDeviation;

GeomLib::BuildCurve3d(Precision::Intersection(), curveToApproximate,
curveToApproximate->FirstParameter(), curveToApproximate->LastParameter(),
result, maxDeviation, averageDeviation);

if (result.IsNull())
{
throw Exception("Curve cannot be approximated.", __TRACE__);
}``````

The variable curveToApproximate is the curve to approximate and the variable result will contain the approximation.

Benjamin Thanks, Benjamin.  It seems the raw data was not "curve on surface" in my case.  I will give a try.  Thank you again. Hi Jim,

I am sorry. Just now I have realized that I have proposed a class that is only usable for curves on surfaces.

Still there might a possibility to such a curve approximation like that:

``````GeomConvert_ApproxCurve approximation(curve, Precision::Approximation(), GeomAbs_Shape::GeomAbs_C1, 30, 30);

Handle(Geom_BSplineCurve) result = approximation.Curve();``````

Benjamin