Skip to content

Commit b1b0512

Browse files
committed
WIP fixing warnings
1 parent d65aee0 commit b1b0512

File tree

9 files changed

+222
-171
lines changed

9 files changed

+222
-171
lines changed

modules/mrpt_math/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ set(LIB_PUBLIC_HDRS
141141
include/mrpt/math/fourier.h
142142
include/mrpt/math/fresnel.h
143143
include/mrpt/math/geometry.h
144+
include/mrpt/math/GeometryEntity.h
144145
include/mrpt/math/gtsam_wrappers.h
145146
include/mrpt/math/homog_matrices.h
146147
include/mrpt/math/interp_fit.h
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* +------------------------------------------------------------------------+
2+
| Mobile Robot Programming Toolkit (MRPT) |
3+
| https://www.mrpt.org/ |
4+
| |
5+
| Copyright (c) 2005-2024, Individual contributors, see AUTHORS file |
6+
| See: https://www.mrpt.org/Authors - All rights reserved. |
7+
| Released under BSD License. See: https://www.mrpt.org/License |
8+
+------------------------------------------------------------------------+ */
9+
#pragma once
10+
11+
#include <cstdint>
12+
13+
namespace mrpt::math
14+
{
15+
16+
/** Types of geometric entities */
17+
enum class GeometricEntity : uint8_t
18+
{
19+
UNDEFINED = 0xff,
20+
POINT = 0, //!< Object type for TPoint2D or TPoint3D \sa TObject2D,TObject3D
21+
SEGMENT, //!< Object type for TSegment2D or TSegment3D \sa TObject2D,TObject3D
22+
LINE, //!< Object type for TLine2D or TLine3D \sa TObject2D,TObject3D
23+
POLYGON, //!< Object type for TPolygon2D or TPolygon3D \sa TObject2D,TObject3D
24+
PLANE //!< Object type for TPlane \sa TObject2D,TObject3D
25+
};
26+
27+
} // namespace mrpt::math

modules/mrpt_math/include/mrpt/math/TPoseOrPoint.h

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <mrpt/typemeta/TTypeName.h> // Used in all derived classes
1414

1515
#include <iosfwd> // std::ostream
16-
#include <stdexcept>
1716
#include <type_traits>
1817

1918
namespace mrpt::math
@@ -90,7 +89,10 @@ template <
9089
typename = std::enable_if_t<std::is_base_of_v<mrpt::math::TPoseOrPoint, PoseOrPoint>>>
9190
mrpt::serialization::CArchive& operator>>(mrpt::serialization::CArchive& in, PoseOrPoint& o)
9291
{
93-
for (int i = 0; i < o.static_size; i++) in >> o[i];
92+
for (int i = 0; i < o.static_size; i++)
93+
{
94+
in >> o[i];
95+
}
9496
return in;
9597
}
9698

@@ -100,40 +102,11 @@ template <
100102
typename = std::enable_if_t<std::is_base_of_v<mrpt::math::TPoseOrPoint, PoseOrPoint>>>
101103
mrpt::serialization::CArchive& operator<<(mrpt::serialization::CArchive& out, const PoseOrPoint& o)
102104
{
103-
for (int i = 0; i < o.static_size; i++) out << o[i];
105+
for (int i = 0; i < o.static_size; i++)
106+
{
107+
out << o[i];
108+
}
104109
return out;
105110
}
106111

107-
/**
108-
* Object type identifier for TPoint2D or TPoint3D.
109-
* \sa TObject2D,TObject3D
110-
*/
111-
static constexpr unsigned char GEOMETRIC_TYPE_POINT = 0;
112-
/**
113-
* Object type identifier for TSegment2D or TSegment3D.
114-
* \sa TObject2D,TObject3D
115-
*/
116-
static constexpr unsigned char GEOMETRIC_TYPE_SEGMENT = 1;
117-
/**
118-
* Object type identifier for TLine2D or TLine3D.
119-
* \sa TObject2D,TObject3D
120-
*/
121-
static constexpr unsigned char GEOMETRIC_TYPE_LINE = 2;
122-
/**
123-
* Object type identifier for TPolygon2D or TPolygon3D.
124-
* \sa TObject2D,TObject3D
125-
*/
126-
static constexpr unsigned char GEOMETRIC_TYPE_POLYGON = 3;
127-
/**
128-
* Object type identifier for TPlane.
129-
* \sa TObject3D
130-
*/
131-
static constexpr unsigned char GEOMETRIC_TYPE_PLANE = 4;
132-
/**
133-
* Object type identifier for empty TObject2D or TObject3D.
134-
* \sa TObject2D,TObject3D
135-
*/
136-
static constexpr unsigned char GEOMETRIC_TYPE_UNDEFINED = 255;
137-
/** @} */
138-
139112
} // namespace mrpt::math

