diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2013-10-18 16:44:48 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2013-10-18 16:44:48 +0000 |
| commit | c6f1fa0dfb5beaac7b0781213711028b511c5f6e (patch) | |
| tree | 3712e7c481f312bde6cb19d9b760ad0ba6f48f2a /src/libcola | |
| parent | Update to trunk (diff) | |
| parent | fix memory reallocation (diff) | |
| download | inkscape-c6f1fa0dfb5beaac7b0781213711028b511c5f6e.tar.gz inkscape-c6f1fa0dfb5beaac7b0781213711028b511c5f6e.zip | |
Update to trunk
(bzr r11950.1.185)
Diffstat (limited to 'src/libcola')
| -rw-r--r-- | src/libcola/cola.cpp | 12 | ||||
| -rw-r--r-- | src/libcola/gradient_projection.h | 23 | ||||
| -rw-r--r-- | src/libcola/straightener.cpp | 2 | ||||
| -rw-r--r-- | src/libcola/straightener.h | 4 |
4 files changed, 30 insertions, 11 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/gradient_projection.h b/src/libcola/gradient_projection.h index 8cf45586c..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; diff --git a/src/libcola/straightener.cpp b/src/libcola/straightener.cpp index fab30d48d..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); 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) { } |
