MRSL DecompUtil Library  0.1
An implementaion of convex decomposition over point cloud
decomp_base.h
Go to the documentation of this file.
1 
5 #ifndef DECOMP_BASE_H
6 #define DECOMP_BASE_H
7 
9 #include <decomp_geometry/polyhedron.h>
10 //#include <decomp_geometry/geometry_utils.h>
11 
17 template <int Dim>
18 class DecompBase {
19  public:
28  void set_local_bbox(const Vecf<Dim>& bbox) {
29  local_bbox_ = bbox;
30  }
31 
33  void set_obs(const vec_Vecf<Dim> &obs) {
34  // only consider points inside local bbox
35  Polyhedron<Dim> vs;
36  add_local_bbox(vs);
37  obs_ = vs.points_inside(obs);
38  }
39 
41  vec_Vecf<Dim> get_obs() const { return obs_; }
42 
45 
48 
53  virtual void dilate(decimal_t radius = 0) = 0;
54 
59  virtual void shrink(double shrink_distance) {}
60  protected:
61  virtual void add_local_bbox(Polyhedron<Dim> &Vs) = 0;
62 
63  void find_polyhedron() {
64  //**** find half-space
65  Polyhedron<Dim> Vs;
66  vec_Vecf<Dim> obs_remain = obs_;
67  while (!obs_remain.empty()) {
68  const auto v = ellipsoid_.closest_hyperplane(obs_remain);
69  Vs.add(v);
70  vec_Vecf<Dim> obs_tmp;
71  for (const auto &it : obs_remain) {
72  if (v.signed_dist(it) < 0)
73  obs_tmp.push_back(it);
74  }
75  obs_remain = obs_tmp;
76  /*
77  std::cout << "a: " << a.transpose() << std::endl;
78  std::cout << "b: " << b << std::endl;
79  */
80  }
81 
82  polyhedron_ = Vs;
83  }
84 
87 
92 
95 };
96 #endif
vec_E< Vecf< N >> vec_Vecf
Vector of Eigen 1D float vector.
Definition: data_type.h:69
Line Segment Class.
Definition: decomp_base.h:18
void set_local_bbox(const Vecf< Dim > &bbox)
Adding local bounding box around line seg.
Definition: decomp_base.h:28
Vecf< Dim > local_bbox_
Local bounding box along the line segment.
Definition: decomp_base.h:94
Ellipsoid class.
vec_Vecf< Dim > get_obs() const
Get obstacel points.
Definition: decomp_base.h:41
void set_obs(const vec_Vecf< Dim > &obs)
Import obstacle points.
Definition: decomp_base.h:33
Polyhedron< Dim > polyhedron_
Output polyhedron.
Definition: decomp_base.h:91
Polyhedron class.
Definition: polyhedron.h:41
Ellipsoid< Dim > get_ellipsoid() const
Get ellipsoid.
Definition: decomp_base.h:44
Definition: ellipsoid.h:14
void add(const Hyperplane< Dim > &v)
Append Hyperplane.
Definition: polyhedron.h:49
vec_Vecf< Dim > points_inside(const vec_Vecf< Dim > &O) const
Calculate points inside polyhedron, non-exclusive.
Definition: polyhedron.h:65
vec_Vecf< Dim > obs_
Obstacles, input.
Definition: decomp_base.h:86
DecompBase()
Null constructor.
Definition: decomp_base.h:21
double decimal_t
Rename the float type used in lib.
Definition: data_type.h:50
virtual void shrink(double shrink_distance)
Shrink the polyhedron.
Definition: decomp_base.h:59
Polyhedron< Dim > get_polyhedron() const
Get polyhedron.
Definition: decomp_base.h:47
Eigen::Matrix< decimal_t, N, 1 > Vecf
Eigen 1D float vector.
Definition: data_type.h:57
virtual void dilate(decimal_t radius=0)=0
Inflate the line segment.
Ellipsoid< Dim > ellipsoid_
Output ellipsoid.
Definition: decomp_base.h:89