select patch
Kevin,
i have used triSurfSlice to separate a surface (F,V). this process generated multiple disconnected surfaces. how can i isolate/select/keep one of these subsurfaces..say the one with the largest area?
jonathan
You can use the tesgroup function. To do this.
If F describes your faces for the mesh you use the following to get a node-connected group labeling for each face.
optionStruct.outputType='label'; %Important since the 'array' option can be much slower
[G,~,groupSize]=tesgroup(Fs,optionStruct); %Get face group labels
The output G is $n \times 1$ in size if you have $n$ faces, so you can use it to color the faces, for instance to inspect group label. E.g. using gpatch(F,V,G).
You can get the group id for the group with the most members using:
[~,largestGroupId]=max(groupSize); %Get id of largest group
Then you can access the faces using:
Fs=F(G==largestGroupId,:); %Selecting the largest group
See also this documentation: https://www.gibboncode.org/html/HELP_tesgroup.html
Let me know if this helps.
FYI the tesgroup (tessellation grouping) function shamefully requires MATLAB for-loops and can therefore be quite slow for large meshes.
@jpv20 the above uses "the most faces" rather than areas. You can use something like this to do it based on areas:
groupArea=nan(1,max(G(:))); %Initialize areas
A=patchArea(F,V); %Compute areas for all faces
for q=1:1:max(G(:)) %Loop over all groups
groupArea(q)=sum(A(G==q)); %Assign current area
end
[~,largestGroupId]=max(groupArea); %Get id of largest group in terms of area
I used patchArea :point_up: but for triangles the tri_area works too and may be simpler and faster.
Closing this as stale