src/ldrawalgorithm.h

Wed, 15 Jun 2022 13:03:33 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Wed, 15 Jun 2022 13:03:33 +0300
changeset 229
38d86002d548
parent 206
654661eab7f3
child 232
8efa3a33172e
permissions
-rw-r--r--

Add About Qt menu entry

154
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 #pragma once
206
654661eab7f3 More refactor, merged main.h, basics.h and utility.h into one header file basics.h and removed plenty of unused code
Teemu Piippo <teemu@hecknology.net>
parents: 200
diff changeset
2 #include "basics.h"
200
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 196
diff changeset
3 #include "model.h"
154
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
4
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
5 namespace ldraw
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
6 {
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
7 /// Determines how quadrilaterals are split into triangles
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
8 enum class Diagonal
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
9 {
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
10 Diagonal_13,
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
11 Diagonal_24
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
12 };
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
13
200
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 196
diff changeset
14 std::pair<Triangle, Triangle> splitTriangles(
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 196
diff changeset
15 const Quadrilateral& q,
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 196
diff changeset
16 ldraw::Diagonal diagonal);
154
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
17
200
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 196
diff changeset
18 /*
154
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
19 void makeUnofficial(ModelEditor &editor);
200
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 196
diff changeset
20 */
186
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
21
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
22 template<typename Fn>
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
23 void circle(int segments, int divisions, Fn&& fn)
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
24 {
196
6bcb284679d4 delete unneeded things
Teemu Piippo <teemu@hecknology.net>
parents: 186
diff changeset
25 float factor = 2.0f * pi<> / divisions;
186
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
26 for (int i = 0; i < segments; i += 1)
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
27 {
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
28 fn(
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
29 glm::vec2{std::sin((i - 1) * factor), std::cos((i - 1) * factor)},
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
30 glm::vec2{std::sin(i * factor), std::cos(i * factor)},
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
31 glm::vec2{std::sin((i + 1) * factor), std::cos((i - 1) * factor)}
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
32 );
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
33 }
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
34 }
154
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
35 }
200
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 196
diff changeset
36
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 196
diff changeset
37 ModelElement inverted(const ModelElement &element);

mercurial