Skip to content

Commit 90910f1

Browse files
authored
Merge pull request #5495 from mvieth/misc8
Misc fixes and improvements
2 parents 4d9df3b + b22d6b1 commit 90910f1

File tree

15 files changed

+52
-43
lines changed

15 files changed

+52
-43
lines changed

.ci/azure-pipelines/docs-pipeline.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ resources:
1818
containers:
1919
- container: doc # for documentation.yaml
2020
image: pointcloudlibrary/doc
21-
- container: env1804 # for tutorials.yaml
22-
image: pointcloudlibrary/env:18.04
21+
- container: env2204 # for tutorials.yaml
22+
image: pointcloudlibrary/env:22.04
2323

2424
stages:
2525
- stage: formatting

.ci/azure-pipelines/tutorials.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ jobs:
33
displayName: Building Tutorials
44
pool:
55
vmImage: 'Ubuntu 20.04'
6-
container: env1804
6+
container: env2204
77
timeoutInMinutes: 0
88
variables:
99
BUILD_DIR: '$(Agent.BuildDirectory)/build'

common/src/parse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ parse_argument (int argc, const char * const * argv, const char * str, long long
120120
int
121121
parse_argument (int argc, const char * const * argv, const char * str, unsigned long long int &val) noexcept
122122
{
123-
long long int dummy;
123+
long long int dummy = -1;
124124
const auto ret = parse_argument (argc, argv, str, dummy);
125125
if ((ret == -1) || dummy < 0)
126126
{

filters/include/pcl/filters/farthest_point_sampling.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,7 @@ namespace pcl
9494

9595
};
9696
}
97+
98+
#ifdef PCL_NO_PRECOMPILE
99+
#include <pcl/filters/impl/farthest_point_sampling.hpp>
100+
#endif

filters/include/pcl/filters/impl/voxel_grid.hpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ pcl::getMinMax3D (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
5959
// Get the fields list and the distance field index
6060
std::vector<pcl::PCLPointField> fields;
6161
int distance_idx = pcl::getFieldIndex<PointT> (distance_field_name, fields);
62+
if (distance_idx < 0 || fields.empty()) {
63+
PCL_ERROR ("[pcl::getMinMax3D] Could not find field with name '%s'!\n", distance_field_name.c_str());
64+
return;
65+
}
66+
const auto field_offset = fields[distance_idx].offset;
6267

6368
float distance_value;
6469
// If dense, no need to check for NaNs
@@ -68,7 +73,7 @@ pcl::getMinMax3D (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
6873
{
6974
// Get the distance value
7075
const auto* pt_data = reinterpret_cast<const std::uint8_t*> (&point);
71-
memcpy (&distance_value, pt_data + fields[distance_idx].offset, sizeof (float));
76+
memcpy (&distance_value, pt_data + field_offset, sizeof (float));
7277

7378
if (limit_negative)
7479
{
@@ -94,7 +99,7 @@ pcl::getMinMax3D (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
9499
{
95100
// Get the distance value
96101
const auto* pt_data = reinterpret_cast<const std::uint8_t*> (&point);
97-
memcpy (&distance_value, pt_data + fields[distance_idx].offset, sizeof (float));
102+
memcpy (&distance_value, pt_data + field_offset, sizeof (float));
98103

99104
if (limit_negative)
100105
{
@@ -136,6 +141,11 @@ pcl::getMinMax3D (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
136141
// Get the fields list and the distance field index
137142
std::vector<pcl::PCLPointField> fields;
138143
int distance_idx = pcl::getFieldIndex<PointT> (distance_field_name, fields);
144+
if (distance_idx < 0 || fields.empty()) {
145+
PCL_ERROR ("[pcl::getMinMax3D] Could not find field with name '%s'!\n", distance_field_name.c_str());
146+
return;
147+
}
148+
const auto field_offset = fields[distance_idx].offset;
139149

140150
float distance_value;
141151
// If dense, no need to check for NaNs
@@ -145,7 +155,7 @@ pcl::getMinMax3D (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
145155
{
146156
// Get the distance value
147157
const auto* pt_data = reinterpret_cast<const std::uint8_t*> (&(*cloud)[index]);
148-
memcpy (&distance_value, pt_data + fields[distance_idx].offset, sizeof (float));
158+
memcpy (&distance_value, pt_data + field_offset, sizeof (float));
149159

150160
if (limit_negative)
151161
{
@@ -171,7 +181,7 @@ pcl::getMinMax3D (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
171181
{
172182
// Get the distance value
173183
const auto* pt_data = reinterpret_cast<const std::uint8_t*> (&(*cloud)[index]);
174-
memcpy (&distance_value, pt_data + fields[distance_idx].offset, sizeof (float));
184+
memcpy (&distance_value, pt_data + field_offset, sizeof (float));
175185

176186
if (limit_negative)
177187
{
@@ -272,8 +282,11 @@ pcl::VoxelGrid<PointT>::applyFilter (PointCloud &output)
272282
// Get the distance field index
273283
std::vector<pcl::PCLPointField> fields;
274284
int distance_idx = pcl::getFieldIndex<PointT> (filter_field_name_, fields);
275-
if (distance_idx == -1)
276-
PCL_WARN ("[pcl::%s::applyFilter] Invalid filter field name. Index is %d.\n", getClassName ().c_str (), distance_idx);
285+
if (distance_idx == -1) {
286+
PCL_ERROR ("[pcl::%s::applyFilter] Invalid filter field name (%s).\n", getClassName ().c_str (), filter_field_name_.c_str());
287+
return;
288+
}
289+
const auto field_offset = fields[distance_idx].offset;
277290

278291
// First pass: go over all points and insert them into the index_vector vector
279292
// with calculated idx. Points with the same idx value will contribute to the
@@ -288,7 +301,7 @@ pcl::VoxelGrid<PointT>::applyFilter (PointCloud &output)
288301
// Get the distance value
289302
const auto* pt_data = reinterpret_cast<const std::uint8_t*> (&(*input_)[index]);
290303
float distance_value = 0;
291-
memcpy (&distance_value, pt_data + fields[distance_idx].offset, sizeof (float));
304+
memcpy (&distance_value, pt_data + field_offset, sizeof (float));
292305

293306
if (filter_limit_negative_)
294307
{

geometry/include/pcl/geometry/mesh_base.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ class MeshBase {
894894
inline void
895895
resizeVertices(const std::size_t n, const VertexData& data = VertexData())
896896
{
897-
vertices_.resize(n);
897+
vertices_.resize(n, Vertex());
898898
this->resizeData(vertex_data_cloud_, n, data, HasVertexData());
899899
}
900900

@@ -904,7 +904,7 @@ class MeshBase {
904904
const EdgeData& edge_data = EdgeData(),
905905
const HalfEdgeData he_data = HalfEdgeData())
906906
{
907-
half_edges_.resize(2 * n);
907+
half_edges_.resize(2 * n, HalfEdge());
908908
this->resizeData(half_edge_data_cloud_, 2 * n, he_data, HasHalfEdgeData());
909909
this->resizeData(edge_data_cloud_, n, edge_data, HasEdgeData());
910910
}
@@ -913,7 +913,7 @@ class MeshBase {
913913
inline void
914914
resizeFaces(const std::size_t n, const FaceData& data = FaceData())
915915
{
916-
faces_.resize(n);
916+
faces_.resize(n, Face());
917917
this->resizeData(face_data_cloud_, n, data, HasFaceData());
918918
}
919919

@@ -2026,12 +2026,12 @@ class MeshBase {
20262026
/** \brief Resize the mesh data. */
20272027
template <class DataCloudT>
20282028
inline void
2029-
resizeData(DataCloudT& /*data_cloud*/,
2029+
resizeData(DataCloudT& data_cloud,
20302030
const std::size_t n,
20312031
const typename DataCloudT::value_type& data,
20322032
std::true_type /*has_data*/) const
20332033
{
2034-
data.resize(n, data);
2034+
data_cloud.resize(n, data);
20352035
}
20362036

20372037
/** \brief Does nothing. */

io/include/pcl/io/io_exception.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ namespace pcl
9999
va_list args;
100100
va_start (args, format);
101101
vsnprintf (msg, 1024, format, args);
102+
va_end (args);
102103
throw IOException (function, file, line, msg);
103104
}
104105
} // namespace

io/include/pcl/io/openni_camera/openni_exception.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ namespace openni_wrapper
132132
va_list args;
133133
va_start (args, format);
134134
vsprintf (msg, format, args);
135+
va_end (args);
135136
throw OpenNIException (function_name, file_name, line_number, msg);
136137
}
137138
} // namespace openni_camera

io/src/ifs_io.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,14 @@ pcl::IFSReader::readHeader (const std::string &file_name, pcl::PCLPointCloud2 &c
8181
fs.read ((char*)&length_of_magic, sizeof (std::uint32_t));
8282
char *magic = new char [length_of_magic];
8383
fs.read (magic, sizeof (char) * length_of_magic);
84-
if (strcmp (magic, "IFS"))
84+
const bool file_is_ifs_file = (strcmp (magic, "IFS") == 0);
85+
delete[] magic;
86+
if (!file_is_ifs_file)
8587
{
8688
PCL_ERROR ("[pcl::IFSReader::readHeader] File %s is not an IFS file!\n", file_name.c_str ());
8789
fs.close ();
8890
return (-1);
8991
}
90-
delete[] magic;
9192

9293
//Read IFS version
9394
float version;

io/src/image_grabber.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ struct pcl::ImageGrabberBase::ImageGrabberImpl
6868
bool pclzf_mode=false);
6969
//! For now, split rgb / depth folders only makes sense for VTK images
7070
ImageGrabberImpl (pcl::ImageGrabberBase& grabber,
71-
const std::string& rgb_dir,
7271
const std::string& depth_dir,
72+
const std::string& rgb_dir,
7373
float frames_per_second,
7474
bool repeat);
7575
ImageGrabberImpl (pcl::ImageGrabberBase& grabber,
@@ -805,8 +805,8 @@ pcl::ImageGrabberBase::ImageGrabberBase (const std::string& directory, float fra
805805
}
806806

807807
//////////////////////////////////////////////////////////
808-
pcl::ImageGrabberBase::ImageGrabberBase (const std::string& rgb_dir, const std::string &depth_dir, float frames_per_second, bool repeat)
809-
: impl_ (new ImageGrabberImpl (*this, rgb_dir, depth_dir, frames_per_second, repeat))
808+
pcl::ImageGrabberBase::ImageGrabberBase (const std::string& depth_directory, const std::string &rgb_directory, float frames_per_second, bool repeat)
809+
: impl_ (new ImageGrabberImpl (*this, depth_directory, rgb_directory, frames_per_second, repeat))
810810
{
811811
}
812812

0 commit comments

Comments
 (0)