Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Valid and closed polyhedron cannot be converted into nef polyhedron

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Valid and closed polyhedron cannot be converted into nef polyhedron


Chronological Thread 
  • From: Sebastien Loriot <>
  • To:
  • Subject: Re: [cgal-discuss] Valid and closed polyhedron cannot be converted into nef polyhedron
  • Date: Wed, 5 May 2021 10:47:37 +0200
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-hdrordr: A9a23:VHANm62f2siJdlLCHffyjQqjBbRyeYIsi2QD101hICF9WMqeisyogbA/3Rj7lD4eVBgb6K29EYOHRm7R8oMw3JIYOq2sUBKjlGyjKoxj6oWK+UydJwTV8OlB2aB8N5VvEdGYNykBse/WwimdV+whzt6O7byyiY7lpUtFYAl2Z8hbnmFEIymBFEkefngjObMYE96m6tNDt36cfx0sH7+GL10ke8SGmNHRjpLhZnc9dmYawS2Dlymh5rK/MzXw5GZ4bxp1zb0v8XfInmXCj83J082T8RPS23Te6J5bgrLau75+LfeBl9QPLXHUghuoDb4BZ5S5oDs3rOuzgWxa8+XknhFIBbUQ11rsZG2v5TPi1w78uQxekkPK+Bu3hT/GrdbiTDw3T/BdjZ9UGyG012MQ+P971qxP0ya1lbpySSnBkiP0+sTSW3hR+3ackD4Nl+gcinAaa48Ccftqq5AF9k89Kvg9NRO/04wsHOlwAMy03phrTW8=
  • Ironport-phdr: A9a23:jr1AGBCvLfsyKmh5P2yqUyQUq0QY04WcBSYlr6E/grcLSJyIuqrYVGTh7PlgxGXEQZ/co6odzbaP4ua6AjNLsM/JmUtBWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYdFRrlKAV6OPn+FJLMgMSrzeCy/IDYbxlViDanbr5+MRG7oR/PusQYg4ZuJaI8xgbUqXZUZupawn9lK0iOlBjm/Mew+5Bj8yVUu/0/8sNLTLv3caclQ7FGFTo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+wnIDJPSiG2YkbyrfOISxn3j7mCGmFGDtkhDTA99V+3hWmoeYVee+c/94VnDSKPoDLAPPQ5IyMrEIaxPPI66xW5aTevubYyNK1m6nH29UE7g7oPJV5LjfiAm5AuYDUEFlw4J+nPuHQc7Dyal5WnZCW43fXrfJnj0+Ow7k0uVC1cuxmmiYEho1r7z8RkQ16T0Y8NW5aoNvWIakxsxHFu52Lr+DtOBo09+ZvwZb45hplhA0m3dukp2OZnyd8hf

Note that there is an alternative package to perform Boolean operations
(with some restrictions on the kind of input/output handled) available
in the Polygon mesh processing package:

https://doc.cgal.org/latest/Polygon_mesh_processing/#title13

Those restriction enables this package to have better runtimes than
Nef.

Best regards,

Sebastien.

On 5/5/21 10:36 AM, Matthew Lai ( via cgal-discuss Mailing List) wrote:
Thanks Maxime.

I had missed that part of the documentation, and indeed switching to EPECK fixed it.

Thanks for your help!

On Wed, May 5, 2021 at 8:03 AM Maxime Gimeno < <>> wrote:

Hi,

I think the problem is your kernel. If you look at the documentation
<https://doc.cgal.org/latest/Nef_3/classCGAL_1_1Nef__polyhedron__3.html>,
you can see that the kernel used for a Nef_polyhedron_3 must be
exact, and the one you are using has inexact constructions. You can
try to replace Epick by Epeck

<https://doc.cgal.org/latest/Kernel_23/classCGAL_1_1Exact__predicates__exact__constructions__kernel.html>,
I have tried on my machine and it works.

Le mar. 4 mai 2021 à 23:46, Matthew Lai <
<>> a écrit :

Hello!

I am running into an assertion fail trying to convert a
polyhedron into a Nef polyhedron, despite the polyhedron being
apparently closed and valid. Can someone help?

I have simplified it down to this minimal test case including
the model file:
=============================================
#include <iostream>
#include <sstream>

#include "CGAL/Exact_predicates_inexact_constructions_kernel.h"
#include "CGAL/Nef_polyhedron_3.h"
#include "CGAL/Polyhedron_3.h"

