How to find the optimal parameters for alphaShape?
8 views (last 30 days)
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);
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?