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 "analytic-view.hh"
00036 #include "ineq-table-6.hh"
00037 #include "ineq-table-6-att.hh"
00038 #include "int-att.hh"
00039 #include "ineq-use-att.hh"
00040 #include "ineq-table-2-att.hh"
00041 #include "ineq-table-2.hh"
00042 #include "ineq-use.hh"
00043 #include "definition.hh"
00044 #include "vector3d.hh"
00045 #include "point-list.hh"
00046 #include "attribute-vertex.hh"
00047
00048 using namespace std;
00049 using namespace GMap3d;
00050
00051
00052
00053
00054 Analytic_View::Analytic_View(CGMap * GM)
00055 {
00056 G = GM;
00057 directInfo = G->getNewDirectInfo();
00058 }
00059
00060
00061
00062 Analytic_View::~Analytic_View()
00063 {
00064
00065 G->freeDirectInfo(directInfo);
00066 }
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 void Analytic_View::Create_Vertices_Faces()
00077 {
00078 CAttribute* alpha;
00079 Ineq_Table6* t;
00080 CVertex* p;
00081
00082
00083
00084 int markVertex = G->getNewMark();
00085
00086
00087 CDynamicCoverageAll Cgm(G);
00088 for (Cgm.reinit(); Cgm.cont(); Cgm++)
00089 {
00090 CDart* dgm = *Cgm;
00091
00092
00093 if (!G->isMarked(dgm, markVertex))
00094 {
00095
00096 Point_List* pList = new Point_List();
00097 list<CVertex*> *vL = (list<CVertex*>*)pList->Get_Data();
00098
00099
00100 list<CVertex*> *l = new list<CVertex*>;
00101
00102
00103
00104 alpha = G->getAttribute(dgm,ORBIT_123,INEQ6_ATTRIBUTE_ID);
00105 t = ((Ineq_Table6_Att*)alpha)->Get_Data();
00106 alpha = G->getAttribute(dgm,ORBIT_123,VERTEX_ATTRIBUTE_ID);
00107 p = (CAttributeVertex*)alpha;
00108
00109
00110 l->push_front(new CVertex(p->getX()+0.5,
00111 p->getY()+0.5,
00112 p->getZ()+0.5));
00113 l->push_front(new CVertex(p->getX()+0.5,
00114 p->getY()+0.5,
00115 p->getZ()-0.5));
00116 l->push_front(new CVertex(p->getX()+0.5,
00117 p->getY()-0.5,
00118 p->getZ()-0.5));
00119 l->push_front(new CVertex(p->getX()+0.5,
00120 p->getY()-0.5,
00121 p->getZ()+0.5));
00122 l->push_front(new CVertex(p->getX()-0.5,
00123 p->getY()+0.5,
00124 p->getZ()+0.5));
00125 l->push_front(new CVertex(p->getX()-0.5,
00126 p->getY()+0.5,
00127 p->getZ()-0.5));
00128 l->push_front(new CVertex(p->getX()-0.5,
00129 p->getY()-0.5,
00130 p->getZ()-0.5));
00131 l->push_front(new CVertex(p->getX()-0.5,
00132 p->getY()-0.5,
00133 p->getZ()+0.5));
00134
00135
00136
00137
00138 G->setDirectInfo(G->getEmbeddingOwner(dgm, ORBIT_123),directInfo,l);
00139
00140
00141 for (int i = 0 ; i<6 ; i++)
00142 {
00143
00144 Inequation *ineq = t->Get_Ineq(i);
00145
00146
00147 if (ineq->Is_Used())
00148 {
00149
00150 switch (i)
00151 {
00152 case 0:
00153 vL->push_front(new CVertex(ineq->GetW(),
00154 p->getY()+0.5,
00155 p->getZ()+0.5));
00156 vL->push_front(new CVertex(ineq->GetW(),
00157 p->getY()+0.5,
00158 p->getZ()-0.5));
00159 vL->push_front(new CVertex(ineq->GetW(),
00160 p->getY()-0.5,
00161 p->getZ()-0.5));
00162 vL->push_front(new CVertex(ineq->GetW(),
00163 p->getY()-0.5,
00164 p->getZ()+0.5));
00165 break;
00166
00167 case 1:
00168 vL->push_front(new CVertex(-ineq->GetW(),
00169 p->getY()+0.5,
00170 p->getZ()+0.5));
00171 vL->push_front(new CVertex(-ineq->GetW(),
00172 p->getY()+0.5,
00173 p->getZ()-0.5));
00174 vL->push_front(new CVertex(-ineq->GetW(),
00175 p->getY()-0.5,
00176 p->getZ()-0.5));
00177 vL->push_front(new CVertex(-ineq->GetW(),
00178 p->getY()-0.5,
00179 p->getZ()+0.5));
00180 break;
00181
00182 case 2:
00183 vL->push_front(new CVertex(p->getX()+0.5,
00184 ineq->GetW(),
00185 p->getZ()+0.5));
00186 vL->push_front(new CVertex(p->getX()+0.5,
00187 ineq->GetW(),
00188 p->getZ()-0.5));
00189 vL->push_front(new CVertex(p->getX()-0.5,
00190 ineq->GetW(),
00191 p->getZ()-0.5));
00192 vL->push_front(new CVertex(p->getX()-0.5,
00193 ineq->GetW(),
00194 p->getZ()+0.5));
00195 break;
00196
00197 case 3:
00198 vL->push_front(new CVertex(p->getX()+0.5,
00199 -ineq->GetW(),
00200 p->getZ()+0.5));
00201 vL->push_front(new CVertex(p->getX()+0.5,
00202 -ineq->GetW(),
00203 p->getZ()-0.5));
00204 vL->push_front(new CVertex(p->getX()-0.5,
00205 -ineq->GetW(),
00206 p->getZ()-0.5));
00207 vL->push_front(new CVertex(p->getX()-0.5,
00208 -ineq->GetW(),
00209 p->getZ()+0.5));
00210 break;
00211
00212 case 4:
00213 vL->push_front(new CVertex(p->getX()+0.5,
00214 p->getY()+0.5,
00215 ineq->GetW()));
00216 vL->push_front(new CVertex(p->getX()+0.5,
00217 p->getY()-0.5,
00218 ineq->GetW()));
00219 vL->push_front(new CVertex(p->getX()-0.5,
00220 p->getY()-0.5,
00221 ineq->GetW()));
00222 vL->push_front(new CVertex(p->getX()-0.5,
00223 p->getY()+0.5,
00224 ineq->GetW()));
00225 break;
00226
00227 case 5:
00228 vL->push_front(new CVertex(p->getX()+0.5,
00229 p->getY()+0.5,
00230 -ineq->GetW()));
00231 vL->push_front(new CVertex(p->getX()+0.5,
00232 p->getY()-0.5,
00233 -ineq->GetW()));
00234 vL->push_front(new CVertex(p->getX()-0.5,
00235 p->getY()-0.5,
00236 -ineq->GetW()));
00237 vL->push_front(new CVertex(p->getX()-0.5,
00238 p->getY()+0.5,
00239 -ineq->GetW()));
00240 break;
00241
00242 default:
00243 break;
00244 }
00245 }
00246 }
00247
00248
00249 G->addAttribute(dgm, ORBIT_123, pList);
00250
00251
00252 CCoverage* DCv = G->getDynamicCoverage(dgm, ORBIT_123);
00253 for(DCv->reinit(); DCv->cont(); (*DCv)++)
00254 G->setMark(**DCv, markVertex);
00255 delete DCv;
00256 }
00257 }
00258
00259
00260 for (Cgm.reinit(); Cgm.cont(); Cgm++)
00261 G->unsetMark(*Cgm, markVertex);
00262 G->freeMark(markVertex);
00263
00264 }
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274 void Analytic_View::Create_Edges_Faces()
00275 {
00276 CAttribute* alpha;
00277 Ineq_Table6* t;
00278 list<CVertex*> *pl1, *pl2;
00279 list<CVertex*>::iterator iter;
00280 CVertex *p1, *p2;
00281 CVertex* nearest[4];
00282
00283 int tmpNb;
00284 float length;
00285 bool biplanes = false, noEdge;
00286
00287
00288
00289 int markEdge = G->getNewMark();
00290
00291
00292 CDynamicCoverageAll Cgm(G);
00293 for (Cgm.reinit(); Cgm.cont(); Cgm++)
00294 {
00295 CDart* dgm = *Cgm;
00296
00297
00298 if (!G->isMarked(dgm, markEdge) && !G->isFree0(dgm))
00299 {
00300
00301 Point_List* pList = new Point_List();
00302 list<CVertex*> *l = (list<CVertex*>*)pList->Get_Data();
00303
00304
00305 alpha = G->getAttribute(dgm,ORBIT_123,VERTEX_ATTRIBUTE_ID);
00306 p1 = (CAttributeVertex*)alpha;
00307 alpha = G->getAttribute(G->alpha0(dgm),ORBIT_123,
00308 VERTEX_ATTRIBUTE_ID);
00309 p2 = (CAttributeVertex*)alpha;
00310
00311
00312 Vector3D edgeVec(p2->getX()-p1->getX(),
00313 p2->getY()-p1->getY(),
00314 p2->getZ()-p1->getZ());
00315
00316
00317 alpha = G->getAttribute(dgm,ORBIT_023,INEQ6_ATTRIBUTE_ID);
00318 t = ((Ineq_Table6_Att*)alpha)->Get_Data();
00319
00320
00321 pl1 = (list<CVertex*>*)G->getDirectInfo(G->getEmbeddingOwner(dgm, ORBIT_123),directInfo);
00322 pl2 = (list<CVertex*>*)G->getDirectInfo(G->getEmbeddingOwner(G->alpha0(dgm),ORBIT_123),directInfo);
00323
00324
00325 for (int i=0; i<6; i++)
00326 {
00327
00328 Inequation *ineq = t->Get_Ineq(i);
00329
00330 if (ineq->Is_Used())
00331 {
00332 noEdge=false;
00333
00334
00335 if (ineq->Get_Dim()!=1)
00336 {
00337 tmpNb = 0;
00338
00339
00340
00341 for (iter = pl1->begin() ;
00342 iter != pl1->end() && tmpNb < 2 ;
00343 iter++)
00344
00345 if (ineq->Test_Point_Eq(**iter))
00346 {
00347 nearest[tmpNb] = *iter;
00348 tmpNb++;
00349 }
00350
00351
00352
00353 for (iter = pl2->begin() ;
00354 iter != pl2->end() && tmpNb < 4 ;
00355 iter++)
00356
00357 if (ineq->Test_Point_Eq(**iter))
00358 {
00359 nearest[tmpNb] = *iter;
00360 tmpNb++;
00361 }
00362
00363
00364
00365 Vector3D v(nearest[2]->getX()-nearest[0]->getX(),
00366 nearest[2]->getY()-nearest[0]->getY(),
00367 nearest[2]->getZ()-nearest[0]->getZ());
00368
00369 l->push_front(nearest[0]);
00370 l->push_front(nearest[1]);
00371
00372 if (v == edgeVec)
00373 {
00374 l->push_front(nearest[3]);
00375 l->push_front(nearest[2]);
00376 }
00377 else
00378 {
00379 l->push_front(nearest[2]);
00380 l->push_front(nearest[3]);
00381 }
00382 }
00383
00384
00385 else
00386 {
00387 if ((*p2-*p1).norm()<1.0)
00388 length = 2.0;
00389 else
00390 length = 2.0*(*p2-*p1).norm();
00391
00392 tmpNb = 0;
00393
00394
00395
00396 for (iter = pl1->begin();
00397 iter != pl1->end() && tmpNb<4;
00398 iter++)
00399 {
00400 if(ineq->Test_Point_Eq(**iter))
00401 {
00402
00403 if ((*p2-**iter).norm()
00404 <length-EPS)
00405 {
00406 length =
00407 (*p2-**iter).norm();
00408 if (tmpNb != 0)
00409 nearest[tmpNb] = nearest[0];
00410
00411 nearest[0] = *iter;
00412 biplanes = false;
00413
00414 }
00415
00416
00417 else
00418 if(fabs((*p2-**iter).norm()
00419 -length)
00420 <= EPS)
00421 {
00422 if (tmpNb != 1)
00423 nearest[tmpNb] = nearest[1];
00424
00425 nearest[1] = *iter;
00426 biplanes = true;
00427 }
00428
00429
00430 else
00431 nearest[tmpNb]=*iter;
00432
00433 tmpNb++;
00434 }
00435 }
00436
00437
00438 if (!biplanes)
00439 {
00440 CVertex* tmp;
00441 tmpNb = 0;
00442
00443 if ((*p1-*p2).norm()<1.0)
00444 length = 2.0;
00445 else
00446 length = 2.0*(*p1-*p2).norm();
00447
00448
00449
00450 Inequation eq;
00451
00452 if (i == 0 || i == 1)
00453 eq.SetAbcw(0, 0, 1, nearest[0]->getZ());
00454
00455 else
00456 if (i == 2 || i == 3)
00457 eq.SetAbcw(1, 0, 0, nearest[0]->getX());
00458
00459 else
00460 eq.SetAbcw(0, 1, 0, nearest[0]->getY());
00461
00462
00463
00464 for (int i=2; i<4; i++)
00465 {
00466 if (eq.Test_Point_Eq (*nearest[i]))
00467 {
00468 tmp = nearest[1];
00469 nearest[1] = nearest[i];
00470 nearest[i] = tmp;
00471 }
00472 }
00473
00474
00475
00476 for (iter=pl2->begin();
00477 iter!=pl2->end() && tmpNb<4;
00478 iter++)
00479 {
00480 if (ineq->Test_Point_Eq(**iter))
00481 {
00482 Vector3D v((*iter)->getX()
00483 -nearest[1]->getX(),
00484 (*iter)->getY()
00485 -nearest[1]->getY(),
00486 (*iter)->getZ()
00487 -nearest[1]->getZ());
00488
00489
00490 if (edgeVec == v)
00491 nearest[2] = *iter;
00492
00493
00494 else
00495 if((*p1-**iter).norm()
00496 <length-EPS){
00497 length = (*p1-**iter).norm();
00498 nearest[3] = *iter;
00499 }
00500 tmpNb++;
00501 }
00502 }
00503
00504
00505
00506
00507 if (Vector3D(*nearest[0],
00508 *nearest[3]).Scal_Product(edgeVec)
00509 <0.0)
00510 {
00511 Inequation eq2;
00512 bool found = false;
00513
00514 if (nearest[2]->getX() == nearest[3]->getX())
00515 {
00516 eq2.SetAbcw(1,0,0,nearest[3]->getX());
00517 if (eq2 != *ineq)
00518 found = true;
00519 }
00520 if (nearest[2]->getY() == nearest[3]->getY()
00521 && !found)
00522 {
00523 eq2.SetAbcw(0,1,0,nearest[3]->getY());
00524 if (eq2 != *ineq)
00525 found = true;
00526 }
00527
00528 if (nearest[2]->getZ() == nearest[3]->getZ()
00529 && !found)
00530 {
00531 eq2.SetAbcw(0,0,1,nearest[3]->getZ());
00532 if (eq2 != *ineq)
00533 found = true;
00534 }
00535 nearest[0] = ineq->Intersec (eq, eq2);
00536 nearest[3] = nearest[0];
00537 }
00538 }
00539
00540
00541 else
00542 {
00543 tmpNb = 0;
00544
00545
00546
00547 for (iter=pl2->begin();
00548 iter!=pl2->end() && tmpNb < 4;
00549 iter++)
00550 {
00551 if(ineq->Test_Point_Eq(**iter))
00552 {
00553
00554
00555 Vector3D v1((*iter)->getX()
00556 -nearest[1]->getX(),
00557 (*iter)->getY()
00558 -nearest[1]->getY(),
00559 (*iter)->getZ()
00560 -nearest[1]->getZ());
00561
00562 Vector3D v0((*iter)->getX()
00563 -nearest[0]->getX(),
00564 (*iter)->getY()
00565 -nearest[0]->getY(),
00566 (*iter)->getZ()
00567 -nearest[0]->getZ());
00568
00569
00570
00571 if ( v1.Vect_Product(edgeVec) ==
00572 Vector3D(0, 0, 0))
00573 {
00574 if (v1 != edgeVec)
00575 nearest[2] = *iter;
00576 }
00577
00578
00579
00580 else
00581 if ( v0.Vect_Product(edgeVec) ==
00582 Vector3D(0, 0, 0))
00583 {
00584 if (v0 != edgeVec)
00585 nearest[3] = *iter;
00586 }
00587 tmpNb++;
00588 }
00589 }
00590
00591 if (Vector3D(*nearest[0],
00592 *nearest[3]).Scal_Product(edgeVec)
00593 +1<EPS)
00594 noEdge=true;
00595 }
00596 if (!noEdge)
00597 {
00598
00599 l->push_front(nearest[0]);
00600 l->push_front(nearest[1]);
00601 l->push_front(nearest[2]);
00602 l->push_front(nearest[3]);
00603 }
00604 }
00605 }
00606 }
00607
00608
00609 G->addAttribute(dgm, ORBIT_023, pList);
00610
00611
00612 CCoverage* DCe = G->getDynamicCoverage(dgm, ORBIT_023);
00613 for(DCe->reinit(); DCe->cont(); (*DCe)++)
00614 G->setMark(**DCe, markEdge);
00615 delete DCe;
00616 }
00617 }
00618
00619 for (Cgm.reinit(); Cgm.cont(); Cgm++)
00620 G->unsetMark(*Cgm, markEdge);
00621 G->freeMark(markEdge);
00622
00623 }
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633 void Analytic_View::Create_Faces()
00634 {
00635 CAttribute* alpha;
00636 Ineq_Table2* tf;
00637 list<CVertex*> *pl;
00638 list<CVertex*>::iterator iter;
00639 Ineq_Table6 *te;
00640 CVertex* p, *lastPt;
00641 Ineq_Use *u;
00642 CDart *dgm, *d01;
00643 Inequation **faceIneq = NULL, **faceIneq2 = NULL;
00644
00645 int nbPoints, realNbPoints;
00646 bool testPoint;
00647
00648
00649
00650 int markFace = G->getNewMark();
00651
00652
00653 CDynamicCoverageAll Cgm(G);
00654 for (Cgm.reinit(); Cgm.cont(); Cgm++)
00655 {
00656 dgm = *Cgm;
00657
00658
00659 if (!G->isMarked(dgm, markFace) &&
00660 G->getEmbeddingOwner(dgm, ORBIT_013))
00661 {
00662
00663 Point_List* pList = new Point_List();
00664 list<CVertex*> *l = (list<CVertex*>*)pList->Get_Data();
00665
00666
00667 alpha = G->getAttribute(dgm,ORBIT_013,INEQ2_ATTRIBUTE_ID);
00668 tf = ((Ineq_Table2_Att*)alpha)->Get_Data();
00669
00670
00671 alpha = G->getAttribute(dgm,ORBIT_013,INT_ATTRIBUTE_ID);
00672 nbPoints = *(((Int_Att*)alpha)->Get_Data());
00673
00674
00675 for (int i=0 ; i<2 ; i++)
00676 {
00677 Inequation *ineq = tf->Get_Ineq(i);
00678
00679
00680
00681 if (ineq->Get_Dim() == 1)
00682 {
00683 if (i == 0)
00684 {
00685 int k = 0;
00686
00687
00688 faceIneq = new Inequation*[nbPoints];
00689
00690
00691 CCoverage* DC01 = G->getDynamicCoverage(dgm, ORBIT_01);
00692 for (DC01->reinit();
00693 DC01->cont();
00694 (*DC01)++)
00695 {
00696 d01 = **DC01;
00697
00698
00699 if (!G->isMarked(d01, markFace))
00700 {
00701
00702
00703 alpha = G->getAttribute(d01,ORBIT_023,
00704 INEQ6_ATTRIBUTE_ID);
00705 te = ((Ineq_Table6_Att*)alpha)->Get_Data();
00706 alpha = G->getAttribute(d01,ORBIT_0,
00707 USE_ATTRIBUTE_ID);
00708 u = ((Ineq_Use_Att*)alpha)->Get_Data();
00709
00710
00711
00712 for (int j=0; j<6; j++)
00713 if (!u->Get_Use(j) &&
00714 te->Get_Ineq(j)->Get_Dim()!=0)
00715 faceIneq[k++] = te->Get_Ineq(j);
00716
00717 G->setMark(d01, markFace);
00718 G->setMark(G->alpha0(d01), markFace);
00719 }
00720 }
00721 delete DC01;
00722 }
00723
00724 lastPt = NULL;
00725
00726
00727 realNbPoints = 0;
00728
00729
00730 for (int j=0 ; j<nbPoints ; j++)
00731 {
00732 testPoint = false;
00733
00734 for (int k=j+1 ; k<nbPoints+1 && !testPoint; k++)
00735 {
00736
00737
00738 if(Vector3D(faceIneq[j]->GetA(),
00739 faceIneq[j]->GetB(),
00740 faceIneq[j]->GetC())
00741 .Vect_Product(Vector3D(faceIneq[k%nbPoints]
00742 ->GetA(),
00743 faceIneq[k%nbPoints]
00744 ->GetB(),
00745 faceIneq[k%nbPoints]
00746 ->GetC()))
00747 != Vector3D(0,0,0))
00748 {
00749 testPoint = true;
00750
00751
00752 p = ineq->Intersec(*faceIneq[j],
00753 *faceIneq[k%nbPoints]);
00754
00755
00756
00757 for (int m=0 ; m<nbPoints && testPoint ; m++)
00758 {
00759 if (m != j && m != k%nbPoints)
00760 if (faceIneq[m]->Test_Point(*p) &&
00761 !faceIneq[m]->Test_Point_Eq(*p))
00762 {
00763 testPoint = false;
00764 delete p;
00765 }
00766 }
00767 }
00768
00769
00770 if (testPoint)
00771 {
00772
00773 if (lastPt == NULL ||
00774 (lastPt != NULL && *lastPt != *p))
00775 {
00776
00777 l->push_front(p);
00778 lastPt = p;
00779 realNbPoints++;
00780 }
00781 else
00782 delete p;
00783 }
00784 }
00785 }
00786
00787 if (i == 1)
00788 delete [] faceIneq;
00789 }
00790
00791
00792 else
00793 if (ineq->Get_Dim() == 2)
00794 {
00795 int k = 0;
00796
00797 if (i == 0)
00798 {
00799
00800
00801 faceIneq2 = new Inequation*[nbPoints*2];
00802
00803
00804 CCoverage* DC01 = G->getDynamicCoverage(dgm, ORBIT_01);
00805 for (DC01->reinit();
00806 DC01->cont();
00807 (*DC01)++)
00808 {
00809 d01 = **DC01;
00810
00811
00812 if (!G->isMarked(d01, markFace))
00813 {
00814
00815
00816
00817
00818
00819 alpha = G->getAttribute(d01,ORBIT_023,
00820 INEQ6_ATTRIBUTE_ID);
00821 te = ((Ineq_Table6_Att*)alpha)->Get_Data();
00822 alpha = G->getAttribute(d01,ORBIT_0,
00823 USE_ATTRIBUTE_ID);
00824 u = ((Ineq_Use_Att*)alpha)->Get_Data();
00825
00826
00827 for (int j=0; j<6; j++)
00828 {
00829 if (!u->Get_Use(j) &&
00830 te->Get_Ineq(j)->Get_Dim()!=0)
00831 {
00832 faceIneq2[k++] = te->Get_Ineq(j);
00833 }
00834 }
00835 G->setMark(d01, markFace);
00836 G->setMark(G->alpha0(d01), markFace);
00837 }
00838 }
00839
00840
00841 for (DC01->reinit();
00842 DC01->cont();
00843 (*DC01)++)
00844 {
00845 G->unsetMark(**DC01, markFace);
00846 }
00847
00848
00849 delete DC01;
00850
00851 }
00852
00853
00854
00855
00856
00857 faceIneq = new Inequation*[nbPoints];
00858
00859 k = 0;
00860
00861
00862 CCoverage* DC01 = G->getDynamicCoverage(dgm, ORBIT_01);
00863 for (DC01->reinit();
00864 DC01->cont();
00865 (*DC01)++)
00866 {
00867 d01 = **DC01;
00868
00869
00870 if (!G->isMarked(d01, markFace))
00871 {
00872
00873 pl = (list<CVertex*>*)G->getDirectInfo(G->getEmbeddingOwner
00874 (d01,ORBIT_123),directInfo);
00875
00876
00877
00878
00879 for (iter=pl->begin();
00880 iter!=pl->end();
00881 iter++) {
00882 if(ineq->Test_Point_Eq(**iter))
00883 {
00884 for (int j=2*k; j<2*k+2; j++)
00885 {
00886 if (faceIneq2[j]
00887 ->Test_Point_Eq(**iter))
00888
00889
00890 faceIneq[k] = faceIneq2[j];
00891 }
00892 }
00893 }
00894 k++;
00895
00896 G->setMark(d01, markFace);
00897 G->setMark(G->alpha1(d01), markFace);
00898 }
00899 }
00900
00901
00902 if (i==0)
00903 {
00904
00905 for (DC01->reinit();
00906 DC01->cont();
00907 (*DC01)++)
00908 G->unsetMark(**DC01, markFace);
00909 }
00910 delete DC01;
00911
00912 lastPt = NULL;
00913
00914
00915 realNbPoints = 0;
00916
00917 for (int j=0 ; j<nbPoints ; j++)
00918 {
00919 testPoint = false;
00920
00921
00922 for (k=j+1 ; k<nbPoints+1 && !testPoint; k++)
00923 {
00924
00925 if(Vector3D(faceIneq[j]->GetA(),
00926 faceIneq[j]->GetB(),
00927 faceIneq[j]->GetC())
00928 .Vect_Product(Vector3D(faceIneq[k%nbPoints]
00929 ->GetA(),
00930 faceIneq[k%nbPoints]
00931 ->GetB(),
00932 faceIneq[k%nbPoints]
00933 ->GetC()))
00934 != Vector3D(0,0,0))
00935 {
00936 testPoint = true;
00937
00938
00939 p = ineq->Intersec(*faceIneq[j],
00940 *faceIneq[k%nbPoints]);
00941
00942
00943
00944 for (int m=0 ; m<nbPoints && testPoint ; m++)
00945 {
00946 if (m != j && m != k%nbPoints)
00947 if (faceIneq[m]->Test_Point(*p) &&
00948 !faceIneq[m]->Test_Point_Eq(*p))
00949 {
00950 testPoint = false;
00951 delete p;
00952 }
00953 }
00954 }
00955
00956
00957 if (testPoint)
00958 {
00959
00960 if (lastPt == NULL ||
00961 (lastPt != NULL && *lastPt != *p))
00962 {
00963
00964 l->push_front(p);
00965 lastPt = p;
00966 realNbPoints++;
00967 }
00968 else
00969 delete p;
00970 }
00971 }
00972 }
00973
00974 delete [] faceIneq;
00975
00976 if (i==1)
00977 delete [] faceIneq2;
00978 }
00979
00980
00981
00982 else
00983 {
00984
00985
00986 CCoverage* DC01 = G->getDynamicCoverage(dgm, ORBIT_01);
00987 for (DC01->reinit();
00988 DC01->cont();
00989 (*DC01)++)
00990 {
00991 d01 = **DC01;
00992
00993
00994 if (!G->isMarked(d01, markFace))
00995 {
00996
00997 pl = (list<CVertex*>*)G->getDirectInfo(G->getEmbeddingOwner
00998 (d01, ORBIT_123),directInfo);
00999
01000
01001
01002 for (iter=pl->begin();
01003 iter!=pl->end();
01004 iter++)
01005
01006
01007 if(ineq->Test_Point_Eq(**iter))
01008 l->push_front(*iter);
01009
01010
01011 G->setMark(d01, markFace);
01012 G->setMark(G->alpha1(d01), markFace);
01013 }
01014 }
01015
01016 if (i==0)
01017 {
01018
01019 for (DC01->reinit();
01020 DC01->cont();
01021 (*DC01)++)
01022 G->unsetMark(**DC01, markFace);
01023 }
01024 delete DC01;
01025
01026
01027 realNbPoints = nbPoints;
01028 }
01029 }
01030
01031
01032 if(!G->getAttribute(dgm, ORBIT_013, PT_LIST_ATTRIBUTE_ID))
01033 G->addAttribute(dgm, ORBIT_013, pList);
01034
01035
01036
01037
01038 alpha = G->getAttribute(dgm, ORBIT_013, INT_ATTRIBUTE_ID);
01039 *(((Int_Att*)alpha)->Get_Data()) = realNbPoints;
01040 }
01041 else
01042 G->setMark(dgm, markFace);
01043 }
01044
01045
01046 for (Cgm.reinit(); Cgm.cont(); Cgm++)
01047 G->unsetMark(*Cgm, markFace);
01048 G->freeMark(markFace);
01049
01050 }
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061 void Analytic_View::Draw_List(list<CVertex*> *l, int nbPoints) const
01062 {
01063 if (nbPoints >= 3)
01064 {
01065 Vector3D normal;
01066 CVertex ** tab = new CVertex*[nbPoints];
01067
01068 int count = 0;
01069
01070
01071 list<CVertex*>::iterator iter;
01072 for (iter=l->begin();
01073 iter!=l->end();
01074 iter++)
01075 {
01076
01077 tab[count] = *iter;
01078 count++;
01079
01080 if (count == nbPoints)
01081 {
01082
01083 Vector3D v1(*tab[0], *tab[1]);
01084 Vector3D v2(*tab[1], *tab[2]);
01085 normal = v1.Vect_Product(v2);
01086
01087 if (normal.norm()>EPS)
01088 normal.Normalize();
01089
01090
01091 glBegin(GL_POLYGON);
01092 glNormal3f(normal.getX(), normal.getY(), normal.getZ());
01093 for (int i=0; i<nbPoints; i++)
01094 glVertex3f(tab[i]->getX(), tab[i]->getY(), tab[i]->getZ());
01095 glEnd();
01096
01097 count = 0;
01098 }
01099 }
01100
01101 delete [] tab;
01102 }
01103 }
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113 void Analytic_View::Vertices_Draw()
01114 {
01115 int markVertex = G->getNewMark();
01116
01117
01118 glEnable(GL_LIGHTING);
01119 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
01120 glShadeModel(GL_SMOOTH);
01121
01122
01123 CDynamicCoverageAll C(G);
01124
01125
01126 for (C.reinit(); C.cont(); C++)
01127 {
01128 CDart* d = *C;
01129
01130
01131 if (!G->isMarked(d, markVertex))
01132 {
01133
01134 CAttribute * alpha = G->getAttribute(d,ORBIT_123, PT_LIST_ATTRIBUTE_ID);
01135
01136
01137 Draw_List(((Point_List*)alpha)->Get_Data(), 4);
01138
01139
01140 CCoverage* DCv = G->getDynamicCoverage(d, ORBIT_123);
01141 for(DCv->reinit(); DCv->cont(); (*DCv)++)
01142 G->setMark(**DCv, markVertex);
01143 delete DCv;
01144 }
01145 }
01146
01147
01148 for (C.reinit(); C.cont(); C++)
01149 G->unsetMark(*C, markVertex);
01150 G->freeMark(markVertex);
01151
01152
01153 glDisable(GL_LIGHTING);
01154 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
01155 glShadeModel(GL_FLAT);
01156 }
01157
01158
01159
01160
01161
01162
01163
01164
01165
01166
01167 void Analytic_View::Edges_Draw()
01168 {
01169
01170 int markEdge = G->getNewMark();
01171
01172
01173 CDynamicCoverageAll C(G);
01174
01175
01176 glEnable(GL_LIGHTING);
01177 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
01178 glShadeModel(GL_SMOOTH);
01179
01180
01181 for (C.reinit(); C.cont(); C++)
01182 {
01183 CDart* d = *C;
01184
01185
01186 if (!G->isMarked(d, markEdge) && !G->isFree0(d))
01187 {
01188
01189 CAttribute* alpha = G->getAttribute(d, ORBIT_023,PT_LIST_ATTRIBUTE_ID);
01190
01191
01192 Draw_List(((Point_List*)alpha)->Get_Data(), 4);
01193
01194
01195 CCoverage* DCe = G->getDynamicCoverage(d, ORBIT_023);
01196 for(DCe->reinit(); DCe->cont(); (*DCe)++)
01197 G->setMark(**DCe, markEdge);
01198 delete DCe;
01199 }
01200 }
01201
01202
01203 for (C.reinit(); C.cont(); C++)
01204 G->unsetMark(*C, markEdge);
01205 G->freeMark(markEdge);
01206
01207
01208
01209 glDisable(GL_LIGHTING);
01210 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
01211 glShadeModel(GL_FLAT);
01212 }
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222 void Analytic_View::Faces_Draw()
01223 {
01224 CAttribute *alpha;
01225
01226 int nbPoints;
01227
01228
01229 int markFace = G->getNewMark();
01230
01231
01232 CDynamicCoverageAll C(G);
01233
01234
01235 glEnable(GL_LIGHTING);
01236 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
01237 glShadeModel(GL_SMOOTH);
01238
01239
01240 for (C.reinit(); C.cont(); C++)
01241 {
01242 CDart* d = *C;
01243
01244
01245 if(!G->isMarked(d, markFace) && G->getEmbeddingOwner(d, ORBIT_013))
01246 {
01247
01248 alpha = G->getAttribute(d, ORBIT_013, INT_ATTRIBUTE_ID);
01249 nbPoints = *(((Int_Att*)alpha)->Get_Data());
01250
01251
01252 alpha = G->getAttribute(d, ORBIT_013, PT_LIST_ATTRIBUTE_ID);
01253
01254
01255 Draw_List(((Point_List*)alpha)->Get_Data(), nbPoints);
01256
01257
01258 CCoverage* DCf = G->getDynamicCoverage(d, ORBIT_013);
01259 for(DCf->reinit(); DCf->cont(); (*DCf)++)
01260 G->setMark(**DCf, markFace);
01261 delete DCf;
01262 }
01263 }
01264
01265
01266 for (C.reinit(); C.cont(); C++)
01267 G->unsetMark(*C, markFace);
01268 G->freeMark(markFace);
01269
01270
01271
01272 glDisable(GL_LIGHTING);
01273 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
01274 glShadeModel(GL_FLAT);
01275 }