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
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <GL/glut.h>
00035 #include "euclidian-view.hh"
00036 #include "vertex.hh"
00037 #include "attribute-vertex.hh"
00038 #include "vector3d.hh"
00039 #include "color-table.hh"
00040 #include "color-table-att.hh"
00041 #include "gmap-ops.hh"
00042 #include "user.hh"
00043
00044 using namespace std;
00045 using namespace GMap3d;
00046
00047
00048
00049
00050
00051 Euclidian_View::Euclidian_View(CGMap * GM)
00052 {
00053 G = GM;
00054 }
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 void Euclidian_View::Wire_Draw()
00068 {
00069 CAttribute * alpha;
00070 CVertex * p1, * p2;
00071 Color_Table * color;
00072
00073
00074 int markEdge = G->getNewMark();
00075
00076
00077
00078 color = ((Color_Table_Att*)Find_Attribute(G, ORBIT_0123,
00079 COLOR_TABLE_ATTRIBUTE_ID))->Get_Data();
00080
00081
00082
00083 CDynamicCoverageAll C(G);
00084 for (C.reinit(); C.cont(); C++)
00085 {
00086 CDart* dgm = *C;
00087
00088 if (!G->isMarked(dgm, markEdge))
00089 {
00090
00091 alpha = G->getAttribute(dgm, ORBIT_123, VERTEX_ATTRIBUTE_ID);
00092 p1 = (CAttributeVertex*)alpha;
00093
00094
00095 if (G->isFree0(dgm))
00096 {
00097
00098 glColor3f(color->Get_Color(0)->Get_R(),
00099 color->Get_Color(0)->Get_G(),
00100 color->Get_Color(0)->Get_B());
00101 glPointSize(2.0);
00102 glBegin(GL_POINTS);
00103 glVertex3f(p1->getX(), p1->getY(), p1->getZ());
00104 glEnd();
00105 glPointSize(1.0);
00106
00107
00108 G->setMark(dgm, markEdge);
00109 }
00110
00111
00112 else
00113 {
00114
00115 alpha = G->getAttribute(G->alpha0(dgm), ORBIT_123,
00116 VERTEX_ATTRIBUTE_ID);
00117 p2 = (CAttributeVertex*)alpha;
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 glLineWidth(2.0);
00141 glBegin(GL_LINES);
00142 glColor3f(color->Get_Color(1)->Get_R(),
00143 color->Get_Color(1)->Get_G(),
00144 color->Get_Color(1)->Get_B());
00145 glVertex3f(p1->getX(), p1->getY(), p1->getZ());
00146 glVertex3f(p2->getX(), p2->getY(), p2->getZ());
00147 glEnd();
00148 glLineWidth(1.0);
00149
00150
00151
00152 CCoverage* DC = G->getDynamicCoverage(dgm, ORBIT_023);
00153 for (DC->reinit();
00154 DC->cont();
00155 (*DC)++)
00156 G->setMark(**DC, markEdge);
00157 delete DC;
00158 }
00159 }
00160 }
00161
00162
00163 for (C.reinit(); C.cont(); C++)
00164 G->unsetMark(*C, markEdge);
00165 G->freeMark(markEdge);
00166
00167 }
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181 void Euclidian_View::Solid_Draw()
00182 {
00183 int nbPoints;
00184 CAttribute * alpha;
00185 CVertex * p1, * p2;
00186 Vector3D normal;
00187
00188
00189 int markFace = G->getNewMark();
00190
00191
00192
00193 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
00194 glShadeModel(GL_SMOOTH);
00195
00196
00197
00198
00199 CDynamicCoverageAll C(G);
00200 for (C.reinit(); C.cont(); C++)
00201 {
00202 CDart* dgm = *C;
00203
00204 if (!G->isMarked(dgm, markFace))
00205 {
00206
00207 if (G->isFree0(dgm))
00208 {
00209
00210 alpha = G->getAttribute(dgm, ORBIT_123, VERTEX_ATTRIBUTE_ID);
00211 p1 = (CAttributeVertex*)alpha;
00212
00213
00214 glPointSize(2.0);
00215 glBegin(GL_POINTS);
00216 glVertex3f(p1->getX(), p1->getY(), p1->getZ());
00217 glEnd();
00218 glPointSize(1.0);
00219
00220
00221 G->setMark(dgm, markFace);
00222 }
00223
00224
00225 else
00226 if (!G->getAttribute(dgm, ORBIT_013, INT_ATTRIBUTE_ID))
00227 {
00228
00229 glLineWidth(2.0);
00230 glBegin(GL_LINES);
00231
00232
00233 CCoverage* DC01 = G->getDynamicCoverage(dgm, ORBIT_01);
00234 for (DC01->reinit();
00235 DC01->cont();
00236 (*DC01)++)
00237 {
00238 CDart* d01 = **DC01;
00239
00240 if (!G->isMarked(d01, markFace))
00241 {
00242
00243 alpha = G->getAttribute(d01, ORBIT_123,
00244 VERTEX_ATTRIBUTE_ID);
00245 p1 = (CAttributeVertex*)alpha;
00246
00247 alpha = G->getAttribute(G->alpha0(d01), ORBIT_123,
00248 VERTEX_ATTRIBUTE_ID);
00249 p2 = (CAttributeVertex*)alpha;
00250
00251 glVertex3f(p1->getX(), p1->getY(), p1->getZ());
00252 glVertex3f(p2->getX(), p2->getY(), p2->getZ());
00253
00254
00255 G->setMark(d01, markFace);
00256 G->setMark(G->alpha0(d01), markFace);
00257 }
00258 }
00259 glEnd();
00260 glLineWidth(1.0);
00261
00262 delete DC01;
00263 }
00264
00265
00266 else
00267 {
00268 list<CVertex*> ptList;
00269 nbPoints = 0;
00270
00271
00272 CCoverage* DC01 = G->getDynamicCoverage(dgm, ORBIT_01);
00273 for (DC01->reinit();
00274 DC01->cont();
00275 (*DC01)++)
00276 {
00277 CDart* d01 = **DC01;
00278
00279 if (!G->isMarked(d01, markFace))
00280 {
00281
00282 alpha = G->getAttribute(d01, ORBIT_123,
00283 VERTEX_ATTRIBUTE_ID);
00284
00285
00286 ptList.push_front((CAttributeVertex*)alpha);
00287 nbPoints++;
00288
00289
00290
00291 G->setMark(d01, markFace);
00292 G->setMark(G->alpha1(d01), markFace);
00293
00294
00295
00296 if (!G->isFree3(d01))
00297 {
00298 G->setMark(G->alpha3(d01), markFace);
00299 G->setMark(G->alpha3(G->alpha1(d01)),markFace);
00300 }
00301 }
00302 }
00303
00304
00305 if (nbPoints >= 3)
00306 {
00307
00308 CVertex* tab[3];
00309 list<CVertex*>::iterator iter;
00310 int i=0;
00311 for(iter=ptList.begin();iter!=ptList.end() && i<3; iter++)
00312 tab[i++]=*iter;
00313
00314 Vector3D v1(*tab[1],*tab[0]);
00315
00316 Vector3D v2(*tab[2],*tab[1]);
00317
00318 normal = v1.Vect_Product(v2);
00319
00320 normal.Normalize();
00321
00322
00323 glEnable(GL_LIGHTING);
00324
00325
00326 glBegin(GL_POLYGON);
00327 glNormal3f(normal.getX(),
00328 normal.getY(),
00329 normal.getZ());
00330
00331 for (iter=ptList.begin();
00332 iter!=ptList.end();
00333 iter++)
00334 {
00335 CVertex *curPt = *iter;
00336 glVertex3f(curPt->getX(),
00337 curPt->getY(),
00338 curPt->getZ());
00339 }
00340 glEnd();
00341
00342
00343 glDisable(GL_LIGHTING);
00344 }
00345
00346
00347 else
00348 {
00349
00350 CVertex* tab[2];
00351 list<CVertex*>::iterator iter;
00352 int i=0;
00353 for(iter=ptList.begin();iter!=ptList.end() && i<2; iter++)
00354 tab[i++]=*iter;
00355
00356 p1 = tab[0];
00357 glLineWidth(2.0);
00358 glBegin(GL_LINES);
00359 glVertex3f(p1->getX(), p1->getY(), p1->getZ());
00360 p1 = tab[1];
00361 glVertex3f(p1->getX(), p1->getY(), p1->getZ());
00362 glEnd();
00363 glLineWidth(1.0);
00364 }
00365
00366 delete DC01;
00367 }
00368 }
00369 }
00370
00371
00372
00373 for (C.reinit(); C.cont(); C++)
00374 G->unsetMark(*C, markFace);
00375 G->freeMark(markFace);
00376
00377
00378
00379 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
00380 glShadeModel(GL_FLAT);
00381 }