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 [sample_consensus, search, segmentation, stereo, surface] #3185

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
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ pcl::SampleConsensusModelCircle3D<PointT>::isSampleGood (
p1 -= p0;
p2 -= p0;

if (p1.dot (p2) < 0.000001)
return (true);
else
return (false);
return (p1.dot (p2) < 0.000001);
}

//////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 2 additions & 4 deletions search/include/pcl/search/impl/brute_force.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ pcl::search::BruteForce<PointT>::nearestKSearch (

if (input_->is_dense)
return denseKSearch (point, k, k_indices, k_distances);
else
return sparseKSearch (point, k, k_indices, k_distances);
return sparseKSearch (point, k, k_indices, k_distances);
}

//////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -345,8 +344,7 @@ pcl::search::BruteForce<PointT>::radiusSearch (

if (input_->is_dense)
return denseRadiusSearch (point, radius, k_indices, k_sqr_distances, max_nn);
else
return sparseRadiusSearch (point, radius, k_indices, k_sqr_distances, max_nn);
return sparseRadiusSearch (point, radius, k_indices, k_sqr_distances, max_nn);
}

#define PCL_INSTANTIATE_BruteForce(T) template class PCL_EXPORTS pcl::search::BruteForce<T>;
Expand Down
20 changes: 7 additions & 13 deletions search/include/pcl/search/impl/search.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,12 @@ pcl::search::Search<PointT>::nearestKSearch (
assert (index >= 0 && index < static_cast<int> (input_->points.size ()) && "Out-of-bounds error in nearestKSearch!");
return (nearestKSearch (input_->points[index], k, k_indices, k_sqr_distances));
}
else
{
assert (index >= 0 && index < static_cast<int> (indices_->size ()) && "Out-of-bounds error in nearestKSearch!");
if (index >= static_cast<int> (indices_->size ()) || index < 0)
return (0);
return (nearestKSearch (input_->points[(*indices_)[index]], k, k_indices, k_sqr_distances));
}
assert (index >= 0 && index < static_cast<int> (indices_->size ()) && "Out-of-bounds error in nearestKSearch!");
if (index >= static_cast<int> (indices_->size ()) || index < 0)
return (0);
return (nearestKSearch (input_->points[(*indices_)[index]], k, k_indices, k_sqr_distances));
}

///////////////////////////////////////////////////////////////////////////////////////////
template <typename PointT> void
pcl::search::Search<PointT>::nearestKSearch (
Expand Down Expand Up @@ -156,11 +153,8 @@ pcl::search::Search<PointT>::radiusSearch (
assert (index >= 0 && index < static_cast<int> (input_->points.size ()) && "Out-of-bounds error in radiusSearch!");
return (radiusSearch (input_->points[index], radius, k_indices, k_sqr_distances, max_nn));
}
else
{
assert (index >= 0 && index < static_cast<int> (indices_->size ()) && "Out-of-bounds error in radiusSearch!");
return (radiusSearch (input_->points[(*indices_)[index]], radius, k_indices, k_sqr_distances, max_nn));
}
assert (index >= 0 && index < static_cast<int> (indices_->size ()) && "Out-of-bounds error in radiusSearch!");
return (radiusSearch (input_->points[(*indices_)[index]], radius, k_indices, k_sqr_distances, max_nn));
}

///////////////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion search/include/pcl/search/organized.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ namespace pcl
queue.push (Entry (index, squared_distance));
return queue.size () == k;
}
else if (queue.top ().distance > squared_distance)
if (queue.top ().distance > squared_distance)
{
queue.pop ();
queue.push (Entry (index, squared_distance));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ pcl::OrganizedConnectedComponentSegmentation<PointT, PointLT>::segment (pcl::Poi
{
if (!std::isfinite (input_->points[colIdx].x))
continue;
else if (compare_->compare (colIdx, colIdx - 1 ))
if (compare_->compare (colIdx, colIdx - 1 ))
{
labels[colIdx].label = labels[colIdx - 1].label;
}
Expand Down
9 changes: 3 additions & 6 deletions segmentation/include/pcl/segmentation/impl/random_walker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,9 @@ namespace pcl
{
return bimap.right.at (value);
}
else
{
size_t s = bimap.size ();
bimap.insert (typename boost::bimap<size_t, T>::value_type (s, value));
return s;
}
size_t s = bimap.size ();
bimap.insert (typename boost::bimap<size_t, T>::value_type (s, value));
return s;
}

Graph& g_;
Expand Down
18 changes: 6 additions & 12 deletions stereo/include/pcl/stereo/stereo_matching.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,7 @@ namespace pcl
int den = (s1+s3-2*s2);
if (den != 0)
return (static_cast<short int> (16*dbest + (((s1 - s3)*8) / den)));
else
return (static_cast<short int> (dbest*16));
return (static_cast<short int> (dbest*16));
}

inline short int
Expand All @@ -278,8 +277,7 @@ namespace pcl
float den = (s1+s3-2*s2);
if (den != 0)
return (static_cast<short int> (16*dbest + floor(.5 + (((s1 - s3)*8) / den))));
else
return (static_cast<short int> (dbest*16));
return (static_cast<short int> (dbest*16));
}

