Choreonoid  1.5
PolyhedralRegion.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_UTIL_POLYHEDRAL_REGION_H
6 #define CNOID_UTIL_POLYHEDRAL_REGION_H
7 
8 #include "EigenTypes.h"
9 #include <vector>
10 
11 namespace cnoid {
12 
14 {
15 public:
17  PolyhedralRegion(const PolyhedralRegion& org) : planes(org.planes) { }
18  PolyhedralRegion& operator=(const PolyhedralRegion& org) { planes = org.planes; }
19 
20  struct Plane {
23  double d;
24  Plane(const Vector3& normal, const Vector3& point) : normal(normal), point(point) {
25  d = normal.dot(point);
26  }
27  };
28 
29  int numBoundingPlanes() const { return planes.size(); }
30 
31  void clear() { planes.clear(); }
32 
34  planes.push_back(Plane(normal, point));
35  }
36 
37  const Plane& plane(int index) const { return planes[index]; }
38 
39  bool checkInside(const Vector3& point) const {
40  for(size_t i=0; i < planes.size(); ++i){
41  const Plane& p = planes[i];
42  if(point.dot(p.normal) - p.d < 0.0){
43  return false;
44  }
45  }
46  return true;
47  }
48 
49 private:
50  std::vector<Plane> planes;
51 };
52 
53 }
54 
55 #endif
PolyhedralRegion(const PolyhedralRegion &org)
Definition: PolyhedralRegion.h:17
Vector3 normal
Definition: PolyhedralRegion.h:21
PolyhedralRegion & operator=(const PolyhedralRegion &org)
Definition: PolyhedralRegion.h:18
Plane(const Vector3 &normal, const Vector3 &point)
Definition: PolyhedralRegion.h:24
const Plane & plane(int index) const
Definition: PolyhedralRegion.h:37
Definition: PolyhedralRegion.h:13
void clear()
Definition: PolyhedralRegion.h:31
Definition: PolyhedralRegion.h:20
Vector3 point
Definition: PolyhedralRegion.h:22
Defines the minimum processing for performing pasing file for STL.
Definition: AbstractSceneLoader.h:9
bool checkInside(const Vector3 &point) const
Definition: PolyhedralRegion.h:39
int numBoundingPlanes() const
Definition: PolyhedralRegion.h:29
Eigen::Vector3d Vector3
Definition: EigenTypes.h:58
double d
Definition: PolyhedralRegion.h:23
void addBoundingPlane(const Vector3 &normal, const Vector3 &point)
Definition: PolyhedralRegion.h:33
PolyhedralRegion()
Definition: PolyhedralRegion.h:16