Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stitch_borders_example output error #8300

Open
citystrawman opened this issue Jun 21, 2024 · 2 comments
Open

stitch_borders_example output error #8300

citystrawman opened this issue Jun 21, 2024 · 2 comments

Comments

@citystrawman
Copy link

Please use the following template to help us solving your issue.

Issue Details

I am studying the polygon mesh processing stitch_borders_example, and I think this example shows that by using stitch_borders(), it will stitch the duplicated nodes, I ran this program and from the off file we can see that it actually does merge duplicated nodes:

quads_to_stich.off:
OFF
20 8 0
1 0 0
0.75 0 0
0.5 0 0
0.25 0 0
0 0 0
0 1 0
0.25 1 0
0.5 1 0
0.75 1 0
1 1 0
1 1 0
0.75 1 0
0.5 1 0
0.25 1 0
0 1 0
0 2 0
0.25 2 0
0.5 2 0
0.75 2 0
1 2 0
4  5 6 3 4
4  3 6 7 2
4  1 2 7 8
4  1 8 9 0
4  15 16 13 14
4  13 16 17 12
4  11 12 17 18
4  11 18 19 10
mesh_stitched.off:
OFF
15 8 0

1 0 0
0.75 0 0
0.5 0 0
0.25 0 0
0 0 0
0 1 0
0.25 1 0
0.5 1 0
0.75 1 0
1 1 0
0 2 0
0.25 2 0
0.5 2 0
0.75 2 0
1 2 0
4  5 6 3 4
4  3 6 7 2
4  1 2 7 8
4  1 8 9 0
4  10 11 6 5
4  6 11 12 7
4  8 7 12 13
4  8 13 14 9

however, in the terminal output, it is shown as follows:

Before stitching :
         Number of vertices  :  15
         Number of halfedges :  44
         Number of facets    :  8
Stitching done :
         Number of vertices  :  15
         Number of halfedges :  44
         Number of facets    :  8

I dont know if this is a bug ?

Source Code

Environment

  • Operating system (Windows/Mac/Linux, 32/64 bits):
  • Compiler:
  • Release or debug mode:
  • Specific flags used (if any):
  • CGAL version:
  • Boost version:
  • Other libraries versions if used (Eigen, TBB, etc.):
@MaelRL
Copy link
Member

MaelRL commented Jun 21, 2024

You are probably using a CGAL::Surface_mesh and getting the number of elements through num_vertices() and similar functions.

As the doc indicates:

num_vertices() may return a number larger than std::distance(vertices(g).first, vertices(g).second). This is the case for implementations only marking vertices deleted in the vertex container.

This is because the surface mesh will have "garbage" (i.e., removed elements) after calling PMP::stitch_borders duplicate elements have been removed during stitching. In CGAL::Surface_mesh, these are not purged from memory unless you call collect_garbage() and thus the number of elements through num_vertices(sm) is unchanged.

If you want the exact number of elements without collecting garbage, you can use the number_of_vertices member function of the CGAL::surface_mesh, or std::distance(...), or vertices(sm).size(), or CGAL::internal::exact_num_vertices(sm), ...

@citystrawman
Copy link
Author

citystrawman commented Jun 21, 2024

You are probably using a CGAL::Surface_mesh and getting the number of elements through num_vertices() and similar functions.

As the doc indicates:

num_vertices() may return a number larger than std::distance(vertices(g).first, vertices(g).second). This is the case for implementations only marking vertices deleted in the vertex container.

This is because the surface mesh will have "garbage" (i.e., removed elements) after calling PMP::stitch_borders duplicate elements have been removed during stitching. In CGAL::Surface_mesh, these are not purged from memory unless you call collect_garbage() and thus the number of elements through num_vertices(sm) is unchanged.

If you want the exact number of elements without collecting garbage, you can use the number_of_vertices member function of the CGAL::surface_mesh, or std::distance(...), or vertices(sm).size(), or CGAL::internal::exact_num_vertices(sm), ...

but the output shows the numbe of vertex after stitching, not before stitching, which is weired. (I just use the code pulled from git, the branch is 5.5.x)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants