How to find the optimal parameters for alphaShape?
3 views (last 30 days)
Show older comments
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 Comments
Steven Lord
on 16 Dec 2021
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).
Would it be possible for you to send a sample STL file for which the functions in Partial Differential Equations Toolbox throw errors or perform slowly to Technical Support for investigation of the cause of those errors or slow performance?
I looked through the bug reports for this product. There was a bug where importGeometry crashed for STL files with invalid triangles, but that has been fixed in release R2021b. I don't see anything else that from your brief description sound relevant.
Answers (0)
See Also
Categories
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!