From dcb01844458cda3d2401fd3da28d665e80e5ba5d Mon Sep 17 00:00:00 2001 From: Joseph Mirabel <jmirabel@laas.fr> Date: Thu, 18 Aug 2016 17:07:41 +0200 Subject: [PATCH] Fix enum and case validity check in graph helper. --- include/hpp/manipulation/graph/helper.hh | 12 ++++++------ src/graph/helper.cc | 5 ++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/include/hpp/manipulation/graph/helper.hh b/include/hpp/manipulation/graph/helper.hh index fce9ee8..f891610 100644 --- a/include/hpp/manipulation/graph/helper.hh +++ b/include/hpp/manipulation/graph/helper.hh @@ -88,14 +88,14 @@ namespace hpp { }; enum GraspingCase { - NoGrasp = 0, - GraspOnly = 1 << 0, - WithPreGrasp = 1 << 1 + NoGrasp = 1 << 0, + GraspOnly = 1 << 1, + WithPreGrasp = 1 << 2 }; enum PlacementCase { - NoPlace = 1 << 2, - PlaceOnly = 1 << 3, - WithPrePlace = 1 << 4 + NoPlace = 1 << 3, + PlaceOnly = 1 << 4, + WithPrePlace = 1 << 5 }; struct Rule { diff --git a/src/graph/helper.cc b/src/graph/helper.cc index 35ad351..46faba9 100644 --- a/src/graph/helper.cc +++ b/src/graph/helper.cc @@ -118,7 +118,10 @@ namespace hpp { static const bool pregrasp = (gCase & WithPreGrasp); static const bool intersec = !((gCase & NoGrasp) || (gCase & NoPlace)); static const bool preplace = (gCase & WithPrePlace); - static const bool valid = !(gCase == (NoGrasp | NoPlace)); + static const bool valid = + ( (gCase & WithPreGrasp) || (gCase & GraspOnly) || (gCase & NoGrasp) ) + && ( (gCase & WithPrePlace) || (gCase & PlaceOnly) || (gCase & NoPlace) ) + && !(gCase == (NoGrasp | NoPlace)); static const std::size_t nbWaypoints = (pregrasp?1:0) + (intersec?1:0) + (preplace?1:0); static const std::size_t Nnodes = 2 + nbWaypoints; -- GitLab