CGAL precondition error

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

CGAL precondition error

Siyan Dong

Issue Details

Hi, I opened an issue on github get no reply. The issue is: 

I use CGAL to compute difference between two polygons. Sometimes it works well, but sometime it get runtime error:

CGAL error: precondition violation!
Expression : (m_traits.compare_y_at_x_2_object()(p, cv1) == EQUAL) && (m_traits.compare_y_at_x_2_object()(p, cv2) == EQUAL)
File : D:\cgal\include\CGAL/Arr_segment_traits_2.h
Line : 580
Explanation:
Refer to the bug-reporting instructions at http://www.cgal.org/bug_report.html

Whats meaning of this precondition? Does it mean input polygons are not in correct format? I wonder what cause this problem and how to solve it. Thanks in advance!

Source Code

   // polygon 1
   Polygon_with_holes_2 p1;
   ifstream ifs("domain");
   ifs >> p1;
   ifs.clear();
   ifs.close();
   
   // polygon 2
   Polygon_2 p2;
   ifs.open("hole");
   ifs >> p2;
   ifs.clear();
   ifs.close();

   // check orientation
   if (p1.outer_boundary().area() < 0)
          p1.outer_boundary().reverse_orientation();
   if (p2.area() < 0)
          p2.reverse_orientation();

   // difference
   Pwh_list_2 results;
   CGAL::difference(p1, p2, back_inserter(results));

Failure case two polygons:

file "domain":
454 391.004 -217.982 390.041 -218.994 390.053 -219.916 390.057 -220.906 390.062 -221.94 389.031 -222.981 389.015 -223.932 389.069 -224.97 389.031 -225.913 389.053 -226.939 388.048 -227.94 388.047 -228.965 388.072 -229.948 388.044 -230.914 387.077 -231.947 387.087 -232.978 387.094 -233.918 386.021 -234.989 385.091 -234.995 384.085 -234.978 383.064 -234.998 382.028 -234.906 381.057 -234.996 380.042 -234.945 379.022 -234.963 378.098 -234.912 377.038 -234.907 376.082 -234.948 375.009 -234.937 374.018 -234.953 373.036 -234.946 372.072 -234.949 371.016 -234.972 370.017 -234.9 369.036 -234.933 368.068 -234.952 367.032 -234.966 366.059 -234.918 365.069 -234.989 364.064 -234.985 363.017 -234.918 362.05 -234.961 361.086 -234.947 360.054 -234.924 359.079 -234.923 358.064 -234.92 357.043 -234.928 356.016 -234.951 355.067 -234.904 354.071 -234.999 353.003 -234.928 352.092 -234.949 351.076 -234.975 350.083 -234.927 349.044 -234.966 348 -234.937 347.068 -234.954 346.016 -234.911 345.083 -234.949 344.039 -234.943 343.095 -234.902 342.058 -234.932 341.015 -234.991 340.024 -234.911 339.05 -234.904 338.051 -234.967 337.06 -234.96 336.02 -234.948 335.013 -234.988 334.09 -234.954 333.024 -234.967 332.096 -234.907 331.028 -234.982 330.028 -235 329.073 -234.984 328.089 -234.913 327.076 -234.905 326 -234.915 325.022 -234.917 324.082 -234.915 323.07 -234.9 322.054 -234.994 321.028 -234.995 321.092 -235.987 321.06 -236.903 321.094 -237.931 321.007 -238.916 322.074 -239.962 323.054 -239.943 324.047 -239.971 325.056 -240.912 324.032 -241.902 323.039 -242.996 323.022 -243.902 323.087 -244.972 323.05 -245.908 323.035 -246.953 323.004 -247.98 322.081 -248.983 321.027 -248.965 320.04 -247.951 319.042 -247.997 318.042 -247.921 317.035 -247.927 316.005 -247.918 315.061 -247.981 314.08 -247.974 313.078 -248.939 313.01 -249.975 312.083 -250.94 312.088 -251.907 311.068 -252.996 311.057 -253.959 310.056 -254.935 309.046 -255.957 309.023 -256.938 309.077 -258 309.005 -258.901 309.034 -259.975 309.06 -260.986 309.045 -261.919 309.089 -262.992 310.051 -263.997 310.012 -264.91 310.013 -265.975 309.067 -266.981 309.053 -267.957 309.057 -268.943 309.05 -269.947 309.089 -270.978 309.005 -271.937 310.055 -272.925 310.098 -273.95 310.084 -274.901 310.038 -275.956 309.004 -276.983 309.04 -277.992 309.074 -278.979 309.025 -279.99 309.099 -280.962 309.08 -281.965 310.092 -282.989 310.067 -283.94 311.01 -284.974 311.033 -285.982 312.014 -286.936 313.092 -287.925 313.077 -289 314.036 -289.937 314.008 -290.966 315.064 -291.924 315.004 -292.923 316.06 -293.919 316.091 -294.924 316.014 -295.95 317.081 -296.901 318.041 -297.948 318.099 -298.937 319.065 -299.961 319.004 -300.97 320.026 -301.961 321.068 -302.947 322.092 -303.908 322.019 -305 323.024 -305.931 323.034 -306.974 324.075 -307.926 324.074 -308.968 325.075 -309.916 325.042 -310.919 326.079 -311.956 327.079 -312.991 328.033 -312.959 329.059 -312.906 330.036 -312.908 331.09 -312.976 332.052 -312.919 333.015 -312.958 334.046 -312.958 335.092 -312.918 336.098 -312.935 337.047 -312.91 338.086 -312.992 339.004 -312.941 340.063 -313.932 339.054 -314.966 338.039 -315.971 337.093 -316.958 336.094 -317.972 335.071 -318.989 334.023 -319.952 334.001 -320.991 334.039 -321.923 334.051 -322.925 334.047 -323.932 334.084 -324.911 334.001 -325.988 335.06 -326.97 336.066 -327.936 337.065 -328.922 337.001 -329.954 337.088 -330.976 338.061 -331.945 339.098 -332.986 339.067 -333.99 340.064 -334.985 340.021 -335.952 341.043 -336.979 341.018 -337.973 342.097 -338.913 343.041 -339.969 343.06 -340.99 344.074 -340.962 345.015 -340.961 346.038 -340.958 347.005 -340.953 348.072 -340.999 349.027 -340.968 350.07 -340.908 351.049 -340.917 352.096 -340.954 353.092 -340.905 354.078 -340.948 355.005 -340.96 356.021 -340.907 357.002 -340.999 358.027 -340.994 359.064 -340.93 360.065 -340.966 361.081 -340.997 362.075 -340.94 363.049 -340.934 364.06 -340.921 365.087 -340.974 366.042 -340.979 367.081 -340.955 368.03 -340.939 369.038 -340.969 370.097 -340.965 371.052 -340.913 372.085 -340.995 373.046 -340.965 374.059 -340.917 375.019 -340.963 376.023 -340.94 377.055 -340.902 378.007 -340.951 379.003 -340.925 380.053 -340.907 381.009 -340.931 382.004 -340.958 383.003 -340.961 384.02 -340.953 385.015 -340.905 386.031 -340.914 387.027 -340.978 388.049 -340.942 389.033 -340.906 390.041 -340.931 391.025 -340.98 392.002 -340.961 393.063 -340.909 394.015 -340.943 395.048 -340.946 396.043 -340.98 397.063 -340.988 398.039 -340.932 399.006 -340.957 400.02 -340.94 401.062 -340.952 402.09 -340.989 403.051 -340.955 404.057 -340.986 405.098 -340.925 406.033 -340.914 407.061 -340.932 408.057 -340.939 409.06 -340.963 410.034 -340.952 411.045 -340.974 412.024 -340.996 413.049 -340.903 414.084 -340.971 415.057 -340.925 416.088 -340.976 417.048 -339.956 417.034 -338.969 418.024 -338 418.053 -336.902 419.004 -335.934 420.045 -334.928 420.082 -333.93 420.047 -332.918 420.026 -331.914 421.05 -330.999 422.032 -330.947 422.093 -329.945 422.092 -328.943 422.025 -327.928 423.002 -326.903 424.085 -325.974 425.067 -325.976 426.077 -324.916 426.023 -323.932 427.088 -322.998 427.041 -321.956 428.044 -320.92 429.024 -319.945 429.035 -318.978 430.073 -317.925 430.005 -316.99 431.026 -315.963 431.05 -314.954 432.047 -313.985 433.004 -312.944 433.063 -311.992 434.074 -310.98 434.044 -309.978 435.087 -308.978 435.005 -307.927 436.013 -306.915 437.028 -305.92 437.047 -304.921 438.1 -303.904 439.086 -302.932 439.038 -301.967 440.093 -300.913 440.023 -299.978 440.099 -298.98 441.096 -297.914 442.017 -296.94 442.044 -295.95 443.023 -294.975 444.032 -293.936 444.083 -292.988 445.004 -291.923 446.083 -290.931 446.012 -289.969 446.026 -288.946 447 -287.998 448.068 -286.928 448.088 -285.921 449.061 -284.944 449.095 -283.909 450.048 -282.92 451.052 -281.926 451.011 -280.925 451.025 -279.997 451 -278.974 451.011 -277.938 451.04 -276.96 450.03 -275.914 450.056 -274.957 450.068 -273.952 450.004 -272.995 450.094 -271.973 450.053 -270.948 450.017 -269.975 450.008 -268.939 450.092 -267.931 450.005 -267 450.052 -265.926 449.087 -264.99 449.062 -263.909 450.081 -262.926 450.089 -261.976 450.085 -260.996 450.075 -259.956 450.095 -258.938 450.098 -257.928 450.059 -256.952 450.028 -255.937 449.016 -254.909 449.047 -253.929 448.089 -252.943 448.045 -251.977 447.085 -250.983 447.064 -249.927 446.098 -248.913 446.093 -247.924 445.04 -246.915 444.004 -245.955 443.096 -244.98 443.007 -243.962 443.063 -242.954 442.034 -241.966 441.022 -240.986 441.028 -239.958 440.035 -238.961 440.03 -237.993 439.008 -236.982 438.061 -235.944 438.002 -234.966 437.083 -234.953 436.053 -234.953 435.033 -234.938 434.057 -234.958 433.019 -234.988 432.008 -234.983 431.072 -234.908 430.028 -234.919 429.035 -234.944 428.077 -234.95 427.098 -234.961 426.09 -233.991 426.044 -232.983 426.027 -231.968 426.025 -230.983 426.077 -229.982 426.032 -228.936 426.011 -227.956 426.072 -226.908 426.015 -225.91 426.027 -224.998 426.006 -223.957 426.094 -222.925 426.062 -221.982 426.089 -220.95 426.06 -219.981 426.019 -218.932 425.066 -217.917 424.097 -217.927 423.057 -217.996 422.001 -217.908 421.032 -217.995 420.063 -217.92 419.085 -217.951 418.083 -217.947 417.099 -217.955 416.051 -217.917 415.028 -217.941 414.077 -217.908 413.037 -217.926 412.011 -217.981 411.062 -217.9 410.051 -217.915 409.05 -217.994 408.022 -217.962 407.064 -217.947 406.03 -217.992 405.091 -217.905 404.055 -217.955 403.043 -217.953 402.014 -217.931 401.099 -217.917 400.038 -217.986 399.069 -217.956 398.001 -217.906 397.032 -217.969 396.045 -217.942 395.025 -217.914 394.031 -217.915 393.032 -217.91 392.085 -217.934 0

