summaryrefslogtreecommitdiffstats
path: root/src/libcola/connected_components.cpp
diff options
context:
space:
mode:
authorTim Dwyer <tgdwyer@gmail.com>2006-07-17 02:25:52 +0000
committertgdwyer <tgdwyer@users.sourceforge.net>2006-07-17 02:25:52 +0000
commit6de3190ff1b9655ebce6f915b963ab1a10ad2cfe (patch)
treeea20bdd0d815e78ee25c51931a9c8dc519f14bfc /src/libcola/connected_components.cpp
parentmore string cleanup (diff)
downloadinkscape-6de3190ff1b9655ebce6f915b963ab1a10ad2cfe.tar.gz
inkscape-6de3190ff1b9655ebce6f915b963ab1a10ad2cfe.zip
Constraints are now properly divided up between the connected components
(bzr r1424)
Diffstat (limited to 'src/libcola/connected_components.cpp')
-rw-r--r--src/libcola/connected_components.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/libcola/connected_components.cpp b/src/libcola/connected_components.cpp
index 8450e4874..5eb9d07ab 100644
--- a/src/libcola/connected_components.cpp
+++ b/src/libcola/connected_components.cpp
@@ -33,8 +33,10 @@ namespace cola {
// 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);
@@ -45,7 +47,7 @@ namespace cola {
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]);
}
@@ -56,12 +58,28 @@ namespace cola {
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