28 #include "message-macros.hh"
30 #include INCLUDE_NON_INLINE("corefine-2d-propagation.icc")
33 using namespace GMap3d;
40 #define INFO(s) (cout << s << endl)
41 #else // INFO_MESSAGES
43 #endif // INFO_MESSAGES
47 #define a0 FMap->alpha0
48 #define a1 FMap->alpha1
49 #define a2 FMap->alpha2
50 #define a3 FMap->alpha3
52 #define b1(d) ((CDart*)FMap->getDirectInfo(d, FAlpha1DI))
56 CCorefine2dPropagation::CCorefine2dPropagation(CGMapVertex * AMap,
57 const CPlane & APlane,
58 bool ACalculateOrientation,
61 :
CCorefine(AMap, AEpsilon), FPlane(APlane), FTools(AMap, AEpsilon),
62 FCalculateOrientation(ACalculateOrientation), FNumberOfIntersections(0)
70 MSG(
"FVertexDI = FMap->getNewDirectInfo() = " <<
FVertexDI);
79 MSG(
"FAlpha1DI = FMap->getNewDirectInfo() = " <<
FAlpha1DI);
91 MSG(
"FMap->freeDirectInfo(FVertexDI = " <<
FVertexDI <<
")");
95 MSG(
"FMap->freeDirectInfo(FAlpha1DI = " <<
FAlpha1DI <<
")");
104 bitset<NB_MARKS> ACopyMarks)
107 list<CDart*> vertex_list;
109 CDart *vertex, *edge, *face, *tmp_edge, *tmp_face;
110 int edge_mark =
FMap->getNewMark();
111 int vertex_mark =
FMap->getNewMark();
112 CVertex *pt1, *pt2, tmp_pt;
119 INFO(
"Initialisation des maillages");
129 INFO(
"Orientation des maillages");
149 INFO(
"Localisation de la première face");
177 FMap->markOrbit(vertex, ORBIT_VERTEX, vertex_mark);
185 FMap->markOrbit(vertex, ORBIT_VERTEX, vertex_mark);
192 INFO(
"Parcours des maillages et création des intersections");
196 vertex_list.push_back(vertex);
197 vertex_list.push_back(face);
200 while(!vertex_list.empty()) {
203 vertex = vertex_list.front(), vertex_list.pop_front();
204 face = vertex_list.front(), vertex_list.pop_front();
208 MSG(
"Parcours du sommet : " << *
getVertex(vertex));
212 if (!
FMap->isMarked(edge, edge_mark)) {
217 #ifdef DEBUG_MESSAGES
218 cout <<
"Parcours de l'arête : ";
220 #endif // DEBUG_MESSAGES
226 if (
FMap->isMarked(edge, vertex_mark)) {
233 while (
b1(tmp_face) == NULL)
234 tmp_face =
a2(
a1(tmp_face));
235 tmp_face =
b1(tmp_face);
247 #ifdef DEBUG_MESSAGES
248 cout <<
"Recherche d'une intersection dans la face :" << endl;
254 !
FMap->isMarked(
a2(
a0(edge)), vertex_mark))) {
255 #ifdef DEBUG_MESSAGES
256 cout <<
"Une intersection trouvée dans la face avec l'arête :\n";
258 cout <<
"Première arête : ";
262 MSG(
"Intersection franche");
268 <<
"Intersection avec le sommet d'origine de l'arête "
281 MSG(
"Intersection avec le sommet extrémité de l'arête");
282 tmp_edge =
a2(
a0(edge));
286 MSG(
"Deuxième arête : ");
289 MSG(
"Intersection franche");
293 MSG(
"Intersection avec un sommet");
299 !
FMap->isMarked(edge, vertex_mark)) {
304 <<
"Interclassement de plus de deux sommets " << *pt1
315 FMap->markOrbit(tmp_edge, ORBIT_VERTEX, vertex_mark);
318 tmp_edge =
a2(
a0(edge));
321 vertex_list.push_back(tmp_edge);
322 vertex_list.push_back(tmp_face);
324 FMap->markOrbit(edge, ORBIT_EDGE, edge_mark);
330 while (edge != vertex);
333 FMap->unmarkOrbit(AMesh1, ORBIT_CC, edge_mark);
334 FMap->unmarkOrbit(AMesh1, ORBIT_CC, vertex_mark);
336 FMap->freeMark(edge_mark);
337 FMap->freeMark(vertex_mark);
344 INFO(
"Assemblage final des maillages");
351 INFO(
"Aucune intersection entre les maillages "
352 <<
"==> insertion d'une arête fictive");
355 FMap->insertEdge(tmp_face,
a1(face));
361 INFO(
"Nettoyage des maillages");
374 INFO(
"Suppression des arêtes doubles");
383 INFO(
"Nombre d'intersections réalisées : "
448 int vert_mark =
FMap->getNewMark();
449 CAttributeVertex *vert;
451 for (CStaticCoverageCC scc2(
FMap, AMesh); scc2.cont(); ++scc2)
452 if (
FMap->isFree2(*scc2))
453 FMap->stopUp(*scc2, 2);
455 for (CStaticCoverageCC scc1(
FMap, AMesh); scc1.cont(); ++scc1)
456 if (
FMap->isFree1(*scc1))
457 FMap->linkAlpha1(*scc1,
a2(*scc1));
459 for (CDynamicCoverageCC dcc(
FMap, AMesh); dcc.cont(); ++dcc) {
462 if (!
FMap->isMarked(*dcc, vert_mark)) {
463 vert =
FMap->findVertex(*dcc);
468 for (CDynamicCoverageVertex dcv(
FMap, *dcc) ; dcv.cont() ; dcv++) {
469 FMap->setMark(*dcv, vert_mark);
479 FMap->unmarkOrbit(AMesh, ORBIT_CC, vert_mark);
480 FMap->freeMark(vert_mark);
491 int vert_mark =
FMap->getNewMark();
492 CAttributeVertex *vert;
494 for (CDynamicCoverageCC dcc(
FMap, AMesh) ; dcc.cont() ; dcc++) {
497 if (!
FMap->isMarked(*dcc, vert_mark)) {
498 FMap->markOrbit(*dcc, ORBIT_VERTEX, vert_mark);
499 vert =
FMap->findVertex(*dcc);
505 FMap->unmarkOrbit(AMesh, ORBIT_CC, vert_mark);
506 FMap->freeMark(vert_mark);
514 const CVertex & AVertex)
518 CDart *d =
a1(
FMap->CGMapGeneric::insertVertex(AEdge));
520 CAttributeVertex *att =
new CAttributeVertex(AVertex);
522 FMap->setVertex(d, att);
524 for (CDynamicCoverageVertex dcv(
FMap, d) ; dcv.cont() ; dcv++) {
528 for (
int i = 0; i < NB_MARKS; i++)
530 FMap->setMark(*dcv, i);
593 : FMap(AMap), FCenter(ACenter), FVertexDI(AVertexDI) {}
595 bool operator () (CDart * AEdge1, CDart * AEdge2)
597 CVertex v1 = *getVertex(
a0(AEdge1)) - FCenter;
598 CVertex v2 = *getVertex(
a0(AEdge2)) - FCenter;
599 return (v1 * v2).getZ() > 0.0;
604 CAttributeVertex * getVertex(CDart * ADart)
const
605 {
return (CAttributeVertex*)FMap->getDirectInfo(ADart, FVertexDI); }
616 multiset<CDart*, CAngularEdgeComparator> edges(comp);
617 multiset<CDart*, CAngularEdgeComparator>::iterator it, tmp_it;
626 while (d1 != AVertex1);
634 while (d2 != AVertex2);
636 for (it = edges.begin(); it != edges.end(); ) {
640 d2 = (it != edges.end()) ? *it : *edges.begin();
642 if (
a1(d1) !=
a2(d2)) {
656 list<CDart*> vertices;
657 list<CDart*>::iterator it;
659 int mark =
FMap->getNewMark();
661 FMap->markOrbit(AVertex1, ORBIT_VERTEX, mark);
668 if (d2 != NULL && !
FMap->isMarked(d2, mark)) {
669 vertices.push_back(d2);
670 FMap->markOrbit(d2, ORBIT_VERTEX, mark);
675 while (d1 != AVertex1);
678 if (!
FMap->isMarked(AVertex2, mark)) {
679 vertices.push_back(AVertex2);
680 FMap->markOrbit(AVertex2, ORBIT_VERTEX, mark);
688 if (d2 != NULL && !
FMap->isMarked(d2, mark)) {
689 vertices.push_back(d2);
690 FMap->markOrbit(d2, ORBIT_VERTEX, mark);
695 while (d1 != AVertex2);
698 for (it = vertices.begin() ; it != vertices.end() ; it++)
699 FMap->unmarkOrbit(*it, ORBIT_VERTEX, mark);
700 FMap->freeMark(mark);
707 <<
"Erreur lors du tri angulaire => fusion des sommets impossible !"
725 if (
a1(d1) !=
a2(d2)) {
734 while (it != l->end());
789 for (CStaticCoverageCC scc(
FMap, AMesh) ; scc.cont() ; scc++) {
794 if (!
FMap->isFree1(d1))
795 FMap->dartUnsew1(d1);
797 if (!
FMap->isFree1(d2))
798 FMap->dartUnsew1(d2);
800 FMap->dartSew1(d1, d2);