# Problems Processing Periodic B-Spline Data

I have recently been experimenting with OpenCASCADE's functions for B-Spline curves in order to learn more about computational geometry and to try to understand algorithms used for B-Splines and NURBS curves.

I have done this mostly by plugging in raw data copied from exported files directly into functions from BSplCLib and Geom_BSplineCurve, because I sill haven't figured out which libraries and functions to use to create an instance of Geom_BSplineCurve from an exported IGES file containing a type 126 entity.

If anyone knows the simplest way to do this with OpenCASCADE, could you please tell me?

Unfortunately, I have encountered a problem with periodic curves created by Autodesk Maya and trying to get them to be divided into bezier arcs.

Here is an example of the data of a periodic b-spline curve created in Autodesk Maya. This data is same in both the Maya ASCII file and the exported IGES file.

Degree: 3
Planar, Closed, Polynomial, Periodic
Flat Knots (14):
-0.1,-0.1,-0.05,0.0,1.0,2.0,3.0,4.0,4.05,4.1,4.15,5.15,6.15,6.15
Weights (10):
1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0
Poles (10):
66.2, 0.0, 132.9,
20.0, 0.0, 112.0,
20.0, 0.0, 30.0,
100.0, 0.0, 10.0,
180.0, 0.0, 30.0,
180.0, 0.0, 153.0,
87.6, 0.0, 149.7,
66.2, 0.0, 132.9,
20.0, 0.0, 112.0,
20.0, 0.0, 30.0

There are two main problems with this data.
The first is that according to BSplCLib::NbPoles, the data needs two more poles in order to even be used to make a Geom_BSplineCurve.
The second is that I have to manually figure out which of the two poles out of the ten above need to be replicated in order to reproduce the 7 bezier curves given below after division via GeomConvert_BSplineCurveToBezierCurve.
Below is the data for the bezier curves created by Autodesk Maya after it subdivides the periodic curve above into them:

Curve 1:
Knots: 1,1,1,2,2,2
Poles:
33.3333, 0, 46.6667
46.6667, 0, 23.3333
73.3333, 0, 16.6667
100.0000, 0, 16.6667

Curve 2:
Knots: 2,2,2,3,3,3
Poles:
100.0000, 0, 16.6667
126.6667, 0, 16.6667
153.3333, 0, 23.3333
166.6667, 0, 56.6667

Curve 3:
Knots: 3,3,3,4,4,4
Poles:
166.6667, 0, 56.6667
180.0000, 0, 90.0000
180.0000, 0, 150.0000
100.0000, 0, 150.0000

Curve 4:
Knots: 4,4,4,4.05,4.05,4.05
Poles:
100.0000, 0, 150.0000
96.0000, 0, 150.0000
91.8000, 0, 149.8500
86.1333, 0, 146.9750

Curve 5:
Knots: 4.05,4.05,4.05,4.1,4.1,4.1
Poles:
86.1333, 0, 146.9750
80.4667, 0, 144.1000
73.3333, 0, 138.5000
68.7167, 0, 135.2250

Curve 6:
Knots: 4.1,4.1,4.1,4.15,4.15,4.15
Poles:
68.7167, 0, 135.2250
64.1000, 0, 131.9500
62.0000, 0, 131.0000
60.0000, 0, 130.0000

Curve 7:
Knots: 4.15,4.15,4.15,5.15,5.15,5.15
Poles:
60.0000, 0, 130.0000
20.0000, 0, 110.0000
20.0000, 0, 70.0000
33.3333, 0, 46.6667

After some experimentation with manually editing the pole data for the periodic b-spline curve, the pole data below results in subdivision data that comes close to matching the data given above that was generated by Autodesk Maya:

180.0, 0.0, 153.0,
87.6, 0.0, 149.7,
66.2, 0.0, 132.9,
20.0, 0.0, 112.0,
20.0, 0.0, 30.0,
100.0, 0.0, 10.0,
180.0, 0.0, 30.0,
180.0, 0.0, 153.0,
87.6, 0.0, 149.7,
66.2, 0.0, 132.9,
20.0, 0.0, 112.0,
20.0, 0.0, 30.0

This is the data for the bezier arcs generated by GeomConvert_BSplineCurveToBezierCurve applied to the Geom_BSplineCurve created with the above poles and the knots given at the beginning of this post:

Bezier Curve [1]:
(92, 0, 149.857)
(87.6, 0, 149.7)
(76.9, 0, 141.3)
(70.5, 0, 136.625)
Bezier Curve [2]:
(70.5, 0, 136.625)
(64.1, 0, 131.95)
(62, 0, 131)
(60, 0, 130)
Bezier Curve [3]:
(60, 0, 130)
(20, 0, 110)
(20, 0, 70)
(33.3333, 0, 46.6667)
Bezier Curve [4]:
(33.3333, 0, 46.6667)
(46.6667, 0, 23.3333)
(73.3333, 0, 16.6667)
(100, 0, 16.6667)
Bezier Curve [5]:
(100, 0, 16.6667)
(126.667, 0, 16.6667)
(153.333, 0, 23.3333)
(166.667, 0, 56.6667)
Bezier Curve [6]:
(166.667, 0, 56.6667)
(180, 0, 90)
(180, 0, 150)
(100, 0, 150)
Bezier Curve [7]:
(100, 0, 150)
(96, 0, 150)
(91.8, 0, 149.85)
(86.1333, 0, 146.975)
Bezier Curve [8]:
(86.1333, 0, 146.975)
(80.4667, 0, 144.1)
(73.3333, 0, 138.5)
(68.7167, 0, 135.225)
Bezier Curve [9]:
(68.7167, 0, 135.225)
(64.1, 0, 131.95)
(62, 0, 131)
(60, 0, 130)
Bezier Curve [10]:
(60, 0, 130)
(20, 0, 110)
(20, 0, 70)
(60, 0, 80.75)
Bezier Curve [11]:
(60, 0, 80.75)
(100, 0, 91.5)
(180, 0, 153)
(92, 0, 149.857)

The only problem with this data is that it creates four extra undesired curves, and the curves generated are out of order; curve 3 should follow curve 9.

I have attached an IGES file containing the problematic periodic b-spline curve.

Ulimately, my question is: Is there a function somewhere in OpenCASCADE that can "fix" the poles for an IGES type 126 entity by finding which poles to repeat to get the apparently missing poles, like I had to do manually?
Like some sort of conversion algorithm or something?
Or are all periodic b-spline curves generated by Autodesk Maya basically FUBAR'd to the point that they can't be loaded into an application powered by OpenCASCADE?

Attachments:

Dear Steven,
I successfully imported the provided iges file using Open Cascade API.
You can check it using Draw Harness.
Draw command:
>> igesread TestCurvePeriodic.iges s * , where 's' - name of Draw variable.
The imported shape is valid according OCCT criteria of validity.
See in the attached archive the picture and dump of the imported curve.
Also you may overlook Advanced Data Exchange Components presented at the page