summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b7d235e)
raw | patch | inline | side by side (parent: b7d235e)
author | rwst <rwst@users.sourceforge.net> | |
Tue, 23 May 2006 07:41:37 +0000 (07:41 +0000) | ||
committer | rwst <rwst@users.sourceforge.net> | |
Tue, 23 May 2006 07:41:37 +0000 (07:41 +0000) |
src/removeoverlap/remove_rectangle_overlap.cpp | patch | blob | history | |
src/removeoverlap/solve_VPSC.cpp | patch | blob | history |
diff --git a/src/removeoverlap/remove_rectangle_overlap.cpp b/src/removeoverlap/remove_rectangle_overlap.cpp
index 6f6ace03ae0e88af16cc157dd91eb95071aa718c..9fbef647b9c0d6fdbc73af453df284620f0a3222 100755 (executable)
* 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);
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) {
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)
// 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) {