From c2912fc0762f2fba9639a1d701f518026577a531 Mon Sep 17 00:00:00 2001 From: Fernando Cacciola Date: Tue, 1 Dec 2009 14:15:06 +0000 Subject: [PATCH] Fixed Save bezier feature. Saved samples added --- .gitattributes | 2 + .../boolean_operations_2.cpp | 14 +++-- .../include/CGAL/Qt/BezierCurves.h | 2 +- .../Boolean_set_operations_2/input_0.bps | 48 ++++++++++++++++ .../Boolean_set_operations_2/input_1.bps | 57 +++++++++++++++++++ 5 files changed, 118 insertions(+), 5 deletions(-) create mode 100644 Boolean_set_operations_2/examples/Boolean_set_operations_2/input_0.bps create mode 100644 Boolean_set_operations_2/examples/Boolean_set_operations_2/input_1.bps diff --git a/.gitattributes b/.gitattributes index dc168bd8ed0..217d433b25c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -910,6 +910,8 @@ Boolean_set_operations_2/examples/Boolean_set_operations_2/amer_k.bps -text Boolean_set_operations_2/examples/Boolean_set_operations_2/bezier_traits_adapter2.cpp -text Boolean_set_operations_2/examples/Boolean_set_operations_2/char_g.dat -text Boolean_set_operations_2/examples/Boolean_set_operations_2/char_m.dat -text +Boolean_set_operations_2/examples/Boolean_set_operations_2/input_0.bps -text +Boolean_set_operations_2/examples/Boolean_set_operations_2/input_1.bps -text Boolean_set_operations_2/examples/Boolean_set_operations_2/pgn_holes.dat -text Boolean_set_operations_2/examples/Boolean_set_operations_2/test.dxf -text svneol=unset#application/octet-stream Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_on_surface_base_2.h -text diff --git a/Boolean_set_operations_2/demo/Boolean_set_operations_2_GraphicsView/boolean_operations_2.cpp b/Boolean_set_operations_2/demo/Boolean_set_operations_2_GraphicsView/boolean_operations_2.cpp index cf55f097c12..bd6d4cb0ce8 100644 --- a/Boolean_set_operations_2/demo/Boolean_set_operations_2_GraphicsView/boolean_operations_2.cpp +++ b/Boolean_set_operations_2/demo/Boolean_set_operations_2_GraphicsView/boolean_operations_2.cpp @@ -889,7 +889,7 @@ bool save_circular ( QString aFileName, Circular_polygon_set& rSet ) return rOK ; } -void save_bezier_polygon( std::ostream& out_file, Bezier_polygon const& aBP ) +void save_bezier_polygon( std::ostream& out_file, Bezier_polygon const& aBP, boost::optional& rLastP ) { out_file << aBP.size() << std::endl ; @@ -905,7 +905,11 @@ void save_bezier_polygon( std::ostream& out_file, Bezier_polygon const& aBP ) for ( Linear_point_vector::const_iterator pit = lQ.begin() ; pit != lQ.end() ; ++ pit ) { - out_file << pit->x() << " " << pit->y() << std::endl ; + Linear_point lP = pit == lQ.begin() && !!rLastP ? *rLastP : *pit ; + + out_file << lP.x() << " " << lP.y() << std::endl ; + + rLastP = lP ; } } } @@ -930,10 +934,12 @@ bool save_bezier ( QString aFileName, Bezier_polygon_set const& aSet ) out_file << ( 1 + bpwh.number_of_holes() ) << std::endl ; - save_bezier_polygon( out_file, bpwh.outer_boundary() ) ; + boost::optional lLastP ; + + save_bezier_polygon( out_file, bpwh.outer_boundary() , lLastP ) ; for ( Bezier_polygon_with_holes::Hole_const_iterator hit = bpwh.holes_begin() ; hit != bpwh.holes_end() ; ++ hit ) - save_bezier_polygon(out_file, *hit); + save_bezier_polygon(out_file, *hit, lLastP ); rOK = true ; } diff --git a/Boolean_set_operations_2/demo/Boolean_set_operations_2_GraphicsView/include/CGAL/Qt/BezierCurves.h b/Boolean_set_operations_2/demo/Boolean_set_operations_2_GraphicsView/include/CGAL/Qt/BezierCurves.h index 326813bf30e..d5e03df6126 100644 --- a/Boolean_set_operations_2/demo/Boolean_set_operations_2_GraphicsView/include/CGAL/Qt/BezierCurves.h +++ b/Boolean_set_operations_2/demo/Boolean_set_operations_2_GraphicsView/include/CGAL/Qt/BezierCurves.h @@ -108,7 +108,7 @@ struct Bezier_helper } template - static void approximated_clip ( Bezier_X_monotone_curve const& aXMCurve, Output_iterator aOut, double aApproxError = 1e-3 ) + static void approximated_clip ( Bezier_X_monotone_curve const& aXMCurve, Output_iterator aOut, double aApproxError = 1e-10 ) { typedef typename value_type_traits::type Output_point ; diff --git a/Boolean_set_operations_2/examples/Boolean_set_operations_2/input_0.bps b/Boolean_set_operations_2/examples/Boolean_set_operations_2/input_0.bps new file mode 100644 index 00000000000..f22dc0d9e5e --- /dev/null +++ b/Boolean_set_operations_2/examples/Boolean_set_operations_2/input_0.bps @@ -0,0 +1,48 @@ +DOUBLE +1 +1 +9 +4 +-6.18819 -63.2992 +-22.6303 -16.5027 +-32.5842 0.783979 +-34 3 +4 +-34 3 +-103 111 +-158 192 +-241 143 +4 +-241 143 +-324 94 +-307 46 +-361 118 +4 +-361 118 +-410.351 183.802 +-492.277 156.057 +-492.277 114.916 +4 +-492.277 114.916 +-490.318 104.011 +-490.011 103.03 +-490 103 +4 +-490 103 +-472 56 +-474 52 +-468 21 +3 +-468 21 +-462 -10 +-446 -18 +4 +-446 -18 +-384 -206 +-321 -360 +-175 -224 +4 +-175 -224 +-68.9702 -125.233 +-6.18819 -107.159 +-6.18819 -63.2992 diff --git a/Boolean_set_operations_2/examples/Boolean_set_operations_2/input_1.bps b/Boolean_set_operations_2/examples/Boolean_set_operations_2/input_1.bps new file mode 100644 index 00000000000..577c079ef6a --- /dev/null +++ b/Boolean_set_operations_2/examples/Boolean_set_operations_2/input_1.bps @@ -0,0 +1,57 @@ +DOUBLE +1 +1 +11 +4 +-278.944 -19.9798 +-278.957 -34.4347 +-279.241 -47.4194 +-279.228 -58.984 +4 +-279.228 -58.984 +-274.669 -116.195 +-246.089 -136.579 +-203 -139 +4 +-203 -139 +-114 -144 +-114 -158 +-47 -108 +4 +-47 -108 +1.25439 -71.9893 +33.4288 -79.5501 +33.4592 -56.3397 +4 +33.4592 -56.3397 +24.4709 -25.7293 +18.8323 -12.774 +18 -11 +4 +18 -11 +-20 70 +21 108 +-52 110 +4 +-52 110 +-125 112 +-50 37 +-139 68 +4 +-139 68 +-228 99 +-188 140 +-238 105 +3 +-238 105 +-280.373 75.339 +-280.373 13.3597 +3 +-280.373 13.3597 +-279.209 -8.13847 +-279 -10 +4 +-279 -10 +-278.96 -13.4014 +-278.944 -16.7276 +-278.944 -19.9798