geometry.h
Go to the documentation of this file.
1 #pragma once
2 
3 // TODO To be moved to Simox after ROBDEKON demo
4 
5 #include <boost/geometry.hpp>
6 #include <boost/geometry/algorithms/assign.hpp>
7 #include <boost/geometry/algorithms/detail/within/interface.hpp>
8 #include <boost/geometry/algorithms/distance.hpp>
9 #include <boost/geometry/algorithms/make.hpp>
10 #include <boost/geometry/geometries/point_xy.hpp>
11 #include <boost/geometry/geometries/polygon.hpp>
12 #include <boost/geometry/geometries/register/point.hpp>
13 #include <boost/geometry/strategies/strategies.hpp>
14 
15 #include <VirtualRobot/MathTools.h>
16 
17 BOOST_GEOMETRY_REGISTER_POINT_2D(Eigen::Vector2f, float, cs::cartesian, x(), y())
18 
19 namespace armarx::geometry
20 {
21  namespace bg = boost::geometry;
22 
23  class ConvexHull
24  {
25  public:
26  using Point = bg::model::d2::point_xy<float>;
27 
28  ConvexHull(const VirtualRobot::MathTools::ConvexHull2D& hull) : ConvexHull(hull.vertices)
29  {
30  }
31 
32  ConvexHull(const std::vector<Eigen::Vector2f>& hull)
33  {
34  boost::geometry::assign_points(polygon, hull);
35  }
36 
37  bool contains(const Eigen::Vector2f& point) const
38  {
39  return bg::within(Point(point.x(), point.y()), polygon);
40  }
41 
42  float area() const
43  {
44  return static_cast<float>(bg::area(polygon));
45  }
46 
47  private:
48  bg::model::polygon<Point> polygon;
49  };
50 
51  // inline float area()
52  // {
53 
54  // return bg::area(polygon);
55  // }
56 
57 } // namespace armarx::geometry
armarx::armem::contains
bool contains(const MemoryID &general, const MemoryID &specific)
Indicates whether general is "less specific" than, or equal to, specific, i.e.
Definition: MemoryID.cpp:558
Point
Definition: PointCloud.h:21
visionx::Point
Eigen::Vector3f Point
Definition: ObjectShapeClassification.h:69
ConvexHull
Definition: convexHull.hpp:366
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28