| 12 | } |
| 13 | |
| 14 | std::vector<Point> AnnotationGroup::getImageBoundingBox() const { |
| 15 | std::vector<Point> bbox; |
| 16 | Point topLeft(std::numeric_limits<float>::max(), std::numeric_limits<float>::max()); |
| 17 | Point bottomRight(std::numeric_limits<float>::min(), std::numeric_limits<float>::min()); |
| 18 | |
| 19 | if (_groupMembers.empty()) { |
| 20 | topLeft = Point(0, 0); |
| 21 | bottomRight = Point(0, 0); |
| 22 | } |
| 23 | else { |
| 24 | for (std::vector<std::weak_ptr<AnnotationBase> >::const_iterator it = _groupMembers.begin(); it != _groupMembers.end(); ++it) { |
| 25 | if (std::shared_ptr<AnnotationBase> localMember = it->lock()) { |
| 26 | std::vector<Point> memberBBox = localMember->getImageBoundingBox(); |
| 27 | if (memberBBox[1].getX() > bottomRight.getX()) { |
| 28 | bottomRight.setX(memberBBox[1].getX()); |
| 29 | } |
| 30 | if (memberBBox[1].getY() > bottomRight.getY()) { |
| 31 | bottomRight.setY(memberBBox[1].getY()); |
| 32 | } |
| 33 | if (memberBBox[0].getX() < topLeft.getX()) { |
| 34 | topLeft.setX(memberBBox[0].getX()); |
| 35 | } |
| 36 | if (memberBBox[0].getY() < topLeft.getY()) { |
| 37 | topLeft.setY(memberBBox[0].getY()); |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | bbox.push_back(topLeft); |
| 44 | bbox.push_back(bottomRight); |
| 45 | return bbox; |
| 46 | } |
| 47 | |
| 48 | std::vector<Point> AnnotationGroup::getLocalBoundingBox() { |
| 49 | Point center = this->getCenter(); |