25 #include "g-map-vertex.hh"
29 using namespace GMap3d;
42 FShowH2torsion(false),
58 unsigned long res = 0;
59 if ( FMatrix[0]!=NULL ) res += FMatrix[0]->
size() + FCells[0].size();
60 if ( FMatrix[1]!=NULL ) res += FMatrix[1]->
size() + FCells[1].size();
61 if ( FMatrix[2]!=NULL ) res += FMatrix[2]->
size() + FCells[2].size();
66 CDart* ADart2,
int AIndex)
68 assert((0 <= ADim) && (ADim < 3));
81 int incidenceNumber=0;
83 int m2oriented = FMap->getNewMark();
86 FMap->setMark(ADart2,m2oriented);
87 FMap->setMark(ADart2->getAlpha(0),m2oriented);
91 FMap->halfMarkOrbit(ADart2, ORBIT_INF[ADim+1], m2oriented);
94 int treated = FMap->getNewMark();
96 CCoverage * cov = FMap->getDynamicCoverage(ADart, ORBIT_CELL[ADim]);
97 for (; cov->cont(); ++(*cov))
99 if ( !FMap->isMarked(**cov,treated) && FMap->isMarked(**cov,m2oriented) )
101 if ( (ADim>0 && (
long int)FMap->getDirectInfo(**cov,AIndex)>0) ||
102 (ADim==0 && **cov==ADart2) )
113 FMap-> markOrbit(**cov,ORBIT_INF[ADim],treated);
117 for (cov->reinit(); cov->cont(); ++(*cov))
119 if ( FMap->isMarked(**cov,treated) )
121 FMap->unmarkOrbit(**cov,ORBIT_INF[ADim],treated);
128 FMap->unsetMark(ADart2,m2oriented);
129 FMap->unsetMark(ADart2->getAlpha(0),m2oriented);
133 FMap->halfUnmarkOrbit(ADart2, ORBIT_INF[ADim+1], m2oriented);
136 assert(FMap->isWholeMapUnmarked(treated));
137 assert(FMap->isWholeMapUnmarked(m2oriented));
140 FMap->freeMark(treated);
141 FMap->freeMark(m2oriented);
143 return incidenceNumber;
148 assert( 0<=ADim && ADim<3 );
150 long int currentcell = 1;
153 int treated = FMap->getNewMark();
154 int positive = FMap->getNewMark();
155 int index = FMap->getNewDirectInfo();
158 long int currentcell2 = 1;
159 if ( AComputeNextCells ) treated2 = FMap->getNewMark();
162 CDynamicCoverageAll it(FMap);
163 for (; it.cont(); ++it)
165 if (!FMap->isMarked(*it, treated))
167 if ( ADim==1 ) FMap->markOrbit(*it,ORBIT_23,positive);
169 { FMap->halfMarkOrbit(*it,ORBIT_01,positive); }
171 FCells[ADim][currentcell-1]=*it;
175 CCoverage* it2 = FMap->getDynamicCoverage(*it,ORBIT_CELL[ADim]);
176 for(;it2->cont();++(*it2))
178 if ( ADim==1 && !FMap->isMarked(**it2,positive) )
179 number = -currentcell;
180 else if (ADim==2 && !FMap->isMarked(**it2,positive) &&
181 !FMap->isMarked((**it2)->getAlpha(3),positive))
182 number = -currentcell;
184 number = currentcell;
188 FMap->setDirectInfo(**it2,index,(
void*)number);
189 FMap->setMark(**it2, treated);
192 if ( ADim==1 ) FMap->unmarkOrbit(*it,ORBIT_23,positive);
194 { FMap->halfUnmarkOrbit(*it,ORBIT_01,positive); }
199 if ( treated2!=-1 && !FMap->isMarked(*it, treated2) )
201 FCells[ADim+1][currentcell2-1]=*it;
202 FMap->markOrbit(*it, ORBIT_CELL[ADim+1],treated2);
207 FMap->negateMaskMark(treated);
210 FMap->negateMaskMark(treated2);
211 FMap->freeMark(treated2);
217 for ( it.reinit(); it.cont(); ++it )
219 if ( !FMap->isMarked(*it, treated) )
221 CCoverage* it2 = FMap->getDynamicCoverage(*it,ORBIT_CELL[ADim+1]);
222 for( ;it2->cont();++(*it2) )
224 int i = (
long int)FMap->getDirectInfo(**it2, index);
227 if ( i<0 ) icorrected = -i;
230 if ( FMatrix[ADim]->getValPMQ( icorrected, currentcell)==0 )
241 FMatrix[ADim]->
setValPMQ( icorrected, currentcell, val);
244 FMap->setMark(**it2, treated);
252 FMap->negateMaskMark(treated);
254 assert(FMap->isWholeMapUnmarked(treated));
256 FMap->freeMark(treated);
257 FMap->freeDirectInfo(index);
262 FMap->countCells(-1,&FNbVertices,&FNbEdges,&FNbFaces,NULL,NULL,NULL);
264 delete FMatrix[0]; FMatrix[0] =
new MatricePMQ(FNbVertices, FNbEdges);
265 delete FMatrix[1]; FMatrix[1] =
new MatricePMQ(FNbEdges, FNbFaces);
266 delete FMatrix[2]; FMatrix[2] = NULL;
268 FCells[0].clear(); FCells[0].reserve(FNbVertices);
269 FCells[1].clear(); FCells[1].reserve(FNbEdges);
270 FCells[2].clear(); FCells[2].reserve(FNbFaces);
272 if (FCells[0].capacity()<FNbVertices ||
273 FCells[1].capacity()<FNbEdges ||
274 FCells[2].capacity()<FNbFaces ||
275 !FMatrix[0]->valid() ||
276 !FMatrix[1]->valid())
278 FCells[0].clear(); FCells[1].clear(); FCells[2].clear();
279 delete FMatrix[0];
delete FMatrix[1];
280 FMatrix[0]=NULL; FMatrix[1]=NULL;
299 FNbBordFaibleDim0 = FMatrix[0]->
getM()->
getnbcol()-FNbCycleDim1;
300 FNbBordFaibleDim1 = FMatrix[1]->
getM()->
getnbcol()-FNbCycleDim2;
301 FNbBordFaibleDim2 = 0;
303 FNbGenLibreDim0 = FNbCycleDim0 - FNbBordFaibleDim0;
304 FNbGenLibreDim1 = FNbCycleDim1 - FNbBordFaibleDim1;
305 FNbGenLibreDim2 = FNbCycleDim2;
309 FNbGenTorsionDim2 = 0;
318 FMap->countCells(-1,&FNbVertices,&FNbEdges,&FNbFaces,&FNbVolumes,NULL,NULL);
320 delete FMatrix[0]; FMatrix[0] =
new MatricePMQ(FNbVertices, FNbEdges);
321 delete FMatrix[1]; FMatrix[1] =
new MatricePMQ(FNbEdges, FNbFaces);
322 delete FMatrix[2]; FMatrix[2] =
new MatricePMQ(FNbFaces, FNbVolumes);
324 FCells[0].clear(); FCells[0].reserve(FNbVertices);
325 FCells[1].clear(); FCells[1].reserve(FNbEdges);
326 FCells[2].clear(); FCells[2].reserve(FNbFaces);
328 if (FCells[0].capacity()<FNbVertices ||
329 FCells[1].capacity()<FNbEdges ||
330 FCells[2].capacity()<FNbFaces ||
331 !FMatrix[0]->valid() ||
332 !FMatrix[1]->valid() ||
333 !FMatrix[2]->valid())
335 FCells[0].clear(); FCells[1].clear(); FCells[2].clear();
336 delete FMatrix[0];
delete FMatrix[1];
delete FMatrix[2];
337 FMatrix[0]=NULL; FMatrix[1]=NULL; FMatrix[2]=NULL;
374 FNbBordFaibleDim0 = FMatrix[0]->
getM()->
getnbcol()-FNbCycleDim1;
375 FNbBordFaibleDim1 = FMatrix[1]->
getM()->
getnbcol()-FNbCycleDim2;
376 FNbBordFaibleDim2 = FMatrix[2]->
getM()->
getnbcol()-FNbCycleDim3;
378 FNbGenLibreDim0 = FNbCycleDim0 - FNbBordFaibleDim0;
379 FNbGenLibreDim1 = FNbCycleDim1 - FNbBordFaibleDim1;
380 FNbGenLibreDim2 = FNbCycleDim2 - FNbBordFaibleDim2;
381 FNbGenLibreDim3 = FNbCycleDim3;
393 {
return FNbGenLibreDim0; }
396 {
return FNbGenLibreDim1; }
399 {
return FNbGenTorsionDim1; }
402 {
return FNbGenLibreDim2; }
405 {
return FNbGenTorsionDim2; }
408 {
return FNbGenLibreDim3; }
413 {
return FShowH1free; }
415 {
return FShowH1torsion; }
417 {
return FShowH2free; }
419 {
return FShowH2torsion; }
425 if ( AValue!=FShowH0 )
434 if ( AValue!=FShowH1free )
443 if ( AValue!=FShowH1torsion )
445 FShowH1torsion=AValue;
452 if ( AValue!=FShowH2free )
461 if ( AValue!=FShowH2torsion )
463 FShowH2torsion=AValue;
470 if ( AValue!=FShowH3 )
479 if ( FMatrix[0]==NULL || FMark==-1 )
return;
482 for (CDynamicCoverageAll it(FMap); it.cont(); ++it)
483 FMap->unsetMark(*it,FMark);
489 for (
int j=FNbBordFaibleDim0;j<FNbBordFaibleDim0+FNbGenLibreDim0;++j)
493 if (FMatrix[0]->getP()->getVal(i,j)!=0)
496 FMap->markOrbit(FCells[0][i],ORBIT_VERTEX,FMark);
509 for (
int j=FNbBordFaibleDim1;j<FNbBordFaibleDim1+FNbGenLibreDim1;++j)
513 if(FMatrix[1]->getP()->getVal(i,j)!=0)
516 FMap->markOrbit(FCells[1][i],ORBIT_EDGE,FMark);
524 if ( FShowH1torsion )
527 for (
int j=0;j<FNbGenTorsionDim1;j++){
530 if(FMatrix[1]->getP()->getVal(i,j)!=0)
533 FMap->markOrbit(FCells[1][i],ORBIT_EDGE,FMark);
543 if ( FMatrix[2]!=NULL )
546 for (
int j=FNbBordFaibleDim2;j<FNbBordFaibleDim2+FNbGenLibreDim2;++j)
550 if(FMatrix[2]->getP()->getVal(i,j)!=0)
553 FMap->markOrbit(FCells[2][i],ORBIT_FACE,FMark);
563 for (
int j=0;j<FNbCycleDim2;++j)
567 if(FMatrix[1]->getQ()->getVal(i,j)!=0)
570 FMap->markOrbit(FCells[2][i],ORBIT_FACE,FMark);
577 if ( FShowH2torsion && FMatrix[2]!=NULL )
580 for (
int j=0;j<FNbGenTorsionDim2;++j )
584 if(FMatrix[2]->getP()->getVal(i,j)!=0)
587 FMap->markOrbit(FCells[2][i],ORBIT_FACE,FMark);