From: <raf...@us...> - 2012-07-09 13:06:36
|
Revision: 10737 http://octave.svn.sourceforge.net/octave/?rev=10737&view=rev Author: rafavzqz Date: 2012-07-09 13:06:25 +0000 (Mon, 09 Jul 2012) Log Message: ----------- Plot the 3D control mesh Modified Paths: -------------- trunk/octave-forge/extra/nurbs/inst/nrbctrlplot.m Modified: trunk/octave-forge/extra/nurbs/inst/nrbctrlplot.m =================================================================== --- trunk/octave-forge/extra/nurbs/inst/nrbctrlplot.m 2012-07-08 18:08:33 UTC (rev 10736) +++ trunk/octave-forge/extra/nurbs/inst/nrbctrlplot.m 2012-07-09 13:06:25 UTC (rev 10737) @@ -51,7 +51,33 @@ if (iscell (nurbs.knots)) if (size (nurbs.knots,2) == 3) - error ('nrbctrlplot: not implemented for NURBS volumes'); + nsub = 100; + nrbplot (nurbs, [nsub nsub nsub], 'light', light, 'colormap', cmap); + hold on +% Plot the the control net + for ii = 1:size (nurbs.coefs, 2) + for jj = 1:size (nurbs.coefs, 3) + coefs = reshape (nurbs.coefs(1:3,ii,jj,:), 3, []); + weights = reshape (nurbs.coefs(4,ii,jj,:), 1, []); + plot3 (coefs(1,:)./weights, coefs(2,:)./weights, coefs(3,:)./weights,'k--') + plot3 (coefs(1,:)./weights, coefs(2,:)./weights, coefs(3,:)./weights,'r.','MarkerSize',20) + end + for kk = 1:size (nurbs.coefs, 4) + coefs = reshape (nurbs.coefs(1:3,ii,:,kk), 3, []); + weights = reshape (nurbs.coefs(4,ii,:,kk), 1, []); + plot3 (coefs(1,:)./weights, coefs(2,:)./weights, coefs(3,:)./weights,'k--') + plot3 (coefs(1,:)./weights, coefs(2,:)./weights, coefs(3,:)./weights,'r.','MarkerSize',20) + end + end + for jj = 1:size (nurbs.coefs, 3) + for kk = 1:size (nurbs.coefs, 4) + coefs = reshape (nurbs.coefs(1:3,:,jj,kk), 3, []); + weights = reshape (nurbs.coefs(4,:,jj,kk), 1, []); + plot3 (coefs(1,:)./weights, coefs(2,:)./weights, coefs(3,:)./weights,'k--') + plot3 (coefs(1,:)./weights, coefs(2,:)./weights, coefs(3,:)./weights,'r.','MarkerSize',20) + end + end + elseif (size (nurbs.knots,2) == 2) % plot a NURBS surface nsub = 100; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <raf...@us...> - 2012-07-17 08:53:37
|
Revision: 10745 http://octave.svn.sourceforge.net/octave/?rev=10745&view=rev Author: rafavzqz Date: 2012-07-17 08:53:26 +0000 (Tue, 17 Jul 2012) Log Message: ----------- Plot the points only once Modified Paths: -------------- trunk/octave-forge/extra/nurbs/inst/nrbctrlplot.m Modified: trunk/octave-forge/extra/nurbs/inst/nrbctrlplot.m =================================================================== --- trunk/octave-forge/extra/nurbs/inst/nrbctrlplot.m 2012-07-17 00:18:06 UTC (rev 10744) +++ trunk/octave-forge/extra/nurbs/inst/nrbctrlplot.m 2012-07-17 08:53:26 UTC (rev 10745) @@ -8,7 +8,7 @@ % % INPUT: % -% nurbs: NURBS curve or surface, see nrbmak. +% nurbs: NURBS curve, surface or volume, see nrbmak. % % Example: % @@ -22,7 +22,7 @@ % % nrbkntplot % -% Copyright (C) 2011 Rafael Vazquez +% Copyright (C) 2011, 2012 Rafael Vazquez % % This program is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by @@ -54,19 +54,21 @@ nsub = 100; nrbplot (nurbs, [nsub nsub nsub], 'light', light, 'colormap', cmap); hold on -% Plot the the control net +% Plot the control points + coefs = bsxfun (@rdivide, nurbs.coefs(1:3,:,:,:), nurbs.coefs(4,:,:,:)); + coefs = reshape (coefs, 3, []); + plot3 (coefs(1,:), coefs(2,:), coefs(3,:), 'r.','MarkerSize',20); +% Plot the control net for ii = 1:size (nurbs.coefs, 2) for jj = 1:size (nurbs.coefs, 3) coefs = reshape (nurbs.coefs(1:3,ii,jj,:), 3, []); weights = reshape (nurbs.coefs(4,ii,jj,:), 1, []); plot3 (coefs(1,:)./weights, coefs(2,:)./weights, coefs(3,:)./weights,'k--') - plot3 (coefs(1,:)./weights, coefs(2,:)./weights, coefs(3,:)./weights,'r.','MarkerSize',20) end for kk = 1:size (nurbs.coefs, 4) coefs = reshape (nurbs.coefs(1:3,ii,:,kk), 3, []); weights = reshape (nurbs.coefs(4,ii,:,kk), 1, []); plot3 (coefs(1,:)./weights, coefs(2,:)./weights, coefs(3,:)./weights,'k--') - plot3 (coefs(1,:)./weights, coefs(2,:)./weights, coefs(3,:)./weights,'r.','MarkerSize',20) end end for jj = 1:size (nurbs.coefs, 3) @@ -74,7 +76,6 @@ coefs = reshape (nurbs.coefs(1:3,:,jj,kk), 3, []); weights = reshape (nurbs.coefs(4,:,jj,kk), 1, []); plot3 (coefs(1,:)./weights, coefs(2,:)./weights, coefs(3,:)./weights,'k--') - plot3 (coefs(1,:)./weights, coefs(2,:)./weights, coefs(3,:)./weights,'r.','MarkerSize',20) end end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |