Efficient algorithm for plotting edges detect in a triangular mesh
4 ビュー (過去 30 日間)
古いコメントを表示
I often need to represent geometries by parsing STL as triangular meshes. Often plotting the geometry as a surf or trisurf plot does not do well to describe certain features, especially when in my applications, the geometries can become extremely large. Often the surfaces are very simple but have distinct holes/cuts/edges that I'd like to highlight. To do this I just detect all the edges and plot the eges that aren't shared with other triangles.
In the following example, I detect the edges of a peaks surface and plot as a 3D line:
% Generate Triangular Mesh
N = 1e3;
[x,y] = meshgrid(1:N,1:N);
con = delaunay(x,y);
z = peaks(N);
% Identify Mesh Edges
M = [con(:,[1,2]) ; con(:,[2,3]); con(:,[3,1])]; % Find all edges in mesh, note internal edges are repeated
[u,~,n] = unique(sort(M,2),'rows'); % determine uniqueness of edges
counts = accumarray(n(:), 1); % determine counts for each unique edge
O = u(counts==1,:); % extract edges that only occurred once
I = O(:,1:2)';
[x0,y0,z0] = deal(x(I),y(I),z(I));
% Plot Results
figure()
trisurf(con,x,y,z)
figure()
plot3(x0,y0,z0)
Aside from potentially being able to improve performance, I'd like to be able to plot the edge as a single object such that it could be labeled in the legend, and automatically detected if a surface contained several boundaries or holes.
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!