file "hole":
120 315.932 -291.015 315.967 -292.035 315.915 -293.051 315.983 -294.098 315.996 -295.042 315.909 -296.006 315.995 -297.051 316.933 -298.044 317.928 -299.089 317.974 -300.067 318.974 -301.039 318.938 -302.051 319.955 -303.087 320.924 -304.004 321.994 -305.012 321.925 -306.002 322.961 -307.04 322.994 -308.081 323.956 -309.007 323.916 -310.068 324.96 -311.05 324.979 -312.07 325.986 -313.057 326.958 -314.013 327.963 -314.004 328.913 -314.042 329.997 -314.011 330.937 -314.072 331.927 -314.028 332.921 -314.02 333.932 -314.015 334.988 -314.081 335.996 -314.095 336.972 -314.097 337.996 -314.058 338.981 -314.076 339.922 -314.003 340.915 -314.01 341.977 -314.077 342.903 -314.052 343.985 -314.014 345 -314.089 345.951 -314.026 346.925 -314.088 347.99 -314.05 348.987 -314.05 349.982 -314.007 350.956 -314.029 351.959 -314.063 352.949 -314.071 352.998 -313.067 352.984 -312.032 352.903 -311.052 353.955 -310.013 354.966 -310.053 355.906 -310.081 356.989 -310.058 357.941 -310.017 358.947 -310.029 359.944 -310.055 360.988 -310.01 360.972 -309.052 360.941 -308.062 360.953 -307.061 360.92 -306.041 360.993 -305.035 360.92 -304.062 360.905 -303.039 361.972 -302.06 361.959 -301.008 361.949 -300.091 361.977 -299.013 361.916 -298.092 361.965 -297.079 360.991 -297.032 359.912 -296.019 358.913 -296.079 357.947 -296.025 356.902 -296.02 355.975 -296.086 354.994 -296.043 353.991 -295.061 353.918 -294.036 352.997 -293.088 351.942 -292.006 350.911 -292.063 349.918 -292.064 348.999 -292.049 347.957 -292.087 346.922 -292.065 345.987 -292.011 344.915 -292.018 343.901 -292.046 342.907 -292.009 341.958 -292.086 340.992 -292.001 339.942 -292.097 338.957 -292.06 337.945 -292.049 336.983 -292.063 335.977 -292.087 334.913 -292.089 333.964 -292.01 332.926 -292.083 331.947 -292.031 330.985 -292.01 329.938 -292.007 328.913 -292.08 327.939 -292.013 326.965 -292.083 325.995 -292.032 324.942 -292.094 323.975 -291.05 322.923 -291.086 321.95 -291.024 320.957 -291.036 319.983 -291.014 318.993 -291.036 317.971 -291.033 316.983 -291.099

Environment

  • Operating system (Windows/Mac/Linux, 32/64 bits): windows 64
  • Compiler: vs 2013
  • Release or debug mode: release
  • CGAL version: 4.9.1
  • Boost version: 1.6.1


Reply | Threaded
Open this post in threaded view
|

Re: CGAL precondition error

Efi Fogel
What kernel are you using? 

On Sun, Jul 22, 2018, 10:29 Siyan Dong <[hidden email]> wrote:

Issue Details

Hi, I opened an issue on github get no reply. The issue is: 

I use CGAL to compute difference between two polygons. Sometimes it works well, but sometime it get runtime error:

CGAL error: precondition violation!
Expression : (m_traits.compare_y_at_x_2_object()(p, cv1) == EQUAL) && (m_traits.compare_y_at_x_2_object()(p, cv2) == EQUAL)
File : D:\cgal\include\CGAL/Arr_segment_traits_2.h
Line : 580
Explanation:
Refer to the bug-reporting instructions at http://www.cgal.org/bug_report.html

Whats meaning of this precondition? Does it mean input polygons are not in correct format? I wonder what cause this problem and how to solve it. Thanks in advance!

Source Code

   // polygon 1
   Polygon_with_holes_2 p1;
   ifstream ifs("domain");
   ifs >> p1;
   ifs.clear();
   ifs.close();
   
   // polygon 2
   Polygon_2 p2;
   ifs.open("hole");
   ifs >> p2;
   ifs.clear();
   ifs.close();

   // check orientation
   if (p1.outer_boundary().area() < 0)
          p1.outer_boundary().reverse_orientation();
   if (p2.area() < 0)
          p2.reverse_orientation();

   // difference
   Pwh_list_2 results;
   CGAL::difference(p1, p2, back_inserter(results));

Failure case two polygons:

file "domain":
454 391.004 -217.982 390.041 -218.994 390.053 -219.916 390.057 -220.906 390.062 -221.94 389.031 -222.981 389.015 -223.932 389.069 -224.97 389.031 -225.913 389.053 -226.939 388.048 -227.94 388.047 -228.965 388.072 -229.948 388.044 -230.914 387.077 -231.947 387.087 -232.978 387.094 -233.918 386.021 -234.989 385.091 -234.995 384.085 -234.978 383.064 -234.998 382.028 -234.906 381.057 -234.996 380.042 -234.945 379.022 -234.963 378.098 -234.912 377.038 -234.907 376.082 -234.948 375.009 -234.937 374.018 -234.953 373.036 -234.946 372.072 -234.949 371.016 -234.972 370.017 -234.9 369.036 -234.933 368.068 -234.952 367.032 -234.966 366.059 -234.918 365.069 -234.989 364.064 -234.985 363.017 -234.918 362.05 -234.961 361.086 -234.947 360.054 -234.924 359.079 -234.923 358.064 -234.92 357.043 -234.928 356.016 -234.951 355.067 -234.904 354.071 -234.999 353.003 -234.928 352.092 -234.949 351.076 -234.975 350.083 -234.927 349.044 -234.966 348 -234.937 347.068 -234.954 346.016 -234.911 345.083 -234.949 344.039 -234.943 343.095 -234.902 342.058 -234.932 341.015 -234.991 340.024 -234.911 339.05 -234.904 338.051 -234.967 337.06 -234.96 336.02 -234.948 335.013 -234.988 334.09 -234.954 333.024 -234.967 332.096 -234.907 331.028 -234.982 330.028 -235 329.073 -234.984 328.089 -234.913 327.076 -234.905 326 -234.915 325.022 -234.917 324.082 -234.915 323.07 -234.9 322.054 -234.994 321.028 -234.995 321.092 -235.987 321.06 -236.903 321.094 -237.931 321.007 -238.916 322.074 -239.962 323.054 -239.943 324.047 -239.971 325.056 -240.912 324.032 -241.902 323.039 -242.996 323.022 -243.902 323.087 -244.972 323.05 -245.908 323.035 -246.953 323.004 -247.98 322.081 -248.983 321.027 -248.965 320.04 -247.951 319.042 -247.997 318.042 -247.921 317.035 -247.927 316.005 -247.918 315.061 -247.981 314.08 -247.974 313.078 -248.939 313.01 -249.975 312.083 -250.94 312.088 -251.907 311.068 -252.996 311.057 -253.959 310.056 -254.935 309.046 -255.957 309.023 -256.938 309.077 -258 309.005 -258.901 309.034 -259.975 309.06 -260.986 309.045 -261.919 309.089 -262.992 310.051 -263.997 310.012 -264.91 310.013 -265.975 309.067 -266.981 309.053 -267.957 309.057 -268.943 309.05 -269.947 309.089 -270.978 309.005 -271.937 310.055 -272.925 310.098 -273.95 310.084 -274.901 310.038 -275.956 309.004 -276.983 309.04 -277.992 309.074 -278.979 309.025 -279.99 309.099 -280.962 309.08 -281.965 310.092 -282.989 310.067 -283.94 311.01 -284.974 311.033 -285.982 312.014 -286.936 313.092 -287.925 313.077 -289 314.036 -289.937 314.008 -290.966 315.064 -291.924 315.004 -292.923 316.06 -293.919 316.091 -294.924 316.014 -295.95 317.081 -296.901 318.041 -297.948 318.099 -298.937 319.065 -299.961 319.004 -300.97 320.026 -301.961 321.068 -302.947 322.092 -303.908 322.019 -305 323.024 -305.931 323.034 -306.974 324.075 -307.926 324.074 -308.968 325.075 -309.916 325.042 -310.919 326.079 -311.956 327.079 -312.991 328.033 -312.959 329.059 -312.906 330.036 -312.908 331.09 -312.976 332.052 -312.919 333.015 -312.958 334.046 -312.958 335.092 -312.918 336.098 -312.935 337.047 -312.91 338.086 -312.992 339.004 -312.941 340.063 -313.932 339.054 -314.966 338.039 -315.971 337.093 -316.958 336.094 -317.972 335.071 -318.989 334.023 -319.952 334.001 -320.991 334.039 -321.923 334.051 -322.925 334.047 -323.932 334.084 -324.911 334.001 -325.988 335.06 -326.97 336.066 -327.936 337.065 -328.922 337.001 -329.954 337.088 -330.976 338.061 -331.945 339.098 -332.986 339.067 -333.99 340.064 -334.985 340.021 -335.952 341.043 -336.979 341.018 -337.973 342.097 -338.913 343.041 -339.969 343.06 -340.99 344.074 -340.962 345.015 -340.961 346.038 -340.958 347.005 -340.953 348.072 -340.999 349.027 -340.968 350.07 -340.908 351.049 -340.917 352.096 -340.954 353.092 -340.905 354.078 -340.948 355.005 -340.96 356.021 -340.907 357.002 -340.999 358.027 -340.994 359.064 -340.93 360.065 -340.966 361.081 -340.997 362.075 -340.94 363.049 -340.934 364.06 -340.921 365.087 -340.974 366.042 -340.979 367.081 -340.955 368.03 -340.939 369.038 -340.969 370.097 -340.965 371.052 -340.913 372.085 -340.995 373.046 -340.965 374.059 -340.917 375.019 -340.963 376.023 -340.94 377.055 -340.902 378.007 -340.951 379.003 -340.925 380.053 -340.907 381.009 -340.931 382.004 -340.958 383.003 -340.961 384.02 -340.953 385.015 -340.905 386.031 -340.914 387.027 -340.978 388.049 -340.942 389.033 -340.906 390.041 -340.931 391.025 -340.98 392.002 -340.961 393.063 -340.909 394.015 -340.943 395.048 -340.946 396.043 -340.98 397.063 -340.988 398.039 -340.932 399.006 -340.957 400.02 -340.94 401.062 -340.952 402.09 -340.989 403.051 -340.955 404.057 -340.986 405.098 -340.925 406.033 -340.914 407.061 -340.932 408.057 -340.939 409.06 -340.963 410.034 -340.952 411.045 -340.974 412.024 -340.996 413.049 -340.903 414.084 -340.971 415.057 -340.925 416.088 -340.976 417.048 -339.956 417.034 -338.969 418.024 -338 418.053 -336.902 419.004 -335.934 420.045 -334.928 420.082 -333.93 420.047 -332.918 420.026 -331.914 421.05 -330.999 422.032 -330.947 422.093 -329.945 422.092 -328.943 422.025 -327.928 423.002 -326.903 424.085 -325.974 425.067 -325.976 426.077 -324.916 426.023 -323.932 427.088 -322.998 427.041 -321.956 428.044 -320.92 429.024 -319.945 429.035 -318.978 430.073 -317.925 430.005 -316.99 431.026 -315.963 431.05 -314.954 432.047 -313.985 433.004 -312.944 433.063 -311.992 434.074 -310.98 434.044 -309.978 435.087 -308.978 435.005 -307.927 436.013 -306.915 437.028 -305.92 437.047 -304.921 438.1 -303.904 439.086 -302.932 439.038 -301.967 440.093 -300.913 440.023 -299.978 440.099 -298.98 441.096 -297.914 442.017 -296.94 442.044 -295.95 443.023 -294.975 444.032 -293.936 444.083 -292.988 445.004 -291.923 446.083 -290.931 446.012 -289.969 446.026 -288.946 447 -287.998 448.068 -286.928 448.088 -285.921 449.061 -284.944 449.095 -283.909 450.048 -282.92 451.052 -281.926 451.011 -280.925 451.025 -279.997 451 -278.974 451.011 -277.938 451.04 -276.96 450.03 -275.914 450.056 -274.957 450.068 -273.952 450.004 -272.995 450.094 -271.973 450.053 -270.948 450.017 -269.975 450.008 -268.939 450.092 -267.931 450.005 -267 450.052 -265.926 449.087 -264.99 449.062 -263.909 450.081 -262.926 450.089 -261.976 450.085 -260.996 450.075 -259.956 450.095 -258.938 450.098 -257.928 450.059 -256.952 450.028 -255.937 449.016 -254.909 449.047 -253.929 448.089 -252.943 448.045 -251.977 447.085 -250.983 447.064 -249.927 446.098 -248.913 446.093 -247.924 445.04 -246.915 444.004 -245.955 443.096 -244.98 443.007 -243.962 443.063 -242.954 442.034 -241.966 441.022 -240.986 441.028 -239.958 440.035 -238.961 440.03 -237.993 439.008 -236.982 438.061 -235.944 438.002 -234.966 437.083 -234.953 436.053 -234.953 435.033 -234.938 434.057 -234.958 433.019 -234.988 432.008 -234.983 431.072 -234.908 430.028 -234.919 429.035 -234.944 428.077 -234.95 427.098 -234.961 426.09 -233.991 426.044 -232.983 426.027 -231.968 426.025 -230.983 426.077 -229.982 426.032 -228.936 426.011 -227.956 426.072 -226.908 426.015 -225.91 426.027 -224.998 426.006 -223.957 426.094 -222.925 426.062 -221.982 426.089 -220.95 426.06 -219.981 426.019 -218.932 425.066 -217.917 424.097 -217.927 423.057 -217.996 422.001 -217.908 421.032 -217.995 420.063 -217.92 419.085 -217.951 418.083 -217.947 417.099 -217.955 416.051 -217.917 415.028 -217.941 414.077 -217.908 413.037 -217.926 412.011 -217.981 411.062 -217.9 410.051 -217.915 409.05 -217.994 408.022 -217.962 407.064 -217.947 406.03 -217.992 405.091 -217.905 404.055 -217.955 403.043 -217.953 402.014 -217.931 401.099 -217.917 400.038 -217.986 399.069 -217.956 398.001 -217.906 397.032 -217.969 396.045 -217.942 395.025 -217.914 394.031 -217.915 393.032 -217.91 392.085 -217.934 0

file "hole":
120 315.932 -291.015 315.967 -292.035 315.915 -293.051 315.983 -294.098 315.996 -295.042 315.909 -296.006 315.995 -297.051 316.933 -298.044 317.928 -299.089 317.974 -300.067 318.974 -301.039 318.938 -302.051 319.955 -303.087 320.924 -304.004 321.994 -305.012 321.925 -306.002 322.961 -307.04 322.994 -308.081 323.956 -309.007 323.916 -310.068 324.96 -311.05 324.979 -312.07 325.986 -313.057 326.958 -314.013 327.963 -314.004 328.913 -314.042 329.997 -314.011 330.937 -314.072 331.927 -314.028 332.921 -314.02 333.932 -314.015 334.988 -314.081 335.996 -314.095 336.972 -314.097 337.996 -314.058 338.981 -314.076 339.922 -314.003 340.915 -314.01 341.977 -314.077 342.903 -314.052 343.985 -314.014 345 -314.089 345.951 -314.026 346.925 -314.088 347.99 -314.05 348.987 -314.05 349.982 -314.007 350.956 -314.029 351.959 -314.063 352.949 -314.071 352.998 -313.067 352.984 -312.032 352.903 -311.052 353.955 -310.013 354.966 -310.053 355.906 -310.081 356.989 -310.058 357.941 -310.017 358.947 -310.029 359.944 -310.055 360.988 -310.01 360.972 -309.052 360.941 -308.062 360.953 -307.061 360.92 -306.041 360.993 -305.035 360.92 -304.062 360.905 -303.039 361.972 -302.06 361.959 -301.008 361.949 -300.091 361.977 -299.013 361.916 -298.092 361.965 -297.079 360.991 -297.032 359.912 -296.019 358.913 -296.079 357.947 -296.025 356.902 -296.02 355.975 -296.086 354.994 -296.043 353.991 -295.061 353.918 -294.036 352.997 -293.088 351.942 -292.006 350.911 -292.063 349.918 -292.064 348.999 -292.049 347.957 -292.087 346.922 -292.065 345.987 -292.011 344.915 -292.018 343.901 -292.046 342.907 -292.009 341.958 -292.086 340.992 -292.001 339.942 -292.097 338.957 -292.06 337.945 -292.049 336.983 -292.063 335.977 -292.087 334.913 -292.089 333.964 -292.01 332.926 -292.083 331.947 -292.031 330.985 -292.01 329.938 -292.007 328.913 -292.08 327.939 -292.013 326.965 -292.083 325.995 -292.032 324.942 -292.094 323.975 -291.05 322.923 -291.086 321.95 -291.024 320.957 -291.036 319.983 -291.014 318.993 -291.036 317.971 -291.033 316.983 -291.099

Environment

  • Operating system (Windows/Mac/Linux, 32/64 bits): windows 64
  • Compiler: vs 2013
  • Release or debug mode: release
  • CGAL version: 4.9.1
  • Boost version: 1.6.1


Reply | Threaded
Open this post in threaded view
|

Re: CGAL precondition error

Siyan Dong
CGAL::Exact_predicates_inexact_constructions_kernel

2018-07-22 16:57 GMT+08:00 Efi Fogel <[hidden email]>:
What kernel are you using? 

On Sun, Jul 22, 2018, 10:29 Siyan Dong <[hidden email]> wrote:

Issue Details

Hi, I opened an issue on github get no reply. The issue is: 

I use CGAL to compute difference between two polygons. Sometimes it works well, but sometime it get runtime error:

CGAL error: precondition violation!
Expression : (m_traits.compare_y_at_x_2_object()(p, cv1) == EQUAL) && (m_traits.compare_y_at_x_2_object()(p, cv2) == EQUAL)
File : D:\cgal\include\CGAL/Arr_segment_traits_2.h
Line : 580
Explanation:
Refer to the bug-reporting instructions at http://www.cgal.org/bug_report.html

Whats meaning of this precondition? Does it mean input polygons are not in correct format? I wonder what cause this problem and how to solve it. Thanks in advance!

Source Code

   // polygon 1
   Polygon_with_holes_2 p1;
   ifstream ifs("domain");
   ifs >> p1;
   ifs.clear();
   ifs.close();
   
   // polygon 2
   Polygon_2 p2;
   ifs.open("hole");
   ifs >> p2;
   ifs.clear();
   ifs.close();

   // check orientation
   if (p1.outer_boundary().area() < 0)
          p1.outer_boundary().reverse_orientation();
   if (p2.area() < 0)
          p2.reverse_orientation();

   // difference
   Pwh_list_2 results;
   CGAL::difference(p1, p2, back_inserter(results));

Failure case two polygons:

file "domain":
454 391.004 -217.982 390.041 -218.994 390.053 -219.916 390.057 -220.906 390.062 -221.94 389.031 -222.981 389.015 -223.932 389.069 -224.97 389.031 -225.913 389.053 -226.939 388.048 -227.94 388.047 -228.965 388.072 -229.948 388.044 -230.914 387.077 -231.947 387.087 -232.978 387.094 -233.918 386.021 -234.989 385.091 -234.995 384.085 -234.978 383.064 -234.998 382.028 -234.906 381.057 -234.996 380.042 -234.945 379.022 -234.963 378.098 -234.912 377.038 -234.907 376.082 -234.948 375.009 -234.937 374.018 -234.953 373.036 -234.946 372.072 -234.949 371.016 -234.972 370.017 -234.9 369.036 -234.933 368.068 -234.952 367.032 -234.966 366.059 -234.918 365.069 -234.989 364.064 -234.985 363.017 -234.918 362.05 -234.961 361.086 -234.947 360.054 -234.924 359.079 -234.923 358.064 -234.92 357.043 -234.928 356.016 -234.951 355.067 -234.904 354.071 -234.999 353.003 -234.928 352.092 -234.949 351.076 -234.975 350.083 -234.927 349.044 -234.966 348 -234.937 347.068 -234.954 346.016 -234.911 345.083 -234.949 344.039 -234.943 343.095 -234.902 342.058 -234.932 341.015 -234.991 340.024 -234.911 339.05 -234.904 338.051 -234.967 337.06 -234.96 336.02 -234.948 335.013 -234.988 334.09 -234.954 333.024 -234.967 332.096 -234.907 331.028 -234.982 330.028 -235 329.073 -234.984 328.089 -234.913 327.076 -234.905 326 -234.915 325.022 -234.917 324.082 -234.915 323.07 -234.9 322.054 -234.994 321.028 -234.995 321.092 -235.987 321.06 -236.903 321.094 -237.931 321.007 -238.916 322.074 -239.962 323.054 -239.943 324.047 -239.971 325.056 -240.912 324.032 -241.902 323.039 -242.996 323.022 -243.902 323.087 -244.972 323.05 -245.908 323.035 -246.953 323.004 -247.98 322.081 -248.983 321.027 -248.965 320.04 -247.951 319.042 -247.997 318.042 -247.921 317.035 -247.927 316.005 -247.918 315.061 -247.981 314.08 -247.974 313.078 -248.939 313.01 -249.975 312.083 -250.94 312.088 -251.907 311.068 -252.996 311.057 -253.959 310.056 -254.935 309.046 -255.957 309.023 -256.938 309.077 -258 309.005 -258.901 309.034 -259.975 309.06 -260.986 309.045 -261.919 309.089 -262.992 310.051 -263.997 310.012 -264.91 310.013 -265.975 309.067 -266.981 309.053 -267.957 309.057 -268.943 309.05 -269.947 309.089 -270.978 309.005 -271.937 310.055 -272.925 310.098 -273.95 310.084 -274.901 310.038 -275.956 309.004 -276.983 309.04 -277.992 309.074 -278.979 309.025 -279.99 309.099 -280.962 309.08 -281.965 310.092 -282.989 310.067 -283.94 311.01 -284.974 311.033 -285.982 312.014 -286.936 313.092 -287.925 313.077 -289 314.036 -289.937 314.008 -290.966 315.064 -291.924 315.004 -292.923 316.06 -293.919 316.091 -294.924 316.014 -295.95 317.081 -296.901 318.041 -297.948 318.099 -298.937 319.065 -299.961 319.004 -300.97 320.026 -301.961 321.068 -302.947 322.092 -303.908 322.019 -305 323.024 -305.931 323.034 -306.974 324.075 -307.926 324.074 -308.968 325.075 -309.916 325.042 -310.919 326.079 -311.956 327.079 -312.991 328.033 -312.959 329.059 -312.906 330.036 -312.908 331.09 -312.976 332.052 -312.919 333.015 -312.958 334.046 -312.958 335.092 -312.918 336.098 -312.935 337.047 -312.91 338.086 -312.992 339.004 -312.941 340.063 -313.932 339.054 -314.966 338.039 -315.971 337.093 -316.958 336.094 -317.972 335.071 -318.989 334.023 -319.952 334.001 -320.991 334.039 -321.923 334.051 -322.925 334.047 -323.932 334.084 -324.911 334.001 -325.988 335.06 -326.97 336.066 -327.936 337.065 -328.922 337.001 -329.954 337.088 -330.976 338.061 -331.945 339.098 -332.986 339.067 -333.99 340.064 -334.985 340.021 -335.952 341.043 -336.979 341.018 -337.973 342.097 -338.913 343.041 -339.969 343.06 -340.99 344.074 -340.962 345.015 -340.961 346.038 -340.958 347.005 -340.953 348.072 -340.999 349.027 -340.968 350.07 -340.908 351.049 -340.917 352.096 -340.954 353.092 -340.905 354.078 -340.948 355.005 -340.96 356.021 -340.907 357.002 -340.999 358.027 -340.994 359.064 -340.93 360.065 -340.966 361.081 -340.997 362.075 -340.94 363.049 -340.934 364.06 -340.921 365.087 -340.974 366.042 -340.979 367.081 -340.955 368.03 -340.939 369.038 -340.969 370.097 -340.965 371.052 -340.913 372.085 -340.995 373.046 -340.965 374.059 -340.917 375.019 -340.963 376.023 -340.94 377.055 -340.902 378.007 -340.951 379.003 -340.925 380.053 -340.907 381.009 -340.931 382.004 -340.958 383.003 -340.961 384.02 -340.953 385.015 -340.905 386.031 -340.914 387.027 -340.978 388.049 -340.942 389.033 -340.906 390.041 -340.931 391.025 -340.98 392.002 -340.961 393.063 -340.909 394.015 -340.943 395.048 -340.946 396.043 -340.98 397.063 -340.988 398.039 -340.932 399.006 -340.957 400.02 -340.94 401.062 -340.952 402.09 -340.989 403.051 -340.955 404.057 -340.986 405.098 -340.925 406.033 -340.914 407.061 -340.932 408.057 -340.939 409.06 -340.963 410.034 -340.952 411.045 -340.974 412.024 -340.996 413.049 -340.903 414.084 -340.971 415.057 -340.925 416.088 -340.976 417.048 -339.956 417.034 -338.969 418.024 -338 418.053 -336.902 419.004 -335.934 420.045 -334.928 420.082 -333.93 420.047 -332.918 420.026 -331.914 421.05 -330.999 422.032 -330.947 422.093 -329.945 422.092 -328.943 422.025 -327.928 423.002 -326.903 424.085 -325.974 425.067 -325.976 426.077 -324.916 426.023 -323.932 427.088 -322.998 427.041 -321.956 428.044 -320.92 429.024 -319.945 429.035 -318.978 430.073 -317.925 430.005 -316.99 431.026 -315.963 431.05 -314.954 432.047 -313.985 433.004 -312.944 433.063 -311.992 434.074 -310.98 434.044 -309.978 435.087 -308.978 435.005 -307.927 436.013 -306.915 437.028 -305.92 437.047 -304.921 438.1 -303.904 439.086 -302.932 439.038 -301.967 440.093 -300.913 440.023 -299.978 440.099 -298.98 441.096 -297.914 442.017 -296.94 442.044 -295.95 443.023 -294.975 444.032 -293.936 444.083 -292.988 445.004 -291.923 446.083 -290.931 446.012 -289.969 446.026 -288.946 447 -287.998 448.068 -286.928 448.088 -285.921 449.061 -284.944 449.095 -283.909 450.048 -282.92 451.052 -281.926 451.011 -280.925 451.025 -279.997 451 -278.974 451.011 -277.938 451.04 -276.96 450.03 -275.914 450.056 -274.957 450.068 -273.952 450.004 -272.995 450.094 -271.973 450.053 -270.948 450.017 -269.975 450.008 -268.939 450.092 -267.931 450.005 -267 450.052 -265.926 449.087 -264.99 449.062 -263.909 450.081 -262.926 450.089 -261.976 450.085 -260.996 450.075 -259.956 450.095 -258.938 450.098 -257.928 450.059 -256.952 450.028 -255.937 449.016 -254.909 449.047 -253.929 448.089 -252.943 448.045 -251.977 447.085 -250.983 447.064 -249.927 446.098 -248.913 446.093 -247.924 445.04 -246.915 444.004 -245.955 443.096 -244.98 443.007 -243.962 443.063 -242.954 442.034 -241.966 441.022 -240.986 441.028 -239.958 440.035 -238.961 440.03 -237.993 439.008 -236.982 438.061 -235.944 438.002 -234.966 437.083 -234.953 436.053 -234.953 435.033 -234.938 434.057 -234.958 433.019 -234.988 432.008 -234.983 431.072 -234.908 430.028 -234.919 429.035 -234.944 428.077 -234.95 427.098 -234.961 426.09 -233.991 426.044 -232.983 426.027 -231.968 426.025 -230.983 426.077 -229.982 426.032 -228.936 426.011 -227.956 426.072 -226.908 426.015 -225.91 426.027 -224.998 426.006 -223.957 426.094 -222.925 426.062 -221.982 426.089 -220.95 426.06 -219.981 426.019 -218.932 425.066 -217.917 424.097 -217.927 423.057 -217.996 422.001 -217.908 421.032 -217.995 420.063 -217.92 419.085 -217.951 418.083 -217.947 417.099 -217.955 416.051 -217.917 415.028 -217.941 414.077 -217.908 413.037 -217.926 412.011 -217.981 411.062 -217.9 410.051 -217.915 409.05 -217.994 408.022 -217.962 407.064 -217.947 406.03 -217.992 405.091 -217.905 404.055 -217.955 403.043 -217.953 402.014 -217.931 401.099 -217.917 400.038 -217.986 399.069 -217.956 398.001 -217.906 397.032 -217.969 396.045 -217.942 395.025 -217.914 394.031 -217.915 393.032 -217.91 392.085 -217.934 0

