Wed, 22 Jun 2022 16:53:35 +0300
I felt that the compiler was too kind to me, so I enabled a big pile of warnings
| 154 | 1 | #include "ldrawalgorithm.h" | 
| 2 | ||
| 200 | 3 | std::pair<Triangle, Triangle> splitTriangles( | 
| 4 | const Quadrilateral& q, | |
| 5 | ldraw::Diagonal diagonal) | |
| 154 | 6 | { | 
| 200 | 7 | std::pair<Triangle, Triangle> result; | 
| 154 | 8 | switch (diagonal) | 
| 9 | { | |
| 10 | case ldraw::Diagonal::Diagonal_13: | |
| 200 | 11 | result = {Triangle{q.p1, q.p2, q.p3}, {q.p1, q.p3, q.p4}}; | 
| 154 | 12 | break; | 
| 13 | case ldraw::Diagonal::Diagonal_24: | |
| 200 | 14 | result = {Triangle{q.p1, q.p2, q.p3}, {q.p2, q.p3, q.p4}}; | 
| 154 | 15 | break; | 
| 16 | } | |
| 17 | return result; | |
| 18 | } | |
| 19 | ||
| 20 | /** | |
| 21 | * @brief Modifies the !LDRAW_ORG line so that it becomes unofficial | |
| 22 | */ | |
| 200 | 23 | /* | 
| 154 | 24 | void ldraw::makeUnofficial(ModelEditor& editor) | 
| 25 | { | |
| 26 | if (editor.model().size() >= 4) | |
| 27 | { | |
| 28 | const ldraw::Object* ldrawOrgLine = editor.model()[3]; | |
| 29 | if (isA<ldraw::MetaCommand>(ldrawOrgLine)) | |
| 30 | { | |
| 31 | const QString& body = ldrawOrgLine->getProperty<ldraw::Property::Text>(); | |
| 32 | if (body.startsWith("!LDRAW_ORG ") and not body.startsWith("!LDRAW_ORG Unofficial_")) | |
| 33 | { | |
| 34 | // Add Unofficial_ to part type | |
| 35 | QStringList tokens = body.split(" "); | |
| 36 | tokens[1] = "Unofficial_" + tokens[1]; | |
| 37 | // Remove the UPDATE tag if it's there | |
| 38 | if (tokens.size() >= 4 && tokens[2] == "UPDATE") | |
| 39 | { | |
| 40 | tokens.removeAt(3); | |
| 41 | tokens.removeAt(2); | |
| 42 | } | |
| 43 | editor.setObjectProperty<ldraw::Property::Text>(ldrawOrgLine->id, tokens.join(" ")); | |
| 44 | } | |
| 45 | } | |
| 46 | } | |
| 200 | 47 | } | 
| 48 | */ | |
| 49 | ||
| 50 | ModelElement inverted(const ModelElement& element) | |
| 51 | { | |
| 52 | return std::visit(overloaded{ | |
| 53 | [](Colored<SubfileReference> ref) -> ModelElement { | |
| 54 | ref.inverted = not ref.inverted; | |
| 55 | return ref; | |
| 56 | }, | |
| 
248
 
29986dfd1750
Fix invertnext not working with circular primitives
 
Teemu Piippo <teemu.s.piippo@gmail.com> 
parents: 
200 
diff
changeset
 | 
57 | [](Colored<CircularPrimitive> circ) -> ModelElement { | 
| 
 
29986dfd1750
Fix invertnext not working with circular primitives
 
Teemu Piippo <teemu.s.piippo@gmail.com> 
parents: 
200 
diff
changeset
 | 
58 | circ.inverted = not circ.inverted; | 
| 
 
29986dfd1750
Fix invertnext not working with circular primitives
 
Teemu Piippo <teemu.s.piippo@gmail.com> 
parents: 
200 
diff
changeset
 | 
59 | return circ; | 
| 
 
29986dfd1750
Fix invertnext not working with circular primitives
 
Teemu Piippo <teemu.s.piippo@gmail.com> 
parents: 
200 
diff
changeset
 | 
60 | }, | 
| 200 | 61 | [](Colored<Triangle> triangle) -> ModelElement { | 
| 62 | std::swap(triangle.p1, triangle.p2); | |
| 63 | return triangle; | |
| 64 | }, | |
| 65 | [](Colored<Quadrilateral> quad) -> ModelElement { | |
| 66 | std::swap(quad.p2, quad.p4); | |
| 67 | return quad; | |
| 68 | }, | |
| 69 | [](const ModelElement& x) { return x; } | |
| 70 | }, element); | |
| 71 | } |