operations.hh 2.56 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//
// Copyright (c) 2016 CNRS
// Authors: Anna Seppala
//
// This file is part of hpp-core
// hpp-core is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// hpp-core is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// General Lesser Public License for more details.  You should have
// received a copy of the GNU Lesser General Public License along with
// hpp-core  If not, see
// <http://www.gnu.org/licenses/>.

#ifndef HPP_AFFORDANCE_OPERATIONS_HH
#define HPP_AFFORDANCE_OPERATIONS_HH

# include <hpp/fcl/math/vec_3f.h>

namespace hpp {
  namespace affordance {

    class OperationBase
    {
      public:
30
        OperationBase (): zWorld_(0,0,1), margin_(0.3), minArea_(0.05), 
31
                          affordance_("noAffordance") {}
Steve Tonneau's avatar
Steve Tonneau committed
32
        explicit OperationBase (const double margin = 0.3, const double minArea = 0.05,
33
                                const char* affordanceName = "noAffordance"): zWorld_(0,0,1), 
34
                                margin_(margin), minArea_(minArea), affordance_(affordanceName) {}
Steve Tonneau's avatar
Steve Tonneau committed
35
        virtual bool requirement (const fcl::Vec3f& normal) =0;
36

37
38
        const fcl::Vec3f zWorld_;
        const double margin_;
39
        const double minArea_;
40
        const char* affordance_;
41
42
43
44
45
    }; // class OperationBase

    class SupportOperation : public OperationBase
    {
      public:
Steve Tonneau's avatar
Steve Tonneau committed
46
47
     explicit SupportOperation (const double margin = 0.3, const double minArea = 0.05,
                                    const char* affordanceName = "Support"):
48
                                    OperationBase(margin, minArea, affordanceName) {}
49

Steve Tonneau's avatar
Steve Tonneau committed
50
        bool requirement (const fcl::Vec3f& normal)
51
      {
Steve Tonneau's avatar
Steve Tonneau committed
52
        return ((zWorld_ - normal).sqrLength() < margin_);
53
54
55
56
57
58
      }
    }; // class SupportOperation
   
    class LeanOperation : public OperationBase
    {
      public:
Steve Tonneau's avatar
Steve Tonneau committed
59
        explicit LeanOperation (const double margin = 0.3, const double minArea = 0.05,
60
61
                                const char* affordanceName = "Lean"): 
                                OperationBase(margin, minArea, affordanceName) {}
Steve Tonneau's avatar
Steve Tonneau committed
62
        bool requirement (const fcl::Vec3f& normal)
63
        {
Steve Tonneau's avatar
Steve Tonneau committed
64
          return (fabs (normal.dot(zWorld_)) < margin_);
65
66
67
68
69
70
71
        }
    }; // class LeanOperation
   
  } // namespace affordance
} // namespace hpp

#endif // HPP_AFFORDANCE_OPERATIONS_HH