@@ -56,7 +56,7 @@ struct TBoundingBox_
5656 /* * Initialize with min=+Infinity, max=-Infinity. This is useful as an
5757 * initial value before processing a list of points to keep their
5858 * minimum/maximum. */
59- static TBoundingBox_<T> PlusMinusInfinity ()
59+ [[nodiscard]] static TBoundingBox_<T> PlusMinusInfinity ()
6060 {
6161 const T i = std::numeric_limits<T>::max ();
6262 return {{i, i, i}, {-i, -i, -i}, CTOR_FLAGS ::AllowUnordered};
@@ -67,7 +67,7 @@ struct TBoundingBox_
6767 * already sorted by the user as one being the minimum and maximum corners.
6868 * \note (New in MRPT 2.5.6)
6969 */
70- static TBoundingBox_<T> FromUnsortedPoints (
70+ [[nodiscard]] static TBoundingBox_<T> FromUnsortedPoints (
7171 const mrpt::math::TPoint3D_<T>& pt1,
7272 const mrpt::math::TPoint3D_<T>& pt2)
7373 {
@@ -82,7 +82,7 @@ struct TBoundingBox_
8282 }
8383
8484 /* * Returns the volume of the box */
85- T volume () const
85+ [[nodiscard]] T volume () const
8686 {
8787 return (max.x - min.x ) * (max.y - min.y ) * (max.z - min.z );
8888 }
@@ -93,7 +93,7 @@ struct TBoundingBox_
9393 * intersection to handle numerical innacuracies, for example on planar
9494 * bounding boxes with a fixed "z".
9595 */
96- std::optional<TBoundingBox_<T>> intersection (
96+ [[nodiscard]] std::optional<TBoundingBox_<T>> intersection (
9797 const TBoundingBox_<T>& b, const T epsilon = static_cast <T>(1e-4 )) const
9898 {
9999 if (b.min .x - epsilon > max.x || b.min .y - epsilon > max.y ||
@@ -111,7 +111,7 @@ struct TBoundingBox_
111111
112112 /* * Returns the union of this bounding box with "b", i.e. a new bounding box
113113 * comprising both `this` and `b` */
114- TBoundingBox_<T> unionWith (const TBoundingBox_<T>& b) const
114+ [[nodiscard]] TBoundingBox_<T> unionWith (const TBoundingBox_<T>& b) const
115115 {
116116 return {TBoundingBox_<T>(
117117 {std::min (min.x , b.min .x ), std::min (min.y , b.min .y ),
@@ -136,7 +136,7 @@ struct TBoundingBox_
136136 * exact border)
137137 * \note (New in MRPT 2.3.3)
138138 */
139- bool containsPoint (const mrpt::math::TPoint3D_<T>& p) const
139+ [[nodiscard]] bool containsPoint (const mrpt::math::TPoint3D_<T>& p) const
140140 {
141141 return p.x >= min.x && p.y >= min.y && p.z >= min.z && p.x <= max.x &&
142142 p.y <= max.y && p.z <= max.z ;
@@ -155,7 +155,7 @@ struct TBoundingBox_
155155 * accurate representation of the actual 3D box.
156156 */
157157 template <typename POSE_T >
158- TBoundingBox_<T> compose (const POSE_T & pose) const
158+ [[nodiscard]] TBoundingBox_<T> compose (const POSE_T & pose) const
159159 {
160160 return FromUnsortedPoints (
161161 pose.composePoint (min), pose.composePoint (max));
@@ -174,7 +174,7 @@ struct TBoundingBox_
174174 * accurate representation of the actual 3D box.
175175 */
176176 template <typename POSE_T >
177- TBoundingBox_<T> inverseCompose (const POSE_T & pose) const
177+ [[nodiscard]] TBoundingBox_<T> inverseCompose (const POSE_T & pose) const
178178 {
179179 return FromUnsortedPoints (
180180 pose.inverseComposePoint (min), pose.inverseComposePoint (max));
@@ -186,18 +186,23 @@ struct TBoundingBox_
186186 * \note Do not inherit from mrpt::Stringifyable to avoid virtual class
187187 * table and keeping the class trivially-copiable.
188188 */
189- std::string asString () const
189+ [[nodiscard]] std::string asString () const
190190 {
191191 std::string s = min.asString ();
192192 s += " -" ;
193193 s += max.asString ();
194194 return s;
195195 }
196196
197- bool operator ==(const TBoundingBox_<T>& o) const
197+ [[nodiscard]] bool operator ==(const TBoundingBox_<T>& o) const
198198 {
199199 return max == o.max && min == o.min ;
200200 }
201+
202+ [[nodiscard]] bool operator !=(const TBoundingBox_<T>& o) const
203+ {
204+ return max != o.max || min != o.min ;
205+ }
201206};
202207
203208/* * A bounding box defined by the 3D points at each minimum-maximum corner.
0 commit comments