[vtk-developers] Class design for spline visualizations

Lin M majcjc at gmail.com
Wed Jun 24 10:43:30 EDT 2015


Hi Dr. Thompson,

I'm writing the knot insertion method InsertKnot() and I hope it can be
used to handle both 1-d, 2-d and 3-d cases.

1. One question is that when converting a nurbs curve to a bezier curve,
eaca segment of a nurbs curve will correspond to a new bezier curve. So we
need to repeatedly retrieve a subset of the control points and the knot
vector from the original nurbs curve. To make the InserKnot() method more
generally. I define the API as

void InsertKnot(
vtkPoints* pointsOut,
double tNew, int dim,
vtkPoints* pointsIn, int* knotsLen, double* knotsArr)

// pointsOut stores the new control points
// tNew is the new knot we want to insert
// dim is the dimension where the new knot is
// pointsIn is the old control points (which is probably a subset of the
original nurbs control points)
// knotsLen stores the number of entries of the knots vector in each
dimension (I'll assume it is always a 1*3 int array)
// knotsArr stores the knot vector for all dimensions

Do you think this API is proper?

2. The second question is that, as described in the first question, a
p-degree nurbs curve with a given knot vector actually will generate a
series of bezier curve. Each of the them corresponds to a segment of the
original nurbs curve. How can I find the subset of the control points and
knot vector for a segment?

Best,
Lin

On Mon, Jun 22, 2015 at 6:54 PM, David Thompson <david.thompson at kitware.com>
wrote:

> Hi Lin,
>
> > 1. The definition of knot vector seems to be a little different from the
> NURBS book. In the NURBS book, a knot vector is defined as U =
> {a,...,a,u_{p+1},...,u_{m-p-1},b,...,b} where a and b are repeated p+1
> times (p is the degree of NURBS curve). And since NURBS cruve  is defined
> as C(u) = sum_{i,n}(N_{i,p}(u)*P_{i}),  the endpoints seems to be
> interpolated as well.
>
> NURBS do not require any knot vector entries to be repeated. Many examples
> in the NURBS book *happen* to have repeated entries, but it is not a
> requirement.
>
> > ...
> > 2. The previous section of the wiki page writes "The number of knots is
> always equal to the number of control points plus curve degree plus one
> (i.e. number of control points plus curve order)." Should it be degree + N
> + 1 = K ?
>
> From the wikipedia entry: "Some modelers that use older algorithms for
> NURBS evaluation require two extra knot values for a total of (degree+N+1)
> knots.[7]"  You can use whichever you like. I would advise sticking with
> the NURBS book because it has many examples worked out in detail. (The
> NURBS book appears to use the degree + N + 1 = K formulation.)
>
> > 3. I think the inference is only for a single patch.  If there are
> several patches in the vtkStructuredGrid, we can not get the number of
> control points for a certain patch by vtkStructuredGrid->GetDimension()
> unless we know the number of patches and the number of control points are
> the same for all these patches.
>
>
> Nope, you can use GetDimension() to discover the number, N, of control
> points for all patches. That is related to the degree by the number of knot
> vector entries for all patches. We have not specified how the knot vector
> would be stored. If stored as an array in vtkFieldData, then   we would
> also have to store the number entries along each axis (the equivalent
> information as GetDimension() returns for the control points). Or we could
> store the degree along each axis and use that to determine the size of the
> knot vector along each axis... whichever you prefer.
>
>         David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20150624/7c2e643d/attachment.html>


More information about the vtk-developers mailing list