adds a pt to the conn comp and updates its boundaries
| 51 | |
| 52 | // adds a pt to the conn comp and updates its boundaries |
| 53 | bool ConComp::Add(int x, int y) { |
| 54 | ConCompPt *pt_ptr = new ConCompPt(x, y); |
| 55 | |
| 56 | if (head_ == NULL) { |
| 57 | left_ = x; |
| 58 | right_ = x; |
| 59 | top_ = y; |
| 60 | bottom_ = y; |
| 61 | |
| 62 | head_ = pt_ptr; |
| 63 | } else { |
| 64 | left_ = left_ <= x ? left_ : x; |
| 65 | top_ = top_ <= y ? top_ : y; |
| 66 | right_ = right_ >= x ? right_ : x; |
| 67 | bottom_ = bottom_ >= y ? bottom_ : y; |
| 68 | } |
| 69 | |
| 70 | if (tail_ != NULL) { |
| 71 | tail_->SetNext(pt_ptr); |
| 72 | } |
| 73 | |
| 74 | tail_ = pt_ptr; |
| 75 | pt_cnt_++; |
| 76 | return true; |
| 77 | } |
| 78 | |
| 79 | // merges two connected components |
| 80 | bool ConComp::Merge(ConComp *concomp) { |
no test coverage detected