Skip to content
Snippets Groups Projects
Commit 34c44677 authored by Matti Pellika's avatar Matti Pellika
Browse files

Still tinkering with cell combining.

parent 8e0a0dca
Branches
Tags
No related merge requests found
...@@ -509,7 +509,7 @@ void CellComplex::computeBettiNumbers(){ ...@@ -509,7 +509,7 @@ void CellComplex::computeBettiNumbers(){
void CellComplex::replaceCells(Cell* c1, Cell* c2, Cell* newCell, bool orMatch, bool co){ void CellComplex::replaceCells(Cell* c1, Cell* c2, Cell* newCell, bool orMatch, bool co){
int dim = c1->getDim(); int dim = c1->getDim();
/*
std::list< std::pair<int, Cell*> > coboundary1 = c1->getOrientedCoboundary(); std::list< std::pair<int, Cell*> > coboundary1 = c1->getOrientedCoboundary();
std::list< std::pair<int, Cell*> > coboundary2 = c2->getOrientedCoboundary(); std::list< std::pair<int, Cell*> > coboundary2 = c2->getOrientedCoboundary();
std::list< std::pair<int, Cell*> > boundary1 = c1->getOrientedBoundary(); std::list< std::pair<int, Cell*> > boundary1 = c1->getOrientedBoundary();
...@@ -538,7 +538,7 @@ void CellComplex::replaceCells(Cell* c1, Cell* c2, Cell* newCell, bool orMatch, ...@@ -538,7 +538,7 @@ void CellComplex::replaceCells(Cell* c1, Cell* c2, Cell* newCell, bool orMatch,
else cbdCell->addBoundaryCell(ori, newCell, true); else cbdCell->addBoundaryCell(ori, newCell, true);
} }
*/ */
/*
for(std::list< std::pair<int, Cell*> >::iterator it = coboundary2.begin(); it != coboundary2.end(); it++){ for(std::list< std::pair<int, Cell*> >::iterator it = coboundary2.begin(); it != coboundary2.end(); it++){
Cell* cbdCell = (*it).second; Cell* cbdCell = (*it).second;
int ori = (*it).first; int ori = (*it).first;
...@@ -579,7 +579,7 @@ void CellComplex::replaceCells(Cell* c1, Cell* c2, Cell* newCell, bool orMatch, ...@@ -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++){ for(std::list< std::pair<int, Cell* > >::iterator it = boundary2.begin(); it != boundary2.end(); it++){
Cell* bdCell = (*it).second; Cell* bdCell = (*it).second;
int ori = (*it).first; int ori = (*it).first;
...@@ -596,7 +596,7 @@ void CellComplex::replaceCells(Cell* c1, Cell* c2, Cell* newCell, bool orMatch, ...@@ -596,7 +596,7 @@ void CellComplex::replaceCells(Cell* c1, Cell* c2, Cell* newCell, bool orMatch,
else bdCell->addCoboundaryCell(ori, newCell, true); else bdCell->addCoboundaryCell(ori, newCell, true);
} }
*/
_cells[dim].erase(c1); _cells[dim].erase(c1);
_cells[dim].erase(c2); _cells[dim].erase(c2);
//removeCell(c1); //removeCell(c1);
...@@ -652,7 +652,10 @@ int CellComplex::cocombine(int dim){ ...@@ -652,7 +652,10 @@ int CellComplex::cocombine(int dim){
enqueueCells(cbd_c, Q, Qset); enqueueCells(cbd_c, Q, Qset);
CombinedCell* newCell = new CombinedCell(c1, c2, (or1 != or2), true ); 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); cit = firstCell(dim);
count++; count++;
...@@ -711,7 +714,10 @@ int CellComplex::combine(int dim){ ...@@ -711,7 +714,10 @@ int CellComplex::combine(int dim){
CombinedCell* newCell = new CombinedCell(c1, c2, (or1 != or2) ); 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); //removeCell(s);
cit = firstCell(dim); cit = firstCell(dim);
//cit++; //cit++;
......
...@@ -88,7 +88,6 @@ class Cell ...@@ -88,7 +88,6 @@ class Cell
for( std::list< std::pair<int, Cell*> >::iterator it= _boundary.begin();it!= _boundary.end();it++){ for( std::list< std::pair<int, Cell*> >::iterator it= _boundary.begin();it!= _boundary.end();it++){
Cell* cell = (*it).second; Cell* cell = (*it).second;
boundary.push_back(cell); boundary.push_back(cell);
if((*it).first == 0) boundary.push_back(cell);
} }
return boundary; return boundary;
} }
...@@ -98,7 +97,6 @@ class Cell ...@@ -98,7 +97,6 @@ class Cell
for( std::list< std::pair<int, Cell*> >::iterator it= _coboundary.begin();it!= _coboundary.end();it++){ for( std::list< std::pair<int, Cell*> >::iterator it= _coboundary.begin();it!= _coboundary.end();it++){
Cell* cell = (*it).second; Cell* cell = (*it).second;
coboundary.push_back(cell); coboundary.push_back(cell);
if((*it).first == 0) coboundary.push_back(cell);
} }
return coboundary; return coboundary;
} }
...@@ -483,10 +481,11 @@ class CombinedCell : public Cell{ ...@@ -483,10 +481,11 @@ class CombinedCell : public Cell{
_cells.push_back(*it); _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*> > c1Boundary = c1->getOrientedBoundary();
std::list< std::pair<int, Cell*> > c2Boundary = c2->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++){ for(std::list< std::pair<int, Cell*> >::iterator it = c1Boundary.begin(); it != c1Boundary.end(); it++){
Cell* cell = (*it).second; Cell* cell = (*it).second;
...@@ -502,21 +501,31 @@ class CombinedCell : public Cell{ ...@@ -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++){ 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; if(!orMatch) (*it).first = -1*(*it).first;
Cell* cell = (*it).second; Cell* cell = (*it).second;
int ori = (*it).first;
cell->removeCoboundaryCell(c2);
if(co){ if(co){
bool old = false; bool old = false;
for(std::list< std::pair<int, Cell* > >::iterator it2 = c1Boundary.begin(); it2 != c1Boundary.end(); it2++){ for(std::list< std::pair<int, Cell* > >::iterator it2 = c1Boundary.begin(); it2 != c1Boundary.end(); it2++){
Cell* cell2 = (*it2).second; Cell* cell2 = (*it2).second;
if(*cell2 == *cell) old = true; 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*> > c1Coboundary = c1->getOrientedCoboundary();
std::list< std::pair<int, Cell*> > c2Coboundary = c2->getOrientedCoboundary(); std::list< std::pair<int, Cell*> > c2Coboundary = c2->getOrientedCoboundary();
...@@ -536,18 +545,30 @@ class CombinedCell : public Cell{ ...@@ -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++){ 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; if(!orMatch) (*it).first = -1*(*it).first;
Cell* cell = (*it).second; Cell* cell = (*it).second;
int ori = (*it).first;
cell->removeBoundaryCell(c2);
if(!co){ if(!co){
bool old = false; bool old = false;
for(std::list< std::pair<int, Cell* > >::iterator it2 = c1Coboundary.begin(); it2 != c1Coboundary.end(); it2++){ for(std::list< std::pair<int, Cell* > >::iterator it2 = c1Coboundary.begin(); it2 != c1Coboundary.end(); it2++){
Cell* cell2 = (*it2).second; Cell* cell2 = (*it2).second;
if(*cell2 == *cell) old = true; 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); }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment