ColdetModelSharedDataSet.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
00003  * All rights reserved. This program is made available under the terms of the
00004  * Eclipse Public License v1.0 which accompanies this distribution, and is
00005  * available at http://www.eclipse.org/legal/epl-v10.html
00006  * Contributors:
00007  * National Institute of Advanced Industrial Science and Technology (AIST)
00008  */
00013 #ifndef OPENHRP_COLDET_MODEL_SHARED_DATA_SET_H_INCLUDED
00014 #define OPENHRP_COLDET_MODEL_SHARED_DATA_SET_H_INCLUDED
00015 
00016 
00017 #include "ColdetModel.h"
00018 #include "Opcode/Opcode.h"
00019 #include <vector>
00020 
00021 using namespace std;
00022 using namespace hrp;
00023 
00024 namespace hrp {
00025      struct triangle3 {
00026         int triangles[3];
00027      };
00028 
00029     class ColdetModelSharedDataSet
00030     {
00031     public:
00032          struct NeighborTriangleSet {
00033              int triangles[3];
00034              NeighborTriangleSet(){
00035                  triangles[0] = triangles[1] = triangles[2] = -1;
00036              }
00037              void addNeighbor(int neighbor){
00038                  for(int i=0; i < 3; ++i){
00039                      if(triangles[i] < 0){
00040                          triangles[i] = neighbor;
00041                          break;
00042                      }
00043                  }
00044              }
00045              void deleteNeighbor(int neighbor){
00046                  for(int i=0; i<3; i++){
00047                      if(triangles[i]==neighbor){
00048                          for(int j=i+1; j<3; j++){
00049                              triangles[j-1] = triangles[j];
00050                          }
00051                          triangles[2] = -1;
00052                      }
00053                      break;
00054                  }
00055              }
00056              int operator[](int index) const { return triangles[index]; }
00057          };
00058 
00059          typedef std::vector<NeighborTriangleSet> NeighborTriangleSetArray;
00060 
00061         ColdetModelSharedDataSet();
00062 
00063         bool build();
00064 
00065         // need two instances ?
00066         Opcode::Model model;
00067 
00068             Opcode::MeshInterface iMesh;
00069 
00070             vector<IceMaths::Point> vertices;
00071             vector<IceMaths::IndexedTriangle> triangles;
00072 
00073         ColdetModel::PrimitiveType pType;
00074         std::vector<float> pParams;
00075 
00076         NeighborTriangleSetArray neighbor;
00077 
00078         int getAABBTreeDepth() {
00079             return AABBTreeMaxDepth;
00080         };
00081         int getNumofBB(int depth){
00082             return numBBMap.at(depth);
00083         };
00084         int getmaxNumofBB(){
00085             if(AABBTreeMaxDepth>0)
00086                 return numBBMap.at(AABBTreeMaxDepth-1);
00087             else
00088                 return 0;
00089         };
00090 
00091       private:
00092         int refCounter;
00093         int AABBTreeMaxDepth;
00094         std::vector<int> numBBMap;
00095         std::vector<int> numLeafMap;
00096         int computeDepth(const Opcode::AABBCollisionNode* node, int currentDepth, int max );
00097 
00098         friend class ColdetModel;
00099     };
00100 }
00101 
00102 #endif


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sun Apr 2 2017 03:43:53