matlab offsets,Offset surface of triangle mesh in matlab

Here’s a little demonstration of how to use gptoolbox and MATLAB to generate an offset surfaces of a triangle mesh. This takes a mesh in V , F and creates a mesh SV , SF of the isosurface at signed distance iso :

% Extract offset at minus 3% of bounind box diagonal length

iso = -0.03;

% Resolution grid → resolution of extracted offset surface

side = 60;

% Amount of smoothing to apply to distance field

sigma = 1.4;

bbd = norm(max(V)-min(V));

% Pad generously for positive iso values

[BC,side,r] = voxel_grid([V;max(V)+iso*1;min(V)-iso*1],side);

D = signed_distance(BC,V,F);

D = reshape(D,side([2 1 3]));

% Smooth signed distance field

D = imfilter(D,fspecial('gaussian',9,sigma),'replicate');

BC3 = reshape(BC,[side([2 1 3]) 3]);

% Use matlab's built-in marching cubes iso-surface mesher (works most of the time)

surf = isosurface(BC3(:,:,:,1),BC3(:,:,:,2),BC3(:,:,:,3),D,iso*bbd);

SV = surf.vertices;

SF = surf.faces;

Here’s a blue bunny with a positive offset surface, an orange “cage”:

aedf79907bbd94730dd6419af7b838a4.jpg

Here’s a blue bunny with a negative offset surface. This is useful for hollowing out objects to 3d print:

42eefb692713ed9b23489e026ac008c9.jpg

Because the iso-surface extraction will over tesselate low curvature patches of the output surface, it would make a lot of sense to remesh/decimate this mesh.

(to create these fancy renderings:)

clf;

hold on;

t = tsurf(F,V,'EdgeColor','none',fsoft, 'FaceVertexCData',repmat(blue,size(V,1),1),'FaceAlpha',1+(iso<0)*(0.35-1),fphong);

ts = tsurf(SF,SV,'EdgeAlpha',0.2+(iso0)*(0.2-1));

apply_ambient_occlusion(ts);

hold off;

axis equal;

view(-20,20)

camlight;

t.SpecularStrength = 0.04;

l = light('Position',[5 -5 10],'Style','local');

add_shadow(t,l,'Color',0.8*[1 1 1],'Fade','local','Ground',[0 0 -1 min([V(:,3);SV(:,3)])]);

set(gca,'pos',[0 0 1 1])

set(gca,'Visible','off');

set(gcf,'Color','w');

drawnow;

This entry was posted on Wednesday, March 22nd, 2017 at 3:33 pm and is filed undercode. You can follow any responses to this entry through theRSS 2.0 feed. You can, ortrackback from your own site.

注意:本文来自Alec's Web Log。本站无法对本文内容的真实性、完整性、及时性、原创性提供任何保证,请您自行验证核实并承担相关的风险与后果!

CoLaBug.com遵循[CC BY-SA 4.0]分享并保持客观立场,本站不承担此类作品侵权行为的直接责任及连带责任。您有版权、意见、投诉等问题,请通过[eMail]联系我们处理,如需商业授权请联系原作者/原网站。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值