필터 지우기
필터 지우기

How to fix the incorrect shape of a mesh

조회 수: 2 (최근 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 CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by