OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/box_f.h" | 5 #include "ui/gfx/box_f.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... | |
38 float max_x = std::max(right(), box.right()); | 38 float max_x = std::max(right(), box.right()); |
39 float max_y = std::max(bottom(), box.bottom()); | 39 float max_y = std::max(bottom(), box.bottom()); |
40 float max_z = std::max(front(), box.front()); | 40 float max_z = std::max(front(), box.front()); |
41 | 41 |
42 origin_.SetPoint(min_x, min_y, min_z); | 42 origin_.SetPoint(min_x, min_y, min_z); |
43 width_ = max_x - min_x; | 43 width_ = max_x - min_x; |
44 height_ = max_y - min_y; | 44 height_ = max_y - min_y; |
45 depth_ = max_z - min_z; | 45 depth_ = max_z - min_z; |
46 } | 46 } |
47 | 47 |
48 void BoxF::ExpandTo(const Point3F& point) { | |
49 Point3F max( | |
50 origin_.x() + width_, origin_.y() + height_, origin_.z() + depth_); | |
51 | |
52 if (point.x() < origin_.x()) | |
53 origin_.set_x(point.x()); | |
54 if (point.y() < origin_.y()) | |
55 origin_.set_y(point.y()); | |
56 if (point.z() < origin_.z()) | |
57 origin_.set_z(point.z()); | |
58 | |
59 if (point.x() > max.x()) | |
60 max.set_x(point.x()); | |
61 if (point.y() > max.y()) | |
62 max.set_y(point.y()); | |
63 if (point.z() > max.z()) | |
64 max.set_z(point.z()); | |
65 | |
66 width_ = max.x() - origin_.x(); | |
67 height_ = max.y() - origin_.y(); | |
68 depth_ = max.z() - origin_.z(); | |
ajuma
2013/10/01 13:21:02
How about putting the logic that ExpandTo and Unio
| |
69 } | |
70 | |
48 BoxF UnionBoxes(const BoxF& a, const BoxF& b) { | 71 BoxF UnionBoxes(const BoxF& a, const BoxF& b) { |
49 BoxF result = a; | 72 BoxF result = a; |
50 result.Union(b); | 73 result.Union(b); |
51 return result; | 74 return result; |
52 } | 75 } |
53 | 76 |
54 } // namespace gfx | 77 } // namespace gfx |
OLD | NEW |