Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Crashed problems of insertion operation in bezier arrangement

Subject: CGAL users discussion list

List archive

[cgal-discuss] Crashed problems of insertion operation in bezier arrangement


Chronological Thread 
  • From: stzpz <>
  • To:
  • Subject: [cgal-discuss] Crashed problems of insertion operation in bezier arrangement
  • Date: Sun, 6 Mar 2011 08:44:55 -0800 (PST)

When I inserting a lot of bezier curves into the bezier arrangement, two
crash problems may occurred. Here is the code for test:
===================== CODE BEGIN ======================
#include
#include
#include
#include
#include
#include
#include
using namespace std;

typedef CGAL::CORE_algebraic_number_traits Nt_traits;
typedef Nt_traits::Rational NT;
typedef Nt_traits::Rational Rational;
typedef Nt_traits::Algebraic Algebraic;
typedef CGAL::Cartesian Rat_kernel;
typedef CGAL::Cartesian Alg_kernel;
typedef Rat_kernel::Point_2 Rat_point_2;
typedef CGAL::Arr_Bezier_curve_traits_2
Traits_2;
typedef Traits_2::Curve_2 Bezier_curve_2;
typedef CGAL::Arrangement_2 Arrangement_2;
#define TORAT(x) (CGAL::to_rational((x)))

void insertCurves(const char *filename, Arrangement_2 *arr)
{
std::ifstream in_file (filename);

int n_curves;
list curves;
int k;

in_file >> n_curves;
for (k = 0; k < n_curves; k++)
{
int cp_count;
double xx, yy;
list ctrl_points;

in_file >> cp_count;
for(int i=0; i> xx >> yy;
ctrl_points.push_back(Rat_point_2(TORAT(xx), TORAT(yy)));
}

Bezier_curve_2 org_curve(ctrl_points.begin(), ctrl_points.end());
curves.push_back(org_curve);
}
// assertion here
insert (*arr, curves.begin(), curves.end());
}

int main (int argc, char *argv[])
{
const char *filename = (argc > 1) ? argv[1] : "test_data.txt";
int k = 0;
while(true)
{
Arrangement_2 arr;
insertCurves(filename, &arr);
printf("%d done.\n", k++);
}
return 0;
}
==================== CODE END ========================

