1 function idx = nrbnumbasisfun (points, nrb)
3 % NRBNUMBASISFUN: Numbering of basis functions for NURBS
7 % N = nrbnumbasisfun (u, crv)
8 % N = nrbnumbasisfun ({u, v}, srf)
9 % N = nrbnumbasisfun (p, srf)
13 % u or p(1,:,:) - parametric points along u direction
14 % v or p(2,:,:) - parametric points along v direction
20 % N - Indices of the basis functions that are nonvanishing at each
21 % point. size(N) == size(B)
23 % Copyright (C) 2009 Carlo de Falco
25 % This program is free software: you can redistribute it and/or modify
26 % it under the terms of the GNU General Public License as published by
27 % the Free Software Foundation, either version 2 of the License, or
28 % (at your option) any later version.
30 % This program is distributed in the hope that it will be useful,
31 % but WITHOUT ANY WARRANTY; without even the implied warranty of
32 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 % GNU General Public License for more details.
35 % You should have received a copy of the GNU General Public License
36 % along with this program. If not, see <http://www.gnu.org/licenses/>.
40 || (~isstruct(nrb)) ...
41 || (iscell(points) && ~iscell(nrb.knots)) ...
42 || (~iscell(points) && iscell(nrb.knots) && (size(points,1)~=2)) ...
44 error('Incorrect input arguments in nrbnumbasisfun');
48 if (~iscell(nrb.knots)) %% NURBS curve
50 iv = findspan (nrb.number-1, nrb.order-1, points, nrb.knots);
51 idx = numbasisfun (iv, points, nrb.order-1, nrb.knots);
53 elseif size(nrb.knots,2) == 2 %% NURBS surface
56 [v, u] = meshgrid(points{2}, points{1});
59 p = reshape(p, 2, []);
64 idx = nrb_srf_numbasisfun__ (p, nrb);
66 error('The function nrbnumbasisfun is not yet ready for volumes')
73 %! p = 2; q = 3; m = 4; n = 5;
75 %! nrb = nrb4surf ([0 0], [1 0], [0 1], [1 1]);
76 %! nrb = nrbdegelev (nrb, [p-1, q-1]);
77 %! ikx = linspace(0,1,m); iky = linspace(0,1,n);
78 %! nrb = nrbkntins (nrb, {ikx(2:end-1), iky(2:end-1)});
79 %! nrb.coefs (4,:,:) = nrb.coefs (4,:,:) + rand (size (nrb.coefs (4,:,:)));
80 %! u = rand (1, 30); v = rand (1, 10);
81 %! u = (u-min (u))/max (u-min (u));
82 %! v = (v-min (v))/max (v-min (v));
83 %! N = nrbnumbasisfun ({u, v}, nrb);
84 %! assert (all (all (N>0)), true)
85 %! assert (all (all (N <= prod (nrb.number))), true)
86 %! assert (max (max (N)), prod (nrb.number))
87 %! assert (min (min (N)), 1)