26 #include "g-map-vertex.hh"
27 #include "geometry.hh"
29 using namespace GMap3d;
42 #define GET_V(DART) FMap->getDirectInfoAsAttributeVertex((DART), directVertex)
44 #define IT_PRED(IT,SET) (((IT)==(SET).begin()) \
48 #define IT_SUCC(IT,SET) (++(IT), \
50 ? (--(IT), (CDartVertex *) NULL) \
54 const CVertex& ANormalVector)
56 assert(ADart1 != NULL);
57 assert(ADart2 != NULL);
58 assert(FMap->isIFreeOrbit(ADart1, 3, ORBIT_CC));
59 assert(FMap->isIFreeOrbit(ADart2, 3, ORBIT_CC));
60 assert(!ANormalVector.isNull());
62 if (FMap->isSameOrbit(ADart1, ADart2, ORBIT_CC))
66 int treated = FMap->getNewMark();
68 int directVertex = FMap->getNewDirectInfo();
69 int mesh1 = FMap->getNewMark();
70 int extremity1 = FMap->getNewMark();
75 for (dart = ADart1; dart!=NULL; dart = dart==ADart1 ? ADart2 : NULL)
77 for (CDynamicCoverageCC cov(FMap, dart); cov.cont(); ++cov)
78 if (FMap->isFree2(*cov))
79 FMap->stopUp(*cov, 2);
83 FMap->pointDirectInfoToAttributeVertex(directVertex);
84 FMap->markOrbit(ADart1, ORBIT_CC, mesh1);
88 extremity1, ANormalVector,
91 LEX_SET eventSet(lexComparator);
93 for (dart = ADart1; dart!=NULL; dart = dart==ADart1 ? ADart2 : NULL)
95 for (CDynamicCoverageCC cov(FMap, dart); cov.cont(); ++cov)
96 if (! FMap->isMarked(*cov, treated))
98 FMap->markOrbit(*cov, ORBIT_02, treated);
100 if (! FMap->isFree0(*cov))
102 if (lexComparator((CDartVertex*) *cov,
103 (CDartVertex*) FMap->alpha0(*cov)))
104 FMap->setMark( *cov , extremity1);
106 FMap->setMark(FMap->alpha0(*cov), extremity1);
108 eventSet.insert((CDartVertex*) *cov );
109 eventSet.insert((CDartVertex*) FMap->alpha0(*cov));
113 FMap->unmarkOrbit(dart, ORBIT_CC, treated);
117 LEX_SET eventTreatedSet(lexComparator);
120 vertComparator(FMap, directVertex, extremity1, ANormalVector);
122 VERT_SET sweepingSet(vertComparator);
124 while (eventSet.begin()!=eventSet.end())
126 CDartVertex* current = * eventSet.begin();
130 if (FMap->isMarked(current, extremity1))
134 VERT_IT currentPos = sweepingSet.insert((CDartVertex *) current);
135 assert(sweepingSet.find((CDartVertex *) current) != sweepingSet.end());
138 CDart * neighbors[2];
140 neighbors[0] =
IT_PRED(currentPos, sweepingSet);
141 neighbors[1] =
IT_SUCC(currentPos, sweepingSet);
144 for (
int i=0; i<2; ++i)
146 lexComparator, sweepingSet, extremity1,
147 mesh1, directVertex, ANormalVector);
152 assert(lexComparator((CDartVertex*) FMap->alpha0(current),
153 (CDartVertex*) current));
161 neighbors[0] =
IT_PRED(it, sweepingSet);
162 neighbors[1] =
IT_SUCC(it, sweepingSet);
166 lexComparator, sweepingSet, extremity1,
167 mesh1, directVertex, ANormalVector);
171 sweepingSet.erase(it);
175 eventTreatedSet.insert(current);
176 eventSet.erase(current);
179 eventTreatedSet.swap(eventSet);
182 int exterior = FMap->getNewMark();
184 CDart* darts[2] = { ADart1, ADart2 };
186 for (
int i=0; i<2; ++i)
188 if (CGeometry::getAngle(FMap->cellDimensionNormalVector(darts[i], 3),
191 FMap->markOrbit (darts[i], ORBIT_CC, exterior);
192 FMap->halfUnmarkOrbit(darts[i], ORBIT_CC, exterior);
195 FMap->halfMarkOrbit(darts[i], ORBIT_CC, exterior);
201 lexComparator2(FMap, directVertex,
202 extremity1, ANormalVector,
205 LEX_SET eventSet2(lexComparator2);
208 for (it = eventSet.begin(); it!=eventSet.end(); ++it)
209 eventSet2.insert(*it);
213 angComparator(FMap, directVertex, ANormalVector);
215 for (it = eventSet2.begin(); it!=eventSet2.end(); )
217 const CAttributeVertex & currentVertex = *
GET_V(*it);
218 bool uniqueTopoVertex =
true;
222 while (it!=eventSet2.end() && *
GET_V(*it) == currentVertex)
224 if (
GET_V(*it) != ¤tVertex)
225 uniqueTopoVertex =
false;
230 if (!uniqueTopoVertex)
235 for (
LEX_IT local = first; local!=it; ++local)
237 CDart * current = *local;
239 assert(! FMap->isFree2(current));
241 if (! FMap->isMarked(current, exterior))
242 current = FMap->alpha2(current);
244 assert(FMap->isMarked(current, exterior));
245 assert(FMap->findVertex(current) ==
GET_V(current));
247 angSet.insert((CDartVertex*) current);
251 ANG_IT round = angSet.end();
252 CDart* pred = *(--round);
254 for (round = angSet.begin(); round!=angSet.end(); ++round)
256 if (! FMap->isFree1(FMap->alpha2(pred)))
257 FMap->unsew1(FMap->alpha2(pred));
259 if (! FMap->isFree1(*round))
260 FMap->unsew1(*round);
262 assert(FMap->isMarked(FMap->alpha2(pred), exterior) !=
263 FMap->isMarked(*round, exterior));
265 FMap->sew1(FMap->alpha2(pred), *round);
270 FMap->pointDirectInfoToAttributeVertex(directVertex, pred);
275 int toDelete = FMap->getNewMark();
277 CDynamicCoverageAll itAll(FMap);
279 for (; itAll.cont(); ++itAll)
280 if (! FMap->isMarked(*itAll, toDelete) &&
281 ! FMap->isFree0(*itAll) && ! FMap->isFree1(*itAll) &&
282 (
GET_V(FMap->alpha0(*itAll)) ==
GET_V(FMap->alpha10(*itAll))))
284 if (FMap->alpha01(*itAll) != FMap->alpha10(*itAll))
287 CDart* d0 = FMap->alpha0 (*itAll); FMap->unsew0(d0 );
288 CDart* d10 = FMap->alpha10(*itAll); FMap->unsew0(d10);
290 FMap->sew0( *itAll , FMap->alpha2(d10));
291 FMap->sew0(FMap->alpha1(*itAll), FMap->alpha2(d0 ));
294 assert(FMap->alpha01(*itAll) == FMap->alpha10(*itAll));
297 CDart* d2 = FMap->alpha2 (*itAll); FMap->unsew2(d2 );
298 CDart* d12 = FMap->alpha12(*itAll); FMap->unsew2(d12);
302 FMap->markOrbit(*itAll, ORBIT_FACE, toDelete);
306 for (itAll.reinit(); itAll.cont(); )
308 CDart * current = itAll++;
310 if (FMap->isMarked(current, toDelete))
311 FMap->delMapDart(current);
314 FMap->freeMark(toDelete);
317 FMap->freeMark(treated);
318 FMap->freeDirectInfo(directVertex);
320 FMap->unmarkAll(mesh1);
321 FMap->freeMark(mesh1);
323 FMap->unmarkAll(exterior);
324 FMap->freeMark(exterior);
326 FMap->unmarkAll(extremity1);
327 FMap->freeMark(extremity1);
337 assert(AElement != NULL);
339 VERT_IT it = ASweepingSet.find((CDartVertex *) AElement);
341 if (it == ASweepingSet.end())
343 cout <<
"Élément introuvable: " << AElement <<
"!" << endl;
344 it = ASweepingSet.begin();
345 while (it != ASweepingSet.end() && *it != AElement)
348 if (it==ASweepingSet.end())
350 cout << * (CVertex*) FMap->findVertex( AElement ) << endl;
351 cout << * (CVertex*) FMap->findVertex(FMap->alpha0(AElement)) << endl;
354 assert(it != ASweepingSet.end());
360 #define GET_V(DART) FMap->getDirectInfoAsAttributeVertex((DART), ADirectVertex)
367 int AExtremity1,
int AMesh1,
int ADirectVertex,
368 const CVertex & ANormalVector)
370 if (ADart1==NULL || ADart2==NULL)
373 if (FMap->isMarked(ADart1, AMesh1) == FMap->isMarked(ADart2, AMesh1))
377 CAttributeVertex* A =
GET_V( ADart1 );
378 CAttributeVertex* B =
GET_V(FMap->alpha0(ADart1));
381 CAttributeVertex* C =
GET_V( ADart2 );
382 CAttributeVertex* D =
GET_V(FMap->alpha0(ADart2));
386 CDart* cutDart[2] = { ADart1, ADart2 };
387 static CVertex intersections[2];
389 CGeometry::getSegmentsIntersection(*A,*B,*C,*D, ANormalVector,
390 cut[0], intersections[0],
391 cut[1], intersections[1]);
393 for (
int i=1; i>=0; --i)
396 CDart* toCut = cutDart[cut[i]-1];
398 assert(ALexComparator((CDartVertex*) toCut,
399 (CDartVertex*) FMap->alpha0(toCut)));
401 FMap->CGMapGeneric::insertVertex(toCut);
402 FMap->setVertex(FMap->alpha0(toCut), intersections[i]);
404 FMap->pointDirectInfoToAttributeVertex(ADirectVertex,
405 FMap->alpha0(toCut));
407 FMap->setMark(FMap->alpha01(toCut), AExtremity1);
409 if (FMap->isMarked(toCut, AMesh1))
410 FMap->markOrbit(FMap->alpha0(toCut), ORBIT_VERTEX, AMesh1);
412 AEventSet.insert((CDartVertex*) FMap->alpha0 (toCut));
413 AEventSet.insert((CDartVertex*) FMap->alpha01(toCut));
415 assert(ALexComparator((CDartVertex*) toCut,
416 (CDartVertex*) FMap->alpha0 (toCut)));
417 assert(ALexComparator((CDartVertex*) FMap->alpha01 (toCut),
418 (CDartVertex*) FMap->alpha010(toCut)));