Jump to content
TomoftheDay

Issue with BSplineCurve Knot Vectors

Recommended Posts

Hi There,

I'm currently writing a feature that will elevate the degree of a given B-Spline by generating new control points.
My feature generates a curve and the points correctly.
I am running into an issue with the Knot vector for this augmented curve.

I am constructing the knot vector as an FDoubleSeries, this appears to be as per the documentation for the curve command .setKnotVector()

The code evaluates with no errors, I can see that the correct number of items are in the series,  but the double series does not appear to play nicely with anything else. 

I'm at a bit of a loss. I've placed the relevant code below and attached the working file, please excuse it's structure, it is a practice exercise. Any help is appreciated!

//Constuct Knot Vector
FInteger numPoints(augPoints.getSize())
FDoubleSeries knotVector([])

//Case where num Points is 10 or less
if(numPoints<=10)
  loop(numPoints)
    knotVector.add(0)
  endloop
  loop(numPoints)
    knotVector.add(1)
  endloop
  
  //Case where num Points is greater than 10
elseif(numPoints>10)
  FDouble knotFraction(1/((numPoints-10)+1))
  loop(10)
    knotVector.add(0)
  endloop
  loop(numPoints-10)
    knotVector.add(knotFraction)
    knotFraction += knotFraction
  endloop
  loop(10)
    knotVector.add(1)
  endloop
endif

echo("" + knotVector.getCount())

beginPersistentSection()
BSplineCurve augCurve()
augCurve.setDegree(augPoints.getSize()-1)
augCurve.setKnotVector(knotVector)
augCurve.setPointList(augPoints)
endPersistentSection()

 

Q2.cdbc

Share this post


Link to post
Share on other sites

Hi Thomas,

Your code seems to work fine and sets the knot vector correctly for the b-spline curve.

2024-03-13_07h19_54.png.35274d0004970e54b63f1b170dfed14e.png

 

However, the display field of double series attributes in feature definitions has a small bug. So to see the values of the knotVector doubleseries you can drag and drop the "knotVector" into the console field and press enter. 

2024-03-13_07h21_44.png.7cd0b1151ed35433bfe1f6a386d1cfc2.png

 

Cheers,

Hedi

  • Upvote 1

Share this post


Link to post
Share on other sites

Hi Heidi, 

Thanks for your response.

The knotVector that shows in the curve inspection window is not the same as the knotVector that prints to the console.

The vector I construct in the script has 14 values, while the one populated in the inspection window seems to have 10 values?

 

Share this post


Link to post
Share on other sites

Ah as soon as I typed that I found the bug!
Amazing what a bit of sleep will do.

I had neglected to cast the first and last points in the entityGroup of points to an FPoint type.

Although they rendered on screen as points it seems like the spline curve was not actually reading them as points, which was maybe interfering with the allowable length of the knot vector?Weird...

Anyway, Thank you very much for your help!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...