reducepatch function with stl file

7 ビュー (過去 30 日間)
nourdine ouzoubair
nourdine ouzoubair 2016 年 7 月 28 日
編集済み: DGM 2025 年 7 月 16 日
How can I use reducepatch function with stl file?? Thank you

回答 (1 件)

Rahul
Rahul 2025 年 6 月 4 日
In order to use 'reducepatch' function with an stl file, consider the following steps:
  • Read the stl file using 'stlread' function.
  • You would obtain a Triagulation object which would contain 'ConnectivityList' and 'Points'
  • Either construct a struct with properties 'faces', 'vertices', where 'faces' would crrespond to 'ConnectivityList' and 'vertices' would correspond to 'Points' of the Triangulation object.
  • You can also consider creating a 'patch' object with the 'ConnectivityList' and 'Points' as 'Faces' and 'Vertices'.
  • This struct or 'patch' object created can be passed to the 'reducepatch' function with appropriate arguments.
The following MathWorks documentations can be referred:
Thanks.
  1 件のコメント
DGM
DGM 2025 年 7 月 16 日
編集済み: DGM 2025 年 7 月 16 日
How about an example?
unzip sphere_200.stl.zip % for the forum
% read the file
T = stlread('sphere_200.stl'); % triangulation object
% convert to an FV struct
FV = t2fv(T);
size(FV.faces,1)
ans = 39996
patch(FV,'facecolor',[0.2 0.8 1],'edgecolor','none');
view(3); view(-30,47); camlight;
axis equal; grid on
% reduce the model to 10% of the facecount
FVr = reducepatch(FV,0.1);
size(FVr.faces,1)
ans = 3998
patch(FVr,'facecolor',[0.2 0.8 1],'edgecolor','none');
view(3); view(-30,47); camlight;
axis equal; grid on
My use of t2fv() here is both a convenience and an anachronism. In 2016, we wouldn't be reading into triangulation objects. The first-party stlread() didn't exist until late 2018. The available third party decoders would have been returning data as an FV struct, separate F,V lists, or other less useful formats. As a consequence, we would likely need to do nothing extra to obtain the FV struct.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSTL (STereoLithography) についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by