32 #include "message-macros.hh"
37 using namespace GMap3d;
41 #define a0 FMap->alpha0
42 #define a1 FMap->alpha1
43 #define a2 FMap->alpha2
44 #define a3 FMap->alpha3
47 #define VTX(d) ((CAttributeVertex*)FMap->getDirectInfo(d, FVertexDI))
48 #define LINK(d) ((CDart*)FMap->getDirectInfo(d, FLinkedVertexDI))
51 #define freeMark(m) (assert(FMap->isWholeMapUnmarked(m)), FMap->freeMark(m))
53 #define freeMark(m) (FMap->freeMark(m))
62 TCorefFaceList::iterator f2, TCorefFaceList::iterator l2)
63 : first1(f1), last1(l1), first2(f2), last2(l2) {}
64 TCorefFaceList::iterator first1, last1, first2,
last2;
69 CCorefine3dFF::CCorefine3dFF(CGMapVertex * AMap,
bool ACalculateOrientation,
70 TCoordinate AEpsilon,
int AVertexDI)
71 :
CCorefine(AMap, AEpsilon), FCalculateOrientation(ACalculateOrientation),
72 FOptimizeSearch(true), FGridResolution(64), FDisplayMessages(2)
75 CBoundingBox::setEpsilon(AEpsilon);
101 bitset<NB_MARKS> ACopyMarks)
103 CDart *meshes[2] = {AMesh1, AMesh2};
118 bitset<NB_MARKS> ACopyMarks)
130 bitset<NB_MARKS> ACopyMarks)
145 CBoundingBox box1 =
initMesh(AMesh1);
146 CBoundingBox box2 =
initMesh(AMesh2);
159 << end - start << endl;
171 cout <<
"Le premier objet possède " <<
FMesh1->size()
172 << (
FMesh1->size() > 1 ?
" faces" :
" face") << endl
173 <<
"Le second objet possède " <<
FMesh2->size()
174 << (
FMesh2->size() > 1 ?
" faces" :
" face")<< endl;
193 if (
FDisplayMessages) cout <<
"Durée du nettoyage : " << end - start << endl;
204 bitset<NB_MARKS> ACopyMarks)
223 << end - start << endl;
231 << end - start << endl;
233 cout <<
"Le premier objet possède " <<
FMesh1->size()
234 << (
FMesh1->size() > 1 ?
" faces" :
" face") << endl
235 <<
"Le second objet possède " <<
FMesh2->size()
236 << (
FMesh2->size() > 1 ?
" faces" :
" face")<< endl;
244 << end - start << endl;
251 for (CDynamicCoverageAll dca(
FMap); dca.cont(); ++dca) {
256 if (
FDisplayMessages) cout <<
"Durée du nettoyage : " << end - start << endl;
274 int face_plane_di =
FMap->getNewDirectInfo();
275 int negative_mark =
FMap->getNewMark();
277 for (CDynamicCoverageAll dca(
FMap); dca.cont(); ++dca)
278 FMap->setDirectInfo(*dca, face_plane_di, NULL);
288 FMap->freeDirectInfo(face_plane_di);
305 int mark =
FMap->getNewMark();
314 for (i = 0; i < ANbDarts; ++i)
315 if (
FMap->isMarked(ADarts[i], mark)) {
316 CDart *d = ADarts[i];
318 while (d != ADarts[i] &&
FMap->isMarked(d, mark));
319 ADarts[i] = (d == ADarts[i] ? NULL : d);
322 TCorefFaceList::iterator fit, tmp_fit;
324 for (i = 0; i < 2; ++i)
325 for (fit = face_list[i]->begin(); fit != face_list[i]->end(); ) {
327 if (
FMap->isMarked(tmp_fit->face, mark))
328 face_list[i]->erase(tmp_fit);
331 list<CDart*>::iterator it;
333 if (
FMap->isMarked(*it, mark))
345 << end - start << endl;
458 std::bitset<NB_MARKS> ACopyMarks)
463 CDart *d1 = AMesh1, *d2 = AMesh2;
464 CVertex line = *
VTX(d2) - *
VTX(d1);
466 if (line.getX() == 0.0 && line.getY() == 0.0 && line.getZ() == 0.0) {
468 line = *
VTX(d2) - *
VTX(d1);
471 CPlane ref_plane(line, *
VTX(d1));
472 TCoordinate dist, best_dist = 0.0;
474 int mark =
FMap->getNewMark();
476 MSG(
"Recherche d'un sommet de l'enveloppe convexe du premier objet");
477 FMap->halfMarkOrbit(d1, ORBIT_CC, mark);
478 FMap->unmarkOrbit(d1, ORBIT_VERTEX, mark);
479 for (CDynamicCoverageCC dcc(
FMap, d1); dcc.cont(); ++dcc)
480 if (
FMap->isMarked(*dcc, mark)) {
481 FMap->unmarkOrbit(*dcc, ORBIT_VERTEX, mark);
482 dist = ref_plane.pointDistance(*
VTX(*dcc));
483 if (dist > best_dist) {
489 MSG(
"Calcul d'un nouveau vecteur directeur");
490 line = *
VTX(d2) - *
VTX(d1);
491 if (line.getX() == 0.0 && line.getY() == 0.0 && line.getZ() == 0.0) {
493 line = *
VTX(d2) - *
VTX(d1);
496 MSG(
"Recherche d'une arête de l'enveloppe convexe du premier objet");
497 ref_plane.setPlane(line, *
VTX(d1));
498 best_dist = -FLT_MAX;
499 FMap->halfMarkOrbit(d1, ORBIT_VERTEX, mark);
500 for (CDynamicCoverageVertex dcv(
FMap, d1); dcv.cont(); ++dcv)
501 if (
FMap->isMarked(*dcv, mark)) {
502 FMap->unsetMark(*dcv, mark);
504 if (!
FMap->isFree2(*dcv))
506 if (normal.dot(line) > 0.0) {
507 dist = ref_plane.pointDistance(*
VTX(
a0(*dcv)));
508 if (dist > best_dist) {
515 MSG(
"Recherche de la plus proche cellule du deuxième objet");
522 MSG(
"Recherche d'une arête de l'enveloppe convexe du deuxième objet");
523 TOrbit cell_orbit = ORBIT_VERTEX;
525 case 1: cell_orbit = ORBIT_EDGE;
526 case 2: cell_orbit = ORBIT_FACE;
528 ref_plane.setPlane(-line, *
VTX(d2));
529 best_dist = -FLT_MAX;
530 FMap->halfMarkOrbit(d2, cell_orbit, mark);
531 CCoverage *cov =
FMap->getDynamicCoverage(d2, cell_orbit);
532 for (; cov->cont(); ++(*cov))
533 if (
FMap->isMarked(**cov, mark)) {
534 FMap->unsetMark(**cov, mark);
536 if (!
FMap->isFree2(**cov))
538 if (normal.dot(-line) > 0.0) {
539 dist = ref_plane.pointDistance(*
VTX(
a0(**cov)));
540 if (dist > best_dist) {
553 CDart *square =
FMap->createTopoSquare();
554 FMap->topoSew3(square,
FMap->createTopoSquare());
558 CDart *a2d1 =
FTools->alpha2(d1);
559 CDart *a2d2 =
FTools->alpha2(d2);
561 if (!
FMap->isFree2(d1))
FMap->unsew2(d1);
562 if (!
FMap->isFree2(d2))
FMap->unsew2(d2);
564 FMap->sew2(square, d1);
565 FMap->sew2(
a3(square), a2d1);
567 FMap->sew2(square, d2);
568 FMap->sew2(
a3(square), a2d2);
570 for (
int m = 0; m < NB_MARKS; ++m)
572 if (
FMap->isMarked(d1, m))
FMap->markOrbit(
a2(d1), ORBIT_01, m);
573 if (
FMap->isMarked(a2d1, m))
FMap->markOrbit(
a2(a2d1), ORBIT_01, m);
574 if (
FMap->isMarked(d2, m))
FMap->markOrbit(
a2(d2), ORBIT_01, m);
575 if (
FMap->isMarked(a2d2, m))
FMap->markOrbit(
a2(a2d2), ORBIT_01, m);
589 CDart *edge1, *edge2;
590 for (list<CDart*>::iterator it =
FInterEdges.begin();
594 if (AObjectsToMark & 1 && edge1 && !
FMap->isMarked(edge1, AMark))
595 FMap->markOrbit(edge1, ORBIT_EDGE, AMark);
596 if (AObjectsToMark & 2 && edge2 && !
FMap->isMarked(edge2, AMark))
597 FMap->markOrbit(edge2, ORBIT_EDGE, AMark);
607 if (!
FMap->isMarked(*it, AMark))
608 FMap->markOrbit(*it, ORBIT_FACE, AMark);
615 int face_plane_di =
FMap->getNewDirectInfo();
616 int negative_mark =
FMap->getNewMark();
617 CDart *edge1, *edge2;
623 for (list<CDart*>::iterator it =
FInterEdges.begin();
627 if (edge1 && edge2) {
629 face_plane_di, negative_mark);
638 FMap->freeDirectInfo(face_plane_di);
663 list<SFaceListIterators> inter_list;
665 TCorefFaceList::iterator it1, it2;
666 list<CDart*> face_list1, face_list2;
673 cout <<
"Création des intersections..." << endl;
675 cout <<
"+ intersection franche" << endl
676 <<
"# faces coplanaires" << endl;
679 while (!inter_list.empty()) {
680 iters = inter_list.front();
681 inter_list.pop_front();
712 for (it2 = iters.
first2; it2 != iters.
last2 && !found; ++it2) {
714 it1->plane, it2->plane,
715 &face_list1, &face_list2)) {
723 inter_list.push_back(next_iters);
725 it1 = next_iters.
last1;
735 cout <<
"Durée de la création des intersections : "
744 << (
FInterEdges.size() / 2 > 1 ?
" arêtes" :
" arête")
745 <<
" d'intersection" << endl;
747 list<CDart*>::iterator it;
761 int mark =
FMap->getNewMark();
764 for (CDynamicCoverageAll dca(
FMap); dca.cont(); ++dca)
765 if (!
FMap->isMarked(*dca, mark)) {
766 FMap->markOrbit(*dca, ORBIT_EDGE, mark);
768 cout <<
"Arête de longueur nulle trouvée : [" << *
VTX(*dca)
769 <<
", " << *
VTX(
a0(*dca)) <<
"]" << endl;
773 FMap->negateMaskMark(mark);
782 TOrbit AOrbit,
void * AData)
784 CCoverage *cov =
FMap->getDynamicCoverage(ADart, AOrbit);
785 for (; cov->cont(); ++(*cov))
786 FMap->setDirectInfo(**cov, ADirectInfo, AData);
796 MSG(
"Fermeture des 3-bords");
797 for (CStaticCoverageCC scc(
FMap, AMesh); scc.cont(); ++scc)
798 if (
FMap->isFree3(*scc))
799 FMap->stopUp(*scc, 3);
802 int mark =
FMap->getNewMark();
803 CDynamicCoverageCC dcc(
FMap, AMesh);
804 CAttributeVertex *vtx;
806 MSG(
"Mise à jour des champs FVertexDI");
808 for (; dcc.cont(); ++dcc)
809 if (!
FMap->isMarked(*dcc, mark)) {
810 vtx =
FMap->findVertex(*dcc);
813 for (CDynamicCoverageVertex dcv(
FMap, *dcc); dcv.cont(); ++dcv) {
814 FMap->setMark(*dcv, mark);
828 MSG(
"Initialisation des champs FInterPointDI et FLinkedVertexDI");
829 for (dcc.reinit(); dcc.cont(); ++dcc) {
830 FMap->unsetMark(*dcc, mark);
846 CDynamicCoverageAll dca(
FMap);
848 MSG(
"Fermeture des 3-bords");
849 for (; dca.cont(); ++dca)
850 if (
FMap->isMarked(*dca, AMark) &&
FMap->isFree3(*dca))
851 FMap->stopUp(*dca, 3);
854 int mark =
FMap->getNewMark();
855 CAttributeVertex *vtx;
857 FMap->markCopy(AMark, mark);
858 FMap->markIncidentCells(ORBIT_FACE, mark);
859 FMap->markIncidentCells(ORBIT_VERTEX, mark);
860 FMap->markIncidentCells(ORBIT_FACE, mark);
862 MSG(
"Mise à jour des champs FVertexDI, FInterPointDI et FLinkedVertexDI");
863 for (dca.reinit(); dca.cont(); ++dca)
864 if (
FMap->isMarked(*dca, mark)) {
865 vtx =
FMap->findVertex(*dca);
868 for (CDynamicCoverageVertex dcv(
FMap, *dca); dcv.cont(); ++dcv) {
869 FMap->unsetMark(*dcv, mark);
887 for (CDynamicCoverageCC dcc(
FMap, AMesh); dcc.cont(); ++dcc) {
939 CVertex *vtx, pt, center, normal(0.0, 0.0, 0.0);
950 d = AFace;
FMap->unsetMark(d, AMark);
951 d =
a0(d);
FMap->unsetMark(d, AMark);
952 d =
a3(d);
FMap->unsetMark(d, AMark);
953 d =
a0(d);
FMap->unsetMark(d, AMark);
954 d =
a1(d);
FMap->unsetMark(d, AMark);
955 d =
a3(d);
FMap->unsetMark(d, AMark);
956 d =
a0(d);
FMap->unsetMark(d, AMark);
957 d =
a3(d);
FMap->unsetMark(d, AMark);
960 infos.
box.addPoint(pt);
961 infos.
box.addPoint(*
VTX(d));
965 for (CDynamicCoverage01 cov(
FMap, AFace); cov.cont(); ++cov)
966 if (
FMap->isMarked(*cov, AMark)) {
968 d = *cov;
FMap->unsetMark(d, AMark);
969 d =
a3(d);
FMap->unsetMark(d, AMark);
970 d =
a0(d);
FMap->unsetMark(d, AMark);
971 d =
a3(d);
FMap->unsetMark(d, AMark);
972 normal += (*vtx - pt) * (*
VTX(d) - pt);
974 infos.
box.addPoint(*vtx);
978 infos.
plane.setPlane(normal, center / nb);
991 int mark =
FMap->getNewMark();
992 FMap->halfMarkOrbit(AMesh, ORBIT_CC, mark);
993 for (CDynamicCoverageCC dcc(
FMap, AMesh); dcc.cont(); ++dcc)
994 if (
FMap->isMarked(*dcc, mark))
1009 int mark =
FMap->getNewMark();
1010 FMap->markCopy(AMark, mark);
1011 FMap->halfMarkIncidentCells(ORBIT_FACE, mark);
1012 for (CDynamicCoverageAll dca(
FMap); dca.cont(); ++dca)
1013 if (
FMap->isMarked(*dca, mark))
1024 const CBoundingBox & ABox)
1028 long size_i, size_j, size_k;
1029 long nb_faces = (AList1->size() > AList2->size() ?
1030 AList1->size() : AList2->size());
1032 if (nb_faces < 50) {
1034 cout <<
"Nombre de faces trop faible => aucune réduction !" << endl;
1039 size = ABox.getEpsMaxBound() - ABox.getEpsMinBound();
1040 max = (size.getX() > size.getY() ?
1041 (size.getX() > size.getZ() ? size.getX() : size.getZ()) :
1042 (size.getY() > size.getZ() ? size.getY() : size.getZ()));
1053 if (size_i <= 0) size_i = 1;
1054 if (size_j <= 0) size_j = 1;
1055 if (size_k <= 0) size_k = 1;
1058 cout <<
"Résolution de la grille = "
1059 << size_i <<
"x" << size_j <<
"x" << size_k << endl;
1062 TCorefFaceList::iterator it, tmp_it;
1063 list<CDart*>::iterator li;
1064 int mark =
FMap->getNewMark();
1067 for (it = AList1->begin(); it != AList1->end(); ++it)
1069 gi->first.push_back(it->face);
1070 for (it = AList2->begin(); it != AList2->end(); ++it)
1072 gi->second.push_back(it->face);
1075 if (gi->first.size() > 0 && gi->second.size() > 0) {
1076 for (li = gi->first.begin(); li != gi->first.end(); ++li)
1077 FMap->setMark(*li, mark);
1078 for (li = gi->second.begin(); li != gi->second.end(); ++li)
1079 FMap->setMark(*li, mark);
1084 for (it = AList1->begin(); it != AList1->end(); ) {
1086 if (
FMap->isMarked(tmp_it->face, mark))
1087 FMap->unsetMark(tmp_it->face, mark);
1090 AList1->erase(tmp_it);
1094 cout << nb << (nb == 1 ?
1095 " face a été supprimée" :
1096 " faces ont été supprimées")
1097 <<
" de la première liste" << endl;
1100 for (it = AList2->begin(); it != AList2->end(); ) {
1102 if (
FMap->isMarked(tmp_it->face, mark))
1103 FMap->unsetMark(tmp_it->face, mark);
1106 AList2->erase(tmp_it);
1110 cout << nb << (nb == 1 ?
1111 " face a été supprimée" :
1112 " faces ont été supprimées")
1113 <<
" de la seconde liste" << endl;
1121 TCorefFaceList::iterator AElt,
1122 list<CDart*> * AFaces)
1126 TCorefFaceList::iterator pos = AElt;
1127 list<CDart*>::iterator it = AFaces->begin();
1129 MSG(
"La face à été éclatée en " << AFaces->size() <<
" faces");
1135 for (; it != AFaces->end(); ++it)
1136 AList->insert(pos,
SCorefFace(*it, AElt->plane,
1137 FTools->orbitBoundingBox(*it, ORBIT_01,
1146 if (
LINK(AVertex) == NULL)
1149 bool result =
false;
1150 for (CDynamicCoverageVertex dcv(
FMap,
LINK(AVertex));
1151 dcv.cont() && !result; ++dcv)
1152 if (
FMap->isMarked(*dcv, AFaceMark))
1162 for (CDynamicCoverageVertex dcv(
FMap, AVertex); dcv.cont(); ++dcv)
1163 if (
FMap->isMarked(*dcv, AFaceMark))
1164 FMap->setMark(*dcv, AMark);
1172 for (CDynamicCoverage23 cov(
FMap, ADart); cov.cont() && !d; ++cov)
1173 if (*cov != ADart &&
FMap->isMarked(*cov, AFaceMark)) d = *cov;
1180 const CPlane & AFacePlane,
1181 int AFaceMark,
const CVertex & AVector)
1185 int orient_mark =
FMap->getNewMark();
1187 CVertex pt = *
VTX(AFaceVertex);
1189 MSG(
"AVector = " << AVector);
1190 MSG(
"sommet testé : " << pt);
1192 FMap->halfMarkOrbit(AFaceVertex, ORBIT_VERTEX, orient_mark);
1193 for (CDynamicCoverageVertex dcv(
FMap, AFaceVertex); dcv.cont(); ++dcv)
1194 if (
FMap->isMarked(*dcv, orient_mark)) {
1195 FMap->unsetMark(*dcv, orient_mark);
1196 if (
FMap->isMarked(*dcv, AFaceMark)) {
1199 *
VTX(
a0(*dcv)) - pt,
1204 MSG(
"secteur trouvé : " << *
VTX(
a0(*dcv))
1205 <<
", " << *
VTX(
a0(
a1(*dcv))));
1217 const CPlane & ARefPlane,
1218 const CPlane & AClipPlane1,
1219 const CPlane & AClipPlane2)
1221 CDart *d, *nearest = NULL;
1222 TCoordinate best_dist = 0, dist;
1229 if (AClipPlane1.pointDistance(pt) >= -
FEps &&
1230 AClipPlane2.pointDistance(pt) >= -
FEps) {
1231 dist = abs(ARefPlane.pointDistance(pt));
1232 if (!nearest || dist < best_dist) {
1248 const CPlane & AFacePlane)
1250 return AFacePlane.getNormal() * (*
VTX(
a0(AEdge)) - *
VTX(AEdge));
1256 const CPlane & AFacePlane)
1265 int APositiveMark,
int ANegativeMark,
1266 int AFacesMark,
bool AUseVerticesLinks,
1268 int * ANbPositiveVertices,
1269 int * ANbNegativeVertices)
1273 int treated_mark =
FMap->getNewMark();
1274 int nb = 0, nb_pos = 0, nb_neg = 0;
1276 MSG(
"Classement des sommets de AFace par rapport à APlane");
1278 if (!
FMap->isMarked(d, treated_mark)) {
1282 dist = APlane.pointDistance(*
VTX(d));
1287 else if (dist >
FEps) {
1298 MSG(
"Démarquage des brins de la face");
1300 FMap->unsetMark(d, treated_mark);
1302 FMap->unsetMark(d, treated_mark);
1309 MSG(
"La face comporte " << nb <<
" sommets dont :");
1310 MSG(
" " << nb_pos <<
" du côté positif");
1311 MSG(
" " << nb_neg <<
" du côté negatif");
1313 if (ANbVertices) *ANbVertices = nb;
1314 if (ANbPositiveVertices) *ANbPositiveVertices = nb_pos;
1315 if (ANbNegativeVertices) *ANbNegativeVertices = nb_neg;
1321 std::list<CDart*> * AFictVertices,
1322 std::list<CDart*> * AFictEdges)
1324 int fict_mark =
FMap->getNewMark();
1329 if (!
FMap->isMarked(d, fict_mark) &&
1333 MSG(
"Récupération du sommet fictif " << *
VTX(d));
1334 AFictVertices->push_back(d);
1343 if (
FMap->isMarked(d, fict_mark)) {
1344 FMap->unmarkOrbit(d, ORBIT_EDGE, fict_mark);
1346 AFictEdges->push_back(d);
1359 const CVertex & AInterLine,
1360 const CPlane & AFacePlane)
1362 MSG(
"sector = " << *
VTX(
a0(
a1(AVertex))) <<
","
1363 << *
VTX(AVertex) <<
"," << *
VTX(
a0(AVertex)));
1372 MSG(
"On entre dans la face");
1380 MSG(
"On sort de la face");
1392 MSG(
"Il y a une intersetion avec le bord");
1393 if (AComparator(AOldPoint, ANewPoint)) {
1394 MSG(
"AOldPoint < ANewPoint ==> OnBorder");
1401 MSG(
"ANewPoint < AOldPoint ==> OnReversedBorder");
1411 #define GET_IP(d) ((TInterPt*)FMap->getDirectInfo(d, FInterPointDI))
1415 const CPlane & AFacePlane,
1416 const CPlane & AInterPlane,
1417 const CVertex & AInterLine,
1418 int APositiveMark,
int ANegativeMark,
1426 CAttributeVertex *vtx1, *vtx2, pt;
1433 MSG(
"normale au plan : " << AFacePlane.getNormal());
1439 if (!
FMap->isMarked(d, APositiveMark) && !
FMap->isMarked(d, ANegativeMark)) {
1441 inter_point->setLeavingSector(d);
1443 MSG(
"première intersection avec le sommet " << inter_point->getPoint());
1444 inter_set->insert(inter_point);
1448 MSG(
"Recherche des sommets de AFace se trouvant sur AInterPlane");
1451 old_point = inter_point;
1456 MSG(
"intersection déjà existante avec un sommet");
1457 MSG(inter_point->getPoint());
1462 if (!
FMap->isMarked(d, APositiveMark) &&
1463 !
FMap->isMarked(d, ANegativeMark)) {
1465 inter_point->setLeavingSector(d);
1467 MSG(
"nouvelle intersection avec un sommet");
1468 MSG(inter_point->getPoint());
1469 inter_set->insert(inter_point);
1479 MSG(
"Recherche des arêtes de AFace intersectant AInterPlane");
1484 if ( (
FMap->isMarked(d, APositiveMark) &&
1485 FMap->isMarked(
a0(d), ANegativeMark)) ||
1486 (
FMap->isMarked(d, ANegativeMark) &&
1487 FMap->isMarked(
a0(d), APositiveMark))) {
1490 dir = *vtx2 - *vtx1;
1492 MSG(
"dir = " << dir);
1494 if (AInterPlane.getLineIntersection(*vtx1, dir, &t)) {
1495 assert(t >= 0.0 && t <= 1.0);
1497 pt = *vtx1 + t * dir;
1499 inter_set->insert(inter_point);
1500 MSG(
"intersection avec l'arête [" << *vtx1 <<
"," << *vtx2 <<
"] en "
1503 if ((AFacePlane.getNormal() * dir).dot(AInterLine) > 0.0) {
1505 inter_point->setEnteringSector(d);
1509 inter_point->setLeavingSector(d);
1513 if (!
FMap->isFree2(d) || !
FMap->isFree2(
a3(d))) {
1515 for (CDynamicCoverage23 cov(
FMap, d); cov.cont() && !d2; ++cov)
1516 if (*cov != d &&
FMap->isMarked(*cov, AFacesMark)) d2 = *cov;
1520 if (inter_point->getPosition() ==
FP_Outside) {
1522 inter_point->setEnteringSector(d2);
1525 inter_point->setLeavingSector(d2);
1530 MSG(
"pos = " << inter_point->getPosition());
1535 for (CDynamicCoverageEdge dce(
FMap, d); dce.cont(); ++dce) {
1536 FMap->unsetMark(*dce, APositiveMark);
1537 FMap->unsetMark(*dce, ANegativeMark);
1553 for (
int i=0; i<8; ++i) {
1554 d[i] =
FMap->addMapDart();
1559 FMap->linkAlpha0(d[0], d[1]);
1560 FMap->linkAlpha0(d[2], d[3]);
1561 FMap->linkAlpha0(d[4], d[5]);
1562 FMap->linkAlpha0(d[6], d[7]);
1564 FMap->linkAlpha2(d[0], d[2]);
1565 FMap->linkAlpha2(d[1], d[3]);
1566 FMap->linkAlpha2(d[4], d[6]);
1567 FMap->linkAlpha2(d[5], d[7]);
1569 FMap->linkAlpha3(d[0], d[4]);
1570 FMap->linkAlpha3(d[1], d[5]);
1571 FMap->linkAlpha3(d[2], d[6]);
1572 FMap->linkAlpha3(d[3], d[7]);
1592 const CVertex & AVertex2)
1596 CDart *link =
LINK(AVertex1);
1599 CDart *old_a1 =
a1(AVertex1);
1600 FMap->unsew1(AVertex1);
1601 FMap->sew1(AVertex1,
a2(edge));
1602 FMap->sew1(old_a1, edge);
1608 for (CDynamicCoverage23 dc(
FMap, edge); dc.cont(); ++dc) {
1610 for (
int m = 0; m < NB_MARKS; m++)
1612 FMap->setMark(*dc, m);
1613 FMap->setMark(
a0(*dc), m);
1616 FMap->pointDirectInfoToAttributeVertex(
FVertexDI, AVertex1);
1618 CAttributeVertex *vtx =
new CAttributeVertex(AVertex2);
1619 FMap->setVertex(
a0(edge), vtx);
1621 for (CDynamicCoverageVertex dcv(
FMap,
a0(edge)); dcv.cont(); ++dcv) {
1626 MSG(
"arête insérée : [" << *
VTX(AVertex1) <<
";" << AVertex2 <<
"]");
1634 list<CDart*> * AFictiveEdges)
1638 FMap->CGMapGeneric::insertVertex(AEdge);
1640 CDart *d =
a1(
a0(AEdge));
1646 if (AFictiveEdges) {
1647 CDart *edge =
a2(
a3(AEdge));
1649 for (list<CDart*>::iterator it = AFictiveEdges->begin();
1650 it != AFictiveEdges->end() && !found; ++it)
1651 if (*it == AEdge || *it == edge)
1653 AFictiveEdges->push_back(found ? d : AEdge);
1657 CAttributeVertex *vtx =
new CAttributeVertex(APoint);
1658 FMap->setVertex(d, vtx);
1660 for (CDynamicCoverageVertex dcv(
FMap, d); dcv.cont(); ++dcv) {
1664 for (
int m = 0; m < NB_MARKS; m++)
1666 FMap->setMark(*dcv, m);
1669 MSG(
"sommet inséré : " << APoint);
1680 assert(AVertex1 != AVertex2);
1685 CDart *old_a1[2] = {
a1(AVertex1),
a1(AVertex2)};
1686 FMap->unsew1(AVertex1);
1687 FMap->sew1(AVertex1,
a2(edge));
1688 FMap->sew1(old_a1[0], edge);
1689 FMap->unsew1(AVertex2);
1690 FMap->sew1(AVertex2,
a0(edge));
1691 FMap->sew1(old_a1[1],
a2(
a0(edge)));
1698 link =
LINK(AVertex1);
1699 for (CDynamicCoverage23 dc1(
FMap, edge); dc1.cont(); ++dc1) {
1701 for (
int m = 0; m < NB_MARKS; m++)
1703 FMap->setMark(*dc1, m);
1705 FMap->pointDirectInfoToAttributeVertex(
FVertexDI, AVertex1);
1707 link =
LINK(AVertex2);
1708 for (CDynamicCoverage23 dc2(
FMap,
a0(edge)); dc2.cont(); ++dc2) {
1710 for (
int m = 0; m < NB_MARKS; m++)
1712 FMap->setMark(*dc2, m);
1714 FMap->pointDirectInfoToAttributeVertex(
FVertexDI, AVertex2);
1716 MSG(
"arête insérée : [" << *
VTX(AVertex1) <<
";" << *
VTX(AVertex2) <<
"]");
1727 for (CDynamicCoverageVertex dcv(
FMap, AVertex); dcv.cont() && result; ++dcv)
1738 return (
a1(AEdge) ==
a2(AEdge) ||
a1(
a0(AEdge)) ==
a2(
a0(AEdge)) ||
1739 !
FMap->isSameOrbit(AEdge,
a2(AEdge), ORBIT_01));
1747 for (CDynamicCoverageFace dcf(
FMap, AFace); dcf.cont() && result; ++dcf)
1748 if (!
FMap->isMarked(*dcf, AMark))
1759 int edge_mark =
FMap->getNewMark();
1760 CDart *d1, *d2, *other;
1763 MSG(
"Marquage des arêtes de la face");
1766 FMap->markOrbit(d1, ORBIT_EDGE, edge_mark);
1769 while (d1 != AFace);
1771 MSG(
"Recherche de la face jumelle");
1773 other =
a3(
a2(AFace));
1776 other =
a2(
a3(AFace));
1786 MSG(
"Copie des marques se trouvant sur la face à supprimer");
1789 FMap->unmarkOrbit(d1, ORBIT_EDGE, edge_mark);
1790 for (m = 0; m < NB_MARKS; ++m) {
1792 FMap->setMark(d2, m);
1794 FMap->setMark(
a3(d2), m);
1798 for (m = 0; m < NB_MARKS; ++m) {
1800 FMap->setMark(d2, m);
1802 FMap->setMark(
a3(d2), m);
1807 while (d1 != AFace);
1808 assert(d2 == other);
1822 assert(
LINK(AVertex) == NULL);
1824 CDart *d =
a0(AVertex);
1826 if (ADeleteMark < 0)
1827 FMap->merge(AVertex,
a1(AVertex), 1,
true);
1829 FMap->markOrbit(AVertex, ORBIT_VERTEX, ADeleteMark);
1830 FMap->merge(AVertex,
a1(AVertex), 1,
false);
1843 assert(!
FMap->isFree2(AEdge));
1844 assert(
a3(
a2(AEdge)) ==
a2(
a3(AEdge)));
1846 CDart *d1 =
a1(AEdge);
1847 CDart *d2 =
a1(
a0(AEdge));
1850 if (
a2(AEdge) == d1) d1 = NULL;
1851 if (
a2(
a0(AEdge)) == d2) d2 = NULL;
1856 if (AEdge == l1 ||
a3(
a2(AEdge)) == l1 ||
1857 a2(AEdge) == l1 ||
a3(AEdge) == l1) {
1858 MSG(
"Déplacement des liens sur le premier sommet");
1865 if (
a2(
a0(AEdge)) == l1 ||
a3(
a0(AEdge)) == l1 ||
1866 a0(AEdge) == l1 ||
a3(
a2(
a0(AEdge))) == l1) {
1867 MSG(
"Déplacement des liens sur le second sommet");
1872 MSG(
"Démarquage des sommets de l'arête");
1878 MSG(
"Suppression de l'arête");
1879 if (ADeleteMark < 0)
1880 FMap->merge(AEdge,
a2(AEdge), 2,
true);
1882 FMap->markOrbit(AEdge, ORBIT_EDGE, ADeleteMark);
1883 FMap->merge(AEdge,
a2(AEdge), 2,
false);
1886 MSG(
"Mise à jour des champs FVertexDI");
1887 if (d1)
FMap->pointDirectInfoToAttributeVertex(
FVertexDI, d1);
1888 if (d2)
FMap->pointDirectInfoToAttributeVertex(
FVertexDI, d2);
1901 MSG(
"Suppression de la face en trop");
1902 FMap->merge(AFace,
a3(AFace), 3,
true);
1904 MSG(
"Mise à jour des champs FVertexDI");
1920 MSG(
"AVertex1 = " << *
VTX(AVertex1));
1921 MSG(
"AVertex2 = " << *
VTX(AVertex2));
1922 assert(
FTools->arePointsEqual(*
VTX(AVertex1), *
VTX(AVertex2)));
1923 for (CDynamicCoverageVertex dcv1(
FMap, AVertex1); dcv1.cont(); ++dcv1)
1925 for (CDynamicCoverageVertex dcv2(
FMap, AVertex2); dcv2.cont(); ++dcv2)
1932 int AFacesMark,
int AInterMark,
1933 std::list<CDart*> * AInterList)
1935 MSG(
"Ajout du point d'intersection " << *
VTX(AVertices[0]));
1941 AInterList->push_back(AVertices[AFaceNumber]);
1949 const CPlane & APlane1,
1950 const CPlane & APlane2,
1951 list<CDart*> * AFaceList1,
1952 list<CDart*> * AFaceList2)
1956 list<CDart*> fict_vertices, fict_edges;
1957 list<CDart*>::iterator it, last_edge =
FInterEdges.begin();
1958 int positive_mark =
FMap->getNewMark();
1959 int negative_mark =
FMap->getNewMark();
1960 int nb1, nb_pos1, nb_neg1, nb2, nb_pos2, nb_neg2;
1961 char inter_type = 0;
1966 #ifdef DEBUG_MESSAGES
1968 MSG(
"**** ETAPE N°" << nb <<
" ****");
1969 #ifdef SAVE_STEPS_SINCE
1970 #ifdef SAVE_STEPS_UNTIL
1971 if (nb >= SAVE_STEPS_SINCE && nb <= SAVE_STEPS_UNTIL) {
1973 if (nb >= SAVE_STEPS_SINCE) {
1977 s<<
"CCorefine3DFF_intersectFaces";
1978 s.width(4); s.fill(0); s.flags (ios::right);
1986 FMap->save(s.str(), AsciiFormat);
1993 FFaceMark,
true, &nb1, &nb_pos1, &nb_neg1);
1995 FFaceMark,
true, &nb2, &nb_pos2, &nb_neg2);
1997 MSG(
"Récupération des sommets fictifs et des arêtes fictives sur les faces");
2001 if ((nb_pos1 == 0 && nb_neg1 == 0) || (nb_pos2 == 0 && nb_neg2 == 0)) {
2003 if (nb_pos1 > 0)
FMap->unmarkOrbit(AFace1, ORBIT_01, positive_mark);
2004 if (nb_neg1 > 0)
FMap->unmarkOrbit(AFace1, ORBIT_01, negative_mark);
2005 if (nb_pos2 > 0)
FMap->unmarkOrbit(AFace2, ORBIT_01, positive_mark);
2006 if (nb_neg2 > 0)
FMap->unmarkOrbit(AFace2, ORBIT_01, negative_mark);
2008 positive_mark, negative_mark,
FFaceMark,
2009 &fict_vertices, &fict_edges);
2011 else if (nb_pos1 < nb1 && nb_neg1 < nb1 && nb_pos2 < nb2 && nb_neg2 < nb2) {
2014 positive_mark, negative_mark,
FFaceMark,
2015 &fict_vertices, &fict_edges);
2018 for (CDynamicCoverage01 cov1(
FMap, AFace1); cov1.cont(); ++cov1) {
2019 FMap->unsetMark(*cov1, positive_mark);
2020 FMap->unsetMark(*cov1, negative_mark);
2022 for (CDynamicCoverage01 cov2(
FMap, AFace2); cov2.cont(); ++cov2) {
2023 FMap->unsetMark(*cov2, positive_mark);
2024 FMap->unsetMark(*cov2, negative_mark);
2028 MSG(
"Suppression des arêtes fictives inutiles");
2029 for (it = fict_edges.begin(); it != fict_edges.end(); ++it)
2034 MSG(
"Suppression des sommets fictifs inutiles");
2035 for (it = fict_vertices.begin(); it != fict_vertices.end(); ++it)
2040 MSG(
"Récupération des faces résultantes");
2041 assert(AFaceList1 != NULL);
2042 assert(AFaceList2 != NULL);
2043 AFaceList1->clear();
2044 AFaceList2->clear();
2054 list<CDart*> *face_list[2] = {AFaceList1, AFaceList2};
2058 for (it =
FInterEdges.begin(); it != last_edge; ) {
2059 for (i = 0; i < 2; ++i) {
2063 face_list[i]->push_back(edge);
2067 face_list[i]->push_back(
a0(
a2(edge)));
2086 const CPlane & APlane1,
2087 const CPlane & APlane2,
2088 int APositiveMark,
int ANegativeMark,
2091 list<CDart*> * AFictiveEdges)
2097 CPlane plane[2] = {APlane1, APlane2};
2100 line = APlane1.getNormal() * APlane2.getNormal();
2102 MSG(
"line = " << line);
2104 assert(line.getX() != 0.0 || line.getY() != 0.0 || line.getZ() != 0.0);
2113 MSG(
"Recherche des intersections sur la première face");
2115 APositiveMark, ANegativeMark,
2118 MSG(
"Recherche des intersections sur la deuxième face");
2120 APositiveMark, ANegativeMark,
2123 TInterPtSet::iterator it[2] = {inter_set[0]->begin(), inter_set[1]->begin()};
2126 int prev_point, next_point;
2127 CDart *vtx[2], *edge[2], *last_vertex[2];
2128 int mark =
FMap->getNewMark();
2131 ip[0] = ip[1] = NULL;
2132 prev_pos[0] = prev_pos[1] = pos[0] = pos[1] =
FP_Outside;
2133 prev_point = next_point = 0;
2134 last_vertex[0] = last_vertex[1] = NULL;
2137 while (it[0] != inter_set[0]->end() && it[1] != inter_set[1]->end()) {
2139 if (
FTools->arePointsEqual((*it[0])->getPoint(), (*it[1])->getPoint()))
2142 else if (comp(*it[0], *it[1]))
2148 MSG(
"prev_point = " << prev_point);
2149 MSG(
"next_point = " << next_point);
2150 MSG(
"pos1 = " << pos[0]);
2151 MSG(
"pos2 = " << pos[1]);
2154 for (i = 0; i < 2; ++i) {
2155 BEGIN(
"Création d'une arête d'intersection sur la face " << i);
2156 MSG(
"prev dim = " << ip[i]->getCellDim());
2157 MSG(
"prev point = " << ip[i]->getPoint());
2158 MSG(
"next dim = " << (*it[i])->getCellDim());
2159 MSG(
"next point = " << (*it[i])->getPoint());
2163 MSG(
"test d'erreur numérique");
2169 if (!(prev_point & (i+1)) && prev_pos[(i+1)%2] !=
FP_Outside) {
2170 assert(last_vertex[i] != NULL);
2171 vtx[0] = last_vertex[i];
2181 vtx[1] = ((*it[i])->getPosition() ==
FP_Inside ?
2182 (*it[i])->getEnteringSector() :
2183 (*it[i])->getLeavingSector());
2185 MSG(
"vtx[0] = " << *
VTX(vtx[0]));
2186 MSG(
"vtx[1] = " << *
VTX(vtx[1]));
2188 if (!
FMap->isMarked(d, mark)) {
2189 cerr <<
"Erreur numérique détectée : " << pos[i] <<
" ==> ";
2195 if (
FMap->isMarked(d, mark) &&
FMap->isMarked(
a0(d), mark))
2197 FMap->unsetMark(d, mark);
2199 FMap->unsetMark(d, mark);
2202 while (d != vtx[0]);
2205 if ((*
VTX(
a0(d_on)) - *
VTX(d_on)).dot(line) > 0.0)
2212 CDart *d_in =
findFaceSector(vtx[0], plane[i], AFacesMark, line);
2217 cerr << pos[i] << endl;
2220 FMap->unmarkOrbit(vtx[0], ORBIT_VERTEX, mark);
2221 FMap->unmarkOrbit(vtx[1], ORBIT_VERTEX, mark);
2228 if (!(prev_point & (i+1))) {
2230 assert(last_vertex[i] != NULL);
2231 vtx[0] = last_vertex[i];
2234 vtx[0] =
splitEdge(vtx[0], ip[(i+1)%2]->getPoint(),
2239 if (!(next_point & (i+1)))
2240 splitEdge(vtx[0], (*it[(i+1)%2])->getPoint(), AFictiveEdges);
2242 last_vertex[i] = vtx[1] =
a1(
a0(edge[i]));
2247 if (!(prev_point & (i+1))) {
2249 splitEdge(last_vertex[i], ip[(i+1)%2]->getPoint(), AFictiveEdges);
2251 if (!(next_point & (i+1)))
2252 last_vertex[i] =
splitEdge(last_vertex[i],
2253 (*it[(i+1)%2])->getPoint(),
2255 vtx[0] = edge[i] = last_vertex[i];
2256 vtx[1] =
a1(
a0(edge[i]));
2261 if (prev_point & (i+1)) {
2262 MSG(
"Le premier sommet se trouve sur la face courante");
2263 if (ip[i]->getCellDim() == 0)
2266 vtx[0] =
splitEdge(ip[i]->getEnteringSector(),
2267 ip[i]->getPoint(), AFictiveEdges);
2268 MSG(
"sommet trouvé : " << *
VTX(vtx[0]));
2271 MSG(
"Le premier sommet se trouve sur l'autre face");
2273 assert(last_vertex[i] != NULL);
2274 vtx[0] = last_vertex[i];
2276 else if (!(next_point & (i+1))) {
2277 if (!last_vertex[i]) {
2278 if (ip[i]->getCellDim() == 1) {
2286 CPlane clip_plane2(-line, ip[(i+1)%2]->getPoint());
2288 clip_plane1, clip_plane2);
2290 ip[(i+1)%2]->getPoint() -
2298 vtx[0] = last_vertex[i];
2300 AFictiveEdges->push_back(vtx[0]);
2307 if (next_point & (i+1)) {
2308 MSG(
"Le second sommet se trouve sur la face courante");
2309 MSG(
"next_point = " << (*it[i])->getPoint());
2310 if ((*it[i])->getCellDim() == 0)
2311 vtx[1] = ((*it[i])->getLeavingSector() ?
2312 (*it[i])->getLeavingSector() :
2313 (*it[i])->getEnteringSector());
2315 vtx[1] =
splitEdge((*it[i])->getLeavingSector(),
2316 (*it[i])->getPoint(), AFictiveEdges);
2322 ip[(i+1)%2]->getPoint())));
2326 if ((*it[i])->getPosition() ==
FP_Inside) {
2327 if ((*it[i])->getCellDim() == 1) {
2328 (*it[i])->setCellDim(0);
2329 (*it[i])->setEnteringSector(
a1(
a0((*it[i])->getEnteringSector())));
2331 else if (((*
VTX(
a0((*it[i])->getEnteringSector())) -
2332 *
VTX((*it[i])->getEnteringSector()))
2333 * line).dot(plane[i].getNormal()) < 0.0)
2334 (*it[i])->setEnteringSector(
a2(
a0(edge[i])));
2336 last_vertex[i] = NULL;
2339 MSG(
"Le second sommet se trouve sur l'autre face");
2341 vtx[1] = last_vertex[i] =
a1(
a0(edge[i]));
2348 MSG(
"arête d'intersection trouvée : [" << *
VTX(edge[i]) <<
";"
2349 << *
VTX(
a0(edge[i])) <<
"]");
2356 MSG(
"Marquage et stockage des arêtes d'intersection");
2392 cerr <<
"Intersection incohérante ignorée !" << endl;
2397 for (i = 0; i < 2; ++i) {
2398 if (next_point & (i+1)) {
2400 prev_pos[i] = pos[i];
2402 last_vertex[i] = NULL;
2405 prev_point = next_point;
2410 MSG(
"Destruction des ensembles de points d'intersection");
2411 for (i = 0; i < 2; ++i) {
2412 for (it[i] = inter_set[i]->begin(); it[i] != inter_set[i]->end(); ++it[i])
2414 delete inter_set[i];
2421 const CPlane & APlane1,
2422 const CPlane & APlane2,
2423 int APositiveMark,
int ANegativeMark,
2426 list<CDart*> * AFictiveEdges)
2430 CDart *d, *face[2], *vtx[2], *edge[2];
2431 CPlane plane[2], edge_plane;
2432 CVertex edge_vector, pt1, pt2;
2433 int i, j, nb, nb_pos, nb_neg;
2434 int inter_mark =
FMap->getNewMark();
2435 list<CDart*> inter_points;
2436 bool local_inside, inside;
2439 face[0] = AFace1; plane[0] = APlane1;
2440 face[1] = AFace2; plane[1] = APlane2;
2441 for (i = 0; i < 2 && inter_points.empty(); ++i) {
2442 MSG(
"Recherche des points d'intersection entre les arêtes de la face "
2443 << i <<
" et les arêtes de la face " << (i+1)%2);
2451 pt2 = *
VTX(
a0(vtx[0]));
2452 edge_vector = pt2 - pt1;
2453 edge_plane.setPlane(plane[i].getNormal() * edge_vector, pt1);
2454 local_inside =
false;
2456 MSG(
"arête testée : [" << pt1 <<
" ; " << pt2 <<
"]");
2459 APositiveMark, ANegativeMark, AFacesMark,
2460 false, &nb, &nb_pos, &nb_neg);
2462 FMap->unmarkOrbit(face[(i+1)%2], ORBIT_01, APositiveMark);
2463 else if (nb_neg == nb)
2464 FMap->unmarkOrbit(face[(i+1)%2], ORBIT_01, ANegativeMark);
2468 TInterPtSet::iterator it[2];
2471 int prev_point, next_point;
2477 inter_set[0]->insert(ip[0]);
2480 inter_set[0]->insert(ip[0]);
2483 edge_plane, edge_vector,
2484 APositiveMark, ANegativeMark,
2487 it[0] = inter_set[0]->begin();
2488 it[1] = inter_set[1]->begin();
2489 ip[0] = ip[1] = NULL;
2491 prev_point = next_point = 0;
2494 while (it[0] != inter_set[0]->end() && it[1] != inter_set[1]->end()) {
2496 if (
FTools->arePointsEqual((*it[0])->getPoint(),
2497 (*it[1])->getPoint()))
2500 else if (comp(*it[0], *it[1]))
2506 MSG(
"prev_point = " << prev_point);
2507 MSG(
"next_point = " << next_point);
2508 MSG(
"pos[0] = " << pos[0]);
2509 MSG(
"pos[1] = " << pos[1]);
2514 if (local_inside && (prev_point != 1 || next_point != 1))
2515 local_inside =
false;
2519 if (prev_point & 1 && pos[1] !=
FP_Outside) {
2523 plane[(i+1)%2])) > 0.0) {
2524 MSG(
"Le premier sommet est à l'intérieur");
2530 if (prev_point == 1) {
2531 vtx[1] =
splitEdge(ip[1]->getEnteringSector(), pt1,
2538 if (prev_point & 1 && !
FMap->isMarked(vtx[0], inter_mark))
2544 if (next_point == 1) {
2545 vtx[0] =
a1(
a0(vtx[0]));
2546 vtx[1] =
splitEdge(ip[1]->getEnteringSector(), pt2,
2552 if (next_point == 2) {
2553 vtx[0] =
splitEdge(vtx[0], (*it[1])->getPoint(),
2556 else if (next_point == 3) {
2557 vtx[0] =
a1(
a0(vtx[0]));
2559 vtx[1] = ((*it[1])->getPosition() ==
FP_Inside ?
2560 (*it[1])->getEnteringSector() :
2561 (*it[1])->getLeavingSector());
2566 if (!
FMap->isMarked(vtx[0], inter_mark))
2570 MSG(
"edge[0] = [" << *
VTX(edge[0]) <<
";"
2571 << *
VTX(
a0(edge[0])) <<
"]");
2572 MSG(
"edge[1] = [" << *
VTX(edge[1]) <<
";"
2573 << *
VTX(
a0(edge[1])) <<
"]");
2577 MSG(
"Une arête d'intersection avec un bord trouvée");
2584 cerr <<
"topologie de l'objet " << (i+2)%2
2585 <<
" incorrecte !" << endl;
2589 cerr <<
"topologie de l'objet " << i+1
2590 <<
" incorrecte !" << endl;
2602 if (prev_point == 3 && ip[1]->getCellDim() == 1) {
2604 ip[1]->getLeavingSector() :
2605 ip[1]->getEnteringSector(), pt1,
2607 if (!
FMap->isMarked(vtx[0], inter_mark))
2612 if (next_point != 1) {
2613 if (next_point == 2) {
2614 vtx[0] =
splitEdge(vtx[0], (*it[1])->getPoint(),
2616 vtx[1] = ((*it[1])->getPosition() ==
FP_Inside ?
2617 (*it[1])->getEnteringSector() :
2618 (*it[1])->getLeavingSector());
2619 if ((*it[1])->getCellDim() == 1)
2620 vtx[1] =
splitEdge(vtx[1], (*it[1])->getPoint(),
2624 vtx[0] =
a1(
a0(vtx[0]));
2625 vtx[1] = ((*it[1])->getPosition() ==
FP_Inside ?
2626 (*it[1])->getEnteringSector() :
2627 (*it[1])->getLeavingSector());
2628 if ((*it[1])->getCellDim() == 1)
2629 vtx[1] =
splitEdge(vtx[1], pt2, AFictiveEdges);
2631 if (!
FMap->isMarked(vtx[0], inter_mark))
2639 if (next_point == 2 && (*it[1])->getPosition() !=
FP_Outside) {
2640 if ((*it[1])->getPosition() ==
FP_Inside ||
2643 plane[(i+1)%2])) > 0.0) {
2644 MSG(
"Le nouveau sommet est à l'intérieur");
2657 for (j = 0; j < 2; ++j) {
2658 if (next_point & (j+1)) {
2663 prev_point = next_point;
2666 for (j = 0; j < 2; ++j) {
2667 for (it[j] = inter_set[j]->begin(); it[j] != inter_set[j]->end();
2668 ++it[j])
delete *it[j];
2669 delete inter_set[j];
2672 MSG(
"local_inside = " << local_inside);
2673 if (!local_inside) inside =
false;
2675 while (d != face[i]);
2677 MSG(inter_points.size() <<
" points d'intersection trouvés");
2693 MSG(
"La première face se trouve à l'intérieur de l'autre");
2694 assert(inter_points.empty());
2696 TCoordinate dist, best_dist = 0;
2699 MSG(
"Recherche d'un sommet de l'enveloppe convexe de la face");
2703 dist = ref_plane.pointDistance(*
VTX(d));
2704 if (dist < best_dist) {
2710 while (d != face[i]);
2713 edge_plane.setPlane(plane[i].getNormal() * edge_vector, *
VTX(vtx[0]));
2715 MSG(
"Calcul des points d'intersection entre un vecteur et l'autre face");
2718 TInterPtSet::iterator it;
2720 edge_plane, edge_vector,
2721 APositiveMark, ANegativeMark,
2724 MSG(
"Recherche du point d'intersection le plus proche du sommet");
2725 it = inter_set->begin();
2726 while (it != inter_set->end() &&
2727 (*
VTX(vtx[0]) - (*it)->getPoint()).dot(edge_vector) > 0.0) ++it;
2729 MSG(
"Recherche d'un sommet de l'autre face pour insérer une arête");
2730 vtx[1] = ((*it)->getPosition() ==
FP_Inside ?
2731 (*it)->getEnteringSector() : (*it)->getLeavingSector());
2732 if ((*it)->getCellDim() == 1) {
2735 CPlane clip_plane2(edge_vector, *
VTX(vtx[0]));
2737 clip_plane1, clip_plane2);
2740 MSG(
"Insertion de l'arête");
2742 AFictiveEdges->push_back(vtx[1]);
2747 MSG(
"Création des arêtes d'intersection");
2748 int orient_mark =
FMap->getNewMark();
2749 list<CDart*>::iterator it;
2751 for (it = inter_points.begin(); it != inter_points.end(); ++it) {
2757 for (i = 0; i < 2; ++i) {
2758 MSG(
"Parcours des arêtes de la face " << i+1 <<
" autour du sommet "
2760 FMap->halfMarkOrbit(vtx[i], ORBIT_VERTEX, orient_mark);
2761 for (CDynamicCoverageVertex dcv(
FMap, vtx[i]); dcv.cont(); ++dcv)
2762 if (
FMap->isMarked(*dcv, orient_mark)) {
2763 FMap->unsetMark(*dcv, orient_mark);
2764 if (
FMap->isMarked(*dcv, inter_mark)) {
2765 FMap->unsetMark(*dcv, inter_mark);
2769 MSG(
"L'arête courante n'est pas une arête d'intersection");
2771 edge_vector = *
VTX(
a0(d)) - *
VTX(d);
2773 AFacesMark, edge_vector);
2775 MSG(
"L'arête est à l'intérieur de l'autre face");
2779 AFacesMark, -edge_vector);
2800 FMap->setMark(
a0(d), inter_mark);
2804 while (!
FMap->isMarked(
a1(d), inter_mark));
2805 FMap->unsetMark(
a1(d), inter_mark);
2810 for (it = inter_points.begin(); it != inter_points.end(); ++it) {
2813 for (i = 0; i < 2; ++i)
2814 for (CDynamicCoverageVertex dcv(
FMap, vtx[i]); dcv.cont(); ++dcv) {
2815 FMap->unsetMark(*dcv, inter_mark);
2835 for (TCorefFaceList::iterator it = AList->begin(); it != AList->end(); ++it)
2836 for (CDynamicCoverage01 cov(
FMap, it->face); cov.cont(); ++cov) {
2837 FMap->setDirectInfo(*cov, ADirectInfo, &it->plane);
2838 FMap->setDirectInfo(
a3(*cov), ADirectInfo, &it->plane);
2839 FMap->setMark(
a3(*cov), ANegativeMark);
2850 for (TCorefFaceList::iterator it = AList->begin(); it != AList->end(); ++it)
2851 for (CDynamicCoverage01 cov(
FMap,
a3(it->face)); cov.cont(); ++cov)
2852 FMap->unsetMark(*cov, ANegativeMark);
2861 list<CDart*>::iterator it;
2863 CDart *edge1, *edge2;
2868 if (edge1 && edge2) {
2870 AFacePlaneDI, ANegativeMark);
2878 #define VECT(d) (FMap->isMarked(d, ANegativeMark) ?\
2879 -((CPlane*)FMap->getDirectInfo(d, AFacePlaneDI))->getNormal():\
2880 ((CPlane*)FMap->getDirectInfo(d, AFacePlaneDI))->getNormal())
2889 CVertex axis = *
VTX(
a0(AEdge1)) - *
VTX(AEdge1);
2891 FVertexDI, AFacePlaneDI, ANegativeMark);
2900 while (d1 != AEdge1);
2903 if ((*
VTX(
a0(AEdge2)) - *
VTX(AEdge2)).dot(axis) < 0.0)
2904 AEdge2 =
a3(
a0(AEdge2));
2910 while (d2 != AEdge2);
3020 TFaceSet::iterator it;
3022 for (it = AFaceSet->begin(); it != AFaceSet->end(); ) {
3024 d2 = (it != AFaceSet->end()) ? *it : *AFaceSet->begin();
3026 if (
a2(d1) !=
a3(d2)) {
3027 if (!
FMap->isFree2(d1))
FMap->unsew2(d1);
3039 bitset<NB_MARKS> AMarks)
3044 TFaceSet::iterator it;
3047 for (it = AFaceSet->begin(); it != AFaceSet->end(); ) {
3049 d2 = (it != AFaceSet->end()) ? *it : *AFaceSet->begin();
3051 for (m = 0; m < NB_MARKS; ++m)
3052 if (AMarks[m] &&
a2(d1) !=
a3(d2)) {
3053 if (
FMap->isMarked(d1, m))
FMap->setMark(
a3(d2), m);
3054 else if (
FMap->isMarked(
a3(d2), m))
FMap->setMark(d1, m);
3056 else if (
FMap->isMarked(
a0(
a3(d2)), m))
FMap->setMark(
a0(d1), m);
3064 const CPlane & APlane)
3066 CVertex line = *
VTX(AFace) - APoint;
3068 if (
FTools->isVectorNull(line))
3072 CPlane plane(APlane.getNormal() * line, *
VTX(AFace));
3073 int face_mark =
FMap->getNewMark();
3074 int positive_mark =
FMap->getNewMark();
3075 int negative_mark =
FMap->getNewMark();
3078 FMap->markOrbit(AFace, ORBIT_01, face_mark);
3082 positive_mark, negative_mark,
3084 assert(!inter_set->empty());
3086 TInterPtSet::iterator it;
3088 for (it = inter_set->begin(); it != inter_set->end(); ++it) {
3089 if (
FTools->arePointsEqual((*it)->getPoint(), APoint)) {
3093 else if ((APoint - (*it)->getPoint()).dot(line) > 0.0)
3094 pos = (*it)->getPosition();
3099 for (it = inter_set->begin(); it != inter_set->end(); ++it)