modules/mrpt_math/include/mrpt/math/geometry.h

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ namespace mrpt::math
3030
@{
3131
*/
3232
/** Gets the intersection between two 3D segments. Possible outcomes:
33-
* - Segments intersect: Return=true, obj.getType()=GEOMETRIC_TYPE_POINT
33+
* - Segments intersect: Return=true, obj.getType()=GeometricEntity::POINT
3434
* - Segments don't intersect & are parallel: Return=true,
35-
*obj.getType()=GEOMETRIC_TYPE_SEGMENT, obj is the segment "in between" both
35+
*obj.getType()=GeometricEntity::SEGMENT, obj is the segment "in between" both
3636
*segments.
3737
* - Segments don't intersect & aren't parallel: Return=false.
3838
* \sa TObject3D
@@ -42,29 +42,29 @@ bool intersect(const TSegment3D& s1, const TSegment3D& s2, TObject3D& obj);
4242
/** Gets the intersection between a 3D segment and a plane. Possible outcomes:
4343
* - Don't intersect: Return=false
4444
* - s1 is within the plane: Return=true,
45-
*obj.getType()=GEOMETRIC_TYPE_SEGMENT
45+
*obj.getType()=GeometricEntity::SEGMENT
4646
* - s1 intersects the plane at one point: Return=true,
47-
*obj.getType()=GEOMETRIC_TYPE_POINT
47+
*obj.getType()=GeometricEntity::POINT
4848
* \sa TObject3D
4949
*/
5050
bool intersect(const TSegment3D& s1, const TPlane& p2, TObject3D& obj);
5151

5252
/** Gets the intersection between a 3D segment and a 3D line. Possible outcomes:
5353
* - They don't intersect : Return=false
5454
* - s1 lies within the line: Return=true,
55-
*obj.getType()=GEOMETRIC_TYPE_SEGMENT
55+
*obj.getType()=GeometricEntity::SEGMENT
5656
* - s1 intersects the line at a point: Return=true,
57-
*obj.getType()=GEOMETRIC_TYPE_POINT
57+
*obj.getType()=GeometricEntity::POINT
5858
* \sa TObject3D
5959
*/
6060
bool intersect(const TSegment3D& s1, const TLine3D& r2, TObject3D& obj);
6161

6262
/** Gets the intersection between a plane and a 3D segment. Possible outcomes:
6363
* - Don't intersect: Return=false
6464
* - s2 is within the plane: Return=true,
65-
*obj.getType()=GEOMETRIC_TYPE_SEGMENT
65+
*obj.getType()=GeometricEntity::SEGMENT
6666
* - s2 intersects the plane at one point: Return=true,
67-
*obj.getType()=GEOMETRIC_TYPE_POINT
67+
*obj.getType()=GeometricEntity::POINT
6868
* \sa TObject3D
6969
*/
7070
inline bool intersect(const TPlane& p1, const TSegment3D& s2, TObject3D& obj)
@@ -75,27 +75,27 @@ inline bool intersect(const TPlane& p1, const TSegment3D& s2, TObject3D& obj)
7575
/** Gets the intersection between two planes. Possible outcomes:
7676
* - Planes are parallel: Return=false
7777
* - Planes intersect into a line: Return=true,
78-
*obj.getType()=GEOMETRIC_TYPE_LINE
78+
*obj.getType()=GeometricEntity::LINE
7979
* \sa TObject3D
8080
*/
8181
bool intersect(const TPlane& p1, const TPlane& p2, TObject3D& obj);
8282

8383
/** Gets the intersection between a plane and a 3D line. Possible outcomes:
8484
* - Line is parallel to plane but not within it: Return=false
8585
* - Line is contained in the plane: Return=true,
86-
*obj.getType()=GEOMETRIC_TYPE_LINE
86+
*obj.getType()=GeometricEntity::LINE
8787
* - Line intersects the plane at one point: Return=true,
88-
*obj.getType()=GEOMETRIC_TYPE_POINT
88+
*obj.getType()=GeometricEntity::POINT
8989
* \sa TObject3D
9090
*/
9191
bool intersect(const TPlane& p1, const TLine3D& p2, TObject3D& obj);
9292

9393
/** Gets the intersection between a 3D line and a 3D segment. Possible outcomes:
9494
* - They don't intersect : Return=false
9595
* - s2 lies within the line: Return=true,
96-
*obj.getType()=GEOMETRIC_TYPE_SEGMENT
96+
*obj.getType()=GeometricEntity::SEGMENT
9797
* - s2 intersects the line at a point: Return=true,
98-
*obj.getType()=GEOMETRIC_TYPE_POINT
98+
*obj.getType()=GeometricEntity::POINT
9999
* \sa TObject3D
100100
*/
101101
inline bool intersect(const TLine3D& r1, const TSegment3D& s2, TObject3D& obj)
@@ -106,9 +106,9 @@ inline bool intersect(const TLine3D& r1, const TSegment3D& s2, TObject3D& obj)
106106
/** Gets the intersection between a 3D line and a plane. Possible outcomes:
107107
* - Line is parallel to plane but not within it: Return=false
108108
* - Line is contained in the plane: Return=true,
109-
*obj.getType()=GEOMETRIC_TYPE_LINE
109+
*obj.getType()=GeometricEntity::LINE
110110
* - Line intersects the plane at one point: Return=true,
111-
*obj.getType()=GEOMETRIC_TYPE_POINT
111+
*obj.getType()=GeometricEntity::POINT
112112
* \sa TObject3D
113113
*/
114114
inline bool intersect(const TLine3D& r1, const TPlane& p2, TObject3D& obj)
@@ -120,9 +120,9 @@ inline bool intersect(const TLine3D& r1, const TPlane& p2, TObject3D& obj)
120120
* - Lines do not intersect: Return=false
121121
* - Lines are parallel and do not coincide: Return=false
122122
* - Lines coincide (are the same): Return=true,
123-
*obj.getType()=GEOMETRIC_TYPE_LINE
123+
*obj.getType()=GeometricEntity::LINE
124124
* - Lines intesect in a point: Return=true,
125-
*obj.getType()=GEOMETRIC_TYPE_POINT
125+
*obj.getType()=GeometricEntity::POINT
126126
* \sa TObject3D
127127
*/
128128
bool intersect(const TLine3D& r1, const TLine3D& r2, TObject3D& obj);
@@ -131,29 +131,29 @@ bool intersect(const TLine3D& r1, const TLine3D& r2, TObject3D& obj);
131131
* - Lines do not intersect: Return=false
132132
* - Lines are parallel and do not coincide: Return=false
133133
* - Lines coincide (are the same): Return=true,
134-
*obj.getType()=GEOMETRIC_TYPE_LINE
134+
*obj.getType()=GeometricEntity::LINE
135135
* - Lines intesect in a point: Return=true,
136-
*obj.getType()=GEOMETRIC_TYPE_POINT
136+
*obj.getType()=GeometricEntity::POINT
137137
* \sa TObject2D
138138
*/
139139
bool intersect(const TLine2D& r1, const TLine2D& r2, TObject2D& obj);
140140

141141
/** Gets the intersection between a 2D line and a 2D segment. Possible outcomes:
142142
* - They don't intersect: Return=false
143143
* - s2 lies within the line: Return=true,
144-
*obj.getType()=GEOMETRIC_TYPE_SEGMENT
144+
*obj.getType()=GeometricEntity::SEGMENT
145145
* - Both intersects in one point: Return=true,
146-
*obj.getType()=GEOMETRIC_TYPE_POINT
146+
*obj.getType()=GeometricEntity::POINT
147147
* \sa TObject2D
148148
*/
149149
bool intersect(const TLine2D& r1, const TSegment2D& s2, TObject2D& obj);
150150

151151
/** Gets the intersection between a 2D line and a 2D segment. Possible outcomes:
152152
* - They don't intersect: Return=false
153153
* - s1 lies within the line: Return=true,
154-
*obj.getType()=GEOMETRIC_TYPE_SEGMENT
154+
*obj.getType()=GeometricEntity::SEGMENT
155155
* - Both intersects in one point: Return=true,
156-
*obj.getType()=GEOMETRIC_TYPE_POINT
156+
*obj.getType()=GeometricEntity::POINT
157157
* \sa TObject2D
158158
*/
159159
inline bool intersect(const TSegment2D& s1, const TLine2D& r2, TObject2D& obj)
@@ -162,9 +162,9 @@ inline bool intersect(const TSegment2D& s1, const TLine2D& r2, TObject2D& obj)
162162
}
163163

