00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "spamod-api.hh"
00026
00027 #include "g-map.hh"
00028
00029 #include "topologic-view.hh"
00030 #include "analytic-view.hh"
00031 #include "euclidian-view.hh"
00032 #include "voxel-view.hh"
00033 #include "k2-view.hh"
00034
00035 #include "color-table-att.hh"
00036 #include "user.hh"
00037 #include "gmap-ops.hh"
00038 #include "ineq-op.hh"
00039
00040
00041
00042 using namespace GMap3d;
00043
00044
00045 CSpamodAPI::CSpamodAPI(CGMap * AMap)
00046 {
00047 assert(AMap != NULL);
00048
00049 FMap = AMap;
00050 colors = NULL;
00051 FViewMode = SPAMOD_NONE;
00052
00053 EV = new Euclidian_View(FMap);
00054 AV = new Analytic_View(FMap);
00055 TV = new Topologic_View(FMap);
00056 VV = new Voxel_View(FMap);
00057 KV = new K2_View(FMap);
00058
00059 FEuclidianParam[0] = true;
00060 FEuclidianParam[1] = true;
00061
00062 FAnalyticParam [0] = true;
00063 FAnalyticParam [1] = true;
00064 FAnalyticParam [2] = true;
00065 FAnalyticParam [3] = true;
00066
00067 FVoxelParam [0] = true;
00068 FVoxelParam [1] = true;
00069 FVoxelParam [2] = true;
00070
00071 FK2Param [0] = true;
00072 FK2Param [1] = true;
00073 FK2Param [2] = true;
00074 }
00075
00076 CSpamodAPI::~CSpamodAPI()
00077 {
00078 delete EV;
00079 delete AV;
00080 delete TV;
00081 delete VV;
00082 delete KV;
00083 }
00084
00085 void CSpamodAPI::computeSpamodEmbeddings()
00086 {
00087 for (int orbit = ORBIT_SELF; orbit <= ORBIT_CC; ++orbit)
00088 FUsedOrbits[orbit] = FMap->isOrbitUsed(orbit);
00089
00090 FMap->setOrbitUsed(ORBIT_0123);
00091 FMap->setOrbitUsed(ORBIT_123);
00092 FMap->setOrbitUsed(ORBIT_023);
00093 FMap->setOrbitUsed(ORBIT_013);
00094 FMap->setOrbitUsed(ORBIT_01);
00095 FMap->setOrbitUsed(ORBIT_0);
00096 FMap->setOrbitUsed(ORBIT_012);
00097 FMap->setOrbitUsed(ORBIT_SELF);
00098
00099 Init_Gmap(FMap);
00100
00101 colors =
00102 ((Color_Table_Att *) Find_Attribute(FMap, ORBIT_0123,
00103 COLOR_TABLE_ATTRIBUTE_ID))->Get_Data();
00104
00105 TV->Create_Darts_View();
00106 Create_Ineq(FMap);
00107 Choose_Ineq(FMap);
00108 AV->Create_Vertices_Faces();
00109 AV->Create_Edges_Faces();
00110 AV->Create_Faces();
00111 VV->Create_Matrix();
00112 KV->Calculate_Matrix();
00113 }
00114
00115
00116 void CSpamodAPI::deleteSpamodEmbeddings()
00117 {
00118 CAttribute * attr;
00119
00120 for (CDynamicCoverageAll dgm(FMap); dgm.cont(); dgm++)
00121 {
00122
00123 attr = (*dgm)->removeAttribute(ORBIT_SELF, VERTEX_ATTRIBUTE_ID);
00124 if (attr != NULL) delete attr;
00125
00126
00127 attr = (*dgm)->removeAttribute(ORBIT_0, USE_ATTRIBUTE_ID);
00128 if (attr != NULL) delete attr;
00129
00130
00131 attr = (*dgm)->removeAttribute(ORBIT_123, VOXEL_LIST_ATTRIBUTE_ID);
00132 if (attr != NULL) delete attr;
00133
00134
00135 attr = (*dgm)->removeAttribute(ORBIT_123, INEQ6_ATTRIBUTE_ID);
00136 if (attr != NULL) delete attr;
00137
00138
00139 attr = (*dgm)->removeAttribute(ORBIT_123, PT_LIST_ATTRIBUTE_ID);
00140 if (attr != NULL) delete attr;
00141
00142
00143 attr = (*dgm)->removeAttribute(ORBIT_023, INEQ6_ATTRIBUTE_ID);
00144 if (attr != NULL) delete attr;
00145
00146
00147 attr = (*dgm)->removeAttribute(ORBIT_023, PT_LIST_ATTRIBUTE_ID);
00148 if (attr != NULL) delete attr;
00149
00150
00151 attr = (*dgm)->removeAttribute(ORBIT_023, VOXEL_LIST_ATTRIBUTE_ID);
00152 if (attr != NULL) delete attr;
00153
00154
00155 attr = (*dgm)->removeAttribute(ORBIT_013, INT_ATTRIBUTE_ID);
00156 if (attr != NULL) delete attr;
00157
00158
00159 attr = (*dgm)->removeAttribute(ORBIT_013, INEQ2_ATTRIBUTE_ID);
00160 if (attr != NULL) delete attr;
00161
00162
00163 attr = (*dgm)->removeAttribute(ORBIT_013, PT_LIST_ATTRIBUTE_ID);
00164 if (attr != NULL) delete attr;
00165
00166
00167 attr = (*dgm)->removeAttribute(ORBIT_013, VOXEL_LIST_ATTRIBUTE_ID);
00168 if (attr != NULL) delete attr;
00169
00170
00171 attr = (*dgm)->removeAttribute(ORBIT_0123, MATRIX_ATTRIBUTE_ID);
00172 if (attr != NULL) delete attr;
00173
00174
00175 attr = (*dgm)->removeAttribute(ORBIT_0123, COLOR_TABLE_ATTRIBUTE_ID);
00176 if (attr != NULL) delete attr;
00177 }
00178
00179 for (int orbit = ORBIT_SELF; orbit <= ORBIT_CC; ++orbit)
00180 if (FMap->isOrbitUsed(orbit) && ! FUsedOrbits[orbit])
00181 FMap->unsetOrbitUsed(orbit);
00182
00183 colors = NULL;
00184 }
00185
00186 void CSpamodAPI::setViewMode(TSpamodViewMode AMode)
00187 {
00188 if (FViewMode == AMode)
00189 return;
00190
00191 TSpamodViewMode oldMode = FViewMode;
00192 FViewMode = AMode;
00193
00194 if (FViewMode == SPAMOD_NONE)
00195
00196 deleteSpamodEmbeddings();
00197 else
00198 if (oldMode == SPAMOD_NONE)
00199
00200 computeSpamodEmbeddings();
00201 }
00202
00203 TSpamodViewMode CSpamodAPI::getViewMode() const
00204 {
00205 return FViewMode;
00206 }
00207
00208 bool CSpamodAPI::getEuclidianParam(int i)
00209 {
00210 assert(0<=i && i<=1);
00211 return FEuclidianParam[i];
00212 }
00213
00214 void CSpamodAPI::setEuclidianParam(int i, bool val)
00215 {
00216 assert(0<=i && i<=1);
00217 FEuclidianParam[i] = val;
00218 }
00219
00220 bool CSpamodAPI::getAnalyticParam(int i)
00221 {
00222 assert(0<=i && i<=3);
00223 return FAnalyticParam[i];
00224 }
00225
00226 void CSpamodAPI::setAnalyticParam(int i, bool val)
00227 {
00228 assert(0<=i && i<=3);
00229 FAnalyticParam[i] = val;
00230 }
00231
00232 bool CSpamodAPI::getVoxelParam(int i)
00233 {
00234 assert(0<=i && i<=2);
00235 return FVoxelParam[i];
00236 }
00237
00238 void CSpamodAPI::setVoxelParam(int i, bool val)
00239 {
00240 assert(0<=i && i<=2);
00241 FVoxelParam[i] = val;
00242 }
00243
00244 bool CSpamodAPI::getK2Param(int i)
00245 {
00246 assert(0<=i && i<=2);
00247 return FK2Param[i];
00248 }
00249
00250 void CSpamodAPI::setK2Param(int i, bool val)
00251 {
00252 assert(0<=i && i<=2);
00253 FK2Param[i] = val;
00254 }
00255
00256 void CSpamodAPI::drawMap()
00257 {
00258 Color * color;
00259
00260
00261 GLfloat Material_Ks[] = {0.5, 0.5, 0.5, 1.0};
00262 GLfloat Material_Ke[] = {0.0, 0.0, 0.0, 1.0};
00263 GLfloat Material_Se = 200;
00264
00265
00266 GLfloat Light_Ka[] = {0.1, 0.1, 0.1, 1.0};
00267 GLfloat Light_Kd[] = {1.0, 1.0, 1.0, 1.0};
00268 GLfloat Light_Ks[] = {0.5, 0.5, 0.5, 1.0};
00269
00270 GLfloat Light_Kambient[] = {0.4, 0.4, 0.4, 1.0};
00271 glLightModelfv(GL_LIGHT_MODEL_AMBIENT,Light_Kambient);
00272
00273
00274
00275
00276
00277
00278 glEnable(GL_COLOR_MATERIAL);
00279
00280 glEnable(GL_LIGHT0);
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
00293
00294
00295
00296
00297
00298 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00299
00300
00301 glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,Material_Ks);
00302 glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,Material_Ke);
00303 glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,Material_Se);
00304
00305
00306 glLightfv(GL_LIGHT0,GL_AMBIENT, Light_Ka);
00307 glLightfv(GL_LIGHT0,GL_DIFFUSE, Light_Kd);
00308 glLightfv(GL_LIGHT0,GL_SPECULAR, Light_Ks);
00309
00310
00311 glLightfv(GL_LIGHT1,GL_AMBIENT, Light_Ka);
00312 glLightfv(GL_LIGHT1,GL_DIFFUSE, Light_Kd);
00313 glLightfv(GL_LIGHT1,GL_SPECULAR, Light_Ks);
00314
00315 switch (FViewMode)
00316 {
00317 case SPAMOD_TOPOLOGICAL:
00318 {
00319 glPointSize(3.0);
00320
00321
00322 glColor3f(1.0, 1.0, 0.0);
00323
00324
00325 TV->Darts_Draw();
00326
00327 glPointSize(1.0);
00328
00329 glLineWidth(2.0);
00330
00331
00332
00333
00334 glColor3f(1.0, 0.0, 0.0);
00335
00336 TV->Alpha_Draw(0);
00337
00338
00339
00340
00341
00342 glColor3f(0.0, 0.8, 0.0);
00343
00344 TV->Alpha_Draw(1);
00345
00346
00347
00348
00349
00350 glColor3f(0.0, 0.0, 1.0);
00351
00352 TV->Alpha_Draw(2);
00353
00354
00355
00356
00357
00358 glColor3f(0.7, 0.7, 0.7);
00359
00360 TV->Alpha_Draw(3);
00361
00362
00363 glLineWidth(1.0);
00364 }
00365 break;
00366 case SPAMOD_EUCLIDIAN:
00367 {
00368
00369
00370 if (FEuclidianParam[0])
00371 EV->Wire_Draw();
00372
00373
00374
00375 if (FEuclidianParam[1])
00376 {
00377 glEnable(GL_BLEND);
00378 glDepthMask(GL_FALSE);
00379
00380 color = colors->Get_Color(2);
00381
00382 glColor4f(color->Get_R(),
00383 color->Get_G(),
00384 color->Get_B(),
00385 0.7);
00386
00387 EV->Solid_Draw();
00388
00389 glDepthMask(GL_TRUE);
00390 glDisable(GL_BLEND);
00391 }
00392
00393 }
00394 break;
00395 case SPAMOD_ANALYTIC:
00396 {
00397 bool translucid = getAnalyticParam(3);
00398
00399
00400
00401 if (getAnalyticParam(0))
00402 {
00403 color = colors->Get_Color(0);
00404 glColor4f(color->Get_R(), color->Get_G(), color->Get_B(),
00405 translucid ? 0.5 : 1.0);
00406 AV->Vertices_Draw();
00407 }
00408
00409 if (getAnalyticParam(1))
00410 {
00411 color = colors->Get_Color(1);
00412 glColor4f(color->Get_R(), color->Get_G(), color->Get_B(),
00413 translucid ? 0.5 : 1.0);
00414 AV->Edges_Draw();
00415 }
00416
00417 if (getAnalyticParam(2))
00418 {
00419 if (translucid)
00420 {
00421
00422 glEnable(GL_BLEND);
00423 glDepthMask(GL_FALSE);
00424 }
00425
00426 color = colors->Get_Color(2);
00427 glColor4f(color->Get_R(), color->Get_G(), color->Get_B(),
00428 translucid ? 0.5 : 1.0);
00429 AV->Faces_Draw();
00430
00431 if (translucid)
00432 {
00433 glDepthMask(GL_TRUE);
00434 glDisable(GL_BLEND);
00435 }
00436 }
00437
00438 }
00439 break;
00440 case SPAMOD_VOXEL:
00441 {
00442
00443
00444 if (getVoxelParam(0))
00445 {
00446 color = colors->Get_Color(0);
00447 glColor3f(color->Get_R(), color->Get_G(), color->Get_B());
00448 VV->Draw_Vertices();
00449 }
00450
00451 if (getVoxelParam(1))
00452 {
00453 color = colors->Get_Color(1);
00454 glColor3f(color->Get_R(), color->Get_G(), color->Get_B());
00455 VV->Draw_Edges();
00456 }
00457
00458 if (getVoxelParam(2))
00459 {
00460 color = colors->Get_Color(2);
00461 glColor3f(color->Get_R(), color->Get_G(), color->Get_B());
00462 VV->Draw_Faces();
00463 }
00464 }
00465 break;
00466 case SPAMOD_K2:
00467 {
00468 if (getK2Param(0))
00469 {
00470 color = colors->Get_Color(0);
00471
00472 glColor3f(color->Get_R(), color->Get_G(), color->Get_B());
00473 KV->Draw_Pointels();
00474 }
00475
00476 if (getK2Param(1))
00477 {
00478 color = colors->Get_Color(3);
00479
00480 glColor3f(color->Get_R(), color->Get_G(), color->Get_B());
00481 KV->Draw_Lignels();
00482 }
00483
00484 if (getK2Param(2))
00485 {
00486
00487
00488
00489 color = colors->Get_Color(2);
00490
00491 glColor4f(color->Get_R(), color->Get_G(), color->Get_B(), 0.8);
00492 KV->Draw_Surfels();
00493
00494
00495
00496 }
00497 }
00498 break;
00499 default:
00500 {
00501 }
00502 }
00503
00504
00505
00506
00507
00508 }
00509