How to get the cross-sectional area of a PDE model

조회 수: 14 (최근 30일)
Hanshun Yu
Hanshun Yu 2020년 5월 18일
답변: DGM 2025년 3월 29일
Now I have a 3D model of a rebar as a .stl file and I want to calculate the cross-sectional area of this rebar at different places. My point is to calculate the area so the contour or slice function doesn't work for me.
I have imported this model to MATLAB as a PDEModel. But when I searched for the cross-sectional area of a PDEModel, I just got how to plot the PDE solution.
Then I used the generateMesh function to get a FEMesh. I think maybe the Surface Intersection function can do it but I don't know how to build a surface from the FEMesh.
So is there any way I can do this?
  댓글 수: 2
darova
darova 2020년 5월 18일
Can you attach the data? Can you show position you want to get crossection?
Hanshun Yu
Hanshun Yu 2020년 5월 18일
Thanks for your concern. I attached the .stl file here. It's just a cylinder.
About the positoin, I'd like to get cross-sectional area of any section perpendicular to x-axis so it's not so important I think.

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

채택된 답변

darova
darova 2020년 5월 18일
See this solution
f1 = stlread('Cylinder.stl');
[y,z] = meshgrid(-2:2); % meshgrid for plane
h = surf(y*0+2,y,z); % crossection plane
f2 = surf2patch(h,'triangles'); % convert to patch
f2.facecolor= 'r';
patch(f1,'facecolor','y') % display cylinder
patch(f2) % display crossection plane
[~,ff] = SurfaceIntersection(f1,f2);% find crossection line
ff = rmfield(ff,'edges'); % remove edges
patch(ff,'linew',2) % display crossection line
alpha(0.3) % make surfaces transparent
axis vis3d equal
  댓글 수: 13
darova
darova 2021년 2월 9일
  • Do you know why the function is throwing an error when I place the intersection plane at 0 or 50 (lower and upper limit of the cone) ?
I believe the answer is:
Error: in IntersectionPolygon: key is out of bound
Try
h2 = surf(y,z,z*0+50-0.01);
h2 = surf(y,z,z*0+0.01);
  • This is what my crosse sections look like. Is there a command that fills the cross section with a certain color?
Sure, use patch or fill
Matt
Matt 2023년 4월 24일
Hey I'm having a similar issue with this method, I can't find why it doesn't work on my side when trying to "convert" the points/Clist to vertices and faces.
I run the following code :
f1 = stlread('OBJECT.stl');
[y,z] = meshgrid(-20:20);
h = surf(y*0+20,y,z);
f2 = surf2patch(h,'triangles');
f2.facecolor= 'r';
f1.vertices = f1.Points;
f1.faces = f1.ConnectivityList;
f1 = rmfield(f1,'Points','ConnectivityList');
patch(f1,'FaceColor','y')
patch(f2)
but I get this error : Unrecognized property 'vertices' for class 'triangulation'.
and also it seems to Matlab that I don't have enough arguments for patch(f1,'FaceColor','y').
Would appreciate any help !
~Matt

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

추가 답변 (1개)

DGM
DGM 2025년 3월 29일
See also this answer using the same FEX tool. This should solve a few of the issues with SurfaceIntersection(). The setup of patch objects is handled internally by the given function, so that solves some usage issues or at least serves as an example. The conversion of unsorted edge lists into sane closed polygons is also handled.

카테고리

Help CenterFile Exchange에서 Geometry and Mesh에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by