164164
/** Gets the intersection between two 2D segments. Possible outcomes:
165-
* - Segments intersect: Return=true, obj.getType()=GEOMETRIC_TYPE_POINT
165+
* - Segments intersect: Return=true, obj.getType()=GeometricEntity::POINT
166166
* - Segments don't intersect & are parallel: Return=true,
167-
*obj.getType()=GEOMETRIC_TYPE_SEGMENT, obj is the segment "in between" both
167+
*obj.getType()=GeometricEntity::SEGMENT, obj is the segment "in between" both
168168
*segments.
169169
* - Segments don't intersect & aren't parallel: Return=false.
170170
* \sa TObject2D

modules/mrpt_math/src/geometry_unittest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ TEST(Geometry, Segment2DIntersect)
237237
TObject2D inter;
238238
bool do_inter = intersect(s1, s2, inter);
239239

240-
// EXPECT_TRUE(do_inter && inter.getType()==GEOMETRIC_TYPE_SEGMENT);
240+
// EXPECT_TRUE(do_inter && inter.getType()==GeometricEntity::SEGMENT);
241241
EXPECT_FALSE(do_inter);
242242
}
243243
}

modules/mrpt_serialization/include/mrpt/serialization/CArchive.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,10 @@ class CArchive
393393

394394
/** Read the object */
395395
void internal_ReadObject(
396-
CSerializable* newObj, const std::string& className, bool isOldFormat, int8_t version);
396+
CSerializable* newObj, const std::string& className, bool isOldFormat, uint8_t version);
397397

