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

14 views (last 30 days)
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 Comments
darova
darova on 18 May 2020
Can you attach the data? Can you show position you want to get crossection?
Hanshun Yu
Hanshun Yu on 18 May 2020
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.

Sign in to comment.

Accepted Answer

darova
darova on 18 May 2020
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 Comments
darova
darova on 9 Feb 2021
  • 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 on 24 Apr 2023
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

Sign in to comment.

More Answers (1)

DGM
DGM on 29 Mar 2025
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.

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!