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

Simplify boolean expression by DeMorgan's theorem #6129

Merged
merged 5 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion common/include/pcl/range_image/impl/range_image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ RangeImage::isValid (int index) const
bool
RangeImage::isObserved (int x, int y) const
{
return !(!isInImage (x,y) || (std::isinf (getPoint (x,y).range) && getPoint (x,y).range < 0.0f));
return (isInImage (x,y) && (!std::isinf (getPoint (x,y).range) || getPoint (x,y).range >= 0.0f));
}

/////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ bool RangeImageBorderExtractor::calculateMainPrincipalCurvature(int x, int y, in
bool& beam_valid = beams_valid[beam_idx++];
if (step==1)
{
beam_valid = !(x2==x && y2==y);
beam_valid = (x2!=x || y2!=y);
}
else
if (!beam_valid)
Expand Down
2 changes: 1 addition & 1 deletion geometry/include/pcl/geometry/mesh_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@ class MeshBase {
HalfEdgeIndex& /*idx_free_half_edge*/,
std::true_type /*is_manifold*/) const
{
return !(is_new_ab && is_new_bc && !is_isolated_b);
return (!is_new_ab || !is_new_bc || is_isolated_b);
}

/** \brief Check if the half-edge bc is the next half-edge of ab.
Expand Down
2 changes: 1 addition & 1 deletion keypoints/src/brisk_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@ pcl::keypoints::brisk::ScaleSpace::subpixel2D (
return (static_cast<float>(coeff6) / 18.0f);
}

if (!(H_det > 0 && coeff1 < 0))
if (H_det <= 0 || coeff1 >= 0)
{
// The maximum must be at the one of the 4 patch corners.
int tmp_max = coeff3 + coeff4 + coeff5;
Expand Down
6 changes: 3 additions & 3 deletions octree/include/pcl/octree/impl/octree_search.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,9 @@ OctreePointCloudSearch<PointT, LeafContainerT, BranchContainerT>::boxSearchRecur

// test if search region overlap with voxel space

if (!((lower_voxel_corner(0) > max_pt(0)) || (min_pt(0) > upper_voxel_corner(0)) ||
(lower_voxel_corner(1) > max_pt(1)) || (min_pt(1) > upper_voxel_corner(1)) ||
(lower_voxel_corner(2) > max_pt(2)) || (min_pt(2) > upper_voxel_corner(2)))) {
if ((lower_voxel_corner(0) <= max_pt(0)) && (min_pt(0) <= upper_voxel_corner(0)) &&
(lower_voxel_corner(1) <= max_pt(1)) && (min_pt(1) <= upper_voxel_corner(1)) &&
(lower_voxel_corner(2) <= max_pt(2)) && (min_pt(2) <= upper_voxel_corner(2))) {

if (child_node->getNodeType() == BRANCH_NODE) {
// we have not reached maximum tree depth
Expand Down
4 changes: 2 additions & 2 deletions recognition/include/pcl/recognition/ransac_based/bvh.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ namespace pcl
inline bool
intersect(const float box[6]) const
{
return !(box[1] < bounds_[0] || box[3] < bounds_[2] || box[5] < bounds_[4] ||
box[0] > bounds_[1] || box[2] > bounds_[3] || box[4] > bounds_[5]);
return (box[1] >= bounds_[0] && box[3] >= bounds_[2] && box[5] >= bounds_[4] &&
box[0] <= bounds_[1] && box[2] <= bounds_[3] && box[4] <= bounds_[5]);
}

/** \brief Computes and returns the volume of the bounding box of this node. */
Expand Down
4 changes: 2 additions & 2 deletions registration/include/pcl/registration/impl/ndt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -730,8 +730,8 @@ NormalDistributionsTransform<PointSource, PointTarget, Scalar>::computeStepLengt
// the sufficient decrease, Equation 1.1, and curvature condition, Equation 1.2 [More,
// Thuente 1994]
while (!interval_converged && step_iterations < max_step_iterations &&
!(psi_t <= 0 /*Sufficient Decrease*/ &&
d_phi_t <= -nu * d_phi_0 /*Curvature Condition*/)) {
(psi_t > 0 /*Sufficient Decrease*/ ||
d_phi_t > -nu * d_phi_0 /*Curvature Condition*/)) {
// Use auxiliary function if interval I is not closed
if (open_interval) {
a_t = trialValueSelectionMT(a_l, f_l, g_l, a_u, f_u, g_u, a_t, psi_t, d_psi_t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ namespace pcl
int current_label = (*labels_)[idx1].label;
int next_label = (*labels_)[idx2].label;

if (!((*refine_labels_)[current_label] && !(*refine_labels_)[next_label]))
if (!(*refine_labels_)[current_label] || (*refine_labels_)[next_label])
return (false);

const pcl::ModelCoefficients& model_coeff = (*models_)[(*label_to_model_)[current_label]];
Expand Down
2 changes: 1 addition & 1 deletion surface/include/pcl/surface/impl/convex_hull.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pcl::ConvexHull<PointInT>::performReconstruction2D (PointCloud &hull, std::vecto
PointInT p1 = (*input_)[(*indices_)[indices_->size () - 1]];
PointInT p2 = (*input_)[(*indices_)[indices_->size () / 2]];
Eigen::Array4f dy1dy2 = (p1.getArray4fMap () - p0.getArray4fMap ()) / (p2.getArray4fMap () - p0.getArray4fMap ());
while (!( (dy1dy2[0] != dy1dy2[1]) || (dy1dy2[2] != dy1dy2[1]) ) )
while ( (dy1dy2[0] == dy1dy2[1]) && (dy1dy2[2] == dy1dy2[1]) )
DIlkhush00 marked this conversation as resolved.
Show resolved Hide resolved
{
p0 = (*input_)[(*indices_)[rand () % indices_->size ()]];
p1 = (*input_)[(*indices_)[rand () % indices_->size ()]];
Expand Down
2 changes: 1 addition & 1 deletion surface/include/pcl/surface/impl/gp3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ pcl::GreedyProjectionTriangulation<PointInT>::reconstructPolygons (std::vector<p
}
if (inside_CB && !outside_CB)
need_invert = true;
else if (!(!inside_CB && outside_CB))
else if (inside_CB || !outside_CB)
{
if ((angles_[end].angle - angles_[start].angle) < M_PI)
need_invert = true;
Expand Down
2 changes: 1 addition & 1 deletion surface/include/pcl/surface/impl/marching_cubes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ template <typename PointNT> void
pcl::MarchingCubes<PointNT>::performReconstruction (pcl::PointCloud<PointNT> &points,
std::vector<pcl::Vertices> &polygons)
{
if (!(iso_level_ >= 0 && iso_level_ < 1))
if (iso_level_ < 0 || iso_level_ >= 1)
{
PCL_ERROR ("[pcl::%s::performReconstruction] Invalid iso level %f! Please use a number between 0 and 1.\n",
getClassName ().c_str (), iso_level_);
Expand Down
2 changes: 1 addition & 1 deletion test/outofcore/test_outofcore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ AlignedPointTVector points;
bool
compPt (const PointT &p1, const PointT &p2)
{
return !(p1.x != p2.x || p1.y != p2.y || p1.z != p2.z);
return (p1.x == p2.x && p1.y == p2.y && p1.z == p2.z);
}

TEST (PCL, Outofcore_Octree_Build)
Expand Down
Loading