Choreonoid  1.5
ColdetModel.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_COLDET_MODEL_H_INCLUDED
6 #define CNOID_COLDET_MODEL_H_INCLUDED
7 
8 #include <cnoid/EigenTypes>
9 #include <boost/shared_ptr.hpp>
10 #include <string>
11 #include <vector>
12 #include "exportdecl.h"
13 
14 namespace IceMaths {
15 class Matrix4x4;
16 }
17 
18 namespace cnoid {
19 
21 typedef boost::shared_ptr<ColdetModel> ColdetModelPtr;
22 
24 
26 {
27 public:
28  enum PrimitiveType { SP_MESH, SP_BOX, SP_CYLINDER, SP_CONE, SP_SPHERE, SP_PLANE };
29 
33  ColdetModel();
34 
40  ColdetModel(const ColdetModel& org);
41 
45  virtual ~ColdetModel();
46 
47  virtual ColdetModelPtr clone() const;
48 
49  void cloneInternalModel();
50 
55  void setName(const std::string& name) { name_ = name; }
56 
61  const std::string& name() const { return name_; }
62 
67  void setNumVertices(int n);
68 
73  int getNumVertices() const;
74 
79  void setNumTriangles(int n);
80 
81  int getNumTriangles() const;
82 
90  void setVertex(int index, float x, float y, float z);
91 
95  void addVertex(float x, float y, float z);
96 
104  void getVertex(int index, float& out_x, float& out_y, float& out_z) const;
105 
113  void setTriangle(int index, int v1, int v2, int v3);
114 
118  void addTriangle(int v1, int v2, int v3);
119 
120  void getTriangle(int index, int& out_v1, int& out_v2, int& out_v3) const;
121 
127  void build();
128 
133  bool isValid() const { return isValid_; }
134 
135 #ifdef CNOID_BACKWARD_COMPATIBILITY
136 
141  void setPosition(const Matrix3& R, const Vector3& p);
142 #endif
143  void setPosition(const Position& T);
144 
150  void setPosition(const double* R, const double* p);
151 
156  void setPrimitiveType(PrimitiveType ptype);
157 
162  PrimitiveType getPrimitiveType() const;
163 
168  void setNumPrimitiveParams(unsigned int nparam);
169 
176  bool setPrimitiveParam(unsigned int index, float value);
177 
184  bool getPrimitiveParam(unsigned int index, float &value) const;
185 
191  void setPrimitivePosition(const double* R, const double* p);
192 
199  double computeDistanceWithRay(const double *point, const double *dir);
200 
207  bool checkCollisionWithPointCloud(const std::vector<Vector3> &i_cloud,
208  double i_radius);
209 
210  void getBoundingBoxData(const int depth, std::vector<Vector3>& out_boxes);
211 
212  int getAABBTreeDepth();
213  int getAABBmaxNum();
214  int numofBBtoDepth(int minNumofBB);
215 
216 private:
217  void initialize();
218 
219  ColdetModelInternalModel* internalModel;
220  IceMaths::Matrix4x4* transform;
221  IceMaths::Matrix4x4* pTransform;
222  std::string name_;
223  bool isValid_;
224 
225  friend class ColdetModelPair;
226 };
227 }
228 
229 
230 #endif
PrimitiveType
Definition: ColdetModel.h:28
Definition: ColdetModelInternalModel.h:14
Definition: ColdetModel.h:28
Definition: ColdetModel.h:25
Eigen::Transform< double, 3, Eigen::AffineCompact > Position
Definition: EigenTypes.h:73
Definition: ColdetModelPair.h:15
bool isValid() const
check if build() is already called or not
Definition: ColdetModel.h:133
Defines the minimum processing for performing pasing file for STL.
Definition: AbstractSceneLoader.h:9
boost::shared_ptr< ColdetModel > ColdetModelPtr
Definition: ColdetModel.h:20
void setName(const std::string &name)
set name of this model
Definition: ColdetModel.h:55
Eigen::Vector3d Vector3
Definition: EigenTypes.h:58
Definition: ColdetModel.h:14
#define CNOID_EXPORT
Definition: Util/exportdecl.h:37
PROPERTIES INSTALL_RPATH lib dir
Definition: OpenRTMPlugin/CMakeLists.txt:139
const std::string & name() const
get name of this model
Definition: ColdetModel.h:61
Eigen::Matrix3d Matrix3
Definition: EigenTypes.h:57