Understanding documentation on interpolation/CRV_BSPLINE

Hello,

I would like to be able to reproduce (at least approximatly) the result of MakeInterpol from the information given by geompy.KindOfShape(), I was looking to get back the x,y,z of each of the points used to create originally the interpolation, but the returning of KindOfShape() eventhought in the documentation looks like it should return the xi,yi,zi (doc) the return of it does not give anything like it:


geompy = geomBuilder.New()

v0 = geompy.MakeVertex(0, 0, 0)
v1 = geompy.MakeVertex(100, 0, 50)
v2 = geompy.MakeVertex(2000, 0, 0)

interpolation = geompy.MakeInterpol([v0, v1, v2], False, False)
beizer = geompy.MakeBezier([v0, v1, v2], False)

interpolationInf=geompy.KindOfShape(interpolation)
beizerInf=geompy.KindOfShape(beizer)

with beizerInf i am getting the expected result:

[CRV_BEZIER, 3, 0, 0.0, 0.0, 0.0, 100.0, 0.0, 50.0, 2000.0, 0.0, 0.0]

but for interpolation I am getting a return values that i am not understanding:
[CRV_BSPLINE, 0, 2, 3, 2, 0, 2, 0.0, 0.0, 0.0, 894.1176470588235, 0.0, 476.4705882352941, 2000.0, 0.0, 0.0, 0.0, 2012.4611797498108, 3, 3]

what I am looking to get back is the coordinates of v0,v1,v2 that in bezier i am getting it but for spline no.

Hello,

According to the GEOM module documentation, the format returned for a B-Spline is:

CRV_BSPLINE: [periodicity degree nb_poles nb_knots nb_weights nb_multiplicities xi yi zi ki wi mi]

So, to extract the information you’re looking for (the poles’ coordinates), you can simply do something like:

info = geompy.KindOfShape(interpolation)
# Example: [CRV_BSPLINE, 0, 2, 3, 2, 0, 2, 0.0, 0.0, 0.0, ...]

nb_poles = info[2]
offset = 7  # the first doubles start after the 7 integer parameters

coords = [info[offset + i] for i in range(nb_poles * 3)]
points = [(coords[i], coords[i+1], coords[i+2]) for i in range(0, len(coords), 3)]

print(points)

hello,

thanks for your answer,

maybe i missunderstood the doc, but thought that the xi yi zi, was the coordinates of the points used for creating the spline, where actually they (as you mentionned) are the poles, so to recreate the geometry, the next time one needs to use a beizer over this points and one gets a really similar curve (not perfect but really similar).

what i was looking was instead of this, to be able to get points that i could reproduce the geometry using the interpolation tool again, i ‘solved’ by simply having the nodes in the extreme and cutting the curve by vertexeOnCurve at different factors between 0 and 1, this will not recreate the same thing neither but it is to export to another software where i only got the interpolation method.

thanks