Demo entry 5728209

IGES

   

Submitted by anonymous on Jul 11, 2016 at 09:27
Language: Octave. Code size: 1.1 kB.

isOctave = (exist ('OCTAVE_VERSION', 'builtin') > 0);
if isOctave
  pkg load nurbs; % for Octave
end

% open my custom surface file
fid = fopen('test.srf', 'r');
% load the # of control points in each direction
n = fscanf(fid, '%d', 1);
m = fscanf(fid, '%d', 1);
% preallocate the control point array
pnts = zeros(3,n,m);
% load the knot vectors from the surface file
knots{1} = fscanf(fid, '%f', [1 n+4]);
knots{2} = fscanf(fid, '%f', [1 m+4]);
% load the list of control points
for i = (1:n)
  for j = (1:m)
    pnts(:,i,j) = fscanf(fid, '%f', 3);
  end
end
% close the surface file
fclose(fid);

% create NURBS toolbox surface object
srf = nrbmak(pnts,knots);

% plot
if isOctave
  nrbctrlplot(srf,[3*(n-1)+1 3*(m-1)+1]);
  %nrbkntplot(srf,[3*(n-1)+1 3*(m-1)+1]);
else
  nrbplot(srf,[3*(n-1)+1 3*(m-1)+1]);
end
title('Test surface');
hold off;

% generate IGES file from surface
if isOctave
  % Octave's IGES files use metres
  nrb2iges(srf,'octave.iges');
else
  % Matlab's IGES files use millimetres
  NrbsSrf2IGES(srf, 'matlab.iges', './')
end

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).