00001 #include "vtrack.h"
00002
00003 #include <cmath>
00004 #include <iostream>
00005
00006 #include "container.h"
00007 #include "vertex.h"
00008 #include "vertex_schedule.h"
00009 #include "virtual_disp.h"
00010
00011 using std::cout;
00012 using std::endl;
00013
00014 VTrack::VTrack (void)
00015 :vv(0),topN_val(2,0),vd_val(2,0),sepdis(2,0),
00016 p_orig(3,-1.0),p_new(3,-1.0),cp_orig(3,-1.0),cp_new(3,-1.0),
00017 trouble(0)
00018 {
00019 }
00020
00021 VTrack::VTrack (const VTrack& rhs)
00022 :vv(0),topN_val(2,0),vd_val(2,0),sepdis(2,0),
00023 p_orig(3,-1.0),p_new(3,-1.0),cp_orig(3,-1.0),cp_new(3,-1.0),
00024 trouble(0)
00025 {
00026 cout << "Copy constructor prohibited on instances of VTrack class.\n";
00027 cout << "VTrack " << rhs.vv->getIndex() << endl;
00028 exit(0);
00029 }
00030
00031 VTrack& VTrack::operator = (const VTrack& rhs)
00032 {
00033 cout << "Assignment operator prohibited on instances of VTrack class.\n";
00034 cout << "VTRack " << rhs.vv->getIndex() << endl;
00035 exit(0);
00036 }
00037
00038 void VTrack::printBad (void)
00039 {
00040 if (vv==NULL){cout << "vertex* is NULL.\n";}
00041 if (p_orig[0]<0){cout << "orig pos not set.\n";}
00042 if (p_new[0]<0){cout << "new pos not set.\n";}
00043 if (cp_orig[0]<0){cout << "orig clos pos not set.\n";}
00044 if (cp_new[0]<0){cout << "new clos pos not set.\n";}
00045 if (topN_val[0]<0){cout << "orig topN_val not set.\n";}
00046 if (topN_val[1]<0){cout << "new topN_val not set.\n";}
00047 if (vd_val[0]<0){cout << "orig vd_val not set.\n";}
00048 if (vd_val[1]<0){cout << "new vd_val not set.\n";}
00049 if (sepdis[0]<0){cout << "orig sepdis not set.\n";}
00050 if (sepdis[1]<0){cout << "new sepdis not set.\n";}
00051 cout << "p_orig[0] = " << p_orig[0] << endl;
00052 cout << "p_new[0] = " << p_new[0] << endl;
00053 cout << "cp_orig[0] = " << cp_orig[0] << endl;
00054 cout << "cp_new[0] = " << cp_new[0] << endl;
00055 cout << "topN_val[0] = " << topN_val[0] << endl;
00056 cout << "topN_val[1] = " << topN_val[1] << endl;
00057 cout << "vd_val[0] = " << vd_val[0] << endl;
00058 cout << "vd_val[1] = " << vd_val[1] << endl;
00059 cout << "sepdis[0] = " << sepdis[0] << endl;
00060 cout << "sepdis[1] = " << sepdis[1] << endl;
00061 }
00062
00063 void VTrack::print (void)
00064 {
00065 cout << "pos ["
00066 << p_orig[0] << " "
00067 << p_orig[1] << " "
00068 << p_orig[2] << "]->["
00069 << p_new[0] << " "
00070 << p_new[1] << " "
00071 << p_new[2] << "]\n"
00072 << "closest pos ["
00073 << cp_orig[0] << " "
00074 << cp_orig[1] << " "
00075 << cp_orig[2] << "]->["
00076 << cp_new[0] << " "
00077 << cp_new[1] << " "
00078 << cp_new[2] << "]\n"
00079 << "topN_val rank ["
00080 << topN_val[0] << "]->["
00081 << topN_val[1] << "], "
00082 << "vd_val ["
00083 << vd_val[0] << "]->["
00084 << vd_val[1] << "], "
00085 << "sepdis ["
00086 << sepdis[0] << "]->["
00087 << sepdis[1] << "]\n";
00088 }
00089
00090 Vertex* VTrack::getVertex (void)
00091 {
00092 return vv;
00093 }
00094
00095 void VTrack::addVertex (Vertex *uu)
00096 {
00097 vv=uu;
00098 }
00099
00100 bool VTrack::isGood (void)
00101 {
00102 return vv!=NULL &&
00103 (p_orig[0]>0) &&
00104 (p_new[0]>0) &&
00105 (cp_orig[0]>0) &&
00106 (cp_new[0]>0) &&
00107 (topN_val[0]>0) &&
00108 (topN_val[1]>0) &&
00109 (vd_val[0]>=0) &&
00110 (vd_val[1]>=0) &&
00111 (sepdis[0]>=0) &&
00112 (sepdis[1]>0);
00113 }
00114
00115 void VTrack::addNewSepDis (double i)
00116 {
00117 sepdis[1]=i;
00118 }
00119
00120 double VTrack::getNewSepDis (void)
00121 {
00122 return sepdis[1];
00123 }
00124
00125 void VTrack::addNewVD (double i)
00126 {
00127 vd_val[1]=i;
00128 }
00129
00130 double VTrack::getNewVD (void)
00131 {
00132 return vd_val[1];
00133 }
00134
00135 void VTrack::addNewTopN (double i)
00136 {
00137 topN_val[1]=i;
00138 }
00139
00140 double VTrack::getNewTopN (void)
00141 {
00142 return topN_val[1];
00143 }
00144
00145 void VTrack::addOrigSepDis (double i)
00146 {
00147 sepdis[0]=i;
00148 }
00149
00150 double VTrack::getOrigSepDis (void)
00151 {
00152 return sepdis[0];
00153 }
00154
00155 void VTrack::addOrigVD (double i)
00156 {
00157 vd_val[0]=i;
00158 }
00159
00160 double VTrack::getOrigVD (void)
00161 {
00162 return vd_val[0];
00163 }
00164
00165 void VTrack::addOrigTopN (double i)
00166 {
00167 topN_val[0]=i;
00168 }
00169
00170 double VTrack::getOrigTopN (void)
00171 {
00172 return topN_val[0];
00173 }
00174
00175 void VTrack::clear (void)
00176 {
00177 p_orig[0] = p_orig[1] = p_orig[2] = -1.0;
00178 p_new[0] = p_new[1] = p_new[2] = -1.0;
00179 cp_orig[0] = cp_orig[1] = cp_orig[2] = -1.0;
00180 cp_new[0] = cp_new[1] = cp_new[2] = -1.0;
00181 for(int i=0;i<2;i++)
00182 {
00183 topN_val[i]=vd_val[i]=sepdis[i]=-1.0;
00184 }
00185 }
00186
00187
00188
00189
00190
00191
00192
00193
00194 void VTrack::addOrigP (vec_d const * const q)
00195 {
00196 p_orig[0]=(*q)[0];
00197 p_orig[1]=(*q)[1];
00198 p_orig[2]=(*q)[2];
00199 }
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222 void VTrack::addNewP (vec_d const * const q)
00223 {
00224 p_new[0]=(*q)[0];
00225 p_new[1]=(*q)[1];
00226 p_new[2]=(*q)[2];
00227 }
00228
00229 void VTrack::addOrigCP (double q[3])
00230 {
00231 cp_orig[0]=q[0];
00232 cp_orig[1]=q[1];
00233 cp_orig[2]=q[2];
00234 }
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250 void VTrack::addNewCP (double q[3])
00251 {
00252 cp_new[0]=q[0];
00253 cp_new[1]=q[1];
00254 cp_new[2]=q[2];
00255 }
00256
00257 void VTrack::premove (Vertex * v)
00258 {
00259 clear();
00260 addVertex(Vertex_Schedule::instance().getCurrentVertex());
00261 addOrigP(Vertex_Schedule::instance().getCurrentVertex()->getPos());
00262 addOrigSepDis(sqrt(v->getSqSepDist()));
00263
00264 int rank;
00265 tv_it t;
00266 Virtual_Disp::instance().findTopN(Vertex_Schedule::instance().getCurrentVertex(),t,rank);
00267
00268 double pC[3];
00269 Container::instance().getNearPtOnFaceToVertex(Vertex_Schedule::instance().getCurrentVertex()->getFace(),Vertex_Schedule::instance().getCurrentVertex(),pC);
00270
00271 addOrigCP(pC);
00272 addOrigVD(sqrt((*t).first));
00273 addOrigTopN(rank);
00274 }
00275
00276 void VTrack::postmove (void)
00277 {
00278
00279 addNewP(Vertex_Schedule::instance().getCurrentVertex()->getPos());
00280 addNewSepDis(sqrt(Vertex_Schedule::instance().getCurrentVertex()->getSqSepDist()));
00281 int rank;
00282 tv_it t;
00283 Virtual_Disp::instance().findTopN(Vertex_Schedule::instance().getCurrentVertex(),t,rank);
00284
00285 double pC[3];
00286 Container::instance().getNearPtOnFaceToVertex(Vertex_Schedule::instance().getCurrentVertex()->getFace(),Vertex_Schedule::instance().getCurrentVertex(),pC);
00287
00288 addNewCP(pC);
00289 addNewVD(sqrt((*t).first));
00290 addNewTopN(rank);
00291 if (isGood()==true)
00292 {
00293 print();
00294 }
00295 else
00296 {
00297 printBad();
00298 cout << "Program exited because VTrack is bad.\n";
00299 exit(0);
00300 }
00301 }
00302