398398
/** Read the object Header*/
399-
void internal_ReadObjectHeader(std::string& className, bool& isOldFormat, int8_t& version);
399+
void internal_ReadObjectHeader(std::string& className, bool& isOldFormat, uint8_t& version);
400400
};
401401

402402
// Note: write op accepts parameters by value on purpose, to avoid misaligned

modules/mrpt_serialization/include/mrpt/serialization/archiveFrom_std_streams.h

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,17 @@ class CArchiveStreamBase<std::istream> : public CArchive
2626
CArchiveStreamBase(std::istream& s) : m_s(s) {}
2727

2828
protected:
29-
size_t write(const void* d, size_t n) override
29+
size_t write([[maybe_unused]] const void* d, [[maybe_unused]] size_t n) override
3030
{
31-
throw std::runtime_error(
32-
"CArchiveStreamBase<std::istream>:"
33-
"cannot write to an input stream.");
31+
throw std::runtime_error("CArchiveStreamBase<std::istream>: cannot write to an input stream.");
3432
}
3533
size_t read(void* d, size_t n) override
3634
{
3735
if (m_s.read(reinterpret_cast<char*>(d), n))
36+
{
3837
return n;
39-
else
40-
return 0;
38+
}
39+
return 0;
4140
}
4241
};
4342

@@ -53,16 +52,15 @@ class CArchiveStreamBase<std::ostream> : public CArchive
5352
protected:
5453
size_t write(const void* d, size_t n) override
5554
{
56-
if (m_s.write(reinterpret_cast<const char*>(d), n))
55+
if (m_s.write(reinterpret_cast<const char*>(d), static_cast<std::streamsize>(n)))
56+
{
5757
return n;
58-
else
59-
return 0;
58+
}
59+
return 0;
6060
}
6161
size_t read(void* d, size_t n) override
6262
{
63-
throw std::runtime_error(
64-
"CArchiveStreamBase<std::ostream>:"
65-
"cannot read from output stream.");
63+
throw std::runtime_error("CArchiveStreamBase<std::ostream>: cannot read from output stream.");
6664
}
6765
};
6866

@@ -78,17 +76,20 @@ class CArchiveStreamBase<std::iostream> : public CArchive
7876
protected:
7977
size_t write(const void* d, size_t n) override
8078
{
81-
if (m_s.write(reinterpret_cast<const char*>(d), n))
79+
if (m_s.write(reinterpret_cast<const char*>(d), static_cast<std::streamsize>(n)))
80+
{
8281
return n;
83-
else
84-
return 0;
82+
}
83+
84+
return 0;
8585
}
8686
size_t read(void* d, size_t n) override
8787
{
88-
if (m_s.read(reinterpret_cast<char*>(d), n))
88+
if (m_s.read(reinterpret_cast<char*>(d), static_cast<std::streamsize>(n)))
89+
{
8990
return n;
90-
else
91-
return 0;
91+
}
92+
return 0;
9293
}
9394
};
9495

0 commit comments

Comments
 (0)