30 using namespace GMap3d;
35 int mark = getNewMark();
38 bool same = isMarked(ADart2, mark);
54 bool orientable =
true;
57 int selected = getNewMark();
59 for (
int dim=0; dim<=3; ++dim)
62 CCoverage * cov = getDynamicCoverage(ADart, AOrbit);
64 setMark(**cov, selected);
66 for (; cov->
cont() && orientable; ++(*cov))
67 if (isMarked(**cov, selected))
69 for (
int dim=0; dim<=3; ++dim)
70 if (usedDim[dim] && !isFree(**cov, dim) &&
71 isMarked(alpha(**cov, dim), selected))
76 for (
int dim=0; dim<=3; ++dim)
77 if (usedDim[dim] && !isFree(**cov, dim))
78 setMark(alpha(**cov, dim), selected);
92 int mark = getNewMark();
94 for (; it.
cont(); ++it)
96 if ( !isMarked(*it, mark) )
102 negateMaskMark(mark);
108 int * ANb0,
int * ANb1,
int * ANb2,
int * ANb3)
110 int * count[4] = { ANb0, ANb1, ANb2, ANb3 };
118 if (count[i] != NULL)
120 count[nbAsked] = count[i];
121 * count[nbAsked] = 0;
123 borderMark[nbAsked] = getNewMark();
130 for (; it.
cont(); ++it)
131 for (i=0; i<nbAsked; ++i)
132 if (isFree(*it, dim[i]) && !isMarked(*it, borderMark[i]))
140 for (i=0; i<nbAsked; ++i)
141 if (isMarked(*it, borderMark[i]))
145 for (i=0; i<nbAsked; ++i)
146 freeMark(borderMark[i]);
150 int * ANb0,
int * ANb1,
int * ANb2,
int * ANb3)
152 assert(ADart != NULL);
154 int * count[4] = { ANb0, ANb1, ANb2, ANb3 };
162 if (count[i] != NULL)
164 count[nbAsked] = count[i];
165 * count[nbAsked] = 0;
167 borderMark[nbAsked] = getNewMark();
171 CCoverage * cov = getDynamicCoverage(ADart, AOrbit);
174 for (; cov->
cont(); ++(*cov))
175 for (i=0; i<nbAsked; ++i)
176 if (isFree(**cov, dim[i]) && !isMarked(**cov, borderMark[i]))
184 for (i=0; i<nbAsked; ++i)
185 if (isMarked(**cov, borderMark[i]))
191 for (i=0; i<nbAsked; ++i)
192 freeMark(borderMark[i]);
196 int * ANb0,
int * ANb1,
int * ANb2,
197 int * ANb3,
int * ANb4,
int * ANbDarts)
199 int * count[5] = { ANb0, ANb1, ANb2, ANb3, ANb4 };
208 if (count[i] != NULL)
210 count[nbAsked] = count[i];
211 * count[nbAsked] = 0;
213 cellMark[nbAsked] = getNewMark();
219 for (; it.
cont(); ++it, ++nbDarts)
220 for (i=0; i<nbAsked; ++i)
221 if (!isMarked(*it, cellMark[i]))
227 if (ANbDarts != NULL)
228 * ANbDarts = nbDarts;
232 for (i=0; i<nbAsked; ++i)
233 if (isMarked(*it, cellMark[i]))
237 for (i=0; i<nbAsked; ++i)
238 freeMark(cellMark[i]);
242 int * ANb0,
int * ANb1,
int * ANb2,
243 int * ANb3,
int * ANb4,
int * ANbDarts)
245 assert(ADart != NULL);
247 int * count[5] = { ANb0, ANb1, ANb2, ANb3, ANb4 };
256 if (count[i] != NULL)
258 count[nbAsked] = count[i];
259 * count[nbAsked] = 0;
261 cellMark[nbAsked] = getNewMark();
265 CCoverage * cov = getDynamicCoverage(ADart, AOrbit);
268 for (; cov->
cont(); ++(*cov), ++nbDarts)
269 for (i=0; i<nbAsked; ++i)
270 if (!isMarked(**cov, cellMark[i]))
276 if (ANbDarts != NULL)
277 * ANbDarts = nbDarts;
281 for (i=0; i<nbAsked; ++i)
282 if (isMarked(**cov, cellMark[i]))
288 for (i=0; i<nbAsked; ++i)
289 freeMark(cellMark[i]);
293 int * ANbVertices,
int * ANbEdges,
294 int * ANbFaces,
int * ANbVolumes,
301 int mark = getNewMark();
303 negateMaskMark(mark);
305 countCells (mark, ANbVertices, ANbEdges, ANbFaces, ANbVolumes, ANbCC,
308 countBorders(mark, ANb0Borders, ANb1Borders, ANb2Borders, ANb3Borders);
310 negateMaskMark(mark);
322 int * ANb2BordersWhenClosed,
327 assert(ADart != NULL);
336 if (ANbDarts != NULL) * ANbDarts = nd;
337 if (ANbVertices != NULL) * ANbVertices = nc[0];
338 if (ANbEdges != NULL) * ANbEdges = nc[1];
339 if (ANbFaces != NULL) * ANbFaces = nc[2];
340 if (ANb0Borders != NULL) * ANb0Borders = nb[0];
341 if (ANb1Borders != NULL) * ANb1Borders = nb[1];
342 if (ANb2Borders != NULL) * ANb2Borders = nb[2];
344 bool needGenus = AGenus != NULL;
345 bool needOrient = AOrient != NULL || needGenus;
346 bool needEuler = AEuler != NULL || needOrient;
348 int euler = 0, orient = 0, genus = 0;
353 int memoAlpha3 = getNewDirectInfo();
359 for (; vol.
cont(); ++vol)
361 setDirectInfo(*vol, memoAlpha3, alpha3(*vol));
366 negateMaskMark(newDart);
376 negateMaskMark(newDart);
380 & nc[0], & nc[1], &nc[2], NULL, NULL, NULL);
383 if (ANbVertices != NULL) * ANbVertices = nc[0];
384 if (ANbEdges != NULL) * ANbEdges = nc[1];
385 if (ANbFaces != NULL) * ANbFaces = nc[2];
386 if (ANb0Borders != NULL) * ANb0Borders = nb[0];
387 if (ANb1Borders != NULL) * ANb1Borders = nb[1];
388 if (ANb2Borders != NULL) * ANb2Borders = nb[2];
390 if (ANb2BordersWhenClosed != NULL)
391 * ANb2BordersWhenClosed = nb[2];
394 euler = nc[0] - nc[1] + nc[2];
399 CDart * current = vol++;
401 if (isMarked(current, newDart))
403 alpha0(current)->setFree0();
404 alpha1(current)->setFree1();
405 alpha2(current)->setFree2();
416 freeDirectInfo(memoAlpha3);
429 : 2 - abs((euler + nb[2]) % 2);
437 assert((euler + nb[2] + orient) % 2 == 0);
439 genus = 1 - (euler + nb[2] + orient) / 2;
448 int nbd, nbv, nbe, nbf, nbvol, nbcc;
450 NULL, NULL, NULL, NULL);
451 AOs<<
"Nb of darts= "<<nbd<<
"; vertices= "<<nbv<<
"; edges="<<nbe
452 <<
"; faces="<<nbf<<
"; volumes="<<nbvol<<
"; cc="<<nbcc;
459 assert(0 <= AQ && AQ <= 2);
462 ostringstream result;
464 result <<
"S(" << AB2 <<
"," << AQ <<
"," << AG <<
")" <<
": ";
476 case 0 : result <<
"Sphere";
break;
477 case 1 : result <<
"Disk";
break;
478 case 2 : result <<
"Strip" ;
break;
479 default: result <<
"Sphere with " << AB2 <<
" borders";
488 result <<
" with " << AG <<
" tunnels";
491 result << (AG > 1 ?
" and" :
" with")
492 <<
" " << AB2 <<
" border" << (AB2 > 1 ?
"s" :
"");
500 result <<
"Projective plane";
502 result <<
"Möbius strip";
505 result <<
" with " << AG <<
" tunnel" << (AG > 1 ?
"s" :
"");
508 result << (AG > 0 ?
" and " :
" with ") << AB2 <<
" borders";
514 result <<
"Klein bottle";
517 result <<
" with " << AG <<
" tunnel" << (AG > 1 ?
"s" :
"");
520 result << (AG > 0 ?
" and " :
" with ")
521 << AB2 <<
" border" << (AB2 > 1 ?
"s" :
"");
534 int reached = getNewMark();
541 if (! isMarked(*it, reached))
545 negateMaskMark(reached);
557 for (
int dim=0; dim<=3; ++dim)
559 if (!isFree(*it, dim) && *it != alpha(alpha(*it,dim),dim))
561 cerr <<
"CGMapGeneric::integrity: The dart " << *it
562 <<
" does not satisfy the constraint "
563 <<
"alpha" << dim <<
"(alpha" << dim <<
"(brin)) == brin." << endl;
572 int alphaI [3] = { 0 , 0 , 1 };
573 int alphaJ [3] = { 2, 3, 3 };
575 int treated = getNewMark();
577 for (
int invoIndex=0; invoIndex<3 && ok; ++invoIndex)
579 TOrbit orbit = involutions[invoIndex];
580 int ai = alphaI[invoIndex];
581 int aj = alphaJ[invoIndex];
584 if (!isMarked(*it, treated))
586 if (isFree(*it, ai) || isFree(*it, aj))
587 setMark(*it, treated);
591 alpha( alpha(*it, ai) , aj) == alpha( alpha(*it, aj) , ai);
595 cerr <<
"CGMapGeneric::checkTopology: The involution "
596 << (invoIndex==0 ?
"02" : invoIndex==1 ?
"03" :
"13")
597 <<
" is not satisfied for dart " << *it
606 negateMaskMark(treated);
617 bool AEmbeddingMustExist)
619 assert(isOrbitUsed(AOrbit));
623 int treated = getNewMark();
626 if (!isMarked(*it, treated))
630 CCoverage * cov = getDynamicCoverage(*it, AOrbit);
632 for (; cov->
cont(); ++(*cov))
634 if ((**cov)->getAttribute(AOrbit, AAttributeIdentity) != NULL)
637 setMark(**cov, treated);
642 if (i>1 || (i==0 && AEmbeddingMustExist))
644 static const char * ORBIT_NAMES[16] =
646 "dart",
"0",
"1",
"01",
"2",
"02",
"12",
"volume",
"3",
"03",
"13",
"face",
647 "23",
"edge",
"vertex",
"connected component"
650 cerr <<
"CGMapGeneric::checkEmbeddings: The cell '"
651 << ORBIT_NAMES[AOrbit] <<
"' incident to dart " << *it <<
" ";
654 cerr <<
"has no embedding!" << endl;
656 cerr <<
" has " << i <<
" embeddings!" << endl;
662 negateMaskMark(treated);
671 assert(0<=ADimension && ADimension<=3);
673 CCoverage * cov = getDynamicCoverage(ADart, AOrbit);
677 for (; closed && cov->
cont(); (*cov)++)
678 closed = ! isFree(**cov, ADimension);
688 assert(0<=ADimension && ADimension<=3);
690 CCoverage * cov = getDynamicCoverage(ADart, AOrbit);
694 for (; free && cov->
cont(); (*cov)++)
695 free = isFree(**cov, ADimension);
708 for (i = res + 1; i < 4; ++i)
709 if ( !isFree(*it, i) )
712 if (res == 3)
return res;
721 CDart* precDangling = ADart;
724 while( alpha2(precDangling)==alpha3(precDangling) &&
728 assert( !isFree1(precDangling) && !isFree0(alpha1(precDangling)) );
729 assert( !isFree2(precDangling) && !isFree3(precDangling) );
730 precDangling=
alpha10(precDangling);
733 if ( alpha2(precDangling)==alpha3(precDangling) )
738 CDart* current = precDangling;
742 assert( !isFree0(current) && !isFree1(alpha0(current)) );
743 assert( !isFree2(current) && !isFree3(current) );
746 while( current!=precDangling && alpha2(current)!=alpha3(current) );
748 if ( current==precDangling )
755 assert( !isFree0(current) && !isFree1(alpha0(current)) );
756 assert( !isFree2(current) && !isFree3(current) );
759 while( alpha2(current)==alpha3(current) );
771 if ( isFree2(d1) || isFree1(alpha2(d1)) )
return false;
772 if ( alpha2(d1)==alpha3(d1) )
return false;
775 while ( d1!=current);
777 while( current!=precDangling);