資源簡介
Matlab與CAD軟件直接的圖形相互輸入接口
里面有初步的成型的算法!

代碼片段和文件信息
function?cad2matdemo(filename)
%?CAD2MATDEMO?a?demonstration?of?importing?3D?CAD?data?into?Matlab.
%?To?get?CAD?data?into?Matlab?the?process?is:
%
%?1)?Export?the?3D?CAD?data?as?an?ASCII?STL?(or?Pro/E?render?SLP)?file.
%?2)?This?Matlab?routine?reads?the?CAD?data
%?3)?Once?read?the?CAD?data?is?rotated?around?a?bit.
%
%?Program?has?been?tested?with:?AutoCAD?Cadkey?and?Pro/Engineer.
%?Should?work?with?most?any?CAD?programs?that?can?export?STL.
%?
%?Format?Details:??STL?is?supported?and?the?color?version?of?STL
%?that?Pro/E?exports?called?‘render.‘??The?render?(SLP)?is?just?
%?like?STL?but?with?color?added.
%?
%?Note:?This?routine?has?both?the?import?function?and?some?basic
%?manipulation?for?testing.??The?actual?reading?mechanism?is?located
%?at?the?end?of?this?file.
??
if?nargin?==?0????
???filename?=?‘hook.stl‘;?%?a?simple?demo?part
???warning([‘No?file?specified?using?demo?file:?‘?filename]);
end
%
%?Read?the?CAD?data?file:
[F?V?C]?=?rndread(filename);
clf;
??p?=?patch(‘faces‘?F?‘vertices‘?V);
????%set(p?‘facec‘?‘b‘);??????????????%?Set?the?face?color?(force?it)
????set(p?‘facec‘?‘flat‘);????????????%?Set?the?face?color?flat
????set(p?‘FaceVertexCData‘?C);???????%?Set?the?color?(from?file)
????%set(p?‘facealpha‘.4)?????????????%?Use?for?transparency
????set(p?‘EdgeColor‘‘none‘);?????????%?Set?the?edge?color
????%set(p?‘EdgeColor‘[1?0?0?]);??????%?Use?to?see?triangles?if?needed.
????light???????????????????????????????%?add?a?default?light
????daspect([1?1?1])????????????????????%?Setting?the?aspect?ratio
????view(3)?????????????????????????????%?Isometric?view
????xlabel(‘X‘)ylabel(‘Y‘)zlabel(‘Z‘)
????title([‘Imported?CAD?data?from?‘?filename])
????drawnow?????????????????????????????%?axis?manual
????%
????disp([‘CAD?file?‘?filename?‘?data?is?read?will?now?show?object?rotating‘])
????pause(1)?
????%
????%?Move?it?around.
????%?To?use?homogenous?transforms?the?n?by?3?Vertices?will?be?turned?to?
????%?n?by?4?vertices?then?back?to?3?for?the?set?command.
????%?Note:?n?by?4?needed?for?translations?not?used?here?but?could?using?tl(xyz)
????V?=?V‘;
????V?=?[V(1:);?V(2:);?V(3:);?ones(1length(V))];
????%
????vsize?=?maxv(V);?%attempt?to?determine?the?maximum?xyz?vertex.?
????AXIS([-vsize?vsize?-vsize?vsize?-vsize?vsize]);
????%
for?ang?=?0:1:90
????nv?=?rx(ang)*V;
????set(p‘Vertices‘nv(1:3:)‘)???????
????drawnow
end
for?ang1?=?0:2:90
????nv1?=?ry(ang1)*nv;
????set(p‘Vertices‘nv1(1:3:)‘)?????
????drawnow
end
for?ang2?=?0:3:90
????nv2=?rz(ang2)*nv1;
????set(p‘Vertices‘nv2(1:3:)‘)??????
????drawnow
end
for?ang3?=?0:5:180
????nv3?=?rx(ang3)*ry(ang3)*rz(ang3)*nv2;
????set(p‘Vertices‘nv3(1:3:)‘)??????
????drawnow
end
%
%?End?of?main?routine?here?are?the?functions?used:
%?Homogeneous?manipulation?functions?follow:
%
function?Rx?=?rx(THETA)
%?ROTATION?ABOUT?THE?X-AXIS
%
%?Rx?=?rx(THETA)
%
%?This?is?the?homogeneous?transformatio
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????4243??2004-03-10?21:19??surf2stl.m
-----------?---------??----------?-----??----
?????????????????4243????????????????????1
評(píng)論
共有 條評(píng)論