Crash/access-violation in PMP::remove_self_intersections
Issue Details
I have a surface which has self-intersections. Running PMP::remove_self_intersections on this surface causes an access violation and crashes the program. No exception is caught. I understand that it's not always possible to fix self-intersections with PMP::remove_self_intersections, but the API should not cause access violation. Throwing an exception in case PMP::remove_self_intersections fails should suffice.
The input surface can be found at the link below: https://drive.google.com/file/d/1q1cOh995zaEgxZz9I_ZXOPKm_-wgOZ4q/view?usp=sharing
Source Code
#include "stdafx.h"
#include <fstream>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Polygon_mesh_processing/repair.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
namespace PMP = CGAL::Polygon_mesh_processing;
int _tmain(int argc, _TCHAR* argv[])
{
Mesh mesh;
std::ifstream ostream_off_file("M:\\test\\Greenstone_cutint.off");
CGAL::read_off(ostream_off_file, mesh);
try {
if (PMP::does_self_intersect(mesh)) {
PMP::remove_self_intersections(mesh);
}
}
catch (...) {
std::cout << "Exception caught" << std::endl;
}
return 0;
}
Environment
- Operating system (Windows/Mac/Linux, 32/64 bits): Windows 64 bit
- Compiler: Visual Studio 2017 MSVC
- Release or debug mode: Release and Debug
- Specific flags used (if any):
- CGAL version: 4.13
- Boost version:1.68
- Other libraries versions if used (Eigen, TBB, etc.):
Any luck with this ?
I was rather busy and did not have a chance to look in detail. I hope I'll find some time during this week.
Update: the version in master should be working if you call PMP::remove_self_intersections(mesh, PMP::parameters::preserve_genus(false);. I'm still working on fixing the other case but I'm missing time for now.
By working I mean not crashing, but some part are still intersecting and this method is not able to fix those for now.
Thanks Sebastien. What does the 'preserve_genus' parameter do? I couldn't find it in the documentation.
The function is not documented for now so that's at least consistent :) It controls whether the genus of the model can be changed or not. In your particular case, the remaining issues are due to non-manifold vertices that got removed if I allow genus change.