# How to find the optimal parameters for alphaShape?

조회 수: 11(최근 30일)
Pelajar UM 2021년 12월 16일
편집: Pelajar UM 2021년 12월 17일
I have a STL file for which I want to generate a tetrahedral mesh. I know there's already a function for this in the PDE toolbox and most of the time it works well, but sometimes it does not accept the STL file (various errors, I won't go into details, that's beside the point. It's also slow for large parts).
More importantly, you cannot view the soruce code of generateMesh. So I'm not sure how MATLAB is handling the whole thing.
Anyway I had this idea:
1) I will create point clouds from the STL (at the moment I'm doing this out of MATLAB, if you have any idea how this could be handled within MATLAB, that would be great).
2) Then use alphaShape to generate the mesh. (Delaunary triagnulation doesn't work well for complex shapes with lots of holes)
Somewhat successful, but as I play with different parameters, I cannot seem to be able to get the right balance.
shp = alphaShape(points); %points is Nx3 data from the 3D cloud points
shp.Alpha = 3; %I have been experimenting mainly with this parameter
tri = alphaTriangulation(shp);
pdemesh(shp.Points',tri')
Alpha radius from left to right is 1.5, 2, 3 and 10. As you see, when it's small, you can see all the fine details of the part, but at the same time there are many "gaps". As I increase the radius, these gaps are filled, but the part also loses its details. The edges merge and the smaller holes completely vanish.
This is how the STL file look like:
Any thoughts? There's probably a more robust approach for this that would be independent from the geometry. For instance, is there a way to first generate a triangular surface mesh to establish the edges (from the point clouds alone, there's no connectively list) and only then convert it to a solid tetrahedral mesh?
##### 댓글 수: 2표시숨기기 이전 댓글 수: 1
Pelajar UM 2021년 12월 17일
편집: Pelajar UM 2021년 12월 17일
Thanks Steven. It doesn't really crash (using R2021a). The errors are very specific to a paricular STL file. I have to go back and look for the files. Some of the errors are:
1) Invalid geometry. Unable to compute associativity between mesh and the geometry. (to be honest, I don't know what this actually means)
2) Meshing failed for Hmax ... and Hmin ..., try adjusting the mesh size, (still keeps giving this error after I adjust, or let MATLAB decide the size)
3) The STL file does not form a close surface or something along those lines (I cannot see any open gaps, but this is sometimes solved if you generate the same STL in other CAD software)
Regarding the speed, is it possible to use GPU to accelerate the meshing?

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

### 범주

Find more on Geometry and Mesh in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by