file "hole":
120 315.932 -291.015 315.967 -292.035 315.915 -293.051 315.983 -294.098 315.996 -295.042 315.909 -296.006 315.995 -297.051 316.933 -298.044 317.928 -299.089 317.974 -300.067 318.974 -301.039 318.938 -302.051 319.955 -303.087 320.924 -304.004 321.994 -305.012 321.925 -306.002 322.961 -307.04 322.994 -308.081 323.956 -309.007 323.916 -310.068 324.96 -311.05 324.979 -312.07 325.986 -313.057 326.958 -314.013 327.963 -314.004 328.913 -314.042 329.997 -314.011 330.937 -314.072 331.927 -314.028 332.921 -314.02 333.932 -314.015 334.988 -314.081 335.996 -314.095 336.972 -314.097 337.996 -314.058 338.981 -314.076 339.922 -314.003 340.915 -314.01 341.977 -314.077 342.903 -314.052 343.985 -314.014 345 -314.089 345.951 -314.026 346.925 -314.088 347.99 -314.05 348.987 -314.05 349.982 -314.007 350.956 -314.029 351.959 -314.063 352.949 -314.071 352.998 -313.067 352.984 -312.032 352.903 -311.052 353.955 -310.013 354.966 -310.053 355.906 -310.081 356.989 -310.058 357.941 -310.017 358.947 -310.029 359.944 -310.055 360.988 -310.01 360.972 -309.052 360.941 -308.062 360.953 -307.061 360.92 -306.041 360.993 -305.035 360.92 -304.062 360.905 -303.039 361.972 -302.06 361.959 -301.008 361.949 -300.091 361.977 -299.013 361.916 -298.092 361.965 -297.079 360.991 -297.032 359.912 -296.019 358.913 -296.079 357.947 -296.025 356.902 -296.02 355.975 -296.086 354.994 -296.043 353.991 -295.061 353.918 -294.036 352.997 -293.088 351.942 -292.006 350.911 -292.063 349.918 -292.064 348.999 -292.049 347.957 -292.087 346.922 -292.065 345.987 -292.011 344.915 -292.018 343.901 -292.046 342.907 -292.009 341.958 -292.086 340.992 -292.001 339.942 -292.097 338.957 -292.06 337.945 -292.049 336.983 -292.063 335.977 -292.087 334.913 -292.089 333.964 -292.01 332.926 -292.083 331.947 -292.031 330.985 -292.01 329.938 -292.007 328.913 -292.08 327.939 -292.013 326.965 -292.083 325.995 -292.032 324.942 -292.094 323.975 -291.05 322.923 -291.086 321.95 -291.024 320.957 -291.036 319.983 -291.014 318.993 -291.036 317.971 -291.033 316.983 -291.099

Environment

  • Operating system (Windows/Mac/Linux, 32/64 bits): windows 64
  • Compiler: vs 2013
  • Release or debug mode: release
  • CGAL version: 4.9.1
  • Boost version: 1.6.1



Reply | Threaded
Open this post in threaded view
|

Re: CGAL precondition error

Efi Fogel
  Try with exact construction. 

On Sun, Jul 22, 2018, 12:00 Siyan Dong <[hidden email]> wrote:
CGAL::Exact_predicates_inexact_constructions_kernel

2018-07-22 16:57 GMT+08:00 Efi Fogel <[hidden email]>:
What kernel are you using? 

On Sun, Jul 22, 2018, 10:29 Siyan Dong <[hidden email]> wrote:

Issue Details

Hi, I opened an issue on github get no reply. The issue is: 

I use CGAL to compute difference between two polygons. Sometimes it works well, but sometime it get runtime error:

CGAL error: precondition violation!
Expression : (m_traits.compare_y_at_x_2_object()(p, cv1) == EQUAL) && (m_traits.compare_y_at_x_2_object()(p, cv2) == EQUAL)
File : D:\cgal\include\CGAL/Arr_segment_traits_2.h
Line : 580
Explanation:
Refer to the bug-reporting instructions at http://www.cgal.org/bug_report.html

Whats meaning of this precondition? Does it mean input polygons are not in correct format? I wonder what cause this problem and how to solve it. Thanks in advance!

Source Code

   // polygon 1
   Polygon_with_holes_2 p1;
   ifstream ifs("domain");
   ifs >> p1;
   ifs.clear();
   ifs.close();
   
   // polygon 2
   Polygon_2 p2;
   ifs.open("hole");
   ifs >> p2;
   ifs.clear();
   ifs.close();

   // check orientation
   if (p1.outer_boundary().area() < 0)
          p1.outer_boundary().reverse_orientation();
   if (p2.area() < 0)
          p2.reverse_orientation();

   // difference
   Pwh_list_2 results;
   CGAL::difference(p1, p2, back_inserter(results));

Failure case two polygons:

