Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00014 #ifndef __COLINFO_H__
00015 #define __COLINFO_H__
00016
00017 #include <chain.h>
00018
00019
00020 class ColPair
00021 {
00022 friend class ColInfo;
00023 public:
00024 ColPair(Chain* chain, const char* jointname1, const char* charname1, const char* jointname2, const char* charname2) {
00025 }
00026
00027 ~ColPair() {
00028 }
00029
00030 Joint* GetJoint(int i) {
00031 return joints[i];
00032 }
00033
00034 private:
00035 Joint* joints[2];
00036 };
00037
00038 class ColInfo
00039 {
00040 friend class ColPair;
00041 friend class ColModel;
00042 public:
00043 ColInfo() {
00044 n_pairs = 0;
00045 n_allocated_pairs = 0;
00046 n_models = 0;
00047 n_allocated_models = 0;
00048 n_total_tri = 0;
00049 pairs = 0;
00050 models = 0;
00051 }
00052 ~ColInfo() {
00053 if(pairs)
00054 {
00055 for(int i=0; i<n_pairs; i++) delete pairs[i];
00056 delete[] pairs;
00057 }
00058 if(models)
00059 {
00060 for(int i=0; i<n_models; i++) delete models[i];
00061 delete[] models;
00062 }
00063 }
00064
00065
00066
00067
00068 int AddCharPairs(const char* char1, const char* char2,
00069 Chain* chain, SceneGraph* sg);
00070
00071
00072
00073 int AddJointPair(const char* joint1, const char* joint2,
00074 Chain* chain, SceneGraph* sg);
00075
00076
00077
00078
00079 int NumPairs() {
00080 return n_pairs;
00081 }
00082 int NumModels() {
00083 return n_models;
00084 }
00085 int NumTriangles() {
00086 return n_total_tri;
00087 }
00088 ColPair* Pair(int i) {
00089 return pairs[i];
00090 }
00091 ColModel* Model(int i) {
00092 return models[i];
00093 }
00094 ColModel* Model(Joint* jref) {
00095 for(int i=0; i<n_models; i++)
00096 {
00097 if(models[i]->joint == jref) return models[i];
00098 }
00099 return 0;
00100 }
00101 ColPair* Pair(Joint* jref1, Joint* jref2) {
00102 for(int i=0; i<n_pairs; i++)
00103 {
00104 if(pairs[i]->models[0]->joint == jref1 && pairs[i]->models[1]->joint == jref2) return pairs[i];
00105 else if(pairs[i]->models[1]->joint == jref1 && pairs[i]->models[0]->joint == jref2) return pairs[i];
00106 }
00107 return 0;
00108 }
00109 ColModel* AddModel(Joint* jref, SceneGraph* sg);
00110
00111 private:
00112 void allocate_pair(int n_new_alloc) {
00113 ColPair** tmp = pairs;
00114 pairs = new ColPair* [n_new_alloc];
00115 if(tmp)
00116 {
00117 for(int i=0; i<n_allocated_pairs; i++) pairs[i] = tmp[i];
00118 delete[] tmp;
00119 }
00120 n_allocated_pairs = n_new_alloc;
00121 }
00122 void allocate_model(int n_new_alloc) {
00123 ColModel** tmp = models;
00124 models = new ColModel* [n_new_alloc];
00125 if(tmp)
00126 {
00127 for(int i=0; i<n_allocated_models; i++) models[i] = tmp[i];
00128 delete[] tmp;
00129 }
00130 n_allocated_models = n_new_alloc;
00131 }
00132 void add_pair(ColPair* p);
00133 void add_model(ColModel* m);
00134
00135 int add_char_pairs(Joint* cur, const char* char1, const char* char2, Chain* chain, SceneGraph* sg);
00136 int add_char_pairs(Joint* j1, Joint* j2, const char* char2, SceneGraph* sg);
00137 int add_joint_pair(Joint* j1, Joint* j2, SceneGraph* sg);
00138
00139 int n_pairs;
00140 int n_allocated_pairs;
00141 ColPair** pairs;
00142
00143 int n_models;
00144 int n_allocated_models;
00145 ColModel** models;
00146 int n_total_tri;
00147 };
00148
00149
00150 #endif