Create STL from patch object or simlar
Afficher commentaires plus anciens
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 commentaires
KSSV
le 3 Mar 2022
Attach your data.
Holden Tranquillo
le 3 Mar 2022
Holden Tranquillo
le 5 Mar 2022
Réponses (1)
KSSV
le 3 Mar 2022
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 commentaires
Holden Tranquillo
le 5 Mar 2022
Holden Tranquillo
le 5 Mar 2022
Holden Tranquillo
le 5 Mar 2022
Modifié(e) : KSSV
le 7 Mar 2022
KSSV
le 7 Mar 2022
Using perimeter2 doesnot crash my MATLAB. You may consider using like shown below:
id = knnsearch(perimeter2,perimeter2) ;
C = [id(1:end-1) id(2:end)];
% Make delaunay triangulation with constriants
dt = delaunayTriangulation(perimeter2,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)
Holden Tranquillo
le 7 Avr 2022
Catégories
En savoir plus sur STL (STereoLithography) dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!