For all issues regarding the Forums use, please, refer to the Forum Rules.

### Our Solutions

Need professional assistance?
Consider our:

Need to speed up your development?
Have a look at our:

Need some functionality extending standard OCCT capabilities?
Check out our:

# create periodic curve from points

Forums:

Hi,

I want to create a periodic curve from a list of points. I found the two algorithms GeomAPI_PointsToBSpline and GeomAPI_Interpolate.
I can create a curve with PointsToBSpline but I don't know how to make the curve periodic.
PointsToBSpline offers a parameter to make teh curve periodic, but the algorithm throws an exception when I use it. I don't know how to set the parameters proper. The doxygen documentation gives no further information how to set the parameters right. Any suggestions? How can I create periodic curve from a given list of points?

Best regards

Marco

Dear Marco,
You should use GeomAPI_Interpolate algorithm with PeriodicFlag set to .
In this case the curve will be periodic and closed, the junction point will be
the first point of the table Points. (See comments to the first constructor in
GeomAPI_Interpolate.cdl).

Regards

Hi,

I tried this, but it doesn't work. First I tried it like in the example code:

Handle(TColgp_HArray1OfPnt) ptArr = new TColgp_HArray1OfPnt(0,points.size()-2);
for(unsigned int i = 0;i {
ptArr->SetValue(i,gp_Pnt(points[i].X(),points[i].Y(),points[i].Z()));
}
GeomAPI_Interpolate algo(ptArr,paramArr,Standard_True,0.000001);
algo.Perform();

But in this case the constructor throws an exception. Then I tried to add the parameters:
Handle(TColgp_HArray1OfPnt) ptArr = new TColgp_HArray1OfPnt(0,points.size()-2);
Handle(TColStd_HArray1OfReal) paramArr = new TColStd_HArray1OfReal(0,points.size()-1);
for(unsigned int i = 0;i {
ptArr->SetValue(i,gp_Pnt(points[i].X(),points[i].Y(),points[i].Z()));
paramArr->SetValue(i,distance);

distance += (points[i+1] - points[i]).Length();
}
paramArr->SetValue(points.size()-1,distance);

GeomAPI_Interpolate algo(ptArr,paramArr,Standard_True,0.000001);
algo.Perform();

Now the perform method throws an exception with an emtpy error message string. So I don't know whys it doesn't work.

Best regards

Marco

Dear Marco,
If you have confidence that it is a bug
I would suggested you to register the issue in Mantis BugTracker
available at the development portal - http://dev.opencascade.org.
If the problem is critical for you, you may contact us via the Contact Form -
We will try to find a solution/workaround acceptable for you.
Regards

I created a bug report. The code looks right I think, so I don't know why it should going wrong.

Is there another class which I can use for my goal?

Yes, GeomAPI_PointsToBSpline is a good and robust curve approximation API, but no period option available.
GeomAPI_Interpolate always throw exception when the input point array have too much points, it's not robust as expectation.

Why is GeomAPI_Interpolate there, if is not so robust? Is it a general advise to use GeomAPI_PointsToBSpline instead?