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 
258  std::string name_;
259  bool isValid_;
260  EdgeToTriangleMap triangleMap;
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
EdgeToTriangleMap triangleMap
Definition: ColdetModel.h:260
bool isValid() const
check if build() is already called or not
Definition: ColdetModel.h:165
* x
Definition: IceUtils.h:98
ColdetModelSharedDataSet * dataSet
Definition: ColdetModel.h:255
png_infop png_charpp name
Definition: png.h:2382
png_voidp int value
Definition: png.h:2113
int vertex[2]
Definition: ColdetModel.h:33
IceMaths::Matrix4x4 * transform
Definition: ColdetModel.h:256
Eigen::Vector3d Vector3
Definition: EigenTypes.h:11
void setName(const std::string &name)
set name of this model
Definition: ColdetModel.h:87
Eigen::Matrix3d Matrix33
Definition: EigenTypes.h:12
Edge(int vertexIndex1, int vertexIndex2)
Definition: ColdetModel.h:35
std::string name_
Definition: ColdetModel.h:258
bool operator<(const Edge &rhs) const
Definition: ColdetModel.h:44
list index
#define HRP_COLLISION_EXPORT
Definition: Opcode.h:27
t
IceMaths::Matrix4x4 * pTransform
transform of primitive
Definition: ColdetModel.h:257
ColdetModelSharedDataSet * getDataSet()
Definition: ColdetModel.h:245
const std::string & name() const
get name of this model
Definition: ColdetModel.h:93
org
boost::intrusive_ptr< ColdetModel > ColdetModelPtr
Definition: ColdetModel.h:268
* y
Definition: IceUtils.h:97
std::map< Edge, trianglePair > EdgeToTriangleMap
Definition: ColdetModel.h:59


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat May 8 2021 02:42:37