Choreonoid  1.8
ColdetModelInternalModel.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_AIST_COLLISION_DETECTOR_COLDET_MODEL_INTERNAL_MODEL_H
6 #define CNOID_AIST_COLLISION_DETECTOR_COLDET_MODEL_INTERNAL_MODEL_H
7 
8 #include "ColdetModel.h"
9 #include "Opcode/Opcode.h"
10 #include <vector>
11 
12 namespace cnoid {
13 
15 {
16 public:
18  int neighbors[3];
20  neighbors[0] = neighbors[1] = neighbors[2] = -1;
21  }
22  void addNeighbor(int neighbor){
23  for(int i=0; i < 3; ++i){
24  if(neighbors[i] < 0){
25  neighbors[i] = neighbor;
26  break;
27  }
28  }
29  }
30  void deleteNeighbor(int neighbor){
31  for(int i=0; i<3; i++){
32  if(neighbors[i]==neighbor){
33  for(int j=i+1; j<3; j++){
34  neighbors[j-1] = neighbors[j];
35  }
36  neighbors[2] = -1;
37  break;
38  }
39  }
40  }
41  int operator[](int index) const { return neighbors[index]; }
42  };
43 
44  typedef std::vector<NeighborTriangleSet> NeighborTriangleSetArray;
45 
47 
48  bool build();
49 
50  // need two instances ?
51  Opcode::Model model;
52  Opcode::MeshInterface iMesh;
53  std::vector<IceMaths::Point> vertices;
54  std::vector<IceMaths::IndexedTriangle> triangles;
57  std::vector<float> pParams;
58 
60  return AABBTreeMaxDepth;
61  };
62  int getNumofBB(int depth){
63  return numBBMap.at(depth);
64  };
66  if(AABBTreeMaxDepth>0){
67  return numBBMap.at(AABBTreeMaxDepth-1);
68  } else {
69  return 0;
70  }
71  };
72 
73 private:
74  int refCounter;
75  int AABBTreeMaxDepth;
76  std::vector<int> numBBMap;
77  std::vector<int> numLeafMap;
78 
79  void extractNeghiborTriangles();
80  int computeDepth(const Opcode::AABBCollisionNode* node, int currentDepth, int max );
81 
82  friend class ColdetModel;
83 };
84 }
85 
86 #endif
cnoid::ColdetModelInternalModel::model
Opcode::Model model
Definition: ColdetModelInternalModel.h:51
cnoid::ColdetModelInternalModel::iMesh
Opcode::MeshInterface iMesh
Definition: ColdetModelInternalModel.h:52
cnoid::ColdetModelInternalModel::getAABBTreeDepth
int getAABBTreeDepth()
Definition: ColdetModelInternalModel.h:59
cnoid::ColdetModelInternalModel::build
bool build()
Definition: ColdetModel.cpp:253
cnoid::ColdetModel
Definition: ColdetModel.h:22
cnoid::ColdetModelInternalModel::NeighborTriangleSet::addNeighbor
void addNeighbor(int neighbor)
Definition: ColdetModelInternalModel.h:22
cnoid::ColdetModelInternalModel::triangles
std::vector< IceMaths::IndexedTriangle > triangles
Definition: ColdetModelInternalModel.h:54
cnoid::ColdetModelInternalModel
Definition: ColdetModelInternalModel.h:14
cnoid::ColdetModelInternalModel::getNumofBB
int getNumofBB(int depth)
Definition: ColdetModelInternalModel.h:62
cnoid::ColdetModelInternalModel::ColdetModelInternalModel
ColdetModelInternalModel()
Definition: ColdetModel.cpp:100
cnoid::ColdetModelInternalModel::vertices
std::vector< IceMaths::Point > vertices
Definition: ColdetModelInternalModel.h:53
cnoid::ColdetModelInternalModel::NeighborTriangleSet::NeighborTriangleSet
NeighborTriangleSet()
Definition: ColdetModelInternalModel.h:19
cnoid::ColdetModelInternalModel::getmaxNumofBB
int getmaxNumofBB()
Definition: ColdetModelInternalModel.h:65
cnoid::ColdetModelInternalModel::NeighborTriangleSetArray
std::vector< NeighborTriangleSet > NeighborTriangleSetArray
Definition: ColdetModelInternalModel.h:44
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::ColdetModelInternalModel::pType
ColdetModel::PrimitiveType pType
Definition: ColdetModelInternalModel.h:56
cnoid::ColdetModelInternalModel::NeighborTriangleSet::deleteNeighbor
void deleteNeighbor(int neighbor)
Definition: ColdetModelInternalModel.h:30
cnoid::ColdetModel::PrimitiveType
PrimitiveType
Definition: ColdetModel.h:25
ColdetModel.h
cnoid::ColdetModelInternalModel::NeighborTriangleSet
Definition: ColdetModelInternalModel.h:17
cnoid::ColdetModelInternalModel::NeighborTriangleSet::neighbors
int neighbors[3]
Definition: ColdetModelInternalModel.h:18
cnoid::ColdetModelInternalModel::NeighborTriangleSet::operator[]
int operator[](int index) const
Definition: ColdetModelInternalModel.h:41
cnoid::ColdetModelInternalModel::neighbors
NeighborTriangleSetArray neighbors
Definition: ColdetModelInternalModel.h:55
cnoid::ColdetModelInternalModel::pParams
std::vector< float > pParams
Definition: ColdetModelInternalModel.h:57