diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-05-09 22:37:31 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-05-09 22:37:31 +0000 |
| commit | 6195a5fd157ff2681534aa90a279627e0048d4e1 (patch) | |
| tree | 2f3d936f145cc1b641a79dc12246bc87286672c9 /src/helper | |
| parent | fixing review (diff) | |
| download | inkscape-6195a5fd157ff2681534aa90a279627e0048d4e1.tar.gz inkscape-6195a5fd157ff2681534aa90a279627e0048d4e1.zip | |
fixing review
(bzr r13645.1.87)
Diffstat (limited to 'src/helper')
| -rw-r--r-- | src/helper/geom-satellite.cpp | 50 | ||||
| -rw-r--r-- | src/helper/geom-satellite.h | 54 |
2 files changed, 53 insertions, 51 deletions
diff --git a/src/helper/geom-satellite.cpp b/src/helper/geom-satellite.cpp index 397a556a9..51cff7d79 100644 --- a/src/helper/geom-satellite.cpp +++ b/src/helper/geom-satellite.cpp @@ -11,7 +11,6 @@ #include <helper/geom-satellite.h> #include <2geom/curve.h> #include <2geom/nearest-point.h> -#include <2geom/sbasis-geometric.h> #include <2geom/path-intersection.h> #include <2geom/sbasis-to-bezier.h> #include <2geom/ray.h> @@ -29,56 +28,7 @@ Satellite::Satellite(SatelliteType satellite_type) Satellite::~Satellite() {} -/** - * Calculate the time in d2_in with a size of A - * TODO: find a better place to it - */ -double timeAtArcLength(double A, Geom::D2<Geom::SBasis> const d2_in) -{ - if (!d2_in.isFinite() || d2_in.isZero() || A == 0) { - return 0; - } - double t = 0; - double length_part = Geom::length(d2_in, Geom::EPSILON); - if (A > length_part || d2_in[0].degreesOfFreedom() == 2) { - if (length_part != 0) { - t = A / length_part; - } - } else if (d2_in[0].degreesOfFreedom() != 2) { - Geom::Piecewise<Geom::D2<Geom::SBasis> > u; - u.push_cut(0); - u.push(d2_in, 1); - std::vector<double> t_roots = roots(arcLengthSb(u) - A); - if (t_roots.size() > 0) { - t = t_roots[0]; - } - } - return t; -} - -/** - * Calculate the size in d2_in with a point at A - * TODO: find a better place to it - */ -double arcLengthAt(double A, Geom::D2<Geom::SBasis> const d2_in) -{ - if (!d2_in.isFinite() || d2_in.isZero() || A == 0) { - return 0; - } - double s = 0; - double length_part = Geom::length(d2_in, Geom::EPSILON); - if (A > length_part || d2_in[0].degreesOfFreedom() == 2) { - s = (A * length_part); - } else if (d2_in[0].degreesOfFreedom() != 2) { - Geom::Piecewise<Geom::D2<Geom::SBasis> > u; - u.push_cut(0); - u.push(d2_in, 1); - u = Geom::portion(u, 0.0, A); - s = Geom::length(u, 0.001); - } - return s; -} /** * Calculate the length of a satellite from a radious A input. diff --git a/src/helper/geom-satellite.h b/src/helper/geom-satellite.h index 263cefa68..a4b1b23b9 100644 --- a/src/helper/geom-satellite.h +++ b/src/helper/geom-satellite.h @@ -14,6 +14,7 @@ #include <2geom/d2.h> #include <map> #include <boost/assign.hpp> +#include <2geom/sbasis-geometric.h> #include "util/enums.h" @@ -22,7 +23,7 @@ enum SatelliteType { INVERSE_FILLET, //Inverse Fillet CHAMFER, //Chamfer INVERSE_CHAMFER, //Inverse Chamfer - INVALID_SATELLITE // Invalid Satellite) + INVALID_SATELLITE // Invalid Satellite }; /** * @brief Satellite a per ?node/curve holder of data. @@ -68,6 +69,57 @@ public: size_t steps; }; +/** + * Calculate the time in d2_in with a size of A + * TODO: find a better place to it + */ +double timeAtArcLength(double A, Geom::D2<Geom::SBasis> const d2_in) +{ + if (!d2_in.isFinite() || d2_in.isZero() || A == 0) { + return 0; + } + double t = 0; + double length_part = Geom::length(d2_in, Geom::EPSILON); + if (A > length_part || d2_in[0].degreesOfFreedom() == 2) { + if (length_part != 0) { + t = A / length_part; + } + } else if (d2_in[0].degreesOfFreedom() != 2) { + Geom::Piecewise<Geom::D2<Geom::SBasis> > u; + u.push_cut(0); + u.push(d2_in, 1); + std::vector<double> t_roots = roots(arcLengthSb(u) - A); + if (t_roots.size() > 0) { + t = t_roots[0]; + } + } + + return t; +} + +/** + * Calculate the size in d2_in with a point at A + * TODO: find a better place to it + */ +double arcLengthAt(double A, Geom::D2<Geom::SBasis> const d2_in) +{ + if (!d2_in.isFinite() || d2_in.isZero() || A == 0) { + return 0; + } + double s = 0; + double length_part = Geom::length(d2_in, Geom::EPSILON); + if (A > length_part || d2_in[0].degreesOfFreedom() == 2) { + s = (A * length_part); + } else if (d2_in[0].degreesOfFreedom() != 2) { + Geom::Piecewise<Geom::D2<Geom::SBasis> > u; + u.push_cut(0); + u.push(d2_in, 1); + u = Geom::portion(u, 0.0, A); + s = Geom::length(u, 0.001); + } + return s; +} + #endif // SEEN_SATELLITE_H /* |
