Code

make loop var unsigned etc, remove compiler warnings
authorrwst <rwst@users.sourceforge.net>
Tue, 23 May 2006 07:41:37 +0000 (07:41 +0000)
committerrwst <rwst@users.sourceforge.net>
Tue, 23 May 2006 07:41:37 +0000 (07:41 +0000)
src/removeoverlap/remove_rectangle_overlap.cpp
src/removeoverlap/solve_VPSC.cpp

index 6f6ace03ae0e88af16cc157dd91eb95071aa718c..9fbef647b9c0d6fdbc73af453df284620f0a3222 100755 (executable)
@@ -40,19 +40,18 @@ double Rectangle::yBorder=0;
  *    too much in the first pass.
  */
 void removeRectangleOverlap(unsigned n, Rectangle *rs[], double xBorder, double yBorder) {
-       assert(0 <= n);
        try {
        // The extra gap avoids numerical imprecision problems
        Rectangle::setXBorder(xBorder+EXTRA_GAP);
        Rectangle::setYBorder(yBorder+EXTRA_GAP);
        Variable **vs=new Variable*[n];
-       for(int i=0;i<n;i++) {
+       for(unsigned int i=0;i<n;i++) {
                vs[i]=new Variable(i,0,1);
        }
        Constraint **cs;
        double *oldX = new double[n];
        int m=generateXConstraints(n,rs,vs,cs,true);
-       for(int i=0;i<n;i++) {
+       for(unsigned int i=0;i<n;i++) {
                oldX[i]=vs[i]->desiredPosition;
        }
        VPSC vpsc_x(n,vs,m,cs);
@@ -62,7 +61,7 @@ void removeRectangleOverlap(unsigned n, Rectangle *rs[], double xBorder, double
        f.close();
 #endif
        vpsc_x.solve();
-       for(int i=0;i<n;i++) {
+       for(unsigned int i=0;i<n;i++) {
                rs[i]->moveCentreX(vs[i]->position());
        }
        for(int i = 0; i < m; ++i) {
@@ -80,7 +79,7 @@ void removeRectangleOverlap(unsigned n, Rectangle *rs[], double xBorder, double
        f.close();
 #endif
        vpsc_y.solve();
-       for(int i=0;i<n;i++) {
+       for(unsigned int i=0;i<n;i++) {
                rs[i]->moveCentreY(vs[i]->position());
                rs[i]->moveCentreX(oldX[i]);
        }
@@ -102,14 +101,14 @@ void removeRectangleOverlap(unsigned n, Rectangle *rs[], double xBorder, double
                delete cs[i];
        }
        delete [] cs;
-       for(int i=0;i<n;i++) {
+       for(unsigned int i=0;i<n;i++) {
                rs[i]->moveCentreX(vs[i]->position());
                delete vs[i];
        }
        delete [] vs;
        } catch (char const *str) {
                std::cerr<<str<<std::endl;
-               for(int i=0;i<n;i++) {
+               for(unsigned int i=0;i<n;i++) {
                        std::cerr << *rs[i]<<std::endl;
                }
        }
index 21865c518ffdffc97a4ca4d5a4ef339d3700144b..77279c8a8c9518161288510c507ddc21407a001a 100644 (file)
@@ -96,7 +96,7 @@ void VPSC::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) {