From 45f0861824d6fedba8db1cdd6b6b1a5c8def399b Mon Sep 17 00:00:00 2001 From: Matti Pellika <matti.pellikka@tut.fi> Date: Sat, 9 Jan 2010 13:40:40 +0000 Subject: [PATCH] Fix cell combine. --- Geo/CellComplex.cpp | 9 ++++---- Geo/CellComplex.h | 4 +++- Geo/ChainComplex.cpp | 51 +++++--------------------------------------- 3 files changed, 13 insertions(+), 51 deletions(-) diff --git a/Geo/CellComplex.cpp b/Geo/CellComplex.cpp index 97dd976a42..7162aefca0 100644 --- a/Geo/CellComplex.cpp +++ b/Geo/CellComplex.cpp @@ -717,8 +717,8 @@ int CellComplex::cocombine(int dim){ it++; int or2 = (*it).second; Cell* c2 = (*it).first; - - if(!(*c1 == *c2) + + if(!(*c1 == *c2) && abs(or1) == abs(or2) && inSameDomain(s, c1) && inSameDomain(s, c2) && c1->getNumVertices() < getSize(dim) // heuristics for mammoth cell birth control && c2->getNumVertices() < getSize(dim)){ @@ -771,12 +771,13 @@ int CellComplex::combine(int dim){ bd_c = cell->getBoundary(); enqueueCells(bd_c, Q, Qset); while(Q.size() != 0){ - + Cell* s = Q.front(); Q.pop(); cbd_c = s->getOrientedCoboundary(); if(s->getCoboundarySize() == 2){ + std::map<Cell*, int, Less_Cell>::iterator it = cbd_c.begin(); int or1 = (*it).second; Cell* c1 = (*it).first; @@ -784,7 +785,7 @@ int CellComplex::combine(int dim){ int or2 = (*it).second; Cell* c2 = (*it).first; - if(!(*c1 == *c2) + if(!(*c1 == *c2) && abs(or1) == abs(or2) && inSameDomain(s, c1) && inSameDomain(s, c2) && c1->getNumVertices() < getSize(dim) // heuristics for mammoth cell birth control && c2->getNumVertices() < getSize(dim)){ diff --git a/Geo/CellComplex.h b/Geo/CellComplex.h index c5a901e6c7..92ac46b194 100644 --- a/Geo/CellComplex.h +++ b/Geo/CellComplex.h @@ -66,7 +66,9 @@ class Cell // for some algorithms to omit this cell bool _immune; - + + + // mutable list of cells on the boundary and on the coboundary of this cell std::map< Cell*, int, Less_Cell > _boundary; std::map< Cell*, int, Less_Cell > _coboundary; diff --git a/Geo/ChainComplex.cpp b/Geo/ChainComplex.cpp index 77e528b9cb..172fe594e7 100644 --- a/Geo/ChainComplex.cpp +++ b/Geo/ChainComplex.cpp @@ -88,67 +88,26 @@ ChainComplex::ChainComplex(CellComplex* cellComplex){ gmp_matrix_get_elem(elem, bdCell->getIndex(), cell->getIndex(), _HMatrix[dim]); old_elem = mpz_get_si(elem); mpz_set_si(elem, old_elem + (*it).second); - if( (old_elem + (*it).second) > 1 || (old_elem + (*it).second) < -1 ){ + /*if( (old_elem + (*it).second) > 1 || (old_elem + (*it).second) < -1 ){ printf("Warning: Invalid incidence index: %d! HMatrix: %d.", (old_elem + (*it).second), dim); printf(" Set to %d. \n", (old_elem + (*it).second) % 2); mpz_set_si(elem, (old_elem + (*it).second) % 2); - } + }*/ gmp_matrix_set_elem(elem, bdCell->getIndex(), cell->getIndex(), _HMatrix[dim]); } } } } - } - - mpz_clear(elem); - - } - - /* - else{ - - long int elems[rows*cols]; - - std::set<Cell*, Less_Cell>::iterator high = cellComplex->firstCell(dim); - std::set<Cell*, Less_Cell>::iterator low = cellComplex->firstCell(dim-1); - - unsigned int i = 0; - while(i < rows*cols){ - while(low != cellComplex->lastCell(dim-1)){ - Cell* lowcell = *low; - Cell* highcell = *high; - if(!(highcell->inSubdomain() || lowcell->inSubdomain())){ - - - std::list< std::pair<int, Cell*> >bdHigh = highcell->getBoundary(); - for(std::list< std::pair<int, Cell*> >::iterator it = bdHigh.begin(); it != bdHigh.end(); it++){ - Cell* bdCell = (*it).second; - if(bdCell->getTag() == lowcell->getTag()) elems[i] = (*it).first; - else elems[i] = 0; - } - - - elems[i] = cellComplex->kappa(*high, *low); - i++; - } - low++; - } - low = cellComplex->firstCell(dim-1); - high++; - } - _HMatrix[dim] = create_gmp_matrix_int(rows, cols, elems); + } + mpz_clear(elem); } - */ - _kerH[dim] = NULL; _codH[dim] = NULL; _JMatrix[dim] = NULL; _QMatrix[dim] = NULL; - _Hbasis[dim] = NULL; - + _Hbasis[dim] = NULL; } - return; } -- GitLab