Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove else after return statement [io] #3181

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions io/include/pcl/io/file_grabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ namespace pcl
// Throw error
throw pcl::IOException ("[pcl::FileGrabber] Attempted to access element which is out of bounds!");
}
else
{
return (operator[] (idx));
}
return (operator[] (idx));
}
};
}
3 changes: 1 addition & 2 deletions io/include/pcl/io/impl/buffers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ pcl::io::AverageBuffer<T>::operator[] (size_t idx) const
assert (idx < size_);
if (data_invalid_count_[idx] == window_size_)
return (buffer_traits<T>::invalid ());
else
return (data_sum_[idx] / static_cast<T> (window_size_ - data_invalid_count_[idx]));
return (data_sum_[idx] / static_cast<T> (window_size_ - data_invalid_count_[idx]));
}

template <typename T> void
Expand Down
13 changes: 5 additions & 8 deletions io/include/pcl/io/impl/pcd_io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,15 +546,12 @@ pcl::PCDWriter::writeASCII (const std::string &file_name, const pcl::PointCloud<
stream << boost::numeric_cast<uint32_t>(value);
break;
}
float value;
memcpy (&value, reinterpret_cast<const char*> (&cloud.points[i]) + fields[d].offset + c * sizeof (float), sizeof (float));
if (std::isnan (value))
stream << "nan";
else
{
float value;
memcpy (&value, reinterpret_cast<const char*> (&cloud.points[i]) + fields[d].offset + c * sizeof (float), sizeof (float));
if (std::isnan (value))
stream << "nan";
else
stream << boost::numeric_cast<float>(value);
}
stream << boost::numeric_cast<float>(value);
break;
}
case pcl::PCLPointField::FLOAT64:
Expand Down
11 changes: 4 additions & 7 deletions io/include/pcl/io/openni2_grabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,16 +465,13 @@ namespace pcl
{
if (mode1.getResolutionX () < mode2.getResolutionX ())
return true;
else if (mode1.getResolutionX () > mode2.getResolutionX ())
if (mode1.getResolutionX () > mode2.getResolutionX ())
return false;
else if (mode1.getResolutionY () < mode2.getResolutionY ())
if (mode1.getResolutionY () < mode2.getResolutionY ())
return true;
else if (mode1.getResolutionY () > mode2.getResolutionY ())
return false;
else if (mode1.getFps () < mode2.getFps () )
return true;
else
if (mode1.getResolutionY () > mode2.getResolutionY ())
return false;
return (mode1.getFps () < mode2.getFps ());
}
};

Expand Down
3 changes: 1 addition & 2 deletions io/include/pcl/io/openni_camera/openni_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,7 @@ namespace openni_wrapper
float scale = static_cast<float> (output_x_resolution) / static_cast<float> (XN_SXGA_X_RES);
if (isDepthRegistered ())
return (rgb_focal_length_SXGA_ * scale);
else
return (depth_focal_length_SXGA_ * scale);
return (depth_focal_length_SXGA_ * scale);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
11 changes: 4 additions & 7 deletions io/include/pcl/io/openni_grabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,16 +449,13 @@ namespace pcl
{
if (mode1.nXRes < mode2.nXRes)
return true;
else if (mode1.nXRes > mode2.nXRes)
if (mode1.nXRes > mode2.nXRes)
return false;
else if (mode1.nYRes < mode2.nYRes)
if (mode1.nYRes < mode2.nYRes)
return true;
else if (mode1.nYRes > mode2.nYRes)
return false;
else if (mode1.nFPS < mode2.nFPS)
return true;
else
if (mode1.nYRes > mode2.nYRes)
return false;
return (mode1.nFPS < mode2.nFPS);
}
} ;
std::map<int, XnMapOutputMode> config2xn_map_;
Expand Down
9 changes: 3 additions & 6 deletions io/include/pcl/io/pcd_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,7 @@ namespace pcl
{
if (binary)
return (writeBinary (file_name, cloud, origin, orientation));
else
return (writeASCII (file_name, cloud, origin, orientation, 8));
return (writeASCII (file_name, cloud, origin, orientation, 8));
}

