-
Hi, I generated a Polyhedron_3 from a triangle soup. I followed the examples and repaired the soup first. The triangles were already oriented. I then combined the soup to a Polyhedron_3, and then tried to repair the surface mesh as much as possible. I then illustrated both the faces (grey) and the borders (red) of the mesh (down below). It seems some halfedges are not merged or stitched. What should I do? Should I somehow increase the tolerance? Please help. Thanks. Here's the code: CGAL::Polygon_mesh_processing::repair_polygon_soup(points, triangles);
// Then, since triangles are already oriented, we merge the soup to create the Polyhedron_3
Polyhedron isoSurface;
CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh(points, triangles, isoSurface);
CGAL::Polygon_mesh_processing::merge_duplicated_vertices_in_boundary_cycles(isoSurface);
CGAL::Polygon_mesh_processing::stitch_borders(isoSurface);
CGAL::Polygon_mesh_processing::remove_degenerate_edges(isoSurface);
CGAL::Polygon_mesh_processing::remove_almost_degenerate_faces(isoSurface); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This problem was fixed when I used a customized trait: struct Array_traits {
double marginSquared; // Member to store the squared margin for comparison
// Constructor to initialize marginSquared
Array_traits(double min_squared) : marginSquared(min_squared * 0.1) {} // Adjusting margin here directly
struct Equal_3 {
double marginSquared;
Equal_3(double marginSquared) : marginSquared(marginSquared) {}
bool operator()(const K::Point_3& p, const K::Point_3& q) const {
return CGAL::squared_distance(p, q) < marginSquared;
}
};
struct Less_xyz_3 {
double marginSquared;
Less_xyz_3(double marginSquared) : marginSquared(marginSquared) {}
bool operator()(const K::Point_3& p, const K::Point_3& q) const {
if (CGAL::squared_distance(p, q) < marginSquared) {
return false; // Consider equal within margin, so not less
}
// Lexicographical comparison considering margin
if (std::fabs(p.x() - q.x()) >= marginSquared) {
return p.x() < q.x();
}
if (std::fabs(p.y() - q.y()) >= marginSquared) {
return p.y() < q.y();
}
return p.z() < q.z(); // No margin comparison needed for the last coordinate
}
};
Equal_3 equal_3_object() const { return Equal_3(marginSquared); }
Less_xyz_3 less_xyz_3_object() const { return Less_xyz_3(marginSquared); }
}; and then : CGAL::Polygon_mesh_processing::repair_polygon_soup(points, triangles, CGAL::parameters::geom_traits(Array_traits(min_square_length))); |
Beta Was this translation helpful? Give feedback.
This problem was fixed when I used a customized trait: