38 #include <GLUT/glut.h>
54 #include "attribute-vertex.hh"
57 using namespace GMap3d;
62 Analytic_View::Analytic_View(CGMap * GM)
65 directInfo = G->getNewDirectInfo();
70 Analytic_View::~Analytic_View()
73 G->freeDirectInfo(directInfo);
84 void Analytic_View::Create_Vertices_Faces()
92 int markVertex = G->getNewMark();
95 CDynamicCoverageAll Cgm(G);
96 for (Cgm.reinit(); Cgm.cont(); Cgm++)
101 if (!G->isMarked(dgm, markVertex))
105 list<CVertex*> *vL = (list<CVertex*>*)pList->
Get_Data();
108 list<CVertex*> *l =
new list<CVertex*>;
115 p = (CAttributeVertex*)alpha;
118 l->push_front(
new CVertex(p->getX()+0.5,
121 l->push_front(
new CVertex(p->getX()+0.5,
124 l->push_front(
new CVertex(p->getX()+0.5,
127 l->push_front(
new CVertex(p->getX()+0.5,
130 l->push_front(
new CVertex(p->getX()-0.5,
133 l->push_front(
new CVertex(p->getX()-0.5,
136 l->push_front(
new CVertex(p->getX()-0.5,
139 l->push_front(
new CVertex(p->getX()-0.5,
146 G->setDirectInfo(G->getEmbeddingOwner(dgm, ORBIT_123),directInfo,l);
149 for (
int i = 0 ; i<6 ; i++)
161 vL->push_front(
new CVertex(ineq->
GetW(),
164 vL->push_front(
new CVertex(ineq->
GetW(),
167 vL->push_front(
new CVertex(ineq->
GetW(),
170 vL->push_front(
new CVertex(ineq->
GetW(),
176 vL->push_front(
new CVertex(-ineq->
GetW(),
179 vL->push_front(
new CVertex(-ineq->
GetW(),
182 vL->push_front(
new CVertex(-ineq->
GetW(),
185 vL->push_front(
new CVertex(-ineq->
GetW(),
191 vL->push_front(
new CVertex(p->getX()+0.5,
194 vL->push_front(
new CVertex(p->getX()+0.5,
197 vL->push_front(
new CVertex(p->getX()-0.5,
200 vL->push_front(
new CVertex(p->getX()-0.5,
206 vL->push_front(
new CVertex(p->getX()+0.5,
209 vL->push_front(
new CVertex(p->getX()+0.5,
212 vL->push_front(
new CVertex(p->getX()-0.5,
215 vL->push_front(
new CVertex(p->getX()-0.5,
221 vL->push_front(
new CVertex(p->getX()+0.5,
224 vL->push_front(
new CVertex(p->getX()+0.5,
227 vL->push_front(
new CVertex(p->getX()-0.5,
230 vL->push_front(
new CVertex(p->getX()-0.5,
236 vL->push_front(
new CVertex(p->getX()+0.5,
239 vL->push_front(
new CVertex(p->getX()+0.5,
242 vL->push_front(
new CVertex(p->getX()-0.5,
245 vL->push_front(
new CVertex(p->getX()-0.5,
257 G->addAttribute(dgm, ORBIT_123, pList);
260 CCoverage* DCv = G->getDynamicCoverage(dgm, ORBIT_123);
261 for(DCv->reinit(); DCv->cont(); (*DCv)++)
262 G->setMark(**DCv, markVertex);
268 for (Cgm.reinit(); Cgm.cont(); Cgm++)
269 G->unsetMark(*Cgm, markVertex);
270 G->freeMark(markVertex);
282 void Analytic_View::Create_Edges_Faces()
286 list<CVertex*> *pl1, *pl2;
287 list<CVertex*>::iterator iter;
293 bool biplanes =
false, noEdge;
297 int markEdge = G->getNewMark();
300 CDynamicCoverageAll Cgm(G);
301 for (Cgm.reinit(); Cgm.cont(); Cgm++)
306 if (!G->isMarked(dgm, markEdge) && !G->isFree0(dgm))
310 list<CVertex*> *l = (list<CVertex*>*)pList->
Get_Data();
314 p1 = (CAttributeVertex*)alpha;
315 alpha = G->getAttribute(G->alpha0(dgm),ORBIT_123,
317 p2 = (CAttributeVertex*)alpha;
320 Vector3D edgeVec(p2->getX()-p1->getX(),
321 p2->getY()-p1->getY(),
322 p2->getZ()-p1->getZ());
329 pl1 = (list<CVertex*>*)G->getDirectInfo(G->getEmbeddingOwner(dgm, ORBIT_123),directInfo);
330 pl2 = (list<CVertex*>*)G->getDirectInfo(G->getEmbeddingOwner(G->alpha0(dgm),ORBIT_123),directInfo);
333 for (
int i=0; i<6; i++)
349 for (iter = pl1->begin() ;
350 iter != pl1->end() && tmpNb < 2 ;
355 nearest[tmpNb] = *iter;
361 for (iter = pl2->begin() ;
362 iter != pl2->end() && tmpNb < 4 ;
367 nearest[tmpNb] = *iter;
373 Vector3D v(nearest[2]->getX()-nearest[0]->getX(),
374 nearest[2]->getY()-nearest[0]->getY(),
375 nearest[2]->getZ()-nearest[0]->getZ());
377 l->push_front(nearest[0]);
378 l->push_front(nearest[1]);
382 l->push_front(nearest[3]);
383 l->push_front(nearest[2]);
387 l->push_front(nearest[2]);
388 l->push_front(nearest[3]);
395 if ((*p2-*p1).norm()<1.0)
398 length = 2.0*(*p2-*p1).norm();
404 for (iter = pl1->begin();
405 iter != pl1->end() && tmpNb<4;
411 if ((*p2-**iter).norm()
417 nearest[tmpNb] = nearest[0];
426 if(fabs((*p2-**iter).norm()
431 nearest[tmpNb] = nearest[1];
439 nearest[tmpNb]=*iter;
451 if ((*p1-*p2).norm()<1.0)
454 length = 2.0*(*p1-*p2).norm();
460 if (i == 0 || i == 1)
461 eq.
SetAbcw(0, 0, 1, nearest[0]->getZ());
464 if (i == 2 || i == 3)
465 eq.
SetAbcw(1, 0, 0, nearest[0]->getX());
468 eq.
SetAbcw(0, 1, 0, nearest[0]->getY());
472 for (
int i=2; i<4; i++)
477 nearest[1] = nearest[i];
484 for (iter=pl2->begin();
485 iter!=pl2->end() && tmpNb<4;
495 -nearest[1]->getZ());
503 if((*p1-**iter).norm()
505 length = (*p1-**iter).norm();
522 if (nearest[2]->getX() == nearest[3]->getX())
524 eq2.
SetAbcw(1,0,0,nearest[3]->getX());
528 if (nearest[2]->getY() == nearest[3]->getY()
531 eq2.
SetAbcw(0,1,0,nearest[3]->getY());
536 if (nearest[2]->getZ() == nearest[3]->getZ()
539 eq2.
SetAbcw(0,0,1,nearest[3]->getZ());
543 nearest[0] = ineq->
Intersec (eq, eq2);
544 nearest[3] = nearest[0];
555 for (iter=pl2->begin();
556 iter!=pl2->end() && tmpNb < 4;
568 -nearest[1]->getZ());
575 -nearest[0]->getZ());
579 if ( v1.Vect_Product(edgeVec) ==
589 if ( v0.Vect_Product(edgeVec) ==
607 l->push_front(nearest[0]);
608 l->push_front(nearest[1]);
609 l->push_front(nearest[2]);
610 l->push_front(nearest[3]);
617 G->addAttribute(dgm, ORBIT_023, pList);
620 CCoverage* DCe = G->getDynamicCoverage(dgm, ORBIT_023);
621 for(DCe->reinit(); DCe->cont(); (*DCe)++)
622 G->setMark(**DCe, markEdge);
627 for (Cgm.reinit(); Cgm.cont(); Cgm++)
628 G->unsetMark(*Cgm, markEdge);
629 G->freeMark(markEdge);
641 void Analytic_View::Create_Faces()
646 list<CVertex*>::iterator iter;
651 Inequation **faceIneq = NULL, **faceIneq2 = NULL;
653 int nbPoints, realNbPoints;
658 int markFace = G->getNewMark();
661 CDynamicCoverageAll Cgm(G);
662 for (Cgm.reinit(); Cgm.cont(); Cgm++)
667 if (!G->isMarked(dgm, markFace) &&
668 G->getEmbeddingOwner(dgm, ORBIT_013))
672 list<CVertex*> *l = (list<CVertex*>*)pList->
Get_Data();
680 nbPoints = *(((
Int_Att*)alpha)->Get_Data());
683 for (
int i=0 ; i<2 ; i++)
699 CCoverage* DC01 = G->getDynamicCoverage(dgm, ORBIT_01);
707 if (!G->isMarked(d01, markFace))
711 alpha = G->getAttribute(d01,ORBIT_023,
714 alpha = G->getAttribute(d01,ORBIT_0,
720 for (
int j=0; j<6; j++)
725 G->setMark(d01, markFace);
726 G->setMark(G->alpha0(d01), markFace);
738 for (
int j=0 ; j<nbPoints ; j++)
742 for (
int k=j+1 ; k<nbPoints+1 && !testPoint; k++)
761 *faceIneq[k%nbPoints]);
765 for (
int m=0 ; m<nbPoints && testPoint ; m++)
767 if (m != j && m != k%nbPoints)
768 if (faceIneq[m]->Test_Point(*p) &&
769 !faceIneq[m]->Test_Point_Eq(*p))
781 if (lastPt == NULL ||
782 (lastPt != NULL && *lastPt != *p))
812 CCoverage* DC01 = G->getDynamicCoverage(dgm, ORBIT_01);
820 if (!G->isMarked(d01, markFace))
827 alpha = G->getAttribute(d01,ORBIT_023,
830 alpha = G->getAttribute(d01,ORBIT_0,
835 for (
int j=0; j<6; j++)
843 G->setMark(d01, markFace);
844 G->setMark(G->alpha0(d01), markFace);
853 G->unsetMark(**DC01, markFace);
870 CCoverage* DC01 = G->getDynamicCoverage(dgm, ORBIT_01);
878 if (!G->isMarked(d01, markFace))
881 pl = (list<CVertex*>*)G->getDirectInfo(G->getEmbeddingOwner
882 (d01,ORBIT_123),directInfo);
887 for (iter=pl->begin();
892 for (
int j=2*k; j<2*k+2; j++)
895 ->Test_Point_Eq(**iter))
898 faceIneq[k] = faceIneq2[j];
904 G->setMark(d01, markFace);
905 G->setMark(G->alpha1(d01), markFace);
916 G->unsetMark(**DC01, markFace);
925 for (
int j=0 ; j<nbPoints ; j++)
930 for (k=j+1 ; k<nbPoints+1 && !testPoint; k++)
936 .Vect_Product(
Vector3D(faceIneq[k%nbPoints]
948 *faceIneq[k%nbPoints]);
952 for (
int m=0 ; m<nbPoints && testPoint ; m++)
954 if (m != j && m != k%nbPoints)
955 if (faceIneq[m]->Test_Point(*p) &&
956 !faceIneq[m]->Test_Point_Eq(*p))
968 if (lastPt == NULL ||
969 (lastPt != NULL && *lastPt != *p))
994 CCoverage* DC01 = G->getDynamicCoverage(dgm, ORBIT_01);
1002 if (!G->isMarked(d01, markFace))
1005 pl = (list<CVertex*>*)G->getDirectInfo(G->getEmbeddingOwner
1006 (d01, ORBIT_123),directInfo);
1010 for (iter=pl->begin();
1016 l->push_front(*iter);
1019 G->setMark(d01, markFace);
1020 G->setMark(G->alpha1(d01), markFace);
1027 for (DC01->reinit();
1030 G->unsetMark(**DC01, markFace);
1035 realNbPoints = nbPoints;
1041 G->addAttribute(dgm, ORBIT_013, pList);
1047 *(((
Int_Att*)alpha)->Get_Data()) = realNbPoints;
1050 G->setMark(dgm, markFace);
1054 for (Cgm.reinit(); Cgm.cont(); Cgm++)
1055 G->unsetMark(*Cgm, markFace);
1056 G->freeMark(markFace);
1069 void Analytic_View::Draw_List(list<CVertex*> *l,
int nbPoints)
const
1074 CVertex ** tab =
new CVertex*[nbPoints];
1079 list<CVertex*>::iterator iter;
1080 for (iter=l->begin();
1088 if (count == nbPoints)
1095 if (normal.norm()>
EPS)
1099 glBegin(GL_POLYGON);
1100 glNormal3f(normal.getX(), normal.getY(), normal.getZ());
1101 for (
int i=0; i<nbPoints; i++)
1102 glVertex3f(tab[i]->getX(), tab[i]->getY(), tab[i]->getZ());
1121 void Analytic_View::Vertices_Draw()
1123 int markVertex = G->getNewMark();
1126 glEnable(GL_LIGHTING);
1127 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
1128 glShadeModel(GL_SMOOTH);
1131 CDynamicCoverageAll C(G);
1134 for (C.reinit(); C.cont(); C++)
1139 if (!G->isMarked(d, markVertex))
1145 Draw_List(((
Point_List*)alpha)->Get_Data(), 4);
1148 CCoverage* DCv = G->getDynamicCoverage(d, ORBIT_123);
1149 for(DCv->reinit(); DCv->cont(); (*DCv)++)
1150 G->setMark(**DCv, markVertex);
1156 for (C.reinit(); C.cont(); C++)
1157 G->unsetMark(*C, markVertex);
1158 G->freeMark(markVertex);
1161 glDisable(GL_LIGHTING);
1162 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
1163 glShadeModel(GL_FLAT);
1175 void Analytic_View::Edges_Draw()
1178 int markEdge = G->getNewMark();
1181 CDynamicCoverageAll C(G);
1184 glEnable(GL_LIGHTING);
1185 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
1186 glShadeModel(GL_SMOOTH);
1189 for (C.reinit(); C.cont(); C++)
1194 if (!G->isMarked(d, markEdge) && !G->isFree0(d))
1200 Draw_List(((
Point_List*)alpha)->Get_Data(), 4);
1203 CCoverage* DCe = G->getDynamicCoverage(d, ORBIT_023);
1204 for(DCe->reinit(); DCe->cont(); (*DCe)++)
1205 G->setMark(**DCe, markEdge);
1211 for (C.reinit(); C.cont(); C++)
1212 G->unsetMark(*C, markEdge);
1213 G->freeMark(markEdge);
1217 glDisable(GL_LIGHTING);
1218 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
1219 glShadeModel(GL_FLAT);
1230 void Analytic_View::Faces_Draw()
1237 int markFace = G->getNewMark();
1240 CDynamicCoverageAll C(G);
1243 glEnable(GL_LIGHTING);
1244 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
1245 glShadeModel(GL_SMOOTH);
1248 for (C.reinit(); C.cont(); C++)
1253 if(!G->isMarked(d, markFace) && G->getEmbeddingOwner(d, ORBIT_013))
1257 nbPoints = *(((
Int_Att*)alpha)->Get_Data());
1263 Draw_List(((
Point_List*)alpha)->Get_Data(), nbPoints);
1266 CCoverage* DCf = G->getDynamicCoverage(d, ORBIT_013);
1267 for(DCf->reinit(); DCf->cont(); (*DCf)++)
1268 G->setMark(**DCf, markFace);
1274 for (C.reinit(); C.cont(); C++)
1275 G->unsetMark(*C, markFace);
1276 G->freeMark(markFace);
1280 glDisable(GL_LIGHTING);
1281 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
1282 glShadeModel(GL_FLAT);