summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9d95372)
raw | patch | inline | side by side (parent: 9d95372)
author | tgdwyer <tgdwyer@users.sourceforge.net> | |
Mon, 17 Jul 2006 02:25:52 +0000 (02:25 +0000) | ||
committer | tgdwyer <tgdwyer@users.sourceforge.net> | |
Mon, 17 Jul 2006 02:25:52 +0000 (02:25 +0000) |
src/graphlayout/graphlayout.cpp | patch | blob | history | |
src/libcola/cola.h | patch | blob | history | |
src/libcola/connected_components.cpp | patch | blob | history |
index 72c47d9bf718e688937deaa32b7025f756573c22..ec5c780c7707494761c732f626b47c4773a568a5 100644 (file)
rs.push_back(new Rectangle(ll[0],ur[0],ll[1],ur[1]));
}
- SimpleConstraints scy;
+ SimpleConstraints scx,scy;
double ideal_connector_length = prefs_get_double_attribute("tools.connector","length",100);
double directed_edge_height_modifier = 1.0;
gchar const *directed_str = NULL, *overlaps_str = NULL;
double eweights[E];
fill(eweights,eweights+E,1);
vector<Component*> cs;
- connectedComponents(rs,es,cs);
+ connectedComponents(rs,es,scx,scy,cs);
for(unsigned i=0;i<cs.size();i++) {
Component* c=cs[i];
printf("Component %d:\n",i);
cout << endl;
ConstrainedMajorizationLayout alg(c->rects,c->edges,eweights,ideal_connector_length);
alg.setupConstraints(NULL,NULL,avoid_overlaps,
- NULL,NULL,NULL,&scy,NULL,NULL);
+ NULL,NULL,&c->scx,&c->scy,NULL,NULL);
alg.run();
}
sp_item_move_rel(u, NR::translate(dest - curr));
}
}
+ for(unsigned i=0;i<scx.size();i++) {
+ delete scx[i];
+ }
+ for(unsigned i=0;i<scy.size();i++) {
+ delete scy[i];
+ }
+ for(unsigned i=0;i<rs.size();i++) {
+ delete rs[i];
+ }
}
// vim: set cindent
// vim: ts=4 sw=4 et tw=0 wm=0
diff --git a/src/libcola/cola.h b/src/libcola/cola.h
index e0cf1257c03ec4fb0722d7f7357bafa319e8195b..d3c1624dbc5c7b9f84fb6235e1b6c02e9d145572 100644 (file)
--- a/src/libcola/cola.h
+++ b/src/libcola/cola.h
vector<unsigned> node_ids;
vector<Rectangle*> rects;
vector<Edge> edges;
+ SimpleConstraints scx, scy;
+ ~Component() {
+ for(unsigned i=0;i<scx.size();i++) {
+ delete scx[i];
+ }
+ for(unsigned i=0;i<scy.size();i++) {
+ delete scy[i];
+ }
+ }
};
// for a graph of n nodes, return connected components
void connectedComponents(
- vector<Rectangle*> &rs,
- vector<Edge> &es,
+ const vector<Rectangle*> &rs,
+ const vector<Edge> &es,
+ const SimpleConstraints &scx,
+ const SimpleConstraints &scy,
vector<Component*> &components);
// defines references to three variables for which the goal function
index 8450e48743a951972f79796834b71f6ffa6b57cc..5eb9d07ab047dfad23b282383712886f00cab7fa 100644 (file)
// for a graph of n nodes, return connected components
void connectedComponents(
- vector<Rectangle*> &rs,
- vector<Edge> &es,
+ const vector<Rectangle*> &rs,
+ const vector<Edge> &es,
+ const SimpleConstraints &scx,
+ const SimpleConstraints &scy,
vector<Component*> &components) {
unsigned n=rs.size();
vector<Node> vs(n);
vs[i].r=rs[i];
remaining.insert(&vs[i]);
}
- for(vector<Edge>::iterator e=es.begin();e!=es.end();e++) {
+ for(vector<Edge>::const_iterator e=es.begin();e!=es.end();e++) {
vs[e->first].neighbours.push_back(&vs[e->second]);
vs[e->second].neighbours.push_back(&vs[e->first]);
}
dfs(v,remaining,component,cmap);
components.push_back(component);
}
- for(vector<Edge>::iterator e=es.begin();e!=es.end();e++) {
+ for(vector<Edge>::const_iterator e=es.begin();e!=es.end();e++) {
pair<Component*,unsigned> u=cmap[e->first],
v=cmap[e->second];
assert(u.first==v.first);
u.first->edges.push_back(make_pair(u.second,v.second));
}
+ for(SimpleConstraints::const_iterator ci=scx.begin();ci!=scx.end();ci++) {
+ SimpleConstraint *c=*ci;
+ pair<Component*,unsigned> u=cmap[c->left],
+ v=cmap[c->right];
+ assert(u.first==v.first);
+ u.first->scx.push_back(
+ new SimpleConstraint(u.second,v.second,c->gap));
+ }
+ for(SimpleConstraints::const_iterator ci=scy.begin();ci!=scy.end();ci++) {
+ SimpleConstraint *c=*ci;
+ pair<Component*,unsigned> u=cmap[c->left],
+ v=cmap[c->right];
+ assert(u.first==v.first);
+ u.first->scy.push_back(
+ new SimpleConstraint(u.second,v.second,c->gap));
+ }
}
}
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4