diff options
| author | Tim Dwyer <tgdwyer@gmail.com> | 2006-02-06 05:22:54 +0000 |
|---|---|---|
| committer | tgdwyer <tgdwyer@users.sourceforge.net> | 2006-02-06 05:22:54 +0000 |
| commit | 26764b3878c6aec5f315f9f63c8721640218b826 (patch) | |
| tree | 95545994301bc2fb624076245706d4aea8f8bca8 /src/removeoverlap | |
| parent | add scaling and translation so that the DXFs open properly in robomaster (diff) | |
| download | inkscape-26764b3878c6aec5f315f9f63c8721640218b826.tar.gz inkscape-26764b3878c6aec5f315f9f63c8721640218b826.zip | |
DBL_MIN replaced by -DBL_MAX which is what I meant all along.
Fixes bug.
(bzr r89)
Diffstat (limited to 'src/removeoverlap')
| -rw-r--r-- | src/removeoverlap/block.cpp | 8 | ||||
| -rw-r--r-- | src/removeoverlap/constraint.cpp | 2 | ||||
| -rw-r--r-- | src/removeoverlap/constraint.h | 4 | ||||
| -rw-r--r-- | src/removeoverlap/pairingheap/PairingHeap.cpp | 28 | ||||
| -rw-r--r-- | src/removeoverlap/pairingheap/PairingHeap.h | 2 |
5 files changed, 39 insertions, 5 deletions
diff --git a/src/removeoverlap/block.cpp b/src/removeoverlap/block.cpp index ebf56ea9e..7a2ab53af 100644 --- a/src/removeoverlap/block.cpp +++ b/src/removeoverlap/block.cpp @@ -104,6 +104,9 @@ void Block::mergeIn(Block *b) { findMinInConstraint(); b->findMinInConstraint(); in->merge(b->in); +#ifdef RECTANGLE_OVERLAP_LOGGING + f<<" merged heap: "<<*in<<endl; +#endif } void Block::mergeOut(Block *b) { findMinOutConstraint(); @@ -171,6 +174,11 @@ Constraint *Block::findMinOutConstraint() { } void Block::deleteMinInConstraint() { in->deleteMin(); +#ifdef RECTANGLE_OVERLAP_LOGGING + ofstream f(LOGFILE,ios::app); + f<<"deleteMinInConstraint... "<<endl; + f<<" result: "<<*in<<endl; +#endif } void Block::deleteMinOutConstraint() { out->deleteMin(); diff --git a/src/removeoverlap/constraint.cpp b/src/removeoverlap/constraint.cpp index e48775f8c..bb889c4d9 100644 --- a/src/removeoverlap/constraint.cpp +++ b/src/removeoverlap/constraint.cpp @@ -24,6 +24,6 @@ Constraint::Constraint(Variable *left, Variable *right, double gap) } std::ostream& operator <<(std::ostream &os, const Constraint &c) { - os<<*c.left<<"+"<<c.gap<<"<="<<*c.right<<"("<<c.slack()<<")"; + os<<*c.left<<"+"<<c.gap<<"<="<<*c.right<<"("<<c.slack()<<"):lts="<<c.left->block->timeStamp<<",cts="<<c.timeStamp; return os; } diff --git a/src/removeoverlap/constraint.h b/src/removeoverlap/constraint.h index 683d66da3..c8273376b 100644 --- a/src/removeoverlap/constraint.h +++ b/src/removeoverlap/constraint.h @@ -37,11 +37,11 @@ static inline bool compareConstraints(Constraint *const &l, Constraint *const &r double const sl = l->left->block->timeStamp > l->timeStamp ||l->left->block==l->right->block - ?DBL_MIN:l->slack(); + ?-DBL_MAX:l->slack(); double const sr = r->left->block->timeStamp > r->timeStamp ||r->left->block==r->right->block - ?DBL_MIN:r->slack(); + ?-DBL_MAX:r->slack(); if(sl==sr) { // arbitrary choice based on id if(l->left->id==r->left->id) { diff --git a/src/removeoverlap/pairingheap/PairingHeap.cpp b/src/removeoverlap/pairingheap/PairingHeap.cpp index e0db8fdaf..42d009c6a 100644 --- a/src/removeoverlap/pairingheap/PairingHeap.cpp +++ b/src/removeoverlap/pairingheap/PairingHeap.cpp @@ -17,7 +17,7 @@ */ #include <vector> - +#include <list> #include "dsexceptions.h" #include "PairingHeap.h" @@ -305,5 +305,29 @@ PairingHeap<T>::clone( PairNode<T> * t ) const return p; } } - +template <class T> +ostream& operator <<(ostream &os, const PairingHeap<T> &b) +{ + os<<"Heap:"; + if (b.root != NULL) { + PairNode<T> *r = b.root; + list<PairNode<T>*> q; + q.push_back(r); + while (!q.empty()) { + r = q.front(); + q.pop_front(); + if (r->leftChild != NULL) { + os << *r->element << ">"; + PairNode<T> *c = r->leftChild; + while (c != NULL) { + q.push_back(c); + os << "," << *c->element; + c = c->nextSibling; + } + os << "|"; + } + } + } + return os; +} #endif diff --git a/src/removeoverlap/pairingheap/PairingHeap.h b/src/removeoverlap/pairingheap/PairingHeap.h index 5f57f2f1b..038a395f4 100644 --- a/src/removeoverlap/pairingheap/PairingHeap.h +++ b/src/removeoverlap/pairingheap/PairingHeap.h @@ -43,6 +43,7 @@ class PairingHeap; template <class T> class PairNode { + friend std::ostream& operator <<(std::ostream &os,const PairingHeap<T> &b); T element; PairNode *leftChild; PairNode *nextSibling; @@ -63,6 +64,7 @@ public: template <class T> class PairingHeap { + friend std::ostream& operator <<(std::ostream &os,const PairingHeap<T> &b); public: PairingHeap( bool (*lessThan)(T const &lhs, T const &rhs) ); PairingHeap( const PairingHeap & rhs ); |
