summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/adaptagrams/libcola/tests/overlappingClusters04.cpp
blob: 45a06ff124ea6ed52a367fc55e5d427c9844b544 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// From Aidan Delaney: a_b_ab_abc.json.svg 
// Regression test for SEGFAULT caused by specifing an invalid node index 7
// in cluster description.
#include <vector>
#include <utility>
#include "libcola/cola.h"
using namespace cola;
int main(void) {
    CompoundConstraints ccs;
    std::vector<Edge> es;
    EdgeLengths eLengths;
    double defaultEdgeLength=10;
    std::vector<vpsc::Rectangle*> rs;
    vpsc::Rectangle *rect = nullptr;

    rect = new vpsc::Rectangle(0, 5, 0, 5);
    rs.push_back(rect);

    rect = new vpsc::Rectangle(-2, 3, -2, 3);
    rs.push_back(rect);

    rect = new vpsc::Rectangle(-1, 4, -1, 4);
    rs.push_back(rect);

    rect = new vpsc::Rectangle(1, 6, 1, 6);
    rs.push_back(rect);

    rect = new vpsc::Rectangle(1, 6, 1, 6);
    rs.push_back(rect);


    ConstrainedFDLayout alg(rs, es, defaultEdgeLength, eLengths);
    alg.setAvoidNodeOverlaps(true);

    RootCluster *cluster33771480 = new RootCluster();
    RectangularCluster *cluster33771952 = new RectangularCluster();
    cluster33771952->setPadding(Box(2));
    cluster33771952->addChildNode(1);
    cluster33771952->addChildNode(3);
    cluster33771952->addChildNode(7);
    cluster33771480->addChildCluster(cluster33771952);
    
    RectangularCluster *cluster33772496 = new RectangularCluster();
    cluster33772496->setPadding(Box(2));
    cluster33772496->addChildNode(2);
    cluster33772496->addChildNode(3);
    cluster33772496->addChildNode(7);
    cluster33771480->addChildCluster(cluster33772496);
    
    RectangularCluster *cluster33773040 = new RectangularCluster();
    cluster33773040->setPadding(Box(2));
    cluster33773040->addChildNode(7);
    cluster33771480->addChildCluster(cluster33773040);
    
    alg.setClusterHierarchy(cluster33771480);
    
    alg.setConstraints(ccs);
    alg.makeFeasible();
    //alg.outputInstanceToSVG("overlappingCLusters04");
    alg.freeAssociatedObjects();
};