/** \brief Save point cloud data to a PCD file containing n-D points
Expand Down Expand Up @@ -555,8 +554,7 @@ namespace pcl
{
if (binary)
return (writeBinary<PointT> (file_name, cloud));
else
return (writeASCII<PointT> (file_name, cloud));
return (writeASCII<PointT> (file_name, cloud));
}

/** \brief Save point cloud data to a PCD file containing n-D points
Expand All @@ -581,8 +579,7 @@ namespace pcl
{
if (binary)
return (writeBinary<PointT> (file_name, cloud, indices));
else
return (writeASCII<PointT> (file_name, cloud, indices));
return (writeASCII<PointT> (file_name, cloud, indices));
}

protected:
Expand Down
92 changes: 43 additions & 49 deletions io/include/pcl/io/ply/ply_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -572,23 +572,20 @@ inline bool pcl::io::ply::ply_parser::parse_scalar_property (format_type format,
scalar_property_callback (value);
return (true);
}
else
scalar_type value = std::numeric_limits<scalar_type>::quiet_NaN ();
istream.read (reinterpret_cast<char*> (&value), sizeof (scalar_type));
if (!istream)
{
scalar_type value = std::numeric_limits<scalar_type>::quiet_NaN ();
istream.read (reinterpret_cast<char*> (&value), sizeof (scalar_type));
if (!istream)
{
if (error_callback_)
error_callback_ (line_number_, "parse error");
return (false);
}
if (((format == binary_big_endian_format) && (host_byte_order == little_endian_byte_order)) ||
((format == binary_little_endian_format) && (host_byte_order == big_endian_byte_order)))
swap_byte_order (value);
if (scalar_property_callback)
scalar_property_callback (value);
return (true);
if (error_callback_)
error_callback_ (line_number_, "parse error");
return (false);
}
if (((format == binary_big_endian_format) && (host_byte_order == little_endian_byte_order)) ||
((format == binary_little_endian_format) && (host_byte_order == big_endian_byte_order)))
swap_byte_order (value);
if (scalar_property_callback)
scalar_property_callback (value);
return (true);
}

template <typename SizeType, typename ScalarType>
Expand Down Expand Up @@ -659,52 +656,49 @@ inline bool pcl::io::ply::ply_parser::parse_list_property (format_type format, s
}
return (true);
}
else
size_type size = std::numeric_limits<size_type>::infinity ();
istream.read (reinterpret_cast<char*> (&size), sizeof (size_type));
if (((format == binary_big_endian_format) && (host_byte_order == little_endian_byte_order)) ||
((format == binary_little_endian_format) && (host_byte_order == big_endian_byte_order)))
{
size_type size = std::numeric_limits<size_type>::infinity ();
istream.read (reinterpret_cast<char*> (&size), sizeof (size_type));
if (((format == binary_big_endian_format) && (host_byte_order == little_endian_byte_order)) ||
((format == binary_little_endian_format) && (host_byte_order == big_endian_byte_order)))
swap_byte_order (size);
}
if (!istream)
{
if (error_callback_)
{
swap_byte_order (size);
error_callback_ (line_number_, "parse error");
}
if (!istream)
{
if (error_callback_)
{
return (false);
}
if (list_property_begin_callback)
{
list_property_begin_callback (size);
}
for (std::size_t index = 0; index < size; ++index) {
scalar_type value = std::numeric_limits<scalar_type>::quiet_NaN ();
istream.read (reinterpret_cast<char*> (&value), sizeof (scalar_type));
if (!istream) {
if (error_callback_) {
error_callback_ (line_number_, "parse error");
}
return (false);
}
if (list_property_begin_callback)
if (((format == binary_big_endian_format) && (host_byte_order == little_endian_byte_order)) ||
((format == binary_little_endian_format) && (host_byte_order == big_endian_byte_order)))
{
list_property_begin_callback (size);
}
for (std::size_t index = 0; index < size; ++index) {
scalar_type value = std::numeric_limits<scalar_type>::quiet_NaN ();
istream.read (reinterpret_cast<char*> (&value), sizeof (scalar_type));
if (!istream) {
if (error_callback_) {
error_callback_ (line_number_, "parse error");
}
return (false);
}
if (((format == binary_big_endian_format) && (host_byte_order == little_endian_byte_order)) ||
((format == binary_little_endian_format) && (host_byte_order == big_endian_byte_order)))
{
swap_byte_order (value);
}
if (list_property_element_callback)
{
list_property_element_callback (value);
}
swap_byte_order (value);
}
if (list_property_end_callback)
if (list_property_element_callback)
{
list_property_end_callback ();
list_property_element_callback (value);
}
return (true);
}
if (list_property_end_callback)
{
list_property_end_callback ();
}
return (true);
}

#ifdef BUILD_Maintainer
Expand Down
6 changes: 2 additions & 4 deletions io/include/pcl/io/ply_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,7 @@ namespace pcl
{
if (binary)
return (this->writeBinary (file_name, cloud, origin, orientation, true));
else
return (this->writeASCII (file_name, cloud, origin, orientation, 8, true));
return (this->writeASCII (file_name, cloud, origin, orientation, 8, true));
}

/** \brief Save point cloud data to a PLY file containing n-D points
Expand All @@ -656,8 +655,7 @@ namespace pcl
{
if (binary)
return (this->writeBinary (file_name, cloud, origin, orientation, use_camera));
else
return (this->writeASCII (file_name, cloud, origin, orientation, 8, use_camera));
return (this->writeASCII (file_name, cloud, origin, orientation, 8, use_camera));
}

/** \brief Save point cloud data to a PLY file containing n-D points
Expand Down
21 changes: 7 additions & 14 deletions io/src/image_grabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,14 +493,11 @@ pcl::ImageGrabberBase::ImageGrabberImpl::getCloudAt (size_t idx,
cy = principal_point_y_;
return (getCloudVTK (idx, blob, origin, orientation) );
}
else if (!depth_pclzf_files_.empty ())
if (!depth_pclzf_files_.empty ())
return (getCloudPCLZF (idx, blob, origin, orientation, fx, fy, cx, cy) );
else
{
PCL_ERROR ("[pcl::ImageGrabber::getCloudAt] Could not find VTK or PCLZF files.\n");
return (false);
}
}
PCL_ERROR ("[pcl::ImageGrabber::getCloudAt] Could not find VTK or PCLZF files.\n");
return (false);
}

bool
pcl::ImageGrabberBase::ImageGrabberImpl::getCloudVTK (size_t idx,
Expand Down Expand Up @@ -810,7 +807,7 @@ pcl::ImageGrabberBase::ImageGrabberImpl::getVtkImage (
PCL_ERROR ("[pcl::ImageGrabber::getVtkImage] Image file can't be read: %s\n", filename.c_str ());
return (false);
}
else if (retval == 1)
if (retval == 1)
{
PCL_ERROR ("[pcl::ImageGrabber::getVtkImage] Can't prove that I can read: %s\n", filename.c_str ());
return (false);
Expand All @@ -828,8 +825,7 @@ pcl::ImageGrabberBase::ImageGrabberImpl::numFrames () const
{
if (pclzf_mode_)
return (depth_pclzf_files_.size ());
else
return (depth_image_files_.size ());
return (depth_image_files_.size ());
}

//////////////////////// GrabberBase //////////////////////
Expand Down Expand Up @@ -996,10 +992,7 @@ pcl::ImageGrabberBase::getCloudAt (size_t idx,
bool
pcl::ImageGrabberBase::atLastFrame () const
{
if (impl_->cur_frame_ == numFrames () - 1)
return (true);
else
return (false);
return (impl_->cur_frame_ == numFrames () - 1);
}

//////////////////////////////////////////////////////////////////////////////////////////
Expand Down
51 changes: 24 additions & 27 deletions io/src/obj_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,35 +221,32 @@ pcl::MTLReader::read (const std::string& mtl_file_path)
materials_.clear ();
return (-1);
}
else
{
pcl::TexMaterial::RGB *rgb = &materials_.back ().tex_Ka;
if (st[0] == "Kd")
rgb = &materials_.back ().tex_Kd;
else if (st[0] == "Ks")
rgb = &materials_.back ().tex_Ks;
pcl::TexMaterial::RGB *rgb = &materials_.back ().tex_Ka;
if (st[0] == "Kd")
rgb = &materials_.back ().tex_Kd;
else if (st[0] == "Ks")
rgb = &materials_.back ().tex_Ks;

if (st[1] == "xyz")
if (st[1] == "xyz")
{
if (fillRGBfromXYZ (st, *rgb))
{
if (fillRGBfromXYZ (st, *rgb))
{
PCL_ERROR ("[pcl::MTLReader::read] Could not convert %s to RGB values",
line.c_str ());
mtl_file.close ();
materials_.clear ();
return (-1);
}
PCL_ERROR ("[pcl::MTLReader::read] Could not convert %s to RGB values",
line.c_str ());
mtl_file.close ();
materials_.clear ();
return (-1);
}
else
}
else
{
if (fillRGBfromRGB (st, *rgb))
{
if (fillRGBfromRGB (st, *rgb))
{
PCL_ERROR ("[pcl::MTLReader::read] Could not convert %s to RGB values",
line.c_str ());
mtl_file.close ();
materials_.clear ();
return (-1);
}
PCL_ERROR ("[pcl::MTLReader::read] Could not convert %s to RGB values",
line.c_str ());
mtl_file.close ();
materials_.clear ();
return (-1);
}
}
continue;
Expand Down Expand Up @@ -400,14 +397,14 @@ pcl::OBJReader::readHeader (const std::string &file_name, pcl::PCLPointCloud2 &c
}

// Vertex texture (vt)
else if ((line[1] == 't') && !vertex_texture_found)
if ((line[1] == 't') && !vertex_texture_found)
{
vertex_texture_found = true;
continue;
}

// Vertex normal (vn)
else if ((line[1] == 'n') && !vertex_normal_found)
if ((line[1] == 'n') && !vertex_normal_found)
{
vertex_normal_found = true;
continue;
Expand Down
3 changes: 1 addition & 2 deletions io/src/oni_grabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@ ONIGrabber::getFramesPerSecond () const
{
if (device_->isStreaming())
return (static_cast<float> (device_->getDepthOutputMode ().nFPS));
else
return (0);
return (0);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Loading