file "domain":
454 391.004 -217.982 390.041 -218.994 390.053 -219.916 390.057 -220.906 390.062 -221.94 389.031 -222.981 389.015 -223.932 389.069 -224.97 389.031 -225.913 389.053 -226.939 388.048 -227.94 388.047 -228.965 388.072 -229.948 388.044 -230.914 387.077 -231.947 387.087 -232.978 387.094 -233.918 386.021 -234.989 385.091 -234.995 384.085 -234.978 383.064 -234.998 382.028 -234.906 381.057 -234.996 380.042 -234.945 379.022 -234.963 378.098 -234.912 377.038 -234.907 376.082 -234.948 375.009 -234.937 374.018 -234.953 373.036 -234.946 372.072 -234.949 371.016 -234.972 370.017 -234.9 369.036 -234.933 368.068 -234.952 367.032 -234.966 366.059 -234.918 365.069 -234.989 364.064 -234.985 363.017 -234.918 362.05 -234.961 361.086 -234.947 360.054 -234.924 359.079 -234.923 358.064 -234.92 357.043 -234.928 356.016 -234.951 355.067 -234.904 354.071 -234.999 353.003 -234.928 352.092 -234.949 351.076 -234.975 350.083 -234.927 349.044 -234.966 348 -234.937 347.068 -234.954 346.016 -234.911 345.083 -234.949 344.039 -234.943 343.095 -234.902 342.058 -234.932 341.015 -234.991 340.024 -234.911 339.05 -234.904 338.051 -234.967 337.06 -234.96 336.02 -234.948 335.013 -234.988 334.09 -234.954 333.024 -234.967 332.096 -234.907 331.028 -234.982 330.028 -235 329.073 -234.984 328.089 -234.913 327.076 -234.905 326 -234.915 325.022 -234.917 324.082 -234.915 323.07 -234.9 322.054 -234.994 321.028 -234.995 321.092 -235.987 321.06 -236.903 321.094 -237.931 321.007 -238.916 322.074 -239.962 323.054 -239.943 324.047 -239.971 325.056 -240.912 324.032 -241.902 323.039 -242.996 323.022 -243.902 323.087 -244.972 323.05 -245.908 323.035 -246.953 323.004 -247.98 322.081 -248.983 321.027 -248.965 320.04 -247.951 319.042 -247.997 318.042 -247.921 317.035 -247.927 316.005 -247.918 315.061 -247.981 314.08 -247.974 313.078 -248.939 313.01 -249.975 312.083 -250.94 312.088 -251.907 311.068 -252.996 311.057 -253.959 310.056 -254.935 309.046 -255.957 309.023 -256.938 309.077 -258 309.005 -258.901 309.034 -259.975 309.06 -260.986 309.045 -261.919 309.089 -262.992 310.051 -263.997 310.012 -264.91 310.013 -265.975 309.067 -266.981 309.053 -267.957 309.057 -268.943 309.05 -269.947 309.089 -270.978 309.005 -271.937 310.055 -272.925 310.098 -273.95 310.084 -274.901 310.038 -275.956 309.004 -276.983 309.04 -277.992 309.074 -278.979 309.025 -279.99 309.099 -280.962 309.08 -281.965 310.092 -282.989 310.067 -283.94 311.01 -284.974 311.033 -285.982 312.014 -286.936 313.092 -287.925 313.077 -289 314.036 -289.937 314.008 -290.966 315.064 -291.924 315.004 -292.923 316.06 -293.919 316.091 -294.924 316.014 -295.95 317.081 -296.901 318.041 -297.948 318.099 -298.937 319.065 -299.961 319.004 -300.97 320.026 -301.961 321.068 -302.947 322.092 -303.908 322.019 -305 323.024 -305.931 323.034 -306.974 324.075 -307.926 324.074 -308.968 325.075 -309.916 325.042 -310.919 326.079 -311.956 327.079 -312.991 328.033 -312.959 329.059 -312.906 330.036 -312.908 331.09 -312.976 332.052 -312.919 333.015 -312.958 334.046 -312.958 335.092 -312.918 336.098 -312.935 337.047 -312.91 338.086 -312.992 339.004 -312.941 340.063 -313.932 339.054 -314.966 338.039 -315.971 337.093 -316.958 336.094 -317.972 335.071 -318.989 334.023 -319.952 334.001 -320.991 334.039 -321.923 334.051 -322.925 334.047 -323.932 334.084 -324.911 334.001 -325.988 335.06 -326.97 336.066 -327.936 337.065 -328.922 337.001 -329.954 337.088 -330.976 338.061 -331.945 339.098 -332.986 339.067 -333.99 340.064 -334.985 340.021 -335.952 341.043 -336.979 341.018 -337.973 342.097 -338.913 343.041 -339.969 343.06 -340.99 344.074 -340.962 345.015 -340.961 346.038 -340.958 347.005 -340.953 348.072 -340.999 349.027 -340.968 350.07 -340.908 351.049 -340.917 352.096 -340.954 353.092 -340.905 354.078 -340.948 355.005 -340.96 356.021 -340.907 357.002 -340.999 358.027 -340.994 359.064 -340.93 360.065 -340.966 361.081 -340.997 362.075 -340.94 363.049 -340.934 364.06 -340.921 365.087 -340.974 366.042 -340.979 367.081 -340.955 368.03 -340.939 369.038 -340.969 370.097 -340.965 371.052 -340.913 372.085 -340.995 373.046 -340.965 374.059 -340.917 375.019 -340.963 376.023 -340.94 377.055 -340.902 378.007 -340.951 379.003 -340.925 380.053 -340.907 381.009 -340.931 382.004 -340.958 383.003 -340.961 384.02 -340.953 385.015 -340.905 386.031 -340.914 387.027 -340.978 388.049 -340.942 389.033 -340.906 390.041 -340.931 391.025 -340.98 392.002 -340.961 393.063 -340.909 394.015 -340.943 395.048 -340.946 396.043 -340.98 397.063 -340.988 398.039 -340.932 399.006 -340.957 400.02 -340.94 401.062 -340.952 402.09 -340.989 403.051 -340.955 404.057 -340.986 405.098 -340.925 406.033 -340.914 407.061 -340.932 408.057 -340.939 409.06 -340.963 410.034 -340.952 411.045 -340.974 412.024 -340.996 413.049 -340.903 414.084 -340.971 415.057 -340.925 416.088 -340.976 417.048 -339.956 417.034 -338.969 418.024 -338 418.053 -336.902 419.004 -335.934 420.045 -334.928 420.082 -333.93 420.047 -332.918 420.026 -331.914 421.05 -330.999 422.032 -330.947 422.093 -329.945 422.092 -328.943 422.025 -327.928 423.002 -326.903 424.085 -325.974 425.067 -325.976 426.077 -324.916 426.023 -323.932 427.088 -322.998 427.041 -321.956 428.044 -320.92 429.024 -319.945 429.035 -318.978 430.073 -317.925 430.005 -316.99 431.026 -315.963 431.05 -314.954 432.047 -313.985 433.004 -312.944 433.063 -311.992 434.074 -310.98 434.044 -309.978 435.087 -308.978 435.005 -307.927 436.013 -306.915 437.028 -305.92 437.047 -304.921 438.1 -303.904 439.086 -302.932 439.038 -301.967 440.093 -300.913 440.023 -299.978 440.099 -298.98 441.096 -297.914 442.017 -296.94 442.044 -295.95 443.023 -294.975 444.032 -293.936 444.083 -292.988 445.004 -291.923 446.083 -290.931 446.012 -289.969 446.026 -288.946 447 -287.998 448.068 -286.928 448.088 -285.921 449.061 -284.944 449.095 -283.909 450.048 -282.92 451.052 -281.926 451.011 -280.925 451.025 -279.997 451 -278.974 451.011 -277.938 451.04 -276.96 450.03 -275.914 450.056 -274.957 450.068 -273.952 450.004 -272.995 450.094 -271.973 450.053 -270.948 450.017 -269.975 450.008 -268.939 450.092 -267.931 450.005 -267 450.052 -265.926 449.087 -264.99 449.062 -263.909 450.081 -262.926 450.089 -261.976 450.085 -260.996 450.075 -259.956 450.095 -258.938 450.098 -257.928 450.059 -256.952 450.028 -255.937 449.016 -254.909 449.047 -253.929 448.089 -252.943 448.045 -251.977 447.085 -250.983 447.064 -249.927 446.098 -248.913 446.093 -247.924 445.04 -246.915 444.004 -245.955 443.096 -244.98 443.007 -243.962 443.063 -242.954 442.034 -241.966 441.022 -240.986 441.028 -239.958 440.035 -238.961 440.03 -237.993 439.008 -236.982 438.061 -235.944 438.002 -234.966 437.083 -234.953 436.053 -234.953 435.033 -234.938 434.057 -234.958 433.019 -234.988 432.008 -234.983 431.072 -234.908 430.028 -234.919 429.035 -234.944 428.077 -234.95 427.098 -234.961 426.09 -233.991 426.044 -232.983 426.027 -231.968 426.025 -230.983 426.077 -229.982 426.032 -228.936 426.011 -227.956 426.072 -226.908 426.015 -225.91 426.027 -224.998 426.006 -223.957 426.094 -222.925 426.062 -221.982 426.089 -220.95 426.06 -219.981 426.019 -218.932 425.066 -217.917 424.097 -217.927 423.057 -217.996 422.001 -217.908 421.032 -217.995 420.063 -217.92 419.085 -217.951 418.083 -217.947 417.099 -217.955 416.051 -217.917 415.028 -217.941 414.077 -217.908 413.037 -217.926 412.011 -217.981 411.062 -217.9 410.051 -217.915 409.05 -217.994 408.022 -217.962 407.064 -217.947 406.03 -217.992 405.091 -217.905 404.055 -217.955 403.043 -217.953 402.014 -217.931 401.099 -217.917 400.038 -217.986 399.069 -217.956 398.001 -217.906 397.032 -217.969 396.045 -217.942 395.025 -217.914 394.031 -217.915 393.032 -217.91 392.085 -217.934 0

