3D modeling & numerical simulation

### create periodic curve from points

create periodic curve from points
 Marco 2013/02/12 13:09 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
 Forum supervisor 2013/02/12 14:51 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
 Marco 2013/02/15 13:44 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 < points.size()-1;++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 < points.size()-1;++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.Load(t,t);      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
 Forum supervisor 2013/02/15 15:09 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 - http://www.opencascade.org/about/contacts/. We will try to find a solution/workaround acceptable for you. Regards
 Marco 2013/02/20 10:50 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?
 Cauchy Ding 2013/09/17 11:17 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.
 Benjamin Bihler 2014/02/21 14:28 Why is GeomAPI_Interpolate there, if is not so robust? Is it a general advise to use GeomAPI_PointsToBSpline instead?