How to fix the incorrect shape of a mesh

6 ビュー (過去 30 日間)
Mohammad Abu Haifa
Mohammad Abu Haifa 2022 年 9 月 1 日
回答済み: Mohammad Abu Haifa 2022 年 9 月 1 日
I have 3D points that represent a cuboid saved in F which I extracted from an image. F is 8x3 double array. When I converted the data to a triangulated mesh and plotted it, I got this incorrect shape, see the image below. It should produce a cuboid with 6 faces, but the resulted one has 8 faces. Anyone can help me how to fix the problem to plot the correct shape? However, when I write the values of x,y, and z manually (see the code below the image), the code plots the shape correctly.
The code is:
x = F(:,1);
y = F(:,2);
z = F(:,3);
shp = alphaShape(x,y,z);
[elements,nodes] = boundaryFacets(shp);
model = createpde(); % requires Partial Differential Equation Toolbox
geometryFromMesh(model,nodes',elements');
pdegplot(model,'FaceLabels','on','FaceAlpha',0.5)
generateMesh(model);
% This section is the manual values of x, y, and z. Here the plot is correct. But if I use the existed one, the plot is not correct
F = [0.014 -0.4472 0
0.4055 -0.4472 0
0.409 -0.6478 0
0.014 -0.6478 0
0.014 -0.4472 -0.18
0.4055 -0.4472 -0.18
0.409 -0.6478 -0.18
0.014 -0.6478 -0.18];

採用された回答

Mohammad Abu Haifa
Mohammad Abu Haifa 2022 年 9 月 1 日
I found the answer. To fix this problem we need to arrange the vertices order. So, you can do the following:
K = convhull(x,y,z);
nodes = [x';y';z'];
elements = K';
model = createpde();
geometryFromMesh(model,nodes,elements);
pdegplot(model,'FaceLabels','on','FaceAlpha',0.5)

その他の回答 (1 件)

KSSV
KSSV 2022 年 9 月 1 日
You need to arrange the vertices in an order...get the order from the above file exchange..
  2 件のコメント
Mohammad Abu Haifa
Mohammad Abu Haifa 2022 年 9 月 1 日
This is a different story. I want to keep it as a mesh (not only a plot) because I want to export the mesh to nother software. The problem is the number of faces of the mesh is correct when I enter the values manually, but when I use the 3D data extracted from an image, the mesh has two more faces.
KSSV
KSSV 2022 年 9 月 1 日
Check the order of the vertices...

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

カテゴリ

Help Center および File ExchangePoint Cloud Processing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by