simple line/arc segment Polygon_2 fails preconditions while taking orientation()

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

simple line/arc segment Polygon_2 fails preconditions while taking orientation()

Forest Darling
Hello,

As I mentioned in my earlier email, I am having a discrepancy between the exact math and floating point kernels when constructing a "CGAL::Gps_circle_segment_traits_2" Polygon_2, resulting in a crash.

I attached an image of the test case, and the C++ sourcecode that constructs the Polygon_2 and tries to calculate it's orientation. You can uncomment the "#define USE_EXACT_MATH" on line 3 of main.cpp to enable the use of the exact construction kernel to verify it works under that.

Console output when using the "CGAL::Exact_predicates_exact_constructions_kernel" kernel:

g++ -c -o main.o main.cpp -Os -g -std=c++1z -DCGAL_DISABLE_ROUNDING_MATH_CHECK=ON
g++ -o broken-cgal main.o -lCGAL -lCGAL_Core -lmpfr -lgmp
poly = 6 (0 0.5 0.0001 1) [0.01 0.5 --> 0.01 0.5] (0 0.5 0.0001 1) [0.01 0.5 --> -0.01 0.5] (0 0.5 0.0001 1) [-0.01 0.5 --> -0.01 0.5] [-0.01 0.5 --> -0.01 0] (0 0 0.0001 1) [-0.01 0 --> 0.01 0] [0.01 0 --> 0.01 0.5]
poly.orientation() = 1

Console output when using the "CGAL::Simple_cartesian<double>" kernel:

g++ -c -o main.o main.cpp -Os -g -std=c++1z -DCGAL_DISABLE_ROUNDING_MATH_CHECK=ON
g++ -o broken-cgal main.o -lCGAL -lCGAL_Core -lmpfr -lgmp
poly = 4 (0 0.5 0.0001 1) [0.01 0.5 --> -0.01 0.5] [-0.01 0.5 --> -0.01 0] (0 0 0.0001 1) [-0.01 0 --> 0.01 0] [0.01 0 --> 0.01 0.5]
terminate called after throwing an instance of 'CGAL::Precondition_exception'
  what():  CGAL ERROR: precondition violation!
Expr: cv1.point_position (p) == EQUAL && cv2.point_position (p) == EQUAL
File: /usr/include/CGAL/Arr_circle_segment_traits_2.h
Line: 254
Aborted (core dumped)

I am using "stock" CGAL 4.11-2build1 on Ubuntu 18.04 64-bit.

Is it normal for the algorithms to be this sensitive? Is it a bug? Or am I doing something wrong?

I'd appreciate any insight!

--Forest

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


Makefile (456 bytes) Download Attachment
main.cpp (6K) Download Attachment
CGAL_Test_Shape.png (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: simple line/arc segment Polygon_2 fails preconditions while taking orientation()

Efi Fogel
It's normal.
It's not a bug.
You are doing something wrong---you are using limited precision.
Use the Epec kernel, for example, it is exact and filtered.
Read the manual.

   ____  _        ____             _
  /_____/_) o    /__________  __  //
 (____ (   (    (    (_/ (_/-(-'_(/
                         _/




On Fri, 14 Aug 2020 at 12:21, Forest Darling <[hidden email]> wrote:
Hello,

As I mentioned in my earlier email, I am having a discrepancy between the exact math and floating point kernels when constructing a "CGAL::Gps_circle_segment_traits_2" Polygon_2, resulting in a crash.

I attached an image of the test case, and the C++ sourcecode that constructs the Polygon_2 and tries to calculate it's orientation. You can uncomment the "#define USE_EXACT_MATH" on line 3 of main.cpp to enable the use of the exact construction kernel to verify it works under that.

Console output when using the "CGAL::Exact_predicates_exact_constructions_kernel" kernel:

g++ -c -o main.o main.cpp -Os -g -std=c++1z -DCGAL_DISABLE_ROUNDING_MATH_CHECK=ON
g++ -o broken-cgal main.o -lCGAL -lCGAL_Core -lmpfr -lgmp
poly = 6 (0 0.5 0.0001 1) [0.01 0.5 --> 0.01 0.5] (0 0.5 0.0001 1) [0.01 0.5 --> -0.01 0.5] (0 0.5 0.0001 1) [-0.01 0.5 --> -0.01 0.5] [-0.01 0.5 --> -0.01 0] (0 0 0.0001 1) [-0.01 0 --> 0.01 0] [0.01 0 --> 0.01 0.5]
poly.orientation() = 1

Console output when using the "CGAL::Simple_cartesian<double>" kernel:

g++ -c -o main.o main.cpp -Os -g -std=c++1z -DCGAL_DISABLE_ROUNDING_MATH_CHECK=ON
g++ -o broken-cgal main.o -lCGAL -lCGAL_Core -lmpfr -lgmp
poly = 4 (0 0.5 0.0001 1) [0.01 0.5 --> -0.01 0.5] [-0.01 0.5 --> -0.01 0] (0 0 0.0001 1) [-0.01 0 --> 0.01 0] [0.01 0 --> 0.01 0.5]
terminate called after throwing an instance of 'CGAL::Precondition_exception'
  what():  CGAL ERROR: precondition violation!
Expr: cv1.point_position (p) == EQUAL && cv2.point_position (p) == EQUAL
File: /usr/include/CGAL/Arr_circle_segment_traits_2.h
Line: 254
Aborted (core dumped)

I am using "stock" CGAL 4.11-2build1 on Ubuntu 18.04 64-bit.

Is it normal for the algorithms to be this sensitive? Is it a bug? Or am I doing something wrong?

I'd appreciate any insight!

--Forest

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
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