colinfo.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  * The University of Tokyo
8  */
14 #ifndef __COLINFO_H__
15 #define __COLINFO_H__
16 
17 #include <chain.h>
18 //#include <tList.h>
19 
20 class ColPair
21 {
22  friend class ColInfo;
23 public:
24  ColPair(Chain* chain, const char* jointname1, const char* charname1, const char* jointname2, const char* charname2) {
25  }
26 
28  }
29 
30  Joint* GetJoint(int i) {
31  return joints[i];
32  }
33 
34 private:
36 };
37 
38 class ColInfo
39 {
40  friend class ColPair;
41  friend class ColModel;
42 public:
43  ColInfo() {
44  n_pairs = 0;
45  n_allocated_pairs = 0;
46  n_models = 0;
47  n_allocated_models = 0;
48  n_total_tri = 0;
49  pairs = 0;
50  models = 0;
51  }
53  if(pairs)
54  {
55  for(int i=0; i<n_pairs; i++) delete pairs[i];
56  delete[] pairs;
57  }
58  if(models)
59  {
60  for(int i=0; i<n_models; i++) delete models[i];
61  delete[] models;
62  }
63  }
64 
65  /*
66  * add collision pairs by character name
67  */
68  int AddCharPairs(const char* char1, const char* char2,
69  Chain* chain, SceneGraph* sg);
70  /*
71  * add collision pairs by joint name
72  */
73  int AddJointPair(const char* joint1, const char* joint2,
74  Chain* chain, SceneGraph* sg);
75 
76  /*
77  * query information
78  */
79  int NumPairs() {
80  return n_pairs;
81  }
82  int NumModels() {
83  return n_models;
84  }
85  int NumTriangles() {
86  return n_total_tri;
87  }
88  ColPair* Pair(int i) {
89  return pairs[i];
90  }
91  ColModel* Model(int i) {
92  return models[i];
93  }
94  ColModel* Model(Joint* jref) {
95  for(int i=0; i<n_models; i++)
96  {
97  if(models[i]->joint == jref) return models[i];
98  }
99  return 0;
100  }
101  ColPair* Pair(Joint* jref1, Joint* jref2) {
102  for(int i=0; i<n_pairs; i++)
103  {
104  if(pairs[i]->models[0]->joint == jref1 && pairs[i]->models[1]->joint == jref2) return pairs[i];
105  else if(pairs[i]->models[1]->joint == jref1 && pairs[i]->models[0]->joint == jref2) return pairs[i];
106  }
107  return 0;
108  }
109  ColModel* AddModel(Joint* jref, SceneGraph* sg);
110 
111 private:
112  void allocate_pair(int n_new_alloc) {
113  ColPair** tmp = pairs;
114  pairs = new ColPair* [n_new_alloc];
115  if(tmp)
116  {
117  for(int i=0; i<n_allocated_pairs; i++) pairs[i] = tmp[i];
118  delete[] tmp;
119  }
120  n_allocated_pairs = n_new_alloc;
121  }
122  void allocate_model(int n_new_alloc) {
123  ColModel** tmp = models;
124  models = new ColModel* [n_new_alloc];
125  if(tmp)
126  {
127  for(int i=0; i<n_allocated_models; i++) models[i] = tmp[i];
128  delete[] tmp;
129  }
130  n_allocated_models = n_new_alloc;
131  }
132  void add_pair(ColPair* p);
133  void add_model(ColModel* m);
134 
135  int add_char_pairs(Joint* cur, const char* char1, const char* char2, Chain* chain, SceneGraph* sg);
136  int add_char_pairs(Joint* j1, Joint* j2, const char* char2, SceneGraph* sg);
137  int add_joint_pair(Joint* j1, Joint* j2, SceneGraph* sg);
138 
139  int n_pairs;
142 
143  int n_models;
145  ColModel** models;
147 };
148 
149 
150 #endif
int n_total_tri
Definition: colinfo.h:146
void allocate_model(int n_new_alloc)
Definition: colinfo.h:122
~ColInfo()
Definition: colinfo.h:52
png_uint_32 i
Definition: png.h:2735
int NumPairs()
Definition: colinfo.h:79
ColPair ** pairs
Definition: colinfo.h:141
ColModel * Model(int i)
Definition: colinfo.h:91
ColModel * Model(Joint *jref)
Definition: colinfo.h:94
int n_allocated_models
Definition: colinfo.h:144
void allocate_pair(int n_new_alloc)
Definition: colinfo.h:112
Joint * GetJoint(int i)
Definition: colinfo.h:30
ColModel ** models
Definition: colinfo.h:145
~ColPair()
Definition: colinfo.h:27
int NumTriangles()
Definition: colinfo.h:85
ColInfo()
Definition: colinfo.h:43
Classes for defining open/closed kinematic chains.
int NumModels()
Definition: colinfo.h:82
The class representing the whole mechanism. May contain multiple characters.
Definition: chain.h:144
ColPair(Chain *chain, const char *jointname1, const char *charname1, const char *jointname2, const char *charname2)
Definition: colinfo.h:24
Joint * joints[2]
Definition: colinfo.h:35
int n_pairs
Definition: colinfo.h:139
The class for representing a joint.
Definition: chain.h:538
int n_allocated_pairs
Definition: colinfo.h:140
int n_models
Definition: colinfo.h:143
ColPair * Pair(Joint *jref1, Joint *jref2)
Definition: colinfo.h:101
ColPair * Pair(int i)
Definition: colinfo.h:88


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat Apr 13 2019 02:14:20