29 #include INCLUDE_NON_INLINE("corefine-3d.icc")
32 using namespace GMap3d;
36 #define a0 FMap->alpha0
37 #define a1 FMap->alpha1
38 #define a2 FMap->alpha2
39 #define a3 FMap->alpha3
41 #define VTX(d) (AVertexDI < 0 ? FMap->findVertex(d) : \
42 (CAttributeVertex*)FMap->getDirectInfo(d, AVertexDI))
47 #define MIN_GRID_RES 2
48 #define MAX_GRID_RES 512
57 #define COREFINEMENT_VERSION "Co-raffinement v11"
80 #define WARNING_MESSAGES
81 #include "message-macros.hh"
85 #ifdef SAVE_INTERSECTION_POINTS
87 FILE * point_file = NULL;
89 #define SAVE_POINT(p) (fprintf(point_file ? point_file : stdout, \
90 "%.6f # %.6f # %.6f\n", \
91 (p).getX()*10, (p).getY()*10, (p).getZ()*10))
93 #else // SAVE_INTERSECTION_POINTS
97 #endif // SAVE_INTERSECTION_POINTS
101 CCorefine3d::CCorefine3d(CGMapVertex * AMap,
bool ACalculateOrientation,
102 TCoordinate AEpsilon,
int AVertexDI)
103 :
CCorefine(AMap, AEpsilon), FCalculateOrientation(ACalculateOrientation),
104 FComputeOnlyFirstIntersection(false), FGridResolution(70),
105 FTools(AMap, AEpsilon)
110 CBoundingBox::setEpsilon(2*
FEps);
113 FVertexDI =
FMap->getNewDirectInfo();
114 FLocalVertexDirectInfo =
true;
117 FVertexDI = AVertexDI;
118 FLocalVertexDirectInfo =
false;
130 if (FLocalVertexDirectInfo)
131 FMap->freeDirectInfo(FVertexDI);
140 FComputeOnlyFirstIntersection = ABoolean;
147 FGridResolution = ARes;
153 bitset<NB_MARKS> ACopyMarks)
157 list<CDart*> vertex_list;
159 unsigned long nb_faces;
160 CDart *vertex=NULL, *edge=NULL, *tmp_edge=NULL, *tmp_face=NULL;
161 int edge_mark =
FMap->getNewMark();
162 int vertex_mark =
FMap->getNewMark();
163 CVertex *pt1, *pt2, tmp_pt;
167 FFaceDI =
FMap->getNewDirectInfo();
168 FAlpha2DI =
FMap->getNewDirectInfo();
170 FOrientMark =
FMap->getNewMark();
171 FFictiveMark =
FMap->getNewMark();
172 FIntersectionMark =
FMap->getNewMark();
176 FNumberOfIntersectionLines = 0;
177 FNumberOfIntersectionEdges = 0;
190 #ifdef COREFINEMENT_VERSION
194 #ifdef SAVE_INTERSECTION_POINTS
195 point_file = fopen(
"intersections.dat",
"w");
198 cout <<
"Initialisation des maillages" << endl;
202 cout <<
"Nombre de faces sur le premier maillage : " << nb_faces << endl;
205 cout <<
"Nombre de faces sur le second maillage : " << nb_faces << endl;
208 FInitialisationTime = end - start;
209 cout <<
"Durée de l'initialisation : " << FInitialisationTime << endl;
211 cout <<
"Orientation des maillages" << endl;
215 if (FCalculateOrientation) {
221 FMap->halfMarkOrbit(AMesh1, ORBIT_CC, FOrientMark);
222 FMap->halfMarkOrbit(AMesh2, ORBIT_CC, FOrientMark);
225 cout <<
"Durée de l'orientation : " << end - start << endl;
227 cout <<
"Création de la grille régulière pour l'optimisation" << endl;
238 FGridCreationTime = end - start;
239 cout <<
"Durée de la création : " << FGridCreationTime << endl;
241 FLineCreationTime.setTime(0);
243 cout <<
"Traitement de la première intersection" << endl;
251 if (tmp_face != NULL) {
269 cout <<
"Parcours des maillages et création des intersections" << endl;
272 vertex_list.push_back(AMesh1);
275 while(!vertex_list.empty()) {
278 vertex = vertex_list.front(), vertex_list.pop_front();
281 for (CStaticCoverageVertex dcv(
FMap, vertex); dcv.cont(); ++dcv) {
284 if (!
FMap->isMarked(edge, edge_mark) &&
285 FMap->isMarked(edge, FOrientMark)) {
289 MSG(
"Arête parcourue = [" << *pt1 <<
"," << *pt2 <<
"]");
291 if (!
FMap->isMarked(edge, FFictiveMark))
299 !
FMap->isMarked(
a0(edge), vertex_mark))) {
316 tmp_edge =
a3(
a0(edge));
350 tmp_edge =
a3(
a0(edge));
353 if (!
FMap->isMarked(tmp_edge, vertex_mark) ||
354 !FComputeOnlyFirstIntersection)
355 vertex_list.push_back(tmp_edge);
357 FMap->markOrbit(edge, ORBIT_EDGE, edge_mark);
362 FMap->unmarkOrbit(AMesh1, ORBIT_CC, edge_mark);
363 FMap->unmarkOrbit(AMesh1, ORBIT_CC, vertex_mark);
365 if (FNumberOfIntersectionEdges == 0)
366 FMap->unmarkOrbit(AMesh2, ORBIT_CC, vertex_mark);
368 FMap->freeMark(edge_mark);
369 FMap->freeMark(vertex_mark);
372 FResearchTime = end - start;
373 cout <<
"Durée de la recherche des intersections : "
374 << FResearchTime << endl;
376 FResearchTime -= FLineCreationTime;
378 cout <<
"Assemblage des maillages" << endl;
384 FUpdateTime = end - start;
385 cout <<
"Durée de l'assemblage : " << FUpdateTime << endl;
388 cout <<
"Extraction des lignes de coupes" << endl;
390 FMap->unmarkOrbit(AMesh1, ORBIT_CC, FIntersectionMark);
391 #endif // EXTRACT_LINES
393 cout <<
"Destruction de la grille" << endl;
399 cout <<
"Durée de la destruction : " << end - start << endl;
401 cout <<
"Nettoyage des maillages" << endl;
406 if (FNumberOfIntersectionEdges == 0)
410 cout <<
"Durée du nettoyage : " << end - start << endl;
412 cout <<
"Il y a eu " << FNumberOfIntersectionLines <<
" ligne(s) de coupe et "
413 << FNumberOfIntersectionEdges <<
" arête(s) d'intersection" << endl;
415 #ifdef SAVE_INTERSECTION_POINTS
416 if (point_file != NULL) {
422 FMap->freeDirectInfo(FFaceDI);
423 FMap->freeDirectInfo(FAlpha2DI);
425 FMap->freeMark(FOrientMark);
426 FMap->freeMark(FFictiveMark);
427 FMap->freeMark(FIntersectionMark);
431 return FNumberOfIntersectionLines;
440 int mark =
FMap->getNewMark();
441 unsigned long int nb_faces = 0;
443 MSG(
"mark = " << mark);
446 for (CStaticCoverageCC scc(
FMap, AMesh); scc.cont(); ++scc) {
447 if (
FMap->isFree1(*scc))
448 cerr <<
"<initMesh> Le brin " << *scc
449 <<
" n'est pas lié par alpha1 !!!" << endl;
451 if (
FMap->isFree3(*scc))
452 FMap->stopUp(*scc, 3);
461 CDynamicCoverageCC dcc(
FMap, AMesh);
465 for (dcc.reinit(); dcc.cont(); ++dcc) {
466 if (!
FMap->isMarked(*dcc, mark)) {
467 FMap->markOrbit(*dcc, ORBIT_VERTEX, mark);
478 for (dcc.reinit(); dcc.cont(); ++dcc) {
479 FMap->setDirectInfo(*dcc, FAlpha2DI, NULL);
481 if (
FMap->isMarked(*dcc, mark)) {
483 FMap->unmarkOrbit(*dcc, ORBIT_FACE, mark);
488 FMap->freeMark(mark);
501 int delete_mark =
FMap->getNewMark();
503 MSG(
"delete_mark = " << delete_mark);
505 for (CDynamicCoverageAll dca(
FMap); dca.cont(); ++dca) {
506 if (
FMap->isMarked(*dca, FOrientMark)) {
507 FMap->unmarkOrbit(*dca, ORBIT_EDGE, FOrientMark);
509 if (
FMap->isMarked(*dca, FFictiveMark)) {
514 FMap->unmarkOrbit(*dca, ORBIT_EDGE, FFictiveMark);
518 FMap->deleteMarkedDarts(delete_mark);
519 FMap->freeMark(delete_mark);
592 int face_mark =
FMap->getNewMark();
593 CBoundingBox bb = FTools.orbitBoundingBox(AMesh, ORBIT_CC, FVertexDI);
594 CVertex size = bb.getEpsMaxBound() - bb.getEpsMinBound();
595 unsigned int size_i, size_j, size_k;
597 MSG(
"face_mark = " << face_mark);
600 if (FGridResolution > 0)
602 &size_i, &size_j, &size_k);
606 &size_i, &size_j, &size_k,
609 cout <<
"Résolution de la grille = "
610 << size_i <<
"x" << size_j <<
"x" << size_k << endl;
612 FGrid =
new TFaceGrid(size_i, size_j, size_k, bb);
614 FGrid->setCell(gi,
new list<CDart*>);
616 for (CDynamicCoverageCC dcc(
FMap, AMesh); dcc.cont(); ++dcc) {
617 if (!
FMap->isMarked(*dcc, face_mark) &&
618 FMap->isMarked(*dcc, FOrientMark)) {
619 FMap->markOrbit(*dcc, ORBIT_FACE, face_mark);
624 FMap->unmarkOrbit(AMesh, ORBIT_CC, face_mark);
625 FMap->freeMark(face_mark);
697 list<CDart*>::iterator it;
698 unsigned int max_deg = 0, current_deg;
700 for (it = AList->begin(); it != AList->end(); it++) {
701 for (CDynamicCoverage01 dcf(
FMap, *it); dcf.cont(); dcf++) {
702 if (
FMap->isMarked(*dcf, FOrientMark)) {
705 for (CDynamicCoverageVertex dcv(
FMap, *dcf); dcv.cont(); dcv++)
708 if (current_deg > max_deg)
709 max_deg = current_deg;
725 max = (AGridSize.getX() > AGridSize.getY() ?
726 (AGridSize.getX() > AGridSize.getZ() ?
727 AGridSize.getX() : AGridSize.getZ()) :
728 (AGridSize.getY() > AGridSize.getZ() ?
729 AGridSize.getY() : AGridSize.getZ()));
731 return AGridSize / max;
737 unsigned int AMinRes,
738 unsigned int AMaxRes,
739 unsigned int * AResX,
740 unsigned int * AResY,
741 unsigned int * AResZ)
743 assert(AGridSize.getX() >= 0.0 && AGridSize.getX() <= 1.0 &&
744 AGridSize.getY() >= 0.0 && AGridSize.getY() <= 1.0 &&
745 AGridSize.getZ() >= 0.0 && AGridSize.getZ() <= 1.0);
747 *AResX = (int)(AGridSize.getX() * AMaxRes + 0.5);
748 *AResY = (int)(AGridSize.getY() * AMaxRes + 0.5);
749 *AResZ = (int)(AGridSize.getZ() * AMaxRes + 0.5);
750 if (*AResX < AMinRes) *AResX = AMinRes;
751 if (*AResY < AMinRes) *AResY = AMinRes;
752 if (*AResZ < AMinRes) *AResZ = AMinRes;
758 unsigned long ANbFaces,
759 TCoordinate ANbFacesPerCell,
760 unsigned int * AResX,
761 unsigned int * AResY,
762 unsigned int * AResZ,
763 unsigned int AMinRes,
766 assert(AGridSize.getX() >= 0.0 && AGridSize.getX() <= 1.0 &&
767 AGridSize.getY() >= 0.0 && AGridSize.getY() <= 1.0 &&
768 AGridSize.getZ() >= 0.0 && AGridSize.getZ() <= 1.0);
770 double res = pow((
double)ANbFaces /
771 (
double)(ANbFacesPerCell * AGridSize.getX() *
772 AGridSize.getY() * AGridSize.getZ()),
781 unsigned int AMaxNumberOfFaces)
786 list<CDart*>::iterator it;
788 unsigned int max_deg, size, result = 0;
789 unsigned int div_x, div_y, div_z;
795 if (size > AMaxNumberOfFaces) {
798 if (max_deg <= AMaxNumberOfFaces || size > 2 * max_deg) {
801 #ifdef FIXED_SUB_GRID_RES
802 div_x = div_y = div_z = FIXED_SUB_GRID_RES;
806 &div_x, &div_y, &div_z,
813 sub_grid = FGrid->splitCellInGrid(gi, div_x, div_y, div_z);
816 sub_grid->setCell(gi2,
new list<CDart*>);
818 for (it = l->begin(); it != l->end(); ++it)
837 assert(AGrid != NULL);
838 assert(AFace != NULL);
840 CBoundingBox bb = FTools.orbitBoundingBox(AFace, ORBIT_01, FVertexDI);
843 (*gi)->push_back(
getFace(AFace));
857 CBoundingBox bb = FTools.orbitBoundingBox(AFace, ORBIT_01, FVertexDI);
858 list<CDart*> *dart_list;
859 list<CDart*>::iterator li, old_li;
864 for (li = dart_list->begin(); li != dart_list->end(); ) {
867 if (*old_li == AFace)
868 dart_list->erase(old_li);
881 for (CDynamicCoverageVertex dcv(
FMap, ADart); dcv.cont(); ++dcv) {
882 FMap->setDirectInfo(*dcv, FVertexDI, AVertex);
894 CAttributeVertex * att =
FMap->findVertex(ADart);
896 for (CDynamicCoverageVertex dcv(
FMap, ADart); dcv.cont(); ++dcv) {
897 FMap->setDirectInfo(*dcv, FVertexDI, att);
909 for (CDynamicCoverageFace dcf(
FMap, AFace); dcf.cont(); ++dcf) {
910 FMap->setDirectInfo(*dcf, FFaceDI, AFace);
924 for (
int i=0; i<8; ++i) {
925 d[i] =
FMap->addMapDart();
926 FMap->setDirectInfo(d[i], FAlpha2DI, NULL);
929 FMap->linkAlpha0(d[0], d[1]);
930 FMap->linkAlpha0(d[2], d[3]);
931 FMap->linkAlpha0(d[4], d[5]);
932 FMap->linkAlpha0(d[6], d[7]);
934 FMap->linkAlpha2(d[0], d[2]);
935 FMap->linkAlpha2(d[1], d[3]);
936 FMap->linkAlpha2(d[4], d[6]);
937 FMap->linkAlpha2(d[5], d[7]);
939 FMap->linkAlpha3(d[0], d[4]);
940 FMap->linkAlpha3(d[1], d[5]);
941 FMap->linkAlpha3(d[2], d[6]);
942 FMap->linkAlpha3(d[3], d[7]);
944 FMap->halfMarkOrbit(d[0], ORBIT_EDGE, FOrientMark);
962 assert(
FMap->isMarked(AFace, FOrientMark));
966 FMap->markOrbit(vertex, ORBIT_EDGE, FFictiveMark);
976 const CVertex & AVertex2)
980 assert(
FMap->isMarked(AVertex1, FOrientMark));
999 CDart *old_a1, *face =
getFace(AVertex1);
1001 CPlane plane = FTools.facePlane(AVertex1, FVertexDI);
1003 assert(FTools.isPointOnPlane(AVertex2, plane));
1005 if (FTools.isVectorNull(plane.getNormal())) {
1006 cout <<
"\033[1;34m";
1007 FTools.displayFaceVertices(AVertex1, FVertexDI);
1008 cout <<
"<insertEdgeInFace> La normale à la face est nulle : "
1009 << plane.getNormal() <<
"\033[0m\n";
1015 AVertex1, plane, FVertexDI);
1017 AVertex1 =
a1(AVertex1);
1021 assert(!
FMap->isFree1(AVertex1));
1023 old_a1 =
a1(AVertex1);
1024 FMap->unsew1(AVertex1);
1026 FMap->sew1(AVertex1, edge);
1027 FMap->sew1(old_a1,
a2(edge));
1032 FMap->setVertex(
a0(edge), AVertex2);
1034 for (CDynamicCoverage23 dc(
FMap, edge); dc.cont(); ++dc) {
1035 FMap->setDirectInfo(*dc, FFaceDI, face);
1036 FMap->setDirectInfo(
a0(*dc), FFaceDI, face);
1038 for (
int m = 0; m < NB_MARKS; m++)
1040 FMap->setMark(*dc, m);
1041 FMap->setMark(
a0(*dc), m);
1059 assert(AVertex1 != AVertex2);
1060 assert(
FMap->isMarked(AVertex1, FOrientMark));
1061 assert(
FMap->isMarked(AVertex2, FOrientMark));
1066 for (CDynamicCoverage12 dc1(
FMap, AVertex1); dc1.cont() && !edge; ++dc1)
1067 for (CDynamicCoverage12 dc2(
FMap, AVertex2); dc2.cont() && !edge; ++dc2)
1068 if (
a0(*dc1) == *dc2) {
1069 if (
FMap->isMarked(*dc1, FOrientMark))
1074 if (
FMap->isMarked(edge, FFictiveMark))
1075 FMap->unmarkOrbit(edge, ORBIT_EDGE, FFictiveMark);
1082 MSG(
"Création d'une arête entre " << *
getVertex(AVertex1)
1085 CPlane plane = FTools.facePlane(AVertex1, FVertexDI);
1087 if (FTools.isVectorNull(plane.getNormal())) {
1088 cout <<
"\033[1;34m";
1089 FTools.displayFaceVertices(AVertex1, FVertexDI);
1090 cout <<
"<splitFace> La normale à la face est nulle : "
1091 << plane.getNormal() <<
"\033[0m\n";
1097 CDart *old_a1[2], *face =
getFace(AVertex1);
1103 AVertex1 =
a1(AVertex1);
1105 old_a1[0] =
a1(AVertex1);
1106 old_a1[1] =
a1(AVertex2);
1108 assert(!
FMap->isFree1(AVertex1));
1109 FMap->unsew1(AVertex1);
1111 assert(!
FMap->isFree1(AVertex2));
1112 FMap->unsew1(AVertex2);
1114 FMap->sew1(AVertex1, edge);
1115 FMap->sew1(old_a1[0],
a2(edge));
1117 FMap->sew1(AVertex2,
a0(edge));
1118 FMap->sew1(old_a1[1],
a2(
a0(edge)));
1123 if (!
FMap->isSameOrbit(edge,
a2(edge), ORBIT_01)) {
1128 for (CDynamicCoverageEdge dce(
FMap, edge); dce.cont(); ++dce)
1129 FMap->setDirectInfo(*dce, FFaceDI, face);
1137 for (CDynamicCoverageEdge dce(
FMap, edge); dce.cont(); ++dce) {
1138 for (
int m = 0; m < NB_MARKS; m++)
1140 FMap->setMark(*dce, m);
1155 assert(
FMap->isMarked(AVertex, FOrientMark));
1160 <<
"] éclatée en " << APoint);
1162 CDart *d, *face =
getFace(AVertex);
1164 FMap->CGMapGeneric::insertVertex(AVertex);
1166 d =
a1(
a0(AVertex));
1168 FMap->halfMarkOrbit(d, ORBIT_VERTEX, FOrientMark);
1170 if (
FMap->isMarked(AVertex, FFictiveMark))
1171 FMap->markOrbit(d, ORBIT_VERTEX, FFictiveMark);
1173 FMap->setVertex(d, APoint);
1176 for (CDynamicCoverageVertex dcv(
FMap, d); dcv.cont(); ++dcv) {
1177 FMap->setDirectInfo(*dcv, FFaceDI, face);
1178 FMap->setDirectInfo(*dcv, FAlpha2DI, NULL);
1180 for (
int m = 0; m < NB_MARKS; m++)
1182 FMap->setMark(*dcv, m);
1195 CDart *d1 =
a1(AEdge);
1196 CDart *d2 =
a1(
a0(AEdge));
1198 if (ADeleteMark < 0)
1199 FMap->merge(AEdge,
a2(AEdge), 2,
true);
1201 FMap->markOrbit(AEdge, ORBIT_EDGE, ADeleteMark);
1202 FMap->merge(AEdge,
a2(AEdge), 2,
false);
1214 const CPlane & APlane)
1225 APlane.getLineIntersection(pt, v1, &t);
1230 APlane.getLineIntersection(pt, v2, &t);
1243 assert(
FMap->isMarked(AEdge1, FOrientMark));
1244 assert(
FMap->isMarked(AEdge2, FOrientMark));
1248 for (CDynamicCoverage23 dc1(
FMap, AEdge1); dc1.cont() && !found; ++dc1)
1249 for (CDynamicCoverage23 dc2(
FMap, AEdge2); dc2.cont() && !found; ++dc2)
1250 found = (
FMap->getDirectInfo(*dc1, FAlpha2DI) == *dc2);
1263 assert(
FMap->isMarked(AEdge1, FOrientMark));
1264 assert(
FMap->isMarked(AEdge2, FOrientMark));
1267 bool same_edge =
false;
1270 if (
FMap->getDirectInfo(d, FAlpha2DI) != NULL)
1271 d =
a3((CDart*)
FMap->getDirectInfo(d, FAlpha2DI));
1273 d =
a3(FTools.alpha2(d));
1275 same_edge = (d == AEdge2) || (d ==
a3(
a0(AEdge2)));
1277 while (d != AEdge1 && !same_edge);
1285 #define isSameEdge isSameEdge_Optimized
1289 assert(
FMap->isMarked(AFace1, FOrientMark));
1290 assert(
FMap->isMarked(AFace2, FOrientMark));
1302 const CVertex & AVertex2)
1308 TCoordinate t1 = 0.0, t2 = 0.0;
1309 CVertex *pt1, *pt2, pt;
1311 CBoundingBox line_bb(AVertex1, AVertex2);
1313 int mark =
FMap->getNewMark();
1314 int edge_mark =
FMap->getNewMark();
1315 int face_mark =
FMap->getNewMark();
1317 MSG(
"mark = " << mark);
1318 MSG(
"edge_mark = " << edge_mark);
1319 MSG(
"face_mark = " << face_mark);
1322 list<CDart*>::iterator li;
1328 MSG(
"Recherche d'une éventuelle intersection avec les sommets");
1330 for (gi.reinit(); gi.cont(); ++gi) {
1331 for (li = (*gi)->begin(); li != (*gi)->end(); ++li) {
1332 for (CDynamicCoverageFace dcf(
FMap, *li); dcf.cont(); ++dcf) {
1333 if (!
FMap->isMarked(*dcf, mark) &&
FMap->isMarked(*dcf, FOrientMark)) {
1335 FMap->markOrbit(*dcf, ORBIT_VERTEX, mark);
1339 if (line_bb.isInBox(pt)) {
1344 MSG(
"Une intersection trouvée avec le sommet " << pt);
1354 for (CDynamicCoverageVertex dcv(
FMap, *dcf); dcv.cont(); ++dcv) {
1356 if (!
FMap->isMarked(*dcv, edge_mark))
1357 FMap->markOrbit(*dcv, ORBIT_EDGE, edge_mark);
1360 if (!
FMap->isMarked(*dcv, face_mark))
1361 FMap->markOrbit(*dcv, ORBIT_FACE, face_mark);
1370 MSG(
"Recherche d'une éventuelle intersection avec les arêtes");
1372 for (gi.reinit(); gi.cont(); ++gi) {
1373 for (li = (*gi)->begin(); li != (*gi)->end(); ++li) {
1374 for (CDynamicCoverageFace dcf(
FMap, *li); dcf.cont(); ++dcf) {
1375 if (
FMap->isMarked(*dcf, edge_mark)) {
1376 FMap->unmarkOrbit(*dcf, ORBIT_EDGE, edge_mark);
1377 FMap->unmarkOrbit(*dcf, ORBIT_EDGE, mark);
1379 else if (
FMap->isMarked(*dcf, mark) &&
1381 FMap->isMarked(*dcf, FOrientMark)) {
1382 FMap->unmarkOrbit(*dcf, ORBIT_EDGE, mark);
1387 if (CBoundingBox(*pt1, *pt2) * line_bb) {
1392 pt = *pt1 + t1 * (*pt2 - *pt1);
1397 (t1 >= 0.0 && t1 <= 1.0)) {
1400 MSG(
"Une intersection trouvée avec l'arête "
1401 <<
"[" << *pt1 <<
"," << *pt2 <<
"]");
1411 for (CDynamicCoverageEdge dce(
FMap, *dcf); dce.cont(); ++dce) {
1413 if (!
FMap->isMarked(*dce, face_mark))
1414 FMap->markOrbit(*dce, ORBIT_FACE, face_mark);
1424 MSG(
"Recherche d'une éventuelle intersection avec les faces");
1426 for (gi.reinit(); gi.cont(); ++gi) {
1427 for (li = (*gi)->begin(); li != (*gi)->end(); ++li) {
1428 if (
FMap->isMarked(*li, face_mark)) {
1429 FMap->unmarkOrbit(*li, ORBIT_FACE, face_mark);
1430 FMap->markOrbit(*li, ORBIT_FACE, mark);
1432 else if (!
FMap->isMarked(*li, mark)) {
1433 face = (
FMap->isMarked(*li, FOrientMark)) ? *li :
a3(*li);
1434 FMap->markOrbit(face, ORBIT_FACE, mark);
1437 plane = FTools.facePlane(face, FVertexDI);
1442 pt = AVertex1 + t2 * (AVertex2 - AVertex1);
1450 MSG(
"Une intersection avec une face trouvée");
1463 MSG(
"Démarquage des faces");
1465 for (gi.reinit(); gi.cont(); ++gi)
1466 for (li = (*gi)->begin(); li != (*gi)->end(); ++li)
1467 for (CDynamicCoverageFace dcf(
FMap, *li); dcf.cont(); ++dcf)
1468 if (
FMap->isMarked(*dcf, mark))
1469 FMap->unmarkOrbit(*dcf, ORBIT_VERTEX, mark);
1471 FMap->freeMark(mark);
1472 FMap->freeMark(edge_mark);
1473 FMap->freeMark(face_mark);
1487 CVertex pt1, pt2, pt;
1488 CDart *face, *result = NULL;
1491 int mark =
FMap->getNewMark();
1493 MSG(
"mark = " << mark);
1496 list<CDart*>::iterator li;
1499 for (gi.reinit(); gi.cont() && !result; ++gi)
1500 for (li = (*gi)->begin(); li != (*gi)->end() && !result; ++li)
1501 for (CDynamicCoverageFace dcf(
FMap, *li); dcf.cont() && !result; ++dcf)
1502 if (!
FMap->isMarked(*dcf, mark) &&
FMap->isMarked(*dcf, FOrientMark)) {
1504 FMap->markOrbit(*dcf, ORBIT_VERTEX, mark);
1508 if (FTools.arePointsEqual(AVertex, pt)) {
1509 MSG(
"Une intersection trouvée avec le sommet " << pt);
1516 for (gi.reinit(); gi.cont() && !result; ++gi)
1517 for (li = (*gi)->begin(); li != (*gi)->end() && !result; ++li)
1518 for (CDynamicCoverageFace dcf(
FMap, *li); dcf.cont() && !result; ++dcf)
1519 if (
FMap->isMarked(*dcf, mark) &&
FMap->isMarked(*dcf, FOrientMark)) {
1520 FMap->unmarkOrbit(*dcf, ORBIT_EDGE, mark);
1525 if (FTools.isPointOnLine(AVertex, pt1, pt2)) {
1528 if (t >= 0.0 && t <= 1.0) {
1529 MSG(
"Une intersection trouvée avec l'arête "
1530 <<
"[" << pt1 <<
"," << pt2 <<
"]");
1538 for (gi.reinit(); gi.cont() && !result; ++gi)
1539 for (li = (*gi)->begin(); li != (*gi)->end() && !result; ++li)
1540 if (!
FMap->isMarked(*li, mark)) {
1541 face = (
FMap->isMarked(*li, FOrientMark)) ? *li :
a3(*li);
1542 FMap->markOrbit(face, ORBIT_FACE, mark);
1544 plane = FTools.facePlane(face, FVertexDI);
1546 if (FTools.isPointOnPlane(AVertex, plane) &&
1548 MSG(
"Une intersection avec une face trouvée");
1554 for (gi.reinit(); gi.cont(); ++gi)
1555 for (li = (*gi)->begin(); li != (*gi)->end(); ++li)
1556 for (CDynamicCoverageFace dcf(
FMap, *li); dcf.cont(); ++dcf)
1557 if (
FMap->isMarked(*dcf, mark))
1558 FMap->unmarkOrbit(*dcf, ORBIT_VERTEX, mark);
1560 FMap->freeMark(mark);
1580 assert(
FMap->isMarked(AVertex1, FOrientMark));
1581 assert(
FMap->isMarked(AVertex2, FOrientMark));
1583 list<CDart*> inter_list;
1584 CDart *d1, *d2, *current, *first, *last;
1586 int mark =
FMap->getNewMark();
1588 int nb_vertices = 0;
1589 CPlane plane1, plane2;
1591 MSG(
"mark = " << mark);
1593 FNumberOfIntersectionLines++;
1595 cout <<
"--> Suivi d'une ligne de coupe" << endl;
1600 inter_list.push_back(AVertex1);
1601 inter_list.push_back(AVertex2);
1602 while (!inter_list.empty()) {
1603 d1 = inter_list.front(), inter_list.pop_front();
1604 d2 = inter_list.front(), inter_list.pop_front();
1608 for (CStaticCoverageVertex dcv1(
FMap, d1); dcv1.cont(); ++dcv1)
1609 if (!
FMap->isMarked(*dcv1, mark) &&
1610 FMap->isMarked(*dcv1, FOrientMark)) {
1611 FMap->markOrbit(*dcv1, ORBIT_13, mark);
1614 last = FTools.alpha2(
a1(*dcv1));
1616 for (CStaticCoverageVertex dcv2(
FMap, d2); dcv2.cont(); ++dcv2)
1617 if (!
FMap->isMarked(*dcv2, mark) &&
1618 FMap->isMarked(*dcv2, FOrientMark)) {
1619 FMap->markOrbit(*dcv2, ORBIT_13, mark);
1628 plane1 = FTools.facePlane(current, FVertexDI);
1629 plane2 = FTools.facePlane(*dcv2, FVertexDI);
1632 if ((plane1.getNormal() * plane2.getNormal()).norm() >
FEps) {
1635 AMark, &inter_list);
1638 WARN_BB(
"<followIntersection> Faces coplanaires !");
1642 current = FTools.alpha2(
a1(current));
1644 while (current != last && !ok);
1647 FMap->unmarkOrbit(d2, ORBIT_VERTEX, mark);
1650 FMap->markOrbit(d1, ORBIT_VERTEX, AMark);
1651 FMap->unmarkOrbit(d1, ORBIT_VERTEX, mark);
1654 FMap->freeMark(mark);
1658 cout <<
" Durée du suivi : " << end - start << endl;
1659 FLineCreationTime += end - start;
1674 const CPlane & APlane1,
1676 const CPlane & APlane2,
1678 list<CDart*> * AList)
1682 assert(
FMap->isMarked(AFace1, FOrientMark));
1683 assert(
FMap->isMarked(AFace2, FOrientMark));
1687 bool result =
false;
1689 #ifdef DEBUG_MESSAGES
1690 FTools.displayFaceVertices(AFace1, FVertexDI);
1691 FTools.displayFaceVertices(AFace2, FVertexDI);
1694 if (FTools.isVectorNull(APlane1.getNormal())) {
1695 cout <<
"\033[1;34m";
1696 FTools.displayFaceVertices(AFace1, FVertexDI);
1697 cout <<
"<manageFacesIntersection> La normale à la face 1 est nulle : "
1698 << APlane1.getNormal() <<
"\033[0m\n";
1700 if (FTools.isVectorNull(APlane2.getNormal())) {
1701 cout <<
"\033[1;34m";
1702 FTools.displayFaceVertices(AFace2, FVertexDI);
1703 cout <<
"<manageFacesIntersection> La normale à la face 2 est nulle : "
1704 << APlane2.getNormal() <<
"\033[0m\n";
1710 dir = APlane1.getNormal() * APlane2.getNormal();
1720 MSG(
"Ligne de coupe = (" << pt <<
"," << pt + dir <<
")");
1728 if (inter1.getCell() != AFace1 && inter2.getCell() != AFace2) {
1729 if (inter1.getCell() != NULL && inter2.getCell() != NULL) {
1731 inter1, inter2, AMark, AList);
1736 WARN_BB(
"<manageFacesIntersection> Intersections trouvées invalides !");
1746 #define sortFacesAroundEdges sortFacesAroundEdges_SuperNaive
1749 const CPlane & APlane1,
1750 const CPlane & APlane2,
1753 int AMark, list<CDart*> * AList)
1757 CDart *d1, *d2, *edge1, *edge2;
1758 bool add_to_list =
true;
1765 MSG(
"L'intersection sur chaque face se trouve à égale distance");
1783 if (
FMap->isMarked(d1, AMark))
1784 add_to_list =
false;
1800 MSG(
"L'intersection la plus proche se trouve sur la même face");
1810 if (
FMap->isMarked(d1, AMark))
1811 add_to_list =
false;
1829 MSG(
"L'intersection la plus proche se trouve sur l'autre face");
1852 FMap->markOrbit(
a0(edge1), ORBIT_VERTEX, AMark);
1854 assert(
FMap->isMarked(edge1, FOrientMark));
1855 assert(
FMap->isMarked(edge2, FOrientMark));
1858 FNumberOfIntersectionEdges++;
1860 MSG(
"Tri des faces autour de l'arête d'intersection n°"
1861 << FNumberOfIntersectionEdges);
1863 FTools.sortFacesAroundEdges(edge1, edge2, FAlpha2DI, FVertexDI);
1865 #ifdef EXTRACT_LINES //---------------------------------------------------------
1866 FMap->markOrbit(edge1, ORBIT_EDGE, FIntersectionMark);
1867 FMap->markOrbit(edge2, ORBIT_EDGE, FIntersectionMark);
1868 #endif // EXTRACT_LINES --------------------------------------------------------
1880 AList->push_back(d1);
1881 AList->push_back(d2);
1884 #ifdef FOLLOW_DEBUG_MODE //-----------------------------------------------------
1885 CGMapVertex * tmp_map =
new CGMapVertex;
1886 char file_name[1024] =
"\0";
1890 s.width(4); s.fill(0); s.flags (ios::right);
1891 s<<FNumberOfIntersectionEdges;
1895 d1 = tmp_map->addMapDart();
1896 d2 = tmp_map->addMapDart();
1898 tmp_map->linkAlpha0(d1, d2);
1900 tmp_map->setVertex(d1, *
getVertex(edge1));
1903 tmp_map->save(s.str(), AsciiFormat);
1906 #endif // FOLLOW_DEBUG_MODE ----------------------------------------------------
1911 #undef sortFacesAroundEdges
1920 for (CStaticCoverageCC scc(
FMap, AMesh); scc.cont(); ++scc) {
1921 d = (CDart*)
FMap->getDirectInfo(*scc, FAlpha2DI);
1924 if (!
FMap->isFree2(*scc))
1926 if (!
FMap->isFree2(d))
1929 FMap->sew2(*scc, d);
1931 FMap->setDirectInfo(*scc, FAlpha2DI, NULL);
1932 FMap->setDirectInfo(
a0(*scc), FAlpha2DI, NULL);
1933 FMap->setDirectInfo(d, FAlpha2DI, NULL);
1934 FMap->setDirectInfo(
a0(d), FAlpha2DI, NULL);
1942 #define COPY(d) ((CDart*)FMap->getDirectInfo(d, copy_direct_info))
1948 int copy_direct_info =
FMap->getNewDirectInfo();
1950 CDynamicCoverageCC dcc(
FMap, AMesh);
1953 for (dcc.reinit(); dcc.cont(); ++dcc) {
1954 if (
FMap->isMarked(*dcc, FIntersectionMark)) {
1955 FMap->setDirectInfo(*dcc, copy_direct_info,
FMap->addMapDart());
1956 FMap->setMark(
COPY(*dcc), FIntersectionMark);
1962 for (dcc.reinit(); dcc.cont(); ++dcc) {
1963 if (
FMap->isMarked(*dcc, FIntersectionMark)) {
1968 while (!
FMap->isMarked(d, FIntersectionMark))
1977 for (dcc.reinit(); dcc.cont(); ++dcc) {
1978 if (
FMap->isMarked(*dcc, FIntersectionMark)) {
1987 for (dcc.reinit(); dcc.cont(); ++dcc) {
1988 if (
FMap->isMarked(
COPY(*dcc), FIntersectionMark)&&
1989 FMap->isMarked(
COPY(*dcc), FIntersectionMark)) {
1990 FMap->unmarkOrbit(
COPY(*dcc), ORBIT_VERTEX, FIntersectionMark);
1995 FMap->freeDirectInfo(copy_direct_info);