file "hole":
120 315.932 -291.015 315.967 -292.035 315.915 -293.051 315.983 -294.098 315.996 -295.042 315.909 -296.006 315.995 -297.051 316.933 -298.044 317.928 -299.089 317.974 -300.067 318.974 -301.039 318.938 -302.051 319.955 -303.087 320.924 -304.004 321.994 -305.012 321.925 -306.002 322.961 -307.04 322.994 -308.081 323.956 -309.007 323.916 -310.068 324.96 -311.05 324.979 -312.07 325.986 -313.057 326.958 -314.013 327.963 -314.004 328.913 -314.042 329.997 -314.011 330.937 -314.072 331.927 -314.028 332.921 -314.02 333.932 -314.015 334.988 -314.081 335.996 -314.095 336.972 -314.097 337.996 -314.058 338.981 -314.076 339.922 -314.003 340.915 -314.01 341.977 -314.077 342.903 -314.052 343.985 -314.014 345 -314.089 345.951 -314.026 346.925 -314.088 347.99 -314.05 348.987 -314.05 349.982 -314.007 350.956 -314.029 351.959 -314.063 352.949 -314.071 352.998 -313.067 352.984 -312.032 352.903 -311.052 353.955 -310.013 354.966 -310.053 355.906 -310.081 356.989 -310.058 357.941 -310.017 358.947 -310.029 359.944 -310.055 360.988 -310.01 360.972 -309.052 360.941 -308.062 360.953 -307.061 360.92 -306.041 360.993 -305.035 360.92 -304.062 360.905 -303.039 361.972 -302.06 361.959 -301.008 361.949 -300.091 361.977 -299.013 361.916 -298.092 361.965 -297.079 360.991 -297.032 359.912 -296.019 358.913 -296.079 357.947 -296.025 356.902 -296.02 355.975 -296.086 354.994 -296.043 353.991 -295.061 353.918 -294.036 352.997 -293.088 351.942 -292.006 350.911 -292.063 349.918 -292.064 348.999 -292.049 347.957 -292.087 346.922 -292.065 345.987 -292.011 344.915 -292.018 343.901 -292.046 342.907 -292.009 341.958 -292.086 340.992 -292.001 339.942 -292.097 338.957 -292.06 337.945 -292.049 336.983 -292.063 335.977 -292.087 334.913 -292.089 333.964 -292.01 332.926 -292.083 331.947 -292.031 330.985 -292.01 329.938 -292.007 328.913 -292.08 327.939 -292.013 326.965 -292.083 325.995 -292.032 324.942 -292.094 323.975 -291.05 322.923 -291.086 321.95 -291.024 320.957 -291.036 319.983 -291.014 318.993 -291.036 317.971 -291.033 316.983 -291.099

Environment

  • Operating system (Windows/Mac/Linux, 32/64 bits): windows 64
  • Compiler: vs 2013
  • Release or debug mode: release
  • CGAL version: 4.9.1
  • Boost version: 1.6.1



Reply | Threaded
Open this post in threaded view
|

Re: CGAL precondition error

Siyan Dong
I change to exact kernel. It works. Thanks!

2018-07-22 19:21 GMT+08:00 Efi Fogel <[hidden email]>:
  Try with exact construction. 

On Sun, Jul 22, 2018, 12:00 Siyan Dong <[hidden email]> wrote:
CGAL::Exact_predicates_inexact_constructions_kernel

2018-07-22 16:57 GMT+08:00 Efi Fogel <[hidden email]>:
What kernel are you using? 

On Sun, Jul 22, 2018, 10:29 Siyan Dong <[hidden email]> wrote:

Issue Details

Hi, I opened an issue on github get no reply. The issue is: 

I use CGAL to compute difference between two polygons. Sometimes it works well, but sometime it get runtime error:

CGAL error: precondition violation!
Expression : (m_traits.compare_y_at_x_2_object()(p, cv1) == EQUAL) && (m_traits.compare_y_at_x_2_object()(p, cv2) == EQUAL)
File : D:\cgal\include\CGAL/Arr_segment_traits_2.h
Line : 580
Explanation:
Refer to the bug-reporting instructions at http://www.cgal.org/bug_report.html

Whats meaning of this precondition? Does it mean input polygons are not in correct format? I wonder what cause this problem and how to solve it. Thanks in advance!

Source Code

   // polygon 1
   Polygon_with_holes_2 p1;
   ifstream ifs("domain");
   ifs >> p1;
   ifs.clear();
   ifs.close();
   
   // polygon 2
   Polygon_2 p2;
   ifs.open("hole");
   ifs >> p2;
   ifs.clear();
   ifs.close();

   // check orientation
   if (p1.outer_boundary().area() < 0)
          p1.outer_boundary().reverse_orientation();
   if (p2.area() < 0)
          p2.reverse_orientation();

   // difference
   Pwh_list_2 results;
   CGAL::difference(p1, p2, back_inserter(results));

Failure case two polygons:

