Revize 6d678302
Přidáno uživatelem Patrik Harag před téměř 6 roky(ů)
sources/imiger-core/src/main/webapp/js/services/initialElimination.js | ||
---|---|---|
21 | 21 |
visibleComponentsCount - this._maxVisibleComponents); |
22 | 22 |
|
23 | 23 |
if (numberOfVerticesToGroup > 0) { |
24 |
// pack the first n vertices into a group |
|
25 |
let group = Group.create(); |
|
26 |
visibleVertices.slice(0, numberOfVerticesToGroup).forEach(vertex => { |
|
27 |
group.addVertex(vertex); |
|
28 |
}); |
|
29 |
app.nodeList.push(group); |
|
30 |
app.groupList.push(group); |
|
31 |
app.viewportComponent.addNode(group); |
|
24 |
if (!this._groupByTypes(visibleVertices)) { |
|
25 |
this._simpleGrouping(visibleVertices, numberOfVerticesToGroup); |
|
26 |
} |
|
32 | 27 |
} |
33 | 28 |
} |
34 | 29 |
} |
30 |
|
|
31 |
_groupByTypes(visibleVertices) { |
|
32 |
let groups = new Map(); |
|
33 |
visibleVertices.forEach(vertex => { |
|
34 |
let entry = groups.get(vertex.archetype); |
|
35 |
if (entry !== undefined) { |
|
36 |
entry.push(vertex); |
|
37 |
} else { |
|
38 |
groups.set(vertex.archetype, [vertex]); |
|
39 |
} |
|
40 |
}); |
|
41 |
|
|
42 |
if (groups.size > 2) { |
|
43 |
// group by types |
|
44 |
groups.forEach((v, k) => { |
|
45 |
let archetype = app.archetype.vertex[k]; |
|
46 |
let groupName = archetype.name; |
|
47 |
this._createGroup(v, groupName); |
|
48 |
}); |
|
49 |
return true; |
|
50 |
} else { |
|
51 |
// not enough vertex types (archetypes) |
|
52 |
return false; |
|
53 |
} |
|
54 |
} |
|
55 |
|
|
56 |
_simpleGrouping(visibleVertices, numberOfVerticesToGroup) { |
|
57 |
// just pack the first n vertices into a group |
|
58 |
this._createGroup(visibleVertices.slice(0, numberOfVerticesToGroup), null); |
|
59 |
} |
|
60 |
|
|
61 |
_createGroup(vertices, name) { |
|
62 |
let group = Group.create(); |
|
63 |
vertices.forEach(vertex => { |
|
64 |
group.addVertex(vertex); |
|
65 |
}); |
|
66 |
if (name !== null) { |
|
67 |
group.name = name; |
|
68 |
} |
|
69 |
|
|
70 |
app.nodeList.push(group); |
|
71 |
app.groupList.push(group); |
|
72 |
app.viewportComponent.addNode(group); |
|
73 |
} |
|
35 | 74 |
} |
Také k dispozici: Unified diff
Group by archetype if possible (refs #7468)