Garmaine Staff asked 1 year ago

I have a tetrahedral mesh as a vector of points (std::array<double, 3>) and a vector of tetrahedrons (std::array<int, 4>). I want to check if a particular vertex belongs to the boundary of the mesh.

For that, each tetrahedron defines 4 faces ([0,1,2], [0,1,3], [1,2,3] and [0,2,3]). The face [0,1,2] is considered equal as the face [0,2,1] or any other permutation. A face is a boundary if it only exists once in all the mesh. Internal faces appear twice. A vertex is a boundary if it belongs to a boundary face.

My plan is to create a vector of all the faces (std::array<int, 3>) and then remove the entries that appear twice. I want to remove both entries if they appear twice, not only the repeated one. Also, the equality comparator must be capable of detecting if two faces are equivalent, taking into account the possible permutations.

I am not sure how to proceed with this or if storing a vector with all the faces and then removing elements is the best solution. Any ideas would be very helpful.