| #pragma once |
| |
| #ifndef TCURVES_UTIL_INCLUDED |
| #define TCURVES_UTIL_INCLUDED |
| |
| |
| #include "tgeometry.h" |
| |
| #undef DVAPI |
| #undef DVVAR |
| #ifdef TGEOMETRY_EXPORTS |
| #define DVAPI DV_EXPORT_API |
| #define DVVAR DV_EXPORT_VAR |
| #else |
| #define DVAPI DV_IMPORT_API |
| #define DVVAR DV_IMPORT_VAR |
| #endif |
| |
| |
| |
| |
| class TSegment; |
| class TQuadratic; |
| class TThickQuadratic; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| DVAPI bool isCloseToSegment(const TPointD &point, const TSegment &segment, |
| double distance); |
| |
| |
| |
| |
| DVAPI double tdistance(const TSegment &segment, const TPointD &point); |
| inline double tdistance(const TPointD &point, const TSegment &segment) { |
| return tdistance(segment, point); |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| DVAPI int intersect(const TPointD &seg1p0, const TPointD &seg1p1, |
| const TPointD &seg2p0, const TPointD &seg2p1, |
| std::vector<DoublePair> &intersections); |
| |
| DVAPI int intersect(const TSegment &first, const TSegment &second, |
| std::vector<DoublePair> &intersections); |
| |
| |
| |
| |
| |
| |
| DVAPI int intersect(const TQuadratic &q0, const TQuadratic &q1, |
| std::vector<DoublePair> &intersections, |
| bool checksegments = true); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| DVAPI int intersect(const TQuadratic &q, const TSegment &s, |
| std::vector<DoublePair> &intersections, |
| bool firstQuad = true); |
| |
| inline int intersect(const TSegment &s, const TQuadratic &q, |
| std::vector<DoublePair> &intersections) { |
| return intersect(q, s, intersections, false); |
| } |
| |
| template <class T> |
| void split(const T &tq, const std::vector<double> &pars, std::vector<T *> &v) { |
| if (pars.empty()) return; |
| |
| T *q1, q2; |
| |
| UINT i; |
| |
| q1 = new T(); |
| tq.split(pars[0], *q1, q2); |
| v.push_back(q1); |
| |
| for (i = 1; i < pars.size(); ++i) { |
| double newPar = (pars[i] - pars[i - 1]) / (1.0 - pars[i - 1]); |
| |
| q1 = new T(); |
| q2.split(newPar, *q1, q2); |
| v.push_back(q1); |
| } |
| |
| v.push_back(new T(q2)); |
| } |
| |
| template <class T> |
| void split(const T &tq, double w0, double w1, T &qOut) { |
| T q2; |
| |
| assert(w0 <= w1); |
| |
| if ((w1 - w0 == 0.0) && w0 == 1.0) { |
| tq.split(w0, q2, qOut); |
| return; |
| } |
| |
| tq.split(w0, qOut, q2); |
| |
| double newPar = (w1 - w0) / (1.0 - w0); |
| |
| q2.split(newPar, qOut, q2); |
| } |
| |
| DVAPI double computeStep(const TQuadratic &quad, double pixelSize); |
| |
| DVAPI double computeStep(const TThickQuadratic &quad, double pixelSize); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| class TQuadraticLengthEvaluator { |
| double m_c, m_e, m_f, m_sqrt_a_div_2, m_tRef, m_primitive_0; |
| bool m_constantSpeed, m_noSpeed0, m_squareIntegrand; |
| |
| public: |
| TQuadraticLengthEvaluator() {} |
| TQuadraticLengthEvaluator(const TQuadratic &quad) { setQuad(quad); } |
| |
| void setQuad(const TQuadratic &quad); |
| double getLengthAt(double t) const; |
| }; |
| |
| #endif |
| |
| |
| |