Scale space reconstruction does not return a mesh
The "Scale-Space Surface Reconstruction" algorithm states that it creates a reconstructed mesh. It does not however return a triangulated mesh, rather some kind of object from which one has to figure out how to extract the mesh.
I looked in a bunch of places and all of them show the same thing.
https://doc.cgal.org/latest/Scale_space_reconstruction_3/Scale_space_reconstruction_3_2scale_space_8cpp-example.html#_a2 https://doc.cgal.org/latest/Scale_space_reconstruction_3/classCGAL_1_1Scale__space__surface__reconstruction__3.html#a300d0992b3be8caeacc1da30c5315eff
It would be helpful if the tutorial for this functionality would do the same as for the rest of examples. Input should be points, output should be a mesh the user can work with.
You can easily create the mesh. See code below. Don't pay attention to the Rcpp::NumericMatrix.
Mesh3 SSSreconstruction_cpp(
const Rcpp::NumericMatrix pts, const size_t scaleIterations,
const unsigned nneighs, const unsigned nsamples,
const bool separateShells, const bool forceManifold, const double borderAngle
) {
std::vector<Point3> points = matrix_to_points3<Point3>(pts);
SSS_reconstruction SSSR(points.begin(), points.end());
SSS_smoother smoother(nneighs, nsamples);
SSSR.increase_scale(scaleIterations, smoother);
SSS_mesher mesher(
smoother.squared_radius(), separateShells, forceManifold, borderAngle
);
SSSR.reconstruct_surface(mesher);
Mesh3 mesh;
for(
SSS_point_iterator it = SSSR.points_begin(); it != SSSR.points_end(); ++it
) {
mesh.add_vertex(*it);
}
for(
SSS_facet_iterator it = SSSR.facets_begin(); it != SSSR.facets_end(); ++it
) {
std::array<size_t, 3> face = *it;
mesh.add_face(vxdescr(face[0]), vxdescr(face[1]), vxdescr(face[2]));
}
return mesh;
}
Thank you. This is helpful. Likely users will be grateful if the SSS_reconstruction class has an operator to return the mesh, maybe just the code you mention. And if that operator is added, the existing examples can be standardised to use it. I pointed out above two locations where the SSS reconstruction is used and would help if a mesh is returned. Another one is https://github.com/CGAL/cgal/blob/a8e87526348d2d1faa2ea893747314853ee6868d/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/tutorial_example.cpp.
CGAL is a great library but its API takes a while to understand and the variety of structures used and approaches can be very confusing. I understand why, it is a heterogenous set of libraries by many people, and also very flexible, but it is hard to understand. Having at least an algorithm return a mesh rather than the user having to understand how to make that mesh, would help.
Note that scale space reconstruction creates a triangle soup, so maybe we should have a method that writes into a vector of points and a vector of vertex triples and the user then orients them and constructs a surface mesh as in this example of the Polygon Mesh Processing package.
That will work, I think. It will also make the example at https://github.com/CGAL/cgal/blob/c36d6df775f930880eae243385f33380d3ccc479/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/tutorial_example.cpp#L13 have uniform treatment for the three kinds of surface reconstruction in it.
It would be nice if the example https://doc.cgal.org/latest/Scale_space_reconstruction_3/Scale_space_reconstruction_3_2scale_space_8cpp-example.html#_a2 is modified too.
Thank you for looking into this. Such small things make the library a lot more user-friendly.