diff --git a/Arrangement_2/examples/Arrangement_2/Bezier.dat b/Arrangement_2/examples/Arrangement_2/Bezier.dat index 2c6323c5995..b8ee0c0ff1d 100644 --- a/Arrangement_2/examples/Arrangement_2/Bezier.dat +++ b/Arrangement_2/examples/Arrangement_2/Bezier.dat @@ -1,21 +1,12 @@ -3 - -4 -0/1 1/2 -1/1 -2/1 -3/1 2/1 -4/1 -1/2 - -4 -0/1 0/1 -1/1 1/1 -3/1 -1/1 -4/1 0/1 - -4 --2/1 4/1 -4/1 2/1 --2/1 0/1 -4/1 -2/1 - +10 +6 2295 5175 3555 4365 4185 5445 5220 4770 6255 5400 7200 4230 +6 8460 6165 9675 5130 7425 4680 8910 3915 6930 3465 7965 2835 +6 4635 5850 1440 4410 4275 3285 5940 4410 4455 4905 3960 4365 +6 3375 3510 2115 2970 3780 1980 4815 2880 6165 2070 6930 3060 +6 8010 3375 6615 4050 5085 2925 5490 1935 3105 1755 1620 4050 +6 9315 3690 7875 1710 7290 2475 6435 2700 5985 3780 8775 4590 +6 8055 5715 5355 6345 2745 5490 3150 4275 2115 3825 3150 3015 +6 1980 6570 3285 4320 1530 3375 2385 2160 3825 2790 4860 1485 +6 6480 2205 5535 5625 7470 6165 3375 6705 1305 5535 2790 3825 +6 4320 6300 6840 6795 7515 5535 7875 6525 6075 7335 3015 6840 diff --git a/Arrangement_2/examples/Arrangement_2/ex_Bezier_curves.cpp b/Arrangement_2/examples/Arrangement_2/ex_Bezier_curves.cpp index 2b4657ba5d3..b8978e87feb 100644 --- a/Arrangement_2/examples/Arrangement_2/ex_Bezier_curves.cpp +++ b/Arrangement_2/examples/Arrangement_2/ex_Bezier_curves.cpp @@ -29,55 +29,6 @@ typedef CGAL::Arr_Bezier_curve_traits_2 Arrangement_2; -bool read_Bezier_curves (const char* filename, - std::list& curves) -{ - // Clear the output list. - curves.clear(); - - // Open the input file. - std::ifstream in_file (filename); - - if (! in_file.is_open()) - return (false); - - // Read the number of curves. - int n_curves = -1; - - in_file >> n_curves; - if (n_curves <= 0) - return (false); - - // Read the curves one by one. Each curve is given by a number of control - // points, followed by a list of the control points (with rational - // coordinates). - int n_points; - Rational x, y; - int i, j; - - for (i = 0; i < n_curves; i++) - { - // Read the number of control points. - in_file >> n_points; - if (n_points <= 0) - return (false); - - // Read the control points. - std::vector ctrl_pts (n_points); - - for (j = 0; j < n_points; j++) - { - in_file >> x >> y; - ctrl_pts[j] = Rat_point_2 (x, y); - } - - // Construct the Bezier curve. - curves.push_back (Bezier_curve_2 (ctrl_pts.begin(), ctrl_pts.end())); - } - - return (true); -} - int main (int argc, char **argv) { // Get the name of the input file from the command line, or use the default @@ -87,21 +38,30 @@ int main (int argc, char **argv) if (argc > 1) filename = argv[1]; - // Read the curves from the input file. - std::list curves; + // Open the input file. + std::ifstream in_file (filename); - if (! read_Bezier_curves (filename, curves)) + if (! in_file.is_open()) { - std::cerr << "Failed to read data from " << filename << std::endl; + std::cerr << "Failed to open " << filename << std::endl; return (1); } - // Print the curves. - std::list::iterator cit; - unsigned int ind = 1; + // Read the curves from the input file. + unsigned int n_curves; + std::list curves; + Bezier_curve_2 B; + unsigned int k; + + in_file >> n_curves; + for (k = 0; k < n_curves; k++) + { + // Read the current curve (specified by its control points). + in_file >> B; + curves.push_back (B); - for (cit = curves.begin(); cit != curves.end(); ++cit, ind++) - std::cout << "B_" << ind << " (t) = " << *cit << std::endl; + std::cout << "B = {" << B << "}" << std::endl; + } // Construct the arrangement. Arrangement_2 arr; diff --git a/Arrangement_2/include/CGAL/Arr_traits_2/Bezier_curve_2.h b/Arrangement_2/include/CGAL/Arr_traits_2/Bezier_curve_2.h index 53f05e20e5b..4a0d0db7adb 100644 --- a/Arrangement_2/include/CGAL/Arr_traits_2/Bezier_curve_2.h +++ b/Arrangement_2/include/CGAL/Arr_traits_2/Bezier_curve_2.h @@ -620,7 +620,7 @@ operator>> (std::istream& is, is >> n; // Read the control points. - std::vector ctrl_pts; + std::vector ctrl_pts (n); unsigned int k; for (k = 0; k < n; k++)