Choreonoid  1.8
ColdetModel.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_AIST_COLLISION_DETECTOR_COLDET_MODEL_H
6 #define CNOID_AIST_COLLISION_DETECTOR_COLDET_MODEL_H
7 
8 #include <cnoid/Referenced>
9 #include <cnoid/EigenTypes>
10 #include <string>
11 #include <vector>
12 #include "exportdecl.h"
13 
14 namespace IceMaths {
15 class Matrix4x4;
16 }
17 
18 namespace cnoid {
19 
20 class ColdetModelInternalModel;
21 
22 class CNOID_EXPORT ColdetModel : public Referenced
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 
44  virtual ColdetModel* clone() const;
45 
46  void cloneInternalModel();
47 
52  void setName(const std::string& name) { name_ = name; }
53 
58  const std::string& name() const { return name_; }
59 
64  void setNumVertices(int n);
65 
70  int getNumVertices() const;
71 
76  void setNumTriangles(int n);
77 
78  int getNumTriangles() const;
79 
87  void setVertex(int index, float x, float y, float z);
88 
92  void addVertex(float x, float y, float z);
93 
101  void getVertex(int index, float& out_x, float& out_y, float& out_z) const;
102 
110  void setTriangle(int index, int v1, int v2, int v3);
111 
115  void addTriangle(int v1, int v2, int v3);
116 
117  void getTriangle(int index, int& out_v1, int& out_v2, int& out_v3) const;
118 
124  void build();
125 
130  bool isValid() const { return isValid_; }
131 
132 #ifdef CNOID_BACKWARD_COMPATIBILITY
133 
138  void setPosition(const Matrix3& R, const Vector3& p);
139 #endif
140  void setPosition(const Isometry3& T);
141 
147  void setPosition(const double* R, const double* p);
148 
153  void setPrimitiveType(PrimitiveType ptype);
154 
159  PrimitiveType getPrimitiveType() const;
160 
165  void setNumPrimitiveParams(unsigned int nparam);
166 
173  bool setPrimitiveParam(unsigned int index, float value);
174 
181  bool getPrimitiveParam(unsigned int index, float &value) const;
182 
188  void setPrimitivePosition(const double* R, const double* p);
189 
196  double computeDistanceWithRay(const double *point, const double *dir);
197 
204  bool checkCollisionWithPointCloud(const std::vector<Vector3> &i_cloud,
205  double i_radius);
206 
207  void getBoundingBoxData(const int depth, std::vector<Vector3>& out_boxes);
208 
209  int getAABBTreeDepth();
210  int getAABBmaxNum();
211  int numofBBtoDepth(int minNumofBB);
212 
213 private:
214  void initialize();
215 
216  ColdetModelInternalModel* internalModel;
217  IceMaths::Matrix4x4* transform;
218  IceMaths::Matrix4x4* pTransform;
219  std::string name_;
220  bool isValid_;
221 
222  friend class ColdetModelPair;
223 };
224 
226 
227 }
228 
229 #endif
cnoid::Vector3
Eigen::Vector3d Vector3
Definition: EigenTypes.h:57
cnoid::ColdetModel::setName
void setName(const std::string &name)
set name of this model
Definition: ColdetModel.h:52
cnoid::Isometry3
Eigen::Isometry3d Isometry3
Definition: EigenTypes.h:73
cnoid::ColdetModel
Definition: ColdetModel.h:22
cnoid::ColdetModel::SP_SPHERE
@ SP_SPHERE
Definition: ColdetModel.h:25
cnoid::Matrix3
Eigen::Matrix3d Matrix3
Definition: EigenTypes.h:56
cnoid::ColdetModelInternalModel
Definition: ColdetModelInternalModel.h:14
cnoid::ref_ptr< ColdetModel >
cnoid::ColdetModelPair
Definition: ColdetModelPair.h:15
cnoid::ColdetModel::name
const std::string & name() const
get name of this model
Definition: ColdetModel.h:58
cnoid::ColdetModel::isValid
bool isValid() const
check if build() is already called or not
Definition: ColdetModel.h:130
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::ColdetModel::PrimitiveType
PrimitiveType
Definition: ColdetModel.h:25
cnoid::Referenced
Definition: Referenced.h:54
cnoid::ColdetModelPtr
ref_ptr< ColdetModel > ColdetModelPtr
Definition: ColdetModel.h:225