inline short int
Expand All @@ -297,8 +295,7 @@ namespace pcl

if (sad_min * precision > (precision - ratio_filter) * sad_second_min)
return (-2);
else
return (dbest);
return (dbest);
}

inline short int
Expand All @@ -316,8 +313,7 @@ namespace pcl

if (sad_min * static_cast<float> (precision) > static_cast<float> (precision - ratio_filter) * sad_second_min)
return (-2);
else
return (dbest);
return (dbest);
}

inline short int
Expand All @@ -328,8 +324,7 @@ namespace pcl

if (da + db < peak_filter)
return (-4);
else
return (dbest);
return (dbest);
}

inline short int
Expand All @@ -340,8 +335,7 @@ namespace pcl

if (da + db < peak_filter)
return (-4);
else
return (dbest);
return (dbest);
}

};
Expand Down
27 changes: 11 additions & 16 deletions surface/include/pcl/surface/gp3.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,16 @@ namespace pcl
}
if (intersection_outside_XR)
return true;
else
{
if (S1[0] > S2[0])
return (x <= S2[0]) || (x >= S1[0]);
else if (S1[0] < S2[0])
return (x >= S2[0]) || (x <= S1[0]);
else if (S1[1] > S2[1])
return (y <= S2[1]) || (y >= S1[1]);
else if (S1[1] < S2[1])
return (y >= S2[1]) || (y <= S1[1]);
else
return false;
}
}
if (S1[0] > S2[0])
return (x <= S2[0]) || (x >= S1[0]);
if (S1[0] < S2[0])
return (x >= S2[0]) || (x <= S1[0]);
if (S1[1] > S2[1])
return (y <= S2[1]) || (y >= S1[1]);
if (S1[1] < S2[1])
return (y >= S2[1]) || (y <= S1[1]);
return false;
}

