diff options
| author | MenTaLguY <mental@rydia.net> | 2006-01-16 02:36:01 +0000 |
|---|---|---|
| committer | mental <mental@users.sourceforge.net> | 2006-01-16 02:36:01 +0000 |
| commit | 179fa413b047bede6e32109e2ce82437c5fb8d34 (patch) | |
| tree | a5a6ac2c1708bd02288fbd8edb2ff500ff2e0916 /src/removeoverlap/constraint.h | |
| download | inkscape-179fa413b047bede6e32109e2ce82437c5fb8d34.tar.gz inkscape-179fa413b047bede6e32109e2ce82437c5fb8d34.zip | |
moving trunk for module inkscape
(bzr r1)
Diffstat (limited to 'src/removeoverlap/constraint.h')
| -rw-r--r-- | src/removeoverlap/constraint.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/removeoverlap/constraint.h b/src/removeoverlap/constraint.h new file mode 100644 index 000000000..26afcefdd --- /dev/null +++ b/src/removeoverlap/constraint.h @@ -0,0 +1,52 @@ +/** + * \brief Remove overlaps function + * + * Authors: + * Tim Dwyer <tgdwyer@gmail.com> + * + * Copyright (C) 2005 Authors + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifndef SEEN_REMOVEOVERLAP_CONSTRAINT_H +#define SEEN_REMOVEOVERLAP_CONSTRAINT_H + +#include <iostream> +#include "variable.h" + +class Constraint +{ + friend std::ostream& operator <<(std::ostream &os,const Constraint &c); +public: + Variable *left; + Variable *right; + double gap; + double lm; + Constraint(Variable *left, Variable *right, double gap); + ~Constraint(void){}; + inline double Constraint::slack() const { return right->position() - gap - left->position(); } + //inline bool operator<(Constraint const &o) const { return slack() < o.slack(); } + long timeStamp; + bool active; + bool visited; +}; +#include <float.h> +static inline bool compareConstraints(Constraint *&l, Constraint *&r) { + double sl = l->slack(); + double sr = r->slack(); + if(l->left->block==l->right->block) sl=DBL_MIN; + if(r->left->block==r->right->block) sr=DBL_MIN; + if(sl==sr) { + // arbitrary choice based on id + if(l->left->id==r->left->id) { + if(l->right->id<r->right->id) return true; + return false; + } + if(l->left->id<r->left->id) return true; + return false; + } + return sl < sr; +} + +#endif // SEEN_REMOVEOVERLAP_CONSTRAINT_H |
