Hey guys, my stlwrite function is not working and i would like to know how to fix it. In the code C is random points
5 views (last 30 days)
Show older comments
seeds=C;
[Ver,Cel,C_tst]=voronoi3d_cuboid(seeds,Vcub);
FK = zeros(100,3,312);
figure
hold on
axis('equal')
view([-36 27])
scatter3(seeds(:,1),seeds(:,2),seeds(:,3),25, ...
'Marker','o','MarkerFaceColor',[1 0 0], 'MarkerEdgeColor','k');
scatter3(Ver(:,1),Ver(:,2),Ver(:,3),25, ...
'Marker','o','MarkerFaceColor',[0 1 0], 'MarkerEdgeColor','r');
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');
%
FK(1:size(Fk,1),1:3,k) = Fk(:,1:3);
VK(1:size(Vk,1),1:3,k) = Vk(:,1:3);
end
end
end
grid on
xlabel('X');ylabel('Y');zlabel('Z');
P = struct('faces',FK,'vertices',VK);
stlwrite('mytriangulation.stl',P);
1 Comment
Answers (1)
VINAYAK LUHA
on 6 Oct 2023
Hi Akhshay,
It is my understanding that you are facing issues while using the “stlwrite” function. The issue is caused by the incorrect placement of the passed parameters in the calling syntax for the "stlwrite" function.
Refer to the examples listed in the following documentation of “stlwrite” function to learn how to use “stlwrite” function correctly- https://in.mathworks.com/help/matlab/ref/stlwrite.html
Hope this helps in fixing the “stlwrite” error.
Regards,
Vinayak Luha
1 Comment
Rik
on 6 Oct 2023
Is this a practice post?
The OP didn't respond in a year and a half. Why resurrect it now?
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!