QmlMaterial 0.1.0
Loading...
Searching...
No Matches
measured_path.hpp
1#pragma once
2
3#include "qml_material/shape/rounded_polygon.hpp"
4
5namespace qml_material
6{
7
8class QML_MATERIAL_API MeasuredPath {
9public:
10 struct Location {
11 QPointF point;
12 QPointF tangent;
13 };
14 explicit MeasuredPath(std::vector<Cubic> curves = {}, qreal tolerance = 0.001);
15 qreal length() const { return m_length; }
16 Location location(qreal distance) const;
17 QPainterPath segment(qreal start, qreal end) const;
18 // Input is a continuous closed contour; extent is limited to one lap.
19 QPainterPath cyclicSegment(qreal start, qreal extent) const;
20
21private:
22 struct Sample {
23 qreal t;
24 qreal distance;
25 };
26 struct Entry {
27 Cubic curve;
28 qreal start;
29 qreal length;
30 std::vector<Sample> samples;
31 };
32 qreal parameter(const Entry& entry, qreal distance) const;
33 std::vector<Entry> m_entries;
34 qreal m_length = 0;
35};
36
37} // namespace qml_material