1 function srf = nrbextrude(curve,vector)
4 % NRBEXTRUDE: Construct a NURBS surface by extruding a NURBS curve, or
5 % construct a NURBS volume by extruding a NURBS surface.
9 % srf = nrbextrude(crv,vec);
13 % crv : NURBS curve or surface to extrude, see nrbmak.
15 % vec : Vector along which the entity is extruded.
19 % srf : NURBS surface or volume constructed.
23 % Constructs either a NURBS surface by extruding a NURBS curve along a
24 % defined vector, or a NURBS volume by extruding a NURBS surface. In the
25 % first case, the NURBS curve forms the U direction of the surface edge, and
26 % is extruded along the vector in the V direction. In the second case, the
27 % original surface forms the U and V direction of the volume, and is extruded
28 % along the W direction.
32 % Form a hollow cylinder by extruding a circle along the z-axis.
34 % srf = nrbextrude(nrbcirc, [0,0,1]);
36 % Copyright (C) 2000 Mark Spink
37 % Copyright (C) 2010 Rafael Vazquez
39 % This program is free software: you can redistribute it and/or modify
40 % it under the terms of the GNU General Public License as published by
41 % the Free Software Foundation, either version 2 of the License, or
42 % (at your option) any later version.
44 % This program is distributed in the hope that it will be useful,
45 % but WITHOUT ANY WARRANTY; without even the implied warranty of
46 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47 % GNU General Public License for more details.
49 % You should have received a copy of the GNU General Public License
50 % along with this program. If not, see <http://www.gnu.org/licenses/>.
53 error('Error too few input arguments!');
56 if (iscell (curve.knots))
57 if (numel (curve.knots) == 3)
58 error('Nurbs volumes cannot be extruded!');
60 for ii = 1:size(curve.coefs,3)
61 coefs(:,:,ii) = vectrans(vector) * squeeze (curve.coefs(:,:,ii));
63 coefs = cat(4,curve.coefs,coefs);
64 srf = nrbmak(coefs,{curve.knots{:}, [0 0 1 1]});
66 coefs = cat(3,curve.coefs,vectrans(vector)*curve.coefs);
67 srf = nrbmak(coefs,{curve.knots, [0 0 1 1]});
74 %! srf = nrbextrude(crv,[0 0 5]);
75 %! nrbplot(srf,[40 10]);
76 %! title('Extrusion of a test curve along the z-axis');
80 %! crv1 = nrbcirc (1, [0 0], 0, pi/2);
81 %! crv2 = nrbcirc (2, [0 0], 0, pi/2);
82 %! srf = nrbruled (crv1, crv2);
83 %! vol = nrbextrude (srf, [0 0 1]);
84 %! nrbplot (vol, [30 10 10])
85 %! title ('Extrusion of the quarter of a ring')
89 %! vol = nrbextrude(srf, [0 0 10]);
90 %! nrbplot(vol,[20 20 20]);
91 %! title('Extrusion of a test surface along the z-axis');