ColdetModel.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
3  * All rights reserved. This program is made available under the terms of the
4  * Eclipse Public License v1.0 which accompanies this distribution, and is
5  * available at http://www.eclipse.org/legal/epl-v10.html
6  * Contributors:
7  * National Institute of Advanced Industrial Science and Technology (AIST)
8  */
13 #ifndef HRPCOLLISION_COLDET_MODEL_H_INCLUDED
14 #define HRPCOLLISION_COLDET_MODEL_H_INCLUDED
15 
16 #include "config.h"
17 #include <string>
18 #include <hrpUtil/Eigen3d.h>
19 #include <hrpUtil/Referenced.h>
20 #include <vector>
21 #include <map>
22 
23 
24 namespace IceMaths {
25  class Matrix4x4;
26 }
27 
28 namespace hrp {
29 
31  class Edge
32  {
33  int vertex[2];
34  public :
35  Edge(int vertexIndex1, int vertexIndex2){
36  if(vertexIndex1 < vertexIndex2){
37  vertex[0] = vertexIndex1;
38  vertex[1] = vertexIndex2;
39  } else {
40  vertex[0] = vertexIndex2;
41  vertex[1] = vertexIndex1;
42  }
43  }
44  bool operator<(const Edge& rhs) const {
45  if(vertex[0] < rhs.vertex[0]){
46  return true;
47  } else if(vertex[0] == rhs.vertex[0]){
48  return (vertex[1] < rhs.vertex[1]);
49  } else {
50  return false;
51  }
52  }
53  };
54 
55  struct trianglePair {
56  int t[2];
57  };
58 
59  typedef std::map< Edge, trianglePair > EdgeToTriangleMap;
60 
62  {
63  public:
64  enum PrimitiveType { SP_MESH, SP_BOX, SP_CYLINDER, SP_CONE, SP_SPHERE, SP_PLANE };
65 
69  ColdetModel();
70 
76  ColdetModel(const ColdetModel& org);
77 
81  virtual ~ColdetModel();
82 
87  void setName(const std::string& name) { name_ = name; }
88 
93  const std::string& name() const { return name_; }
94 
99  void setNumVertices(int n);
100 
105  int getNumVertices() const;
106 
111  void setNumTriangles(int n);
112 
113  int getNumTriangles() const;
114 
122  void setVertex(int index, float x, float y, float z);
123 
127  void addVertex(float x, float y, float z);
128 
136  void getVertex(int index, float& out_x, float& out_y, float& out_z) const;
137 
145  void setTriangle(int index, int v1, int v2, int v3);
146 
150  void addTriangle(int v1, int v2, int v3);
151 
152  void getTriangle(int index, int& out_v1, int& out_v2, int& out_v3) const;
153 
159  void build();
160 
165  bool isValid() const { return isValid_; }
166 
172  void setPosition(const Matrix33& R, const Vector3& p);
173 
179  void setPosition(const double* R, const double* p);
180 
185  void setPrimitiveType(PrimitiveType ptype);
186 
191  PrimitiveType getPrimitiveType() const;
192 
197  void setNumPrimitiveParams(unsigned int nparam);
198 
205  bool setPrimitiveParam(unsigned int index, float value);
206 
213  bool getPrimitiveParam(unsigned int index, float &value) const;
214 
220  void setPrimitivePosition(const double* R, const double* p);
221 
228  double computeDistanceWithRay(const double *point, const double *dir);
229 
236  bool checkCollisionWithPointCloud(const std::vector<Vector3> &i_cloud,
237  double i_radius);
238 
239  void getBoundingBoxData(const int depth, std::vector<Vector3>& out_boxes);
240 
241  int getAABBTreeDepth();
242  int getAABBmaxNum();
243  int numofBBtoDepth(int minNumofBB);
244 
245  ColdetModelSharedDataSet *getDataSet() { return dataSet; }
246  private:
250  void initialize();
251  void setNeighborTriangle(int triangle, int vertex0, int vertex1, int vertex2);
252  void initNeighbor(int n);
253 
254 
256  IceMaths::Matrix4x4* transform;
257  IceMaths::Matrix4x4* pTransform;
258  std::string name_;
259  bool isValid_;
261 
262  bool setNeighborTriangleSub(int triangle, int vertex0, int vertex1);
263  void setNeighbor(int triangle0, int triangle1);
264 
265  friend class ColdetModelPair;
266  };
267 
268  typedef boost::intrusive_ptr<ColdetModel> ColdetModelPtr;
269 }
270 
271 
272 #endif
hrp::Referenced
Definition: Referenced.h:15
Referenced.h
hrp::ColdetModel
Definition: ColdetModel.h:61
Matrix4x4
Definition: IceMatrix4x4.h:21
config.h
hrp::Edge::vertex
int vertex[2]
Definition: ColdetModel.h:33
autoplay.n
n
Definition: autoplay.py:12
hrp::ColdetModel::triangleMap
EdgeToTriangleMap triangleMap
Definition: ColdetModel.h:260
hrp
Definition: ColdetModel.h:28
hrp::ColdetModel::getDataSet
ColdetModelSharedDataSet * getDataSet()
Definition: ColdetModel.h:245
hrp::trianglePair::t
int t[2]
Definition: ColdetModel.h:56
hrp::Vector3
Eigen::Vector3d Vector3
Definition: EigenTypes.h:11
hrp::Edge
Definition: ColdetModel.h:31
value
png_voidp int value
Definition: png.h:2110
hrp::ColdetModel::name
const std::string & name() const
get name of this model
Definition: ColdetModel.h:93
hrp::Edge::Edge
Edge(int vertexIndex1, int vertexIndex2)
Definition: ColdetModel.h:35
hrp::ColdetModelSharedDataSet
Definition: ColdetModelSharedDataSet.h:29
hrp::Edge::operator<
bool operator<(const Edge &rhs) const
Definition: ColdetModel.h:44
hrp::ColdetModelPair
Definition: ColdetModelPair.h:29
hrp::ColdetModel::transform
IceMaths::Matrix4x4 * transform
Definition: ColdetModel.h:256
name
png_infop png_charpp name
Definition: png.h:2379
hrp::ColdetModel::dataSet
ColdetModelSharedDataSet * dataSet
Definition: ColdetModel.h:255
HRP_COLLISION_EXPORT
#define HRP_COLLISION_EXPORT
Definition: hrplib/hrpCollision/config.h:26
hrp::trianglePair
Definition: ColdetModel.h:55
hrp::ColdetModel::isValid
bool isValid() const
check if build() is already called or not
Definition: ColdetModel.h:165
hrp::ColdetModel::PrimitiveType
PrimitiveType
Definition: ColdetModel.h:64
hrp::Matrix33
Eigen::Matrix3d Matrix33
Definition: EigenTypes.h:12
hrp::ColdetModel::isValid_
bool isValid_
Definition: ColdetModel.h:259
Eigen3d.h
hrp::EdgeToTriangleMap
std::map< Edge, trianglePair > EdgeToTriangleMap
Definition: ColdetModel.h:59
hrp::ColdetModel::pTransform
IceMaths::Matrix4x4 * pTransform
transform of primitive
Definition: ColdetModel.h:257
hrp::ColdetModelPtr
boost::intrusive_ptr< ColdetModel > ColdetModelPtr
Definition: ColdetModel.h:268
IceMaths
Definition: ColdetModel.h:24
hrp::ColdetModel::SP_SPHERE
@ SP_SPHERE
Definition: ColdetModel.h:64
hrp::ColdetModel::name_
std::string name_
Definition: ColdetModel.h:258
hrp::ColdetModel::setName
void setName(const std::string &name)
set name of this model
Definition: ColdetModel.h:87


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Wed Sep 7 2022 02:51:02