@@ -56,7 +56,7 @@ struct TBoundingBox_
56
56
/* * Initialize with min=+Infinity, max=-Infinity. This is useful as an
57
57
* initial value before processing a list of points to keep their
58
58
* minimum/maximum. */
59
- static TBoundingBox_<T> PlusMinusInfinity ()
59
+ [[nodiscard]] static TBoundingBox_<T> PlusMinusInfinity ()
60
60
{
61
61
const T i = std::numeric_limits<T>::max ();
62
62
return {{i, i, i}, {-i, -i, -i}, CTOR_FLAGS::AllowUnordered};
@@ -67,7 +67,7 @@ struct TBoundingBox_
67
67
* already sorted by the user as one being the minimum and maximum corners.
68
68
* \note (New in MRPT 2.5.6)
69
69
*/
70
- static TBoundingBox_<T> FromUnsortedPoints (
70
+ [[nodiscard]] static TBoundingBox_<T> FromUnsortedPoints (
71
71
const mrpt::math::TPoint3D_<T>& pt1,
72
72
const mrpt::math::TPoint3D_<T>& pt2)
73
73
{
@@ -82,7 +82,7 @@ struct TBoundingBox_
82
82
}
83
83
84
84
/* * Returns the volume of the box */
85
- T volume () const
85
+ [[nodiscard]] T volume () const
86
86
{
87
87
return (max.x - min.x ) * (max.y - min.y ) * (max.z - min.z );
88
88
}
@@ -93,7 +93,7 @@ struct TBoundingBox_
93
93
* intersection to handle numerical innacuracies, for example on planar
94
94
* bounding boxes with a fixed "z".
95
95
*/
96
- std::optional<TBoundingBox_<T>> intersection (
96
+ [[nodiscard]] std::optional<TBoundingBox_<T>> intersection (
97
97
const TBoundingBox_<T>& b, const T epsilon = static_cast <T>(1e-4 )) const
98
98
{
99
99
if (b.min .x - epsilon > max.x || b.min .y - epsilon > max.y ||
@@ -111,7 +111,7 @@ struct TBoundingBox_
111
111
112
112
/* * Returns the union of this bounding box with "b", i.e. a new bounding box
113
113
* comprising both `this` and `b` */
114
- TBoundingBox_<T> unionWith (const TBoundingBox_<T>& b) const
114
+ [[nodiscard]] TBoundingBox_<T> unionWith (const TBoundingBox_<T>& b) const
115
115
{
116
116
return {TBoundingBox_<T>(
117
117
{std::min (min.x , b.min .x ), std::min (min.y , b.min .y ),
@@ -136,7 +136,7 @@ struct TBoundingBox_
136
136
* exact border)
137
137
* \note (New in MRPT 2.3.3)
138
138
*/
139
- bool containsPoint (const mrpt::math::TPoint3D_<T>& p) const
139
+ [[nodiscard]] bool containsPoint (const mrpt::math::TPoint3D_<T>& p) const
140
140
{
141
141
return p.x >= min.x && p.y >= min.y && p.z >= min.z && p.x <= max.x &&
142
142
p.y <= max.y && p.z <= max.z ;
@@ -155,7 +155,7 @@ struct TBoundingBox_
155
155
* accurate representation of the actual 3D box.
156
156
*/
157
157
template <typename POSE_T>
158
- TBoundingBox_<T> compose (const POSE_T& pose) const
158
+ [[nodiscard]] TBoundingBox_<T> compose (const POSE_T& pose) const
159
159
{
160
160
return FromUnsortedPoints (
161
161
pose.composePoint (min), pose.composePoint (max));
@@ -174,7 +174,7 @@ struct TBoundingBox_
174
174
* accurate representation of the actual 3D box.
175
175
*/
176
176
template <typename POSE_T>
177
- TBoundingBox_<T> inverseCompose (const POSE_T& pose) const
177
+ [[nodiscard]] TBoundingBox_<T> inverseCompose (const POSE_T& pose) const
178
178
{
179
179
return FromUnsortedPoints (
180
180
pose.inverseComposePoint (min), pose.inverseComposePoint (max));
@@ -186,18 +186,23 @@ struct TBoundingBox_
186
186
* \note Do not inherit from mrpt::Stringifyable to avoid virtual class
187
187
* table and keeping the class trivially-copiable.
188
188
*/
189
- std::string asString () const
189
+ [[nodiscard]] std::string asString () const
190
190
{
191
191
std::string s = min.asString ();
192
192
s += " -" ;
193
193
s += max.asString ();
194
194
return s;
195
195
}
196
196
197
- bool operator ==(const TBoundingBox_<T>& o) const
197
+ [[nodiscard]] bool operator ==(const TBoundingBox_<T>& o) const
198
198
{
199
199
return max == o.max && min == o.min ;
200
200
}
201
+
202
+ [[nodiscard]] bool operator !=(const TBoundingBox_<T>& o) const
203
+ {
204
+ return max != o.max || min != o.min ;
205
+ }
201
206
};
202
207
203
208
/* * A bounding box defined by the 3D points at each minimum-maximum corner.
0 commit comments