1 // SPDX-License-Identifier: GPL-2.0-or-later 2 #ifndef INKSCAPE_LPE_PTS_TO_ELLIPSE_H 3 #define INKSCAPE_LPE_PTS_TO_ELLIPSE_H 4 5 /** \file 6 * LPE "Points to Ellipse" implementation 7 */ 8 9 /* 10 * Authors: 11 * Markus Schwienbacher 12 * 13 * Copyright (C) Markus Schwienbacher 2013 <mschwienbacher@gmail.com> 14 * 15 * Released under GNU GPL v2+, read the file 'COPYING' for more information. 16 */ 17 18 #include "live_effects/effect.h" 19 #include "live_effects/parameter/bool.h" 20 #include "live_effects/parameter/enum.h" 21 22 #include <gsl/gsl_linalg.h> 23 24 25 // struct gsl_vector; 26 // struct gsl_permutation; 27 28 namespace Inkscape { 29 namespace LivePathEffect { 30 31 enum EllipseMethod { 32 EM_AUTO, 33 EM_CIRCLE, 34 EM_ISOMETRIC_CIRCLE, 35 EM_PERSPECTIVE_CIRCLE, 36 EM_STEINER_ELLIPSE, 37 EM_STEINER_INELLIPSE, 38 EM_END 39 }; 40 41 class LPEPts2Ellipse : public Effect { 42 public: 43 LPEPts2Ellipse(LivePathEffectObject *lpeobject); 44 ~LPEPts2Ellipse() override; 45 46 Geom::PathVector doEffect_path(Geom::PathVector const &path_in) override; 47 48 private: 49 LPEPts2Ellipse(const LPEPts2Ellipse &) = delete; 50 LPEPts2Ellipse &operator=(const LPEPts2Ellipse &) = delete; 51 52 53 int genIsometricEllipse(std::vector<Geom::Point> const &points_in, Geom::PathVector &path_out); 54 55 int genFitEllipse(std::vector<Geom::Point> const &points_in, Geom::PathVector &path_out); 56 57 int genSteinerEllipse(std::vector<Geom::Point> const &points_in, bool gen_inellipse, Geom::PathVector &path_out); 58 59 int genPerspectiveEllipse(std::vector<Geom::Point> const &points_in, Geom::PathVector &path_out); 60 61 // utility functions 62 static int unit_arc_path(Geom::Path &path_in, Geom::Affine &affine, double start = 0.0, 63 double end = 2.0 * M_PI, // angles 64 bool slice = false); 65 static void gen_iso_frame_paths(Geom::PathVector &path_out, const Geom::Affine &affine); 66 static void gen_perspective_frame_paths(Geom::PathVector &path_out, const double rot_angle, 67 double projmatrix[3][3]); 68 static void gen_axes_paths(Geom::PathVector &path_out, const Geom::Affine &affine); 69 static void gen_perspective_axes_paths(Geom::PathVector &path_out, const double rot_angle, double projmatrix[3][3]); 70 static bool is_ccw(const std::vector<Geom::Point> &pts); 71 static Geom::Point projectPoint(Geom::Point p, double m[][3]); 72 73 // GUI parameters 74 EnumParam<EllipseMethod> method; 75 BoolParam gen_isometric_frame; 76 BoolParam gen_perspective_frame; 77 BoolParam gen_arc; 78 BoolParam other_arc; 79 BoolParam slice_arc; 80 BoolParam draw_axes; 81 BoolParam draw_perspective_axes; 82 ScalarParam rot_axes; 83 BoolParam draw_ori_path; 84 85 // collect the points from the input paths 86 std::vector<Geom::Point> points; 87 88 // used for solving perspective circle 89 gsl_vector *gsl_x; 90 gsl_permutation *gsl_p; 91 std::vector<Geom::Point> five_pts; 92 }; 93 94 } // namespace LivePathEffect 95 } // namespace Inkscape 96 97 #endif 98 99 /* 100 Local Variables: 101 mode:c++ 102 c-file-style:"stroustrup" 103 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) 104 indent-tabs-mode:nil 105 fill-column:99 106 End: 107 */ 108 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : 109