namespace {

constexpr char kModel[] = R"""(
OFF
24 52 0
296.9305 -36.80449 0
296.9305 -280 0
296.9305 -36.80449 50
296.9305 -280 50
30.94792 -36.80449 0
30.94792 -36.80449 50
30.94792 -280 0
30.94792 -280 50
296.9305 -322.1497 0
296.9305 -529.0251 0
296.9305 -322.1497 50
296.9305 -529.0251 50
30.94792 -322.1497 0
30.94792 -322.1497 50
30.94792 -529.0251 0
30.94792 -529.0251 50
0 0 0
0 -560 0
0 0 50
0 -560 50
330 -3.944305e-30 0
330 0 50
330 -560 0
330 -560 50
3 0 1 2
3 2 1 3
3 4 0 5
3 5 0 2
3 6 4 7
3 7 4 5
3 1 6 3
3 3 6 7
3 8 9 10
3 10 9 11
3 12 8 13
3 13 8 10
3 14 12 15
3 15 12 13
3 9 14 11
3 11 14 15
3 16 17 18
3 18 17 19
3 20 16 21
3 21 16 18
3 22 20 23
3 23 20 21
3 17 22 19
3 19 22 23
3 15 19 11
3 11 19 23
3 11 23 10
3 10 23 3
3 10 3 7
3 15 13 19
3 19 13 7
3 19 7 18
3 18 7 5
3 18 5 2
3 13 10 7
3 18 2 21
3 21 2 3
3 21 3 23
3 12 14 17
3 17 14 9
3 17 9 22
3 22 9 8
3 22 8 1
3 1 8 12
3 1 12 6
3 6 12 17
3 6 17 16
3 22 1 20
3 20 1 0
3 20 0 16
3 16 0 4
3 16 4 6
)""";

using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
using Polyhedron_3 = CGAL::Polyhedron_3<Kernel>;
using Nef_polyhedron_3 = CGAL::Nef_polyhedron_3<Kernel>;

}  // namespace

int main(int argc, char** argv) {
  Polyhedron_3 poly;
  std::stringstream ss(kModel);
  ss >> poly;
  poly.normalize_border();
  std::cout << "is_closed(): " << poly.is_closed() << std::endl;
  std::cout << "is_valid(): " << poly.is_valid(false, 1) <<
std::endl;
  std::cout << "is_pure_triangle(): " <<
poly.is_pure_triangle() << std::endl;
  std::cout << "# faces: " << poly.size_of_facets() << std::endl;
  std::cout << "# vertices: " << poly.size_of_vertices() <<
std::endl;
  std::cout << "# border halfedges: " <<
poly.size_of_border_halfedges() << std::endl;

  Nef_polyhedron_3 nef_poly(poly);
  std::cout << "volumes: " << nef_poly.number_of_volumes() <<
std::endl;
  std::cout << "nef(poly) is_valid: " <<
nef_poly.is_valid(false, 3) << std::endl;
  std::cout << "is_simple: " << nef_poly.is_simple() << std::endl;
}
=============================================

And this is the output:
=============================================
is_closed(): 1
is_valid(): 1
is_pure_triangle(): 1
# faces: 52
# vertices: 24
# border halfedges: 0
CGAL error: assertion violation!
Expression : ss_circle.has_on(sv_prev->point())
File       : CGAL/Nef_3/polygon_mesh_to_nef_3.h
Line       : 256
Explanation:
Refer to the bug-reporting instructions at
https://www.cgal.org/bug_report.html
<https://www.cgal.org/bug_report.html>
Unhandled exception:
    @     0x55c31fb34732  GoogleTerminateHandler()
    @     0x55c31fc5a768  std::__terminate()
    @     0x55c31fc59dfb  __cxxabiv1::failed_throw()
    @     0x55c31fc59d75  __cxa_throw
    @     0x55c31fab767c  CGAL::assertion_fail()
    @     0x55c31faecdcd  CGAL::polygon_mesh_to_nef_3<>()
    @     0x55c31fac2ec2  CGAL::polyhedron_3_to_nef_3<>()
    @     0x55c31fab6ea6
 CGAL::Nef_polyhedron_3<>::Nef_polyhedron_3<>()
    @     0x55c31fab5bbb  main
    @     0x7f1dff68abbd  __libc_start_main
    @     0x55c31fab5569  _start
libc++abi: terminating with uncaught exception of type
CGAL::Assertion_exception: CGAL ERROR: assertion violation!
Expr: ss_circle.has_on(sv_prev->point())
File: CGAL/Nef_3/polygon_mesh_to_nef_3.h
Line: 256
*** SIGABRT received by PID 3953462 (TID 3953462) on cpu 10 from
PID 3953462; ***
E0504 22:31:27.565500 3953462 process_state.cc:770] RAW: Raising
signal 6 with default behavior
Aborted
=============================================

Thanks for your help!
Matthew


-- You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss
<https://sympa.inria.fr/sympa/info/cgal-discuss>


-- You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss
<https://sympa.inria.fr/sympa/info/cgal-discuss>


--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss




Archive powered by MHonArc 2.6.19+.

Top of Page