data_types.h 3.67 KB
Newer Older
jpan's avatar
jpan committed
1
2
3
/*
 * Software License Agreement (BSD License)
 *
4
5
 *  Copyright (c) 2011-2014, Willow Garage, Inc.
 *  Copyright (c) 2014-2015, Open Source Robotics Foundation
jpan's avatar
jpan committed
6
7
8
9
10
11
12
13
14
15
16
17
 *  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above
 *     copyright notice, this list of conditions and the following
 *     disclaimer in the documentation and/or other materials provided
 *     with the distribution.
18
 *   * Neither the name of Open Source Robotics Foundation nor the names of its
jpan's avatar
jpan committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 *  POSSIBILITY OF SUCH DAMAGE.
 */

/** \author Jia Pan */

Joseph Mirabel's avatar
Joseph Mirabel committed
38
39
#ifndef HPP_FCL_DATA_TYPES_H
#define HPP_FCL_DATA_TYPES_H
jpan's avatar
jpan committed
40

41
#include <cstddef>
isucan's avatar
isucan committed
42
#include <boost/cstdint.hpp>
jpan's avatar
jpan committed
43

44
45
46
#include <Eigen/Core>
#include <Eigen/Geometry>

Lucile Remigy's avatar
Lucile Remigy committed
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

namespace hpp
{

#ifdef HPP_FCL_HAVE_OCTOMAP
  #define OCTOMAP_VERSION_AT_LEAST(x,y,z) \
    (OCTOMAP_MAJOR_VERSION > x || (OCTOMAP_MAJOR_VERSION >= x && \
    (OCTOMAP_MINOR_VERSION > y || (OCTOMAP_MINOR_VERSION >= y && \
    OCTOMAP_PATCH_VERSION >= z))))

  #define OCTOMAP_VERSION_AT_MOST(x,y,z) \
    (OCTOMAP_MAJOR_VERSION < x || (OCTOMAP_MAJOR_VERSION <= x && \
    (OCTOMAP_MINOR_VERSION < y || (OCTOMAP_MINOR_VERSION <= y && \
    OCTOMAP_PATCH_VERSION <= z))))
#endif // HPP_FCL_HAVE_OCTOMAP
}

64
65
namespace hpp
{
66
67
namespace fcl
{
jpan's avatar
jpan committed
68
typedef double FCL_REAL;
v4hn's avatar
v4hn committed
69
70
71
72
typedef boost::uint64_t FCL_INT64;
typedef boost::int64_t FCL_UINT64;
typedef boost::uint32_t FCL_UINT32;
typedef boost::int32_t FCL_INT32;
Lucile Remigy's avatar
Lucile Remigy committed
73
74
typedef Eigen::Matrix<FCL_REAL, 3, 1> Vec3f;
typedef Eigen::Matrix<FCL_REAL, 3, 3> Matrix3f;
75
typedef Eigen::Vector2i support_func_guess_t;
jpan's avatar
jpan committed
76

77
78
79
80
/// @brief Triangle with 3 indices for points
class Triangle
{
public:
81
82
83
  typedef std::size_t index_type;
  typedef int size_type;

84
85
86
87
  /// @brief Default constructor
  Triangle() {}

  /// @brief Create a triangle with given vertex indices
88
  Triangle(index_type p1, index_type p2, index_type p3)
89
90
91
92
93
  {
    set(p1, p2, p3);
  }

  /// @brief Set the vertex indices of the triangle
94
  inline void set(index_type p1, index_type p2, index_type p3)
95
96
97
98
  {
    vids[0] = p1; vids[1] = p2; vids[2] = p3;
  }

Joseph Mirabel's avatar
Joseph Mirabel committed
99
  /// @brief Access the triangle index
100
  inline index_type operator[](int i) const { return vids[i]; }
101

102
103
104
105
  inline index_type& operator[](int i) { return vids[i]; }

  static inline size_type size() { return 3; }

Joseph Mirabel's avatar
Joseph Mirabel committed
106
107
108
109
110
111
112
  bool operator== (const Triangle& other) const
  {
    return vids[0] == other.vids[0]
      &&   vids[1] == other.vids[1]
      &&   vids[2] == other.vids[2];
  }

113
114
115
private:
  /// @brief indices for each vertex of triangle
  index_type vids[3];
116
117
118
119
};

}

120
121
} // namespace hpp

122

jpan's avatar
jpan committed
123
#endif