/** \brief GreedyProjectionTriangulation is an implementation of a greedy triangulation algorithm for 3D points
* based on local 2D projections. It assumes locally smooth surfaces and relatively smooth transitions between
Expand Down Expand Up @@ -515,8 +511,7 @@ namespace pcl
{
if (a1.visible == a2.visible)
return (a1.angle < a2.angle);
else
return a1.visible;
return a1.visible;
}
};

Expand Down
51 changes: 24 additions & 27 deletions surface/include/pcl/surface/impl/gp3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,37 +239,34 @@ pcl::GreedyProjectionTriangulation<PointInT>::reconstructPolygons (std::vector<p
while ((left < nnn_) && ((!angles_[left].visible) || (state_[nnIdx[left]] > FREE))) left++;
if (left >= nnn_)
break;
else
int right = left+1;
do
{
int right = left+1;
do
while ((right < nnn_) && ((!angles_[right].visible) || (state_[nnIdx[right]] > FREE))) right++;
if (right >= nnn_)
break;
if ((coords_[nnIdx[left]] - coords_[nnIdx[right]]).squaredNorm () > sqr_max_edge)
right++;
else
{
while ((right < nnn_) && ((!angles_[right].visible) || (state_[nnIdx[right]] > FREE))) right++;
if (right >= nnn_)
break;
else if ((coords_[nnIdx[left]] - coords_[nnIdx[right]]).squaredNorm () > sqr_max_edge)
right++;
else
{
addFringePoint (nnIdx[right], R_);
addFringePoint (nnIdx[left], nnIdx[right]);
addFringePoint (R_, nnIdx[left]);
state_[R_] = state_[nnIdx[left]] = state_[nnIdx[right]] = FRINGE;
ffn_[R_] = nnIdx[left];
sfn_[R_] = nnIdx[right];
ffn_[nnIdx[left]] = nnIdx[right];
sfn_[nnIdx[left]] = R_;
ffn_[nnIdx[right]] = R_;
sfn_[nnIdx[right]] = nnIdx[left];
addTriangle (R_, nnIdx[left], nnIdx[right], polygons);
nr_parts++;
not_found = false;
break;
}
addFringePoint (nnIdx[right], R_);
addFringePoint (nnIdx[left], nnIdx[right]);
addFringePoint (R_, nnIdx[left]);
state_[R_] = state_[nnIdx[left]] = state_[nnIdx[right]] = FRINGE;
ffn_[R_] = nnIdx[left];
sfn_[R_] = nnIdx[right];
ffn_[nnIdx[left]] = nnIdx[right];
sfn_[nnIdx[left]] = R_;
ffn_[nnIdx[right]] = R_;
sfn_[nnIdx[right]] = nnIdx[left];
addTriangle (R_, nnIdx[left], nnIdx[right], polygons);
nr_parts++;
not_found = false;
break;
}
while (true);
left++;
}
while (true);
left++;
}
while (not_found);
}
Expand Down
46 changes: 21 additions & 25 deletions surface/include/pcl/surface/impl/grid_projection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ pcl::GridProjection<PointNT>::createSurfaceForCell (const Eigen::Vector3i &index
if (cell_hash_map_.find (index_1d) == cell_hash_map_.end () ||
occupied_cell_list_[index_1d] == 0)
return;
else
vector_at_pts[i] = cell_hash_map_.at (index_1d).vect_at_grid_pt;
vector_at_pts[i] = cell_hash_map_.at (index_1d).vect_at_grid_pt;
}

// Go through the 3 edges, test whether they are intersected by the surface
Expand Down Expand Up @@ -525,32 +524,29 @@ pcl::GridProjection<PointNT>::findIntersection (int level,
intersection = start_pt;
return;
}
else
vec.normalize ();
if (vec.dot (vect_at_end_pts[0]) < 0)
{
vec.normalize ();
if (vec.dot (vect_at_end_pts[0]) < 0)
{
Eigen::Vector4f new_start_pt = end_pts[0] + (start_pt - end_pts[0]) * 0.5;
new_end_pts[0] = end_pts[0];
new_end_pts[1] = start_pt;
new_vect_at_end_pts[0] = vect_at_end_pts[0];
new_vect_at_end_pts[1] = vec;
findIntersection (level + 1, new_end_pts, new_vect_at_end_pts, new_start_pt, pt_union_indices, intersection);
return;
}
if (vec.dot (vect_at_end_pts[1]) < 0)
{
Eigen::Vector4f new_start_pt = start_pt + (end_pts[1] - start_pt) * 0.5;
new_end_pts[0] = start_pt;
new_end_pts[1] = end_pts[1];
new_vect_at_end_pts[0] = vec;
new_vect_at_end_pts[1] = vect_at_end_pts[1];
findIntersection (level + 1, new_end_pts, new_vect_at_end_pts, new_start_pt, pt_union_indices, intersection);
return;
}
intersection = start_pt;
Eigen::Vector4f new_start_pt = end_pts[0] + (start_pt - end_pts[0]) * 0.5;
new_end_pts[0] = end_pts[0];
new_end_pts[1] = start_pt;
new_vect_at_end_pts[0] = vect_at_end_pts[0];
new_vect_at_end_pts[1] = vec;
findIntersection (level + 1, new_end_pts, new_vect_at_end_pts, new_start_pt, pt_union_indices, intersection);
return;
}
if (vec.dot (vect_at_end_pts[1]) < 0)
{
Eigen::Vector4f new_start_pt = start_pt + (end_pts[1] - start_pt) * 0.5;
new_end_pts[0] = start_pt;
new_end_pts[1] = end_pts[1];
new_vect_at_end_pts[0] = vec;
new_vect_at_end_pts[1] = vect_at_end_pts[1];
findIntersection (level + 1, new_end_pts, new_vect_at_end_pts, new_start_pt, pt_union_indices, intersection);
return;
}
intersection = start_pt;
return;
}


Expand Down
5 changes: 1 addition & 4 deletions surface/include/pcl/surface/impl/texture_mapping.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,7 @@ pcl::TextureMapping<PointInT>::isPointOccluded (const PointInT &pt, OctreePtr oc
}
}

if (nbocc == 0)
return (false);
else
return (true);
return (nbocc != 0);
}

///////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion surface/src/ear_clipping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pcl::EarClipping::triangulate (const Vertices& vertices, PolygonMesh& output)

if (n_vertices < 3)
return;
else if (n_vertices == 3)
if (n_vertices == 3)
{
output.polygons.push_back( vertices );
return;
Expand Down
16 changes: 6 additions & 10 deletions surface/src/on_nurbs/fitting_curve_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,16 +478,12 @@ FittingCurve2d::inverseMapping (const ON_NurbsCurve &nurbs, const Eigen::Vector2
return current;

}
else
{
current += delta;

if (current < minU)
current = minU;
if (current > maxU)
current = maxU;
}
current += delta;

if (current < minU)
current = minU;
if (current > maxU)
current = maxU;
}

error = r.norm ();
Expand Down Expand Up @@ -702,7 +698,7 @@ FittingCurve2d::findClosestElementMidPoint (const ON_NurbsCurve &nurbs, const Ei

if (d_shortest_hint < d_shortest_elem)
return hint;
else

return param;
}

Expand Down
Loading