diff --git a/Geo/CellComplex.cpp b/Geo/CellComplex.cpp index 3338006ed7ac58cfa35cf3255fa228502a2efd83..97dd976a421a49f6bc988f6d3f9ff293c7d9aa59 100644 --- a/Geo/CellComplex.cpp +++ b/Geo/CellComplex.cpp @@ -734,7 +734,8 @@ int CellComplex::cocombine(int dim){ CombinedCell* newCell = new CombinedCell(c1, c2, (or1 != or2), true ); removeCell(c1); removeCell(c2); - _cells[dim].insert(newCell); + std::pair<citer, bool> insertInfo = _cells[dim].insert(newCell); + if(!insertInfo.second) printf("Warning: Combined cell not inserted! \n"); cit = firstCell(dim); count++; @@ -752,7 +753,6 @@ int CellComplex::cocombine(int dim){ } int CellComplex::combine(int dim){ - double t1 = Cpu(); printf("Cell complex before combining: %d volumes, %d faces, %d edges and %d vertices.\n", getSize(3), getSize(2), getSize(1), getSize(0)); diff --git a/Geo/ChainComplex.cpp b/Geo/ChainComplex.cpp index 42ee1ee0d18d8afc2e958b70e43a18ce03fe119f..77e528b9cb559a66210552ca9baf7bb24ebf4115 100644 --- a/Geo/ChainComplex.cpp +++ b/Geo/ChainComplex.cpp @@ -484,28 +484,26 @@ Chain::Chain(std::set<Cell*, Less_Cell> cells, std::vector<int> coeffs, CellComp } bool Chain::deform(std::map<Cell*, int, Less_Cell> &cellsInChain, std::map<Cell*, int, Less_Cell> &cellsNotInChain){ - //printf("--- \n"); + std::vector<int> cc; std::vector<int> bc; for(citer cit = cellsInChain.begin(); cit != cellsInChain.end(); cit++){ Cell* c = (*cit).first; c->setImmune(false); - //c->printCell(); if(!c->inSubdomain()) { cc.push_back(getCoeff(c)); bc.push_back((*cit).second); } - removeCell(c); } - if(cc.empty()) return false; + + if(cc.empty() || (getDim() == 2 && cc.size() < 2) ) return false; int inout = cc[0]*bc[0]; for(int i = 0; i < cc.size(); i++){ - //printf("cc: %d, bc: %d \n", cc.at(i), bc.at(i)); - if(cc[i]*bc[i] != inout) printf("Error: Chain smoothening orientation mismatch! \n"); + if(cc[i]*bc[i] != inout) return false; } - //for(citer cit = cellsInChain.begin(); cit != cellsInChain.end(); cit++) removeCell((*cit).first); + for(citer cit = cellsInChain.begin(); cit != cellsInChain.end(); cit++) removeCell((*cit).first); int n = 1; for(citer cit = cellsNotInChain.begin(); cit != cellsNotInChain.end(); cit++){ @@ -514,10 +512,8 @@ bool Chain::deform(std::map<Cell*, int, Less_Cell> &cellsInChain, std::map<Cell* else c->setImmune(false); int coeff = -1*inout*(*cit).second; addCell(c, coeff); - //c->printCell(); n++; } - //printf("--- \n"); return true; } @@ -531,9 +527,8 @@ bool Chain::deformChain(std::pair<Cell*, int> cell, bool bend){ std::map<Cell*, int, Less_Cell> cellsInChain; std::map<Cell*, int, Less_Cell> cellsNotInChain; Cell* c1CbdCell = (*cit).first; - //c1CbdCell->printCell(); - //c1CbdCell->printOrgBd(); std::map<Cell*, int, Less_Cell> c1CbdBd = c1CbdCell->getOrgBd(); + for(citer cit2 = c1CbdBd.begin(); cit2 != c1CbdBd.end(); cit2++){ Cell* c1CbdBdCell = (*cit2).first; int coeff = (*cit2).second; @@ -558,8 +553,6 @@ bool Chain::deformChain(std::pair<Cell*, int> cell, bool bend){ if(next) continue; - if(getDim() != 2) bend = false; - //printf("dim: %d, in chain: %d, not in chain: %d \n", getDim(), cellsInChain.size(), cellsNotInChain.size()); if( (getDim() == 1 && cellsInChain.size() == 2 && cellsNotInChain.size() == 1) || @@ -583,7 +576,6 @@ bool Chain::deformChain(std::pair<Cell*, int> cell, bool bend){ } void Chain::smoothenChain(){ - if(!_cellComplex->simplicial()) return; int start = getSize(); @@ -593,8 +585,9 @@ void Chain::smoothenChain(){ for(int i = 0; i < 20; i++){ int size = getSize(); for(citer cit = _cells.begin(); cit != _cells.end(); cit++){ - deformChain(*cit, true); - deformChain(*cit, false); + //if(!deformChain(*cit, false) && getDim() == 2) deformChain(*cit, true); + if(getDim() == 2) deformChain(*cit, true); + deformChain(*cit, false); } deImmuneCells(); eraseNullCells();