Choreonoid  1.1
ColdetModel.h
[詳解]
1 
5 #ifndef CNOID_COLDET_MODEL_H_INCLUDED
6 #define CNOID_COLDET_MODEL_H_INCLUDED
7 
8 #include <string>
9 #include <vector>
10 #include <cnoid/EigenTypes>
11 #include <cnoid/Referenced>
12 #include "exportdecl.h"
13 
14 namespace IceMaths {
15  class Matrix4x4;
16 }
17 
18 namespace cnoid {
19 
20  class ColdetModelSharedDataSet;
21 
23  {
24  public:
25  enum PrimitiveType { SP_MESH, SP_BOX, SP_CYLINDER, SP_CONE, SP_SPHERE, SP_PLANE };
26 
30  ColdetModel();
31 
37  ColdetModel(const ColdetModel& org);
38 
42  virtual ~ColdetModel();
43 
48  inline void setName(const std::string& name) { name_ = name; }
49 
54  inline const std::string& name() const { return name_; }
55 
60  void setNumVertices(int n);
61 
66  int getNumVertices() const;
67 
72  void setNumTriangles(int n);
73 
74  int getNumTriangles() const;
75 
83  void setVertex(int index, float x, float y, float z);
84 
88  void addVertex(float x, float y, float z);
89 
97  void getVertex(int index, float& out_x, float& out_y, float& out_z) const;
98 
106  void setTriangle(int index, int v1, int v2, int v3);
107 
111  void addTriangle(int v1, int v2, int v3);
112 
113  void getTriangle(int index, int& out_v1, int& out_v2, int& out_v3) const;
114 
120  void build();
121 
126  inline bool isValid() const { return isValid_; }
127 
133  void setPosition(const Matrix3& R, const Vector3& p);
134 
140  void setPosition(const double* R, const double* p);
141 
146  void setPrimitiveType(PrimitiveType ptype);
147 
152  PrimitiveType getPrimitiveType() const;
153 
158  void setNumPrimitiveParams(unsigned int nparam);
159 
166  bool setPrimitiveParam(unsigned int index, float value);
167 
174  bool getPrimitiveParam(unsigned int index, float &value) const;
175 
181  void setPrimitivePosition(const double* R, const double* p);
182 
189  double computeDistanceWithRay(const double *point, const double *dir);
190 
197  bool checkCollisionWithPointCloud(const std::vector<Vector3> &i_cloud,
198  double i_radius);
199 
200  void getBoundingBoxData(const int depth, std::vector<Vector3>& out_boxes);
201 
202  int getAABBTreeDepth();
203  int getAABBmaxNum();
204  int numofBBtoDepth(int minNumofBB);
205 
206  private:
210  void initialize();
211 
212  ColdetModelSharedDataSet* dataSet;
213  IceMaths::Matrix4x4* transform;
214  IceMaths::Matrix4x4* pTransform;
215  std::string name_;
216  bool isValid_;
217 
218  friend class ColdetModelPair;
219  };
220 
221  typedef boost::intrusive_ptr<ColdetModel> ColdetModelPtr;
222 }
223 
224 
225 #endif
PrimitiveType
Definition: ColdetModel.h:25
boost::intrusive_ptr< ColdetModel > ColdetModelPtr
Definition: ColdetModel.h:221
Definition: Referenced.h:21
Definition: ColdetModel.h:25
Definition: ColdetModel.h:22
Definition: ColdetModelPair.h:17
bool isValid() const
check if build() is already called or not
Definition: ColdetModel.h:126
Definition: ColdetModelSharedDataSet.h:17
void setName(const std::string &name)
set name of this model
Definition: ColdetModel.h:48
Eigen::Vector3d Vector3
Definition: EigenTypes.h:26
#define CNOID_EXPORT
Definition: Util/exportdecl.h:13
bool initialize()
const std::string & name() const
get name of this model
Definition: ColdetModel.h:54
Eigen::Matrix3d Matrix3
Definition: EigenTypes.h:25