cgal icon indicating copy to clipboard operation
cgal copied to clipboard

Cannot read a PLY or OFF file in an EPECK mesh since version 5.5.2

Open stla opened this issue 2 years ago • 0 comments

Hello,

With version 5.4 I was able to read a PLY/OFF file directly in an EPECK mesh. Now with 5.5.2 this crashes the session.

So I changed my code, the following one works. Mesh3 is EPICK and EMesh3 is EPECK`.

EMesh3 readValidMesh(const std::string filename, bool binary) {
  Mesh3 mesh;
  const std::string ext = toLower(filename.substr(filename.length() - 4, 4));
  bool ok = false;

  std::ifstream infile;
  if(binary) {
    infile.open(filename, std::ios::binary);
  } else {
    infile.open(filename);
  }

  std::string comments;
  if(ext == ".ply") {
    ok = CGAL::IO::read_PLY(infile, mesh, comments);
  } else if(ext == ".off") {
    ok = CGAL::IO::read_OFF(infile, mesh);
  } else {
    ok = PMP::IO::read_polygon_mesh(
      filename, mesh, CGAL::parameters::verbose(true)
    );
  }
  infile.close();

  if(!ok) {
    Rcpp::stop("Reading failure.");
  }

  if(!comments.empty()) {
    Message("Comments found in " + filename + ":");
    Message("------------------");
    Message(comments);
  }

  const bool valid = mesh.is_valid(false);
  if(!valid) {
    Rcpp::warning("The mesh is not valid.");
  }

  EMesh3 emesh;
  CGAL::copy_face_graph(
    mesh, emesh
  );
  return emesh;
}

But if you replace Mesh3 mesh with EMesh3 mesh at the beginning, it crashes.

stla avatar Jun 07 '23 17:06 stla