MCPcopy Create free account
hub / github.com/computationalpathologygroup/ASAP / getImageBoundingBox

Method getImageBoundingBox

annotation/AnnotationGroup.cpp:14–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12}
13
14std::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
48std::vector<Point> AnnotationGroup::getLocalBoundingBox() {
49 Point center = this->getCenter();

Callers

nothing calls this directly

Calls 2

PointClass · 0.85
emptyMethod · 0.80

Tested by

no test coverage detected