Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] CGAL::Polygon_mesh_processing::corefine_and_compute_difference(..) unable to calc second time

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] CGAL::Polygon_mesh_processing::corefine_and_compute_difference(..) unable to calc second time


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] CGAL::Polygon_mesh_processing::corefine_and_compute_difference(..) unable to calc second time
  • Date: Tue, 5 May 2020 11:35:11 +0200
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:sIP40hKuzn6ZDLQnXNmcpTZWNBhigK39O0sv0rFitYgXKv/7rarrMEGX3/hxlliBBdydt6sZzbWI+Pm9EUU7or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQviPgRpOOv1BpTSj8Oq3Oyu5pHfeQpFiCe9bL9oLhi7rArdutQWjIB/Nqs/1xzFr2dSde9L321oP1WTnxj95se04pFu9jlbtuwi+cBdT6j0Zrw0QrNEAjsoNWA1/9DrugLYTQST/HscU34ZnQRODgPY8Rz1RJbxsi/9tupgxCmXOND9QL4oVTi+6apgVRnlgzoFOTEk6mHaktF+grxVoByhpBJxzYDbb46XO/ViZa7deM8WSHBbU8pNWSFMAIWxZJYPAeobOuZYqpHwq1UToxSgHgajHvjvyiNJhnDo260xzuIvEQbc3AwhGNIOrGnfoNH0OqgMVuC1ybfHzSnZb/JW2Tny8pTHcgwmofGWXbN8dMTdwlQoGgPeilWQrpblPzKS1uQRqWSb6u5gWPmgi24isQ5xozyvyt0whYnOg4IY01bJ/jh2z4gpP9O3UlJ7YcK6H5tKsSGXL4R4Tt0sTmxruis31qELtJ6lcSUJyJor2x3SZv6HfYWH7BzuWvqcLCp4iX9qd7yymRi//EiuxODhSMW530hGoy5Dn9LRuH4N0BnT5dKGSvt75kquxTmP2BrX6u1eJkA0j6XbJ4YnwrEqjZUcqkDDETHslErqi6+Wc10o+uep6+T7YrXmu4STO5VohQH5N6QjnNG0D+cgMgUWQWSX5eCx2Kfg8ED5WrlGkOM6nrTDvJ3aOcgXvrC1DBVJ3oo+7huwESuq384dkHUZMF5JZReKgobzNF3QPPz1CPiyj0ixnzhwwv3LOqHtDonTIXXGnrfsf6hy5kpZxQcx0NxQ+pBZB7ccK/zpQEDxrsbXDhohPgy03ennDNJ925sbWW2VA6+ZNLresFGS5u4yOuWMao8YtCrnJ/gq4P7uinA5mVsDcqWzwZQXb3W4EuxnI0Wff3Xsns8MHXkWsgc6VuDni12PXSRNa3qsQq4w/DE2BJ6+AYfGXI+tgbiB3CmhHp1RY2BLEkuMEXPvd4WeWvcMbz6SLtVkkjwATrWhRIoh2guvtA/+0bZoMu3U+igAuZL5yNd1//HTlQ019TFsE8ud3HuCT2VtkmwVRj82x7xwoVFmyleYyqV4mPxZFdlL5/xTSAs6NJjcz/Z7C9/oQA7BcM2JGx6aRYCtDjg1C94w2NQTeF1VGtO4jxmF0TD5LaUSkunBP5E++7nA3nX3b+J60XfByOFhoFQhR8ZTL3yIj6Vj8BLCRsSBx16dkLyrcrha2Srl+2KKzG7It0ZdBl0jGZ7ZVGwSMxOF5e/y4VnPGuf3VOYXdzBZwMvHEZNkL93kiVIcGaXmMdXaJn2rwiK+WE7OybSLY47nPW4a2XeFURRWo0Uo5X+DcDMGKGK5uWuHVW5hEFvuZwXn9uws8CrqHH9x9BmDagha75Tw/xcUgfKGTPZKh+ALvS4gr3N/G1Pvht8=

If you look at the return value of the function, it will tell you that the second operation could not be computed. Looking in details, there is
a small non-manifold edge that prevents the operation to be performed.

In you case, this happens because of rounding issues after the first operation.

Two solutions:
1) you know that mesh_end1 and mesh_end2 are disjoint, you can call
mesh_end1.join(mesh_end2) as in the attached example and do only one
difference operation.

2) you have more operations to do and you want to use an exact vertex
point map to avoid issues. The following example shows how to create
an exact vertex point map that also maintains the rounded version:

https://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2corefinement_consecutive_bool_op_8cpp-example.html


Note that in your case your input was valid but if you have some
non-manifold edges in the output no result can be computed with
the current version of the code.

Best,

Sebastien.



On 4/30/20 3:40 PM, stiklaz wrote:
Sebastien Loriot (GeometryFactory) wrote
To avoid unwanted rounding, try:

stream << std::setprecision(17) << my_mesh;

Yes, now i get the same mesh after save/load.
So here are the original meshes:
mesh_end1.off
<http://cgal-discuss.949826.n4.nabble.com/file/t376212/mesh_end1.off>
mesh_end2.off
<http://cgal-discuss.949826.n4.nabble.com/file/t376212/mesh_end2.off>
mesh_main.off
<http://cgal-discuss.949826.n4.nabble.com/file/t376212/mesh_main.off>

and here is the code snippet where second cut fails: link
<https://gist.github.com/stiklaz/39ee8ecf6827d25502900831d9f3e3aa>




--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>

#include <CGAL/Polygon_mesh_processing/corefinement.h>

#include <fstream>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3>             Mesh;

namespace PMP = CGAL::Polygon_mesh_processing;

int main()
{
  Mesh mesh_end1, mesh_end2, mesh_main;
  std::ifstream("mesh_end1.off") >> mesh_end1;
  std::ifstream("mesh_end2.off") >> mesh_end2;
  std::ifstream("mesh_main.off") >> mesh_main;
  
  mesh_end1.join(mesh_end2);
  bool valid = PMP::corefine_and_compute_difference(mesh_main,mesh_end1, mesh_main, CGAL::parameters::throw_on_self_intersection(true));

  
  std::ofstream output("res.off");
  output.precision(17);
  output << mesh_main;  
  
  if (valid)
  {
    std::cout << "Output was successfully computed\n";
    return 0;
  }
  std::cout << "Output could not be computed\n";

  return 1;
}



Archive powered by MHonArc 2.6.18.

Top of Page