-
Hello, Using |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 2 replies
-
Beta Was this translation helpful? Give feedback.
-
For me there's only one connected component here. Two connected components must be separate. But you're right, there's a potential problem. It could happen that two connected components share a common vertex. So we would have to duplicate this vertex. I think that Boost constructs the connected components from the edges. Here is the code I use: Vertex_index_map vccmap = mesh.add_property_map<vertex_descriptor, std::size_t>("v:CC").first;
const std::size_t ncc = connected_components(mesh, vccmap);
std::vector<std::vector<EMesh3::Vertex_index>> components(ncc);
for(EMesh3::Vertex_index v : mesh.vertices()) {
std::size_t c = vccmap[v];
components[c].push_back(v);
} Wondering what would happend if there's a common vertex... Will try later. |
Beta Was this translation helpful? Give feedback.
-
Hmm I will take a look at the dual graph notion. No, it's not related to #7148 With |
Beta Was this translation helpful? Give feedback.
-
I think I was wrong: if we can retrieve the original face indices in the parent mesh, then we can retrieve the original vertex indices in the parent mesh. Indeed, take a vertex in a component. You can get its face. Then you can get the index of the corresponding face in the parent mesh. Then you can retrieve the corresponding vertex in the parent mesh by using the index of the vertex within the face. |
Beta Was this translation helpful? Give feedback.
-
I'm not able to retrieve the vertex descriptor in the parent mesh. What's wrong in this code: // input: cv is a vertex descriptor in the component mesh `cmesh`
face_descriptor cf = cmesh.face(cmesh.halfedge(cv)); // the face of cv in cmesh
face_descriptor pf = // my code to get the face in the parent mesh `mesh` - it works
int vi = CGAL::vertex_index_in_face(cv, cf, cmesh);
halfedge_descriptor ph = mesh.halfedge(pf);
while(vi > 0) {
ph = mesh.next(ph);
vi--;
}
vertex_descriptor pv = mesh.source(ph); // should be the vertex descriptor in the
// parent mesh corresponding to `cv` |
Beta Was this translation helpful? Give feedback.
-
I see: something has disturbed the order of the vertices within the faces. Don't know what yet. |
Beta Was this translation helpful? Give feedback.
-
I found: I use |
Beta Was this translation helpful? Give feedback.
-
Completely stupid. With |
Beta Was this translation helpful? Give feedback.
Completely stupid. With
Filtered_face_graph
andcopy_face_graph
usingvertex_to_vertex_map
, it is straightforward to transfer the vertex properties of the parent mesh to a connected component. There's no need to retrieve the face indices of the component in the parent mesh, and no need to use the vertex indices within the faces.