diff options
| author | Tim Dwyer <tgdwyer@gmail.com> | 2006-07-17 06:03:13 +0000 |
|---|---|---|
| committer | tgdwyer <tgdwyer@users.sourceforge.net> | 2006-07-17 06:03:13 +0000 |
| commit | be33b17955cd4e6fda3050fa3056a6e56ce314bc (patch) | |
| tree | 7583166c065080d86f753bc568486238e551d9d6 | |
| parent | minor performance improvement (diff) | |
| download | inkscape-be33b17955cd4e6fda3050fa3056a6e56ce314bc.tar.gz inkscape-be33b17955cd4e6fda3050fa3056a6e56ce314bc.zip | |
cleanup, remove warnings
(bzr r1429)
| -rw-r--r-- | src/libcola/cola.cpp | 53 | ||||
| -rw-r--r-- | src/libcola/cola.h | 53 | ||||
| -rw-r--r-- | src/libvpsc/solve_VPSC.cpp | 2 |
3 files changed, 57 insertions, 51 deletions
diff --git a/src/libcola/cola.cpp b/src/libcola/cola.cpp index 3499d729a..74cab50da 100644 --- a/src/libcola/cola.cpp +++ b/src/libcola/cola.cpp @@ -1,6 +1,7 @@ #include "cola.h" #include "conjugate_gradient.h" #include "straightener.h" +#include "shortest_paths.h" namespace cola { @@ -12,6 +13,58 @@ inline double dummy_var_euclidean_dist(GradientProjection* gpx, GradientProjecti dy = gpy->dummy_vars[i]->place_r - gpy->dummy_vars[i]->place_l; return sqrt(dx*dx + dy*dy); } +ConstrainedMajorizationLayout +::ConstrainedMajorizationLayout( + vector<Rectangle*>& rs, + vector<Edge>& es, + double* eweights, + double idealLength, + TestConvergence& done) + : constrainedLayout(false), + n(rs.size()), + lapSize(n), lap2(new double*[lapSize]), + Q(lap2), Dij(new double*[lapSize]), + tol(0.0001), + done(done), + X(new double[n]), + Y(new double[n]), + clusters(NULL), + linearConstraints(NULL), + gpX(NULL), + gpY(NULL), + straightenEdges(NULL) +{ + assert(rs.size()==n); + boundingBoxes = new Rectangle*[rs.size()]; + copy(rs.begin(),rs.end(),boundingBoxes); + + done.reset(); + + double** D=new double*[n]; + for(unsigned i=0;i<n;i++) { + D[i]=new double[n]; + } + shortest_paths::johnsons(n,D,es,eweights); + edge_length = idealLength; + // Lij_{i!=j}=1/(Dij^2) + // + for(unsigned i = 0; i<n; i++) { + X[i]=rs[i]->getCentreX(); + Y[i]=rs[i]->getCentreY(); + double degree = 0; + lap2[i]=new double[n]; + Dij[i]=new double[n]; + for(unsigned j=0;j<n;j++) { + double w = edge_length * D[i][j]; + Dij[i][j]=w; + if(i==j) continue; + degree+=lap2[i][j]=w>1e-30?1.f/(w*w):0; + } + lap2[i][i]=-degree; + delete [] D[i]; + } + delete [] D; +} void ConstrainedMajorizationLayout diff --git a/src/libcola/cola.h b/src/libcola/cola.h index c3cdb03c0..b56d2327e 100644 --- a/src/libcola/cola.h +++ b/src/libcola/cola.h @@ -8,18 +8,16 @@ #include <cmath> #include <iostream> #include <cassert> -#include "shortest_paths.h" #include "gradient_projection.h" -#include <libvpsc/generate-constraints.h> #include "straightener.h" typedef vector<unsigned> Cluster; typedef vector<Cluster*> Clusters; - -using vpsc::Rectangle; +namespace vpsc { class Rectangle; } namespace cola { + using vpsc::Rectangle; typedef pair<unsigned, unsigned> Edge; // a graph component with a list of node_ids giving indices for some larger list of nodes @@ -153,52 +151,7 @@ namespace cola { vector<Edge>& es, double* eweights, double idealLength, - TestConvergence& done=defaultTest) - : constrainedLayout(false), - n(rs.size()), - lapSize(n), lap2(new double*[lapSize]), - Q(lap2), Dij(new double*[lapSize]), - tol(0.0001), - done(done), - X(new double[n]), - Y(new double[n]), - clusters(NULL), - linearConstraints(NULL), - gpX(NULL), - gpY(NULL), - straightenEdges(NULL) - { - assert(rs.size()==n); - boundingBoxes = new Rectangle*[rs.size()]; - copy(rs.begin(),rs.end(),boundingBoxes); - - done.reset(); - - double** D=new double*[n]; - for(unsigned i=0;i<n;i++) { - D[i]=new double[n]; - } - shortest_paths::johnsons(n,D,es,eweights); - edge_length = idealLength; - // Lij_{i!=j}=1/(Dij^2) - // - for(unsigned i = 0; i<n; i++) { - X[i]=rs[i]->getCentreX(); - Y[i]=rs[i]->getCentreY(); - double degree = 0; - lap2[i]=new double[n]; - Dij[i]=new double[n]; - for(unsigned j=0;j<n;j++) { - double w = edge_length * D[i][j]; - Dij[i][j]=w; - if(i==j) continue; - degree+=lap2[i][j]=w>1e-30?1.f/(w*w):0; - } - lap2[i][i]=-degree; - delete [] D[i]; - } - delete [] D; - } + TestConvergence& done=defaultTest); void moveBoundingBoxes() { for(unsigned i=0;i<lapSize;i++) { diff --git a/src/libvpsc/solve_VPSC.cpp b/src/libvpsc/solve_VPSC.cpp index ff0ff96bf..ec2c48d46 100644 --- a/src/libvpsc/solve_VPSC.cpp +++ b/src/libvpsc/solve_VPSC.cpp @@ -96,7 +96,7 @@ void Solver::refine() { // Solve shouldn't loop indefinately // ... but just to make sure we limit the number of iterations unsigned maxtries=100; - while(!solved&&maxtries>=0) { + while(!solved&&maxtries>0) { solved=true; maxtries--; for(set<Block*>::const_iterator i=bs->begin();i!=bs->end();++i) { |