file "domain":
454 391.004 -217.982 390.041 -218.994 390.053 -219.916 390.057 -220.906 390.062 -221.94 389.031 -222.981 389.015 -223.932 389.069 -224.97 389.031 -225.913 389.053 -226.939 388.048 -227.94 388.047 -228.965 388.072 -229.948 388.044 -230.914 387.077 -231.947 387.087 -232.978 387.094 -233.918 386.021 -234.989 385.091 -234.995 384.085 -234.978 383.064 -234.998 382.028 -234.906 381.057 -234.996 380.042 -234.945 379.022 -234.963 378.098 -234.912 377.038 -234.907 376.082 -234.948 375.009 -234.937 374.018 -234.953 373.036 -234.946 372.072 -234.949 371.016 -234.972 370.017 -234.9 369.036 -234.933 368.068 -234.952 367.032 -234.966 366.059 -234.918 365.069 -234.989 364.064 -234.985 363.017 -234.918 362.05 -234.961 361.086 -234.947 360.054 -234.924 359.079 -234.923 358.064 -234.92 357.043 -234.928 356.016 -234.951 355.067 -234.904 354.071 -234.999 353.003 -234.928 352.092 -234.949 351.076 -234.975 350.083 -234.927 349.044 -234.966 348 -234.937 347.068 -234.954 346.016 -234.911 345.083 -234.949 344.039 -234.943 343.095 -234.902 342.058 -234.932 341.015 -234.991 340.024 -234.911 339.05 -234.904 338.051 -234.967 337.06 -234.96 336.02 -234.948 335.013 -234.988 334.09 -234.954 333.024 -234.967 332.096 -234.907 331.028 -234.982 330.028 -235 329.073 -234.984 328.089 -234.913 327.076 -234.905 326 -234.915 325.022 -234.917 324.082 -234.915 323.07 -234.9 322.054 -234.994 321.028 -234.995 321.092 -235.987 321.06 -236.903 321.094 -237.931 321.007 -238.916 322.074 -239.962 323.054 -239.943 324.047 -239.971 325.056 -240.912 324.032 -241.902 323.039 -242.996 323.022 -243.902 323.087 -244.972 323.05 -245.908 323.035 -246.953 323.004 -247.98 322.081 -248.983 321.027 -248.965 320.04 -247.951 319.042 -247.997 318.042 -247.921 317.035 -247.927 316.005 -247.918 315.061 -247.981 314.08 -247.974 313.078 -248.939 313.01 -249.975 312.083 -250.94 312.088 -251.907 311.068 -252.996 311.057 -253.959 310.056 -254.935 309.046 -255.957 309.023 -256.938 309.077 -258 309.005 -258.901 309.034 -259.975 309.06 -260.986 309.045 -261.919 309.089 -262.992 310.051 -263.997 310.012 -264.91 310.013 -265.975 309.067 -266.981 309.053 -267.957 309.057 -268.943 309.05 -269.947 309.089 -270.978 309.005 -271.937 310.055 -272.925 310.098 -273.95 310.084 -274.901 310.038 -275.956 309.004 -276.983 309.04 -277.992 309.074 -278.979 309.025 -279.99 309.099 -280.962 309.08 -281.965 310.092 -282.989 310.067 -283.94 311.01 -284.974 311.033 -285.982 312.014 -286.936 313.092 -287.925 313.077 -289 314.036 -289.937 314.008 -290.966 315.064 -291.924 315.004 -292.923 316.06 -293.919 316.091 -294.924 316.014 -295.95 317.081 -296.901 318.041 -297.948 318.099 -298.937 319.065 -299.961 319.004 -300.97 320.026 -301.961 321.068 -302.947 322.092 -303.908 322.019 -305 323.024 -305.931 323.034 -306.974 324.075 -307.926 324.074 -308.968 325.075 -309.916 325.042 -310.919 326.079 -311.956 327.079 -312.991 328.033 -312.959 329.059 -312.906 330.036 -312.908 331.09 -312.976 332.052 -312.919 333.015 -312.958 334.046 -312.958 335.092 -312.918 336.098 -312.935 337.047 -312.91 338.086 -312.992 339.004 -312.941 340.063 -313.932 339.054 -314.966 338.039 -315.971 337.093 -316.958 336.094 -317.972 335.071 -318.989 334.023 -319.952 334.001 -320.991 334.039 -321.923 334.051 -322.925 334.047 -323.932 334.084 -324.911 334.001 -325.988 335.06 -326.97 336.066 -327.936 337.065 -328.922 337.001 -329.954 337.088 -330.976 338.061 -331.945 339.098 -332.986 339.067 -333.99 340.064 -334.985 340.021 -335.952 341.043 -336.979 341.018 -337.973 342.097 -338.913 343.041 -339.969 343.06 -340.99 344.074 -340.962 345.015 -340.961 346.038 -340.958 347.005 -340.953 348.072 -340.999 349.027 -340.968 350.07 -340.908 351.049 -340.917 352.096 -340.954 353.092 -340.905 354.078 -340.948 355.005 -340.96 356.021 -340.907 357.002 -340.999 358.027 -340.994 359.064 -340.93 360.065 -340.966 361.081 -340.997 362.075 -340.94 363.049 -340.934 364.06 -340.921 365.087 -340.974 366.042 -340.979 367.081 -340.955 368.03 -340.939 369.038 -340.969 370.097 -340.965 371.052 -340.913 372.085 -340.995 373.046 -340.965 374.059 -340.917 375.019 -340.963 376.023 -340.94 377.055 -340.902 378.007 -340.951 379.003 -340.925 380.053 -340.907 381.009 -340.931 382.004 -340.958 383.003 -340.961 384.02 -340.953 385.015 -340.905 386.031 -340.914 387.027 -340.978 388.049 -340.942 389.033 -340.906 390.041 -340.931 391.025 -340.98 392.002 -340.961 393.063 -340.909 394.015 -340.943 395.048 -340.946 396.043 -340.98 397.063 -340.988 398.039 -340.932 399.006 -340.957 400.02 -340.94 401.062 -340.952 402.09 -340.989 403.051 -340.955 404.057 -340.986 405.098 -340.925 406.033 -340.914 407.061 -340.932 408.057 -340.939 409.06 -340.963 410.034 -340.952 411.045 -340.974 412.024 -340.996 413.049 -340.903 414.084 -340.971 415.057 -340.925 416.088 -340.976 417.048 -339.956 417.034 -338.969 418.024 -338 418.053 -336.902 419.004 -335.934 420.045 -334.928 420.082 -333.93 420.047 -332.918 420.026 -331.914 421.05 -330.999 422.032 -330.947 422.093 -329.945 422.092 -328.943 422.025 -327.928 423.002 -326.903 424.085 -325.974 425.067 -325.976 426.077 -324.916 426.023 -323.932 427.088 -322.998 427.041 -321.956 428.044 -320.92 429.024 -319.945 429.035 -318.978 430.073 -317.925 430.005 -316.99 431.026 -315.963 431.05 -314.954 432.047 -313.985 433.004 -312.944 433.063 -311.992 434.074 -310.98 434.044 -309.978 435.087 -308.978 435.005 -307.927 436.013 -306.915 437.028 -305.92 437.047 -304.921 438.1 -303.904 439.086 -302.932 439.038 -301.967 440.093 -300.913 440.023 -299.978 440.099 -298.98 441.096 -297.914 442.017 -296.94 442.044 -295.95 443.023 -294.975 444.032 -293.936 444.083 -292.988 445.004 -291.923 446.083 -290.931 446.012 -289.969 446.026 -288.946 447 -287.998 448.068 -286.928 448.088 -285.921 449.061 -284.944 449.095 -283.909 450.048 -282.92 451.052 -281.926 451.011 -280.925 451.025 -279.997 451 -278.974 451.011 -277.938 451.04 -276.96 450.03 -275.914 450.056 -274.957 450.068 -273.952 450.004 -272.995 450.094 -271.973 450.053 -270.948 450.017 -269.975 450.008 -268.939 450.092 -267.931 450.005 -267 450.052 -265.926 449.087 -264.99 449.062 -263.909 450.081 -262.926 450.089 -261.976 450.085 -260.996 450.075 -259.956 450.095 -258.938 450.098 -257.928 450.059 -256.952 450.028 -255.937 449.016 -254.909 449.047 -253.929 448.089 -252.943 448.045 -251.977 447.085 -250.983 447.064 -249.927 446.098 -248.913 446.093 -247.924 445.04 -246.915 444.004 -245.955 443.096 -244.98 443.007 -243.962 443.063 -242.954 442.034 -241.966 441.022 -240.986 441.028 -239.958 440.035 -238.961 440.03 -237.993 439.008 -236.982 438.061 -235.944 438.002 -234.966 437.083 -234.953 436.053 -234.953 435.033 -234.938 434.057 -234.958 433.019 -234.988 432.008 -234.983 431.072 -234.908 430.028 -234.919 429.035 -234.944 428.077 -234.95 427.098 -234.961 426.09 -233.991 426.044 -232.983 426.027 -231.968 426.025 -230.983 426.077 -229.982 426.032 -228.936 426.011 -227.956 426.072 -226.908 426.015 -225.91 426.027 -224.998 426.006 -223.957 426.094 -222.925 426.062 -221.982 426.089 -220.95 426.06 -219.981 426.019 -218.932 425.066 -217.917 424.097 -217.927 423.057 -217.996 422.001 -217.908 421.032 -217.995 420.063 -217.92 419.085 -217.951 418.083 -217.947 417.099 -217.955 416.051 -217.917 415.028 -217.941 414.077 -217.908 413.037 -217.926 412.011 -217.981 411.062 -217.9 410.051 -217.915 409.05 -217.994 408.022 -217.962 407.064 -217.947 406.03 -217.992 405.091 -217.905 404.055 -217.955 403.043 -217.953 402.014 -217.931 401.099 -217.917 400.038 -217.986 399.069 -217.956 398.001 -217.906 397.032 -217.969 396.045 -217.942 395.025 -217.914 394.031 -217.915 393.032 -217.91 392.085 -217.934 0

file "hole":
120 315.932 -291.015 315.967 -292.035 315.915 -293.051 315.983 -294.098 315.996 -295.042 315.909 -296.006 315.995 -297.051 316.933 -298.044 317.928 -299.089 317.974 -300.067 318.974 -301.039 318.938 -302.051 319.955 -303.087 320.924 -304.004 321.994 -305.012 321.925 -306.002 322.961 -307.04 322.994 -308.081 323.956 -309.007 323.916 -310.068 324.96 -311.05 324.979 -312.07 325.986 -313.057 326.958 -314.013 327.963 -314.004 328.913 -314.042 329.997 -314.011 330.937 -314.072 331.927 -314.028 332.921 -314.02 333.932 -314.015 334.988 -314.081 335.996 -314.095 336.972 -314.097 337.996 -314.058 338.981 -314.076 339.922 -314.003 340.915 -314.01 341.977 -314.077 342.903 -314.052 343.985 -314.014 345 -314.089 345.951 -314.026 346.925 -314.088 347.99 -314.05 348.987 -314.05 349.982 -314.007 350.956 -314.029 351.959 -314.063 352.949 -314.071 352.998 -313.067 352.984 -312.032 352.903 -311.052 353.955 -310.013 354.966 -310.053 355.906 -310.081 356.989 -310.058 357.941 -310.017 358.947 -310.029 359.944 -310.055 360.988 -310.01 360.972 -309.052 360.941 -308.062 360.953 -307.061 360.92 -306.041 360.993 -305.035 360.92 -304.062 360.905 -303.039 361.972 -302.06 361.959 -301.008 361.949 -300.091 361.977 -299.013 361.916 -298.092 361.965 -297.079 360.991 -297.032 359.912 -296.019 358.913 -296.079 357.947 -296.025 356.902 -296.02 355.975 -296.086 354.994 -296.043 353.991 -295.061 353.918 -294.036 352.997 -293.088 351.942 -292.006 350.911 -292.063 349.918 -292.064 348.999 -292.049 347.957 -292.087 346.922 -292.065 345.987 -292.011 344.915 -292.018 343.901 -292.046 342.907 -292.009 341.958 -292.086 340.992 -292.001 339.942 -292.097 338.957 -292.06 337.945 -292.049 336.983 -292.063 335.977 -292.087 334.913 -292.089 333.964 -292.01 332.926 -292.083 331.947 -292.031 330.985 -292.01 329.938 -292.007 328.913 -292.08 327.939 -292.013 326.965 -292.083 325.995 -292.032 324.942 -292.094 323.975 -291.05 322.923 -291.086 321.95 -291.024 320.957 -291.036 319.983 -291.014 318.993 -291.036 317.971 -291.033 316.983 -291.099

Environment

  • Operating system (Windows/Mac/Linux, 32/64 bits): windows 64
  • Compiler: vs 2013
  • Release or debug mode: release
  • CGAL version: 4.9.1
  • Boost version: 1.6.1