I would like to know how to store faces and vertices in order to generate an stlwrite file for the entire structure
2 views (last 30 days)
Show older comments
code: This code will generarte one stl file with one vornoi polygon since I am not storing all the faces and vertices of the whole polygon
for k = 1:length(Cel)
if ~isempty(Cel{k})
col=rand(1,3);
Vk = Ver(Cel{k},:); Fk = convhull(Vk);
if exist('mergeCoplanarFaces.m','file')==2
[Vk, Fk] = mergeCoplanarFaces(Vk, Fk);
for i=1:length(Fk)
patch('Vertices',Vk,'Faces',Fk{i},'FaceColor',col,'FaceAlpha',0.3)
end
else
trisurf(Fk,Vk(:,1),Vk(:,2),Vk(:,3),'FaceColor',col, ...
'FaceAlpha', 1,'EdgeAlpha',1,'EdgeColor','k');
end
end
end
grid on
xlabel('X');ylabel('Y');zlabel('Z');
stlwrite('mytriangulation.stl',struct('faces',Fk,'vertices',Vk));
Answers (0)
See Also
Categories
Find more on Voronoi Diagram in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!