One algorithm of extracting surface in 3d data set.
In vtk, there is a filter called geometry filter which can be used to extract the external surface of the data sets. However, this filter does not run as expected some times. The extracted surface is not the clean surface, it always contains some fragments in the output results.
It depends on how we design the 3d mesh. For complex geometry, such as a hole in a blade, the mesh around hole region is not extracted properly.
However, we found that after extracting the slice, than using the feature edge filter, the outline of the 2d plane can be extracted properly.
So we design a algorithm which work in this way:
1 Extracting the slice of the object, depending on the dim of the z dimention, if there are 100 points at z dims, we need more than 100 slices.
2 For each slice, using feature edge to extract the outline of these slices and keep the coordinated for the points around that line.
3 Iterating through each point of the object mesh. For each point, we can find one associated slice according to its z axis (same as step 1). Then computing the distance between current point and each points on slice. We cam use numpy operation to get a vector by one line code to avoide the for loop.
4 Find the min value among that distance vector. If that distance value is less than a threshold, such as 0.0001, we label that point and also record the distance value. This means that the point is really close to the boundry point.
5 In order to not miss the point, the threshold should not be to small, but that cause a issue that there might be several points in mesh are close to one edge point. So we also need to use a map to record the edge point, the key could be <slice_index>_<point index on slice>
then if we find a point on the mesh that are closer than recorded one, we update the map and store the new point. We also set the flag of the new point as 1 and old point (the point that are switched out) as 0.
6 After iterating over all points, we can get new array with value one on boundry points and zero on innter points. We can extracting the points with flag value equals to one and save out for subsequent analysis.