80 } |
80 } |
81 |
81 |
82 template<typename Fn, typename Fn2> |
82 template<typename Fn, typename Fn2> |
83 static void collectPolygons( |
83 static void collectPolygons( |
84 const ParsedLine& element, |
84 const ParsedLine& element, |
85 Winding& winding, |
85 winding_e& winding, |
86 GetPolygonsContext* context, |
86 GetPolygonsContext* context, |
87 Fn&& add, |
87 Fn&& add, |
88 Fn2&& reserve) |
88 Fn2&& reserve) |
89 { |
89 { |
90 bool foundinvertnext = false; |
90 bool foundinvertnext = false; |
94 if (text == QStringLiteral("BFC INVERTNEXT")) { |
94 if (text == QStringLiteral("BFC INVERTNEXT")) { |
95 context->invertnext = true; |
95 context->invertnext = true; |
96 foundinvertnext = true; |
96 foundinvertnext = true; |
97 } |
97 } |
98 else if (text == QStringLiteral("BFC CERTIFY CW")) { |
98 else if (text == QStringLiteral("BFC CERTIFY CW")) { |
99 winding = Clockwise; |
99 winding = winding_e::clockwise; |
100 } |
100 } |
101 else if (text == QStringLiteral("BFC CERTIFY CCW")) { |
101 else if (text == QStringLiteral("BFC CERTIFY CCW")) { |
102 winding = Anticlockwise; |
102 winding = winding_e::anticlockwise; |
103 } |
103 } |
104 else if (text == QStringLiteral("BFC NOCERTIFY")) { |
104 else if (text == QStringLiteral("BFC NOCERTIFY")) { |
105 winding = NoWinding; |
105 winding = winding_e::none; |
106 } |
106 } |
107 }, |
107 }, |
108 [&](const LineType2& line2) { |
108 [&](const LineType2& line2) { |
109 add(2, {line2.value, line2.value.color}); |
109 add(2, {line2.value, line2.value.color}); |
110 }, |
110 }, |
145 |
145 |
146 static std::vector<WithId<PolygonElement>> inlinePolygons( |
146 static std::vector<WithId<PolygonElement>> inlinePolygons( |
147 const QTextDocument* model, |
147 const QTextDocument* model, |
148 GetPolygonsContext* context) |
148 GetPolygonsContext* context) |
149 { |
149 { |
150 Winding winding = NoWinding; |
150 winding_e winding = winding_e::none; |
151 std::vector<WithId<PolygonElement>> result; |
151 std::vector<WithId<PolygonElement>> result; |
152 int i = 0; |
152 int i = 0; |
153 const auto add = [&result, &winding, &i](int lineno, const PolygonElement& poly){ |
153 const auto add = [&result, &winding, &i](int lineno, const PolygonElement& poly){ |
154 result.push_back({poly, i}); |
154 result.push_back({poly, i}); |
155 if (lineno != 1 and winding == Winding::Clockwise) { |
155 if (lineno != 1 and winding == winding_e::clockwise) { |
156 gl::invert(result.back()); |
156 gl::invert(result.back()); |
157 } |
157 } |
158 }; |
158 }; |
159 const auto reserve = [&result](std::size_t incomingsize){ |
159 const auto reserve = [&result](std::size_t incomingsize){ |
160 reserveMore(result, incomingsize); |
160 reserveMore(result, incomingsize); |