cgal icon indicating copy to clipboard operation
cgal copied to clipboard

Crash/access-violation in PMP::remove_self_intersections

Open shareq2005 opened this issue 7 years ago • 6 comments

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.):

shareq2005 avatar Dec 19 '18 16:12 shareq2005

Any luck with this ?

shareq2005 avatar Jan 11 '19 18:01 shareq2005

I was rather busy and did not have a chance to look in detail. I hope I'll find some time during this week.

sloriot avatar Jan 14 '19 17:01 sloriot

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.

sloriot avatar Feb 08 '19 07:02 sloriot

By working I mean not crashing, but some part are still intersecting and this method is not able to fix those for now.

sloriot avatar Feb 08 '19 07:02 sloriot

Thanks Sebastien. What does the 'preserve_genus' parameter do? I couldn't find it in the documentation.

shareq2005 avatar Feb 11 '19 15:02 shareq2005

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.

sloriot avatar Feb 11 '19 15:02 sloriot