Create STL from patch object or simlar

조회 수: 19(최근 30일)
Holden Tranquillo
Holden Tranquillo 2022년 3월 3일
댓글: Holden Tranquillo 2022년 4월 7일
Hello,
Currently, I have several matrices that represent the (x,y) coordinates for contours. In the image shown, I am just plotting those contours using the 'patch' command. What I need to do, however, is export these contours (either individually, or all at once) as an STL file to be opened in a CAD software.
Matlab's 'stlwrite' command only accepts a triangulation object as an argument. However, currently, when I try to create a triangulation of one of the contours (in the image shown it is of the outermost contour), I get a distorted and incorrect representation.
It seems like this should be a simple task to do, so any help would be greatly appreciated.
  댓글 수: 3
Holden Tranquillo
Holden Tranquillo 2022년 3월 5일
So it looks like you do the delaunayTriangulation w/ constraints is so that the the edges are known to Matlab for when you do 'isInterior'?

댓글을 달려면 로그인하십시오.

답변(1개)

KSSV
KSSV 2022년 3월 3일
load('Contours.mat') ;
p = [perimeter1 ; perimeter2 ; perimeter3 ; perimeter4 ; perimeter5 ; perimeter6 ; perimeter7 ; perimeter8 ;
perimeter9] ;
id = knnsearch(p,perimeter1) ;
C = [id(1:end-1) id(2:end)];
% Make delaunay triangulation with constriants
dt = delaunayTriangulation(perimeter1,C) ;
% Get the interior triangular elements
tf = isInterior(dt) ;
% get points and nodes
p = dt.Points ;
t = dt.ConnectivityList ;
% Pick the required
t(~tf,:) = [] ;
% Make deluanay again
dt = triangulation(t,p);
triplot(dt)
  댓글 수: 5
Holden Tranquillo
Holden Tranquillo 2022년 4월 7일
Hi KSSV, sorry to bother you again, but there is on emore thing I cannot seem to figure out. I am now using a filter on the boundary traces in order to smooth them out, and now during the STL creation, the 'isInterior' command returns all true, and thus the correct STLs are not being created. If you can, can you glance at this attached code and see if you can figure out why it returns all true? I cannot figure it out

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by