Commits

Barry Schwartz committed e6a149a

"optimize" function

Comments (0)

Files changed (3)

   external of_four_points : Point.t -> Point.t -> Point.t -> Point.t -> t = "bezier_curve_of_four_points_wrapper"
   external order : t -> int = "bezier_curve_order_wrapper"
   external subdivide : t -> float -> t * t = "bezier_curve_subdivide_wrapper"
+  external optimize : t -> t = "bezier_curve_optimize_wrapper"
   external initial_point : t -> Point.t = "bezier_curve_initial_point_wrapper"
   external final_point : t -> Point.t = "bezier_curve_final_point_wrapper"
   external is_degenerate : t -> bool = "bezier_curve_is_degenerate_wrapper"
   external of_two_points : Point.t -> Point.t -> t = "line_segment_of_two_points_wrapper"
   external order : t -> int = "line_segment_order_wrapper"
   external subdivide : t -> float -> Bezier_curve.t * Bezier_curve.t = "line_segment_subdivide_wrapper"
+  external optimize : t -> t = "line_segment_optimize_wrapper"
   external initial_point : t -> Point.t = "line_segment_initial_point_wrapper"
   external final_point : t -> Point.t = "line_segment_final_point_wrapper"
   external is_degenerate : t -> bool = "line_segment_is_degenerate_wrapper"
   external of_three_points : Point.t -> Point.t -> Point.t -> t = "quadratic_bezier_of_three_points_wrapper"
   external order : t -> int = "quadratic_bezier_order_wrapper"
   external subdivide : t -> float -> Bezier_curve.t * Bezier_curve.t = "quadratic_bezier_subdivide_wrapper"
+  external optimize : t -> t = "quadratic_bezier_optimize_wrapper"
   external initial_point : t -> Point.t = "quadratic_bezier_initial_point_wrapper"
   external final_point : t -> Point.t = "quadratic_bezier_final_point_wrapper"
   external is_degenerate : t -> bool = "quadratic_bezier_is_degenerate_wrapper"
   external of_four_points : Point.t -> Point.t -> Point.t -> Point.t -> t = "cubic_bezier_of_four_points_wrapper"
   external order : t -> int = "cubic_bezier_order_wrapper"
   external subdivide : t -> float -> Bezier_curve.t * Bezier_curve.t = "cubic_bezier_subdivide_wrapper"
+  external optimize : t -> t = "cubic_bezier_optimize_wrapper"
   external initial_point : t -> Point.t = "cubic_bezier_initial_point_wrapper"
   external final_point : t -> Point.t = "cubic_bezier_final_point_wrapper"
   external is_degenerate : t -> bool = "cubic_bezier_is_degenerate_wrapper"
   external of_four_points : Point.t -> Point.t -> Point.t -> Point.t -> t = "bezier_curve_of_four_points_wrapper"
   external order : t -> int = "bezier_curve_order_wrapper"
   external subdivide : t -> float -> t * t = "bezier_curve_subdivide_wrapper"
+  external optimize : t -> t = "bezier_curve_optimize_wrapper"
   external initial_point : t -> Point.t = "bezier_curve_initial_point_wrapper"
   external final_point : t -> Point.t = "bezier_curve_final_point_wrapper"
   external is_degenerate : t -> bool = "bezier_curve_is_degenerate_wrapper"
   external of_two_points : Point.t -> Point.t -> t = "line_segment_of_two_points_wrapper"
   external order : t -> int = "line_segment_order_wrapper"
   external subdivide : t -> float -> Bezier_curve.t * Bezier_curve.t = "line_segment_subdivide_wrapper"
+  external optimize : t -> t = "line_segment_optimize_wrapper"
   external initial_point : t -> Point.t = "line_segment_initial_point_wrapper"
   external final_point : t -> Point.t = "line_segment_final_point_wrapper"
   external is_degenerate : t -> bool = "line_segment_is_degenerate_wrapper"
   external of_three_points : Point.t -> Point.t -> Point.t -> t = "quadratic_bezier_of_three_points_wrapper"
   external order : t -> int = "quadratic_bezier_order_wrapper"
   external subdivide : t -> float -> Bezier_curve.t * Bezier_curve.t = "quadratic_bezier_subdivide_wrapper"
+  external optimize : t -> t = "quadratic_bezier_optimize_wrapper"
   external initial_point : t -> Point.t = "quadratic_bezier_initial_point_wrapper"
   external final_point : t -> Point.t = "quadratic_bezier_final_point_wrapper"
   external is_degenerate : t -> bool = "quadratic_bezier_is_degenerate_wrapper"
   external of_four_points : Point.t -> Point.t -> Point.t -> Point.t -> t = "cubic_bezier_of_four_points_wrapper"
   external order : t -> int = "cubic_bezier_order_wrapper"
   external subdivide : t -> float -> Bezier_curve.t * Bezier_curve.t = "cubic_bezier_subdivide_wrapper"
+  external optimize : t -> t = "cubic_bezier_optimize_wrapper"
   external initial_point : t -> Point.t = "cubic_bezier_initial_point_wrapper"
   external final_point : t -> Point.t = "cubic_bezier_final_point_wrapper"
   external is_degenerate : t -> bool = "cubic_bezier_is_degenerate_wrapper"

caml2geom_stubs.c

         Store_field(_pair, 0, _bc1);                                    \
         Store_field(_pair, 1, _bc2);                                    \
         CAMLreturn(_pair);                                              \
+    }                                                                   \
+                                                                        \
+    extern "C" CAMLprim value name##_optimize_wrapper(value _bezcurve)  \
+    {                                                                   \
+        CAMLparam1(_bezcurve);                                          \
+        CAMLlocal1(_new_curve);                                         \
+        t *bc = OPAQUE_P(t, _bezcurve);                                 \
+        Geom::BezierCurve *new_curve = bc->optimize();                  \
+        _new_curve = OPAQUE_P_ALLOC(Geom::BezierCurve, bezier_curve_ops); \
+        OPAQUE_P(Geom::BezierCurve, _new_curve) = new Geom::BezierCurve(*new_curve); \
+        CAMLreturn(_new_curve);                                         \
     }
-    
 
 //-------------------------------------------------------------------------