src/polygoncache.cpp

changeset 358
ef90ed0a5720
parent 338
719b909a7d2b
child 372
b2914aaeec1a
equal deleted inserted replaced
357:66c75604f5b8 358:ef90ed0a5720
68 gl::invert(polygon); 68 gl::invert(polygon);
69 } 69 }
70 if (polygon.color == MAIN_COLOR) { 70 if (polygon.color == MAIN_COLOR) {
71 polygon.color = ref.color; 71 polygon.color = ref.color;
72 } 72 }
73 add(polygon); 73 add(1, polygon);
74 } 74 }
75 } 75 }
76 76
77 static QTextDocument* findDependency(const SubfileReference& ref, GetPolygonsContext* context) 77 static QTextDocument* findDependency(const SubfileReference& ref, GetPolygonsContext* context)
78 { 78 {
104 else if (text == QStringLiteral("BFC NOCERTIFY")) { 104 else if (text == QStringLiteral("BFC NOCERTIFY")) {
105 winding = NoWinding; 105 winding = NoWinding;
106 } 106 }
107 }, 107 },
108 [&](const LineType2& line2) { 108 [&](const LineType2& line2) {
109 add({line2.value, line2.value.color}); 109 add(2, {line2.value, line2.value.color});
110 }, 110 },
111 [&](const LineType3& line3) { 111 [&](const LineType3& line3) {
112 add({line3.value, line3.value.color}); 112 add(3, {line3.value, line3.value.color});
113 }, 113 },
114 [&](const LineType4& line4) { 114 [&](const LineType4& line4) {
115 add({line4.value, line4.value.color}); 115 add(4, {line4.value, line4.value.color});
116 }, 116 },
117 [&](const LineType5& line5) { 117 [&](const LineType5& line5) {
118 add({line5.value, line5.value.color}); 118 add(5, {line5.value, line5.value.color});
119 }, 119 },
120 [&add, context, &reserve](const LineType1& line1) { 120 [&add, context, &reserve](const LineType1& line1) {
121 QTextDocument* const dependency = findDependency(line1.value, context); 121 QTextDocument* const dependency = findDependency(line1.value, context);
122 if (PolygonCache* cache = (dependency != nullptr) 122 if (PolygonCache* cache = (dependency != nullptr)
123 ? findPolygonCacheForModel(dependency, context->documents) 123 ? findPolygonCacheForModel(dependency, context->documents)
148 GetPolygonsContext* context) 148 GetPolygonsContext* context)
149 { 149 {
150 Winding winding = NoWinding; 150 Winding winding = NoWinding;
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](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 (winding == Winding::Clockwise) { 155 if (lineno != 1 and winding == Winding::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);

mercurial