Tue, 27 Jul 2021 13:23:34 +0300
Add vertex map
117 | 1 | #include "vertexmap.h" |
2 | #include "linetypes/polygonobject.h" | |
3 | ||
4 | VertexMap::VertexMap(const Model *model) : | |
5 | model{model} | |
6 | { | |
7 | connect( | |
8 | model, | |
9 | &Model::dataChanged, | |
10 | this, | |
11 | &VertexMap::build | |
12 | ); | |
13 | connect( | |
14 | model, | |
15 | &Model::rowsInserted, | |
16 | this, | |
17 | &VertexMap::build | |
18 | ); | |
19 | connect( | |
20 | model, | |
21 | &Model::rowsRemoved, | |
22 | this, | |
23 | &VertexMap::build | |
24 | ); | |
25 | this->build(); | |
26 | } | |
27 | ||
28 | void VertexMap::build() | |
29 | { | |
30 | this->map.clear(); | |
31 | this->model->apply<ldraw::Object>([&](const ldraw::Object* object) | |
32 | { | |
33 | for (int i = 0; i < object->numPoints(); i += 1) | |
34 | { | |
35 | const glm::vec3& point = object->getPoint(i); | |
36 | this->map[qHash(point)].insert(object->id); | |
37 | } | |
38 | }); | |
39 | } |