(1) Using the above code, with a test_data.txt contains a lot of bezier
curves, the insert() is likely to crash because of assertion violation. It
may sometimes running normally, but it seems that, the more the curves, the
higher probability of being crashed. Here is the test data:
==================== test_data.txt BEGIN ========================
67
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 42.000 -108.000 -25.257 -59.257 -59.082 -35.082 -133.000 7.000
4 -133.000 7.000 -139.882 10.918 -155.728 13.528 -160.000 7.000
4 -160.000 7.000 -176.928 -18.872 -181.561 -43.247 -186.000 -74.000
4 -186.000 -74.000 -187.161 -82.047 -181.542 -92.622 -174.000 -90.000
4 -174.000 -90.000 -88.342 -60.222 -35.391 -37.809 47.000 7.000
4 47.000 7.000 55.809 11.791 52.673 23.717 54.000 34.000
4 54.000 34.000 54.273 36.117 53.313 37.513 51.000 38.000
4 51.000 38.000 45.713 39.113 39.023 40.377 35.000 38.000
4 35.000 38.000 30.223 35.177 31.084 30.516 29.000 25.000
4 29.000 25.000 24.284 12.516 20.901 7.299 18.000 -7.000
4 18.000 -7.000 15.301 -20.301 17.667 -30.667 15.000 -44.000
4 15.000 -44.000 11.267 -62.667 6.008 -68.608 2.000 -87.000
4 2.000 -87.000 -0.792 -99.808 -0.400 -108.000 -2.000 -122.000
4 -2.000 -122.000 12.000 -123.200 21.536 -128.227 33.000 -125.000
4 33.000 -125.000 75.536 -113.027 102.872 -110.272 133.000 -84.000
4 133.000 -84.000 152.872 -66.672 155.308 -43.655 158.000 -16.000
4 158.000 -16.000 159.708 1.545 149.600 11.000 144.000 29.000
4 144.000 29.000 133.200 10.600 119.329 4.855 117.000 -17.000
4 117.000 -17.000 114.129 -43.945 119.701 -68.299 131.000 -93.000
4 131.000 -93.000 136.901 -105.899 146.281 -105.919 160.000 -111.000
4 160.000 -111.000 167.881 -113.919 175.550 -113.579 185.000 -113.000
4 185.000 -113.000 195.150 -112.379 202.075 -110.189 209.000 -108.000
4 -113.000 -125.000 -178.960 -20.560 -161.920 -46.120 -196.000 5.000
4 -196.000 5.000 -213.120 30.680 -223.000 42.200 -241.000 67.000
4 -241.000 67.000 -255.000 33.800 -272.583 19.667 -276.000 -16.000
4 -276.000 -16.000 -278.983 -47.133 -264.600 -66.400 -257.000 -100.000
4 -257.000 -100.000 -197.000 -65.600 -173.497 -41.903 -107.000 -14.000
4 -107.000 -14.000 -71.497 0.897 -39.591 8.114 -2.000 7.000
4 -2.000 7.000 14.409 6.514 20.313 -3.687 28.000 -18.000
4 28.000 -18.000 43.513 -46.887 44.800 -67.800 56.000 -101.000
4 56.000 -101.000 14.400 -78.600 -20.709 -81.709 -48.000 -45.000
4 -48.000 -45.000 -77.509 -5.309 -70.800 36.000 -86.000 90.000
4 -86.000 90.000 -50.800 89.600 -25.217 97.383 2.000 89.000
4 2.000 89.000 79.983 64.983 123.845 57.845 177.000 9.000
4 177.000 9.000 197.845 -10.155 198.018 -56.808 187.000 -81.000
4 187.000 -81.000 179.618 -97.208 145.565 -101.030 131.000 -92.000
4 131.000 -92.000 105.565 -76.230 94.770 -57.669 87.000 -19.000
4 87.000 -19.000 77.570 27.931 87.600 65.600 88.000 122.000
4 88.000 122.000 43.600 122.000 20.486 121.086 -23.000 122.000
4 -23.000 122.000 -112.714 123.886 -169.127 140.864 -245.000 129.000
4 -245.000 129.000 -279.127 123.664 -288.048 109.054 -298.000 79.000
4 -298.000 79.000 -308.048 48.654 -314.050 0.550 -295.000 -22.000
4 -295.000 -22.000 -274.850 -45.850 -240.057 -36.211 -200.000 -37.000
4 -200.000 -37.000 -138.457 -38.211 -105.970 -29.630 -41.000 -27.000
4 -41.000 -27.000 -7.170 -25.630 13.074 -25.726 47.000 -27.000
4 47.000 -27.000 98.274 -28.926 131.550 -22.250 172.000 -35.000
4 172.000 -35.000 205.150 -45.450 207.400 -65.000 231.000 -85.000
4 231.000 -85.000 181.000 -105.000 159.483 -125.300 106.000 -135.000
4 106.000 -135.000 77.883 -140.100 51.320 -134.480 27.000 -122.000
4 27.000 -122.000 -9.480 -103.280 -15.806 -82.006 -46.000 -57.000
4 -46.000 -57.000 -106.606 -6.806 -135.948 49.212 -200.000 66.000
4 -200.000 66.000 -235.148 75.212 -256.400 31.200 -294.000 8.000
4 -294.000 8.000 -270.400 -8.000 -266.550 -29.663 -235.000 -32.000
4 -235.000 -32.000 -169.350 -36.863 -118.019 -25.381 -51.000 -10.000
4 -51.000 -10.000 52.781 13.819 122.391 39.909 192.000 66.000
4 -287.000 -106.000 -80.593 -124.319 -127.185 -127.639 -34.000 -121.000
4 -34.000 -121.000 24.415 -116.839 44.057 -98.257 92.000 -79.000
4 92.000 -79.000 139.657 -59.857 159.800 -46.600 205.000 -25.000
4 205.000 -25.000 77.800 -7.000 18.949 7.877 -113.000 20.000
4 -113.000 20.000 -168.251 25.077 -213.892 29.692 -263.000 18.000
4 -263.000 18.000 -289.492 11.692 -304.589 -6.011 -302.000 -25.000
4 -302.000 -25.000 -297.389 -58.811 -269.790 -80.390 -245.000 -114.000
4 -245.000 -114.000 -228.190 -136.790 -213.095 -151.395 -198.000 -166.000
4 -185.000 -138.000 -222.687 -68.487 -206.374 -78.974 -239.000 -58.000
4 -239.000 -58.000 -256.774 -46.574 -285.330 -54.112 -311.000 -57.000
4 -311.000 -57.000 -317.330 -57.712 -318.165 -62.356 -319.000 -67.000
==================== test_data.txt END ========================

(2) Using the above code, with a lot of bezier curves of the same control
points, the requiring memory of the code will increasing rapidly and finally
run out of memory. Here is the test data:
==================== test_dup.txt END ========================
30
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
4 45.000 -122.000 43.971 -109.429 45.943 -110.857 42.000 -108.000
==================== test_dup.txt END ========================

Does anyone know how to resolve it?

Thanks so much!

Stzpz


--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Crashed-problems-of-insertion-operation-in-bezier-arrangement-tp3337743p3337743.html
Sent from the cgal-discuss mailing list archive at Nabble.com.



Archive powered by MHonArc 2.6.16.

Top of Page