diff options
| author | Sebastian Wüst <sebi@timewaster.de> | 2013-10-20 15:32:08 +0000 |
|---|---|---|
| committer | Sebastian Wüst <sebi@timewaster.de> | 2013-10-20 15:32:08 +0000 |
| commit | 82908f949129e1fcbf62002799ee7b1b77986eed (patch) | |
| tree | c02098dd7720cdf424f2793ecd3ddac2ea86b969 /src/libcola | |
| parent | changed text (diff) | |
| parent | Fix build errors with clang 3.3 and c++11 enabled. (diff) | |
| download | inkscape-82908f949129e1fcbf62002799ee7b1b77986eed.tar.gz inkscape-82908f949129e1fcbf62002799ee7b1b77986eed.zip | |
merge from trunk
(bzr r12417.1.24)
Diffstat (limited to 'src/libcola')
| -rw-r--r-- | src/libcola/cola.cpp | 12 | ||||
| -rw-r--r-- | src/libcola/connected_components.cpp | 8 | ||||
| -rw-r--r-- | src/libcola/cycle_detector.cpp | 4 | ||||
| -rw-r--r-- | src/libcola/gradient_projection.cpp | 2 | ||||
| -rw-r--r-- | src/libcola/gradient_projection.h | 25 | ||||
| -rw-r--r-- | src/libcola/straightener.cpp | 20 | ||||
| -rw-r--r-- | src/libcola/straightener.h | 4 |
7 files changed, 47 insertions, 28 deletions
diff --git a/src/libcola/cola.cpp b/src/libcola/cola.cpp index 87fbf9f79..168ef5533 100644 --- a/src/libcola/cola.cpp +++ b/src/libcola/cola.cpp @@ -23,7 +23,8 @@ ConstrainedMajorizationLayout double* eweights, double idealLength, TestConvergence& done) - : constrainedLayout(false), + : avoidOverlaps(false), + constrainedLayout(false), n(rs.size()), lapSize(n), lap2(new double*[lapSize]), Q(lap2), Dij(new double*[lapSize]), @@ -116,18 +117,17 @@ void ConstrainedMajorizationLayout::majlayout( void ConstrainedMajorizationLayout::majlayout( double** Dij, GradientProjection* gp, double* coords, double* b) { - double L_ij,dist_ij,degree; /* compute the vector b */ /* multiply on-the-fly with distance-based laplacian */ for (unsigned i = 0; i < n; i++) { - degree = 0; if(i<lapSize) { + double degree = 0; for (unsigned j = 0; j < lapSize; j++) { if (j == i) continue; - dist_ij = euclidean_distance(i, j); + double dist_ij = euclidean_distance(i, j); if (dist_ij > 1e-30 && Dij[i][j] > 1e-30) { /* skip zero distances */ /* calculate L_ij := w_{ij}*d_{ij}/dist_{ij} */ - L_ij = 1.0 / (dist_ij * Dij[i][j]); + double L_ij = 1.0 / (dist_ij * Dij[i][j]); degree -= L_ij; b[i] += L_ij * coords[j]; } @@ -271,7 +271,7 @@ void ConstrainedMajorizationLayout::straighten(std::vector<straightener::Edge*>& double b[n],*coords=dim==HORIZONTAL?X:Y,dist_ub,dist_bv; std::fill(b,b+n,0); for(LinearConstraints::iterator i=linearConstraints.begin(); - i!= linearConstraints.end();i++) { + i!= linearConstraints.end();++i) { LinearConstraint* c=*i; if(straightenToProjection) { Q[c->u][c->u]+=c->w*c->duu; diff --git a/src/libcola/connected_components.cpp b/src/libcola/connected_components.cpp index 1afec55b4..823f7cf6e 100644 --- a/src/libcola/connected_components.cpp +++ b/src/libcola/connected_components.cpp @@ -77,7 +77,7 @@ namespace cola { } vector<Edge>::const_iterator ei; SimpleConstraints::const_iterator ci; - for(ei=es.begin();ei!=es.end();ei++) { + for(ei=es.begin();ei!=es.end();++ei) { vs[ei->first].neighbours.push_back(&vs[ei->second]); vs[ei->second].neighbours.push_back(&vs[ei->first]); } @@ -88,13 +88,13 @@ namespace cola { dfs(v,remaining,component,cmap); components.push_back(component); } - for(ei=es.begin();ei!=es.end();ei++) { + for(ei=es.begin();ei!=es.end();++ei) { pair<Component*,unsigned> u=cmap[ei->first], v=cmap[ei->second]; assert(u.first==v.first); u.first->edges.push_back(make_pair(u.second,v.second)); } - for(ci=scx.begin();ci!=scx.end();ci++) { + for(ci=scx.begin();ci!=scx.end();++ci) { SimpleConstraint *c=*ci; pair<Component*,unsigned> u=cmap[c->left], v=cmap[c->right]; @@ -102,7 +102,7 @@ namespace cola { u.first->scx.push_back( new SimpleConstraint(u.second,v.second,c->gap)); } - for(ci=scy.begin();ci!=scy.end();ci++) { + for(ci=scy.begin();ci!=scy.end();++ci) { SimpleConstraint *c=*ci; pair<Component*,unsigned> u=cmap[c->left], v=cmap[c->right]; diff --git a/src/libcola/cycle_detector.cpp b/src/libcola/cycle_detector.cpp index 89a2ccaae..11e24a0ba 100644 --- a/src/libcola/cycle_detector.cpp +++ b/src/libcola/cycle_detector.cpp @@ -53,7 +53,7 @@ void CycleDetector::make_matrix() { assert(traverse.empty()); // from the edges passed, fill the adjacency matrix - for (ei = edges->begin(); ei != edges->end(); ei++) { + for (ei = edges->begin(); ei != edges->end(); ++ei) { anEdge = *ei; // the matrix is indexed by the first vertex of the edge // the second vertex of the edge is pushed onto another @@ -241,7 +241,7 @@ bool CycleDetector::find_node(std::vector<Node *> *& list, unsigned k) { } pair< bool, vector<unsigned>::iterator > CycleDetector::find_node(std::vector<unsigned>& list, unsigned k) { - for (vector<unsigned>::iterator ti = traverse.begin(); ti != traverse.end(); ti++) { + for (vector<unsigned>::iterator ti = traverse.begin(); ti != traverse.end(); ++ti) { if (*ti == k) { return pair< bool, vector<unsigned>::iterator >(true, ti); } } diff --git a/src/libcola/gradient_projection.cpp b/src/libcola/gradient_projection.cpp index 47109a4b0..3e41aceac 100644 --- a/src/libcola/gradient_projection.cpp +++ b/src/libcola/gradient_projection.cpp @@ -222,7 +222,7 @@ void GradientProjection::destroyVPSC(IncSolver *vpsc) { delete vpsc; delete [] cs; delete [] vs; - for(vector<Constraint*>::iterator i=lcs.begin();i!=lcs.end();i++) { + for(vector<Constraint*>::iterator i=lcs.begin();i!=lcs.end();++i) { delete *i; } lcs.clear(); diff --git a/src/libcola/gradient_projection.h b/src/libcola/gradient_projection.h index 66fc37aba..980fa6064 100644 --- a/src/libcola/gradient_projection.h +++ b/src/libcola/gradient_projection.h @@ -25,7 +25,12 @@ typedef std::vector<SimpleConstraint*> SimpleConstraints; class AlignmentConstraint { friend class GradientProjection; public: - AlignmentConstraint(double pos) : position(pos), variable(NULL) {} + AlignmentConstraint(double pos) : + offsets(), + guide(NULL), + position(pos), + variable(NULL) + {} void updatePosition() { position = variable->position(); } @@ -74,7 +79,21 @@ typedef std::vector<std::pair<unsigned, double> > CList; */ class DummyVarPair { public: - DummyVarPair(double desiredDist) : dist(desiredDist), lap2(1.0/(desiredDist*desiredDist)) { } + DummyVarPair(double desiredDist) : + leftof(), + rightof(), + place_l(0), + place_r(0), + dist(desiredDist), + b(0), + left(NULL), + right(NULL), + lap2(1.0/(desiredDist*desiredDist)), + g(0), + old_place_l(0), + old_place_r(0) + {} + CList leftof; // variables to which left dummy var must be to the left of CList rightof; // variables to which right dummy var must be to the right of double place_l; @@ -225,7 +244,7 @@ public: delete [] g; delete [] d; delete [] old_place; - for(Constraints::iterator i(gcs.begin()); i!=gcs.end(); i++) { + for(Constraints::iterator i(gcs.begin()); i!=gcs.end(); ++i) { delete *i; } gcs.clear(); diff --git a/src/libcola/straightener.cpp b/src/libcola/straightener.cpp index 650f41aac..9e1ab1809 100644 --- a/src/libcola/straightener.cpp +++ b/src/libcola/straightener.cpp @@ -82,7 +82,7 @@ namespace straightener { double bx=route->xs[i]; double by=route->ys[i]; double t=0; - list<unsigned>::iterator copyit=j++; + list<unsigned>::iterator copyit=++j; //printf(" px=%f, py=%f, ax=%f, ay=%f, bx=%f, by=%f\n",px,py,ax,ay,bx,by); if(pointOnLine(px,py,ax,ay,bx,by,t)) { //printf(" got node %d\n",*copyit); @@ -90,7 +90,7 @@ namespace straightener { ds.erase(copyit); } } - for(set<pair<double,unsigned> >::iterator j=pntsOnLineSegment.begin();j!=pntsOnLineSegment.end();j++) { + for(set<pair<double,unsigned> >::iterator j=pntsOnLineSegment.begin();j!=pntsOnLineSegment.end();++j) { path.push_back(j->second); } //printf("\n"); @@ -144,11 +144,11 @@ namespace straightener { e->ypos(conjpos,bs); } //cerr << "edge(intersections="<<bs.size()<<":("<<e->startNode<<","<<e->endNode<<"))"<<endl; - for(vector<double>::iterator it=bs.begin();it!=bs.end();it++) { + for(vector<double>::iterator it=bs.begin();it!=bs.end();++it) { sortedEdges.insert(make_pair(*it,e)); } } - for(set<PosEdgePair>::iterator i=sortedEdges.begin();i!=sortedEdges.end();i++) { + for(set<PosEdgePair>::iterator i=sortedEdges.begin();i!=sortedEdges.end();++i) { double pos=i->first; if(pos < minpos) continue; if(pos > v->scanpos) break; @@ -169,7 +169,7 @@ namespace straightener { if(r!=NULL) { maxpos=r->scanpos; } - for(set<PosEdgePair>::iterator i=sortedEdges.begin();i!=sortedEdges.end();i++) { + for(set<PosEdgePair>::iterator i=sortedEdges.begin();i!=sortedEdges.end();++i) { if(i->first < v->scanpos) continue; if(i->first > maxpos) break; double pos=i->first; @@ -262,7 +262,7 @@ namespace straightener { // Case A: create constraints between adjacent edges skipping edges joined // to l,v or r. Node* lastNode=NULL; - for(vector<Node*>::iterator i=L.begin();i!=L.end();i++) { + for(vector<Node*>::iterator i=L.begin();i!=L.end();++i) { if((*i)->dummy) { // node is on an edge Edge *edge=(*i)->edge; @@ -284,7 +284,7 @@ namespace straightener { // their own end, also in the scan line vector<Node*> skipList; lastNode=NULL; - for(vector<Node*>::iterator i=L.begin();i!=L.end();i++) { + for(vector<Node*>::iterator i=L.begin();i!=L.end();++i) { if((*i)->dummy) { // node is on an edge if(lastNode!=NULL) { @@ -292,7 +292,7 @@ namespace straightener { skipList.push_back(*i); } else { for(vector<Node*>::iterator j=skipList.begin(); - j!=skipList.end();j++) { + j!=skipList.end();++j) { //printf(" Rule B: Constraint: v%d +g <= v%d\n",(*j)->id,(*i)->id); cs.push_back(createConstraint(*j,*i,dim)); } @@ -309,7 +309,7 @@ namespace straightener { skipList.clear(); // Case C: reverse of B lastNode=NULL; - for(vector<Node*>::reverse_iterator i=L.rbegin();i!=L.rend();i++) { + for(vector<Node*>::reverse_iterator i=L.rbegin();i!=L.rend();++i) { if((*i)->dummy) { // node is on an edge if(lastNode!=NULL) { @@ -317,7 +317,7 @@ namespace straightener { skipList.push_back(*i); } else { for(vector<Node*>::iterator j=skipList.begin(); - j!=skipList.end();j++) { + j!=skipList.end();++j) { //printf(" Rule C: Constraint: v%d +g <= v%d\n",(*i)->id,(*j)->id); cs.push_back(createConstraint(*i,*j,dim)); } diff --git a/src/libcola/straightener.h b/src/libcola/straightener.h index b1ce665f4..927780140 100644 --- a/src/libcola/straightener.h +++ b/src/libcola/straightener.h @@ -38,7 +38,7 @@ namespace straightener { std::vector<unsigned> dummyNodes; std::vector<unsigned> path; Edge(unsigned id, unsigned start, unsigned end, Route* route) - : id(id), startNode(start), endNode(end), route(route) + : id(id), openInd(0), startNode(start), endNode(end), route(route) { route->boundingBox(xmin,ymin,xmax,ymax); } @@ -98,7 +98,7 @@ namespace straightener { double weight; bool open; Node(unsigned id, vpsc::Rectangle* r) : - id(id),x(r->getCentreX()),y(r->getCentreY()), width(r->width()), height(r->height()), + id(id),x(r->getCentreX()),y(r->getCentreY()), scanpos(0), width(r->width()), height(r->height()), xmin(x-width/2),xmax(x+width/2), ymin(y-height/2),ymax(y+height/2), edge(NULL),dummy(false),weight(-0.1),open(false) { } |
