patchslim question: how does fnew = indexn(f) work in the code

4 visualizaciones (últimos 30 días)
Zhangxi Feng
Zhangxi Feng el 21 de En. de 2018
Editada: Zhangxi Feng el 21 de En. de 2018
The code essentially takes in V: a nx3 matrix containing a bunch of coordinates in space representing the vertices, and F: a mx3 matrix containing sets of indices that point to V, essentially each row in F contains the three vertices that makes up a face.
Through the process of generating STL grains and combine them into one STL file, faces are often duplicated. Patchslim's purpose is to remove the duplicate faces through the use of the unique function.
I know the following relationship of the unique function call:
[Vnew, ia, ic] = unique(V,'rows');
Vnew = V(ia,:); V = Vnew(ic,:);
Basically ia is the indices of the unique elements in V, and ic is the indices of the elements in V that is still in Vnew.
Next, naturally, with the vertices removed, the code would need to remove the faces that reference to the removed vertices. The function finishes with the code: fnew = indexn(F) and I couldn't wrap my head around what this code is actually doing.
indexn is a 3Mx1 column array and F is the Mx3 matrix. First of all, how does using Mx3 matrix as index to pull items from a 3Mx1 array even work? I tried to duplicate this line of code by manually creating a 3x3 matrix being used as indices for a 9x1 array, but Matlab returns the "Index exceeds matrix dimensions" error.
Attached is an example V, and F data that you can use with patchslim.
Can anyone give me some insight as to how do you reference a 3Mx1 array with a Mx3 matrix?
Thanks!

Respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by