diff --git a/Geo/CellComplex.cpp b/Geo/CellComplex.cpp index f5f2c7b446aa365da1b8fd55de11cd0ba0d1bdcc..03031c0b017f46a935717c83626833004a0c069a 100644 --- a/Geo/CellComplex.cpp +++ b/Geo/CellComplex.cpp @@ -509,7 +509,7 @@ void CellComplex::computeBettiNumbers(){ void CellComplex::replaceCells(Cell* c1, Cell* c2, Cell* newCell, bool orMatch, bool co){ int dim = c1->getDim(); - + /* std::list< std::pair<int, Cell*> > coboundary1 = c1->getOrientedCoboundary(); std::list< std::pair<int, Cell*> > coboundary2 = c2->getOrientedCoboundary(); std::list< std::pair<int, Cell*> > boundary1 = c1->getOrientedBoundary(); @@ -538,7 +538,7 @@ void CellComplex::replaceCells(Cell* c1, Cell* c2, Cell* newCell, bool orMatch, else cbdCell->addBoundaryCell(ori, newCell, true); } */ - + /* for(std::list< std::pair<int, Cell*> >::iterator it = coboundary2.begin(); it != coboundary2.end(); it++){ Cell* cbdCell = (*it).second; int ori = (*it).first; @@ -579,7 +579,7 @@ void CellComplex::replaceCells(Cell* c1, Cell* c2, Cell* newCell, bool orMatch, } */ - + /* for(std::list< std::pair<int, Cell* > >::iterator it = boundary2.begin(); it != boundary2.end(); it++){ Cell* bdCell = (*it).second; int ori = (*it).first; @@ -596,7 +596,7 @@ void CellComplex::replaceCells(Cell* c1, Cell* c2, Cell* newCell, bool orMatch, else bdCell->addCoboundaryCell(ori, newCell, true); } - + */ _cells[dim].erase(c1); _cells[dim].erase(c2); //removeCell(c1); @@ -652,8 +652,11 @@ int CellComplex::cocombine(int dim){ enqueueCells(cbd_c, Q, Qset); CombinedCell* newCell = new CombinedCell(c1, c2, (or1 != or2), true ); - replaceCells(c1, c2, newCell, (or1 != or2), true); - + //replaceCells(c1, c2, newCell, (or1 != or2), true); + _cells[dim].erase(c1); + _cells[dim].erase(c2); + _cells[dim].insert(newCell); + cit = firstCell(dim); count++; } @@ -711,7 +714,10 @@ int CellComplex::combine(int dim){ CombinedCell* newCell = new CombinedCell(c1, c2, (or1 != or2) ); - replaceCells(c1, c2, newCell, (or1 != or2)); + _cells[dim].erase(c1); + _cells[dim].erase(c2); + _cells[dim].insert(newCell); + //replaceCells(c1, c2, newCell, (or1 != or2)); //removeCell(s); cit = firstCell(dim); //cit++; diff --git a/Geo/CellComplex.h b/Geo/CellComplex.h index 16f264c6a03fe3e717928d53352869551929c718..e387628f0b34e95b7335c6e72dbb89c638bd9dee 100644 --- a/Geo/CellComplex.h +++ b/Geo/CellComplex.h @@ -88,7 +88,6 @@ class Cell for( std::list< std::pair<int, Cell*> >::iterator it= _boundary.begin();it!= _boundary.end();it++){ Cell* cell = (*it).second; boundary.push_back(cell); - if((*it).first == 0) boundary.push_back(cell); } return boundary; } @@ -98,7 +97,6 @@ class Cell for( std::list< std::pair<int, Cell*> >::iterator it= _coboundary.begin();it!= _coboundary.end();it++){ Cell* cell = (*it).second; coboundary.push_back(cell); - if((*it).first == 0) coboundary.push_back(cell); } return coboundary; } @@ -483,10 +481,11 @@ class CombinedCell : public Cell{ _cells.push_back(*it); } - if(!co) _boundary = c1->getOrientedBoundary(); - + _boundary = c1->getOrientedBoundary(); std::list< std::pair<int, Cell*> > c1Boundary = c1->getOrientedBoundary(); std::list< std::pair<int, Cell*> > c2Boundary = c2->getOrientedBoundary(); + + /* for(std::list< std::pair<int, Cell*> >::iterator it = c1Boundary.begin(); it != c1Boundary.end(); it++){ Cell* cell = (*it).second; @@ -502,21 +501,31 @@ class CombinedCell : public Cell{ } */ + for(std::list< std::pair<int, Cell*> >::iterator it = c1Boundary.begin(); it != c1Boundary.end(); it++){ + Cell* cell = (*it).second; + int ori = (*it).first; + cell->removeCoboundaryCell(c1); + cell->addCoboundaryCell(ori, this, true); + } + for(std::list< std::pair<int, Cell*> >::iterator it = c2Boundary.begin(); it != c2Boundary.end(); it++){ + int ori2 = (*it).first; if(!orMatch) (*it).first = -1*(*it).first; Cell* cell = (*it).second; + int ori = (*it).first; + cell->removeCoboundaryCell(c2); if(co){ bool old = false; for(std::list< std::pair<int, Cell* > >::iterator it2 = c1Boundary.begin(); it2 != c1Boundary.end(); it2++){ Cell* cell2 = (*it2).second; if(*cell2 == *cell) old = true; } - if(!old) _boundary.push_back(*it); + if(!old){ _boundary.push_back(*it); cell->addCoboundaryCell(ori, this, true); } } - else _boundary.push_back(*it); + else { _boundary.push_back(*it); cell->addCoboundaryCell(ori, this, true); } } - if(co) _coboundary = c1->getOrientedCoboundary(); + _coboundary = c1->getOrientedCoboundary(); std::list< std::pair<int, Cell*> > c1Coboundary = c1->getOrientedCoboundary(); std::list< std::pair<int, Cell*> > c2Coboundary = c2->getOrientedCoboundary(); @@ -536,18 +545,30 @@ class CombinedCell : public Cell{ } */ + for(std::list< std::pair<int, Cell*> >::iterator it = c1Coboundary.begin(); it != c1Coboundary.end(); it++){ + Cell* cell = (*it).second; + int ori = (*it).first; + cell->removeBoundaryCell(c1); + cell->addBoundaryCell(ori, this,true); + } + + for(std::list< std::pair<int, Cell* > >::iterator it = c2Coboundary.begin(); it != c2Coboundary.end(); it++){ + int ori2 = (*it).first; if(!orMatch) (*it).first = -1*(*it).first; Cell* cell = (*it).second; + int ori = (*it).first; + cell->removeBoundaryCell(c2); if(!co){ bool old = false; for(std::list< std::pair<int, Cell* > >::iterator it2 = c1Coboundary.begin(); it2 != c1Coboundary.end(); it2++){ Cell* cell2 = (*it2).second; if(*cell2 == *cell) old = true; } - if(!old) _coboundary.push_back(*it); + if(!old) { _coboundary.push_back(*it); cell->addBoundaryCell(ori, this, true); } + } - else _coboundary.push_back(*it); + else { _coboundary.push_back(*it); cell->addBoundaryCell(ori, this, true); } } }