Understanding what the sample parser is telling me

I run the parser on the first supplied 3dm file and get:

    Object 0:
        object name = ""
        object uuid = DE01E64E-59C6-49a8-9E96-903BFC831C3C
        object mode = normal
        object layer index = 0
        object material index = -1
        material source = layer material
        ON_NurbsSurface dim = 3 is_rat = 0
                order = 3 X 4 cv_count = 3 X 5
        Knot Vector 0 ( 4 knots )
        index                     value  mult       delta
            0                        0     2
            2                        1     2           1
        Knot Vector 1 ( 7 knots )
        index                     value  mult       delta
            0                        0     3
            3                      1.5     1         1.5
            4                        2     3         0.5
        Control Points  15 non-rational points
          index               value
          CV[ 0][ 0] (0, 0, 0)
          CV[ 0][ 1] (0, 1, -1)
          CV[ 0][ 2] (0, 2, -2)
          CV[ 0][ 3] (0, 3, -3)
          CV[ 0][ 4] (0, 4, -4)

          CV[ 1][ 0] (1, 0, 1)
          CV[ 1][ 1] (1, 1, 0)
          CV[ 1][ 2] (1, 2, -1)
          CV[ 1][ 3] (1, 3, -2)
          CV[ 1][ 4] (1, 4, -3)

          CV[ 2][ 0] (2, 0, 2)
          CV[ 2][ 1] (2, 1, 1)
          CV[ 2][ 2] (2, 2, 0)
          CV[ 2][ 3] (2, 3, -1)
          CV[ 2][ 4] (2, 4, -2)

I am trying to relate this to a FreeCAD sample python to create a Nurbs Surface which is essentially

# define a polesList, it is a matrix of 3 rows (u direction) and 4 #columns (v direction)
polesList =
[Vector(0,0,0),Vector(0,2,2),Vector(0,4,0)],[Vector(3,0,3),Vector(3,2,5),Vector(3,4,3)],[Vector(6,0,3),Vector(6,2,5),Vector(6,4,3)],[Vector(9,0,0),Vector(9,2,2),Vector(9,4,0)]
weightList = [ [1,1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1] ]
# knot vectors:     
                                                                                      
uk=[0.0, 0.5, 1.0]  
vk=[0.0, 1.0]                               
                                                 
bsp.buildFromPolesMultsKnots(polesList,(3,1,3),(3,3),udegree=2,vdegree=2,uknots=(0.0,0.5, 1.0),vknots=(0.0, 1.0),weights=weightList)

I assume that the CV relate to the poleList so the equivalent poleList would be poleList = [
Vector(0, 0, 0),
Vector(0, 1, -1),
Vector(0, 2, -2),
Vector(0, 3, -3)
Vector(0, 4, -4) 
],
Vector(1, 0, 1),
Vector(1, 1, 0),
Vector(1, 2, -1),
Vector(1, 3, -2),
Vector(1, 4, -3)
],
Vector(2, 0, 2),
Vector(2, 1, 1),
Vector(2, 2, 0),
Vector(2, 3, -1)
Vector(2, 4, -2)
]

But I don’t know how to interpret what the parser is telling me about knots, what the weights should be or the equivalent parameters on the bsp.buildFromPolesMultsKnots(polesList,(3,1,3),(3,3),udegree=2,vdegree=2,uknots=(0.0,0.5, 1.0),vknots=(0.0, 1.0),weights=weightList)

Hi Keith

Some info about (Rhino) Nurbs here: https://www.rhino3d.com/nurbs

I only would say that here

ON_NurbsSurface dim = 3 is_rat = 0

is_rat = 0 should mean non rational, and hence all weights = 1, and this

order = 3 X 4 cv_count = 3 X 5

should mean degree = 2 X 3

Don’t know about the knots, sorry …

Regards

Ah, wait …

assuming that the values in any row (as indicated) be: Index, Value, Multiplicity, DeltaValue
That may mean:
index 0, value 0, multiplicity 2 ( no delta for first value )
index 2, value 1, multiplicity 2, delta 1

then the U knot vector should be:

0 0 1 1

… and the V knot vector:

0 0 0 1.5 2 2 2

Although the delta info looks redundant …

Well, obviously I’m not sure … just guessing …

Regards

Many thanks gives me something to get started with

OK, one last guess … :wink:

If

(3,1,3),(3,3)

were the knots multiplicities, and

(0.0, 0.5, 1.0), (0.0, 1.0)

the knots values, then the expanded knot vectors should be

0 0 0 0.5 1 1 1

and

0 0 0 1 1 1

that in Rhino/OpenNurbs syntax would translate into

0 0 0.5 1 1

and

0 0 1 1

… maybe …

( … And to write ON knot vectors for FreeCAD, you would need to increase by one the first and last knot’s multiplicity … )

Regards

Does this help?

http://developer.rhino3d.com/guides/opennurbs/superfluous_knots/