GeomAPI_Interpolate

Hi All,

I'm new with Open Cascade and I am trying to use the GeomAPI_Interpolate class to get an interpolating spline from an array of points.

Unfortunately Standard_OutOfRange Error is always raising after .Perform() method. After trying with my own array of points, I also tried the following simple example to see if the problem were my points' values, but still the same problem occurs.

Can someone please help?

Thank you in advance!

Giuli

-------------------------------

Standard_Integer n = 4;

  Handle(TColgp_HArray1OfPnt) myArr = new TColgp_HArray1OfPnt(0, n - 1);
    myArr->SetValue(0, gp_Pnt(0, 0, 0));
    myArr->SetValue(1, gp_Pnt(10, 0, 0));
    myArr->SetValue(2, gp_Pnt(10, 10, 0));
    myArr->SetValue(3, gp_Pnt(20, 20, 0));

    Standard_Real tol = 1.0e-7;

    GeomAPI_Interpolate intp(myArr, Standard_False, tol);

    intp.Perform();
    Handle(Geom_BSplineCurve) myCurve = intp.Curve();
 

Lincoln Nxumalo's picture

Hi Giuli, I have successfully done that a while back but I don't have the source code in front of me right now. I will check and post it for you later on today if someone else hasn't already helped you by then.

Regards
Lincoln

qa qa's picture

Hi Giuli,

please change

  Handle(TColgp_HArray1OfPnt) myArr = new TColgp_HArray1OfPnt(0, n - 1);

to

Handle(TColgp_HArray1OfPnt) myArr = new TColgp_HArray1OfPnt(1, n);

It seems that there is no handling of arrays starting from 0.  Attached image contains resulting curve.

regards,

qa

Attachments: 
GC's picture

That was it! Thanks a lot for the quick reply and help!

Giuli