diff options
| author | Tim Dwyer <tgdwyer@gmail.com> | 2006-05-10 07:13:45 +0000 |
|---|---|---|
| committer | tgdwyer <tgdwyer@users.sourceforge.net> | 2006-05-10 07:13:45 +0000 |
| commit | 0623102c16ecbf5ade1a7ef195659826a6f92548 (patch) | |
| tree | c5d847af5fbb9733a406251c3575bc912da0ab17 /src/removeoverlap/generate-constraints.cpp | |
| parent | patch 1484602 by Niko Kiirala (diff) | |
| download | inkscape-0623102c16ecbf5ade1a7ef195659826a6f92548.tar.gz inkscape-0623102c16ecbf5ade1a7ef195659826a6f92548.zip | |
Apparently a problem was reported with one of the test cases.
I can't reproduce the problem, however solve_VPSC code in inkscape
was getting quite out of date with that in www.sf.net/projects/adaptagrams.
I've updated the code, which may fix the problem, or at least if it's
reported again then I'll know it's still an issue.
(bzr r803)
Diffstat (limited to 'src/removeoverlap/generate-constraints.cpp')
| -rw-r--r-- | src/removeoverlap/generate-constraints.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/removeoverlap/generate-constraints.cpp b/src/removeoverlap/generate-constraints.cpp index a8bfe28e7..312ad960b 100644 --- a/src/removeoverlap/generate-constraints.cpp +++ b/src/removeoverlap/generate-constraints.cpp @@ -1,12 +1,13 @@ /** - * \brief Remove overlaps function + * \brief Functions to automatically generate constraints for the + * rectangular node overlap removal problem. * * Authors: * Tim Dwyer <tgdwyer@gmail.com> * * Copyright (C) 2005 Authors * - * Released under GNU GPL. Read the file 'COPYING' for more information. + * Released under GNU LGPL. Read the file 'COPYING' for more information. */ #include <set> @@ -58,11 +59,11 @@ struct Node { void setNeighbours(NodeSet *left, NodeSet *right) { leftNeighbours=left; rightNeighbours=right; - for(NodeSet::iterator i=left->begin();i!=left->end();i++) { + for(NodeSet::iterator i=left->begin();i!=left->end();++i) { Node *v=*(i); v->addRightNeighbour(this); } - for(NodeSet::iterator i=right->begin();i!=right->end();i++) { + for(NodeSet::iterator i=right->begin();i!=right->end();++i) { Node *v=*(i); v->addLeftNeighbour(this); } @@ -116,7 +117,7 @@ NodeSet* getLeftNeighbours(NodeSet &scanline,Node *v) { NodeSet* getRightNeighbours(NodeSet &scanline,Node *v) { NodeSet *rightv = new NodeSet; NodeSet::iterator i=scanline.find(v); - for(i++;i!=scanline.end(); i++) { + for(++i;i!=scanline.end(); ++i) { Node *u=*(i); if(u->r->overlapX(v->r)<=0) { rightv->insert(u); @@ -159,17 +160,15 @@ int compare_events(const void *a, const void *b) { } /** - * Prepares variables and constraints in order to apply VPSC horizontally. + * Prepares constraints in order to apply VPSC horizontally. Assumes variables have already been created. * useNeighbourLists determines whether or not a heuristic is used to deciding whether to resolve * all overlap in the x pass, or leave some overlaps for the y pass. */ -int generateXConstraints(Rectangle *rs[], double weights[], const int n, Variable **&vars, Constraint **&cs, bool useNeighbourLists) { +int generateXConstraints(const int n, Rectangle** rs, Variable** vars, Constraint** &cs, const bool useNeighbourLists) { events=new Event*[2*n]; int i,m,ctr=0; - vector<Constraint*> constraints; - vars=new Variable*[n]; for(i=0;i<n;i++) { - vars[i]=new Variable(i,rs[i]->getCentreX(),weights[i]); + vars[i]->desiredPosition=rs[i]->getCentreX(); Node *v = new Node(vars[i],rs[i],rs[i]->getCentreX()); events[ctr++]=new Event(Open,v,rs[i]->getMinY()); events[ctr++]=new Event(Close,v,rs[i]->getMaxY()); @@ -177,6 +176,7 @@ int generateXConstraints(Rectangle *rs[], double weights[], const int n, Variabl qsort((Event*)events, (size_t)2*n, sizeof(Event*), compare_events ); NodeSet scanline; + vector<Constraint*> constraints; for(i=0;i<2*n;i++) { Event *e=events[i]; Node *v=e->v; @@ -247,21 +247,20 @@ int generateXConstraints(Rectangle *rs[], double weights[], const int n, Variabl } /** - * Prepares variables and constraints in order to apply VPSC vertically to remove ALL overlap. + * Prepares constraints in order to apply VPSC vertically to remove ALL overlap. */ -int generateYConstraints(Rectangle *rs[], double weights[], const int n, Variable **&vars, Constraint **&cs) { +int generateYConstraints(const int n, Rectangle** rs, Variable** vars, Constraint** &cs) { events=new Event*[2*n]; int ctr=0,i,m; - vector<Constraint*> constraints; - vars=new Variable*[n]; for(i=0;i<n;i++) { - vars[i]=new Variable(i,rs[i]->getCentreY(),weights[i]); + vars[i]->desiredPosition=rs[i]->getCentreY(); Node *v = new Node(vars[i],rs[i],rs[i]->getCentreY()); events[ctr++]=new Event(Open,v,rs[i]->getMinX()); events[ctr++]=new Event(Close,v,rs[i]->getMaxX()); } qsort((Event*)events, (size_t)2*n, sizeof(Event*), compare_events ); NodeSet scanline; + vector<Constraint*> constraints; for(i=0;i<2*n;i++) { Event *e=events[i]; Node *v=e->v; |
