diff --git a/Geo/CGNSRead.cpp b/Geo/CGNSRead.cpp index 26c9dc9072b1d59ca5855459a096640b28cb4f92..12e3034d1a29b904f275735b4bb0722920ec7b66 100644 --- a/Geo/CGNSRead.cpp +++ b/Geo/CGNSRead.cpp @@ -284,7 +284,7 @@ void setPeriodicityInEntities(const std::vector<CGNSZone *> &allZones) // skip if another connnection with the same slave entity already // exists, or if the inverse connection already exists if(entCon.find(sEnt) != entCon.end()) continue; - EntConnect::iterator itInv = entCon.find(mEnt); + auto itInv = entCon.find(mEnt); if((itInv != entCon.end()) && (itInv->second == sEnt)) continue; // store connection and transformation and update corresponding vertices @@ -296,7 +296,7 @@ void setPeriodicityInEntities(const std::vector<CGNSZone *> &allZones) } // set mesh master and transformation between entities - for(EntConnect::iterator it = entCon.begin(); it != entCon.end(); ++it) { + for(auto it = entCon.begin(); it != entCon.end(); ++it) { GEntity *sEnt = it->first, *mEnt = it->second; sEnt->setMeshMaster(mEnt, *(entTfo[sEnt])); } @@ -379,7 +379,7 @@ void setGeomAndPhysicalEntities(GModel *model, int meshDim, // associate physical tags to geometrical entity and store physical names std::pair<Geom2PhysIter, Geom2PhysIter> range = geomName2Phys.equal_range(geomName); - for(Geom2PhysIter it = range.first; it != range.second; ++it) { + for(auto it = range.first; it != range.second; ++it) { const int physTag = it->second; std::vector<int> &entPhys = ent[iEnt]->physicals; if(std::find(entPhys.begin(), entPhys.end(), physTag) == diff --git a/Geo/CGNSWrite.cpp b/Geo/CGNSWrite.cpp index c1ad5029d44c1af5e5efaec9dc135767dd68ed54..a6eec7b7b85e32bff99a5ea432198359c2b6b8a3 100644 --- a/Geo/CGNSWrite.cpp +++ b/Geo/CGNSWrite.cpp @@ -170,17 +170,16 @@ void initInterfVertex2LocalData(const std::vector<GEntity *> &entitiesPer, // Periodic entities for(std::size_t i = 0; i < entitiesPer.size(); i++) { VertVertMap &vv = entitiesPer[i]->correspondingVertices; - for(VertVertMap::iterator itV = vv.begin(); itV != vv.end(); itV++) { + for(auto itV = vv.begin(); itV != vv.end(); itV++) { interfVert2Local[itV->first] = std::vector<LocalData>(); interfVert2Local[itV->second] = std::vector<LocalData>(); } } // Partition interface boundaries - typedef std::set<MVertex *>::iterator NodeSetIter; std::set<MVertex *> nodeSet; getNodesInEntities<false>(entitiesInterf, true, nodeSet); - for(NodeSetIter itN = nodeSet.begin(); itN != nodeSet.end(); ++itN) { + for(auto itN = nodeSet.begin(); itN != nodeSet.end(); ++itN) { interfVert2Local[*itN] = std::vector<LocalData>(); } } @@ -194,7 +193,6 @@ int writeZone(GModel *model, bool saveAll, double scalingFactor, int meshDim, Vertex2LocalData &interfVert2Local, std::set<int> &eleMshTypes, std::map<GEntity *, std::string> &geomEntities) { - typedef std::set<MVertex *>::iterator NodeSetIter; #ifdef HAVE_LIBCGNS_CPEX0045 const bool useCPEX0045 = CTX::instance()->mesh.cgnsExportCPEX0045; #else @@ -210,20 +208,20 @@ int writeZone(GModel *model, bool saveAll, double scalingFactor, int meshDim, // store local data correspondence for periodic/interface nodes std::vector<LocalData> global2Local(numNodesTotal + 1); cgsize_t numNodes = 0; - for(NodeSetIter itN = nodeSet.begin(); itN != nodeSet.end(); ++itN) { + for(auto itN = nodeSet.begin(); itN != nodeSet.end(); ++itN) { const long gInd = (*itN)->getIndex(); if(gInd < 0) continue; numNodes++; LocalData &ld = global2Local[gInd]; ld.partition = partition; ld.index = numNodes; - Vertex2LocalData::iterator itPN = interfVert2Local.find(*itN); + auto itPN = interfVert2Local.find(*itN); if(itPN != interfVert2Local.end()) itPN->second.push_back(ld); } // create lists of coordinates std::vector<double> xcoord(numNodes), ycoord(numNodes), zcoord(numNodes); - for(NodeSetIter itN = nodeSet.begin(); itN != nodeSet.end(); ++itN) { + for(auto itN = nodeSet.begin(); itN != nodeSet.end(); ++itN) { const long gInd = (*itN)->getIndex(); if(gInd < 0) continue; const int ln = global2Local[gInd].index; @@ -393,7 +391,7 @@ int writePeriodic(const std::vector<GEntity *> &entitiesPer, int cgIndexFile, GEntity *slaveEnt = entitiesPer[iEnt]; GEntity *masterEnt = slaveEnt->getMeshMaster(); VertVertMap &vv = slaveEnt->correspondingVertices; - for(VertVertMap::iterator itV = vv.begin(); itV != vv.end(); itV++) { + for(auto itV = vv.begin(); itV != vv.end(); itV++) { const std::vector<LocalData> &allSlaveData = interfVert2Local[itV->first]; const std::vector<LocalData> &allMasterData = interfVert2Local[itV->second]; @@ -421,9 +419,8 @@ int writePeriodic(const std::vector<GEntity *> &entitiesPer, int cgIndexFile, } // write periodic interfaces - typedef PeriodicConnection::iterator PerConnectIter; int cgnsErr; - for(PerConnectIter it = connect.begin(); it != connect.end(); ++it) { + for(auto it = connect.begin(); it != connect.end(); ++it) { printProgress("Writing periodic interface", std::distance(connect.begin(), it) + 1, connect.size()); const PeriodicInterface &perInt = it->first; @@ -533,7 +530,6 @@ int writeInterfaces(const std::vector<GEntity *> &entitiesInterf, typedef std::map<PartitionInterface, NodeCorrespondence> PartitionConnection; // get nodes in partition interface entities - typedef std::set<MVertex *>::iterator NodeSetIter; std::set<MVertex *> nodeSet; getNodesInEntities<false>(entitiesInterf, true, nodeSet); @@ -541,7 +537,7 @@ int writeInterfaces(const std::vector<GEntity *> &entitiesInterf, Msg::Info("Constructing connectivities for %i partition interface entities", entitiesInterf.size()); PartitionConnection connect; - for(NodeSetIter itN = nodeSet.begin(); itN != nodeSet.end(); ++itN) { + for(auto itN = nodeSet.begin(); itN != nodeSet.end(); ++itN) { const std::vector<LocalData> &allLocalData = interfVert2Local[*itN]; for(std::size_t iLD1 = 0; iLD1 < allLocalData.size(); iLD1++) { const LocalData &localData1 = allLocalData[iLD1]; @@ -558,10 +554,9 @@ int writeInterfaces(const std::vector<GEntity *> &entitiesInterf, } // write partition interfaces - typedef PartitionConnection::iterator PartConnectIter; int cgnsErr; std::size_t iPartConnect = 0; - for(PartConnectIter it = connect.begin(); it != connect.end(); ++it) { + for(auto it = connect.begin(); it != connect.end(); ++it) { iPartConnect++; printProgress("Writing partition interface", iPartConnect, connect.size()); const std::pair<unsigned int, unsigned int> &partInt = it->first; @@ -599,8 +594,7 @@ int writeHOPointInfo(const std::set<int> &eleMshTypes, int cgIndexFile, if(cgnsErr != CG_OK) return cgnsError(__FILE__, __LINE__, cgIndexFile); // write node sets for each element type - typedef std::set<int>::iterator IntSetIter; - for(IntSetIter it = eleMshTypes.begin(); it != eleMshTypes.end(); ++it) { + for(auto it = eleMshTypes.begin(); it != eleMshTypes.end(); ++it) { // get node set const int mshType = *it; const nodalBasis *basis = BasisFactory::getNodalBasis(mshType); @@ -640,8 +634,7 @@ int writeGeomEntities(std::map<GEntity *, std::string> &geomEntities, { int cgnsErr; - typedef std::map<GEntity *, std::string>::iterator GeomEntIter; - for(GeomEntIter it = geomEntities.begin(); it != geomEntities.end(); ++it) { + for(auto it = geomEntities.begin(); it != geomEntities.end(); ++it) { // get geometric entity GEntity *ge = it->first; std::string &geomName = it->second; diff --git a/Geo/CGNSWriteStruct.cpp b/Geo/CGNSWriteStruct.cpp index e36192bbe8e2bbe0d3cd9fe38670549ff84a7391..211da5af0eea4465c1b8b22c0a320cbf10f3e0a9 100644 --- a/Geo/CGNSWriteStruct.cpp +++ b/Geo/CGNSWriteStruct.cpp @@ -501,7 +501,7 @@ int writeZonesStruct(GModel *model, double scalingFactor, int cgIndexFile, int meshDim = -1; std::vector<GFace *> faces; - for(GModel::fiter it = model->firstFace(); it != model->lastFace(); ++it) { + for(auto it = model->firstFace(); it != model->lastFace(); ++it) { if(isTransfinite(*it)) { meshDim = 2; faces.push_back(*it); @@ -509,8 +509,7 @@ int writeZonesStruct(GModel *model, double scalingFactor, int cgIndexFile, } std::vector<GRegion *> regions; - for(GModel::riter it = model->firstRegion(); it != model->lastRegion(); - ++it) { + for(auto it = model->firstRegion(); it != model->lastRegion(); ++it) { if(isTransfinite(*it)) { meshDim = 3; regions.push_back(*it); diff --git a/Geo/CGNSZone.cpp b/Geo/CGNSZone.cpp index ecb2dba2639b2855f7c1e32220a3222af2d88463..8aab0fa025b0fe65d288a273cca9ce3544329698 100644 --- a/Geo/CGNSZone.cpp +++ b/Geo/CGNSZone.cpp @@ -39,8 +39,7 @@ CGNSZone::CGNSZone(int fileIndex, int baseIndex, int zoneIndex, cgnsErr = cg_famname_read(famName); if(cgnsErr != CG_NODE_NOT_FOUND) { if(cgnsErr == CG_OK) { - Family2EltNodeTransfo::const_iterator it = - allEltNodeTransfo.find(std::string(famName)); + auto it = allEltNodeTransfo.find(std::string(famName)); if(it != allEltNodeTransfo.end()) eltNodeTransfo_ = &(it->second); } else diff --git a/Geo/CGNSZoneStruct.cpp b/Geo/CGNSZoneStruct.cpp index de8ac02d1f46c34b6ccd4ebb1486541decbe78fd..15d6aeafd4c54c85f7e5b2ef70b3b2ce9c9b532d 100644 --- a/Geo/CGNSZoneStruct.cpp +++ b/Geo/CGNSZoneStruct.cpp @@ -481,10 +481,8 @@ MElement *CGNSZoneStruct<DIM>::makeBndElement( std::vector<MVertex *> &allVert, std::map<int, std::vector<MElement *> > *allElt) { - typedef std::map<cgsize_t, int>::const_iterator Elt2GeomIter; - cgsize_t iElt = ijk2Ind<DIM>(ijk, nbNodeIJK()); - const Elt2GeomIter it = elt2Geom().find(iElt); + const auto it = elt2Geom().find(iElt); const int entity = (it == elt2Geom().end()) ? defaultEntity : it->second; return createBndElement<DIM>(ijk, nbNodeIJK(), dir, order, entity, diff --git a/Geo/Cell.cpp b/Geo/Cell.cpp index 8150a7fb93e7c1aa0e4f5d8f0a2343ec755d818a..83fde015649e923cd72e97e81775758d4d1b4fa8 100644 --- a/Geo/Cell.cpp +++ b/Geo/Cell.cpp @@ -498,8 +498,7 @@ bool Cell::hasVertex(int vertex) const bool CombinedCell::hasVertex(int vertex) const { - for(std::map<Cell *, int, CellPtrLessThan>::const_iterator cit = _cells.begin(); - cit != _cells.end(); cit++) { + for(auto cit = _cells.begin(); cit != _cells.end(); cit++) { if(cit->first->hasVertex(vertex)) return true; } return false; @@ -518,10 +517,10 @@ void Cell::printCell() void Cell::saveCellBoundary() { - for(biter it = firstCoboundary(); it != lastCoboundary(); it++) { + for(auto it = firstCoboundary(); it != lastCoboundary(); it++) { it->second.init(); } - for(biter it = firstBoundary(); it != lastBoundary(); it++) { + for(auto it = firstBoundary(); it != lastBoundary(); it++) { it->second.init(); } } @@ -529,13 +528,13 @@ void Cell::saveCellBoundary() void Cell::restoreCellBoundary() { std::vector<Cell *> toRemove; - for(biter it = firstCoboundary(true); it != lastCoboundary(); it++) { + for(auto it = firstCoboundary(true); it != lastCoboundary(); it++) { it->second.reset(); if(it->second.get() == 0) toRemove.push_back(it->first); } for(std::size_t i = 0; i < toRemove.size(); i++) _cbd.erase(toRemove[i]); toRemove.clear(); - for(biter it = firstBoundary(true); it != lastBoundary(); it++) { + for(auto it = firstBoundary(true); it != lastBoundary(); it++) { it->second.reset(); if(it->second.get() == 0) toRemove.push_back(it->first); } @@ -544,15 +543,13 @@ void Cell::restoreCellBoundary() void Cell::addBoundaryCell(int orientation, Cell *cell, bool other) { - biter it = _bd.find(cell); + auto it = _bd.find(cell); if(it != _bd.end()) { int newOrientation = it->second.get() + orientation; it->second.set(newOrientation); if(newOrientation == 0) { it->first->removeCoboundaryCell(this, false); - if(it->second.geto() == 0) { - _bd.erase(it); - } + if(it->second.geto() == 0) { _bd.erase(it); } return; } } @@ -563,15 +560,13 @@ void Cell::addBoundaryCell(int orientation, Cell *cell, bool other) void Cell::addCoboundaryCell(int orientation, Cell *cell, bool other) { - biter it = _cbd.find(cell); + auto it = _cbd.find(cell); if(it != _cbd.end()) { int newOrientation = it->second.get() + orientation; it->second.set(newOrientation); if(newOrientation == 0) { it->first->removeBoundaryCell(this, false); - if(it->second.geto() == 0) { - _cbd.erase(it); - } + if(it->second.geto() == 0) { _cbd.erase(it); } return; } } @@ -582,7 +577,7 @@ void Cell::addCoboundaryCell(int orientation, Cell *cell, bool other) void Cell::removeBoundaryCell(Cell *cell, bool other) { - biter it = _bd.find(cell); + auto it = _bd.find(cell); if(it != _bd.end()) { it->second.set(0); if(other) it->first->removeCoboundaryCell(this, false); @@ -592,7 +587,7 @@ void Cell::removeBoundaryCell(Cell *cell, bool other) void Cell::removeCoboundaryCell(Cell *cell, bool other) { - biter it = _cbd.find(cell); + auto it = _cbd.find(cell); if(it != _cbd.end()) { it->second.set(0); if(other) it->first->removeBoundaryCell(this, false); @@ -603,12 +598,12 @@ void Cell::removeCoboundaryCell(Cell *cell, bool other) bool Cell::hasBoundary(Cell *cell, bool orig) { if(!orig) { - biter it = _bd.find(cell); + auto it = _bd.find(cell); if(it != _bd.end() && it->second.get() != 0) return true; return false; } else { - biter it = _bd.find(cell); + auto it = _bd.find(cell); if(it != _bd.end() && it->second.geto() != 0) return true; return false; } @@ -617,12 +612,12 @@ bool Cell::hasBoundary(Cell *cell, bool orig) bool Cell::hasCoboundary(Cell *cell, bool orig) { if(!orig) { - biter it = _cbd.find(cell); + auto it = _cbd.find(cell); if(it != _cbd.end() && it->second.get() != 0) return true; return false; } else { - biter it = _cbd.find(cell); + auto it = _cbd.find(cell); if(it != _cbd.end() && it->second.geto() != 0) return true; return false; } @@ -630,7 +625,7 @@ bool Cell::hasCoboundary(Cell *cell, bool orig) Cell::biter Cell::firstBoundary(bool orig) { - biter it = _bd.begin(); + auto it = _bd.begin(); if(!orig) while(it->second.get() == 0 && it != _bd.end()) it++; else @@ -642,7 +637,7 @@ Cell::biter Cell::lastBoundary() { return _bd.end(); } Cell::biter Cell::firstCoboundary(bool orig) { - biter it = _cbd.begin(); + auto it = _cbd.begin(); if(!orig) while(it->second.get() == 0 && it != _cbd.end()) it++; else @@ -655,7 +650,7 @@ Cell::biter Cell::lastCoboundary() { return _cbd.end(); } int Cell::getBoundarySize(bool orig) { int size = 0; - for(biter bit = _bd.begin(); bit != _bd.end(); bit++) { + for(auto bit = _bd.begin(); bit != _bd.end(); bit++) { if(!orig && bit->second.get() != 0) size++; else if(orig && bit->second.geto() != 0) @@ -667,7 +662,7 @@ int Cell::getBoundarySize(bool orig) int Cell::getCoboundarySize(bool orig) { int size = 0; - for(biter bit = _cbd.begin(); bit != _cbd.end(); bit++) { + for(auto bit = _cbd.begin(); bit != _cbd.end(); bit++) { if(!orig && bit->second.get() != 0) size++; else if(orig && bit->second.geto() != 0) @@ -680,18 +675,18 @@ void Cell::getBoundary(std::map<Cell *, short int, CellPtrLessThan> &boundary, bool orig) { boundary.clear(); - for(biter it = firstBoundary(); it != lastBoundary(); it++) { + for(auto it = firstBoundary(); it != lastBoundary(); it++) { Cell *cell = it->first; if(!orig && it->second.get() != 0) boundary[cell] = it->second.get(); if(orig && it->second.geto() != 0) boundary[cell] = it->second.geto(); } } -void Cell::getCoboundary(std::map<Cell *, short int, CellPtrLessThan> &coboundary, - bool orig) +void Cell::getCoboundary( + std::map<Cell *, short int, CellPtrLessThan> &coboundary, bool orig) { coboundary.clear(); - for(biter it = firstCoboundary(); it != lastCoboundary(); it++) { + for(auto it = firstCoboundary(); it != lastCoboundary(); it++) { Cell *cell = it->first; if(!orig && it->second.get() != 0) coboundary[cell] = it->second.get(); if(orig && it->second.geto() != 0) coboundary[cell] = it->second.geto(); @@ -700,7 +695,7 @@ void Cell::getCoboundary(std::map<Cell *, short int, CellPtrLessThan> &coboundar void Cell::printBoundary() { - for(biter it = firstBoundary(); it != lastBoundary(); it++) { + for(auto it = firstBoundary(); it != lastBoundary(); it++) { printf("Boundary cell orientation: %d ", it->second.get()); Cell *cell2 = it->first; cell2->printCell(); @@ -712,7 +707,7 @@ void Cell::printBoundary() void Cell::printCoboundary() { - for(biter it = firstCoboundary(); it != lastCoboundary(); it++) { + for(auto it = firstCoboundary(); it != lastCoboundary(); it++) { printf("Coboundary cell orientation: %d, ", it->second.get()); Cell *cell2 = it->first; cell2->printCell(); @@ -740,41 +735,39 @@ CombinedCell::CombinedCell(Cell *c1, Cell *c2, bool orMatch, bool co) c1->getCells(_cells); std::map<Cell *, int, CellPtrLessThan> c2Cells; c2->getCells(c2Cells); - for(citer cit = c2Cells.begin(); cit != c2Cells.end(); cit++) { + for(auto cit = c2Cells.begin(); cit != c2Cells.end(); cit++) { if(!orMatch) (*cit).second = -1 * (*cit).second; _cells.insert(*cit); } // boundary cells - for(biter it = c1->firstBoundary(); it != c1->lastBoundary(); it++) { + for(auto it = c1->firstBoundary(); it != c1->lastBoundary(); it++) { Cell *cell = it->first; int ori = it->second.get(); if(ori == 0) continue; cell->removeCoboundaryCell(c1, false); this->addBoundaryCell(ori, cell, true); } - for(biter it = c2->firstBoundary(); it != c2->lastBoundary(); it++) { + for(auto it = c2->firstBoundary(); it != c2->lastBoundary(); it++) { Cell *cell = it->first; if(!orMatch) it->second.set(-1 * it->second.get()); int ori = it->second.get(); if(ori == 0) continue; cell->removeCoboundaryCell(c2, false); - if(co && !c1->hasBoundary(cell)) { - this->addBoundaryCell(ori, cell, true); - } + if(co && !c1->hasBoundary(cell)) { this->addBoundaryCell(ori, cell, true); } else if(!co) this->addBoundaryCell(ori, cell, true); } // coboundary cells - for(biter it = c1->firstCoboundary(); it != c1->lastCoboundary(); it++) { + for(auto it = c1->firstCoboundary(); it != c1->lastCoboundary(); it++) { Cell *cell = it->first; int ori = it->second.get(); if(ori == 0) continue; cell->removeBoundaryCell(c1, false); this->addCoboundaryCell(ori, cell, true); } - for(biter it = c2->firstCoboundary(); it != c2->lastCoboundary(); it++) { + for(auto it = c2->firstCoboundary(); it != c2->lastCoboundary(); it++) { Cell *cell = it->first; if(!orMatch) it->second.set(-1 * it->second.get()); int ori = it->second.get(); diff --git a/Geo/Cell.h b/Geo/Cell.h index 2b533b22e5770639e8aaebe6d60b397fe9a73e76..e00bf0caa52864ba47b6ecaddc9da5fc92869599 100644 --- a/Geo/Cell.h +++ b/Geo/Cell.h @@ -172,7 +172,10 @@ public: ~CombinedCell() {} int getDim() const { return _cells.begin()->first->getDim(); } - void getCells(std::map<Cell *, int, CellPtrLessThan> &cells) { cells = _cells; } + void getCells(std::map<Cell *, int, CellPtrLessThan> &cells) + { + cells = _cells; + } int getNumCells() const { return _cells.size(); } bool hasVertex(int vertex) const; diff --git a/Geo/CellComplex.cpp b/Geo/CellComplex.cpp index c01174f06326b9211e66b51c20910c6b9dacb890..7a8e1d6cc258348814ba2cd2e8dca0c939636171 100644 --- a/Geo/CellComplex.cpp +++ b/Geo/CellComplex.cpp @@ -39,7 +39,7 @@ CellComplex::CellComplex(GModel *model, std::vector<MElement *> &domainElements, for(int dim = 0; dim < 4; dim++) { if(getSize(dim) != 0) _dim = dim; if(_saveorig) _ocells[dim] = _cells[dim]; - for(citer cit = firstCell(dim); cit != lastCell(dim); cit++) { + for(auto cit = firstCell(dim); cit != lastCell(dim); cit++) { Cell *cell = *cit; cell->setNum(++num); cell->increaseGlobalNum(); @@ -123,7 +123,7 @@ bool CellComplex::_insertCells(std::vector<MElement *> &elements, int domain) Msg::Info(" - Creating subdomain %d-cells", dim); } - for(citer cit = firstCell(dim); cit != lastCell(dim); cit++) { + for(auto cit = firstCell(dim); cit != lastCell(dim); cit++) { Cell *cell = *cit; for(int i = 0; i < cell->getNumBdElements(); i++) { std::pair<Cell *, bool> maybeCell = Cell::createCell(cell, i); @@ -173,7 +173,7 @@ bool CellComplex::_removeCells(std::vector<MElement *> &elements, int domain) } Cell *cell = new Cell(element, domain); int dim = cell->getDim(); - citer cit = _cells[dim].find(cell); + auto cit = _cells[dim].find(cell); if(cit != lastCell(dim)) { removeCell(*cit); removed[dim].insert(cell); @@ -183,12 +183,12 @@ bool CellComplex::_removeCells(std::vector<MElement *> &elements, int domain) } for(int dim = 3; dim > 0; dim--) { - for(citer cit = removed[dim].begin(); cit != removed[dim].end(); cit++) { + for(auto cit = removed[dim].begin(); cit != removed[dim].end(); cit++) { Cell *cell = *cit; for(int i = 0; i < cell->getNumBdElements(); i++) { Cell *newCell = new Cell(cell, i); - citer cit2 = _cells[dim - 1].find(newCell); + auto cit2 = _cells[dim - 1].find(newCell); if(cit2 != lastCell(dim - 1)) { removeCell(*cit2); removed[dim - 1].insert(newCell); @@ -199,7 +199,7 @@ bool CellComplex::_removeCells(std::vector<MElement *> &elements, int domain) } } for(int dim = 3; dim >= 0; dim--) { - for(citer cit = removed[dim].begin(); cit != removed[dim].end(); cit++) { + for(auto cit = removed[dim].begin(); cit != removed[dim].end(); cit++) { delete *cit; } } @@ -216,7 +216,7 @@ bool CellComplex::_immunizeCells(std::vector<MElement *> &elements) MElement *element = elements.at(i); Cell *cell = new Cell(element, 0); int dim = cell->getDim(); - citer cit = _cells[dim].find(cell); + auto cit = _cells[dim].find(cell); if(cit != lastCell(dim)) (*cit)->setImmune(true); delete cell; } @@ -226,7 +226,7 @@ bool CellComplex::_immunizeCells(std::vector<MElement *> &elements) CellComplex::~CellComplex() { for(int i = 0; i < 4; i++) { - for(citer cit = _cells[i].begin(); cit != _cells[i].end(); cit++) { + for(auto cit = _cells[i].begin(); cit != _cells[i].end(); cit++) { Cell *cell = *cit; delete cell; _deleteCount++; @@ -260,14 +260,12 @@ void CellComplex::removeCell(Cell *cell, bool other, bool del) std::map<Cell *, short int, CellPtrLessThan> boundary; cell->getBoundary(boundary); - for(std::map<Cell *, short int, CellPtrLessThan>::iterator it = coboundary.begin(); - it != coboundary.end(); it++) { + for(auto it = coboundary.begin(); it != coboundary.end(); it++) { Cell *cbdCell = (*it).first; cbdCell->removeBoundaryCell(cell, other); } - for(std::map<Cell *, short int, CellPtrLessThan>::iterator it = boundary.begin(); - it != boundary.end(); it++) { + for(auto it = boundary.begin(); it != boundary.end(); it++) { Cell *bdCell = (*it).first; bdCell->removeCoboundaryCell(cell, other); } @@ -286,14 +284,13 @@ void CellComplex::removeCell(Cell *cell, bool other, bool del) _removedcells.push_back(cell); } -void CellComplex::enqueueCells(std::map<Cell *, short int, CellPtrLessThan> &cells, - std::queue<Cell *> &Q, - std::set<Cell *, CellPtrLessThan> &Qset) +void CellComplex::enqueueCells( + std::map<Cell *, short int, CellPtrLessThan> &cells, std::queue<Cell *> &Q, + std::set<Cell *, CellPtrLessThan> &Qset) { - for(std::map<Cell *, short int, CellPtrLessThan>::iterator cit = cells.begin(); - cit != cells.end(); cit++) { + for(auto cit = cells.begin(); cit != cells.end(); cit++) { Cell *cell = (*cit).first; - citer it = Qset.find(cell); + auto it = Qset.find(cell); if(it == Qset.end()) { Qset.insert(cell); Q.push(cell); @@ -355,7 +352,7 @@ int CellComplex::reduction(int dim, int omit, std::vector<Cell *> &omittedCells) bool reduced = true; while(reduced) { reduced = false; - citer cit = firstCell(dim - 1); + auto cit = firstCell(dim - 1); while(cit != lastCell(dim - 1)) { Cell *cell = *cit; if(cell->getCoboundarySize() == 1 && @@ -397,7 +394,7 @@ int CellComplex::coreduction(int dim, int omit, bool reduced = true; while(reduced) { reduced = false; - citer cit = firstCell(dim); + auto cit = firstCell(dim); while(cit != lastCell(dim)) { Cell *cell = *cit; if(cell->getBoundarySize() == 1 && @@ -511,7 +508,7 @@ int CellComplex::reduceComplex(int combine, bool omit, bool homseq) std::vector<Cell *> newCells; while(getSize(getDim()) != 0) { - citer cit = firstCell(getDim()); + auto cit = firstCell(getDim()); Cell *cell = *cit; newCells.push_back(_omitCell(cell, false)); @@ -557,7 +554,7 @@ void CellComplex::removeSubdomain() { std::vector<Cell *> toRemove; for(int i = 0; i < 4; i++) { - for(citer cit = firstCell(i); cit != lastCell(i); ++cit) { + for(auto cit = firstCell(i); cit != lastCell(i); ++cit) { Cell *cell = *cit; if(cell->inSubdomain()) toRemove.push_back(cell); } @@ -570,7 +567,7 @@ void CellComplex::removeCells(int dim) { if(dim < 0 || dim > 3) return; std::vector<Cell *> toRemove; - for(citer cit = firstCell(dim); cit != lastCell(dim); ++cit) { + for(auto cit = firstCell(dim); cit != lastCell(dim); ++cit) { toRemove.push_back(*cit); } for(std::size_t i = 0; i < toRemove.size(); i++) removeCell(toRemove[i]); @@ -587,7 +584,7 @@ int CellComplex::coreduceComplex(int combine, bool omit, int heuristic) if(relative()) removeSubdomain(); std::vector<Cell *> empty; for(int dim = 0; dim < 4; dim++) { - citer cit = firstCell(dim); + auto cit = firstCell(dim); while(cit != lastCell(dim)) { Cell *cell = *cit; int count = +coreduction(cell, -1, empty); @@ -601,7 +598,7 @@ int CellComplex::coreduceComplex(int combine, bool omit, int heuristic) if(omit) { std::vector<Cell *> newCells; while(getSize(0) != 0) { - citer cit = firstCell(0); + auto cit = firstCell(0); Cell *cell = *cit; if(heuristic == -1 && _smallestCell.second != 0. && @@ -678,7 +675,7 @@ int CellComplex::combine(int dim) std::map<Cell *, short int, CellPtrLessThan> bd_c; int count = 0; - for(citer cit = firstCell(dim); cit != lastCell(dim); cit++) { + for(auto cit = firstCell(dim); cit != lastCell(dim); cit++) { double t2 = Cpu(); if(t2 - t1 > CellComplex::_patience) { t1 = Cpu(); @@ -695,7 +692,7 @@ int CellComplex::combine(int dim) Q.pop(); if(s->getCoboundarySize() == 2 && !s->getImmune()) { - Cell::biter it = s->firstCoboundary(); + auto it = s->firstCoboundary(); int or1 = it->second.get(); Cell *c1 = it->first; it++; @@ -756,7 +753,7 @@ int CellComplex::cocombine(int dim) std::map<Cell *, short int, CellPtrLessThan> cbd_c; int count = 0; - for(citer cit = firstCell(dim); cit != lastCell(dim); cit++) { + for(auto cit = firstCell(dim); cit != lastCell(dim); cit++) { double t2 = Cpu(); if(t2 - t1 > CellComplex::_patience) { t1 = Cpu(); @@ -773,7 +770,7 @@ int CellComplex::cocombine(int dim) Cell *s = Q.front(); Q.pop(); if(s->getBoundarySize() == 2) { - Cell::biter it = s->firstBoundary(); + auto it = s->firstBoundary(); int or1 = it->second.get(); Cell *c1 = it->first; it++; @@ -824,16 +821,14 @@ bool CellComplex::coherent() { bool coherent = true; for(int i = 0; i < 4; i++) { - for(citer cit = firstCell(i); cit != lastCell(i); cit++) { + for(auto cit = firstCell(i); cit != lastCell(i); cit++) { Cell *cell = *cit; std::map<Cell *, short int, CellPtrLessThan> boundary; cell->getBoundary(boundary); - for(std::map<Cell *, short int, CellPtrLessThan>::iterator it = - boundary.begin(); - it != boundary.end(); it++) { + for(auto it = boundary.begin(); it != boundary.end(); it++) { Cell *bdCell = (*it).first; int ori = (*it).second; - citer cit = _cells[bdCell->getDim()].find(bdCell); + auto cit = _cells[bdCell->getDim()].find(bdCell); if(cit == lastCell(bdCell->getDim())) { Msg::Debug("Boundary cell not in cell complex! Boundary removed"); cell->removeBoundaryCell(bdCell, false); @@ -847,12 +842,10 @@ bool CellComplex::coherent() } std::map<Cell *, short int, CellPtrLessThan> coboundary; cell->getCoboundary(coboundary); - for(std::map<Cell *, short int, CellPtrLessThan>::iterator it = - coboundary.begin(); - it != coboundary.end(); it++) { + for(auto it = coboundary.begin(); it != coboundary.end(); it++) { Cell *cbdCell = (*it).first; int ori = (*it).second; - citer cit = _cells[cbdCell->getDim()].find(cbdCell); + auto cit = _cells[cbdCell->getDim()].find(cbdCell); if(cit == lastCell(cbdCell->getDim())) { Msg::Debug("Coboundary cell not in cell complex! Coboundary removed"); cell->removeCoboundaryCell(cbdCell, false); @@ -886,7 +879,7 @@ void CellComplex::getCells(std::set<Cell *, CellPtrLessThan> &cells, int dim, int domain) { cells.clear(); - for(citer cit = firstCell(dim); cit != lastCell(dim); cit++) { + for(auto cit = firstCell(dim); cit != lastCell(dim); cit++) { Cell *cell = *cit; if((domain == 0 && !cell->inSubdomain()) || domain == 1 || (domain == 2 && cell->inSubdomain())) { @@ -921,7 +914,7 @@ Cell *CellComplex::getACell(int dim, int domain) return NULL; } - for(citer cit = firstCell(dim); cit != lastCell(dim); cit++) { + for(auto cit = firstCell(dim); cit != lastCell(dim); cit++) { Cell *cell = *cit; if((domain == 1) || (domain == 0 && !cell->inSubdomain()) || (domain == 2 && cell->inSubdomain())) @@ -944,7 +937,7 @@ bool CellComplex::restoreComplex() _removedcells.clear(); for(int i = 0; i < 4; i++) { - for(citer cit = _cells[i].begin(); cit != _cells[i].end(); cit++) { + for(auto cit = _cells[i].begin(); cit != _cells[i].end(); cit++) { Cell *cell = *cit; if(cell->isCombined()) { delete cell; @@ -953,7 +946,7 @@ bool CellComplex::restoreComplex() } _cells[i] = _ocells[i]; - for(citer cit = firstCell(i); cit != lastCell(i); cit++) { + for(auto cit = firstCell(i); cit != lastCell(i); cit++) { Cell *cell = *cit; cell->restoreCellBoundary(); if(relative()) { @@ -980,7 +973,7 @@ bool CellComplex::restoreComplex() void CellComplex::printComplex(int dim) { if(getSize(dim) == 0) Msg::Info("Cell complex dimension %d is empty", dim); - for(citer cit = firstCell(dim); cit != lastCell(dim); cit++) { + for(auto cit = firstCell(dim); cit != lastCell(dim); cit++) { Cell *cell = *cit; cell->printCell(); cell->printBoundary(); diff --git a/Geo/CellComplex.h b/Geo/CellComplex.h index 0fc758369b52ddcd6376e1d64d28aa848d8606d6..ac42da3716a7cf6f4fe002737d7d611f3b48e36a 100644 --- a/Geo/CellComplex.h +++ b/Geo/CellComplex.h @@ -69,7 +69,8 @@ private: // enqueue cells in queue if they are not there already void enqueueCells(std::map<Cell *, short int, CellPtrLessThan> &cells, - std::queue<Cell *> &Q, std::set<Cell *, CellPtrLessThan> &Qset); + std::queue<Cell *> &Q, + std::set<Cell *, CellPtrLessThan> &Qset); // insert/remove a cell from this cell complex void removeCell(Cell *cell, bool other = true, bool del = false); @@ -108,10 +109,12 @@ public: // domain = 0: cells in domain relative to subdomain // domain = 1: cells in domain // domain = 2: cells in subdomain - void getCells(std::set<Cell *, CellPtrLessThan> &cells, int dim, int domain = 0); + void getCells(std::set<Cell *, CellPtrLessThan> &cells, int dim, + int domain = 0); int getNumCells(int dim, int domain = 0); Cell *getACell(int dim, int domain = 0); - // std::set<Cell*, CellPtrLessThan> getOrigCells(int dim){ return _ocells[dim]; } + // std::set<Cell*, CellPtrLessThan> getOrigCells(int dim){ return + // _ocells[dim]; } // iterator for the cells of same dimension typedef std::set<Cell *, CellPtrLessThan>::iterator citer; diff --git a/Geo/ChainComplex.cpp b/Geo/ChainComplex.cpp index 37d80fd01ad5db3cad9ea32a0839fd88c9625087..bde99ed532df5ed1e8f1e0f0db1430862771ddb0 100644 --- a/Geo/ChainComplex.cpp +++ b/Geo/ChainComplex.cpp @@ -31,7 +31,7 @@ ChainComplex::ChainComplex(CellComplex *cellComplex, int domain) int index = 1; // ignore cells depending on domain - for(CellComplex::citer cit = cellComplex->firstCell(dim); + for(auto cit = cellComplex->firstCell(dim); cit != cellComplex->lastCell(dim); cit++) { Cell *cell = *cit; cols--; @@ -58,14 +58,13 @@ ChainComplex::ChainComplex(CellComplex *cellComplex, int domain) mpz_t elem; mpz_init(elem); _hMatrix[dim] = create_gmp_matrix_zero(rows, cols); - for(std::set<Cell *, CellPtrLessThan>::iterator cit = - cellComplex->firstCell(dim); + for(auto cit = cellComplex->firstCell(dim); cit != cellComplex->lastCell(dim); cit++) { Cell *cell = *cit; if((domain == 0 && !cell->inSubdomain()) || domain == 1 || (domain == 2 && cell->inSubdomain())) { - for(Cell::biter it = cell->firstBoundary(); - it != cell->lastBoundary(); it++) { + for(auto it = cell->firstBoundary(); it != cell->lastBoundary(); + it++) { Cell *bdCell = it->first; if(it->second.get() == 0) continue; if((domain == 0 && !bdCell->inSubdomain()) || domain == 1 || @@ -457,9 +456,7 @@ void ChainComplex::getBasisChain(std::map<Cell *, int, CellPtrLessThan> &chain, chain.clear(); if(dim < 0 || dim > 3) return; - if(basisMatrix == NULL || (int)gmp_matrix_cols(basisMatrix) < num) { - return; - } + if(basisMatrix == NULL || (int)gmp_matrix_cols(basisMatrix) < num) { return; } int elemi; long int elemli; @@ -469,7 +466,7 @@ void ChainComplex::getBasisChain(std::map<Cell *, int, CellPtrLessThan> &chain, int torsion = 1; if(basis == 3) torsion = getTorsion(dim, num); - for(citer cit = this->firstCell(dim); cit != this->lastCell(dim); cit++) { + for(auto cit = this->firstCell(dim); cit != this->lastCell(dim); cit++) { Cell *cell = cit->first; int index = cit->second; gmp_matrix_get_elem(elem, index, num, basisMatrix); @@ -478,7 +475,7 @@ void ChainComplex::getBasisChain(std::map<Cell *, int, CellPtrLessThan> &chain, if(elemli != 0) { std::map<Cell *, int, CellPtrLessThan> subCells; cell->getCells(subCells); - for(Cell::citer it = subCells.begin(); it != subCells.end(); it++) { + for(auto it = subCells.begin(); it != subCells.end(); it++) { Cell *subCell = it->first; int coeff = it->second * elemi * torsion; if(coeff == 0) continue; @@ -522,19 +519,20 @@ int ChainComplex::getTorsion(int dim, int num) return _torsion[dim].at(num - 1); } -bool ChainComplex::deform(std::map<Cell *, int, CellPtrLessThan> &cells, - std::map<Cell *, int, CellPtrLessThan> &cellsInChain, - std::map<Cell *, int, CellPtrLessThan> &cellsNotInChain) +bool ChainComplex::deform( + std::map<Cell *, int, CellPtrLessThan> &cells, + std::map<Cell *, int, CellPtrLessThan> &cellsInChain, + std::map<Cell *, int, CellPtrLessThan> &cellsNotInChain) { std::vector<int> cc; std::vector<int> bc; - for(citer cit = cellsInChain.begin(); cit != cellsInChain.end(); cit++) { + for(auto cit = cellsInChain.begin(); cit != cellsInChain.end(); cit++) { Cell *c = (*cit).first; c->setImmune(false); if(!c->inSubdomain()) { int coeff = 0; - citer it = cells.find(c); + auto it = cells.find(c); if(it != cells.end()) coeff = it->second; cc.push_back(coeff); bc.push_back((*cit).second); @@ -547,15 +545,14 @@ bool ChainComplex::deform(std::map<Cell *, int, CellPtrLessThan> &cells, if(cc[i] * bc[i] != inout) return false; } - for(citer cit = cellsInChain.begin(); cit != cellsInChain.end(); cit++) { + for(auto cit = cellsInChain.begin(); cit != cellsInChain.end(); cit++) { Cell *cell = cit->first; - citer it = cells.find(cell); + auto it = cells.find(cell); if(it != cells.end()) cells[cell] = 0; } int n = 1; - for(citer cit = cellsNotInChain.begin(); cit != cellsNotInChain.end(); - cit++) { + for(auto cit = cellsNotInChain.begin(); cit != cellsNotInChain.end(); cit++) { Cell *cell = (*cit).first; if(n == 2) cell->setImmune(true); @@ -580,13 +577,13 @@ bool ChainComplex::deformChain(std::map<Cell *, int, CellPtrLessThan> &cells, { Cell *c1 = cell.first; int dim = c1->getDim(); - for(Cell::biter cit = c1->firstCoboundary(true); cit != c1->lastCoboundary(); + for(auto cit = c1->firstCoboundary(true); cit != c1->lastCoboundary(); cit++) { std::map<Cell *, int, CellPtrLessThan> cellsInChain; std::map<Cell *, int, CellPtrLessThan> cellsNotInChain; Cell *c1CbdCell = cit->first; - for(Cell::biter cit2 = c1CbdCell->firstBoundary(true); + for(auto cit2 = c1CbdCell->firstBoundary(true); cit2 != c1CbdCell->lastBoundary(); cit2++) { Cell *c1CbdBdCell = cit2->first; int coeff = cit2->second.geto(); @@ -601,17 +598,17 @@ bool ChainComplex::deformChain(std::map<Cell *, int, CellPtrLessThan> &cells, bool next = false; - for(citer cit2 = cellsInChain.begin(); cit2 != cellsInChain.end(); cit2++) { + for(auto cit2 = cellsInChain.begin(); cit2 != cellsInChain.end(); cit2++) { Cell *c = (*cit2).first; int coeff = 0; - citer it = cells.find(c); + auto it = cells.find(c); if(it != cells.end()) coeff = it->second; if(c->getImmune()) next = true; if(c->inSubdomain()) bend = false; if(coeff > 1 || coeff < -1) next = true; } - for(citer cit2 = cellsNotInChain.begin(); cit2 != cellsNotInChain.end(); + for(auto cit2 = cellsNotInChain.begin(); cit2 != cellsNotInChain.end(); cit2++) { Cell *c = (*cit2).first; if(c->inSubdomain()) next = true; @@ -651,7 +648,7 @@ void ChainComplex::smoothenChain(std::map<Cell *, int, CellPtrLessThan> &cells) int useless = 0; for(int i = 0; i < 20; i++) { int size = cells.size(); - for(citer cit = cells.begin(); cit != cells.end(); cit++) { + for(auto cit = cells.begin(); cit != cells.end(); cit++) { if(dim == 2) deformChain(cells, *cit, true); deformChain(cells, *cit, false); } @@ -667,7 +664,7 @@ void ChainComplex::smoothenChain(std::map<Cell *, int, CellPtrLessThan> &cells) } deImmuneCells(cells); - for(citer cit = cells.begin(); cit != cells.end(); cit++) { + for(auto cit = cells.begin(); cit != cells.end(); cit++) { deformChain(cells, *cit, false); } eraseNullCells(cells); @@ -679,7 +676,7 @@ void ChainComplex::smoothenChain(std::map<Cell *, int, CellPtrLessThan> &cells) void ChainComplex::eraseNullCells(std::map<Cell *, int, CellPtrLessThan> &cells) { std::vector<Cell *> toRemove; - for(citer cit = cells.begin(); cit != cells.end(); cit++) { + for(auto cit = cells.begin(); cit != cells.end(); cit++) { if(cit->second == 0) toRemove.push_back(cit->first); } for(std::size_t i = 0; i < toRemove.size(); i++) cells.erase(toRemove[i]); @@ -687,7 +684,7 @@ void ChainComplex::eraseNullCells(std::map<Cell *, int, CellPtrLessThan> &cells) void ChainComplex::deImmuneCells(std::map<Cell *, int, CellPtrLessThan> &cells) { - for(citer cit = cells.begin(); cit != cells.end(); cit++) { + for(auto cit = cells.begin(); cit != cells.end(); cit++) { Cell *cell = (*cit).first; cell->setImmune(false); } diff --git a/Geo/ChainComplex.h b/Geo/ChainComplex.h index fcf2c7f420ede1f379ea434e9c5a6b19dd2df28e..082949f0778fec4441366d03dbf3dc3f5a833146 100644 --- a/Geo/ChainComplex.h +++ b/Geo/ChainComplex.h @@ -202,8 +202,8 @@ public: // (deform: with local deformations to make chain smoother and to have // smaller support, deformed chain is homologous to the old one, // only works for chains of the primary chain complex) - void getBasisChain(std::map<Cell *, int, CellPtrLessThan> &chain, int num, int dim, - int basis, bool deform = false); + void getBasisChain(std::map<Cell *, int, CellPtrLessThan> &chain, int num, + int dim, int basis, bool deform = false); // get rank of a basis int getBasisSize(int dim, int basis); // homology torsion coefficient for dim-dimensional chain num diff --git a/Geo/ExtrudeParams.cpp b/Geo/ExtrudeParams.cpp index 9560c9ebdbf0b41edd30f9c3afd8215487ade636..89b8d3d5302390cfe72888bcf370bbdce40af09d 100644 --- a/Geo/ExtrudeParams.cpp +++ b/Geo/ExtrudeParams.cpp @@ -75,7 +75,6 @@ void ExtrudeParams::Extrude(int iLayer, int iElemLayer, double &x, double &y, Extrude(t, x, y, z); } - void ExtrudeParams::Extrude(double t, double &x, double &y, double &z) { double dx, dy, dz, angle; @@ -145,8 +144,7 @@ void ExtrudeParams::GetAffineTransform(std::vector<double> &tfo) SetTranslationMatrix(m1, geo.trans); tfo.resize(16); for(int i = 0; i < 4; i++) - for(int j = 0; j < 4; j++) - tfo[i * 4 + j] = m1[i][j]; + for(int j = 0; j < 4; j++) tfo[i * 4 + j] = m1[i][j]; break; case ROTATE: case TRANSLATE_ROTATE: @@ -155,28 +153,23 @@ void ExtrudeParams::GetAffineTransform(std::vector<double> &tfo) v[2] = -geo.pt[2]; SetTranslationMatrix(m1, v); SetRotationMatrix(m2, geo.axe, geo.angle); - for(int i = 0; i < 4; i++){ - for(int j = 0; j < 4; j++){ + for(int i = 0; i < 4; i++) { + for(int j = 0; j < 4; j++) { m3[i][j] = 0; - for(int k = 0; k < 4; k++){ - m3[i][j] += m1[i][k] * m2[k][j]; - } + for(int k = 0; k < 4; k++) { m3[i][j] += m1[i][k] * m2[k][j]; } } } SetTranslationMatrix(m1, geo.pt); - for(int i = 0; i < 4; i++){ - for(int j = 0; j < 4; j++){ + for(int i = 0; i < 4; i++) { + for(int j = 0; j < 4; j++) { m2[i][j] = 0; - for(int k = 0; k < 4; k++){ - m2[i][j] += m3[i][k] * m1[k][j]; - } + for(int k = 0; k < 4; k++) { m2[i][j] += m3[i][k] * m1[k][j]; } } } tfo.resize(16); for(int i = 0; i < 4; i++) - for(int j = 0; j < 4; j++) - tfo[i * 4 + j] = m2[i][j]; - if(geo.Type == TRANSLATE_ROTATE){ + for(int j = 0; j < 4; j++) tfo[i * 4 + j] = m2[i][j]; + if(geo.Type == TRANSLATE_ROTATE) { tfo[3] += geo.trans[0]; tfo[7] += geo.trans[1]; tfo[11] += geo.trans[2]; diff --git a/Geo/GEdge.h b/Geo/GEdge.h index 7e7205b6daa0fa31a2c1c7a8f5fb4e5af37d7cba..1a4d76aec77fd0cb0da194b255cd157209829788 100644 --- a/Geo/GEdge.h +++ b/Geo/GEdge.h @@ -163,14 +163,12 @@ public: double length(const double &u0, const double &u1, const int nbQuadPoints = 4); // get the prescribed mesh size on the edge - double prescribedMeshSizeAtVertex() const - { - return meshAttributes.meshSize; - } + double prescribedMeshSizeAtVertex() const { return meshAttributes.meshSize; } double prescribedMeshSizeAtParam(double u); - void setMeshSizeParametric(const std::vector<double> u, const std::vector<double> lc); + void setMeshSizeParametric(const std::vector<double> u, + const std::vector<double> lc); // true if start == end and no more than 2 segments void setTooSmall(bool const b) { _tooSmall = b; } @@ -262,7 +260,8 @@ public: SPoint3 closestPointWithTol(SPoint3 &p, double tolerance); virtual void mesh(bool verbose); - virtual bool reorder(const int elementType, const std::vector<std::size_t> &ordering); + virtual bool reorder(const int elementType, + const std::vector<std::size_t> &ordering); }; #endif diff --git a/Geo/GEdgeLoop.cpp b/Geo/GEdgeLoop.cpp index 21be6518d34aa7b20d302744ab415f8d6f4ffa08..04dd91d0f5d6c6311e7ebcc5e7a17fb92d71ff15 100644 --- a/Geo/GEdgeLoop.cpp +++ b/Geo/GEdgeLoop.cpp @@ -14,8 +14,7 @@ void GEdgeSigned::print() const Msg::Info("Curve %d sign %d, begin point %d, end point %d", ge->tag(), _sign, getBeginVertex()->tag(), getEndVertex()->tag()); else - Msg::Info("Curve %d sign %d, no begin or end points", ge->tag(), - _sign); + Msg::Info("Curve %d sign %d, no begin or end points", ge->tag(), _sign); } int countInList(std::list<GEdge *> &wire, GEdge *ge) @@ -35,8 +34,8 @@ GEdgeSigned nextOne(GEdgeSigned *thisOne, std::list<GEdge *> &wire) std::list<GEdge *> possibleChoices; - std::list<GEdge *>::iterator it = wire.begin(); - std::list<GEdge *>::iterator ite = wire.end(); + auto it = wire.begin(); + auto ite = wire.end(); while(it != ite) { GEdge *ge = *it; GVertex *v1 = ge->getBeginVertex(); @@ -87,7 +86,7 @@ GEdgeSigned nextOne(GEdgeSigned *thisOne, std::list<GEdge *> &wire) int GEdgeLoop::count(GEdge *ge) const { int count = 0; - for(GEdgeLoop::citer it = begin(); it != end(); ++it) { + for(auto it = begin(); it != end(); ++it) { if(it->ge == ge) count++; } return count; @@ -95,25 +94,19 @@ int GEdgeLoop::count(GEdge *ge) const void GEdgeLoop::print() const { - for(GEdgeLoop::citer it = begin(); it != end(); ++it) { - it->print(); - } + for(auto it = begin(); it != end(); ++it) { it->print(); } } -void GEdgeLoop::getEdges(std::vector<GEdge*> &edges) const +void GEdgeLoop::getEdges(std::vector<GEdge *> &edges) const { edges.clear(); - for(GEdgeLoop::citer it = begin(); it != end(); ++it) { - edges.push_back(it->getEdge()); - } + for(auto it = begin(); it != end(); ++it) { edges.push_back(it->getEdge()); } } void GEdgeLoop::getSigns(std::vector<int> &signs) const { signs.clear(); - for(GEdgeLoop::citer it = begin(); it != end(); ++it) { - signs.push_back(it->getSign()); - } + for(auto it = begin(); it != end(); ++it) { signs.push_back(it->getSign()); } } static void loopTheLoop(std::list<GEdge *> &wire, std::list<GEdgeSigned> &loop, @@ -149,8 +142,7 @@ GEdgeLoop::GEdgeLoop(const std::vector<GEdge *> &cwire) std::list<GEdge *> wire; std::vector<GEdge *> degenerated; GEdge *degeneratedToInsert = 0; - for(std::vector<GEdge *>::const_iterator it = cwire.begin(); - it != cwire.end(); ++it) { + for(auto it = cwire.begin(); it != cwire.end(); ++it) { GEdge *ed = *it; if(ed->degenerate(0)) degenerated.push_back(ed); @@ -158,9 +150,7 @@ GEdgeLoop::GEdgeLoop(const std::vector<GEdge *> &cwire) wire.push_back(ed); } - if(degenerated.size() == 1) { - wire.push_front(degenerated[0]); - } + if(degenerated.size() == 1) { wire.push_front(degenerated[0]); } else if(degenerated.size() == 2) { degeneratedToInsert = degenerated[1]; wire.push_front(degenerated[0]); @@ -170,7 +160,5 @@ GEdgeLoop::GEdgeLoop(const std::vector<GEdge *> &cwire) "More than two degenerated edges in one model face of an OCC model"); } - while(!wire.empty()) { - loopTheLoop(wire, loop, °eneratedToInsert); - } + while(!wire.empty()) { loopTheLoop(wire, loop, °eneratedToInsert); } } diff --git a/Geo/GEdgeLoop.h b/Geo/GEdgeLoop.h index be75d918902075c6c69d355f22619c6fbea7c246..2e95ee3ff981842b9bdb9bf66a1553a8d929f5d8 100644 --- a/Geo/GEdgeLoop.h +++ b/Geo/GEdgeLoop.h @@ -42,7 +42,7 @@ public: int count(GEdge *) const; int count() const { return (int)loop.size(); } void print() const; - void getEdges(std::vector<GEdge*> &edges) const; + void getEdges(std::vector<GEdge *> &edges) const; void getSigns(std::vector<int> &signs) const; }; diff --git a/Geo/GEntity.cpp b/Geo/GEntity.cpp index 1c4634a3d9e0d20ff78d69adacf17b19c23e83d9..a6e22f1505d1661fdd614bde6e2c83aba323e28c 100644 --- a/Geo/GEntity.cpp +++ b/Geo/GEntity.cpp @@ -91,12 +91,13 @@ std::string GEntity::getInfoString(bool additional, bool multiline) case 3: sstream << "Volume"; break; } sstream << " " << std::abs(physicals[i]); - std::string name = model()->getPhysicalName(dim(), std::abs(physicals[i])); + std::string name = + model()->getPhysicalName(dim(), std::abs(physicals[i])); if(name.size()) sstream << ": " << name; } } - if(useColor()){ + if(useColor()) { int r = CTX::instance()->unpackRed(_color); int g = CTX::instance()->unpackGreen(_color); int b = CTX::instance()->unpackBlue(_color); @@ -113,8 +114,7 @@ std::string GEntity::getInfoString(bool additional, bool multiline) // removes a MeshVertex void GEntity::removeMeshVertex(MVertex *v) { - std::vector<MVertex *>::iterator it = - std::find(mesh_vertices.begin(), mesh_vertices.end(), v); + auto it = std::find(mesh_vertices.begin(), mesh_vertices.end(), v); if(it != mesh_vertices.end()) mesh_vertices.erase(it); } @@ -145,7 +145,7 @@ void GEntity::setMeshMaster(GEntity *gMaster, const std::vector<double> &tfo, return; } - if(tfo.empty()){ + if(tfo.empty()) { GEntity::setMeshMaster(gMaster); return; } @@ -170,21 +170,21 @@ void GEntity::addVerticesInSet(std::set<MVertex *> &vtcs, bool closure) const switch(dim()) { case 3: { std::vector<GFace *> clos = faces(); - std::vector<GFace *>::iterator cIter = clos.begin(); + auto cIter = clos.begin(); for(; cIter != clos.end(); ++cIter) (*cIter)->addVerticesInSet(vtcs, true); break; } case 2: { std::vector<GEdge *> clos = edges(); - std::vector<GEdge *>::iterator cIter = clos.begin(); + auto cIter = clos.begin(); for(; cIter != clos.end(); ++cIter) (*cIter)->addVerticesInSet(vtcs, true); break; } case 1: { std::vector<GVertex *> clos = vertices(); - std::vector<GVertex *>::iterator cIter = clos.begin(); + auto cIter = clos.begin(); for(; cIter != clos.end(); ++cIter) (*cIter)->addVerticesInSet(vtcs, true); break; @@ -207,7 +207,7 @@ void GEntity::updateCorrespondingVertices() std::set<MVertex *> vtcs; this->addVerticesInSet(vtcs, true); - std::set<MVertex *>::iterator vIter = vtcs.begin(); + auto vIter = vtcs.begin(); for(; vIter != vtcs.end(); ++vIter) { MVertex *tv = *vIter; // double tgt[4] = {tv->x(),tv->y(),tv->z(),1}; @@ -239,8 +239,7 @@ void GEntity::updateCorrespondingVertices() void GEntity::copyMasterCoordinates() { if(_meshMaster != this && affineTransform.size() == 16) { - std::map<MVertex *, MVertex *>::iterator cvIter = - correspondingVertices.begin(); + auto cvIter = correspondingVertices.begin(); for(; cvIter != correspondingVertices.end(); ++cvIter) { MVertex *tv = cvIter->first; diff --git a/Geo/GEntity.h b/Geo/GEntity.h index 3ada42fa27ad765b0b32cd6bb0f225c9cdffc809..baef6682d577d95df9670b833f4677d234dda645 100644 --- a/Geo/GEntity.h +++ b/Geo/GEntity.h @@ -295,10 +295,7 @@ public: virtual void alignElementsWithMaster() {} // get the bounding box - virtual SBoundingBox3d bounds(bool fast = false) - { - return SBoundingBox3d(); - } + virtual SBoundingBox3d bounds(bool fast = false) { return SBoundingBox3d(); } // get the oriented bounding box virtual SOrientedBoundingBox getOBB() { return SOrientedBoundingBox(); } @@ -404,7 +401,8 @@ public: std::map<MVertex *, MVertex *> correspondingHighOrderVertices; // reorder the mesh elements of the given type, according to ordering - virtual bool reorder(const int elementType, const std::vector<std::size_t> &ordering) + virtual bool reorder(const int elementType, + const std::vector<std::size_t> &ordering) { return false; } @@ -422,8 +420,7 @@ struct GEntityPtrLessThan { struct GEntityPtrFullLessThan { bool operator()(const GEntity *ent1, const GEntity *ent2) const { - if(ent1->dim() != ent2->dim()) - return ent1->dim() < ent2->dim(); + if(ent1->dim() != ent2->dim()) return ent1->dim() < ent2->dim(); return ent1->tag() < ent2->tag(); } }; diff --git a/Geo/GFace.h b/Geo/GFace.h index a57189f6ebe101c168eb43e6e3b2e4627b23b622..065bb30538184d3b3b6ba223ccebc1fda8c68997 100644 --- a/Geo/GFace.h +++ b/Geo/GFace.h @@ -319,23 +319,14 @@ public: } meshAttributes; int getMeshingAlgo() const; - void setMeshingAlgo(int val) - { - meshAttributes.algorithm = val; - } - void unsetMeshingAlgo() - { - meshAttributes.algorithm = 0; - } + void setMeshingAlgo(int val) { meshAttributes.algorithm = val; } + void unsetMeshingAlgo() { meshAttributes.algorithm = 0; } int getMeshSizeFromBoundary() const; void setMeshSizeFromBoundary(int val) { meshAttributes.meshSizeFromBoundary = val; } - virtual double getMeshSize() const - { - return meshAttributes.meshSize; - } + virtual double getMeshSize() const { return meshAttributes.meshSize; } virtual double getMeshSizeFactor() const { return meshAttributes.meshSizeFactor; diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index 2416859c894e9aed510e871c96f0058816c17c67..94cd1d2f5269558516e3b739dc335878f233ce5c 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -92,8 +92,7 @@ GModel::GModel(const std::string &name) GModel::~GModel() { - std::vector<GModel *>::iterator it = - std::find(list.begin(), list.end(), this); + auto it = std::find(list.begin(), list.end(), this); if(it != list.end()) list.erase(it); if(getVisibility()) { @@ -178,19 +177,19 @@ void GModel::destroy(bool keepName) _lastMeshEntityError.clear(); _lastMeshVertexError.clear(); - for(riter it = firstRegion(); it != lastRegion(); ++it) delete *it; + for(auto it = firstRegion(); it != lastRegion(); ++it) delete *it; regions.clear(); std::set<GRegion *, GEntityPtrLessThan>().swap(regions); - for(fiter it = firstFace(); it != lastFace(); ++it) delete *it; + for(auto it = firstFace(); it != lastFace(); ++it) delete *it; faces.clear(); std::set<GFace *, GEntityPtrLessThan>().swap(faces); - for(eiter it = firstEdge(); it != lastEdge(); ++it) delete *it; + for(auto it = firstEdge(); it != lastEdge(); ++it) delete *it; edges.clear(); std::set<GEdge *, GEntityPtrLessThan>().swap(edges); - for(viter it = firstVertex(); it != lastVertex(); ++it) delete *it; + for(auto it = firstVertex(); it != lastVertex(); ++it) delete *it; vertices.clear(); std::set<GVertex *, GEntityPtrLessThan>().swap(vertices); @@ -227,10 +226,10 @@ void GModel::destroyMeshCaches() void GModel::deleteMesh() { - for(riter it = firstRegion(); it != lastRegion(); ++it) (*it)->deleteMesh(); - for(fiter it = firstFace(); it != lastFace(); ++it) (*it)->deleteMesh(); - for(eiter it = firstEdge(); it != lastEdge(); ++it) (*it)->deleteMesh(); - for(viter it = firstVertex(); it != lastVertex(); ++it) (*it)->deleteMesh(); + for(auto it = firstRegion(); it != lastRegion(); ++it) (*it)->deleteMesh(); + for(auto it = firstFace(); it != lastFace(); ++it) (*it)->deleteMesh(); + for(auto it = firstEdge(); it != lastEdge(); ++it) (*it)->deleteMesh(); + for(auto it = firstVertex(); it != lastVertex(); ++it) (*it)->deleteMesh(); destroyMeshCaches(); _currentMeshEntity = 0; _lastMeshEntityError.clear(); @@ -249,7 +248,7 @@ void GModel::deleteMesh(const std::vector<GEntity *> &entities) switch(ge->dim()) { case 0: { std::vector<GEdge *> e = ge->edges(); - for(std::vector<GEdge *>::iterator it = e.begin(); it != e.end(); ++it) { + for(auto it = e.begin(); it != e.end(); ++it) { if((*it)->getNumMeshElements()) { ok = false; break; @@ -258,7 +257,7 @@ void GModel::deleteMesh(const std::vector<GEntity *> &entities) } break; case 1: { std::vector<GFace *> f = ge->faces(); - for(std::vector<GFace *>::iterator it = f.begin(); it != f.end(); ++it) { + for(auto it = f.begin(); it != f.end(); ++it) { if((*it)->getNumMeshElements()) { ok = false; break; @@ -267,7 +266,7 @@ void GModel::deleteMesh(const std::vector<GEntity *> &entities) } break; case 2: { std::list<GRegion *> r = ge->regions(); - for(std::list<GRegion *>::iterator it = r.begin(); it != r.end(); ++it) { + for(auto it = r.begin(); it != r.end(); ++it) { if((*it)->getNumMeshElements()) { ok = false; break; @@ -290,13 +289,13 @@ void GModel::deleteMesh(const std::vector<GEntity *> &entities) void GModel::deleteVertexArrays() { - for(riter it = firstRegion(); it != lastRegion(); ++it) + for(auto it = firstRegion(); it != lastRegion(); ++it) (*it)->deleteVertexArrays(); - for(fiter it = firstFace(); it != lastFace(); ++it) + for(auto it = firstFace(); it != lastFace(); ++it) (*it)->deleteVertexArrays(); - for(eiter it = firstEdge(); it != lastEdge(); ++it) + for(auto it = firstEdge(); it != lastEdge(); ++it) (*it)->deleteVertexArrays(); - for(viter it = firstVertex(); it != lastVertex(); ++it) + for(auto it = firstVertex(); it != lastVertex(); ++it) (*it)->deleteVertexArrays(); } @@ -308,8 +307,7 @@ bool GModel::empty() const GRegion *GModel::getRegionByTag(int n) const { GEntity tmp((GModel *)this, n); - std::set<GRegion *, GEntityPtrLessThan>::const_iterator it = - regions.find((GRegion *)&tmp); + auto it = regions.find((GRegion *)&tmp); if(it != regions.end()) return *it; else @@ -319,8 +317,7 @@ GRegion *GModel::getRegionByTag(int n) const GFace *GModel::getFaceByTag(int n) const { GEntity tmp((GModel *)this, n); - std::set<GFace *, GEntityPtrLessThan>::const_iterator it = - faces.find((GFace *)&tmp); + auto it = faces.find((GFace *)&tmp); if(it != faces.end()) return *it; else @@ -330,8 +327,7 @@ GFace *GModel::getFaceByTag(int n) const GEdge *GModel::getEdgeByTag(int n) const { GEntity tmp((GModel *)this, n); - std::set<GEdge *, GEntityPtrLessThan>::const_iterator it = - edges.find((GEdge *)&tmp); + auto it = edges.find((GEdge *)&tmp); if(it != edges.end()) return *it; else @@ -341,8 +337,7 @@ GEdge *GModel::getEdgeByTag(int n) const GVertex *GModel::getVertexByTag(int n) const { GEntity tmp((GModel *)this, n); - std::set<GVertex *, GEntityPtrLessThan>::const_iterator it = - vertices.find((GVertex *)&tmp); + auto it = vertices.find((GVertex *)&tmp); if(it != vertices.end()) return *it; else @@ -368,8 +363,7 @@ std::vector<int> GModel::getTagsForPhysicalName(int dim, getPhysicalGroups(dim, physicalGroups); std::vector<GEntity *> entities = physicalGroups[getPhysicalNumber(dim, name)]; - for(std::vector<GEntity *>::iterator it = entities.begin(); - it != entities.end(); it++) { + for(auto it = entities.begin(); it != entities.end(); it++) { GEntity *ge = *it; tags.push_back(ge->tag()); } @@ -378,30 +372,27 @@ std::vector<int> GModel::getTagsForPhysicalName(int dim, void GModel::remove(GRegion *r) { - riter it = std::find(firstRegion(), lastRegion(), r); + auto it = std::find(firstRegion(), lastRegion(), r); if(it != (riter)regions.end()) { regions.erase(it); std::vector<GFace *> f = r->faces(); - for(std::vector<GFace *>::iterator it = f.begin(); it != f.end(); it++) - (*it)->delRegion(r); + for(auto it = f.begin(); it != f.end(); it++) (*it)->delRegion(r); } } void GModel::remove(GFace *f) { - fiter it = std::find(firstFace(), lastFace(), f); + auto it = std::find(firstFace(), lastFace(), f); if(it != faces.end()) { faces.erase(it); std::vector<GEdge *> const &e = f->edges(); - for(std::vector<GEdge *>::const_iterator it = e.begin(); it != e.end(); - it++) - (*it)->delFace(f); + for(auto it = e.begin(); it != e.end(); it++) (*it)->delFace(f); } } void GModel::remove(GEdge *e) { - eiter it = std::find(firstEdge(), lastEdge(), e); + auto it = std::find(firstEdge(), lastEdge(), e); if(it != edges.end()) { edges.erase(it); if(e->getBeginVertex()) e->getBeginVertex()->delEdge(e); @@ -411,7 +402,7 @@ void GModel::remove(GEdge *e) void GModel::remove(GVertex *v) { - viter it = std::find(firstVertex(), lastVertex(), v); + auto it = std::find(firstVertex(), lastVertex(), v); if(it != vertices.end()) vertices.erase(it); } @@ -424,7 +415,7 @@ void GModel::remove(int dim, int tag, bool recursive) remove(gr); if(recursive) { std::vector<GFace *> f = gr->faces(); - for(std::vector<GFace *>::iterator it = f.begin(); it != f.end(); it++) + for(auto it = f.begin(); it != f.end(); it++) remove(2, (*it)->tag(), recursive); } } @@ -433,7 +424,7 @@ void GModel::remove(int dim, int tag, bool recursive) GFace *gf = getFaceByTag(tag); if(gf) { bool skip = false; - for(riter it = firstRegion(); it != lastRegion(); it++) { + for(auto it = firstRegion(); it != lastRegion(); it++) { std::vector<GFace *> f = (*it)->faces(); if(std::find(f.begin(), f.end(), gf) != f.end()) { skip = true; @@ -444,8 +435,7 @@ void GModel::remove(int dim, int tag, bool recursive) remove(gf); if(recursive) { std::vector<GEdge *> const &e = gf->edges(); - for(std::vector<GEdge *>::const_iterator it = e.begin(); - it != e.end(); it++) + for(auto it = e.begin(); it != e.end(); it++) remove(1, (*it)->tag(), recursive); } } @@ -455,7 +445,7 @@ void GModel::remove(int dim, int tag, bool recursive) GEdge *ge = getEdgeByTag(tag); if(ge) { bool skip = false; - for(fiter it = firstFace(); it != lastFace(); it++) { + for(auto it = firstFace(); it != lastFace(); it++) { std::vector<GEdge *> const &e = (*it)->edges(); if(std::find(e.begin(), e.end(), ge) != e.end()) { skip = true; @@ -475,7 +465,7 @@ void GModel::remove(int dim, int tag, bool recursive) GVertex *gv = getVertexByTag(tag); if(gv) { bool skip = false; - for(eiter it = firstEdge(); it != lastEdge(); it++) { + for(auto it = firstEdge(); it != lastEdge(); it++) { GEdge *ge = *it; if(ge->getBeginVertex() == gv || ge->getEndVertex() == gv) { skip = true; @@ -504,14 +494,13 @@ void GModel::remove() void GModel::snapVertices() { - viter vit = firstVertex(); + auto vit = firstVertex(); double tol = CTX::instance()->geom.tolerance; while(vit != lastVertex()) { std::vector<GEdge *> const &edges = (*vit)->edges(); - for(std::vector<GEdge *>::const_iterator it = edges.begin(); - it != edges.end(); ++it) { + for(auto it = edges.begin(); it != edges.end(); ++it) { Range<double> parb = (*it)->parBounds(0); double t; if((*it)->getBeginVertex() == *vit) { t = parb.low(); } @@ -597,16 +586,14 @@ bool GModel::getBoundaryTags(const std::vector<std::pair<int, int> > &inDimTags, if(gr) { if(recursive) { std::vector<GVertex *> const &vert = gr->vertices(); - for(std::vector<GVertex *>::const_iterator it = vert.begin(); - it != vert.end(); it++) + for(auto it = vert.begin(); it != vert.end(); it++) outDimTags.push_back(std::pair<int, int>(0, (*it)->tag())); } else { std::vector<GFace *> faces(gr->faces()); std::vector<int> const &orientations = gr->faceOrientations(); - std::vector<int>::const_iterator ito = orientations.begin(); - for(std::vector<GFace *>::iterator it = faces.begin(); - it != faces.end(); it++) { + auto ito = orientations.begin(); + for(auto it = faces.begin(); it != faces.end(); it++) { int t = (*it)->tag(); if(oriented && ito != orientations.end()) { t *= *ito; @@ -626,16 +613,14 @@ bool GModel::getBoundaryTags(const std::vector<std::pair<int, int> > &inDimTags, if(gf) { if(recursive) { std::vector<GVertex *> const &vert = gf->vertices(); - for(std::vector<GVertex *>::const_iterator it = vert.begin(); - it != vert.end(); it++) + for(auto it = vert.begin(); it != vert.end(); it++) outDimTags.push_back(std::pair<int, int>(0, (*it)->tag())); } else { std::vector<GEdge *> const &edges = gf->edges(); std::vector<int> orientations(gf->edgeOrientations()); - std::vector<int>::iterator ito = orientations.begin(); - for(std::vector<GEdge *>::const_iterator it = edges.begin(); - it != edges.end(); it++) { + auto ito = orientations.begin(); + for(auto it = edges.begin(); it != edges.end(); it++) { int t = (*it)->tag(); if(oriented && ito != orientations.end()) { t *= *ito; @@ -690,7 +675,7 @@ bool GModel::getBoundaryTags(const std::vector<std::pair<int, int> > &inDimTags, int dim = outDimTags[i].first; int tag = outDimTags[i].second; if(dim >= 0 && dim < 3) { - std::set<int, AbsIntLessThan>::iterator it = c[dim].find(tag); + auto it = c[dim].find(tag); if(it == c[dim].end()) c[dim].insert(tag); else { @@ -700,8 +685,7 @@ bool GModel::getBoundaryTags(const std::vector<std::pair<int, int> > &inDimTags, } outDimTags.clear(); for(int dim = 0; dim < 3; dim++) { - for(std::set<int, AbsIntLessThan>::iterator it = c[dim].begin(); - it != c[dim].end(); it++) + for(auto it = c[dim].begin(); it != c[dim].end(); it++) outDimTags.push_back(std::pair<int, int>(dim, *it)); } } @@ -744,8 +728,7 @@ void GModel::getPhysicalGroups( } for(int dim = 0; dim < 4; ++dim) { std::map<int, std::vector<GEntity *> > &group(groups[dim]); - for(std::map<int, std::vector<GEntity *> >::iterator it = group.begin(); - it != group.end(); ++it) { + for(auto it = group.begin(); it != group.end(); ++it) { std::vector<GEntity *> &v = it->second; std::sort(v.begin(), v.end(), GEntityPtrLessThan()); std::unique(v.begin(), v.end(), GEntityPtrLessThan()); @@ -766,8 +749,7 @@ void GModel::getPhysicalGroups( groups[p].push_back(entities[i]); } } - for(std::map<int, std::vector<GEntity *> >::iterator it = groups.begin(); - it != groups.end(); ++it) { + for(auto it = groups.begin(); it != groups.end(); ++it) { std::vector<GEntity *> &v = it->second; std::sort(v.begin(), v.end(), GEntityPtrLessThan()); std::unique(v.begin(), v.end(), GEntityPtrLessThan()); @@ -828,8 +810,7 @@ void GModel::getInnerPhysicalNamesIterators(std::vector<piter> &iterators) { iterators.resize(4, firstPhysicalName()); - for(piter physIt = firstPhysicalName(); physIt != lastPhysicalName(); - ++physIt) + for(auto physIt = firstPhysicalName(); physIt != lastPhysicalName(); ++physIt) iterators[physIt->first.first] = physIt; } @@ -860,16 +841,14 @@ GModel::piter GModel::setPhysicalName(piter pos, const std::string &name, std::string GModel::getPhysicalName(int dim, int number) const { - std::map<std::pair<int, int>, std::string>::const_iterator it = - _physicalNames.find(std::pair<int, int>(dim, number)); + auto it = _physicalNames.find(std::pair<int, int>(dim, number)); if(it != _physicalNames.end()) return it->second; return ""; } void GModel::removePhysicalName(const std::string &name) { - std::map<std::pair<int, int>, std::string>::iterator it = - _physicalNames.begin(); + auto it = _physicalNames.begin(); while(it != _physicalNames.end()) { if(it->second == name) // it = _physicalNames.erase(it); // C++11 only @@ -881,8 +860,7 @@ void GModel::removePhysicalName(const std::string &name) int GModel::getPhysicalNumber(const int &dim, const std::string &name) { - for(piter physIt = firstPhysicalName(); physIt != lastPhysicalName(); - ++physIt) + for(auto physIt = firstPhysicalName(); physIt != lastPhysicalName(); ++physIt) if(dim == physIt->first.first && name == physIt->second) return physIt->first.second; @@ -909,16 +887,14 @@ int GModel::getMeshDim() const std::string GModel::getElementaryName(int dim, int number) { - std::map<std::pair<int, int>, std::string>::iterator it = - _elementaryNames.find(std::pair<int, int>(dim, number)); + auto it = _elementaryNames.find(std::pair<int, int>(dim, number)); if(it != _elementaryNames.end()) return it->second; return ""; } void GModel::removeElementaryName(const std::string &name) { - std::map<std::pair<int, int>, std::string>::iterator it = - _elementaryNames.begin(); + auto it = _elementaryNames.begin(); while(it != _elementaryNames.end()) { if(it->second == name) // it = _elementaryNames.erase(it); // C++11 only @@ -988,7 +964,7 @@ int GModel::mesh(int dimension) bool GModel::setAllVolumesPositive() { bool ok = true; - for(riter it = regions.begin(); it != regions.end(); ++it) + for(auto it = regions.begin(); it != regions.end(); ++it) for(std::size_t i = 0; i < (*it)->getNumMeshElements(); ++i) if(!(*it)->getMeshElement(i)->setVolumePositive()) ok = false; return ok; @@ -1000,8 +976,7 @@ addToMap(std::multimap<MFace, MElement *, MFaceLessThan> &faceToElement, &elToNeighbors, const MFace &face, MElement *el) { - std::multimap<MFace, MElement *, MFaceLessThan>::iterator fit = - faceToElement.find(face); + auto fit = faceToElement.find(face); if(fit == faceToElement.end()) { faceToElement.insert(std::pair<MFace, MElement *>(face, el)); } @@ -1070,7 +1045,7 @@ void GModel::setAllVolumesPositiveTopology() std::multimap<MFace, MElement *, MFaceLessThan> faceToElement; MElement *el; - for(riter it = regions.begin(); it != regions.end(); ++it) { + for(auto it = regions.begin(); it != regions.end(); ++it) { for(std::size_t iEl = 0; iEl < (*it)->getNumMeshElements(); ++iEl) { el = (*it)->getMeshElement(iEl); for(int iFace = 0; iFace < el->getNumFaces(); iFace++) { @@ -1078,7 +1053,7 @@ void GModel::setAllVolumesPositiveTopology() } } } - for(riter it = regions.begin(); it != regions.end(); ++it) { + for(auto it = regions.begin(); it != regions.end(); ++it) { for(std::size_t iEl = 0; iEl < (*it)->getNumMeshElements(); ++iEl) { el = (*it)->getMeshElement(iEl); for(int iFace = 0; iFace < el->getNumFaces(); iFace++) { @@ -1229,7 +1204,7 @@ int GModel::adaptMesh(std::vector<int> technique, std::vector<MElement *> elements; if(getDim() == 2) { - for(fiter fit = firstFace(); fit != lastFace(); ++fit) { + for(auto fit = firstFace(); fit != lastFace(); ++fit) { if((*fit)->quadrangles.size()) return -1; for(unsigned i = 0; i < (*fit)->triangles.size(); i++) { elements.push_back((*fit)->triangles[i]); @@ -1237,7 +1212,7 @@ int GModel::adaptMesh(std::vector<int> technique, } } else if(getDim() == 3) { - for(riter rit = firstRegion(); rit != lastRegion(); ++rit) { + for(auto rit = firstRegion(); rit != lastRegion(); ++rit) { if((*rit)->hexahedra.size()) return -1; for(unsigned i = 0; i < (*rit)->tetrahedra.size(); i++) { elements.push_back((*rit)->tetrahedra[i]); @@ -1255,7 +1230,7 @@ int GModel::adaptMesh(std::vector<int> technique, fields->setBackgroundField(metric); if(getDim() == 2) { - for(fiter fit = firstFace(); fit != lastFace(); ++fit) { + for(auto fit = firstFace(); fit != lastFace(); ++fit) { if((*fit)->geomType() != GEntity::DiscreteSurface) { meshGFaceBamg(*fit); laplaceSmoothing(*fit, CTX::instance()->mesh.nbSmoothing); @@ -1265,7 +1240,7 @@ int GModel::adaptMesh(std::vector<int> technique, } } else if(getDim() == 3) { - for(riter rit = firstRegion(); rit != lastRegion(); ++rit) { + for(auto rit = firstRegion(); rit != lastRegion(); ++rit) { refineMeshMMG(*rit); if(_elementOctree) delete _elementOctree; _elementOctree = 0; @@ -1381,7 +1356,7 @@ int GModel::getMeshStatus(bool countDiscrete) bool toMesh3D = false; bool onlyVisible = CTX::instance()->mesh.meshOnlyVisible; - for(riter it = firstRegion(); it != lastRegion(); ++it) { + for(auto it = firstRegion(); it != lastRegion(); ++it) { GRegion *gr = *it; if(countDiscrete || gr->geomType() != GEntity::DiscreteVolume) numEle3D += gr->getNumMeshElements(); @@ -1394,7 +1369,7 @@ int GModel::getMeshStatus(bool countDiscrete) std::size_t numEle2D = 0; bool toMesh2D = false, meshDone2D = true; - for(fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { GFace *gf = *it; if(countDiscrete || gf->geomType() != GEntity::DiscreteSurface) numEle2D += gf->getNumMeshElements(); @@ -1410,7 +1385,7 @@ int GModel::getMeshStatus(bool countDiscrete) std::size_t numEle1D = 0; bool toMesh1D = false, meshDone1D = true; - for(eiter it = firstEdge(); it != lastEdge(); ++it) { + for(auto it = firstEdge(); it != lastEdge(); ++it) { GEdge *ge = *it; if(countDiscrete || ge->geomType() != GEntity::DiscreteCurve) numEle1D += ge->getNumMeshElements(); @@ -1424,7 +1399,7 @@ int GModel::getMeshStatus(bool countDiscrete) } if(numEle1D && toMesh1D && meshDone1D) return 1; - for(viter it = firstVertex(); it != lastVertex(); ++it) + for(auto it = firstVertex(); it != lastVertex(); ++it) if((*it)->mesh_vertices.size()) return 0; return -1; @@ -1471,7 +1446,7 @@ int GModel::addMEdge(const MEdge &edge) int GModel::getEdgeNumber(const MEdge &edge) { - hashmapMEdge::iterator it = _mapEdgeNum.find(edge); + auto it = _mapEdgeNum.find(edge); if(it != _mapEdgeNum.end()) { return _mapEdgeNum.find(edge)->second; } else { Msg::Error("This edge does not exist in the mapEdgeNum"); @@ -1614,13 +1589,13 @@ std::size_t GModel::getNumMeshElements(unsigned c[6]) c[3] = 0; c[4] = 0; c[5] = 0; - for(riter it = firstRegion(); it != lastRegion(); ++it) + for(auto it = firstRegion(); it != lastRegion(); ++it) (*it)->getNumMeshElements(c); if(c[0] + c[1] + c[2] + c[3] + c[4] + c[5]) return 3; - for(fiter it = firstFace(); it != lastFace(); ++it) + for(auto it = firstFace(); it != lastFace(); ++it) (*it)->getNumMeshElements(c); if(c[0] + c[1] + c[2]) return 2; - for(eiter it = firstEdge(); it != lastEdge(); ++it) + for(auto it = firstEdge(); it != lastEdge(); ++it) (*it)->getNumMeshElements(c); if(c[0]) return 1; return 0; @@ -1778,7 +1753,7 @@ int GModel::getMeshElementIndex(MElement *e) { if(!e) return 0; if(_elementIndexCache.empty()) return e->getNum(); - std::map<int, int>::iterator it = _elementIndexCache.find(e->getNum()); + auto it = _elementIndexCache.find(e->getNum()); if(it != _elementIndexCache.end()) return it->second; return e->getNum(); } @@ -1807,7 +1782,7 @@ static std::size_t removeInvisible(std::vector<T *> &elements, bool all) std::size_t GModel::removeInvisibleElements() { std::size_t n = 0; - for(riter it = firstRegion(); it != lastRegion(); ++it) { + for(auto it = firstRegion(); it != lastRegion(); ++it) { bool all = !(*it)->getVisibility(); n += removeInvisible((*it)->tetrahedra, all); n += removeInvisible((*it)->hexahedra, all); @@ -1817,14 +1792,14 @@ std::size_t GModel::removeInvisibleElements() n += removeInvisible((*it)->polyhedra, all); (*it)->deleteVertexArrays(); } - for(fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { bool all = !(*it)->getVisibility(); n += removeInvisible((*it)->triangles, all); n += removeInvisible((*it)->quadrangles, all); n += removeInvisible((*it)->polygons, all); (*it)->deleteVertexArrays(); } - for(eiter it = firstEdge(); it != lastEdge(); ++it) { + for(auto it = firstEdge(); it != lastEdge(); ++it) { bool all = !(*it)->getVisibility(); n += removeInvisible((*it)->lines, all); (*it)->deleteVertexArrays(); @@ -1852,7 +1827,7 @@ static std::size_t reverseInvisible(std::vector<T *> &elements, bool all) std::size_t GModel::reverseInvisibleElements() { std::size_t n = 0; - for(riter it = firstRegion(); it != lastRegion(); ++it) { + for(auto it = firstRegion(); it != lastRegion(); ++it) { bool all = !(*it)->getVisibility(); n += reverseInvisible((*it)->tetrahedra, all); n += reverseInvisible((*it)->hexahedra, all); @@ -1863,7 +1838,7 @@ std::size_t GModel::reverseInvisibleElements() (*it)->deleteVertexArrays(); if(all) (*it)->setVisibility(1); } - for(fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { bool all = !(*it)->getVisibility(); n += reverseInvisible((*it)->triangles, all); n += reverseInvisible((*it)->quadrangles, all); @@ -1871,7 +1846,7 @@ std::size_t GModel::reverseInvisibleElements() (*it)->deleteVertexArrays(); if(all) (*it)->setVisibility(1); } - for(eiter it = firstEdge(); it != lastEdge(); ++it) { + for(auto it = firstEdge(); it != lastEdge(); ++it) { bool all = !(*it)->getVisibility(); n += reverseInvisible((*it)->lines, all); (*it)->deleteVertexArrays(); @@ -2119,15 +2094,15 @@ void GModel::createGeometryOfDiscreteEntities( std::vector<discreteRegion *> r; if(dimTags.empty()) { - for(eiter it = firstEdge(); it != lastEdge(); it++) { + for(auto it = firstEdge(); it != lastEdge(); it++) { discreteEdge *de = dynamic_cast<discreteEdge *>(*it); if(de) e.push_back(de); } - for(fiter it = firstFace(); it != lastFace(); it++) { + for(auto it = firstFace(); it != lastFace(); it++) { discreteFace *df = dynamic_cast<discreteFace *>(*it); if(df) f.push_back(df); } - for(riter it = firstRegion(); it != lastRegion(); it++) { + for(auto it = firstRegion(); it != lastRegion(); it++) { discreteRegion *dr = dynamic_cast<discreteRegion *>(*it); if(dr) r.push_back(dr); } @@ -2216,7 +2191,7 @@ void GModel::_associateEntityWithMeshVertices() // loop on regions, then on faces, edges and vertices and store the entity // pointer in the the elements' vertices (this way we associate the entity of // lowest geometrical degree with each vertex) - for(riter it = firstRegion(); it != lastRegion(); ++it) { + for(auto it = firstRegion(); it != lastRegion(); ++it) { _associateEntityWithElementVertices(*it, (*it)->tetrahedra); _associateEntityWithElementVertices(*it, (*it)->hexahedra); _associateEntityWithElementVertices(*it, (*it)->prisms); @@ -2224,22 +2199,22 @@ void GModel::_associateEntityWithMeshVertices() _associateEntityWithElementVertices(*it, (*it)->trihedra); _associateEntityWithElementVertices(*it, (*it)->polyhedra); } - for(fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { _associateEntityWithElementVertices(*it, (*it)->triangles); _associateEntityWithElementVertices(*it, (*it)->quadrangles); _associateEntityWithElementVertices(*it, (*it)->polygons); } - for(eiter it = firstEdge(); it != lastEdge(); ++it) { + for(auto it = firstEdge(); it != lastEdge(); ++it) { _associateEntityWithElementVertices(*it, (*it)->lines); } - for(viter it = firstVertex(); it != lastVertex(); ++it) { + for(auto it = firstVertex(); it != lastVertex(); ++it) { _associateEntityWithElementVertices(*it, (*it)->points); } } void GModel::_storeVerticesInEntities(std::map<int, MVertex *> &vertices) { - std::map<int, MVertex *>::iterator it = vertices.begin(); + auto it = vertices.begin(); for(; it != vertices.end(); ++it) { MVertex *v = it->second; GEntity *ge = v->onWhat(); @@ -2287,7 +2262,7 @@ void GModel::pruneMeshVertexAssociations() std::vector<MVertex *> vertices(vertSet.begin(), vertSet.end()); _associateEntityWithMeshVertices(); // associate mesh nodes primarily with chain entities - for(riter it = _chainRegions.begin(); it != _chainRegions.end(); ++it) { + for(auto it = _chainRegions.begin(); it != _chainRegions.end(); ++it) { _associateEntityWithElementVertices(*it, (*it)->tetrahedra, true); _associateEntityWithElementVertices(*it, (*it)->hexahedra, true); _associateEntityWithElementVertices(*it, (*it)->prisms, true); @@ -2295,15 +2270,15 @@ void GModel::pruneMeshVertexAssociations() _associateEntityWithElementVertices(*it, (*it)->trihedra, true); _associateEntityWithElementVertices(*it, (*it)->polyhedra, true); } - for(fiter it = _chainFaces.begin(); it != _chainFaces.end(); ++it) { + for(auto it = _chainFaces.begin(); it != _chainFaces.end(); ++it) { _associateEntityWithElementVertices(*it, (*it)->triangles, true); _associateEntityWithElementVertices(*it, (*it)->quadrangles, true); _associateEntityWithElementVertices(*it, (*it)->polygons, true); } - for(eiter it = _chainEdges.begin(); it != _chainEdges.end(); ++it) { + for(auto it = _chainEdges.begin(); it != _chainEdges.end(); ++it) { _associateEntityWithElementVertices(*it, (*it)->lines, true); } - for(viter it = _chainVertices.begin(); it != _chainVertices.end(); ++it) { + for(auto it = _chainVertices.begin(); it != _chainVertices.end(); ++it) { _associateEntityWithElementVertices(*it, (*it)->points, true); } _storeVerticesInEntities(vertices); @@ -2323,7 +2298,7 @@ void GModel::_storePhysicalTagsInEntities( } if(ge) { - std::map<int, std::string>::const_iterator it2 = it->second.begin(); + auto it2 = it->second.begin(); for(; it2 != it->second.end(); ++it2) { if(std::find(ge->physicals.begin(), ge->physicals.end(), it2->first) == ge->physicals.end()) { @@ -2364,8 +2339,7 @@ void GModel::checkMeshCoherence(double tolerance) FILE *fp = Fopen("duplicate_nodes.pos", "w"); if(fp) { fprintf(fp, "View \"duplicate vertices\"{\n"); - for(std::set<MVertex *>::iterator it = duplicates.begin(); - it != duplicates.end(); it++) { + for(auto it = duplicates.begin(); it != duplicates.end(); it++) { MVertex *v = *it; fprintf(fp, "SP(%.16g,%.16g,%.16g){%lu};\n", v->x(), v->y(), v->z(), v->getNum()); @@ -2478,8 +2452,7 @@ int GModel::removeDuplicateMeshVertices(double tolerance) for(std::size_t j = 0; j < ge->getNumMeshElements(); j++) { MElement *e = ge->getMeshElement(j); for(std::size_t k = 0; k < e->getNumVertices(); k++) { - std::map<MVertex *, MVertex *>::iterator it = - duplicates.find(e->getVertex(k)); + auto it = duplicates.find(e->getVertex(k)); if(it != duplicates.end()) e->setVertex(k, it->second); } } @@ -2490,7 +2463,7 @@ int GModel::removeDuplicateMeshVertices(double tolerance) for(cIter = duplicates.begin(); cIter != duplicates.end(); ++cIter) { MVertex *oldTgt = cIter->first; MVertex *newTgt = cIter->second; - std::map<MVertex *, MVertex *>::iterator cvIter = corrVtcs.find(oldTgt); + auto cvIter = corrVtcs.find(oldTgt); if(cvIter != corrVtcs.end()) { MVertex *src = cvIter->second; corrVtcs.erase(cvIter); @@ -2499,8 +2472,7 @@ int GModel::removeDuplicateMeshVertices(double tolerance) } for(cIter = corrVtcs.begin(); cIter != corrVtcs.end(); ++cIter) { MVertex *oldSrc = cIter->second; - std::map<MVertex *, MVertex *>::iterator nIter = - duplicates.find(oldSrc); + auto nIter = duplicates.find(oldSrc); if(nIter != duplicates.end()) { MVertex *tgt = cIter->first; MVertex *newSrc = nIter->second; @@ -2516,8 +2488,7 @@ int GModel::removeDuplicateMeshVertices(double tolerance) // delete duplicates std::vector<MVertex *> to_delete; - for(std::map<MVertex *, MVertex *>::iterator it = duplicates.begin(); - it != duplicates.end(); it++) + for(auto it = duplicates.begin(); it != duplicates.end(); it++) to_delete.push_back(it->first); for(std::size_t i = 0; i < to_delete.size(); i++) delete to_delete[i]; @@ -2538,7 +2509,7 @@ void GModel::alignPeriodicBoundaries() // realigning edges - for(eiter it = firstEdge(); it != lastEdge(); ++it) { + for(auto it = firstEdge(); it != lastEdge(); ++it) { GEdge *tgt = *it; GEdge *src = dynamic_cast<GEdge *>(tgt->getMeshMaster()); @@ -2575,7 +2546,7 @@ void GModel::alignPeriodicBoundaries() GEntity *ge = tgtVtx->onWhat(); std::map<MVertex *, MVertex *> &geV2v = ge->correspondingVertices; std::map<MVertex *, MVertex *> &v2v = tgt->correspondingVertices; - std::map<MVertex *, MVertex *>::iterator srcIter = v2v.find(tgtVtx); + auto srcIter = v2v.find(tgtVtx); if(srcIter == v2v.end() || !srcIter->second) { srcIter = geV2v.find(tgtVtx); if(srcIter == geV2v.end() || !srcIter->second) { @@ -2594,8 +2565,7 @@ void GModel::alignPeriodicBoundaries() MEdge tgtEdge(tgtVtcs[0], tgtVtcs[1]); - std::map<MEdge, MLine *, MEdgeLessThan>::iterator sIter = - srcLines.find(tgtEdge); + auto sIter = srcLines.find(tgtEdge); if(sIter == srcLines.end() || !sIter->second) { Msg::Debug( @@ -2616,7 +2586,7 @@ void GModel::alignPeriodicBoundaries() // run through all model faces - for(GModel::fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { GFace *tgt = *it; GFace *src = dynamic_cast<GFace *>(tgt->getMeshMaster()); if(src != NULL && src != tgt) { @@ -2652,7 +2622,7 @@ void GModel::alignPeriodicBoundaries() std::map<MVertex *, MVertex *> &geV2v = ge->correspondingVertices; std::map<MVertex *, MVertex *> &v2v = tgt->correspondingVertices; - std::map<MVertex *, MVertex *>::iterator vIter = v2v.find(vtx); + auto vIter = v2v.find(vtx); if(vIter == v2v.end() || !vIter->second) { vIter = geV2v.find(vtx); if(vIter == geV2v.end() || !vIter->second) { @@ -2669,7 +2639,7 @@ void GModel::alignPeriodicBoundaries() } MFace tgtFace(vtcs); - std::map<MFace, MElement *>::iterator mIter = srcElmts.find(tgtFace); + auto mIter = srcElmts.find(tgtFace); if(mIter == srcElmts.end()) { std::ostringstream faceDef; for(int iVtx = 0; iVtx < nbVtcs; iVtx++) { @@ -2728,9 +2698,7 @@ static void connectMElementsByMFace( _stack.pop(); if(touched.find(ff) == touched.end()) { touched.insert(ff); - for(std::multimap<MFace, MElement *, MFaceLessThan>::iterator it = - e2f.lower_bound(ff); - it != e2f.upper_bound(ff); ++it) { + for(auto it = e2f.lower_bound(ff); it != e2f.upper_bound(ff); ++it) { group.insert(it->second); for(int i = 0; i < it->second->getNumFaces(); ++i) { _stack.push(it->second->getFace(i)); @@ -2756,9 +2724,7 @@ static int connectedVolumes(std::vector<MElement *> &elements, std::vector<MElement *> temp; temp.insert(temp.begin(), group.begin(), group.end()); regs.push_back(temp); - for(std::set<MFace, MFaceLessThan>::iterator it = touched.begin(); - it != touched.end(); ++it) - e2f.erase(*it); + for(auto it = touched.begin(); it != touched.end(); ++it) e2f.erase(*it); } return regs.size(); } @@ -2776,9 +2742,7 @@ static void connectMElementsByMEdge( _stack.pop(); if(touched.find(ee) == touched.end()) { touched.insert(ee); - for(std::multimap<MEdge, MElement *, MEdgeLessThan>::iterator it = - e2e.lower_bound(ee); - it != e2e.upper_bound(ee); ++it) { + for(auto it = e2e.lower_bound(ee); it != e2e.upper_bound(ee); ++it) { group.insert(it->second); for(int i = 0; i < it->second->getNumEdges(); ++i) { _stack.push(it->second->getEdge(i)); @@ -2804,9 +2768,7 @@ static int connectedSurfaces(std::vector<MElement *> &elements, std::vector<MElement *> temp; temp.insert(temp.begin(), group.begin(), group.end()); faces.push_back(temp); - for(std::set<MEdge, MEdgeLessThan>::iterator it = touched.begin(); - it != touched.end(); ++it) - e2e.erase(*it); + for(auto it = touched.begin(); it != touched.end(); ++it) e2e.erase(*it); } return faces.size(); } @@ -2816,14 +2778,13 @@ void GModel::makeDiscreteRegionsSimplyConnected() Msg::Info("Making discrete regions simply connected..."); std::vector<discreteRegion *> discRegions; - for(riter it = firstRegion(); it != lastRegion(); it++) + for(auto it = firstRegion(); it != lastRegion(); it++) if((*it)->geomType() == GEntity::DiscreteVolume) discRegions.push_back((discreteRegion *)*it); std::set<MVertex *> touched; - for(std::vector<discreteRegion *>::iterator itR = discRegions.begin(); - itR != discRegions.end(); itR++) { + for(auto itR = discRegions.begin(); itR != discRegions.end(); itR++) { std::vector<MElement *> allElements((*itR)->getNumMeshElements()); for(std::size_t i = 0; i < (*itR)->getNumMeshElements(); i++) allElements[i] = (*itR)->getMeshElement(i); @@ -2876,14 +2837,13 @@ void GModel::makeDiscreteFacesSimplyConnected() Msg::Info("Making discrete faces simply connected..."); std::vector<discreteFace *> discFaces; - for(fiter it = firstFace(); it != lastFace(); it++) + for(auto it = firstFace(); it != lastFace(); it++) if((*it)->geomType() == GEntity::DiscreteSurface) discFaces.push_back((discreteFace *)*it); std::set<MVertex *> touched; - for(std::vector<discreteFace *>::iterator itF = discFaces.begin(); - itF != discFaces.end(); itF++) { + for(auto itF = discFaces.begin(); itF != discFaces.end(); itF++) { std::vector<MElement *> allElements((*itF)->getNumMeshElements()); for(std::size_t i = 0; i < (*itF)->getNumMeshElements(); i++) allElements[i] = (*itF)->getMeshElement(i); @@ -2933,9 +2893,7 @@ makeSimplyConnected(std::map<int, std::vector<MElement *> > elements[11]) // only for tetras and triangles Msg::Info("Make simply connected regions and surfaces"); std::vector<int> regs; - for(std::map<int, std::vector<MElement *> >::iterator it = - elements[4].begin(); - it != elements[4].end(); it++) + for(auto it = elements[4].begin(); it != elements[4].end(); it++) regs.push_back(it->first); std::multimap<MFace, MElement *, MFaceLessThan> f2e; if(regs.size() > 2) { @@ -2970,8 +2928,7 @@ makeSimplyConnected(std::map<int, std::vector<MElement *> > elements[11]) MElement *el = conRegions[j][k]; for(int l = 0; l < el->getNumFaces(); l++) { MFace mf = el->getFace(l); - std::multimap<MFace, MElement *, MFaceLessThan>::iterator itl = - f2e.lower_bound(mf); + auto itl = f2e.lower_bound(mf); for(; itl != f2e.upper_bound(mf); itl++) { if(itl->second != el) break; } @@ -3014,9 +2971,7 @@ makeSimplyConnected(std::map<int, std::vector<MElement *> > elements[11]) } std::vector<int> faces; - for(std::map<int, std::vector<MElement *> >::iterator it = - elements[2].begin(); - it != elements[2].end(); it++) + for(auto it = elements[2].begin(); it != elements[2].end(); it++) faces.push_back(it->first); std::multimap<MEdge, MElement *, MEdgeLessThan> e2e; if(faces.size() > 2) { @@ -3051,8 +3006,7 @@ makeSimplyConnected(std::map<int, std::vector<MElement *> > elements[11]) MElement *el = conSurfaces[j][k]; for(int l = 0; l < el->getNumEdges(); l++) { MEdge me = el->getEdge(l); - std::multimap<MEdge, MElement *, MEdgeLessThan>::iterator itl = - e2e.lower_bound(me); + auto itl = e2e.lower_bound(me); for(; itl != e2e.upper_bound(me); itl++) { if(itl->second != el) break; } @@ -3123,10 +3077,9 @@ GModel *GModel::buildCutGModel(gLevelset *ls, bool cutElem, bool saveTri) for(int i = 0; i < 4; i++) { cutGM->_storePhysicalTagsInEntities(i, physicals[i]); - std::map<int, std::map<int, std::string> >::iterator it = - physicals[i].begin(); + auto it = physicals[i].begin(); for(; it != physicals[i].end(); it++) { - std::map<int, std::string>::iterator it2 = it->second.begin(); + auto it2 = it->second.begin(); for(; it2 != it->second.end(); it2++) if(it2->second != "") cutGM->setPhysicalName(it2->second, i, it2->first); @@ -3223,13 +3176,11 @@ void GModel::computeHomology() typedef std::pair<const std::vector<int>, const std::vector<int> > dpair; typedef std::pair<const std::string, const std::vector<int> > tpair; std::set<dpair> domains; - for(std::multimap<dpair, tpair>::iterator it = _homologyRequests.begin(); - it != _homologyRequests.end(); it++) + for(auto it = _homologyRequests.begin(); it != _homologyRequests.end(); it++) domains.insert(it->first); Msg::Info("Number of cell complexes to construct: %d", domains.size()); - for(std::set<dpair>::iterator it = domains.begin(); it != domains.end(); - it++) { + for(auto it = domains.begin(); it != domains.end(); it++) { std::pair<std::multimap<dpair, tpair>::iterator, std::multimap<dpair, tpair>::iterator> itp = _homologyRequests.equal_range(*it); @@ -3240,8 +3191,7 @@ void GModel::computeHomology() new Homology(this, itp.first->first.first, itp.first->first.second, imdomain, prepareToRestore); - for(std::multimap<dpair, tpair>::iterator itt = itp.first; - itt != itp.second; itt++) { + for(auto itt = itp.first; itt != itp.second; itt++) { std::string type = itt->second.first; std::vector<int> dim0 = itt->second.second; if(dim0.empty()) diff --git a/Geo/GModel.h b/Geo/GModel.h index a875f7303464a36874d35bf7586a6f6db6c69f28..a7c5629c7974b09feb38138533761c7c6bc03bdb 100644 --- a/Geo/GModel.h +++ b/Geo/GModel.h @@ -608,8 +608,9 @@ public: // create a geometry (i.e. a parametrization for curves and surfaces) for the // given discrete entities (or all of them if dimTags is empty) - void createGeometryOfDiscreteEntities(const std::vector<std::pair<int, int> > - &dimTags = std::vector<std::pair<int, int> >()); + void createGeometryOfDiscreteEntities( + const std::vector<std::pair<int, int> > &dimTags = + std::vector<std::pair<int, int> >()); // make discrete entities simply connected void makeDiscreteRegionsSimplyConnected(); diff --git a/Geo/GModelCreateTopologyFromMesh.cpp b/Geo/GModelCreateTopologyFromMesh.cpp index e47dff04af2eb68a201c80269f11164e20313791..44ea328aa89b47761406e22eb396f2686286d8b2 100644 --- a/Geo/GModelCreateTopologyFromMesh.cpp +++ b/Geo/GModelCreateTopologyFromMesh.cpp @@ -29,15 +29,15 @@ bool topoExists(GModel *gm) { - for(GModel::eiter it = gm->firstEdge(); it != gm->lastEdge(); it++) { + for(auto it = gm->firstEdge(); it != gm->lastEdge(); it++) { GEdge *ge = *it; if(!ge->getBeginVertex() || !ge->getEndVertex()) return false; } - for(GModel::fiter it = gm->firstFace(); it != gm->lastFace(); it++) { + for(auto it = gm->firstFace(); it != gm->lastFace(); it++) { GFace *gf = *it; if(gf->edges().empty()) return false; } - for(GModel::riter it = gm->firstRegion(); it != gm->lastRegion(); it++) { + for(auto it = gm->firstRegion(); it != gm->lastRegion(); it++) { GRegion *gr = *it; if(gr->faces().empty()) return false; } @@ -57,8 +57,7 @@ std::vector<GEdge *> ensureSimplyConnectedEdge(GEdge *ge) for(std::size_t i = 0; i < ge->lines.size(); i++) { _lines.insert(ge->lines[i]); for(int j = 0; j < 2; j++) { - std::map<MVertex *, std::pair<MLine *, MLine *> >::iterator it = - _conn.find(ge->lines[i]->getVertex(j)); + auto it = _conn.find(ge->lines[i]->getVertex(j)); if(it == _conn.end()) _conn[ge->lines[i]->getVertex(j)] = std::make_pair(ge->lines[i], (MLine *)NULL); @@ -79,8 +78,7 @@ std::vector<GEdge *> ensureSimplyConnectedEdge(GEdge *ge) // avoid adding twice the last one if(!_part.size() || _part[_part.size() - 1] != l) { _part.push_back(l); } for(int j = 0; j < 2; j++) { - std::map<MVertex *, std::pair<MLine *, MLine *> >::iterator it = - _conn.find(l->getVertex(j)); + auto it = _conn.find(l->getVertex(j)); if(it->second.first == l && it->second.second != NULL && _lines.find(it->second.second) != _lines.end()) { _stack.push(it->second.second); @@ -120,7 +118,7 @@ void assignFace(GFace *gf, std::set<MElement *> &_f) { gf->triangles.clear(); gf->quadrangles.clear(); - for(std::set<MElement *>::iterator it = _f.begin(); it != _f.end(); ++it) { + for(auto it = _f.begin(); it != _f.end(); ++it) { if((*it)->getNumVertices() == 3) gf->triangles.push_back((MTriangle *)*it); else if((*it)->getNumVertices() == 4) @@ -141,8 +139,7 @@ void ensureManifoldFace(GFace *gf) for(int j = 0; j < e->getNumEdges(); j++) { MEdge ed = e->getEdge(j); if(_nonManifold.find(ed) == _nonManifold.end()) { - std::map<MEdge, std::pair<MElement *, MElement *>, MEdgeLessThan>::iterator - it = _pairs.find(ed); + auto it = _pairs.find(ed); if(it == _pairs.end()) { _pairs[ed] = std::make_pair(e, (MElement *)NULL); } @@ -171,8 +168,7 @@ void ensureManifoldFace(GFace *gf) for(int j = 0; j < e->getNumEdges(); j++) { MEdge ed = e->getEdge(j); if(_nonManifold.find(ed) == _nonManifold.end()) { - std::map<MEdge, std::pair<MElement *, MElement *>, - MEdgeLessThan>::iterator it = _pairs.find(ed); + auto it = _pairs.find(ed); if(it->second.second != NULL) { MElement *other = it->second.second == e ? it->second.first : it->second.second; @@ -202,8 +198,7 @@ void ensureManifoldFace(GFace *gf) void ensureManifoldFaces(GModel *gm) { std::vector<GFace *> f; - for(GModel::fiter it = gm->firstFace(); it != gm->lastFace(); it++) - f.push_back(*it); + for(auto it = gm->firstFace(); it != gm->lastFace(); it++) f.push_back(*it); for(std::size_t i = 0; i < f.size(); i++) ensureManifoldFace(f[i]); } @@ -218,7 +213,7 @@ void createTopologyFromMesh1D(GModel *gm, int &num) MVertexToGVertexMap mVertexToGVertex; - for(GModel::viter it = gm->firstVertex(); it != gm->lastVertex(); it++) { + for(auto it = gm->firstVertex(); it != gm->lastVertex(); it++) { GVertex *gv = *it; if(gv->mesh_vertices.size()) { MVertex *mv = gv->mesh_vertices[0]; @@ -234,22 +229,23 @@ void createTopologyFromMesh1D(GModel *gm, int &num) MVertexToGEdgesMap mVertexToGEdges; GEdgeToGVerticesMap gEdgeToGVertices; - for(GModel::eiter it = gm->firstEdge(); it != gm->lastEdge(); it++) { + for(auto it = gm->firstEdge(); it != gm->lastEdge(); it++) { GEdge *ge = *it; for(std::size_t i = 0; i < (*it)->lines.size(); i++) { MLine *e = (*it)->lines[i]; for(int j = 0; j < 2; j++) { MVertex *mv = e->getVertex(j); - MVertexToGVertexMap::iterator gIter = mVertexToGVertex.find(mv); + auto gIter = mVertexToGVertex.find(mv); if(gIter != mVertexToGVertex.end()) gEdgeToGVertices[ge].insert(gIter->second); else { - MVertexToGEdgesMap::iterator it = mVertexToGEdges.find(mv); - if(it != mVertexToGEdges.end() && it->second.find(ge) != it->second.end()) { + auto it = mVertexToGEdges.find(mv); + if(it != mVertexToGEdges.end() && + it->second.find(ge) != it->second.end()) { // in bulk mVertexToGEdges.erase(it); } - else{ + else { mVertexToGEdges[mv].insert(ge); } } @@ -259,19 +255,18 @@ void createTopologyFromMesh1D(GModel *gm, int &num) // now create any missing GVertex - for(MVertexToGEdgesMap::iterator mvIter = mVertexToGEdges.begin(); - mvIter != mVertexToGEdges.end(); ++mvIter) { + for(auto mvIter = mVertexToGEdges.begin(); mvIter != mVertexToGEdges.end(); + ++mvIter) { MVertex *mv = mvIter->first; std::set<GEdge *> &gEdges = mvIter->second; num++; - discreteVertex *dv = new discreteVertex - (gm, gm->getMaxElementaryNumber(0) + 1, mv->x(), mv->y(), mv->z()); + discreteVertex *dv = new discreteVertex( + gm, gm->getMaxElementaryNumber(0) + 1, mv->x(), mv->y(), mv->z()); gm->add(dv); mVertexToGVertex[mv] = dv; MPoint *mp = new MPoint(mv); dv->points.push_back(mp); - for(std::set<GEdge *>::iterator gEIter = gEdges.begin(); - gEIter != gEdges.end(); ++gEIter) { + for(auto gEIter = gEdges.begin(); gEIter != gEdges.end(); ++gEIter) { GEdge *ge = *gEIter; gEdgeToGVertices[ge].insert(dv); } @@ -280,8 +275,8 @@ void createTopologyFromMesh1D(GModel *gm, int &num) // link all GEdge to GVertex and vice versa (we expect to see two GVertex per // GEdge unless it is periodic!) - for(GEdgeToGVerticesMap::iterator gEIter = gEdgeToGVertices.begin(); - gEIter != gEdgeToGVertices.end(); ++gEIter) { + for(auto gEIter = gEdgeToGVertices.begin(); gEIter != gEdgeToGVertices.end(); + ++gEIter) { GEdge *ge = gEIter->first; std::set<GVertex *> gVerts = gEIter->second; @@ -305,8 +300,7 @@ void createTopologyFromMesh1D(GModel *gm, int &num) } else { std::ostringstream gVertexList; - for(std::set<GVertex *>::iterator gvIter = gVerts.begin(); - gvIter != gVerts.end(); ++gvIter) { + for(auto gvIter = gVerts.begin(); gvIter != gVerts.end(); ++gvIter) { gVertexList << " " << (*gvIter)->tag(); } Msg::Error( @@ -319,7 +313,7 @@ void createTopologyFromMesh1D(GModel *gm, int &num) // add GVertex for self-intersecting GEdge; we still need to check this is // actually the case... - for(GModel::eiter it = gm->firstEdge(); it != gm->lastEdge(); it++) { + for(auto it = gm->firstEdge(); it != gm->lastEdge(); it++) { if(!(*it)->getBeginVertex() || !(*it)->getEndVertex()) { num++; MVertex *v = (*it)->lines[0]->getVertex(0); @@ -377,7 +371,7 @@ void createTopologyFromMesh2D(GModel *gm, int &num) TEdgeToGEdgeMap tEdgeToGEdge; - for(GModel::eiter it = gm->firstEdge(); it != gm->lastEdge(); it++) { + for(auto it = gm->firstEdge(); it != gm->lastEdge(); it++) { GEdge *ge = *it; for(std::size_t i = 0; i < (*it)->lines.size(); i++) { topoEdge te(ge->lines[i], 0); @@ -390,23 +384,24 @@ void createTopologyFromMesh2D(GModel *gm, int &num) TEdgeToGFacesMap tEdgeToGFaces; GFaceToGEdgesMap gFaceToGEdges; - for(GModel::fiter it = gm->firstFace(); it != gm->lastFace(); it++) { + for(auto it = gm->firstFace(); it != gm->lastFace(); it++) { GFace *gf = *it; for(std::size_t i = 0; i < (*it)->getNumMeshElements(); i++) { MElement *e = (*it)->getMeshElement(i); if(e->getDim() == 2) { for(int j = 0; j < e->getNumEdges(); j++) { topoEdge te(e, j); - TEdgeToGEdgeMap::iterator eIter = tEdgeToGEdge.find(te); + auto eIter = tEdgeToGEdge.find(te); if(eIter != tEdgeToGEdge.end()) gFaceToGEdges[gf].insert(eIter->second); else { - TEdgeToGFacesMap::iterator it = tEdgeToGFaces.find(te); - if(it != tEdgeToGFaces.end() && it->second.find(gf) != it->second.end()) { + auto it = tEdgeToGFaces.find(te); + if(it != tEdgeToGFaces.end() && + it->second.find(gf) != it->second.end()) { // in bulk tEdgeToGFaces.erase(it); } - else{ + else { tEdgeToGFaces[te].insert(gf); } } @@ -423,15 +418,14 @@ void createTopologyFromMesh2D(GModel *gm, int &num) for(it = tEdgeToGFaces.begin(); it != tEdgeToGFaces.end(); ++it) { std::set<GFace *> &gfaces = it->second; - GFacesToGEdgeMap::iterator gfIter = gFacesToGEdge.find(gfaces); + auto gfIter = gFacesToGEdge.find(gfaces); if(gfIter == gFacesToGEdge.end()) { discreteEdge *de = new discreteEdge(gm, gm->getMaxElementaryNumber(1) + 1, NULL, NULL); num++; gm->add(de); - std::set<GFace *>::iterator gfIter = gfaces.begin(); - for(; gfIter != gfaces.end(); ++gfIter) - gFaceToGEdges[*gfIter].insert(de); + auto gfIter = gfaces.begin(); + for(; gfIter != gfaces.end(); ++gfIter) gFaceToGEdges[*gfIter].insert(de); gFacesToGEdge[gfaces] = de; } } @@ -444,7 +438,7 @@ void createTopologyFromMesh2D(GModel *gm, int &num) const topoEdge &te = it->first; std::set<GFace *> &gfaces = it->second; - GFacesToGEdgeMap::iterator gfIter = gFacesToGEdge.find(gfaces); + auto gfIter = gFacesToGEdge.find(gfaces); if(gfIter != gFacesToGEdge.end()) { GEdge *ge = gfIter->second; @@ -468,7 +462,7 @@ void createTopologyFromMesh2D(GModel *gm, int &num) } std::map<GEdge *, std::vector<GEdge *> > splitEdge; - for(GModel::eiter it = gm->firstEdge(); it != gm->lastEdge(); it++) { + for(auto it = gm->firstEdge(); it != gm->lastEdge(); it++) { std::vector<GEdge *> split = ensureSimplyConnectedEdge(*it); if(split.size() != 1) splitEdge[*it] = split; } @@ -480,10 +474,9 @@ void createTopologyFromMesh2D(GModel *gm, int &num) for(gfToge = gFaceToGEdges.begin(); gfToge != gFaceToGEdges.end(); ++gfToge) { std::set<GEdge *> &edgeSet = gfToge->second; std::set<GEdge *> newEdgeSet; - std::set<GEdge *>::iterator eIter = edgeSet.begin(); + auto eIter = edgeSet.begin(); for(; eIter != edgeSet.end(); ++eIter) { - std::map<GEdge *, std::vector<GEdge *> >::iterator pIter = - splitEdge.find(*eIter); + auto pIter = splitEdge.find(*eIter); if(pIter != splitEdge.end()) { std::vector<GEdge *> &edges = pIter->second; newEdgeSet.insert(edges.begin(), edges.end()); @@ -502,7 +495,7 @@ void createTopologyFromMesh2D(GModel *gm, int &num) gEdges.insert(gEdges.begin(), gEdgeSet.begin(), gEdgeSet.end()); gf->set(gEdges); - std::set<GEdge *>::iterator eIter = gEdgeSet.begin(); + auto eIter = gEdgeSet.begin(); for(; eIter != gEdgeSet.end(); eIter++) (*eIter)->addFace(gf); } } @@ -557,7 +550,7 @@ void createTopologyFromMesh3D(GModel *gm, int &num) // create an inverse dictionary for existing faces TFaceToGFaceMap tFaceToGFace; - for(GModel::fiter it = gm->firstFace(); it != gm->lastFace(); it++) { + for(auto it = gm->firstFace(); it != gm->lastFace(); it++) { for(unsigned i = 0; i < (*it)->triangles.size(); i++) { topoFace tf((*it)->triangles[i], 0); tFaceToGFace.insert(std::make_pair(tf, *it)); @@ -574,17 +567,17 @@ void createTopologyFromMesh3D(GModel *gm, int &num) TFaceToGRegionPairMap tFaceToGRegionPair; GRegionToGFacesMap gRegionToGFaces; - for(GModel::riter it = gm->firstRegion(); it != gm->lastRegion(); it++) { + for(auto it = gm->firstRegion(); it != gm->lastRegion(); it++) { GRegion *gr = *it; for(unsigned i = 0; i < gr->getNumMeshElements(); i++) { MElement *e = gr->getMeshElement(i); for(int j = 0; j < e->getNumFaces(); j++) { topoFace f(e, j); - TFaceToGFaceMap::iterator ffIter = tFaceToGFace.find(f); + auto ffIter = tFaceToGFace.find(f); if(ffIter != tFaceToGFace.end()) gRegionToGFaces[gr].insert(ffIter->second); else { - TFaceToGRegionPairMap::iterator frIter = tFaceToGRegionPair.find(f); + auto frIter = tFaceToGRegionPair.find(f); if(frIter == tFaceToGRegionPair.end()) { tFaceToGRegionPair[f] = std::make_pair((GRegion *)NULL, *it); } @@ -599,19 +592,18 @@ void createTopologyFromMesh3D(GModel *gm, int &num) GRegionPairToGFaceMap gRegionPairToGFace; - TFaceToGRegionPairMap::iterator it = tFaceToGRegionPair.begin(); + auto it = tFaceToGRegionPair.begin(); for(; it != tFaceToGRegionPair.end(); ++it) { GRegion *r1 = it->second.first; GRegion *r2 = it->second.second; if(r1 != r2) { std::pair<GRegion *, GRegion *> gRegionPair; if(r1 && r2) - gRegionPair = std::pair<GRegion*, GRegion*>(std::min(r1, r2), - std::max(r1, r2)); + gRegionPair = + std::pair<GRegion *, GRegion *>(std::min(r1, r2), std::max(r1, r2)); else // r1 null - gRegionPair = std::pair<GRegion*, GRegion*>(r1, r2); - GRegionPairToGFaceMap::iterator iter = - gRegionPairToGFace.find(gRegionPair); + gRegionPair = std::pair<GRegion *, GRegion *>(r1, r2); + auto iter = gRegionPairToGFace.find(gRegionPair); if(iter == gRegionPairToGFace.end()) { discreteFace *df = new discreteFace(gm, gm->getMaxElementaryNumber(2) + 1); @@ -631,8 +623,7 @@ void createTopologyFromMesh3D(GModel *gm, int &num) const topoFace &tf = it->first; std::pair<GRegion *, GRegion *> grPair = it->second; - GRegionPairToGFaceMap::iterator grTogfIter = - gRegionPairToGFace.find(grPair); + auto grTogfIter = gRegionPairToGFace.find(grPair); if(grTogfIter != gRegionPairToGFace.end()) { GFace *gf = grTogfIter->second; @@ -659,14 +650,13 @@ void createTopologyFromMesh3D(GModel *gm, int &num) // now connect GFaces to GRegions and vice versa - GRegionToGFacesMap::iterator itTo = gRegionToGFaces.begin(); + auto itTo = gRegionToGFaces.begin(); for(; itTo != gRegionToGFaces.end(); ++itTo) { GRegion *gr = itTo->first; std::vector<GFace *> faces; faces.insert(faces.begin(), itTo->second.begin(), itTo->second.end()); gr->set(faces); - for(std::vector<GFace *>::iterator it3 = faces.begin(); it3 != faces.end(); - ++it3) + for(auto it3 = faces.begin(); it3 != faces.end(); ++it3) (*it3)->addRegion(itTo->first); } } @@ -695,6 +685,6 @@ void GModel::createTopologyFromMesh() CTX::instance()->mesh.changed = ENT_ALL; double t2 = Cpu(), w2 = TimeOfDay(); - Msg::Info("Done creating topology from mesh (Wall %gs, CPU %gs)", - w2 - w1, t2 - t1); + Msg::Info("Done creating topology from mesh (Wall %gs, CPU %gs)", w2 - w1, + t2 - t1); } diff --git a/Geo/GModelIO_BDF.cpp b/Geo/GModelIO_BDF.cpp index ddf19bd3f3c2844728c6d5446fd79ad3bacac7aa..c522368cc2af4706ccdcf0667b379c556180ce16 100644 --- a/Geo/GModelIO_BDF.cpp +++ b/Geo/GModelIO_BDF.cpp @@ -41,9 +41,7 @@ static double atofBDF(char *str) int len = strlen(str); // classic numbers with E or D exponent notation for(int i = 0; i < len; i++) { - if(str[i] == 'E' || str[i] == 'e') { - return atof(str); - } + if(str[i] == 'E' || str[i] == 'e') { return atof(str); } else if(str[i] == 'D' || str[i] == 'd') { str[i] = 'E'; return atof(str); @@ -111,8 +109,7 @@ static int readVertexBDF(FILE *fp, char *buffer, int keySize, int *num, if(!fgets(buffer2, sizeof(buffer2), fp)) return 0; copyChar(tmp[4], &buffer2[8], 16); break; - default: - return 0; + default: return 0; } *num = atoi(tmp[0]); @@ -199,7 +196,7 @@ static int readElementBDF(FILE *fp, char *buffer, int keySize, int numVertices, int numCheck = (numVertices > 0) ? numVertices : fields.size() - 2; for(int i = 0; i < numCheck; i++) { - std::map<int, MVertex *>::iterator it = vertexMap.find(n[i]); + auto it = vertexMap.find(n[i]); if(it == vertexMap.end()) { Msg::Error("Wrong node index %d", n[i]); return 0; diff --git a/Geo/GModelIO_CELUM.cpp b/Geo/GModelIO_CELUM.cpp index e99a3a1de6fb8d422263334356c34766d4da3b12..6fe4237c6b907cc944c5ae0c8dfca63e86ea6ca3 100644 --- a/Geo/GModelIO_CELUM.cpp +++ b/Geo/GModelIO_CELUM.cpp @@ -37,7 +37,7 @@ int GModel::writeCELUM(const std::string &name, bool saveAll, // count faces and vertices; the CELUM format duplicates vertices on the // boundary of CAD patches int numf = 0, nums = 0; - for(fiter it = firstFace(); it != lastFace(); it++) { + for(auto it = firstFace(); it != lastFace(); it++) { GFace *f = *it; if(!saveAll && f->physicals.empty()) continue; numf += f->triangles.size(); @@ -78,7 +78,7 @@ int GModel::writeCELUM(const std::string &name, bool saveAll, */ fprintf(fpf, "%d\n\n", numf); fprintf(fps, "%d %g\n\n", nums, 1.0); - for(fiter it = firstFace(); it != lastFace(); it++) { + for(auto it = firstFace(); it != lastFace(); it++) { GFace *f = *it; if(!saveAll && f->physicals.empty()) continue; std::vector<MVertex *> vvec; @@ -107,7 +107,7 @@ int GModel::writeCELUM(const std::string &name, bool saveAll, } for(std::size_t i = 0; i < vvec.size(); i++) { MVertex *v = vvec[i]; - std::map<MVertex *, CelumInfo>::iterator it = vmap.find(v); + auto it = vmap.find(v); fprintf(fps, "%ld %g %g %g %g %g %g %g %g %g %g %g %g %g %g\n\n", it->first->getIndex(), it->first->x(), it->first->y(), it->first->z(), it->second.normal.x(), it->second.normal.y(), diff --git a/Geo/GModelIO_CGNS.cpp b/Geo/GModelIO_CGNS.cpp index 48ff32af4b8c0aa4426c82e1a179c01ebb15a9b1..c75fe9aa9c905846b3f49850e3b3eb83a0e19724 100644 --- a/Geo/GModelIO_CGNS.cpp +++ b/Geo/GModelIO_CGNS.cpp @@ -54,26 +54,26 @@ int GModel::readCGNS(const std::string &name, if(cgnsErr != CG_OK) return cgnsError(__FILE__, __LINE__, fileIndex); // create all zones by reading basic info - std::vector<CGNSZone *> allZones(nbZone+1); + std::vector<CGNSZone *> allZones(nbZone + 1); std::map<std::string, int> name2Zone; bool postpro; createZones(fileIndex, baseIndex, meshDim, allEltNodeTransfo, allZones, name2Zone, postpro); // data structures for element and vertices - std::vector<MVertex *> allVert; // all vertices + std::vector<MVertex *> allVert; // all vertices std::map<int, std::vector<MElement *> > allElt[10]; // all elements by type - // vertex and element (global) tags per zone for postpro - vertPerZone.resize(nbZone+1); - eltPerZone.resize(nbZone+1); + // vertex and element (global) tags per zone for postpro + vertPerZone.resize(nbZone + 1); + eltPerZone.resize(nbZone + 1); // read mesh in zones for(int iZone = 1; iZone <= nbZone; iZone++) { CGNSZone *zone = allZones[iZone]; - int err = zone->readMesh(dim, scale, allZones, allVert, allElt, - vertPerZone[iZone], eltPerZone[iZone], - allGeomName); + int err = + zone->readMesh(dim, scale, allZones, allVert, allElt, vertPerZone[iZone], + eltPerZone[iZone], allGeomName); if((!postpro) || (CTX::instance()->mesh.cgnsImportIgnoreSolution != 0)) { vertPerZone[iZone].clear(); eltPerZone[iZone].clear(); @@ -123,7 +123,6 @@ int GModel::readCGNS(const std::string &name, return postpro ? 2 : 1; } - int GModel::writeCGNS(const std::string &name, bool saveAll, double scalingFactor, bool structured) { @@ -136,11 +135,13 @@ int GModel::writeCGNS(const std::string &name, bool saveAll, // write the base node int meshDim = getMeshDim(), dim = 3, cgIndexBase = 0; size_t posStartName = name.find_last_of("/\\"); - if (posStartName == std::string::npos) posStartName = 0; - else posStartName++; + if(posStartName == std::string::npos) + posStartName = 0; + else + posStartName++; std::string baseName = cgnsString(name.substr(posStartName)); - cgnsErr = cg_base_write(cgIndexFile, baseName.c_str(), meshDim, dim, - &cgIndexBase); + cgnsErr = + cg_base_write(cgIndexFile, baseName.c_str(), meshDim, dim, &cgIndexBase); if(cgnsErr != CG_OK) return cgnsError(__FILE__, __LINE__, cgIndexFile); // write information about who generated the mesh @@ -150,8 +151,8 @@ int GModel::writeCGNS(const std::string &name, bool saveAll, if(cgnsErr != CG_OK) return cgnsError(__FILE__, __LINE__, cgIndexFile); // try to write as structured grid (if it fails, write as unstructured) - if(structured && writeZonesStruct(this, scalingFactor, cgIndexFile, - cgIndexBase)) { + if(structured && + writeZonesStruct(this, scalingFactor, cgIndexFile, cgIndexBase)) { cgnsErr = cg_close(cgIndexFile); if(cgnsErr != CG_OK) return cgnsError(__FILE__, __LINE__); return 1; @@ -170,9 +171,9 @@ int GModel::writeCGNS(const std::string &name, bool saveAll, getEntities(allEntities); getEntitiesToSave(allEntities, saveAll, entities); getPeriodicEntities(allEntities, entitiesPer); - if (numPart > 0) { + if(numPart > 0) { getPartitionInterfaceEntities(allEntities, saveAll, entitiesInterf); - if (entitiesInterf.size() == 0) { + if(entitiesInterf.size() == 0) { Msg::Warning("Partitioned entities not detected"); } } @@ -186,40 +187,40 @@ int GModel::writeCGNS(const std::string &name, bool saveAll, // write partitions and periodic/partition connectivities std::set<int> eleMshTypes; std::map<GEntity *, std::string> geomEntities; - if (numPart == 0) { // mesh not partitioned + if(numPart == 0) { // mesh not partitioned int err = writeZone(this, saveAll, scalingFactor, meshDim, numNodes, 0, entities, cgIndexFile, cgIndexBase, zoneName, interfVert2Local, eleMshTypes, geomEntities); if(err == 0) return 0; - if (entitiesPer.size() > 0) { + if(entitiesPer.size() > 0) { err = writePeriodic(entitiesPer, cgIndexFile, cgIndexBase, zoneName, interfVert2Local); if(err == 0) return 0; } } - else { // partitioned mesh + else { // partitioned mesh std::vector<std::vector<GEntity *> > entitiesPart; entitiesPart.resize(numPart + 1); getEntitiesInPartitions(entities, entitiesPart); for(std::size_t iPart = 1; iPart <= numPart; iPart++) { printProgress("Writing partition", iPart, numPart); - int err = writeZone(this, saveAll, scalingFactor, meshDim, numNodes, - iPart, entitiesPart[iPart], cgIndexFile, cgIndexBase, - zoneName, interfVert2Local, eleMshTypes, - geomEntities); + int err = + writeZone(this, saveAll, scalingFactor, meshDim, numNodes, iPart, + entitiesPart[iPart], cgIndexFile, cgIndexBase, zoneName, + interfVert2Local, eleMshTypes, geomEntities); if(err == 0) return 0; - } // loop on partitions - if (entitiesPer.size() > 0) { + } // loop on partitions + if(entitiesPer.size() > 0) { int err = writePeriodic(entitiesPer, cgIndexFile, cgIndexBase, zoneName, interfVert2Local); if(err == 0) return 0; } - if (entitiesInterf.size() > 0) { + if(entitiesInterf.size() > 0) { int err = writeInterfaces(entitiesInterf, cgIndexFile, cgIndexBase, zoneName, interfVert2Local); if(err == 0) return 0; } - } // numPart == 0 + } // numPart == 0 // write geometric entities in families if(geomEntities.size() > 0) { @@ -238,10 +239,8 @@ int GModel::writeCGNS(const std::string &name, bool saveAll, return 1; } - #else - int GModel::readCGNS(const std::string &name, std::vector<std::vector<MVertex *> > &vertPerZone, std::vector<std::vector<MElement *> > &eltPerZone) @@ -250,7 +249,6 @@ int GModel::readCGNS(const std::string &name, return 0; } - int GModel::writeCGNS(const std::string &name, bool saveAll, double scalingFactor, bool structured) { @@ -258,5 +256,4 @@ int GModel::writeCGNS(const std::string &name, bool saveAll, return 0; } - #endif diff --git a/Geo/GModelIO_DIFF.cpp b/Geo/GModelIO_DIFF.cpp index 1f56fdb090a1550f6f42b685460318cbd2fb468a..91ddba72d6a8f1c0b87be45f83a8e64ec2bb0880 100644 --- a/Geo/GModelIO_DIFF.cpp +++ b/Geo/GModelIO_DIFF.cpp @@ -186,8 +186,7 @@ int GModel::readDIFF(const std::string &name) Msg::Warning("Skipping duplicate node %d", num); else vertexMap[num] = new MVertex(xyz[0], xyz[1], xyz[2], 0, num); - if(numVertices > 100000) - Msg::ProgressMeter(i + 1, true, "Reading nodes"); + if(numVertices > 100000) Msg::ProgressMeter(i + 1, true, "Reading nodes"); // If the vertex numbering is dense, tranfer the map into a // vector to speed up element creation if((int)vertexMap.size() == numVertices && @@ -382,7 +381,6 @@ int GModel::readDIFF(const std::string &name) Msg::ProgressMeter(i + 1, true, "Reading elements"); } Msg::StopProgressMeter(); - } // store the elements in their associated elementary entity. If the @@ -432,10 +430,9 @@ int GModel::writeDIFF(const std::string &name, bool binary, bool saveAll, // faces, and the vertices would end up categorized on either one.) std::vector<std::list<int> > vertexTags(numVertices); std::list<int> boundaryIndicators; - for(riter it = firstRegion(); it != lastRegion(); it++) { + for(auto it = firstRegion(); it != lastRegion(); it++) { std::vector<GFace *> faces = (*it)->faces(); - for(std::vector<GFace *>::iterator itf = faces.begin(); itf != faces.end(); - itf++) { + for(auto itf = faces.begin(); itf != faces.end(); itf++) { GFace *gf = *itf; boundaryIndicators.push_back(gf->tag()); for(std::size_t i = 0; i < gf->getNumMeshElements(); i++) { @@ -492,8 +489,8 @@ int GModel::writeDIFF(const std::string &name, bool binary, bool saveAll, fprintf(fp, " Only one subdomain : dpFALSE\n"); fprintf(fp, " Lattice data ? 0\n\n\n\n"); fprintf(fp, " %d Boundary indicators: ", (int)boundaryIndicators.size()); - for(std::list<int>::iterator it = boundaryIndicators.begin(); - it != boundaryIndicators.end(); it++) + for(auto it = boundaryIndicators.begin(); it != boundaryIndicators.end(); + it++) fprintf(fp, " %d", *it); fprintf(fp, "\n\n\n"); @@ -512,7 +509,7 @@ int GModel::writeDIFF(const std::string &name, bool binary, bool saveAll, if(v->getIndex() > 0) { v->writeDIFF(fp, binary, scalingFactor); fprintf(fp, " [%d] ", (int)vertexTags[v->getIndex() - 1].size()); - for(std::list<int>::iterator it = vertexTags[v->getIndex() - 1].begin(); + for(auto it = vertexTags[v->getIndex() - 1].begin(); it != vertexTags[v->getIndex() - 1].end(); it++) fprintf(fp, " %d ", *it); fprintf(fp, "\n"); diff --git a/Geo/GModelIO_GEO.cpp b/Geo/GModelIO_GEO.cpp index 2c9e0504d057bfc2f5e01f5ac42bc6c2b61366c5..df3f789b7324132c503f213f3b1a5039b55f36a3 100644 --- a/Geo/GModelIO_GEO.cpp +++ b/Geo/GModelIO_GEO.cpp @@ -281,7 +281,8 @@ bool GEO_Internals::addBezier(int &tag, const std::vector<int> &pointTags) List_Add(tmp, &t); } bool ok = true; - Curve *c = CreateCurve(tag, MSH_SEGM_BEZIER, 2, tmp, NULL, -1, -1, 0., 1., ok); + Curve *c = + CreateCurve(tag, MSH_SEGM_BEZIER, 2, tmp, NULL, -1, -1, 0., 1., ok); Tree_Add(Curves, &c); CreateReversedCurve(c); List_Delete(tmp); @@ -318,7 +319,8 @@ bool GEO_Internals::addBSpline(int &tag, const std::vector<int> &pointTags, double d = seqknots[i]; List_Add(knotsList, &d); } - c = CreateCurve(tag, MSH_SEGM_NURBS, order, tmp, knotsList, -1, -1, 0., 1., ok); + c = CreateCurve(tag, MSH_SEGM_NURBS, order, tmp, knotsList, -1, -1, 0., 1., + ok); } Tree_Add(Curves, &c); CreateReversedCurve(c); @@ -327,7 +329,8 @@ bool GEO_Internals::addBSpline(int &tag, const std::vector<int> &pointTags, return ok; } -bool GEO_Internals::_addCompoundSpline(int &tag, const std::vector<int> &curveTags, +bool GEO_Internals::_addCompoundSpline(int &tag, + const std::vector<int> &curveTags, int numIntervals, bool bspline) { if(tag >= 0 && FindCurve(tag)) { @@ -344,7 +347,8 @@ bool GEO_Internals::_addCompoundSpline(int &tag, const std::vector<int> &curveTa } if(tag < 0) tag = getMaxTag(1) + 1; - List_T *tmp = List_Create((numIntervals + 1) * curveTags.size(), 2, sizeof(int)); + List_T *tmp = + List_Create((numIntervals + 1) * curveTags.size(), 2, sizeof(int)); for(std::size_t i = 0; i < curveTags.size(); i++) { Curve *c = FindCurve(curveTags[i]); if(!c) { @@ -367,7 +371,7 @@ bool GEO_Internals::_addCompoundSpline(int &tag, const std::vector<int> &curveTa Curve *c; if(bspline) c = CreateCurve(tag, MSH_SEGM_BSPLN, 2, tmp, NULL, -1, -1, 0., 1., ok); - else //often too oscillatory for non-uniform distribution of control points + else // often too oscillatory for non-uniform distribution of control points c = CreateCurve(tag, MSH_SEGM_SPLN, 3, tmp, NULL, -1, -1, 0., 1., ok); Tree_Add(Curves, &c); CreateReversedCurve(c); @@ -376,14 +380,16 @@ bool GEO_Internals::_addCompoundSpline(int &tag, const std::vector<int> &curveTa return ok; } -bool GEO_Internals::addCompoundSpline(int &tag, const std::vector<int> &curveTags, +bool GEO_Internals::addCompoundSpline(int &tag, + const std::vector<int> &curveTags, int numIntervals) { return _addCompoundSpline(tag, curveTags, numIntervals, false); } -bool GEO_Internals::addCompoundBSpline(int &tag, const std::vector<int> &curveTags, - int numIntervals) +bool GEO_Internals::addCompoundBSpline(int &tag, + const std::vector<int> &curveTags, + int numIntervals) { return _addCompoundSpline(tag, curveTags, numIntervals, true); } @@ -416,7 +422,7 @@ struct VertexPtrLessThan { } }; -static bool SortCurvesConsecutive(const std::vector<Curve*> &e, +static bool SortCurvesConsecutive(const std::vector<Curve *> &e, std::vector<std::vector<Vertex *> > &vs) { vs.clear(); @@ -429,18 +435,18 @@ static bool SortCurvesConsecutive(const std::vector<Curve*> &e, if(!v0 || !v1) { Msg::Warning("Skipping GEO curve %d without begin or end point in curve " - "loop detection", e[i]->Num); + "loop detection", + e[i]->Num); continue; } - if(v0 == v1){ // periodic curve + if(v0 == v1) { // periodic curve std::vector<Vertex *> v = {v0, v1}; vs.push_back(v); continue; } - std::map<Vertex *, std::pair<Vertex *, Vertex *>, VertexPtrLessThan> - ::iterator it0 = c.find(v0), it1 = c.find(v1); + auto it0 = c.find(v0), it1 = c.find(v1); if(it0 == c.end()) c[v0] = std::make_pair(v1, (Vertex *)NULL); else { @@ -456,9 +462,8 @@ static bool SortCurvesConsecutive(const std::vector<Curve*> &e, if(it1->second.second == NULL) { it1->second.second = v0; } else { Msg::Debug("Wrong topology for a list of curves"); - Msg::Debug("Point %d is adjacent to more than 2 points %d %d", - v1->Num, it1->second.first->Num, - it1->second.second->Num); + Msg::Debug("Point %d is adjacent to more than 2 points %d %d", v1->Num, + it1->second.first->Num, it1->second.second->Num); return false; } } @@ -468,8 +473,7 @@ static bool SortCurvesConsecutive(const std::vector<Curve*> &e, std::vector<Vertex *> v; Vertex *start = NULL; { - std::map<Vertex *, std::pair<Vertex *, Vertex *>, VertexPtrLessThan> - ::iterator it = c.begin(); + auto it = c.begin(); start = it->first; for(; it != c.end(); ++it) { if(it->second.second == NULL) { @@ -479,8 +483,7 @@ static bool SortCurvesConsecutive(const std::vector<Curve*> &e, } } - std::map<Vertex *, std::pair<Vertex *, Vertex *>, VertexPtrLessThan > - ::iterator its = c.find(start); + auto its = c.find(start); Vertex *prev = (its->second.second == start) ? its->second.first : its->second.second; @@ -492,8 +495,7 @@ static bool SortCurvesConsecutive(const std::vector<Curve*> &e, return false; } v.push_back(current); - std::map<Vertex *, std::pair<Vertex *, Vertex *>, VertexPtrLessThan> - ::iterator it = c.find(current); + auto it = c.find(current); if(it == c.end() || it->first == NULL) { Msg::Error("Impossible to find point %d", current->Num); return false; @@ -534,7 +536,8 @@ bool GEO_Internals::addCurveLoops(const std::vector<int> &curveTags, } if(!c->beg || !c->end) { Msg::Error("Cannot create curve loops using curve %d without begin or " - "end point", c->Num); + "end point", + c->Num); return false; } pairs.insert(std::make_pair(std::make_pair(c->beg, c->end), c)); @@ -569,8 +572,7 @@ bool GEO_Internals::addCurveLoops(const std::vector<int> &curveTags, pairs.erase(it); } } - if(num) - List_Add(tmp, &num); + if(num) List_Add(tmp, &num); } int tag = getMaxTag(-1) + 1; EdgeLoop *l = CreateEdgeLoop(tag, tmp); @@ -729,8 +731,9 @@ bool GEO_Internals::_extrude(int mode, int tag = inDimTags[i].second; Shape s; s.Type = (dim == 3) ? MSH_VOLUME : - (dim == 2) ? MSH_SURF_PLAN : - (dim == 1) ? MSH_SEGM_LINE : MSH_POINT; + (dim == 2) ? MSH_SURF_PLAN : + (dim == 1) ? MSH_SEGM_LINE : + MSH_POINT; s.Num = tag; List_Add(in, &s); } @@ -814,8 +817,9 @@ bool GEO_Internals::_transform(int mode, int tag = dimTags[i].second; Shape s; s.Type = (dim == 3) ? MSH_VOLUME : - (dim == 2) ? MSH_SURF_PLAN : - (dim == 1) ? MSH_SEGM_LINE : MSH_POINT; + (dim == 2) ? MSH_SURF_PLAN : + (dim == 1) ? MSH_SEGM_LINE : + MSH_POINT; s.Num = tag; List_Add(list, &s); } @@ -1361,8 +1365,7 @@ void GEO_Internals::synchronize(GModel *model, bool resetMeshAttributes) // entities, which are also stored in GEO_Internals so that they can be // combined with GEO entities; but they are not GmshModel entities. std::vector<std::pair<int, int> > toRemove; - for(GModel::viter it = model->firstVertex(); it != model->lastVertex(); - ++it) { + for(auto it = model->firstVertex(); it != model->lastVertex(); ++it) { GVertex *gv = *it; if(gv->getNativeType() == GEntity::GmshModel || gv->getNativeType() == GEntity::UnknownModel) { @@ -1370,7 +1373,7 @@ void GEO_Internals::synchronize(GModel *model, bool resetMeshAttributes) toRemove.push_back(std::pair<int, int>(0, gv->tag())); } } - for(GModel::eiter it = model->firstEdge(); it != model->lastEdge(); ++it) { + for(auto it = model->firstEdge(); it != model->lastEdge(); ++it) { GEdge *ge = *it; if(ge->getNativeType() == GEntity::GmshModel || ge->getNativeType() == GEntity::UnknownModel) { @@ -1378,7 +1381,7 @@ void GEO_Internals::synchronize(GModel *model, bool resetMeshAttributes) toRemove.push_back(std::pair<int, int>(1, ge->tag())); } } - for(GModel::fiter it = model->firstFace(); it != model->lastFace(); ++it) { + for(auto it = model->firstFace(); it != model->lastFace(); ++it) { GFace *gf = *it; if(gf->getNativeType() == GEntity::GmshModel || gf->getNativeType() == GEntity::UnknownModel) { @@ -1386,8 +1389,7 @@ void GEO_Internals::synchronize(GModel *model, bool resetMeshAttributes) toRemove.push_back(std::pair<int, int>(2, gf->tag())); } } - for(GModel::riter it = model->firstRegion(); it != model->lastRegion(); - ++it) { + for(auto it = model->firstRegion(); it != model->lastRegion(); ++it) { GRegion *gr = *it; if(gr->getNativeType() == GEntity::GmshModel || gr->getNativeType() == GEntity::UnknownModel) { @@ -1509,18 +1511,17 @@ void GEO_Internals::synchronize(GModel *model, bool resetMeshAttributes) case MSH_PHYSICAL_VOLUME: ge = model->getRegionByTag(tag); break; } int pnum = CTX::instance()->geom.orientedPhysicals ? - (gmsh_sign(num) * p->Num) : - p->Num; + (gmsh_sign(num) * p->Num) : + p->Num; if(ge && std::find(ge->physicals.begin(), ge->physicals.end(), pnum) == - ge->physicals.end()) + ge->physicals.end()) ge->physicals.push_back(pnum); } } // we might want to store mesh compounds directly in GModel; but this is OK // for now. - for(std::multimap<int, std::vector<int> >::iterator it = _meshCompounds.begin(); - it != _meshCompounds.end(); ++it) { + for(auto it = _meshCompounds.begin(); it != _meshCompounds.end(); ++it) { int dim = it->first; std::vector<int> compound = it->second; std::vector<GEntity *> ents; @@ -1710,8 +1711,7 @@ static bool skipFace(GFace *gf) { if(gf->physicals.size()) return false; std::list<GRegion *> regions(gf->regions()); - for(std::list<GRegion *>::iterator itr = regions.begin(); - itr != regions.end(); itr++) { + for(auto itr = regions.begin(); itr != regions.end(); itr++) { if(!skipRegion(*itr)) return false; } return true; @@ -1721,8 +1721,7 @@ static bool skipEdge(GEdge *ge) { if(ge->physicals.size()) return false; std::vector<GFace *> faces(ge->faces()); - for(std::vector<GFace *>::iterator itf = faces.begin(); itf != faces.end(); - itf++) { + for(auto itf = faces.begin(); itf != faces.end(); itf++) { if(!skipFace(*itf)) return false; } return true; @@ -1732,8 +1731,7 @@ static bool skipVertex(GVertex *gv) { if(gv->physicals.size()) return false; std::vector<GEdge *> const &edges = gv->edges(); - for(std::vector<GEdge *>::const_iterator ite = edges.begin(); - ite != edges.end(); ite++) { + for(auto ite = edges.begin(); ite != edges.end(); ite++) { if(!skipEdge(*ite)) return false; } return true; @@ -1750,7 +1748,7 @@ int GModel::writeGEO(const std::string &name, bool printLabels, std::map<double, std::string> meshSizeParameters; int cpt = 0; - for(viter it = firstVertex(); it != lastVertex(); it++) { + for(auto it = firstVertex(); it != lastVertex(); it++) { double val = (*it)->prescribedMeshSizeAtVertex(); if(meshSizeParameters.find(val) == meshSizeParameters.end()) { std::ostringstream paramName; @@ -1760,27 +1758,25 @@ int GModel::writeGEO(const std::string &name, bool printLabels, } } - for(viter it = firstVertex(); it != lastVertex(); it++) { + for(auto it = firstVertex(); it != lastVertex(); it++) { double val = (*it)->prescribedMeshSizeAtVertex(); if(!onlyPhysicals || !skipVertex(*it)) (*it)->writeGEO(fp, meshSizeParameters[val]); } - for(eiter it = firstEdge(); it != lastEdge(); it++) { + for(auto it = firstEdge(); it != lastEdge(); it++) { if(!onlyPhysicals || !skipEdge(*it)) (*it)->writeGEO(fp); } - for(fiter it = firstFace(); it != lastFace(); it++) { + for(auto it = firstFace(); it != lastFace(); it++) { if(!onlyPhysicals || !skipFace(*it)) (*it)->writeGEO(fp); } - for(riter it = firstRegion(); it != lastRegion(); it++) { + for(auto it = firstRegion(); it != lastRegion(); it++) { if(!onlyPhysicals || !skipRegion(*it)) (*it)->writeGEO(fp); } std::map<int, std::string> labels; #if defined(HAVE_PARSER) // get "old-style" labels from parser - for(std::map<std::string, gmsh_yysymbol>::iterator it = - gmsh_yysymbols.begin(); - it != gmsh_yysymbols.end(); ++it) + for(auto it = gmsh_yysymbols.begin(); it != gmsh_yysymbols.end(); ++it) for(std::size_t i = 0; i < it->second.value.size(); i++) labels[(int)it->second.value[i]] = it->first; #endif @@ -1807,13 +1803,13 @@ int GModel::exportDiscreteGEOInternals() if(_geo_internals) delete _geo_internals; _geo_internals = new GEO_Internals; - for(viter it = firstVertex(); it != lastVertex(); it++) { + for(auto it = firstVertex(); it != lastVertex(); it++) { Vertex *v = CreateVertex((*it)->tag(), (*it)->x(), (*it)->y(), (*it)->z(), (*it)->prescribedMeshSizeAtVertex(), 1.0); Tree_Add(_geo_internals->Points, &v); } - for(eiter it = firstEdge(); it != lastEdge(); it++) { + for(auto it = firstEdge(); it != lastEdge(); it++) { if((*it)->geomType() == GEntity::DiscreteCurve) { bool ok = true; Curve *c = CreateCurve((*it)->tag(), MSH_SEGM_DISCRETE, 1, NULL, NULL, -1, @@ -1853,17 +1849,14 @@ int GModel::exportDiscreteGEOInternals() } } - for(fiter it = firstFace(); it != lastFace(); it++) { + for(auto it = firstFace(); it != lastFace(); it++) { if((*it)->geomType() == GEntity::DiscreteSurface) { Surface *s = CreateSurface((*it)->tag(), MSH_SURF_DISCRETE); std::vector<GEdge *> const &edges = (*it)->edges(); s->Generatrices = List_Create(edges.size() + 1, 1, sizeof(Curve *)); - for(std::vector<GEdge *>::const_iterator ite = edges.begin(); - ite != edges.end(); ite++) { + for(auto ite = edges.begin(); ite != edges.end(); ite++) { Curve *c = FindCurve((*ite)->tag()); - if(c) { - List_Add(s->Generatrices, &c); - } + if(c) { List_Add(s->Generatrices, &c); } else { Msg::Error("Unknown GEO curve %d", (*ite)->tag()); } @@ -1873,17 +1866,14 @@ int GModel::exportDiscreteGEOInternals() } } - for(riter it = firstRegion(); it != lastRegion(); it++) { + for(auto it = firstRegion(); it != lastRegion(); it++) { if((*it)->geomType() == GEntity::DiscreteVolume) { Volume *v = CreateVolume((*it)->tag(), MSH_VOLUME_DISCRETE); std::vector<GFace *> faces = (*it)->faces(); v->Surfaces = List_Create(faces.size() + 1, 1, sizeof(Surface *)); - for(std::vector<GFace *>::iterator itf = faces.begin(); - itf != faces.end(); itf++) { + for(auto itf = faces.begin(); itf != faces.end(); itf++) { Surface *s = FindSurface((*itf)->tag()); - if(s) { - List_Add(v->Surfaces, &s); - } + if(s) { List_Add(v->Surfaces, &s); } else { Msg::Error("Unknown GEO surface %d", (*itf)->tag()); } diff --git a/Geo/GModelIO_INP.cpp b/Geo/GModelIO_INP.cpp index 6016fef85f1e35f70b33d5162823d39975babaae..828075c183c9bcdb052b1857106cb3581b516577 100644 --- a/Geo/GModelIO_INP.cpp +++ b/Geo/GModelIO_INP.cpp @@ -21,11 +21,10 @@ static void writeElementsINP(FILE *fp, GEntity *ge, std::vector<T *> &elements, if(elements.size() && (saveAll || ge->physicals.size())) { const char *typ = elements[0]->getStringForINP(); if(typ) { - const char *str = - (ge->dim() == 3) ? "Volume" : - (ge->dim() == 2) ? "Surface" : - (ge->dim() == 1) ? "Line" : - "Point"; // currently unused + const char *str = (ge->dim() == 3) ? "Volume" : + (ge->dim() == 2) ? "Surface" : + (ge->dim() == 1) ? "Line" : + "Point"; // currently unused fprintf(fp, "*ELEMENT, type=%s, ELSET=%s%d\n", typ, str, ge->tag()); for(std::size_t i = 0; i < elements.size(); i++) elements[i]->writeINP(fp, elements[i]->getNum()); @@ -42,7 +41,7 @@ static std::string physicalName(GModel *m, int dim, int num) (dim == 3) ? "PhysicalVolume" : (dim == 2) ? "PhysicalSurface" : (dim == 1) ? "PhysicalLine" : - "PhysicalPoint", + "PhysicalPoint", num); name = tmp; } @@ -60,7 +59,7 @@ static std::string elementaryName(GModel *m, int dim, int num) (dim == 3) ? "Volume" : (dim == 2) ? "Surface" : (dim == 1) ? "Line" : - "Point", + "Point", num); name = tmp; } @@ -94,17 +93,17 @@ int GModel::writeINP(const std::string &name, bool saveAll, entities[i]->mesh_vertices[j]->writeINP(fp, scalingFactor); fprintf(fp, "******* E L E M E N T S *************\n"); - for(viter it = firstVertex(); it != lastVertex(); ++it) { + for(auto it = firstVertex(); it != lastVertex(); ++it) { writeElementsINP(fp, *it, (*it)->points, saveAll); } - for(eiter it = firstEdge(); it != lastEdge(); ++it) { + for(auto it = firstEdge(); it != lastEdge(); ++it) { writeElementsINP(fp, *it, (*it)->lines, saveAll); } - for(fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { writeElementsINP(fp, *it, (*it)->triangles, saveAll); writeElementsINP(fp, *it, (*it)->quadrangles, saveAll); } - for(riter it = firstRegion(); it != lastRegion(); ++it) { + for(auto it = firstRegion(); it != lastRegion(); ++it) { writeElementsINP(fp, *it, (*it)->tetrahedra, saveAll); writeElementsINP(fp, *it, (*it)->hexahedra, saveAll); writeElementsINP(fp, *it, (*it)->prisms, saveAll); @@ -118,8 +117,7 @@ int GModel::writeINP(const std::string &name, bool saveAll, // save elements sets for each physical group (currently we don't save point // elements: is there this concept in Abaqus?) for(int dim = 1; dim <= 3; dim++) { - for(std::map<int, std::vector<GEntity *> >::iterator it = groups[dim].begin(); - it != groups[dim].end(); it++) { + for(auto it = groups[dim].begin(); it != groups[dim].end(); it++) { std::vector<GEntity *> &entities = it->second; fprintf(fp, "*ELSET,ELSET=%s\n", physicalName(this, dim, it->first).c_str()); @@ -141,8 +139,7 @@ int GModel::writeINP(const std::string &name, bool saveAll, // save a node set for each physical group (here we include node sets on // physical points) for(int dim = 0; dim <= 3; dim++) { - for(std::map<int, std::vector<GEntity *> >::iterator it = groups[dim].begin(); - it != groups[dim].end(); it++) { + for(auto it = groups[dim].begin(); it != groups[dim].end(); it++) { std::set<MVertex *, MVertexPtrLessThan> nodes; std::vector<GEntity *> &entities = it->second; for(std::size_t i = 0; i < entities.size(); i++) { @@ -155,8 +152,7 @@ int GModel::writeINP(const std::string &name, bool saveAll, fprintf(fp, "*NSET,NSET=%s\n", physicalName(this, dim, it->first).c_str()); int n = 0; - for(std::set<MVertex *, MVertexPtrLessThan>::iterator it2 = nodes.begin(); - it2 != nodes.end(); it2++) { + for(auto it2 = nodes.begin(); it2 != nodes.end(); it2++) { if(n && !(n % 10)) fprintf(fp, "\n"); fprintf(fp, "%ld, ", (*it2)->getIndex()); n++; @@ -176,18 +172,17 @@ int GModel::writeINP(const std::string &name, bool saveAll, for(std::size_t k = 0; k < e->getNumVertices(); k++) nodes.insert(e->getVertex(k)); } - fprintf(fp, "*NSET,NSET=%s\n", - elementaryName(this, entities[i]->dim(), entities[i]->tag()).c_str()); + fprintf( + fp, "*NSET,NSET=%s\n", + elementaryName(this, entities[i]->dim(), entities[i]->tag()).c_str()); int n = 0; - for(std::set<MVertex *, MVertexPtrLessThan>::iterator it2 = nodes.begin(); - it2 != nodes.end(); it2++) { + for(auto it2 = nodes.begin(); it2 != nodes.end(); it2++) { if(n && !(n % 10)) fprintf(fp, "\n"); fprintf(fp, "%ld, ", (*it2)->getIndex()); n++; } fprintf(fp, "\n"); } - } fclose(fp); diff --git a/Geo/GModelIO_IR3.cpp b/Geo/GModelIO_IR3.cpp index 01fed05867901cd00fa1b5944e669c13772f193a..b95a3578cbe1c136817549d5f7802a4a7ce54971 100644 --- a/Geo/GModelIO_IR3.cpp +++ b/Geo/GModelIO_IR3.cpp @@ -19,9 +19,9 @@ int GModel::writeIR3(const std::string &name, int elementTagType, bool saveAll, if(noPhysicalGroups()) saveAll = true; int numVertices = indexMeshVertices(saveAll), num2D = 0, num3D = 0; - for(fiter it = firstFace(); it != lastFace(); ++it) + for(auto it = firstFace(); it != lastFace(); ++it) if(saveAll || (*it)->physicals.size()) num2D += (*it)->getNumMeshElements(); - for(riter it = firstRegion(); it != lastRegion(); ++it) + for(auto it = firstRegion(); it != lastRegion(); ++it) if(saveAll || (*it)->physicals.size()) num3D += (*it)->getNumMeshElements(); fprintf(fp, "33\n"); @@ -43,7 +43,7 @@ int GModel::writeIR3(const std::string &name, int elementTagType, bool saveAll, entities[i]->mesh_vertices[j]->z() * scalingFactor); int iElement = 1; - for(fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { int numPhys = (*it)->physicals.size(); if(saveAll || numPhys) for(std::size_t i = 0; i < (*it)->getNumMeshElements(); i++) @@ -53,7 +53,7 @@ int GModel::writeIR3(const std::string &name, int elementTagType, bool saveAll, } iElement = 1; - for(riter it = firstRegion(); it != lastRegion(); ++it) { + for(auto it = firstRegion(); it != lastRegion(); ++it) { int numPhys = (*it)->physicals.size(); if(saveAll || numPhys) for(std::size_t i = 0; i < (*it)->getNumMeshElements(); i++) diff --git a/Geo/GModelIO_KEY.cpp b/Geo/GModelIO_KEY.cpp index 250e004654bed8a403f2d26c49fe51327df876b2..676b15456f7266b7e90d47be6eeda835042f1782 100644 --- a/Geo/GModelIO_KEY.cpp +++ b/Geo/GModelIO_KEY.cpp @@ -21,7 +21,8 @@ static std::string physicalName(GModel *m, int dim, int num) char tmp[256]; sprintf(tmp, "%s%d", (dim == 3) ? "PhysicalVolume" : - (dim == 2) ? "PhysicalSurface" : "PhysicalLine", + (dim == 2) ? "PhysicalSurface" : + "PhysicalLine", num); name = tmp; } @@ -73,20 +74,20 @@ int GModel::writeKEY(const std::string &name, int saveAll, entities[i]->mesh_vertices[j]->writeKEY(fp, scalingFactor); if(!(saveAll & 0x2)) // save or ignore points (not in GUI) - for(viter it = firstVertex(); it != lastVertex(); ++it) { + for(auto it = firstVertex(); it != lastVertex(); ++it) { writeElementsKEY(fp, *it, (*it)->points, saveAll & 0x1); } if(!(saveAll & 0x8)) // save or ignore line - for(eiter it = firstEdge(); it != lastEdge(); ++it) { + for(auto it = firstEdge(); it != lastEdge(); ++it) { writeElementsKEY(fp, *it, (*it)->lines, saveAll & 0x4); } if(!(saveAll & 0x20)) // save or ignore surface - for(fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { writeElementsKEY(fp, *it, (*it)->triangles, saveAll & 0x10); writeElementsKEY(fp, *it, (*it)->quadrangles, saveAll & 0x10); } if(!(saveAll & 0x80)) // save or ignore volume - for(riter it = firstRegion(); it != lastRegion(); ++it) { + for(auto it = firstRegion(); it != lastRegion(); ++it) { writeElementsKEY(fp, *it, (*it)->tetrahedra, saveAll & 0x40); writeElementsKEY(fp, *it, (*it)->hexahedra, saveAll & 0x40); writeElementsKEY(fp, *it, (*it)->prisms, saveAll & 0x40); @@ -101,20 +102,17 @@ int GModel::writeKEY(const std::string &name, int saveAll, if(saveGroupsOfNodes & 0x2) { for(int dim = 0; dim <= 3; dim++) { if(saveAll & (0x2 << (2 * dim))) continue; // elements are ignored - for(std::map<int, std::vector<GEntity *> >::iterator it = - groups[dim].begin(); - it != groups[dim].end(); it++) { + for(auto it = groups[dim].begin(); it != groups[dim].end(); it++) { std::vector<GEntity *> &entities = it->second; int n = 0; for(std::size_t i = 0; i < entities.size(); i++) { for(std::size_t j = 0; j < entities[i]->getNumMeshElements(); j++) { MElement *e = entities[i]->getMeshElement(j); if(!n) { - const char *str = (e->getDim() == 3) ? - "SOLID" : - (e->getDim() == 2) ? - "SHELL" : - (e->getDim() == 1) ? "BEAM" : "NODE"; + const char *str = (e->getDim() == 3) ? "SOLID" : + (e->getDim() == 2) ? "SHELL" : + (e->getDim() == 1) ? "BEAM" : + "NODE"; fprintf(fp, "*SET_%s_LIST\n$# %s\n%d", str, physicalName(this, dim, it->first).c_str(), ++setid); } @@ -133,9 +131,7 @@ int GModel::writeKEY(const std::string &name, int saveAll, // save node sets for each physical group, for easier load/b.c. if(saveGroupsOfNodes & 0x1) { for(int dim = 1; dim <= 3; dim++) { - for(std::map<int, std::vector<GEntity *> >::iterator it = - groups[dim].begin(); - it != groups[dim].end(); it++) { + for(auto it = groups[dim].begin(); it != groups[dim].end(); it++) { std::set<MVertex *> nodes; std::vector<GEntity *> &entities = it->second; for(std::size_t i = 0; i < entities.size(); i++) { @@ -148,8 +144,7 @@ int GModel::writeKEY(const std::string &name, int saveAll, fprintf(fp, "*SET_NODE_LIST\n$# %s\n%d", physicalName(this, dim, it->first).c_str(), ++setid); int n = 0; - for(std::set<MVertex *>::iterator it2 = nodes.begin(); - it2 != nodes.end(); it2++) { + for(auto it2 = nodes.begin(); it2 != nodes.end(); it2++) { if(!(n % 8)) fprintf(fp, "\n%ld", (*it2)->getIndex()); else diff --git a/Geo/GModelIO_MAIL.cpp b/Geo/GModelIO_MAIL.cpp index b819f28bee7701cdb61e43a2cdc37365a45997e8..f0d0e5d68cd22397c60f81650720e2971d6627e0 100644 --- a/Geo/GModelIO_MAIL.cpp +++ b/Geo/GModelIO_MAIL.cpp @@ -22,7 +22,7 @@ int GModel::writeMAIL(const std::string &name, bool saveAll, if(noPhysicalGroups()) saveAll = true; int numVertices = indexMeshVertices(saveAll), numTriangles = 0; - for(fiter it = firstFace(); it != lastFace(); ++it) + for(auto it = firstFace(); it != lastFace(); ++it) if(saveAll || (*it)->physicals.size()) numTriangles += (*it)->triangles.size(); @@ -38,7 +38,7 @@ int GModel::writeMAIL(const std::string &name, bool saveAll, } } - for(fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { if(saveAll || (*it)->physicals.size()) { for(std::size_t i = 0; i < (*it)->triangles.size(); i++) { MTriangle *t = (*it)->triangles[i]; @@ -49,7 +49,7 @@ int GModel::writeMAIL(const std::string &name, bool saveAll, } // TODO write edges (with signs) - for(fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { if(saveAll || (*it)->physicals.size()) { for(std::size_t i = 0; i < (*it)->triangles.size(); i++) { // MTriangle *t = (*it)->triangles[i]; diff --git a/Geo/GModelIO_MED.cpp b/Geo/GModelIO_MED.cpp index c8fdc773fa2f25ab35072619d7c717f0af066baa..8e582e9a47e2c04d31fe6aaa225812a4d88cebae 100644 --- a/Geo/GModelIO_MED.cpp +++ b/Geo/GModelIO_MED.cpp @@ -198,41 +198,38 @@ int med2mshNodeIndex(med_geometrie_element med, int k) case MED_PYRA5: return msh2medNodeIndex(med2mshElementType(med), k); // symmetric case MED_HEXA20: { - static const int map[20] = {0, 3, 2, 1, 4, 7, 6, 5, 11, 8, 16, - 10, 19, 9, 18, 17, 15, 12, 14, 13}; + static const int map[20] = {0, 3, 2, 1, 4, 7, 6, 5, 11, 8, + 16, 10, 19, 9, 18, 17, 15, 12, 14, 13}; return map[k]; } #if(MED_MAJOR_NUM >= 3) case MED_HEXA27: { - static const int map[27] = {0, 3, 2, 1, 4, 7, 6, 5, 11, 8, 16, - 10, 19, 9, 18, 17, 15, 12, 14, 13, - 20, 24, 21, 23, 22, 25, 26}; + static const int map[27] = {0, 3, 2, 1, 4, 7, 6, 5, 11, + 8, 16, 10, 19, 9, 18, 17, 15, 12, + 14, 13, 20, 24, 21, 23, 22, 25, 26}; return map[k]; } #endif case MED_PENTA15: { - static const int map[15] = {0, 2, 1, 3, 5, 4, - 8, 6, 12, 7, 14, 13, 11, 9, 10}; + static const int map[15] = {0, 2, 1, 3, 5, 4, 8, 6, + 12, 7, 14, 13, 11, 9, 10}; return map[k]; } #if(MED_MAJOR_NUM >= 4) case MED_PENTA18: { - static const int map[18] = {0, 2, 1, 3, 5, 4, - 8, 6, 12, 7, 14, 13, 11, 9, 10, - 17, 15, 16}; + static const int map[18] = {0, 2, 1, 3, 5, 4, 8, 6, 12, + 7, 14, 13, 11, 9, 10, 17, 15, 16}; return map[k]; } #endif case MED_PYRA13: { - static const int map[13] = {0, 3, 2, 1, - 4, 8, 5, 9, 7, 12, 6, 11, 10}; + static const int map[13] = {0, 3, 2, 1, 4, 8, 5, 9, 7, 12, 6, 11, 10}; return map[k]; } default: Msg::Error("Unknown MED element type"); return k; } } - int GModel::readMED(const std::string &name) { med_idt fid = MEDouvrir((char *)name.c_str(), MED_LECTURE); @@ -608,11 +605,10 @@ int GModel::readMED(const std::string &name, int meshIndex) } template <class T> -static void fillElementsMED(med_int family, std::vector<T *> &elements, - std::vector<med_int> &conn, - std::vector<med_int> &fam, - std::vector<med_int> &tags, - med_geometrie_element &type) +static void +fillElementsMED(med_int family, std::vector<T *> &elements, + std::vector<med_int> &conn, std::vector<med_int> &fam, + std::vector<med_int> &tags, med_geometrie_element &type) { if(elements.empty()) return; int msh = elements[0]->getTypeForMSH(); @@ -788,8 +784,8 @@ int GModel::writeMED(const std::string &name, bool saveAll, char coordUnit[3 * MED_TAILLE_PNOM + 1] = "unknown unknown unknown "; if(MEDnoeudsEcr(fid, meshName, (med_int)3, &coord[0], MED_FULL_INTERLACE, - MED_CART, coordName, coordUnit, 0, MED_FAUX, &tags[0], MED_VRAI, - &fam[0], (med_int)fam.size()) < 0) + MED_CART, coordName, coordUnit, 0, MED_FAUX, &tags[0], + MED_VRAI, &fam[0], (med_int)fam.size()) < 0) #endif Msg::Error("Could not write nodes"); } @@ -799,7 +795,7 @@ int GModel::writeMED(const std::string &name, bool saveAll, { // points med_geometrie_element typ = MED_NONE; std::vector<med_int> conn, fam, tags; - for(viter it = firstVertex(); it != lastVertex(); it++) + for(auto it = firstVertex(); it != lastVertex(); it++) if(saveAll || (*it)->physicals.size()) fillElementsMED(families[*it], (*it)->points, conn, fam, tags, typ); writeElementsMED(fid, meshName, conn, fam, tags, typ); @@ -807,7 +803,7 @@ int GModel::writeMED(const std::string &name, bool saveAll, { // lines med_geometrie_element typ = MED_NONE; std::vector<med_int> conn, fam, tags; - for(eiter it = firstEdge(); it != lastEdge(); it++) + for(auto it = firstEdge(); it != lastEdge(); it++) if(saveAll || (*it)->physicals.size()) fillElementsMED(families[*it], (*it)->lines, conn, fam, tags, typ); writeElementsMED(fid, meshName, conn, fam, tags, typ); @@ -815,39 +811,43 @@ int GModel::writeMED(const std::string &name, bool saveAll, { // triangles med_geometrie_element typ = MED_NONE; std::vector<med_int> conn, fam, tags; - for(fiter it = firstFace(); it != lastFace(); it++) + for(auto it = firstFace(); it != lastFace(); it++) if(saveAll || (*it)->physicals.size()) - fillElementsMED(families[*it], (*it)->triangles, conn, fam, tags, typ); + fillElementsMED(families[*it], (*it)->triangles, conn, fam, tags, + typ); writeElementsMED(fid, meshName, conn, fam, tags, typ); } { // quads med_geometrie_element typ = MED_NONE; std::vector<med_int> conn, fam, tags; - for(fiter it = firstFace(); it != lastFace(); it++) + for(auto it = firstFace(); it != lastFace(); it++) if(saveAll || (*it)->physicals.size()) - fillElementsMED(families[*it], (*it)->quadrangles, conn, fam, tags, typ); + fillElementsMED(families[*it], (*it)->quadrangles, conn, fam, tags, + typ); writeElementsMED(fid, meshName, conn, fam, tags, typ); } { // tets med_geometrie_element typ = MED_NONE; std::vector<med_int> conn, fam, tags; - for(riter it = firstRegion(); it != lastRegion(); it++) + for(auto it = firstRegion(); it != lastRegion(); it++) if(saveAll || (*it)->physicals.size()) - fillElementsMED(families[*it], (*it)->tetrahedra, conn, fam, tags, typ); + fillElementsMED(families[*it], (*it)->tetrahedra, conn, fam, tags, + typ); writeElementsMED(fid, meshName, conn, fam, tags, typ); } { // hexas med_geometrie_element typ = MED_NONE; std::vector<med_int> conn, fam, tags; - for(riter it = firstRegion(); it != lastRegion(); it++) + for(auto it = firstRegion(); it != lastRegion(); it++) if(saveAll || (*it)->physicals.size()) - fillElementsMED(families[*it], (*it)->hexahedra, conn, fam, tags, typ); + fillElementsMED(families[*it], (*it)->hexahedra, conn, fam, tags, + typ); writeElementsMED(fid, meshName, conn, fam, tags, typ); } { // prisms med_geometrie_element typ = MED_NONE; std::vector<med_int> conn, fam, tags; - for(riter it = firstRegion(); it != lastRegion(); it++) + for(auto it = firstRegion(); it != lastRegion(); it++) if(saveAll || (*it)->physicals.size()) fillElementsMED(families[*it], (*it)->prisms, conn, fam, tags, typ); writeElementsMED(fid, meshName, conn, fam, tags, typ); @@ -855,7 +855,7 @@ int GModel::writeMED(const std::string &name, bool saveAll, { // pyramids med_geometrie_element typ = MED_NONE; std::vector<med_int> conn, fam, tags; - for(riter it = firstRegion(); it != lastRegion(); it++) + for(auto it = firstRegion(); it != lastRegion(); it++) if(saveAll || (*it)->physicals.size()) fillElementsMED(families[*it], (*it)->pyramids, conn, fam, tags, typ); writeElementsMED(fid, meshName, conn, fam, tags, typ); diff --git a/Geo/GModelIO_MESH.cpp b/Geo/GModelIO_MESH.cpp index 7f8c82356f2698d9cb07ec90396e5ddff2e9f077..31d6734862c6cec8986d2c1df195058c8d3c4bfa 100644 --- a/Geo/GModelIO_MESH.cpp +++ b/Geo/GModelIO_MESH.cpp @@ -265,18 +265,16 @@ int GModel::writeMESH(const std::string &name, int elementTagType, bool saveAll, int numEdges = 0, numTriangles = 0, numQuadrangles = 0; int numTetrahedra = 0, numHexahedra = 0; - for(eiter it = firstEdge(); it != lastEdge(); ++it) { - if(saveAll || (*it)->physicals.size()) { - numEdges += (*it)->lines.size(); - } + for(auto it = firstEdge(); it != lastEdge(); ++it) { + if(saveAll || (*it)->physicals.size()) { numEdges += (*it)->lines.size(); } } - for(fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { if(saveAll || (*it)->physicals.size()) { numTriangles += (*it)->triangles.size(); numQuadrangles += (*it)->quadrangles.size(); } } - for(riter it = firstRegion(); it != lastRegion(); ++it) { + for(auto it = firstRegion(); it != lastRegion(); ++it) { if(saveAll || (*it)->physicals.size()) { numTetrahedra += (*it)->tetrahedra.size(); numHexahedra += (*it)->hexahedra.size(); @@ -289,7 +287,7 @@ int GModel::writeMESH(const std::string &name, int elementTagType, bool saveAll, else fprintf(fp, " Edges\n"); fprintf(fp, " %d\n", numEdges); - for(eiter it = firstEdge(); it != lastEdge(); ++it) { + for(auto it = firstEdge(); it != lastEdge(); ++it) { int numPhys = (*it)->physicals.size(); if(saveAll || numPhys) { for(std::size_t i = 0; i < (*it)->lines.size(); i++) @@ -304,7 +302,7 @@ int GModel::writeMESH(const std::string &name, int elementTagType, bool saveAll, else fprintf(fp, " Triangles\n"); fprintf(fp, " %d\n", numTriangles); - for(fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { int numPhys = (*it)->physicals.size(); if(saveAll || numPhys) { for(std::size_t i = 0; i < (*it)->triangles.size(); i++) @@ -316,7 +314,7 @@ int GModel::writeMESH(const std::string &name, int elementTagType, bool saveAll, if(numQuadrangles) { fprintf(fp, " Quadrilaterals\n"); fprintf(fp, " %d\n", numQuadrangles); - for(fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { int numPhys = (*it)->physicals.size(); if(saveAll || numPhys) { for(std::size_t i = 0; i < (*it)->quadrangles.size(); i++) @@ -331,7 +329,7 @@ int GModel::writeMESH(const std::string &name, int elementTagType, bool saveAll, else fprintf(fp, " Tetrahedra\n"); fprintf(fp, " %d\n", numTetrahedra); - for(riter it = firstRegion(); it != lastRegion(); ++it) { + for(auto it = firstRegion(); it != lastRegion(); ++it) { int numPhys = (*it)->physicals.size(); if(saveAll || numPhys) { for(std::size_t i = 0; i < (*it)->tetrahedra.size(); i++) @@ -343,7 +341,7 @@ int GModel::writeMESH(const std::string &name, int elementTagType, bool saveAll, if(numHexahedra) { fprintf(fp, " Hexahedra\n"); fprintf(fp, " %d\n", numHexahedra); - for(riter it = firstRegion(); it != lastRegion(); ++it) { + for(auto it = firstRegion(); it != lastRegion(); ++it) { int numPhys = (*it)->physicals.size(); if(saveAll || numPhys) { for(std::size_t i = 0; i < (*it)->hexahedra.size(); i++) diff --git a/Geo/GModelIO_MSH.cpp b/Geo/GModelIO_MSH.cpp index bf59629e4229912f0c217955e6356acd6e3d3511..686e621110befad7f4cbd78128958738c2fb50e5 100644 --- a/Geo/GModelIO_MSH.cpp +++ b/Geo/GModelIO_MSH.cpp @@ -50,13 +50,11 @@ int GModel::readMSH(const std::string &name) return 0; } fclose(fp); - if(version < 3.0){ - return _readMSH2(name); - } - else if(version < 4.0){ + if(version < 3.0) { return _readMSH2(name); } + else if(version < 4.0) { return _readMSH3(name); } - else if(version < 5.0){ + else if(version < 5.0) { return _readMSH4(name); } else { @@ -77,8 +75,7 @@ int GModel::readMSH(const std::string &name) int GModel::writeMSH(const std::string &name, double version, bool binary, bool saveAll, bool saveParametric, double scalingFactor, - int elementStartNum, int saveSinglePartition, - bool append) + int elementStartNum, int saveSinglePartition, bool append) { if(version < 4.0 && getNumPartitions() > 0) { Msg::Warning("Saving a partitioned mesh in a format older than 4.0 may " diff --git a/Geo/GModelIO_MSH2.cpp b/Geo/GModelIO_MSH2.cpp index e7187b7b82dfac9927ad0ca627d25f4c0b3dc6b7..4c88402aa30e8db0875f1ad434f550519f8b630c 100644 --- a/Geo/GModelIO_MSH2.cpp +++ b/Geo/GModelIO_MSH2.cpp @@ -433,7 +433,7 @@ int GModel::_readMSH2(const std::string &name) // search parent element if(parent != 0) { - std::map<int, MElement *>::iterator ite = elems.find(parent); + auto ite = elems.find(parent); if(ite == elems.end()) Msg::Error( "Parent element (ascii) %d not found for element %d of type %d", @@ -442,7 +442,7 @@ int GModel::_readMSH2(const std::string &name) p = ite->second; parents[parent] = p; } - std::set<MElement *>::iterator itpo = parentsOwned.find(p); + auto itpo = parentsOwned.find(p); if(itpo == parentsOwned.end()) { own = true; parentsOwned.insert(p); @@ -453,7 +453,7 @@ int GModel::_readMSH2(const std::string &name) // search domains MElement *doms[2] = {NULL, NULL}; if(dom1) { - std::map<int, MElement *>::iterator ite = elems.find(dom1); + auto ite = elems.find(dom1); if(ite == elems.end()) Msg::Error("Domain element %d not found for element %d", dom1, num); @@ -511,9 +511,9 @@ int GModel::_readMSH2(const std::string &name) int physical = (numTags > 0) ? data[1] : 0; int elementary = (numTags > 1) ? data[2] : 0; int numPartitions = (version >= 2.2 && numTags > 3) ? data[3] : 0; - int partition = (version < 2.2 && numTags > 2) ? - data[3] : - (version >= 2.2 && numTags > 3) ? data[4] : 0; + int partition = (version < 2.2 && numTags > 2) ? data[3] : + (version >= 2.2 && numTags > 3) ? data[4] : + 0; int parent = (version < 2.2 && numTags > 3) || (version >= 2.2 && numPartitions && numTags > 3 + numPartitions) || @@ -540,7 +540,7 @@ int GModel::_readMSH2(const std::string &name) MElement *p = NULL; bool own = false; if(parent) { - std::map<int, MElement *>::iterator ite = elems.find(parent); + auto ite = elems.find(parent); if(ite == elems.end()) Msg::Error( "Parent (binary) element %d not found for element %d", parent, @@ -549,7 +549,7 @@ int GModel::_readMSH2(const std::string &name) p = ite->second; parents[parent] = p; } - std::set<MElement *>::iterator itpo = parentsOwned.find(p); + auto itpo = parentsOwned.find(p); if(itpo == parentsOwned.end()) { own = true; parentsOwned.insert(p); @@ -584,9 +584,7 @@ int GModel::_readMSH2(const std::string &name) MElement *e = ite->second; if(parents.find(num) == parents.end()) { int reg; - if(CTX::instance()->mesh.switchElementTags) { - reg = elemphy[num]; - } + if(CTX::instance()->mesh.switchElementTags) { reg = elemphy[num]; } else { reg = elemreg[num]; } @@ -683,9 +681,7 @@ int GModel::_readMSH2(const std::string &name) } // attempt to (re)create the model topology - if(CTX::instance()->mesh.createTopologyMsh2) { - createTopologyFromMesh(); - } + if(CTX::instance()->mesh.createTopologyMsh2) { createTopologyFromMesh(); } // create new partition entities if the mesh is partitioned if(CTX::instance()->mesh.partitionConvertMsh2 && @@ -702,8 +698,8 @@ static void writeElementMSH(FILE *fp, GModel *model, GEntity *ge, T *ele, int elementary, std::vector<int> &physicals, int parentNum = 0, int dom1Num = 0, int dom2Num = 0) { - if(CTX::instance()->mesh.partitionOldStyleMsh2 && ge->getParentEntity() - && ge->getParentEntity()->dim() > ge->dim()) + if(CTX::instance()->mesh.partitionOldStyleMsh2 && ge->getParentEntity() && + ge->getParentEntity()->dim() > ge->dim()) return; // ignore partition boundaries if(CTX::instance()->mesh.partitionOldStyleMsh2 && @@ -717,8 +713,7 @@ static void writeElementMSH(FILE *fp, GModel *model, GEntity *ge, T *ele, std::pair<std::multimap<MElement *, short>::iterator, std::multimap<MElement *, short>::iterator> itp = model->getGhostCells().equal_range(ele); - for(std::multimap<MElement *, short>::iterator it = itp.first; - it != itp.second; it++) + for(auto it = itp.first; it != itp.second; it++) ghosts.push_back(it->second); } @@ -742,13 +737,13 @@ static void writeElementMSH(FILE *fp, GModel *model, GEntity *ge, T *ele, template <class T> static void writeElementsMSH(FILE *fp, GModel *model, GEntity *ge, - std::vector<T *> &ele, - bool saveAll, int saveSinglePartition, - double version, bool binary, int &num, - int elementary, std::vector<int> &physicals) + std::vector<T *> &ele, bool saveAll, + int saveSinglePartition, double version, + bool binary, int &num, int elementary, + std::vector<int> &physicals) { - if(CTX::instance()->mesh.partitionOldStyleMsh2 && ge->getParentEntity() - && ge->getParentEntity()->dim() > ge->dim()) + if(CTX::instance()->mesh.partitionOldStyleMsh2 && ge->getParentEntity() && + ge->getParentEntity()->dim() > ge->dim()) return; // ignore partition boundaries if(CTX::instance()->mesh.partitionOldStyleMsh2 && @@ -795,8 +790,8 @@ static void writeElementsMSH(FILE *fp, GModel *model, GEntity *ge, static int getNumElementsMSH(GEntity *ge, bool saveAll, int saveSinglePartition) { - if(CTX::instance()->mesh.partitionOldStyleMsh2 && ge->getParentEntity() - && ge->getParentEntity()->dim() > ge->dim()) + if(CTX::instance()->mesh.partitionOldStyleMsh2 && ge->getParentEntity() && + ge->getParentEntity()->dim() > ge->dim()) return 0; // ignore partition boundaries if(CTX::instance()->mesh.partitionOldStyleMsh2 && @@ -820,7 +815,7 @@ static int getNumElementsMSH(GEntity *ge, bool saveAll, int saveSinglePartition) static int getNumElementsMSH(GModel *m, bool saveAll, int saveSinglePartition) { int n = 0; - for(GModel::viter it = m->firstVertex(); it != m->lastVertex(); ++it) { + for(auto it = m->firstVertex(); it != m->lastVertex(); ++it) { n += getNumElementsMSH(*it, saveAll, saveSinglePartition); if(!CTX::instance()->mesh.saveTri) { for(std::size_t i = 0; i < (*it)->points.size(); i++) @@ -828,7 +823,7 @@ static int getNumElementsMSH(GModel *m, bool saveAll, int saveSinglePartition) n += (saveAll ? 1 : (*it)->physicals.size()); } } - for(GModel::eiter it = m->firstEdge(); it != m->lastEdge(); ++it) { + for(auto it = m->firstEdge(); it != m->lastEdge(); ++it) { n += getNumElementsMSH(*it, saveAll, saveSinglePartition); if(!CTX::instance()->mesh.saveTri) { for(std::size_t i = 0; i < (*it)->lines.size(); i++) @@ -836,7 +831,7 @@ static int getNumElementsMSH(GModel *m, bool saveAll, int saveSinglePartition) n += (saveAll ? 1 : (*it)->physicals.size()); } } - for(GModel::fiter it = m->firstFace(); it != m->lastFace(); ++it) { + for(auto it = m->firstFace(); it != m->lastFace(); ++it) { n += getNumElementsMSH(*it, saveAll, saveSinglePartition); if(CTX::instance()->mesh.saveTri) { for(std::size_t i = 0; i < (*it)->polygons.size(); i++) { @@ -853,7 +848,7 @@ static int getNumElementsMSH(GModel *m, bool saveAll, int saveSinglePartition) n += (saveAll ? 1 : (*it)->physicals.size()); } } - for(GModel::riter it = m->firstRegion(); it != m->lastRegion(); ++it) { + for(auto it = m->firstRegion(); it != m->lastRegion(); ++it) { n += getNumElementsMSH(*it, saveAll, saveSinglePartition); if(CTX::instance()->mesh.saveTri) { for(std::size_t i = 0; i < (*it)->polyhedra.size(); i++) { @@ -876,8 +871,8 @@ static int getNumElementsMSH(GModel *m, bool saveAll, int saveSinglePartition) static int _getElementary(GEntity *ge) { - if(CTX::instance()->mesh.partitionOldStyleMsh2 && ge->getParentEntity() - && ge->getParentEntity()->dim() == ge->dim()) { + if(CTX::instance()->mesh.partitionOldStyleMsh2 && ge->getParentEntity() && + ge->getParentEntity()->dim() == ge->dim()) { // hack for backward compatibility of partitioned meshes in MSH2 format: use // elementary tag of parent entity if they are of the same dimension // (i.e. if they are not partition boundaries) @@ -934,7 +929,7 @@ int GModel::_writeMSH2(const std::string &name, double version, bool binary, if(numPhysicalNames()) { fprintf(fp, "$PhysicalNames\n"); fprintf(fp, "%d\n", numPhysicalNames()); - for(piter it = firstPhysicalName(); it != lastPhysicalName(); it++) { + for(auto it = firstPhysicalName(); it != lastPhysicalName(); it++) { std::string name = it->second; if(name.size() > 128) name.resize(128); fprintf(fp, "%d %d \"%s\"\n", it->first.first, it->first.second, @@ -983,111 +978,111 @@ int GModel::_writeMSH2(const std::string &name, double version, bool binary, // parents if(!CTX::instance()->mesh.saveTri) { - for(viter it = firstVertex(); it != lastVertex(); ++it) { + for(auto it = firstVertex(); it != lastVertex(); ++it) { for(std::size_t i = 0; i < (*it)->points.size(); i++) if((*it)->points[i]->ownsParent()) writeElementMSH(fp, this, *it, (*it)->points[i]->getParent(), saveAll, version, binary, num, _getElementary(*it), (*it)->physicals); } - for(eiter it = firstEdge(); it != lastEdge(); ++it) { + for(auto it = firstEdge(); it != lastEdge(); ++it) { for(std::size_t i = 0; i < (*it)->lines.size(); i++) if((*it)->lines[i]->ownsParent()) writeElementMSH(fp, this, *it, (*it)->lines[i]->getParent(), saveAll, version, binary, num, _getElementary(*it), (*it)->physicals); } - for(fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { for(std::size_t i = 0; i < (*it)->triangles.size(); i++) if((*it)->triangles[i]->ownsParent()) - writeElementMSH(fp, this, *it, (*it)->triangles[i]->getParent(), saveAll, - version, binary, num, _getElementary(*it), + writeElementMSH(fp, this, *it, (*it)->triangles[i]->getParent(), + saveAll, version, binary, num, _getElementary(*it), (*it)->physicals); } - for(riter it = firstRegion(); it != lastRegion(); ++it) { + for(auto it = firstRegion(); it != lastRegion(); ++it) { for(std::size_t i = 0; i < (*it)->tetrahedra.size(); i++) if((*it)->tetrahedra[i]->ownsParent()) - writeElementMSH(fp, this, *it, (*it)->tetrahedra[i]->getParent(), saveAll, - version, binary, num, _getElementary(*it), + writeElementMSH(fp, this, *it, (*it)->tetrahedra[i]->getParent(), + saveAll, version, binary, num, _getElementary(*it), (*it)->physicals); } - for(fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { for(std::size_t i = 0; i < (*it)->polygons.size(); i++) if((*it)->polygons[i]->ownsParent()) - writeElementMSH(fp, this, *it, (*it)->polygons[i]->getParent(), saveAll, - version, binary, num, _getElementary(*it), + writeElementMSH(fp, this, *it, (*it)->polygons[i]->getParent(), + saveAll, version, binary, num, _getElementary(*it), (*it)->physicals); } - for(riter it = firstRegion(); it != lastRegion(); ++it) { + for(auto it = firstRegion(); it != lastRegion(); ++it) { for(std::size_t i = 0; i < (*it)->polyhedra.size(); i++) if((*it)->polyhedra[i]->ownsParent()) - writeElementMSH(fp, this, *it, (*it)->polyhedra[i]->getParent(), saveAll, - version, binary, num, _getElementary(*it), + writeElementMSH(fp, this, *it, (*it)->polyhedra[i]->getParent(), + saveAll, version, binary, num, _getElementary(*it), (*it)->physicals); } } // points - for(viter it = firstVertex(); it != lastVertex(); ++it) { + for(auto it = firstVertex(); it != lastVertex(); ++it) { writeElementsMSH(fp, this, *it, (*it)->points, saveAll, saveSinglePartition, version, binary, num, _getElementary(*it), (*it)->physicals); } // lines - for(eiter it = firstEdge(); it != lastEdge(); ++it) { + for(auto it = firstEdge(); it != lastEdge(); ++it) { writeElementsMSH(fp, this, *it, (*it)->lines, saveAll, saveSinglePartition, version, binary, num, _getElementary(*it), (*it)->physicals); } // triangles - for(fiter it = firstFace(); it != lastFace(); ++it) { - writeElementsMSH(fp, this, *it, (*it)->triangles, saveAll, saveSinglePartition, - version, binary, num, _getElementary(*it), - (*it)->physicals); + for(auto it = firstFace(); it != lastFace(); ++it) { + writeElementsMSH(fp, this, *it, (*it)->triangles, saveAll, + saveSinglePartition, version, binary, num, + _getElementary(*it), (*it)->physicals); } // quads - for(fiter it = firstFace(); it != lastFace(); ++it) { - writeElementsMSH(fp, this, *it, (*it)->quadrangles, saveAll, saveSinglePartition, - version, binary, num, _getElementary(*it), - (*it)->physicals); + for(auto it = firstFace(); it != lastFace(); ++it) { + writeElementsMSH(fp, this, *it, (*it)->quadrangles, saveAll, + saveSinglePartition, version, binary, num, + _getElementary(*it), (*it)->physicals); } // polygons - for(fiter it = firstFace(); it != lastFace(); it++) { - writeElementsMSH(fp, this, *it, (*it)->polygons, saveAll, saveSinglePartition, - version, binary, num, _getElementary(*it), - (*it)->physicals); + for(auto it = firstFace(); it != lastFace(); it++) { + writeElementsMSH(fp, this, *it, (*it)->polygons, saveAll, + saveSinglePartition, version, binary, num, + _getElementary(*it), (*it)->physicals); } // tets - for(riter it = firstRegion(); it != lastRegion(); ++it) { - writeElementsMSH(fp, this, *it, (*it)->tetrahedra, saveAll, saveSinglePartition, - version, binary, num, _getElementary(*it), - (*it)->physicals); + for(auto it = firstRegion(); it != lastRegion(); ++it) { + writeElementsMSH(fp, this, *it, (*it)->tetrahedra, saveAll, + saveSinglePartition, version, binary, num, + _getElementary(*it), (*it)->physicals); } // hexas - for(riter it = firstRegion(); it != lastRegion(); ++it) { - writeElementsMSH(fp, this, *it, (*it)->hexahedra, saveAll, saveSinglePartition, - version, binary, num, _getElementary(*it), - (*it)->physicals); + for(auto it = firstRegion(); it != lastRegion(); ++it) { + writeElementsMSH(fp, this, *it, (*it)->hexahedra, saveAll, + saveSinglePartition, version, binary, num, + _getElementary(*it), (*it)->physicals); } // prisms - for(riter it = firstRegion(); it != lastRegion(); ++it) { + for(auto it = firstRegion(); it != lastRegion(); ++it) { writeElementsMSH(fp, this, *it, (*it)->prisms, saveAll, saveSinglePartition, version, binary, num, _getElementary(*it), (*it)->physicals); } // pyramids - for(riter it = firstRegion(); it != lastRegion(); ++it) { - writeElementsMSH(fp, this, *it, (*it)->pyramids, saveAll, saveSinglePartition, - version, binary, num, _getElementary(*it), - (*it)->physicals); + for(auto it = firstRegion(); it != lastRegion(); ++it) { + writeElementsMSH(fp, this, *it, (*it)->pyramids, saveAll, + saveSinglePartition, version, binary, num, + _getElementary(*it), (*it)->physicals); } // polyhedra - for(riter it = firstRegion(); it != lastRegion(); ++it) { - writeElementsMSH(fp, this, *it, (*it)->polyhedra, saveAll, saveSinglePartition, - version, binary, num, _getElementary(*it), - (*it)->physicals); + for(auto it = firstRegion(); it != lastRegion(); ++it) { + writeElementsMSH(fp, this, *it, (*it)->polyhedra, saveAll, + saveSinglePartition, version, binary, num, + _getElementary(*it), (*it)->physicals); } // level set faces - for(fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { for(std::size_t i = 0; i < (*it)->triangles.size(); i++) { MTriangle *t = (*it)->triangles[i]; if(t->getDomain(0)) @@ -1106,7 +1101,7 @@ int GModel::_writeMSH2(const std::string &name, double version, bool binary, } } // level set lines - for(eiter it = firstEdge(); it != lastEdge(); ++it) { + for(auto it = firstEdge(); it != lastEdge(); ++it) { for(std::size_t i = 0; i < (*it)->lines.size(); i++) { MLine *l = (*it)->lines[i]; if(l->getDomain(0)) @@ -1119,9 +1114,7 @@ int GModel::_writeMSH2(const std::string &name, double version, bool binary, if(binary) fprintf(fp, "\n"); - if(version >= 2.0) { - fprintf(fp, "$EndElements\n"); - } + if(version >= 2.0) { fprintf(fp, "$EndElements\n"); } else { fprintf(fp, "$ENDELM\n"); } @@ -1139,8 +1132,7 @@ int GModel::_writePartitionedMSH2(const std::string &baseName, bool binary, { int numElements; int startNum = 0; - for(std::size_t partition = 1; partition <= getNumPartitions(); - partition++) { + for(std::size_t partition = 1; partition <= getNumPartitions(); partition++) { std::ostringstream sstream; sstream << baseName << "_" << partition << ".msh"; diff --git a/Geo/GModelIO_MSH3.cpp b/Geo/GModelIO_MSH3.cpp index 314c5e536f1d69e767baf57e20109e23e45c8210..2c2c2fea41f2119a694eb47e98088fe9d7180d2c 100644 --- a/Geo/GModelIO_MSH3.cpp +++ b/Geo/GModelIO_MSH3.cpp @@ -60,7 +60,7 @@ static void readMSHEntities(FILE *fp, GModel *gm) GVertex *v1 = 0, *v2 = 0; for(int j = 0; j < n; j++) { int tagv; - if(fscanf(fp, "%d", &tagv) != 1){ + if(fscanf(fp, "%d", &tagv) != 1) { delete ge; return; } @@ -83,7 +83,7 @@ static void readMSHEntities(FILE *fp, GModel *gm) std::vector<int> edges, signs; for(int j = 0; j < n; j++) { int tage; - if(fscanf(fp, "%d", &tage) != 1){ + if(fscanf(fp, "%d", &tage) != 1) { delete df; return; } @@ -106,7 +106,7 @@ static void readMSHEntities(FILE *fp, GModel *gm) std::vector<int> faces, signs; for(int j = 0; j < n; j++) { int tagf; - if(fscanf(fp, "%d", &tagf) != 1){ + if(fscanf(fp, "%d", &tagf) != 1) { delete dr; return; } @@ -320,9 +320,7 @@ int GModel::_readMSH3(const std::string &name) } if(swap) SwapBytes((char *)&entity, sizeof(int), 1); } - if(!entity) { - vertex = new MVertex(xyz[0], xyz[1], xyz[2], 0, num); - } + if(!entity) { vertex = new MVertex(xyz[0], xyz[1], xyz[2], 0, num); } else { if(!binary) { if(fscanf(fp, "%d", &dim) != 1) { @@ -569,7 +567,7 @@ static void writeMSHPhysicals(FILE *fp, GEntity *ge) { std::vector<int> phys = ge->physicals; fprintf(fp, "%d ", (int)phys.size()); - for(std::vector<int>::iterator itp = phys.begin(); itp != phys.end(); itp++) + for(auto itp = phys.begin(); itp != phys.end(); itp++) fprintf(fp, "%d ", *itp); } @@ -578,30 +576,28 @@ void writeMSHEntities(FILE *fp, GModel *gm) // also used in MSH2 fprintf(fp, "$Entities\n"); fprintf(fp, "%lu %lu %lu %lu\n", gm->getNumVertices(), gm->getNumEdges(), gm->getNumFaces(), gm->getNumRegions()); - for(GModel::viter it = gm->firstVertex(); it != gm->lastVertex(); ++it) { + for(auto it = gm->firstVertex(); it != gm->lastVertex(); ++it) { fprintf(fp, "%d ", (*it)->tag()); writeMSHPhysicals(fp, *it); fprintf(fp, "\n"); } - for(GModel::eiter it = gm->firstEdge(); it != gm->lastEdge(); ++it) { + for(auto it = gm->firstEdge(); it != gm->lastEdge(); ++it) { std::list<GVertex *> vertices; if((*it)->getBeginVertex()) vertices.push_back((*it)->getBeginVertex()); if((*it)->getEndVertex()) vertices.push_back((*it)->getEndVertex()); fprintf(fp, "%d %d ", (*it)->tag(), (int)vertices.size()); - for(std::list<GVertex *>::iterator itv = vertices.begin(); - itv != vertices.end(); itv++) { + for(auto itv = vertices.begin(); itv != vertices.end(); itv++) { fprintf(fp, "%d ", (*itv)->tag()); } writeMSHPhysicals(fp, *it); fprintf(fp, "\n"); } - for(GModel::fiter it = gm->firstFace(); it != gm->lastFace(); ++it) { + for(auto it = gm->firstFace(); it != gm->lastFace(); ++it) { std::vector<GEdge *> const &edges = (*it)->edges(); std::vector<int> const &ori = (*it)->edgeOrientations(); fprintf(fp, "%d %d ", (*it)->tag(), (int)edges.size()); std::vector<int> tags; - for(std::vector<GEdge *>::const_iterator ite = edges.begin(); - ite != edges.end(); ite++) + for(auto ite = edges.begin(); ite != edges.end(); ite++) tags.push_back((*ite)->tag()); std::vector<int> signs(ori.begin(), ori.end()); @@ -614,13 +610,12 @@ void writeMSHEntities(FILE *fp, GModel *gm) // also used in MSH2 writeMSHPhysicals(fp, *it); fprintf(fp, "\n"); } - for(GModel::riter it = gm->firstRegion(); it != gm->lastRegion(); ++it) { + for(auto it = gm->firstRegion(); it != gm->lastRegion(); ++it) { std::vector<GFace *> faces = (*it)->faces(); std::vector<int> ori = (*it)->faceOrientations(); fprintf(fp, "%d %d ", (*it)->tag(), (int)faces.size()); std::vector<int> tags, signs; - for(std::vector<GFace *>::iterator itf = faces.begin(); itf != faces.end(); - itf++) + for(auto itf = faces.begin(); itf != faces.end(); itf++) tags.push_back((*itf)->tag()); for(std::vector<int>::const_iterator itf = ori.begin(); itf != ori.end(); itf++) @@ -657,8 +652,7 @@ static void writeElementMSH(FILE *fp, GModel *model, MElement *ele, bool binary, std::pair<std::multimap<MElement *, short>::iterator, std::multimap<MElement *, short>::iterator> itp = model->getGhostCells().equal_range(ele); - for(std::multimap<MElement *, short>::iterator it = itp.first; - it != itp.second; it++) + for(auto it = itp.first; it != itp.second; it++) ghosts.push_back(it->second); ele->writeMSH3(fp, binary, elementary, &ghosts); } @@ -684,10 +678,10 @@ void writeMSHPeriodicNodes(FILE *fp, std::vector<GEntity *> &entities, bool renumber, bool saveAll) // also used in MSH2 { int count = 0; - for(std::size_t i = 0; i < entities.size(); i++){ + for(std::size_t i = 0; i < entities.size(); i++) { if(entities[i]->getMeshMaster() != entities[i] && (saveAll || (entities[i]->physicals.size() && - entities[i]->getMeshMaster()->physicals.size()))){ + entities[i]->getMeshMaster()->physicals.size()))) { count++; } } @@ -699,7 +693,7 @@ void writeMSHPeriodicNodes(FILE *fp, std::vector<GEntity *> &entities, GEntity *g_master = g_slave->getMeshMaster(); if(g_slave != g_master && (saveAll || (entities[i]->physicals.size() && - entities[i]->getMeshMaster()->physicals.size()))){ + entities[i]->getMeshMaster()->physicals.size()))) { fprintf(fp, "%d %d %d\n", g_slave->dim(), g_slave->tag(), g_master->tag()); @@ -716,8 +710,7 @@ void writeMSHPeriodicNodes(FILE *fp, std::vector<GEntity *> &entities, g_slave->correspondingHighOrderVertices.end()); fprintf(fp, "%d\n", (int)corrVert.size()); - for(std::map<MVertex *, MVertex *>::iterator it = corrVert.begin(); - it != corrVert.end(); it++) { + for(auto it = corrVert.begin(); it != corrVert.end(); it++) { MVertex *v1 = it->first; MVertex *v2 = it->second; if(renumber) @@ -780,7 +773,7 @@ int GModel::_writeMSH3(const std::string &name, double version, bool binary, if(numPhysicalNames()) { fprintf(fp, "$PhysicalNames\n"); fprintf(fp, "%d\n", numPhysicalNames()); - for(piter it = firstPhysicalName(); it != lastPhysicalName(); it++) { + for(auto it = firstPhysicalName(); it != lastPhysicalName(); it++) { std::string name = it->second; if(name.size() > 254) name.resize(254); fprintf(fp, "%d %d \"%s\"\n", it->first.first, it->first.second, @@ -806,31 +799,31 @@ int GModel::_writeMSH3(const std::string &name, double version, bool binary, _elementIndexCache.clear(); - for(riter it = firstRegion(); it != lastRegion(); ++it) + for(auto it = firstRegion(); it != lastRegion(); ++it) writeElementsMSH(fp, this, *it, (*it)->tetrahedra, saveAll, saveSinglePartition, binary); - for(riter it = firstRegion(); it != lastRegion(); ++it) + for(auto it = firstRegion(); it != lastRegion(); ++it) writeElementsMSH(fp, this, *it, (*it)->hexahedra, saveAll, saveSinglePartition, binary); - for(riter it = firstRegion(); it != lastRegion(); ++it) + for(auto it = firstRegion(); it != lastRegion(); ++it) writeElementsMSH(fp, this, *it, (*it)->prisms, saveAll, saveSinglePartition, binary); - for(riter it = firstRegion(); it != lastRegion(); ++it) + for(auto it = firstRegion(); it != lastRegion(); ++it) writeElementsMSH(fp, this, *it, (*it)->pyramids, saveAll, saveSinglePartition, binary); - for(riter it = firstRegion(); it != lastRegion(); ++it) + for(auto it = firstRegion(); it != lastRegion(); ++it) writeElementsMSH(fp, this, *it, (*it)->trihedra, saveAll, saveSinglePartition, binary); - for(fiter it = firstFace(); it != lastFace(); ++it) + for(auto it = firstFace(); it != lastFace(); ++it) writeElementsMSH(fp, this, *it, (*it)->triangles, saveAll, saveSinglePartition, binary); - for(fiter it = firstFace(); it != lastFace(); ++it) + for(auto it = firstFace(); it != lastFace(); ++it) writeElementsMSH(fp, this, *it, (*it)->quadrangles, saveAll, saveSinglePartition, binary); - for(eiter it = firstEdge(); it != lastEdge(); ++it) + for(auto it = firstEdge(); it != lastEdge(); ++it) writeElementsMSH(fp, this, *it, (*it)->lines, saveAll, saveSinglePartition, binary); - for(viter it = firstVertex(); it != lastVertex(); ++it) + for(auto it = firstVertex(); it != lastVertex(); ++it) writeElementsMSH(fp, this, *it, (*it)->points, saveAll, saveSinglePartition, binary); diff --git a/Geo/GModelIO_MSH4.cpp b/Geo/GModelIO_MSH4.cpp index f470c70fbd9b4a61062a3781e99e7bd5d3c9cee4..0d9eee5808b8313cce045474c9f2cc8e8bb655e6 100644 --- a/Geo/GModelIO_MSH4.cpp +++ b/Geo/GModelIO_MSH4.cpp @@ -1164,9 +1164,7 @@ static bool readMSH4GhostElements(GModel *const model, FILE *fp, bool binary, ghostEntities[partNum] = ge; } - for(std::multimap<std::pair<MElement *, int>, int>::iterator it = - ghostCells.begin(); - it != ghostCells.end(); ++it) { + for(auto it = ghostCells.begin(); it != ghostCells.end(); ++it) { if(it->second >= (int)ghostEntities.size()) { Msg::Error("Invalid partition %d in ghost elements", it->second); return false; @@ -1560,38 +1558,34 @@ static void writeMSH4Entities(GModel *const model, FILE *fp, bool partition, std::set<GVertex *, GEntityPtrLessThan> vertices; if(partition) { - for(GModel::viter it = model->firstVertex(); it != model->lastVertex(); - ++it) { + for(auto it = model->firstVertex(); it != model->lastVertex(); ++it) { if((*it)->geomType() == GEntity::PartitionPoint) vertices.insert(*it); } - for(GModel::eiter it = model->firstEdge(); it != model->lastEdge(); ++it) { + for(auto it = model->firstEdge(); it != model->lastEdge(); ++it) { if((*it)->geomType() == GEntity::PartitionCurve) edges.insert(*it); if((*it)->geomType() == GEntity::GhostCurve) ghost.insert(*it); } - for(GModel::fiter it = model->firstFace(); it != model->lastFace(); ++it) { + for(auto it = model->firstFace(); it != model->lastFace(); ++it) { if((*it)->geomType() == GEntity::PartitionSurface) faces.insert(*it); if((*it)->geomType() == GEntity::GhostSurface) ghost.insert(*it); } - for(GModel::riter it = model->firstRegion(); it != model->lastRegion(); - ++it) { + for(auto it = model->firstRegion(); it != model->lastRegion(); ++it) { if((*it)->geomType() == GEntity::PartitionVolume) regions.insert(*it); if((*it)->geomType() == GEntity::GhostVolume) ghost.insert(*it); } } else { - for(GModel::viter it = model->firstVertex(); it != model->lastVertex(); - ++it) + for(auto it = model->firstVertex(); it != model->lastVertex(); ++it) if((*it)->geomType() != GEntity::PartitionPoint) vertices.insert(*it); - for(GModel::eiter it = model->firstEdge(); it != model->lastEdge(); ++it) + for(auto it = model->firstEdge(); it != model->lastEdge(); ++it) if((*it)->geomType() != GEntity::PartitionCurve && (*it)->geomType() != GEntity::GhostCurve) edges.insert(*it); - for(GModel::fiter it = model->firstFace(); it != model->lastFace(); ++it) + for(auto it = model->firstFace(); it != model->lastFace(); ++it) if((*it)->geomType() != GEntity::PartitionSurface && (*it)->geomType() != GEntity::GhostSurface) faces.insert(*it); - for(GModel::riter it = model->firstRegion(); it != model->lastRegion(); - ++it) + for(auto it = model->firstRegion(); it != model->lastRegion(); ++it) if((*it)->geomType() != GEntity::PartitionVolume && (*it)->geomType() != GEntity::GhostVolume) regions.insert(*it); @@ -1613,9 +1607,7 @@ static void writeMSH4Entities(GModel *const model, FILE *fp, bool partition, if(ghostSize) { tags.resize(2 * ghostSize); int index = 0; - for(std::set<GEntity *, GEntityPtrFullLessThan>::iterator it = - ghost.begin(); - it != ghost.end(); ++it) { + for(auto it = ghost.begin(); it != ghost.end(); ++it) { if((*it)->geomType() == GEntity::GhostCurve) { tags[index] = (*it)->tag(); tags[++index] = static_cast<ghostEdge *>(*it)->getPartition(); @@ -1643,7 +1635,7 @@ static void writeMSH4Entities(GModel *const model, FILE *fp, bool partition, fwrite(&facesSize, sizeof(std::size_t), 1, fp); fwrite(®ionsSize, sizeof(std::size_t), 1, fp); - for(GModel::viter it = vertices.begin(); it != vertices.end(); ++it) { + for(auto it = vertices.begin(); it != vertices.end(); ++it) { int entityTag = (*it)->tag(); fwrite(&entityTag, sizeof(int), 1, fp); if(partition) { @@ -1666,7 +1658,7 @@ static void writeMSH4Entities(GModel *const model, FILE *fp, bool partition, writeMSH4Physicals(fp, *it, binary); } - for(GModel::eiter it = edges.begin(); it != edges.end(); ++it) { + for(auto it = edges.begin(); it != edges.end(); ++it) { std::vector<GVertex *> vertices; std::vector<int> ori; if((*it)->getBeginVertex()) { @@ -1708,7 +1700,7 @@ static void writeMSH4Entities(GModel *const model, FILE *fp, bool partition, } } - for(GModel::fiter it = faces.begin(); it != faces.end(); ++it) { + for(auto it = faces.begin(); it != faces.end(); ++it) { std::vector<GEdge *> const &edges = (*it)->edges(); std::vector<int> const &ori = (*it)->edgeOrientations(); std::size_t edgesSize = edges.size(); @@ -1734,8 +1726,7 @@ static void writeMSH4Entities(GModel *const model, FILE *fp, bool partition, writeMSH4Physicals(fp, *it, binary); fwrite(&edgesSize, sizeof(std::size_t), 1, fp); std::vector<int> tags, signs; - for(std::vector<GEdge *>::const_iterator ite = edges.begin(); - ite != edges.end(); ite++) + for(auto ite = edges.begin(); ite != edges.end(); ite++) tags.push_back((*ite)->tag()); signs.insert(signs.end(), ori.begin(), ori.end()); @@ -1750,7 +1741,7 @@ static void writeMSH4Entities(GModel *const model, FILE *fp, bool partition, } } - for(GModel::riter it = regions.begin(); it != regions.end(); ++it) { + for(auto it = regions.begin(); it != regions.end(); ++it) { std::vector<GFace *> faces = (*it)->faces(); std::vector<int> const &ori = (*it)->faceOrientations(); std::size_t facesSize = faces.size(); @@ -1776,11 +1767,9 @@ static void writeMSH4Entities(GModel *const model, FILE *fp, bool partition, writeMSH4Physicals(fp, *it, binary); fwrite(&facesSize, sizeof(std::size_t), 1, fp); std::vector<int> tags, signs; - for(std::vector<GFace *>::iterator itf = faces.begin(); - itf != faces.end(); itf++) + for(auto itf = faces.begin(); itf != faces.end(); itf++) tags.push_back((*itf)->tag()); - for(std::vector<int>::const_iterator itf = ori.begin(); itf != ori.end(); - itf++) + for(auto itf = ori.begin(); itf != ori.end(); itf++) signs.push_back(*itf); if(tags.size() == signs.size()) { for(std::size_t i = 0; i < tags.size(); i++) @@ -1803,9 +1792,7 @@ static void writeMSH4Entities(GModel *const model, FILE *fp, bool partition, if(ghostSize) { tags.resize(2 * ghostSize); int index = 0; - for(std::set<GEntity *, GEntityPtrFullLessThan>::iterator it = - ghost.begin(); - it != ghost.end(); ++it) { + for(auto it = ghost.begin(); it != ghost.end(); ++it) { if((*it)->geomType() == GEntity::GhostCurve) { tags[index] = (*it)->tag(); tags[++index] = static_cast<ghostEdge *>(*it)->getPartition(); @@ -1831,7 +1818,7 @@ static void writeMSH4Entities(GModel *const model, FILE *fp, bool partition, fprintf(fp, "%lu %lu %lu %lu\n", vertices.size(), edges.size(), faces.size(), regions.size()); - for(GModel::viter it = vertices.begin(); it != vertices.end(); ++it) { + for(auto it = vertices.begin(); it != vertices.end(); ++it) { fprintf(fp, "%d ", (*it)->tag()); if(partition) { partitionVertex *pv = static_cast<partitionVertex *>(*it); @@ -1853,7 +1840,7 @@ static void writeMSH4Entities(GModel *const model, FILE *fp, bool partition, fprintf(fp, "\n"); } - for(GModel::eiter it = edges.begin(); it != edges.end(); ++it) { + for(auto it = edges.begin(); it != edges.end(); ++it) { std::vector<GVertex *> vertices; std::vector<int> ori; if((*it)->getBeginVertex()) { @@ -1885,15 +1872,14 @@ static void writeMSH4Entities(GModel *const model, FILE *fp, bool partition, writeMSH4Physicals(fp, *it, binary); fprintf(fp, "%lu ", vertices.size()); int oriI = 0; - for(std::vector<GVertex *>::iterator itv = vertices.begin(); - itv != vertices.end(); itv++) { + for(auto itv = vertices.begin(); itv != vertices.end(); itv++) { fprintf(fp, "%d ", ori[oriI] * (*itv)->tag()); oriI++; } fprintf(fp, "\n"); } - for(GModel::fiter it = faces.begin(); it != faces.end(); ++it) { + for(auto it = faces.begin(); it != faces.end(); ++it) { std::vector<GEdge *> const &edges = (*it)->edges(); std::vector<int> const &ori = (*it)->edgeOrientations(); fprintf(fp, "%d ", (*it)->tag()); @@ -1916,11 +1902,9 @@ static void writeMSH4Entities(GModel *const model, FILE *fp, bool partition, writeMSH4Physicals(fp, *it, binary); fprintf(fp, "%lu ", edges.size()); std::vector<int> tags, signs; - for(std::vector<GEdge *>::const_iterator ite = edges.begin(); - ite != edges.end(); ite++) + for(auto ite = edges.begin(); ite != edges.end(); ite++) tags.push_back((*ite)->tag()); - for(std::vector<int>::const_iterator ite = ori.begin(); ite != ori.end(); - ite++) + for(auto ite = ori.begin(); ite != ori.end(); ite++) signs.push_back(*ite); if(tags.size() == signs.size()) { for(std::size_t i = 0; i < tags.size(); i++) @@ -1930,7 +1914,7 @@ static void writeMSH4Entities(GModel *const model, FILE *fp, bool partition, fprintf(fp, "\n"); } - for(GModel::riter it = regions.begin(); it != regions.end(); ++it) { + for(auto it = regions.begin(); it != regions.end(); ++it) { std::vector<GFace *> const &faces = (*it)->faces(); std::vector<int> const &ori = (*it)->faceOrientations(); fprintf(fp, "%d ", (*it)->tag()); @@ -2056,13 +2040,11 @@ getAdditionalEntities(std::set<GRegion *, GEntityPtrLessThan> ®ions, { std::size_t numVertices = 0; - for(std::set<GVertex *, GEntityPtrLessThan>::iterator it = vertices.begin(); - it != vertices.end(); ++it) { + for(auto it = vertices.begin(); it != vertices.end(); ++it) { numVertices += (*it)->getNumMeshVertices(); } - for(std::set<GEdge *, GEntityPtrLessThan>::iterator it = edges.begin(); - it != edges.end(); ++it) { + for(auto it = edges.begin(); it != edges.end(); ++it) { numVertices += (*it)->getNumMeshVertices(); for(std::size_t i = 0; i < (*it)->getNumMeshElements(); i++) { for(std::size_t j = 0; j < (*it)->getMeshElement(i)->getNumVertices(); @@ -2103,8 +2085,7 @@ getAdditionalEntities(std::set<GRegion *, GEntityPtrLessThan> ®ions, } } - for(std::set<GFace *, GEntityPtrLessThan>::iterator it = faces.begin(); - it != faces.end(); ++it) { + for(auto it = faces.begin(); it != faces.end(); ++it) { numVertices += (*it)->getNumMeshVertices(); for(std::size_t i = 0; i < (*it)->getNumMeshElements(); i++) { for(std::size_t j = 0; j < (*it)->getMeshElement(i)->getNumVertices(); @@ -2145,8 +2126,7 @@ getAdditionalEntities(std::set<GRegion *, GEntityPtrLessThan> ®ions, } } - for(std::set<GRegion *, GEntityPtrLessThan>::iterator it = regions.begin(); - it != regions.end(); ++it) { + for(auto it = regions.begin(); it != regions.end(); ++it) { numVertices += (*it)->getNumMeshVertices(); for(std::size_t i = 0; i < (*it)->getNumMeshElements(); i++) { for(std::size_t j = 0; j < (*it)->getMeshElement(i)->getNumVertices(); @@ -2198,23 +2178,21 @@ getEntitiesForNodes(GModel *const model, bool partitioned, bool saveAll, std::set<GVertex *, GEntityPtrLessThan> &vertices) { if(partitioned) { - for(GModel::viter it = model->firstVertex(); it != model->lastVertex(); - ++it) + for(auto it = model->firstVertex(); it != model->lastVertex(); ++it) if((*it)->geomType() == GEntity::PartitionPoint) vertices.insert(*it); - for(GModel::eiter it = model->firstEdge(); it != model->lastEdge(); ++it) { + for(auto it = model->firstEdge(); it != model->lastEdge(); ++it) { if((*it)->geomType() == GEntity::PartitionCurve) edges.insert(*it); else if((*it)->geomType() == GEntity::GhostCurve) if(static_cast<ghostEdge *>(*it)->saveMesh()) edges.insert(*it); } - for(GModel::fiter it = model->firstFace(); it != model->lastFace(); ++it) { + for(auto it = model->firstFace(); it != model->lastFace(); ++it) { if((*it)->geomType() == GEntity::PartitionSurface) faces.insert(*it); else if((*it)->geomType() == GEntity::GhostSurface) if(static_cast<ghostFace *>(*it)->saveMesh()) faces.insert(*it); } - for(GModel::riter it = model->firstRegion(); it != model->lastRegion(); - ++it) { + for(auto it = model->firstRegion(); it != model->lastRegion(); ++it) { if((*it)->geomType() == GEntity::PartitionVolume) regions.insert(*it); else if((*it)->geomType() == GEntity::GhostVolume) @@ -2222,23 +2200,21 @@ getEntitiesForNodes(GModel *const model, bool partitioned, bool saveAll, } } else { - for(GModel::viter it = model->firstVertex(); it != model->lastVertex(); - ++it) + for(auto it = model->firstVertex(); it != model->lastVertex(); ++it) if((*it)->geomType() != GEntity::PartitionPoint && (saveAll || (!saveAll && (*it)->getPhysicalEntities().size() != 0))) vertices.insert(*it); - for(GModel::eiter it = model->firstEdge(); it != model->lastEdge(); ++it) + for(auto it = model->firstEdge(); it != model->lastEdge(); ++it) if((*it)->geomType() != GEntity::PartitionCurve && (saveAll || (!saveAll && (*it)->getPhysicalEntities().size() != 0) || (*it)->geomType() == GEntity::GhostCurve)) edges.insert(*it); - for(GModel::fiter it = model->firstFace(); it != model->lastFace(); ++it) + for(auto it = model->firstFace(); it != model->lastFace(); ++it) if((*it)->geomType() != GEntity::PartitionSurface && (saveAll || (!saveAll && (*it)->getPhysicalEntities().size() != 0) || (*it)->geomType() == GEntity::GhostSurface)) faces.insert(*it); - for(GModel::riter it = model->firstRegion(); it != model->lastRegion(); - ++it) + for(auto it = model->firstRegion(); it != model->lastRegion(); ++it) if((*it)->geomType() != GEntity::PartitionVolume && (saveAll || (!saveAll && (*it)->getPhysicalEntities().size() != 0) || (*it)->geomType() == GEntity::GhostVolume)) @@ -2268,25 +2244,25 @@ static void writeMSH4Nodes(GModel *const model, FILE *fp, bool partitioned, fprintf(fp, "$Nodes\n"); std::size_t minTag = std::numeric_limits<std::size_t>::max(), maxTag = 0; - for(GModel::viter it = vertices.begin(); it != vertices.end(); ++it) { + for(auto it = vertices.begin(); it != vertices.end(); ++it) { for(std::size_t i = 0; i < (*it)->getNumMeshVertices(); i++) { minTag = std::min(minTag, (*it)->getMeshVertex(i)->getNum()); maxTag = std::max(maxTag, (*it)->getMeshVertex(i)->getNum()); } } - for(GModel::eiter it = edges.begin(); it != edges.end(); ++it) { + for(auto it = edges.begin(); it != edges.end(); ++it) { for(std::size_t i = 0; i < (*it)->getNumMeshVertices(); i++) { minTag = std::min(minTag, (*it)->getMeshVertex(i)->getNum()); maxTag = std::max(maxTag, (*it)->getMeshVertex(i)->getNum()); } } - for(GModel::fiter it = faces.begin(); it != faces.end(); ++it) { + for(auto it = faces.begin(); it != faces.end(); ++it) { for(std::size_t i = 0; i < (*it)->getNumMeshVertices(); i++) { minTag = std::min(minTag, (*it)->getMeshVertex(i)->getNum()); maxTag = std::max(maxTag, (*it)->getMeshVertex(i)->getNum()); } } - for(GModel::riter it = regions.begin(); it != regions.end(); ++it) { + for(auto it = regions.begin(); it != regions.end(); ++it) { for(std::size_t i = 0; i < (*it)->getNumMeshVertices(); i++) { minTag = std::min(minTag, (*it)->getMeshVertex(i)->getNum()); maxTag = std::max(maxTag, (*it)->getMeshVertex(i)->getNum()); @@ -2314,19 +2290,19 @@ static void writeMSH4Nodes(GModel *const model, FILE *fp, bool partitioned, } } - for(GModel::viter it = vertices.begin(); it != vertices.end(); ++it) { + for(auto it = vertices.begin(); it != vertices.end(); ++it) { writeMSH4EntityNodes(*it, fp, binary, saveParametric, scalingFactor, version); } - for(GModel::eiter it = edges.begin(); it != edges.end(); ++it) { + for(auto it = edges.begin(); it != edges.end(); ++it) { writeMSH4EntityNodes(*it, fp, binary, saveParametric, scalingFactor, version); } - for(GModel::fiter it = faces.begin(); it != faces.end(); ++it) { + for(auto it = faces.begin(); it != faces.end(); ++it) { writeMSH4EntityNodes(*it, fp, binary, saveParametric, scalingFactor, version); } - for(GModel::riter it = regions.begin(); it != regions.end(); ++it) { + for(auto it = regions.begin(); it != regions.end(); ++it) { writeMSH4EntityNodes(*it, fp, binary, saveParametric, scalingFactor, version); } @@ -2345,23 +2321,21 @@ static void writeMSH4Elements(GModel *const model, FILE *fp, bool partitioned, std::set<GVertex *, GEntityPtrLessThan> vertices; if(partitioned) { - for(GModel::viter it = model->firstVertex(); it != model->lastVertex(); - ++it) + for(auto it = model->firstVertex(); it != model->lastVertex(); ++it) if((*it)->geomType() == GEntity::PartitionPoint) vertices.insert(*it); - for(GModel::eiter it = model->firstEdge(); it != model->lastEdge(); ++it) { + for(auto it = model->firstEdge(); it != model->lastEdge(); ++it) { if((*it)->geomType() == GEntity::PartitionCurve) edges.insert(*it); else if((*it)->geomType() == GEntity::GhostCurve) if(static_cast<ghostEdge *>(*it)->saveMesh()) edges.insert(*it); } - for(GModel::fiter it = model->firstFace(); it != model->lastFace(); ++it) { + for(auto it = model->firstFace(); it != model->lastFace(); ++it) { if((*it)->geomType() == GEntity::PartitionSurface) faces.insert(*it); else if((*it)->geomType() == GEntity::GhostSurface) if(static_cast<ghostFace *>(*it)->saveMesh()) faces.insert(*it); } - for(GModel::riter it = model->firstRegion(); it != model->lastRegion(); - ++it) { + for(auto it = model->firstRegion(); it != model->lastRegion(); ++it) { if((*it)->geomType() == GEntity::PartitionVolume) regions.insert(*it); else if((*it)->geomType() == GEntity::GhostVolume) @@ -2369,19 +2343,17 @@ static void writeMSH4Elements(GModel *const model, FILE *fp, bool partitioned, } } else { - for(GModel::viter it = model->firstVertex(); it != model->lastVertex(); - ++it) + for(auto it = model->firstVertex(); it != model->lastVertex(); ++it) if((*it)->geomType() != GEntity::PartitionPoint) vertices.insert(*it); - for(GModel::eiter it = model->firstEdge(); it != model->lastEdge(); ++it) + for(auto it = model->firstEdge(); it != model->lastEdge(); ++it) if((*it)->geomType() != GEntity::PartitionCurve && (*it)->geomType() != GEntity::GhostCurve) edges.insert(*it); - for(GModel::fiter it = model->firstFace(); it != model->lastFace(); ++it) + for(auto it = model->firstFace(); it != model->lastFace(); ++it) if((*it)->geomType() != GEntity::PartitionSurface && (*it)->geomType() != GEntity::GhostSurface) faces.insert(*it); - for(GModel::riter it = model->firstRegion(); it != model->lastRegion(); - ++it) + for(auto it = model->firstRegion(); it != model->lastRegion(); ++it) if((*it)->geomType() != GEntity::PartitionVolume && (*it)->geomType() != GEntity::GhostVolume) regions.insert(*it); @@ -2390,7 +2362,7 @@ static void writeMSH4Elements(GModel *const model, FILE *fp, bool partitioned, std::map<std::pair<int, int>, std::vector<MElement *> > elementsByType[4]; std::size_t numElements = 0; - for(GModel::viter it = vertices.begin(); it != vertices.end(); ++it) { + for(auto it = vertices.begin(); it != vertices.end(); ++it) { if(!saveAll && (*it)->physicals.size() == 0) continue; numElements += (*it)->points.size(); @@ -2400,7 +2372,7 @@ static void writeMSH4Elements(GModel *const model, FILE *fp, bool partitioned, } } - for(GModel::eiter it = edges.begin(); it != edges.end(); ++it) { + for(auto it = edges.begin(); it != edges.end(); ++it) { if(!saveAll && (*it)->physicals.size() == 0 && (*it)->geomType() != GEntity::GhostCurve) continue; @@ -2412,7 +2384,7 @@ static void writeMSH4Elements(GModel *const model, FILE *fp, bool partitioned, } } - for(GModel::fiter it = faces.begin(); it != faces.end(); ++it) { + for(auto it = faces.begin(); it != faces.end(); ++it) { if(!saveAll && (*it)->physicals.size() == 0 && (*it)->geomType() != GEntity::GhostSurface) continue; @@ -2430,7 +2402,7 @@ static void writeMSH4Elements(GModel *const model, FILE *fp, bool partitioned, } } - for(GModel::riter it = regions.begin(); it != regions.end(); ++it) { + for(auto it = regions.begin(); it != regions.end(); ++it) { if(!saveAll && (*it)->physicals.size() == 0 && (*it)->geomType() != GEntity::GhostVolume) continue; @@ -2472,9 +2444,8 @@ static void writeMSH4Elements(GModel *const model, FILE *fp, bool partitioned, std::size_t minTag = std::numeric_limits<std::size_t>::max(), maxTag = 0; for(int dim = 0; dim <= 3; dim++) { - for(std::map<std::pair<int, int>, std::vector<MElement *> >::iterator it = - elementsByType[dim].begin(); - it != elementsByType[dim].end(); ++it) { + for(auto it = elementsByType[dim].begin(); it != elementsByType[dim].end(); + ++it) { for(std::size_t i = 0; i < it->second.size(); i++) { minTag = std::min(minTag, it->second[i]->getNum()); maxTag = std::max(maxTag, it->second[i]->getNum()); @@ -2496,9 +2467,8 @@ static void writeMSH4Elements(GModel *const model, FILE *fp, bool partitioned, } for(int dim = 0; dim <= 3; dim++) { - for(std::map<std::pair<int, int>, std::vector<MElement *> >::iterator it = - elementsByType[dim].begin(); - it != elementsByType[dim].end(); ++it) { + for(auto it = elementsByType[dim].begin(); it != elementsByType[dim].end(); + ++it) { int entityTag = it->first.first; int elmType = it->first.second; std::size_t numElm = it->second.size(); @@ -2608,8 +2578,7 @@ static void writeMSH4PeriodicNodes(GModel *const model, FILE *fp, std::size_t corrVertSize = corrVert.size(); fwrite(&corrVertSize, sizeof(std::size_t), 1, fp); - for(std::map<MVertex *, MVertex *>::iterator it = corrVert.begin(); - it != corrVert.end(); ++it) { + for(auto it = corrVert.begin(); it != corrVert.end(); ++it) { std::size_t numFirst = it->first->getNum(); std::size_t numSecond = it->second->getNum(); fwrite(&numFirst, sizeof(std::size_t), 1, fp); @@ -2642,8 +2611,7 @@ static void writeMSH4PeriodicNodes(GModel *const model, FILE *fp, fprintf(fp, "%lu\n", corrVert.size()); - for(std::map<MVertex *, MVertex *>::iterator it = corrVert.begin(); - it != corrVert.end(); ++it) { + for(auto it = corrVert.begin(); it != corrVert.end(); ++it) { fprintf(fp, "%lu %lu\n", it->first->getNum(), it->second->getNum()); } } @@ -2677,8 +2645,7 @@ static void writeMSH4GhostCells(GModel *const model, FILE *fp, bool binary) partition = static_cast<ghostRegion *>(entities[i])->getPartition(); } - for(std::map<MElement *, int>::iterator it = ghostElements.begin(); - it != ghostElements.end(); ++it) { + for(auto it = ghostElements.begin(); it != ghostElements.end(); ++it) { if(ghostCells[it->first].size() == 0) ghostCells[it->first].push_back(it->second); ghostCells[it->first].push_back(partition); @@ -2691,9 +2658,7 @@ static void writeMSH4GhostCells(GModel *const model, FILE *fp, bool binary) std::size_t ghostCellsSize = ghostCells.size(); fwrite(&ghostCellsSize, sizeof(std::size_t), 1, fp); - for(std::map<MElement *, std::vector<int> >::iterator it = - ghostCells.begin(); - it != ghostCells.end(); ++it) { + for(auto it = ghostCells.begin(); it != ghostCells.end(); ++it) { std::size_t elmTag = it->first->getNum(); int partNum = it->second[0]; std::size_t numGhostPartitions = it->second.size() - 1; @@ -2709,9 +2674,7 @@ static void writeMSH4GhostCells(GModel *const model, FILE *fp, bool binary) else { fprintf(fp, "%ld\n", ghostCells.size()); - for(std::map<MElement *, std::vector<int> >::iterator it = - ghostCells.begin(); - it != ghostCells.end(); ++it) { + for(auto it = ghostCells.begin(); it != ghostCells.end(); ++it) { fprintf(fp, "%lu %d %ld", it->first->getNum(), it->second[0], it->second.size() - 1); for(std::size_t i = 1; i < it->second.size(); i++) { @@ -2729,11 +2692,11 @@ static void writeMSH4Parametrizations(GModel *const model, FILE *fp, { std::size_t nParamE = 0, nParamF = 0; - for(GModel::eiter it = model->firstEdge(); it != model->lastEdge(); ++it) { + for(auto it = model->firstEdge(); it != model->lastEdge(); ++it) { discreteEdge *de = dynamic_cast<discreteEdge *>(*it); if(de && de->haveParametrization()) { nParamE++; } } - for(GModel::fiter it = model->firstFace(); it != model->lastFace(); ++it) { + for(auto it = model->firstFace(); it != model->lastFace(); ++it) { discreteFace *df = dynamic_cast<discreteFace *>(*it); if(df && df->haveParametrization()) { nParamF++; } } @@ -2750,7 +2713,7 @@ static void writeMSH4Parametrizations(GModel *const model, FILE *fp, fprintf(fp, "%lu %lu\n", nParamE, nParamF); } - for(GModel::eiter it = model->firstEdge(); it != model->lastEdge(); ++it) { + for(auto it = model->firstEdge(); it != model->lastEdge(); ++it) { discreteEdge *de = dynamic_cast<discreteEdge *>(*it); if(de && de->haveParametrization()) { int t = de->tag(); @@ -2761,7 +2724,7 @@ static void writeMSH4Parametrizations(GModel *const model, FILE *fp, de->writeParametrization(fp, binary); } } - for(GModel::fiter it = model->firstFace(); it != model->lastFace(); ++it) { + for(auto it = model->firstFace(); it != model->lastFace(); ++it) { discreteFace *df = dynamic_cast<discreteFace *>(*it); if(df && df->haveParametrization()) { int t = df->tag(); @@ -2815,7 +2778,7 @@ int GModel::_writeMSH4(const std::string &name, double version, bool binary, if(numPhysicalNames() > 0) { fprintf(fp, "$PhysicalNames\n"); fprintf(fp, "%d\n", numPhysicalNames()); - for(piter it = firstPhysicalName(); it != lastPhysicalName(); ++it) { + for(auto it = firstPhysicalName(); it != lastPhysicalName(); ++it) { std::string name = it->second; if(name.size() > 128) name.resize(128); fprintf(fp, "%d %d \"%s\"\n", it->first.first, it->first.second, @@ -2879,8 +2842,7 @@ int GModel::_writeMSH4(const std::string &name, double version, bool binary, static void associateVertices(GModel *model) { - for(GModel::const_viter it = model->firstVertex(); it != model->lastVertex(); - ++it) { + for(auto it = model->firstVertex(); it != model->lastVertex(); ++it) { for(std::size_t j = 0; j < (*it)->getNumMeshElements(); j++) { for(std::size_t k = 0; k < (*it)->getMeshElement(j)->getNumVertices(); k++) { @@ -2889,8 +2851,7 @@ static void associateVertices(GModel *model) } (*it)->mesh_vertices.clear(); } - for(GModel::const_eiter it = model->firstEdge(); it != model->lastEdge(); - ++it) { + for(auto it = model->firstEdge(); it != model->lastEdge(); ++it) { for(std::size_t j = 0; j < (*it)->getNumMeshElements(); j++) { for(std::size_t k = 0; k < (*it)->getMeshElement(j)->getNumVertices(); k++) { @@ -2899,8 +2860,7 @@ static void associateVertices(GModel *model) } (*it)->mesh_vertices.clear(); } - for(GModel::const_fiter it = model->firstFace(); it != model->lastFace(); - ++it) { + for(auto it = model->firstFace(); it != model->lastFace(); ++it) { for(std::size_t j = 0; j < (*it)->getNumMeshElements(); j++) { for(std::size_t k = 0; k < (*it)->getMeshElement(j)->getNumVertices(); k++) { @@ -2909,8 +2869,7 @@ static void associateVertices(GModel *model) } (*it)->mesh_vertices.clear(); } - for(GModel::const_riter it = model->firstRegion(); it != model->lastRegion(); - ++it) { + for(auto it = model->firstRegion(); it != model->lastRegion(); ++it) { for(std::size_t j = 0; j < (*it)->getNumMeshElements(); j++) { for(std::size_t k = 0; k < (*it)->getMeshElement(j)->getNumVertices(); k++) { @@ -2920,8 +2879,7 @@ static void associateVertices(GModel *model) (*it)->mesh_vertices.clear(); } - for(GModel::const_viter it = model->firstVertex(); it != model->lastVertex(); - ++it) { + for(auto it = model->firstVertex(); it != model->lastVertex(); ++it) { for(std::size_t j = 0; j < (*it)->getNumMeshElements(); j++) { for(std::size_t k = 0; k < (*it)->getMeshElement(j)->getNumVertices(); k++) { @@ -2933,8 +2891,7 @@ static void associateVertices(GModel *model) } } } - for(GModel::const_eiter it = model->firstEdge(); it != model->lastEdge(); - ++it) { + for(auto it = model->firstEdge(); it != model->lastEdge(); ++it) { for(std::size_t j = 0; j < (*it)->getNumMeshElements(); j++) { for(std::size_t k = 0; k < (*it)->getMeshElement(j)->getNumVertices(); k++) { @@ -2946,8 +2903,7 @@ static void associateVertices(GModel *model) } } } - for(GModel::const_fiter it = model->firstFace(); it != model->lastFace(); - ++it) { + for(auto it = model->firstFace(); it != model->lastFace(); ++it) { for(std::size_t j = 0; j < (*it)->getNumMeshElements(); j++) { for(std::size_t k = 0; k < (*it)->getMeshElement(j)->getNumVertices(); k++) { @@ -2959,8 +2915,7 @@ static void associateVertices(GModel *model) } } } - for(GModel::const_riter it = model->firstRegion(); it != model->lastRegion(); - ++it) { + for(auto it = model->firstRegion(); it != model->lastRegion(); ++it) { for(std::size_t j = 0; j < (*it)->getNumMeshElements(); j++) { for(std::size_t k = 0; k < (*it)->getMeshElement(j)->getNumVertices(); k++) { @@ -3176,9 +3131,7 @@ int GModel::writePartitionedTopology(std::string &name) std::vector<std::map<int, std::string> > tagToString(4); for(size_t i = 4; i > 0; --i) { fprintf(fp, " // Dim %lu\n", i - 1); - for(std::multimap<int, std::pair<int, std::vector<int> > >::iterator it = - allParts[i - 1].begin(); - it != allParts[i - 1].end(); ++it) { + for(auto it = allParts[i - 1].begin(); it != allParts[i - 1].end(); ++it) { std::string partName = "Part~{" + std::to_string(i - 1) + "}~{" + std::to_string(it->second.first) + "}"; fprintf(fp, " Part~{%lu}~{%d}", i - 1, it->second.first); @@ -3207,16 +3160,14 @@ int GModel::writePartitionedTopology(std::string &name) } // omega - for(std::multimap<int, std::pair<int, std::vector<int> > >::iterator it = - allParts[omegaDim].begin(); - it != allParts[omegaDim].end(); ++it) { + for(auto it = allParts[omegaDim].begin(); it != allParts[omegaDim].end(); + ++it) { if(it->second.second.size() == 1) { omegas[it->second.second[0]].push_back(it->first); } } fprintf(fp, " // Omega\n"); - for(std::map<int, std::vector<int> >::iterator it = omegas.begin(); - it != omegas.end(); ++it) { + for(auto it = omegas.begin(); it != omegas.end(); ++it) { fprintf(fp, " Omega~{%d} = Region[{", it->first); for(size_t j = 0; j < it->second.size(); ++j) { if(j == 0) @@ -3230,8 +3181,7 @@ int GModel::writePartitionedTopology(std::string &name) if(omegaDim > 0) { // sigma - for(std::multimap<int, std::pair<int, std::vector<int> > >::iterator it = - allParts[omegaDim - 1].begin(); + for(auto it = allParts[omegaDim - 1].begin(); it != allParts[omegaDim - 1].end(); ++it) { if(it->second.second.size() == 2) { sigmasij[std::pair<int, int>(it->second.second[0], @@ -3245,9 +3195,7 @@ int GModel::writePartitionedTopology(std::string &name) } } fprintf(fp, " // Sigma\n"); - for(std::map<std::pair<int, int>, std::vector<int> >::iterator it = - sigmasij.begin(); - it != sigmasij.end(); ++it) { + for(auto it = sigmasij.begin(); it != sigmasij.end(); ++it) { fprintf(fp, " Sigma~{%d}~{%d} = Region[{", it->first.first, it->first.second); for(size_t j = 0; j < it->second.size(); ++j) { @@ -3260,8 +3208,7 @@ int GModel::writePartitionedTopology(std::string &name) } fprintf(fp, "\n"); - for(std::map<int, std::vector<int> >::iterator it = sigmas.begin(); - it != sigmas.end(); ++it) { + for(auto it = sigmas.begin(); it != sigmas.end(); ++it) { fprintf(fp, " Sigma~{%d} = Region[{", it->first); for(size_t j = 0; j < it->second.size(); ++j) { if(j == 0) @@ -3284,8 +3231,7 @@ int GModel::writePartitionedTopology(std::string &name) if(omegaDim > 0) { // D~{i} - for(std::multimap<int, std::pair<int, std::vector<int> > >::iterator it = - allParts[omegaDim - 1].begin(); + for(auto it = allParts[omegaDim - 1].begin(); it != allParts[omegaDim - 1].end(); ++it) { if(it->second.second.size() == 2) { neighbors[it->second.second[0]].insert(it->second.second[1]); @@ -3294,8 +3240,7 @@ int GModel::writePartitionedTopology(std::string &name) } for(size_t i = 1; i <= getNumPartitions(); ++i) { fprintf(fp, " D~{%lu}() = {", i); - for(std::set<int>::iterator it = neighbors[i].begin(); - it != neighbors[i].end(); ++it) { + for(auto it = neighbors[i].begin(); it != neighbors[i].end(); ++it) { if(it != neighbors[i].begin()) fprintf(fp, ", "); fprintf(fp, "%d", *it); } diff --git a/Geo/GModelIO_NEU.cpp b/Geo/GModelIO_NEU.cpp index 975db596cdf6e45067ea40abd125be71006b5ff6..5311fb17a4e3c35764ea6e35dc884c98ff7246aa 100644 --- a/Geo/GModelIO_NEU.cpp +++ b/Geo/GModelIO_NEU.cpp @@ -101,8 +101,7 @@ namespace { unsigned const gambitBoundaryCode(std::string name) { std::transform(name.begin(), name.end(), name.begin(), ::toupper); - hashMap<std::string, unsigned>::_::const_iterator code = - boundaryCodeMap.find(name); + auto code = boundaryCodeMap.find(name); return code == boundaryCodeMap.end() ? 0 : code->second; } @@ -136,7 +135,7 @@ int GModel::writeNEU(const std::string &name, bool saveAll, unsigned lowestId = std::numeric_limits<int>::max(); hashMap<unsigned, std::vector<unsigned> >::_ elementGroups; - for(riter it = firstRegion(); it != lastRegion(); ++it) { + for(auto it = firstRegion(); it != lastRegion(); ++it) { if(saveAll || (*it)->physicals.size()) { numTetrahedra += (*it)->tetrahedra.size(); numHexahedra += (*it)->hexahedra.size(); @@ -165,7 +164,7 @@ int GModel::writeNEU(const std::string &name, bool saveAll, std::vector<unsigned char> vertex_phys(nVertex); // create association map for vertices and faces hashMap<unsigned, std::vector<unsigned> >::_ vertmap; - for(GModel::fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { for(auto &tri : (*it)->triangles) { for(std::size_t j = 0; j < tri->getNumVertices(); ++j) { unsigned numVertex = tri->getVertex(j)->getNum(); @@ -188,7 +187,7 @@ int GModel::writeNEU(const std::string &name, bool saveAll, for(auto &it : vertmap) { std::sort(it.second.begin(), it.second.end()); } std::vector<unsigned char> elem_phys(numElements); - for(riter it = firstRegion(); it != lastRegion(); ++it) { + for(auto it = firstRegion(); it != lastRegion(); ++it) { if(saveAll || (*it)->physicals.size()) { for(std::size_t i = 0; i < (*it)->getNumMeshElements(); ++i) { unsigned num = (*it)->getMeshElement(i)->getNum(); @@ -207,7 +206,7 @@ int GModel::writeNEU(const std::string &name, bool saveAll, // determine which faces belong to which element by comparing vertices IDFaceMap facemap; - for(GModel::riter it = firstRegion(); it != lastRegion(); ++it) { + for(auto it = firstRegion(); it != lastRegion(); ++it) { for(std::size_t i = 0; i < (*it)->getNumMeshElements(); ++i) { MElement *element = (*it)->getMeshElement(i); unsigned num = element->getNum(); @@ -249,14 +248,14 @@ int GModel::writeNEU(const std::string &name, bool saveAll, // populate boundary conditions for tetrahedra given triangle physicals IDFaceMap boundaryConditions; - for(GModel::fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { if((*it)->physicals.size()) { for(std::size_t i = 0; i < (*it)->physicals.size(); ++i) { unsigned phys = (*it)->physicals[i]; for(std::size_t j = 0; j < (*it)->triangles.size(); ++j) { MTriangle *tri = (*it)->triangles[j]; - IDFaceMap::iterator tets = facemap.find(tri->getNum()); + auto tets = facemap.find(tri->getNum()); if(tets != facemap.end()) { for(std::size_t tet = 0; tet < tets->second.size(); ++tet) { boundaryConditions[phys].push_back(tets->second[tet]); @@ -266,7 +265,7 @@ int GModel::writeNEU(const std::string &name, bool saveAll, for(std::size_t j = 0; j < (*it)->quadrangles.size(); ++j) { MQuadrangle *quad = (*it)->quadrangles[j]; - IDFaceMap::iterator tets = facemap.find(quad->getNum()); + auto tets = facemap.find(quad->getNum()); if(tets != facemap.end()) { for(std::size_t tet = 0; tet < tets->second.size(); ++tet) { boundaryConditions[phys].push_back(tets->second[tet]); @@ -308,7 +307,7 @@ int GModel::writeNEU(const std::string &name, bool saveAll, // Elements fprintf(fp, " ELEMENTS/CELLS 2.0.0\n"); - for(riter it = firstRegion(); it != lastRegion(); ++it) { + for(auto it = firstRegion(); it != lastRegion(); ++it) { std::size_t numPhys = (*it)->physicals.size(); if(saveAll || numPhys) { for(auto cell : (*it)->tetrahedra) { @@ -363,8 +362,8 @@ int GModel::writeNEU(const std::string &name, bool saveAll, unsigned nphys = getMaxPhysicalNumber(2); for(unsigned iphys = 1; iphys <= nphys; ++iphys) { - for(IDFaceMap::iterator it = boundaryConditions.begin(); - it != boundaryConditions.end(); ++it) { + for(auto it = boundaryConditions.begin(); it != boundaryConditions.end(); + ++it) { if(it->first == iphys) { fprintf(fp, " BOUNDARY CONDITIONS 2.0.0\n"); std::string regionName = getPhysicalName(2, it->first); @@ -377,8 +376,7 @@ int GModel::writeNEU(const std::string &name, bool saveAll, fprintf(fp, "%32s%8d%8lu%8d%8d\n", regionName.c_str(), 1, it->second.size(), 0, gambitBoundaryCode(regionName)); std::sort(it->second.begin(), it->second.end(), sortBCs); - for(std::vector<FacePair>::iterator tfp = it->second.begin(); - tfp != it->second.end(); ++tfp) { + for(auto tfp = it->second.begin(); tfp != it->second.end(); ++tfp) { MElement *element = getMeshElementByTag(tfp->first); unsigned type = element->getType(); unsigned gambit_type = 0; diff --git a/Geo/GModelIO_OCC.cpp b/Geo/GModelIO_OCC.cpp index 08b9f00494561dc4601aec390e0477a710f9112e..804fac36119cf9307a61920ca9903ce2053b4e21 100644 --- a/Geo/GModelIO_OCC.cpp +++ b/Geo/GModelIO_OCC.cpp @@ -1895,9 +1895,10 @@ static bool makeTrimmedSurface(Handle(Geom_Surface) & surf, Handle(Geom_Curve) c = BRep_Tool::Curve(edge, first, last); if(wire3D) { // use the 3D curves in the wire and project them onto the patch - Handle(Geom_Curve) cProj = GeomProjLib::Project - (new Geom_TrimmedCurve(c, first, last, Standard_True, Standard_False), - surf); + Handle(Geom_Curve) cProj = GeomProjLib::Project( + new Geom_TrimmedCurve(c, first, last, Standard_True, + Standard_False), + surf); TopoDS_Edge edgeProj = BRepBuilderAPI_MakeEdge( cProj, cProj->FirstParameter(), cProj->LastParameter()); w.Add(edgeProj); @@ -2958,7 +2959,8 @@ bool OCC_Internals::_extrudePerDim( else if(trihedron == "GuidePlanWithContact") mode = GeomFill_IsGuidePlanWithContact; else - Msg::Warning("Unknown trihedron mode for pipe: using 'DiscreteTrihedron'"); + Msg::Warning( + "Unknown trihedron mode for pipe: using 'DiscreteTrihedron'"); BRepOffsetAPI_MakePipe p(wire, c, mode); p.Build(); if(!p.IsDone()) { @@ -3848,14 +3850,12 @@ static void setShapeAttributes(OCCAttributesRTree *attributes, TopoDS_Shape shape = shapeTool->GetShape(label); shape.Location(isRef ? loc : partLoc); int dim = - (shape.ShapeType() == TopAbs_VERTEX) ? - 0 : - (shape.ShapeType() == TopAbs_EDGE || shape.ShapeType() == TopAbs_WIRE) ? - 1 : - (shape.ShapeType() == TopAbs_FACE || - shape.ShapeType() == TopAbs_SHELL) ? - 2 : - 3; + (shape.ShapeType() == TopAbs_VERTEX) ? 0 : + (shape.ShapeType() == TopAbs_EDGE || shape.ShapeType() == TopAbs_WIRE) ? + 1 : + (shape.ShapeType() == TopAbs_FACE || shape.ShapeType() == TopAbs_SHELL) ? + 2 : + 3; Handle(TCollection_HAsciiString) matName; Handle(TCollection_HAsciiString) matDescription; @@ -4058,24 +4058,22 @@ bool OCC_Internals::exportShapes(GModel *model, const std::string &fileName, BRep_Builder b; TopoDS_Compound c; b.MakeCompound(c); - for(GModel::riter it = model->firstRegion(); it != model->lastRegion(); - it++) { + for(auto it = model->firstRegion(); it != model->lastRegion(); it++) { GRegion *gr = *it; if(gr->getNativeType() == GEntity::OpenCascadeModel) b.Add(c, *(TopoDS_Solid *)gr->getNativePtr()); } - for(GModel::fiter it = model->firstFace(); it != model->lastFace(); it++) { + for(auto it = model->firstFace(); it != model->lastFace(); it++) { GFace *gf = *it; if(!gf->numRegions() && gf->getNativeType() == GEntity::OpenCascadeModel) b.Add(c, *(TopoDS_Face *)gf->getNativePtr()); } - for(GModel::eiter it = model->firstEdge(); it != model->lastEdge(); it++) { + for(auto it = model->firstEdge(); it != model->lastEdge(); it++) { GEdge *ge = *it; if(!ge->numFaces() && ge->getNativeType() == GEntity::OpenCascadeModel) b.Add(c, *(TopoDS_Edge *)ge->getNativePtr()); } - for(GModel::viter it = model->firstVertex(); it != model->lastVertex(); - it++) { + for(auto it = model->firstVertex(); it != model->lastVertex(); it++) { GVertex *gv = *it; if(!gv->numEdges() && gv->getNativeType() == GEntity::OpenCascadeModel) b.Add(c, *(TopoDS_Vertex *)gv->getNativePtr()); diff --git a/Geo/GModelIO_OCC.h b/Geo/GModelIO_OCC.h index 49afc42d7ed5107c1a59f422b24941ba44fec047..60540e92ff4437a86bb3eb6d123c4faeae230132 100644 --- a/Geo/GModelIO_OCC.h +++ b/Geo/GModelIO_OCC.h @@ -226,15 +226,11 @@ public: const std::vector<int> &pointTags = std::vector<int>(), const std::vector<int> &surfaceTags = std::vector<int>(), const std::vector<int> &surfaceContinuity = std::vector<int>()); - bool addBSplineFilling(int &tag, int wireTag, - const std::string &type = ""); - bool addBezierFilling(int &tag, int wireTag, - const std::string &type = ""); - bool addBSplineSurface(int &tag, - const std::vector<int> &pointTags, - const int numPointsU, - const int degreeU, const int degreeV, - const std::vector<double> &weights, + bool addBSplineFilling(int &tag, int wireTag, const std::string &type = ""); + bool addBezierFilling(int &tag, int wireTag, const std::string &type = ""); + bool addBSplineSurface(int &tag, const std::vector<int> &pointTags, + const int numPointsU, const int degreeU, + const int degreeV, const std::vector<double> &weights, const std::vector<double> &knotsU, const std::vector<double> &knotsV, const std::vector<int> &multiplicitiesU, @@ -245,8 +241,8 @@ public: const int numPointsU, const std::vector<int> &wireTags = std::vector<int>(), bool wire3D = true); - bool addTrimmedSurface(int &tag, int surfaceTag, const std::vector<int> &wireTags, - bool wire3D); + bool addTrimmedSurface(int &tag, int surfaceTag, + const std::vector<int> &wireTags, bool wire3D); bool addSurfaceLoop(int &tag, const std::vector<int> &surfaceTags, bool sewing); bool addVolume(int &tag, const std::vector<int> &shellTags); @@ -538,21 +534,17 @@ public: { return _error("add surface filling"); } - bool addBSplineFilling(int &tag, int wireTag, - const std::string &type = "") + bool addBSplineFilling(int &tag, int wireTag, const std::string &type = "") { return _error("add BSpline filling"); } - bool addBezierFilling(int &tag, int wireTag, - const std::string &type = "") + bool addBezierFilling(int &tag, int wireTag, const std::string &type = "") { return _error("add Bezier filling"); } - bool addBSplineSurface(int &tag, - const std::vector<int> &pointTags, - const int numPointsU, - const int degreeU, const int degreeV, - const std::vector<double> &weights, + bool addBSplineSurface(int &tag, const std::vector<int> &pointTags, + const int numPointsU, const int degreeU, + const int degreeV, const std::vector<double> &weights, const std::vector<double> &knotsU, const std::vector<double> &knotsV, const std::vector<int> &multiplicitiesU, @@ -570,8 +562,7 @@ public: return _error("add Bezier surface"); } bool addTrimmedSurface(int &tag, int surfaceTag, - const std::vector<int> &wireTags, - bool wire3D) + const std::vector<int> &wireTags, bool wire3D) { return _error("add trimmed surface"); } diff --git a/Geo/GModelIO_P3D.cpp b/Geo/GModelIO_P3D.cpp index 27e8de5eb83cad296c4fd0483dc51d0a8523f46a..bfc93d1aa5d18d9b25b3cc3f2f96446e5f200644 100644 --- a/Geo/GModelIO_P3D.cpp +++ b/Geo/GModelIO_P3D.cpp @@ -132,14 +132,14 @@ int GModel::writeP3D(const std::string &name, bool saveAll, if(noPhysicalGroups()) saveAll = true; std::vector<GFace *> faces; - for(fiter it = firstFace(); it != lastFace(); ++it) + for(auto it = firstFace(); it != lastFace(); ++it) if((*it)->transfinite_vertices.size() && (*it)->transfinite_vertices[0].size() && ((*it)->physicals.size() || saveAll)) faces.push_back(*it); std::vector<GRegion *> regions; - for(riter it = firstRegion(); it != lastRegion(); ++it) + for(auto it = firstRegion(); it != lastRegion(); ++it) if((*it)->transfinite_vertices.size() && (*it)->transfinite_vertices[0].size() && (*it)->transfinite_vertices[0][0].size() && diff --git a/Geo/GModelIO_PLY.cpp b/Geo/GModelIO_PLY.cpp index fb9232664f975c2d3fed673837fa47934b11f200..3f43709a5bfac171acd4e90171a7e82fc84faf23 100644 --- a/Geo/GModelIO_PLY.cpp +++ b/Geo/GModelIO_PLY.cpp @@ -289,7 +289,7 @@ int GModel::writePLY2(const std::string &name) int numVertices = indexMeshVertices(true); int numTriangles = 0; - for(fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { numTriangles += (*it)->triangles.size(); } @@ -302,7 +302,7 @@ int GModel::writePLY2(const std::string &name) for(std::size_t j = 0; j < entities[i]->mesh_vertices.size(); j++) entities[i]->mesh_vertices[j]->writePLY2(fp); - for(fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { for(std::size_t i = 0; i < (*it)->triangles.size(); i++) (*it)->triangles[i]->writePLY2(fp); } diff --git a/Geo/GModelIO_STL.cpp b/Geo/GModelIO_STL.cpp index 4ee8a52c350645a5522796ca69e8ca857603ab7f..d271d506486cb920cd2b12cfdf1f32c6df5eec62 100644 --- a/Geo/GModelIO_STL.cpp +++ b/Geo/GModelIO_STL.cpp @@ -39,7 +39,7 @@ int GModel::readSTL(const std::string &name, double tolerance) return 0; } - //SPoint3 p0(1.9e6, 4e6, 0); + // SPoint3 p0(1.9e6, 4e6, 0); bool binary = strncmp(buffer, "solid", 5) && strncmp(buffer, "SOLID", 5); @@ -75,7 +75,7 @@ int GModel::readSTL(const std::string &name, double tolerance) double x, y, z; if(sscanf(buffer, "%s %lf %lf %lf", s1, &x, &y, &z) != 4) break; SPoint3 p(x, y, z); - //p -= p0; + // p -= p0; points.back().push_back(p); bbox += p; } @@ -126,7 +126,7 @@ int GModel::readSTL(const std::string &name, double tolerance) if(swap) SwapBytes((char *)xyz, sizeof(float), 12); for(int j = 0; j < 3; j++) { SPoint3 p(xyz[3 + 3 * j], xyz[3 + 3 * j + 1], xyz[3 + 3 * j + 2]); - //p -= p0; + // p -= p0; points.back().push_back(p); bbox += p; } @@ -138,11 +138,11 @@ int GModel::readSTL(const std::string &name, double tolerance) } // cleanup names - if(names.size() != points.size()){ + if(names.size() != points.size()) { Msg::Debug("Invalid number of names in STL file - should never happen"); names.resize(points.size()); } - for(std::size_t i = 0; i < names.size(); i++){ + for(std::size_t i = 0; i < names.size(); i++) { names[i].erase(remove_if(names[i].begin(), names[i].end(), invalidChar), names[i].end()); } @@ -192,14 +192,15 @@ int GModel::readSTL(const std::string &name, double tolerance) v[k] = pos.find(x, y, z); if(!v[k]) Msg::Error("Could not find node at position (%.16g, %.16g, %.16g) " - "with tol=%.16g", x, y, z, eps); + "with tol=%.16g", + x, y, z, eps); } if(!v[0] || !v[1] || !v[2]) { // error } else if(v[0] == v[1] || v[0] == v[2] || v[1] == v[2]) { - Msg::Debug("Skipping degenerated triangle %lu %lu %lu", - v[0]->getNum(), v[1]->getNum(), v[2]->getNum()); + Msg::Debug("Skipping degenerated triangle %lu %lu %lu", v[0]->getNum(), + v[1]->getNum(), v[2]->getNum()); nbDegen++; } else if(CTX::instance()->mesh.stlRemoveDuplicateTriangles) { @@ -212,14 +213,14 @@ int GModel::readSTL(const std::string &name, double tolerance) nbDuplic++; } } - else{ + else { faces[i]->triangles.push_back(new MTriangle(v[0], v[1], v[2])); } } } if(nbDuplic || nbDegen) - Msg::Warning("%d duplicate/%d degenerate triangles in STL file", - nbDuplic, nbDegen); + Msg::Warning("%d duplicate/%d degenerate triangles in STL file", nbDuplic, + nbDegen); _associateEntityWithMeshVertices(); @@ -229,25 +230,23 @@ int GModel::readSTL(const std::string &name, double tolerance) return 1; } -static void writeSTLfaces(FILE *fp, std::vector<GFace*> &faces, bool binary, +static void writeSTLfaces(FILE *fp, std::vector<GFace *> &faces, bool binary, double scalingFactor, const std::string &name) { bool useGeoSTL = false; unsigned int nfacets = 0; - for(std::vector<GFace*>::iterator it = faces.begin(); it != faces.end(); ++it) { + for(auto it = faces.begin(); it != faces.end(); ++it) { nfacets += (*it)->triangles.size() + 2 * (*it)->quadrangles.size(); } if(!nfacets) { // use CAD STL if there is no mesh useGeoSTL = true; - for(std::vector<GFace*>::iterator it = faces.begin(); it != faces.end(); ++it) { + for(auto it = faces.begin(); it != faces.end(); ++it) { (*it)->buildSTLTriangulation(); nfacets += (*it)->stl_triangles.size() / 3; } } - if(!binary) { - fprintf(fp, "solid %s\n", name.c_str()); - } + if(!binary) { fprintf(fp, "solid %s\n", name.c_str()); } else { char header[80]; strncpy(header, name.c_str(), 79); @@ -256,7 +255,7 @@ static void writeSTLfaces(FILE *fp, std::vector<GFace*> &faces, bool binary, fwrite(&nfacets, sizeof(unsigned int), 1, fp); } - for(std::vector<GFace*>::iterator it = faces.begin(); it != faces.end(); ++it) { + for(auto it = faces.begin(); it != faces.end(); ++it) { if(useGeoSTL && (*it)->stl_vertices_uv.size()) { for(std::size_t i = 0; i < (*it)->stl_triangles.size(); i += 3) { SPoint2 &p1((*it)->stl_vertices_uv[(*it)->stl_triangles[i]]); @@ -317,12 +316,12 @@ int GModel::writeSTL(const std::string &name, bool binary, bool saveAll, if(noPhysicalGroups()) saveAll = true; - if(oneSolidPerSurface == 1){ // one solid per surface - for(fiter it = firstFace(); it != lastFace(); ++it) { + if(oneSolidPerSurface == 1) { // one solid per surface + for(auto it = firstFace(); it != lastFace(); ++it) { if(saveAll || (*it)->physicals.size()) { - std::vector<GFace*> faces(1, *it); + std::vector<GFace *> faces(1, *it); std::string name = getElementaryName(2, (*it)->tag()); - if(name.empty()){ + if(name.empty()) { std::ostringstream s; s << "Gmsh Surface " << (*it)->tag(); name = s.str(); @@ -331,17 +330,16 @@ int GModel::writeSTL(const std::string &name, bool binary, bool saveAll, } } } - else if(oneSolidPerSurface == 2){ // one solid per physical surface + else if(oneSolidPerSurface == 2) { // one solid per physical surface std::map<int, std::vector<GEntity *> > phys; getPhysicalGroups(2, phys); - for(std::map<int, std::vector<GEntity *> >::iterator it = phys.begin(); - it != phys.end(); it++){ - std::vector<GFace*> faces; - for(std::size_t i = 0; i < it->second.size(); i++){ - faces.push_back(static_cast<GFace*>(it->second[i])); + for(auto it = phys.begin(); it != phys.end(); it++) { + std::vector<GFace *> faces; + for(std::size_t i = 0; i < it->second.size(); i++) { + faces.push_back(static_cast<GFace *>(it->second[i])); } std::string name = getPhysicalName(2, it->first); - if(name.empty()){ + if(name.empty()) { std::ostringstream s; s << "Gmsh Physical Surface " << it->first; name = s.str(); @@ -349,12 +347,10 @@ int GModel::writeSTL(const std::string &name, bool binary, bool saveAll, writeSTLfaces(fp, faces, binary, scalingFactor, name); } } - else{ // one solid - std::vector<GFace*> faces; - for(fiter it = firstFace(); it != lastFace(); ++it) { - if(saveAll || (*it)->physicals.size()) { - faces.push_back(*it); - } + else { // one solid + std::vector<GFace *> faces; + for(auto it = firstFace(); it != lastFace(); ++it) { + if(saveAll || (*it)->physicals.size()) { faces.push_back(*it); } } std::string name = "Created by Gmsh"; writeSTLfaces(fp, faces, binary, scalingFactor, name); diff --git a/Geo/GModelIO_SU2.cpp b/Geo/GModelIO_SU2.cpp index 1b024b13159123f090333ae5448920fb443816da..a6e324e1e288afde2a9c67eb43bb7918c26c5ddb 100644 --- a/Geo/GModelIO_SU2.cpp +++ b/Geo/GModelIO_SU2.cpp @@ -16,7 +16,8 @@ static std::string physicalName(GModel *m, int dim, int num) char tmp[256]; sprintf(tmp, "%s%d", (dim == 3) ? "PhysicalVolume" : - (dim == 2) ? "PhysicalSurface" : "PhysicalLine", + (dim == 2) ? "PhysicalSurface" : + "PhysicalLine", num); name = tmp; } @@ -50,12 +51,12 @@ int GModel::writeSU2(const std::string &name, bool saveAll, // node ordering is the same as VTK int nelem = 0; if(ndime == 2) { - for(fiter it = firstFace(); it != lastFace(); it++) + for(auto it = firstFace(); it != lastFace(); it++) if(saveAll || (*it)->physicals.size()) nelem += (*it)->getNumMeshElements(); } else { - for(riter it = firstRegion(); it != lastRegion(); it++) + for(auto it = firstRegion(); it != lastRegion(); it++) if(saveAll || (*it)->physicals.size()) nelem += (*it)->getNumMeshElements(); } @@ -67,13 +68,13 @@ int GModel::writeSU2(const std::string &name, bool saveAll, fprintf(fp, "NELEM= %d\n", nelem); int num = 0; if(ndime == 2) { - for(fiter it = firstFace(); it != lastFace(); it++) + for(auto it = firstFace(); it != lastFace(); it++) if(saveAll || (*it)->physicals.size()) for(std::size_t i = 0; i < (*it)->getNumMeshElements(); i++) (*it)->getMeshElement(i)->writeSU2(fp, num++); } else { - for(riter it = firstRegion(); it != lastRegion(); it++) + for(auto it = firstRegion(); it != lastRegion(); it++) if(saveAll || (*it)->physicals.size()) for(std::size_t i = 0; i < (*it)->getNumMeshElements(); i++) (*it)->getMeshElement(i)->writeSU2(fp, num++); @@ -93,9 +94,8 @@ int GModel::writeSU2(const std::string &name, bool saveAll, int nmark = groups[ndime - 1].size(); if(nmark) { fprintf(fp, "NMARK= %d\n", nmark); - for(std::map<int, std::vector<GEntity *> >::iterator it = - groups[ndime - 1].begin(); - it != groups[ndime - 1].end(); it++) { + for(auto it = groups[ndime - 1].begin(); it != groups[ndime - 1].end(); + it++) { std::vector<GEntity *> &entities = it->second; int n = 0; for(std::size_t i = 0; i < entities.size(); i++) diff --git a/Geo/GModelIO_TOCHNOG.cpp b/Geo/GModelIO_TOCHNOG.cpp index 2909d2c3a0767722fe0f82518f9eb4c2083a1ad5..438a9ac606025b2762bc4826d75d84ad8ad8340c 100644 --- a/Geo/GModelIO_TOCHNOG.cpp +++ b/Geo/GModelIO_TOCHNOG.cpp @@ -42,7 +42,7 @@ static std::string physicalName(GModel *m, int dim, int num) (dim == 3) ? "PhysicalVolume" : (dim == 2) ? "PhysicalSurface" : (dim == 1) ? "PhysicalLine" : - "PhysicalPoint", + "PhysicalPoint", num); name = tmp; } @@ -95,24 +95,24 @@ int GModel::writeTOCHNOG(const std::string &name, bool saveAll, // Elements fprintf(fp, "(++++++++++++++ E L E M E N T S ++++++++++++++)\n"); fprintf(fp, "\n"); - for(viter it = firstVertex(); it != lastVertex(); ++it) { + for(auto it = firstVertex(); it != lastVertex(); ++it) { writeElementsTOCHNOG(fp, *it, (*it)->points, saveAll); } if(dim == 3) { - for(riter it = firstRegion(); it != lastRegion(); ++it) { + for(auto it = firstRegion(); it != lastRegion(); ++it) { writeElementsTOCHNOG(fp, *it, (*it)->tetrahedra, saveAll); writeElementsTOCHNOG(fp, *it, (*it)->hexahedra, saveAll); } } else if(dim == 2) { - for(fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { writeElementsTOCHNOG(fp, *it, (*it)->triangles, saveAll); writeElementsTOCHNOG(fp, *it, (*it)->quadrangles, saveAll); } } else if(dim == 1) { - for(eiter it = firstEdge(); it != lastEdge(); ++it) { + for(auto it = firstEdge(); it != lastEdge(); ++it) { writeElementsTOCHNOG(fp, *it, (*it)->lines, saveAll); } } @@ -148,9 +148,7 @@ int GModel::writeTOCHNOG(const std::string &name, bool saveAll, // Save elements sets for each physical group for(int dim = 1; dim <= 3; dim++) { - for(std::map<int, std::vector<GEntity *> >::iterator it = - groups[dim].begin(); - it != groups[dim].end(); it++) { + for(auto it = groups[dim].begin(); it != groups[dim].end(); it++) { std::vector<GEntity *> &entities = it->second; fprintf(fp, "\n"); fprintf(fp, @@ -174,8 +172,7 @@ int GModel::writeTOCHNOG(const std::string &name, bool saveAll, // physical points) if(saveGroupsOfNodes) { for(int dim = 0; dim <= 3; dim++) { - for(std::map<int, std::vector<GEntity *> >::iterator it = groups[dim].begin(); - it != groups[dim].end(); it++) { + for(auto it = groups[dim].begin(); it != groups[dim].end(); it++) { std::set<MVertex *, MVertexPtrLessThan> nodes; std::vector<GEntity *> &entities = it->second; for(std::size_t i = 0; i < entities.size(); i++) { @@ -186,12 +183,13 @@ int GModel::writeTOCHNOG(const std::string &name, bool saveAll, } } fprintf(fp, "\n"); - fprintf(fp, "(Node sets ===> Used to set BOUNDARY CONDITIONS in Tochnog =%s)\n", - physicalName(this, dim, it->first).c_str()); + fprintf( + fp, + "(Node sets ===> Used to set BOUNDARY CONDITIONS in Tochnog =%s)\n", + physicalName(this, dim, it->first).c_str()); fprintf(fp, "\n"); int n = 0; - for(std::set<MVertex *, MVertexPtrLessThan>::iterator it2 = nodes.begin(); - it2 != nodes.end(); it2++) { + for(auto it2 = nodes.begin(); it2 != nodes.end(); it2++) { if(n && !(n % 10)) fprintf(fp, "\n"); fprintf(fp, "%ld ", (*it2)->getIndex()); n++; diff --git a/Geo/GModelIO_UNV.cpp b/Geo/GModelIO_UNV.cpp index ba8014054051b498a9c526c358466f39da63bce4..23d3c87a2e313d38a031e4363acc990a50944f04 100644 --- a/Geo/GModelIO_UNV.cpp +++ b/Geo/GModelIO_UNV.cpp @@ -93,15 +93,9 @@ int GModel::readUNV(const std::string &name) if(warn[type]++ == 1) Msg::Warning("No element type: guessing from number of nodes"); switch(numNodes) { - case 2: - type = 11; - break; // line - case 3: - type = 41; - break; // tri - case 4: - type = 111; - break; // tet + case 2: type = 11; break; // line + case 3: type = 41; break; // tri + case 4: type = 111; break; // tet } } @@ -276,7 +270,8 @@ static std::string physicalName(GModel *m, int dim, int num) char tmp[256]; sprintf(tmp, "%s%d", (dim == 3) ? "PhysicalVolume" : - (dim == 2) ? "PhysicalSurface" : "PhysicalLine", + (dim == 2) ? "PhysicalSurface" : + "PhysicalLine", num); name = tmp; } @@ -306,8 +301,9 @@ int GModel::writeUNV(const std::string &name, bool saveAll, fprintf(fp, "%6d\n", 2411); for(std::size_t i = 0; i < entities.size(); i++) for(std::size_t j = 0; j < entities[i]->mesh_vertices.size(); j++) - entities[i]->mesh_vertices[j]->writeUNV - (fp, CTX::instance()->mesh.unvStrictFormat ? true : false, scalingFactor); + entities[i]->mesh_vertices[j]->writeUNV( + fp, CTX::instance()->mesh.unvStrictFormat ? true : false, + scalingFactor); fprintf(fp, "%6d\n", -1); // elements @@ -331,9 +327,7 @@ int GModel::writeUNV(const std::string &name, bool saveAll, fprintf(fp, "%6d\n", -1); fprintf(fp, "%6d\n", 2477); for(int dim = 0; dim <= 3; dim++) { - for(std::map<int, std::vector<GEntity *> >::iterator it = - groups[dim].begin(); - it != groups[dim].end(); it++) { + for(auto it = groups[dim].begin(); it != groups[dim].end(); it++) { std::vector<GEntity *> &entities = it->second; std::set<MVertex *, MVertexPtrLessThan> nodes; @@ -357,8 +351,7 @@ int GModel::writeUNV(const std::string &name, bool saveAll, if(saveGroupsOfNodes) { int row = 0; - for(std::set<MVertex *, MVertexPtrLessThan>::iterator it2 = nodes.begin(); - it2 != nodes.end(); it2++) { + for(auto it2 = nodes.begin(); it2 != nodes.end(); it2++) { if(row == 2) { fprintf(fp, "\n"); row = 0; diff --git a/Geo/GModelIO_VRML.cpp b/Geo/GModelIO_VRML.cpp index 996a9ffdf795962e5279d72a7f140aa03f0a39b1..988b92979341a6e59a3c3d74c0b015927693f7b3 100644 --- a/Geo/GModelIO_VRML.cpp +++ b/Geo/GModelIO_VRML.cpp @@ -18,13 +18,10 @@ static int skipUntil(FILE *fp, const char *key) strcat(key_bracket, "["); while(fscanf(fp, "%s", str)) { if(!strcmp(str, key)) { - while(!feof(fp) && fgetc(fp) != '[') { - } - return 1; - } - if(!strcmp(str, key_bracket)) { + while(!feof(fp) && fgetc(fp) != '[') {} return 1; } + if(!strcmp(str, key_bracket)) { return 1; } } return 0; } @@ -66,9 +63,7 @@ static int readElementsVRML(FILE *fp, std::vector<MVertex *> &vertexVector, format = " %d"; while(fscanf(fp, format, &i) == 1) { - if(i != -1) { - idx.push_back(i); - } + if(i != -1) { idx.push_back(i); } else { std::vector<MVertex *> vertices; for(std::size_t j = 0; j < idx.size(); j++) { @@ -211,20 +206,20 @@ int GModel::writeVRML(const std::string &name, bool saveAll, fprintf(fp, "Coordinate3 {\n"); fprintf(fp, " point [\n"); - for(viter it = firstVertex(); it != lastVertex(); ++it) + for(auto it = firstVertex(); it != lastVertex(); ++it) for(std::size_t i = 0; i < (*it)->mesh_vertices.size(); i++) (*it)->mesh_vertices[i]->writeVRML(fp, scalingFactor); - for(eiter it = firstEdge(); it != lastEdge(); ++it) + for(auto it = firstEdge(); it != lastEdge(); ++it) for(std::size_t i = 0; i < (*it)->mesh_vertices.size(); i++) (*it)->mesh_vertices[i]->writeVRML(fp, scalingFactor); - for(fiter it = firstFace(); it != lastFace(); ++it) + for(auto it = firstFace(); it != lastFace(); ++it) for(std::size_t i = 0; i < (*it)->mesh_vertices.size(); i++) (*it)->mesh_vertices[i]->writeVRML(fp, scalingFactor); fprintf(fp, " ]\n"); fprintf(fp, "}\n"); - for(eiter it = firstEdge(); it != lastEdge(); ++it) { + for(auto it = firstEdge(); it != lastEdge(); ++it) { if(saveAll || (*it)->physicals.size()) { fprintf(fp, "DEF Curve%d IndexedLineSet {\n", (*it)->tag()); fprintf(fp, " coordIndex [\n"); @@ -235,7 +230,7 @@ int GModel::writeVRML(const std::string &name, bool saveAll, } } - for(fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { if(saveAll || (*it)->physicals.size()) { fprintf(fp, "DEF Surface%d IndexedFaceSet {\n", (*it)->tag()); fprintf(fp, " coordIndex [\n"); diff --git a/Geo/GModelIO_VTK.cpp b/Geo/GModelIO_VTK.cpp index ca1244cf19f875bdb6fe3ac77f71a766b6748e05..3ccaed8dd1ed582cb33b464d5a4c654a152b221f 100644 --- a/Geo/GModelIO_VTK.cpp +++ b/Geo/GModelIO_VTK.cpp @@ -314,44 +314,63 @@ int GModel::readVTK(const std::string &name, bool bigEndian) // first order elements case 3: elements[1][iCurve].push_back(new MLine(cells[i])); break; case 5: elements[2][iSurface].push_back(new MTriangle(cells[i])); break; - case 9: elements[3][iSurface].push_back(new MQuadrangle(cells[i])); break; - case 10: elements[4][iVolume].push_back(new MTetrahedron(cells[i])); break; - case 12: elements[5][iVolume].push_back(new MHexahedron(cells[i])); break; + case 9: + elements[3][iSurface].push_back(new MQuadrangle(cells[i])); + break; + case 10: + elements[4][iVolume].push_back(new MTetrahedron(cells[i])); + break; + case 12: + elements[5][iVolume].push_back(new MHexahedron(cells[i])); + break; case 13: elements[6][iVolume].push_back(new MPrism(cells[i])); break; case 14: elements[7][iVolume].push_back(new MPyramid(cells[i])); break; // second order elements case 21: elements[1][iCurve].push_back(new MLine3(cells[i])); break; - case 22: elements[2][iSurface].push_back(new MTriangle6(cells[i])); break; - case 23: elements[3][iSurface].push_back(new MQuadrangle8(cells[i])); break; - case 28: elements[3][iSurface].push_back(new MQuadrangle9(cells[i])); break; - case 24: elements[4][iVolume].push_back(new MTetrahedron10( - cells[i][0], cells[i][1], cells[i][2], cells[i][3], cells[i][4], - cells[i][5], cells[i][6], cells[i][7], cells[i][9], cells[i][8])); + case 22: + elements[2][iSurface].push_back(new MTriangle6(cells[i])); + break; + case 23: + elements[3][iSurface].push_back(new MQuadrangle8(cells[i])); break; - case 25: elements[5][iVolume].push_back(new MHexahedron20( - cells[i][0], cells[i][1], cells[i][2], cells[i][3], cells[i][4], - cells[i][5], cells[i][6], cells[i][7], cells[i][8], cells[i][11], - cells[i][13], cells[i][9], cells[i][16], cells[i][18], cells[i][19], - cells[i][17], cells[i][10], cells[i][12], cells[i][14], cells[i][15])); + case 28: + elements[3][iSurface].push_back(new MQuadrangle9(cells[i])); break; - case 29: elements[5][iVolume].push_back(new MHexahedron27( - cells[i][0], cells[i][1], cells[i][2], cells[i][3], cells[i][4], - cells[i][5], cells[i][6], cells[i][7], cells[i][8], cells[i][11], - cells[i][13], cells[i][9], cells[i][16], cells[i][18], cells[i][19], - cells[i][17], cells[i][10], cells[i][12], cells[i][14], cells[i][15], - cells[i][22], cells[i][23], cells[i][21], cells[i][24], cells[i][20], - cells[i][25], cells[i][26])); + case 24: + elements[4][iVolume].push_back(new MTetrahedron10( + cells[i][0], cells[i][1], cells[i][2], cells[i][3], cells[i][4], + cells[i][5], cells[i][6], cells[i][7], cells[i][9], cells[i][8])); break; - case 26: elements[6][iVolume].push_back(new MPrism15( - cells[i][0], cells[i][1], cells[i][2], cells[i][3], cells[i][4], - cells[i][5], cells[i][6], cells[i][9], cells[i][7], cells[i][12], - cells[i][14], cells[i][13], cells[i][8], cells[i][10], cells[i][11])); + case 25: + elements[5][iVolume].push_back(new MHexahedron20( + cells[i][0], cells[i][1], cells[i][2], cells[i][3], cells[i][4], + cells[i][5], cells[i][6], cells[i][7], cells[i][8], cells[i][11], + cells[i][13], cells[i][9], cells[i][16], cells[i][18], cells[i][19], + cells[i][17], cells[i][10], cells[i][12], cells[i][14], + cells[i][15])); break; - case 32: elements[6][iVolume].push_back(new MPrism18( - cells[i][0], cells[i][1], cells[i][2], cells[i][3], cells[i][4], - cells[i][5], cells[i][6], cells[i][9], cells[i][7], cells[i][12], - cells[i][14], cells[i][13], cells[i][8], cells[i][10], cells[i][11], - cells[i][15], cells[i][17], cells[i][16])); + case 29: + elements[5][iVolume].push_back(new MHexahedron27( + cells[i][0], cells[i][1], cells[i][2], cells[i][3], cells[i][4], + cells[i][5], cells[i][6], cells[i][7], cells[i][8], cells[i][11], + cells[i][13], cells[i][9], cells[i][16], cells[i][18], cells[i][19], + cells[i][17], cells[i][10], cells[i][12], cells[i][14], + cells[i][15], cells[i][22], cells[i][23], cells[i][21], + cells[i][24], cells[i][20], cells[i][25], cells[i][26])); + break; + case 26: + elements[6][iVolume].push_back( + new MPrism15(cells[i][0], cells[i][1], cells[i][2], cells[i][3], + cells[i][4], cells[i][5], cells[i][6], cells[i][9], + cells[i][7], cells[i][12], cells[i][14], cells[i][13], + cells[i][8], cells[i][10], cells[i][11])); + break; + case 32: + elements[6][iVolume].push_back(new MPrism18( + cells[i][0], cells[i][1], cells[i][2], cells[i][3], cells[i][4], + cells[i][5], cells[i][6], cells[i][9], cells[i][7], cells[i][12], + cells[i][14], cells[i][13], cells[i][8], cells[i][10], cells[i][11], + cells[i][15], cells[i][17], cells[i][16])); break; default: Msg::Error("Unknown type of cell %d", type); break; } @@ -364,7 +383,9 @@ int GModel::readVTK(const std::string &name, bool bigEndian) case 1: elements[0][iPoint++].push_back(new MPoint(cells[i])); break; case 2: elements[1][iCurve].push_back(new MLine(cells[i])); break; case 3: elements[2][iSurface].push_back(new MTriangle(cells[i])); break; - case 4: elements[3][iSurface].push_back(new MQuadrangle(cells[i])); break; + case 4: + elements[3][iSurface].push_back(new MQuadrangle(cells[i])); + break; default: Msg::Error("Unknown type of mesh element with %d nodes", nbNodes); break; diff --git a/Geo/GModelIO_X3D.cpp b/Geo/GModelIO_X3D.cpp index 9e00373f29af50d6d1d6c7e93c4fbd495aa8c24d..1e2c405ea41b7f1a00027bba4338d1e8c3fc7011 100644 --- a/Geo/GModelIO_X3D.cpp +++ b/Geo/GModelIO_X3D.cpp @@ -25,14 +25,12 @@ static void writeX3dFaces(FILE *fp, std::vector<GFace *> &faces, { bool useGeoSTL = false; unsigned int nfacets = 0; - for(std::vector<GFace *>::iterator it = faces.begin(); it != faces.end(); - ++it) { + for(auto it = faces.begin(); it != faces.end(); ++it) { nfacets += (*it)->triangles.size() + 2 * (*it)->quadrangles.size(); } if(!nfacets) { // use CAD STL if there is no mesh useGeoSTL = true; - for(std::vector<GFace *>::iterator it = faces.begin(); it != faces.end(); - ++it) { + for(auto it = faces.begin(); it != faces.end(); ++it) { (*it)->buildSTLTriangulation(); nfacets += (*it)->stl_triangles.size() / 3; } @@ -49,8 +47,7 @@ static void writeX3dFaces(FILE *fp, std::vector<GFace *> &faces, // floating-point data will be duplicated) fprintf(fp, " <IndexedTriangleSet DEF=\"set%s\" index=\"\n", name.c_str()); - for(std::vector<GFace *>::iterator it = faces.begin(); it != faces.end(); - ++it) { + for(auto it = faces.begin(); it != faces.end(); ++it) { if((*it)->stl_triangles.size()) { for(std::size_t i = 0; i < (*it)->stl_triangles.size(); i++) { fprintf(fp, "%d ", (*it)->stl_triangles[i]); @@ -61,8 +58,7 @@ static void writeX3dFaces(FILE *fp, std::vector<GFace *> &faces, fprintf(fp, "\">\n"); fprintf(fp, " <Coordinate point=\"\n"); - for(std::vector<GFace *>::iterator it = faces.begin(); it != faces.end(); - ++it) { + for(auto it = faces.begin(); it != faces.end(); ++it) { if((*it)->stl_vertices_uv.size()) { for(std::size_t i = 0; i < (*it)->stl_vertices_uv.size(); i++) { SPoint2 &p((*it)->stl_vertices_uv[i]); @@ -79,8 +75,7 @@ static void writeX3dFaces(FILE *fp, std::vector<GFace *> &faces, fprintf(fp, "\"></Coordinate>\n"); fprintf(fp, " <Normal vector=\"\n"); - for(std::vector<GFace *>::iterator it = faces.begin(); it != faces.end(); - ++it) { + for(auto it = faces.begin(); it != faces.end(); ++it) { if((*it)->stl_normals.size()) { for(std::size_t i = 0; i < (*it)->stl_normals.size(); i++) { SVector3 &n((*it)->stl_normals[i]); @@ -101,8 +96,7 @@ static void writeX3dFaces(FILE *fp, std::vector<GFace *> &faces, fprintf(fp, " <TriangleSet DEF=\"set%s\">\n", name.c_str()); fprintf(fp, " <Coordinate point=\"\n"); - for(std::vector<GFace *>::iterator it = faces.begin(); it != faces.end(); - ++it) { + for(auto it = faces.begin(); it != faces.end(); ++it) { if((*it)->stl_vertices_uv.size()) { for(std::size_t i = 0; i < (*it)->stl_triangles.size(); i += 3) { SPoint2 &p1((*it)->stl_vertices_uv[(*it)->stl_triangles[i]]); @@ -128,8 +122,7 @@ static void writeX3dFaces(FILE *fp, std::vector<GFace *> &faces, fprintf(fp, "\"></Coordinate>\n"); fprintf(fp, " <Normal vector=\"\n"); - for(std::vector<GFace *>::iterator it = faces.begin(); it != faces.end(); - ++it) { + for(auto it = faces.begin(); it != faces.end(); ++it) { if((*it)->stl_normals.size()) { for(std::size_t i = 0; i < (*it)->stl_triangles.size(); i++) { SVector3 &n((*it)->stl_normals[(*it)->stl_triangles[i]]); @@ -148,8 +141,7 @@ static void writeX3dFaces(FILE *fp, std::vector<GFace *> &faces, else { fprintf(fp, " <TriangleSet DEF=\"set%s\">\n", name.c_str()); fprintf(fp, " <Coordinate point=\"\n"); - for(std::vector<GFace *>::iterator it = faces.begin(); it != faces.end(); - ++it) { + for(auto it = faces.begin(); it != faces.end(); ++it) { for(std::size_t i = 0; i < (*it)->triangles.size(); i++) (*it)->triangles[i]->writeX3D(fp, scalingFactor); for(std::size_t i = 0; i < (*it)->quadrangles.size(); i++) @@ -165,8 +157,7 @@ static void writeX3dFaces(FILE *fp, std::vector<GFace *> &faces, static void writeX3dEdges(FILE *fp, std::vector<GEdge *> &edges, double scalingFactor, const std::string &name) { - for(std::vector<GEdge *>::iterator it = edges.begin(); it != edges.end(); - ++it) { + for(auto it = edges.begin(); it != edges.end(); ++it) { if((*it)->stl_vertices_xyz.size()) { fprintf(fp, " <Shape DEF=\"%s\">\n", name.c_str()); fprintf(fp, @@ -229,7 +220,7 @@ int GModel::writeX3D(const std::string &name, bool saveAll, if(x3dsurfaces == 1) { // all surfaces in a single x3d object std::vector<GFace *> faces; - for(fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { if(saveAll || (*it)->physicals.size()) { faces.push_back(*it); } } std::string name = "face"; @@ -237,7 +228,7 @@ int GModel::writeX3D(const std::string &name, bool saveAll, } else if(x3dsurfaces == 2) { // one x3d object for each physical surface - for(fiter it = firstFace(); it != lastFace(); ++it) { + for(auto it = firstFace(); it != lastFace(); ++it) { if(saveAll || (*it)->physicals.size()) { std::vector<GFace *> faces(1, *it); std::string name = getElementaryName(2, (*it)->tag()); @@ -254,8 +245,7 @@ int GModel::writeX3D(const std::string &name, bool saveAll, // one x3d object per physical surface std::map<int, std::vector<GEntity *> > phys; getPhysicalGroups(2, phys); - for(std::map<int, std::vector<GEntity *> >::iterator it = phys.begin(); - it != phys.end(); it++) { + for(auto it = phys.begin(); it != phys.end(); it++) { std::vector<GFace *> faces; for(std::size_t i = 0; i < it->second.size(); i++) { faces.push_back(static_cast<GFace *>(it->second[i])); @@ -279,7 +269,7 @@ int GModel::writeX3D(const std::string &name, bool saveAll, if(x3dedges == 1) { // all edges in a single x3d object std::vector<GEdge *> edges; - for(eiter it = firstEdge(); it != lastEdge(); ++it) { + for(auto it = firstEdge(); it != lastEdge(); ++it) { if(saveAll || (*it)->physicals.size()) { edges.push_back(*it); } } std::string name = "edge"; @@ -287,7 +277,7 @@ int GModel::writeX3D(const std::string &name, bool saveAll, } else if(x3dedges == 2) { // one x3d object for each physical edge - for(eiter it = firstEdge(); it != lastEdge(); ++it) { + for(auto it = firstEdge(); it != lastEdge(); ++it) { if(saveAll || (*it)->physicals.size()) { std::vector<GEdge *> edges(1, *it); std::string name = getElementaryName(1, (*it)->tag()); @@ -304,8 +294,7 @@ int GModel::writeX3D(const std::string &name, bool saveAll, // one x3d object per physical edge std::map<int, std::vector<GEntity *> > phys; getPhysicalGroups(1, phys); - for(std::map<int, std::vector<GEntity *> >::iterator it = phys.begin(); - it != phys.end(); it++) { + for(auto it = phys.begin(); it != phys.end(); it++) { std::vector<GEdge *> edges; for(std::size_t i = 0; i < it->second.size(); i++) { edges.push_back(static_cast<GEdge *>(it->second[i])); @@ -326,7 +315,7 @@ int GModel::writeX3D(const std::string &name, bool saveAll, if(x3dvertices != 0) { fprintf(fp, " <Group DEF=\"vertices\" render=\"false\">\n"); - for(viter it = firstVertex(); it != lastVertex(); ++it) { + for(auto it = firstVertex(); it != lastVertex(); ++it) { fprintf(fp, " <Transform DEF=\"vertex%d\" translation=\"%g %g %g\">\n", (*it)->tag(), (*it)->x(), (*it)->y(), (*it)->z()); fprintf(fp, " <Shape>\n"); diff --git a/Geo/GModelParametrize.cpp b/Geo/GModelParametrize.cpp index 9bc4dbc0e5c6093ae884e4c554853f9d1d11e8a9..50f2258d9bfd82688b61274cbd33ed9480207604 100644 --- a/Geo/GModelParametrize.cpp +++ b/Geo/GModelParametrize.cpp @@ -72,7 +72,7 @@ addTriangle(MTriangle *t, { for(int i = 0; i < 3; i++) { MEdge e = t->getEdge(i); - std::map<MEdge, std::vector<MTriangle *> >::iterator it = tris.find(e); + auto it = tris.find(e); if(it == tris.end()) { std::vector<MTriangle *> v; v.push_back(t); @@ -110,7 +110,7 @@ void classifyFaces(GModel *gm, double curveAngleThreshold) // check if mesh is high-order bool ho = false; - for(GModel::fiter it = gm->firstFace(); it != gm->lastFace(); it++) { + for(auto it = gm->firstFace(); it != gm->lastFace(); it++) { GFace *gf = *it; for(std::size_t i = 0; i < gf->triangles.size(); i++) { if(gf->triangles[i]->getPolynomialOrder() > 1) { @@ -129,7 +129,7 @@ void classifyFaces(GModel *gm, double curveAngleThreshold) // from the model std::set<MLine *, MLinePtrLessThan> lines; std::vector<GEdge *> edgesToRemove; - for(GModel::eiter it = gm->firstEdge(); it != gm->lastEdge(); ++it) { + for(auto it = gm->firstEdge(); it != gm->lastEdge(); ++it) { for(std::size_t i = 0; i < (*it)->lines.size(); i++) { lines.insert((*it)->lines[i]); } @@ -141,7 +141,7 @@ void classifyFaces(GModel *gm, double curveAngleThreshold) // remove points from model std::vector<GVertex *> pointsToRemove; - for(GModel::viter it = gm->firstVertex(); it != gm->lastVertex(); ++it) { + for(auto it = gm->firstVertex(); it != gm->lastVertex(); ++it) { pointsToRemove.push_back(*it); } for(std::size_t i = 0; i < pointsToRemove.size(); ++i) { @@ -152,7 +152,7 @@ void classifyFaces(GModel *gm, double curveAngleThreshold) std::map<MTriangle *, GFace *> reverse_old; std::map<MEdge, std::vector<MTriangle *>, MEdgeLessThan> tris; std::set<MTriangle *, MElementPtrLessThan> touched; - for(GModel::fiter it = gm->firstFace(); it != gm->lastFace(); it++) { + for(auto it = gm->firstFace(); it != gm->lastFace(); it++) { GFace *gf = *it; for(std::size_t i = 0; i < gf->triangles.size(); i++) { touched.insert(gf->triangles[i]); @@ -169,8 +169,7 @@ void classifyFaces(GModel *gm, double curveAngleThreshold) } // reset classification of all mesh nodes - for(std::set<MTriangle *, MElementPtrLessThan>::iterator it = touched.begin(); - it != touched.end(); it++) { + for(auto it = touched.begin(); it != touched.end(); it++) { for(std::size_t j = 0; j < (*it)->getNumVertices(); j++) (*it)->getVertex(j)->setEntity(0); } @@ -192,18 +191,16 @@ void classifyFaces(GModel *gm, double curveAngleThreshold) st.pop(); for(int i = 0; i < 3; i++) { MEdge e = t->getEdge(i); - std::map<MEdge, std::vector<MTriangle *>, MEdgeLessThan>::iterator - it = tris.find(e); + auto it = tris.find(e); if(it == tris.end()) { Msg::Error("Could not find triangle linked to edge"); break; } MLine ll(e.getVertex(0), e.getVertex(1)); - std::set<MLine *, MLinePtrLessThan>::iterator itl = lines.find(&ll); + auto itl = lines.find(&ll); if(itl == lines.end()) { MTriangle *tt = it->second[0] == t ? it->second[1] : it->second[0]; - std::set<MTriangle *, MElementPtrLessThan>::iterator it2 = - touched.find(tt); + auto it2 = touched.find(tt); if(it2 != touched.end()) { st.push(tt); touched.erase(it2); @@ -223,15 +220,12 @@ void classifyFaces(GModel *gm, double curveAngleThreshold) // now we have all faces coloured. If some regions were existing, replace // their faces by the new ones - for(GModel::riter rit = gm->firstRegion(); rit != gm->lastRegion(); ++rit) { + for(auto rit = gm->firstRegion(); rit != gm->lastRegion(); ++rit) { std::vector<GFace *> _xfaces = (*rit)->faces(); std::set<GFace *, GEntityPtrLessThan> _newFaces; - for(std::vector<GFace *>::iterator itf = _xfaces.begin(); - itf != _xfaces.end(); ++itf) { - std::multimap<GFace *, GFace *>::iterator itLow = - replacedBy.lower_bound(*itf); - std::multimap<GFace *, GFace *>::iterator itUp = - replacedBy.upper_bound(*itf); + for(auto itf = _xfaces.begin(); itf != _xfaces.end(); ++itf) { + auto itLow = replacedBy.lower_bound(*itf); + auto itUp = replacedBy.upper_bound(*itf); for(; itLow != itUp; ++itLow) _newFaces.insert(itLow->second); } @@ -240,11 +234,10 @@ void classifyFaces(GModel *gm, double curveAngleThreshold) std::vector<std::pair<GEdge *, std::vector<GFace *> > > newEdges; { - std::map<MEdge, std::vector<MTriangle *>, MEdgeLessThan>::iterator it = - tris.begin(); + auto it = tris.begin(); for(; it != tris.end(); ++it) { MLine ml(it->first.getVertex(0), it->first.getVertex(1)); - std::set<MLine *, MLinePtrLessThan>::iterator itl = lines.find(&ml); + auto itl = lines.find(&ml); if(itl != lines.end()) { std::vector<GFace *> faces; for(size_t i = 0; i < it->second.size(); ++i) @@ -262,9 +255,7 @@ void classifyFaces(GModel *gm, double curveAngleThreshold) newFaceTopology; std::map<MVertex *, GVertex *> modelVertices; - for(std::vector<std::pair<GEdge *, std::vector<GFace *> > >::iterator ite = - newEdges.begin(); - ite != newEdges.end(); ++ite) { + for(auto ite = newEdges.begin(); ite != newEdges.end(); ++ite) { std::vector<MEdge> allEdges; for(std::size_t i = 0; i < ite->first->lines.size(); i++) { @@ -326,7 +317,7 @@ void classifyFaces(GModel *gm, double curveAngleThreshold) MVertex *vB = vs[i][0]; MVertex *vE = vs[i][vs[i].size() - 1]; - std::map<MVertex *, GVertex *>::iterator itMV = modelVertices.find(vB); + auto itMV = modelVertices.find(vB); if(itMV == modelVertices.end()) { GVertex *newGv = new discreteVertex(gm, (MAX0++) + 1, vB->x(), vB->y(), vB->z()); @@ -372,14 +363,12 @@ void classifyFaces(GModel *gm, double curveAngleThreshold) } } - for(std::map<discreteFace *, std::vector<int>, GEntityPtrLessThan>::iterator - itFT = newFaceTopology.begin(); itFT != newFaceTopology.end(); ++itFT) { + for(auto itFT = newFaceTopology.begin(); itFT != newFaceTopology.end(); + ++itFT) { itFT->first->setBoundEdges(itFT->second); } - for(std::vector<std::pair<GEdge *, std::vector<GFace *> > >::iterator ite = - newEdges.begin(); - ite != newEdges.end(); ++ite) { + for(auto ite = newEdges.begin(); ite != newEdges.end(); ++ite) { GEdge *ge = ite->first; gm->remove(ge); // delete ge; @@ -387,8 +376,7 @@ void classifyFaces(GModel *gm, double curveAngleThreshold) // delete empty mesh faces and reclasssify std::set<GFace *, GEntityPtrLessThan> fac = gm->getFaces(); - for(std::set<GFace *, GEntityPtrLessThan>::iterator fit = fac.begin(); - fit != fac.end(); ++fit) { + for(auto fit = fac.begin(); fit != fac.end(); ++fit) { std::set<MVertex *, MVertexPtrLessThan> verts; (*fit)->mesh_vertices.clear(); for(std::size_t i = 0; i < (*fit)->triangles.size(); i++) { @@ -419,7 +407,7 @@ void classifyFaces(GModel *gm, double angleThreshold, bool includeBoundary, double t1 = Cpu(), w1 = TimeOfDay(); std::vector<MElement *> elements; - for(GModel::fiter it = gm->firstFace(); it != gm->lastFace(); ++it) { + for(auto it = gm->firstFace(); it != gm->lastFace(); ++it) { elements.insert(elements.end(), (*it)->triangles.begin(), (*it)->triangles.end()); elements.insert(elements.end(), (*it)->quadrangles.begin(), @@ -476,7 +464,7 @@ int computeDiscreteCurvatures(GModel *gm) { std::map<MVertex *, std::pair<SVector3, SVector3> > &C = gm->getCurvatures(); C.clear(); - for(GModel::fiter it = gm->firstFace(); it != gm->lastFace(); ++it) { + for(auto it = gm->firstFace(); it != gm->lastFace(); ++it) { GFace *gf = *it; std::map<MVertex *, int> nodeIndex; std::vector<SPoint3> nodes; @@ -498,8 +486,7 @@ int computeDiscreteCurvatures(GModel *gm) } } CurvatureRusinkiewicz(tris, nodes, curv); - for(std::map<MVertex *, int>::iterator itv = nodeIndex.begin(); - itv != nodeIndex.end(); itv++) { + for(auto itv = nodeIndex.begin(); itv != nodeIndex.end(); itv++) { C[itv->first] = curv[itv->second]; } } @@ -537,7 +524,8 @@ bool computeParametrization(const std::vector<MTriangle *> &triangles, // compute edge loops std::vector<MEdge> es; for(std::map<MEdge, std::vector<MTriangle *>, MEdgeLessThan>::const_iterator - it = edges.begin(); it != edges.end(); ++it) { + it = edges.begin(); + it != edges.end(); ++it) { if(it->second.size() == 1) { // on boundary es.push_back(it->first); } @@ -545,7 +533,8 @@ bool computeParametrization(const std::vector<MTriangle *> &triangles, } else { // non-manifold: not supported Msg::Error("Wrong topology of triangulation for parametrization: one " - "edge is incident to %d triangles", it->second.size()); + "edge is incident to %d triangles", + it->second.size()); return false; } } @@ -560,7 +549,8 @@ bool computeParametrization(const std::vector<MTriangle *> &triangles, } Msg::Debug("Parametrisation of surface with %lu triangles, %lu edges and " - "%lu holes", triangles.size(), edges.size(), vs.size() - 1); + "%lu holes", + triangles.size(), edges.size(), vs.size() - 1); // find longest loop and use it as the "exterior" loop int loop = 0; @@ -661,19 +651,18 @@ bool computeParametrization(const std::vector<MTriangle *> &triangles, if(vLeft == v0 || vLeft == v1) vLeft = tLeft->getVertex(2); double e[3] = {v1->x() - v0->x(), v1->y() - v0->y(), v1->z() - v0->z()}; double ne = sqrt(e[0] * e[0] + e[1] * e[1] + e[2] * e[2]); - double a[3] = {vLeft->x() - v0->x(), - vLeft->y() - v0->y(), + double a[3] = {vLeft->x() - v0->x(), vLeft->y() - v0->y(), vLeft->z() - v0->z()}; double na = sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]); - double thetaL = acos((a[0] * e[0] + a[1] * e[1] + a[2] * e[2]) / (na * ne)); + double thetaL = + acos((a[0] * e[0] + a[1] * e[1] + a[2] * e[2]) / (na * ne)); double thetaR = 0.; if(it->second.size() == 2) { MTriangle *tRight = it->second[1]; MVertex *vRight = tRight->getVertex(0); if(vRight == v0 || vRight == v1) vRight = tRight->getVertex(1); if(vRight == v0 || vRight == v1) vRight = tRight->getVertex(2); - double b[3] = {vRight->x() - v0->x(), - vRight->y() - v0->y(), + double b[3] = {vRight->x() - v0->x(), vRight->y() - v0->y(), vRight->z() - v0->z()}; double nb = sqrt(b[0] * b[0] + b[1] * b[1] + b[2] * b[2]); thetaR = acos((b[0] * e[0] + b[1] * e[1] + b[2] * e[2]) / (nb * ne)); @@ -741,8 +730,7 @@ static int isTriangulationParametrizable(const std::vector<MTriangle *> &t, surf += t[i]->getVolume(); for(int j = 0; j < 3; j++) { v.insert(t[i]->getVertex(j)); - std::map<MEdge, int, MEdgeLessThan>::iterator it = - e.find(t[i]->getEdge(j)); + auto it = e.find(t[i]->getEdge(j)); if(it == e.end()) e[t[i]->getEdge(j)] = 1; else @@ -750,8 +738,7 @@ static int isTriangulationParametrizable(const std::vector<MTriangle *> &t, } } std::vector<MEdge> bnd; - for(std::map<MEdge, int, MEdgeLessThan>::iterator it = e.begin(); - it != e.end(); ++it) { + for(auto it = e.begin(); it != e.end(); ++it) { if(it->second == 1) bnd.push_back(it->first); } if(bnd.empty()) { @@ -819,7 +806,7 @@ makePartitionSimplyConnected(std::vector<MTriangle *> &t, for(std::size_t i = 0; i < t.size(); i++) { for(int j = 0; j < 3; j++) { MEdge e = t[i]->getEdge(j); - std::map<MEdge, twoT, MEdgeLessThan>::iterator it = conn.find(e); + auto it = conn.find(e); twoT twt(t[i]); if(it == conn.end()) conn.insert(std::make_pair(e, twt)); @@ -838,7 +825,7 @@ makePartitionSimplyConnected(std::vector<MTriangle *> &t, _s.pop(); for(int j = 0; j < 3; j++) { MEdge e = x->getEdge(j); - std::map<MEdge, twoT, MEdgeLessThan>::iterator it = conn.find(e); + auto it = conn.find(e); if(it->second.t2) { MTriangle *tt = it->second.other(x); if(tt && touch.find(tt) == touch.end()) _s.push(tt); @@ -861,7 +848,7 @@ void computeEdgeCut(GModel *gm, std::vector<MLine *> &cut, { Msg::Info("Splitting triangulations to make them parametrizable:"); - for(GModel::fiter it = gm->firstFace(); it != gm->lastFace(); ++it) { + for(auto it = gm->firstFace(); it != gm->lastFace(); ++it) { int part = 0; if((*it)->triangles.empty()) continue; std::vector<MVertex *> verts = (*it)->mesh_vertices; @@ -887,8 +874,8 @@ void computeEdgeCut(GModel *gm, std::vector<MLine *> &cut, vs.end()); partitions.pop(); std::ostringstream why; - int np = isTriangulationParametrizable((*it)->triangles, - max_elems_per_cut, why); + int np = + isTriangulationParametrizable((*it)->triangles, max_elems_per_cut, why); if(np > 1) { Msg::Info(" - Level %d partition with %d triangles split in %d " "parts because %s", @@ -933,13 +920,12 @@ void computeEdgeCut(GModel *gm, std::vector<MLine *> &cut, } } (*it)->triangles.clear(); - for(std::map<MTriangle *, int, MElementPtrLessThan>::iterator it2 = - global.begin(); it2 != global.end(); ++it2) { + for(auto it2 = global.begin(); it2 != global.end(); ++it2) { MTriangle *t = it2->first; (*it)->triangles.push_back(t); for(int i = 0; i < 3; i++) { MEdge ed = t->getEdge(i); - std::map<MEdge, int, MEdgeLessThan>::iterator it3 = cuts.find(ed); + auto it3 = cuts.find(ed); if(it3 == cuts.end()) cuts[ed] = it2->second; else { @@ -957,11 +943,10 @@ void computeNonManifoldEdges(GModel *gm, std::vector<MLine *> &cut, bool addBoundary) { std::map<MEdge, int, MEdgeLessThan> m; - for(GModel::fiter it = gm->firstFace(); it != gm->lastFace(); ++it) { + for(auto it = gm->firstFace(); it != gm->lastFace(); ++it) { for(std::size_t i = 0; i < (*it)->triangles.size(); i++) { for(int j = 0; j < 3; j++) { - std::map<MEdge, int, MEdgeLessThan>::iterator it2 = - m.find((*it)->triangles[i]->getEdge(j)); + auto it2 = m.find((*it)->triangles[i]->getEdge(j)); if(it2 == m.end()) m[(*it)->triangles[i]->getEdge(j)] = 1; else @@ -971,7 +956,7 @@ void computeNonManifoldEdges(GModel *gm, std::vector<MLine *> &cut, } { int countNM = 0, countBND = 0; - std::map<MEdge, int, MEdgeLessThan>::iterator it = m.begin(); + auto it = m.begin(); for(; it != m.end(); ++it) { if(it->second > 2) { cut.push_back( diff --git a/Geo/GModelParametrize.h b/Geo/GModelParametrize.h index a25be196e4b3dd2f79e8570120ecd2a0a8e0e776..d58a9ec6e5a6d392c28f4e2656ddf76b989ebb28 100644 --- a/Geo/GModelParametrize.h +++ b/Geo/GModelParametrize.h @@ -14,8 +14,8 @@ void computeEdgeCut(GModel *gm, std::vector<MLine *> &cut, void computeNonManifoldEdges(GModel *gm, std::vector<MLine *> &cut, bool addBoundary); int computeDiscreteCurvatures(GModel *gm); -bool computeParametrization(const std::vector<MTriangle*> &triangles, - std::vector<MVertex*> &nodes, +bool computeParametrization(const std::vector<MTriangle *> &triangles, + std::vector<MVertex *> &nodes, std::vector<SPoint2> &stl_vertices_uv, std::vector<SPoint3> &stl_vertices_xyz, std::vector<int> &stl_triangles); diff --git a/Geo/GModelVertexArrays.cpp b/Geo/GModelVertexArrays.cpp index 25ed75b81793a67ea74ecb1635fab6fcdf9c3dba..acda27e710a7ae9810ba1d3a1431fab0d78413b1 100644 --- a/Geo/GModelVertexArrays.cpp +++ b/Geo/GModelVertexArrays.cpp @@ -125,8 +125,7 @@ bool isElementVisible(MElement *ele) bool hidden = false; for(int clip = 0; clip < 6; clip++) { if(CTX::instance()->mesh.clip & (1 << clip)) { - if(ele->getDim() < 3 && CTX::instance()->clipOnlyVolume) { - } + if(ele->getDim() < 3 && CTX::instance()->clipOnlyVolume) {} else { double d = intersectClipPlane(clip, ele); if(ele->getDim() == 3 && @@ -343,7 +342,8 @@ public: _curved = (areSomeElementsCurved(f->triangles) || areSomeElementsCurved(f->quadrangles)); f->va_lines = new VertexArray(2, edg ? _estimateNumLines(f) : 100); - f->va_triangles = new VertexArray(3, fac ? _estimateNumTriangles(f) : 100); + f->va_triangles = + new VertexArray(3, fac ? _estimateNumTriangles(f) : 100); if(CTX::instance()->mesh.triangles) addElementsInArrays(f, f->triangles, edg, fac); if(CTX::instance()->mesh.quadrangles) @@ -362,12 +362,12 @@ private: { if(CTX::instance()->clipWholeElements) { for(int clip = 0; clip < 6; clip++) { - if(CTX::instance()->mesh.clip & (1 << clip)){ - if(CTX::instance()->clipOnlyDrawIntersectingVolume){ + if(CTX::instance()->mesh.clip & (1 << clip)) { + if(CTX::instance()->clipOnlyDrawIntersectingVolume) { // let be more aggressive than num^{2/3} return (int)sqrt((double)num); } - else{ + else { // why not :-) return num / 4; } @@ -434,7 +434,8 @@ public: areSomeElementsCurved(r->pyramids) || areSomeElementsCurved(r->trihedra)); r->va_lines = new VertexArray(2, edg ? _estimateNumLines(r) : 100); - r->va_triangles = new VertexArray(3, fac ? _estimateNumTriangles(r) : 100); + r->va_triangles = + new VertexArray(3, fac ? _estimateNumTriangles(r) : 100); if(CTX::instance()->mesh.tetrahedra) addElementsInArrays(r, r->tetrahedra, edg, fac); if(CTX::instance()->mesh.hexahedra) diff --git a/Geo/GRegion.h b/Geo/GRegion.h index 37e608f9597fabb3da711eff636241f62e71cebd..7dbc85662a0de3aa66f86a7e094b0d645e37d81b 100644 --- a/Geo/GRegion.h +++ b/Geo/GRegion.h @@ -151,10 +151,7 @@ public: double meshSize; } meshAttributes; - virtual double getMeshSize() const - { - return meshAttributes.meshSize; - } + virtual double getMeshSize() const { return meshAttributes.meshSize; } // a array for accessing the transfinite vertices using a triplet of // indices @@ -179,7 +176,8 @@ public: // get the boundary layer columns BoundaryLayerColumns *getColumns() { return &_columns; } - virtual bool reorder(const int elementType, const std::vector<std::size_t> &ordering); + virtual bool reorder(const int elementType, + const std::vector<std::size_t> &ordering); // set the reverseMesh constraint in the bounding surfaces so that the // boundary mesh has outward pointing normals, based on the STL triangulation diff --git a/Geo/GVertex.h b/Geo/GVertex.h index f6d1d83a43443e91ca0275c4cd3aa2b4f4fe2006..b2f950483cdbbde8e45fc087863744a7bb39ebb6 100644 --- a/Geo/GVertex.h +++ b/Geo/GVertex.h @@ -117,7 +117,8 @@ public: void addElement(int type, MElement *e); void removeElement(int type, MElement *e); - virtual bool reorder(const int elementType, const std::vector<std::size_t> &ordering); + virtual bool reorder(const int elementType, + const std::vector<std::size_t> &ordering); }; #endif diff --git a/Geo/Geo.cpp b/Geo/Geo.cpp index d0899e62ba82edb33020ec7895a47db3490397fc..b3bbb33f240083dcf13de20bc13d8c3f2454c5aa 100644 --- a/Geo/Geo.cpp +++ b/Geo/Geo.cpp @@ -39,7 +39,7 @@ static int ComparePosition(const void *a, const void *b) Vertex *q = *(Vertex **)a; Vertex *w = *(Vertex **)b; - if(!q || !w){ + if(!q || !w) { Msg::Error("Cannot compare position of null points"); return 99; } @@ -295,9 +295,7 @@ bool EndCurve(Curve *c) double n[3]; prodve(dir12, dir32, n); bool isValid = true; - if(norm3(n) < 1.e-15) { - isValid = false; - } + if(norm3(n) < 1.e-15) { isValid = false; } else { norme(n); if((fabs(n[0]) < 1.e-5 && fabs(n[1]) < 1.e-5 && fabs(n[2]) < 1.e-5)) { @@ -550,8 +548,7 @@ Curve *CreateCurve(int Num, int Typ, int Order, List_T *Liste, List_T *Knots, ok = false; } } - if(!EndCurve(pC)) - ok = false; + if(!EndCurve(pC)) ok = false; } return pC; @@ -675,9 +672,7 @@ static Vertex *FindPoint(int inum, Tree_T *t) Vertex C, *pc; pc = &C; pc->Num = inum; - if(Tree_Query(t, &pc)) { - return pc; - } + if(Tree_Query(t, &pc)) { return pc; } return NULL; } @@ -691,9 +686,7 @@ static Curve *FindCurve(int inum, Tree_T *t) Curve C, *pc; pc = &C; pc->Num = inum; - if(Tree_Query(t, &pc)) { - return pc; - } + if(Tree_Query(t, &pc)) { return pc; } return NULL; } @@ -707,9 +700,7 @@ static Surface *FindSurface(int inum, Tree_T *t) Surface S, *ps; ps = &S; ps->Num = inum; - if(Tree_Query(t, &ps)) { - return ps; - } + if(Tree_Query(t, &ps)) { return ps; } return NULL; } @@ -959,8 +950,7 @@ void DeleteCurve(int ip, bool recursive) } if(c->beg) vv.insert(c->beg->Num); if(c->end) vv.insert(c->end->Num); - for(std::set<int>::iterator it = vv.begin(); it != vv.end(); it++) - DeletePoint(*it); + for(auto it = vv.begin(); it != vv.end(); it++) DeletePoint(*it); } } @@ -1002,12 +992,11 @@ void DeleteSurface(int is, bool recursive) if(c->beg) vv.insert(c->beg->Num); if(c->end) vv.insert(c->end->Num); } - for(std::set<int>::iterator it = cc.begin(); it != cc.end(); it++) { + for(auto it = cc.begin(); it != cc.end(); it++) { DeleteCurve(*it); DeleteCurve(-*it); } - for(std::set<int>::iterator it = vv.begin(); it != vv.end(); it++) - DeletePoint(*it); + for(auto it = vv.begin(); it != vv.end(); it++) DeletePoint(*it); } } @@ -1041,14 +1030,12 @@ void DeleteVolume(int iv, bool recursive) if(c->end) vv.insert(c->end->Num); } } - for(std::set<int>::iterator it = ss.begin(); it != ss.end(); it++) - DeleteSurface(*it); - for(std::set<int>::iterator it = cc.begin(); it != cc.end(); it++) { + for(auto it = ss.begin(); it != ss.end(); it++) DeleteSurface(*it); + for(auto it = cc.begin(); it != cc.end(); it++) { DeleteCurve(*it); DeleteCurve(-*it); } - for(std::set<int>::iterator it = vv.begin(); it != vv.end(); it++) - DeletePoint(*it); + for(auto it = vv.begin(); it != vv.end(); it++) DeletePoint(*it); } } @@ -1198,9 +1185,7 @@ int RecognizeSurfaceLoop(List_T *liste, int *loop) void SetTranslationMatrix(double matrix[4][4], double T[3]) { for(int i = 0; i < 4; i++) { - for(int j = 0; j < 4; j++) { - matrix[i][j] = (i == j) ? 1.0 : 0.0; - } + for(int j = 0; j < 4; j++) { matrix[i][j] = (i == j) ? 1.0 : 0.0; } } for(int i = 0; i < 3; i++) matrix[i][3] = T[i]; } @@ -1229,8 +1214,8 @@ void SetSymmetryMatrix(double matrix[4][4], double A, double B, double C, matrix[3][3] = 1.0; } -void SetDilatationMatrix(double matrix[4][4], double T[3], double A, - double B, double C) +void SetDilatationMatrix(double matrix[4][4], double T[3], double A, double B, + double C) { matrix[0][0] = A; matrix[0][1] = 0.0; @@ -1332,9 +1317,7 @@ static void vecmat4x4(double mat[4][4], double vec[4], double res[4]) { for(int i = 0; i < 4; i++) { res[i] = 0.0; - for(int j = 0; j < 4; j++) { - res[i] += mat[i][j] * vec[j]; - } + for(int j = 0; j < 4; j++) { res[i] += mat[i][j] * vec[j]; } } } @@ -1640,8 +1623,8 @@ static int CompareTwoCurves(const void *a, const void *b) // with the same beg/end points if(c1->Typ == MSH_SEGM_BND_LAYER && c1->Extrude && c2->Typ == MSH_SEGM_BND_LAYER && c2->Extrude) { - int comp = std::abs(c1->Extrude->geo.Source) - - std::abs(c2->Extrude->geo.Source); + int comp = + std::abs(c1->Extrude->geo.Source) - std::abs(c2->Extrude->geo.Source); if(comp) return comp; } @@ -1796,9 +1779,7 @@ static void ReplaceDuplicatePointsNew(double tol = -1.) Tree_Add(GModel::current()->getGEOInternals()->DelPoints, &V); delete unused[i]; } - for(std::size_t i = 0; i < used.size(); i++) { - delete used[i]; - } + for(std::size_t i = 0; i < used.size(); i++) { delete used[i]; } int end = Tree_Nbr(GModel::current()->getGEOInternals()->Points); Msg::Info("Done new Coherence (removed %d additional points)", start - end); } @@ -1835,7 +1816,7 @@ static void ReplaceDuplicatePoints(std::map<int, int> *v_report = 0) Tree_Suppress(GModel::current()->getGEOInternals()->Points, &v); Tree_Insert(points2delete, &v); if(v_report) { // keep track of changes - std::map<int, int>::iterator m_it = v_report->find(v->Num); + auto m_it = v_report->find(v->Num); if(m_it != v_report->end()) { Vertex **v_rep = (Vertex **)Tree_PQuery(allNonDuplicatedPoints, &v); if(v_rep) m_it->second = (*v_rep)->Num; @@ -2022,7 +2003,7 @@ static void ReplaceDuplicateCurves(std::map<int, int> *c_report = 0) Tree_Insert(curves2delete, &c2); if(c_report) { // keep track of changes - std::map<int, int>::iterator m_it = c_report->find(c->Num); + auto m_it = c_report->find(c->Num); if(m_it != c_report->end()) { Curve **c_rep = (Curve **)Tree_PQuery(allNonDuplicatedCurves, &c); if(c_rep) m_it->second = (*c_rep)->Num; @@ -2198,7 +2179,7 @@ static void RemoveDegenerateVolumes() for(int j = 0; j < N; j++) { Surface *s; List_Read(v->Surfaces, j, &s); - std::set<int>::iterator it = unique.find(-s->Num); + auto it = unique.find(-s->Num); if(it == unique.end()) unique.insert(s->Num); else @@ -2241,7 +2222,7 @@ static void RemoveDegenerateSurfaces() for(int j = 0; j < N; j++) { Curve *c; List_Read(s->Generatrices, j, &c); - std::set<int>::iterator it = unique.find(-c->Num); + auto it = unique.find(-c->Num); if(it == unique.end()) unique.insert(c->Num); else @@ -2325,7 +2306,7 @@ static void ReplaceDuplicateSurfaces(std::map<int, int> *s_report = 0) Tree_Insert(surfaces2delete, &s); if(s_report) { // keep track of changes - std::map<int, int>::iterator m_it = (*s_report).find(s->Num); + auto m_it = (*s_report).find(s->Num); if(m_it != s_report->end()) { Surface **s_rep = (Surface **)Tree_PQuery(allNonDuplicatedSurfaces, &s); @@ -2520,7 +2501,8 @@ int ExtrudePoint(int type, int ip, double T0, double T1, double T2, double A0, List_Reset(ListOfTransformedPoints); ApplyTransformationToPoint(matrix, chapeau); if(!ComparePosition(&pv, &chapeau)) return pv->Num; - c = CreateCurve(NEWLINE(), MSH_SEGM_LINE, 1, NULL, NULL, -1, -1, 0., 1., ok); + c = + CreateCurve(NEWLINE(), MSH_SEGM_LINE, 1, NULL, NULL, -1, -1, 0., 1., ok); c->Control_Points = List_Create(2, 1, sizeof(Vertex *)); c->Extrude = new ExtrudeParams; c->Extrude->fill(type, T0, T1, T2, A0, A1, A2, X0, X1, X2, alpha); @@ -2533,8 +2515,8 @@ int ExtrudePoint(int type, int ip, double T0, double T1, double T2, double A0, case BOUNDARY_LAYER: chapeau->Typ = MSH_POINT_BND_LAYER; if(e) chapeau->boundaryLayerIndex = e->mesh.BoundaryLayerIndex; - c = - CreateCurve(NEWLINE(), MSH_SEGM_BND_LAYER, 1, NULL, NULL, -1, -1, 0., 1., ok); + c = CreateCurve(NEWLINE(), MSH_SEGM_BND_LAYER, 1, NULL, NULL, -1, -1, 0., + 1., ok); c->Control_Points = List_Create(2, 1, sizeof(Vertex *)); c->Extrude = new ExtrudeParams; c->Extrude->fill(type, T0, T1, T2, A0, A1, A2, X0, X1, X2, alpha); @@ -2564,7 +2546,8 @@ int ExtrudePoint(int type, int ip, double T0, double T1, double T2, double A0, List_Reset(ListOfTransformedPoints); ApplyTransformationToPoint(matrix, chapeau); if(!ComparePosition(&pv, &chapeau)) return pv->Num; - c = CreateCurve(NEWLINE(), MSH_SEGM_CIRC, 1, NULL, NULL, -1, -1, 0., 1., ok); + c = + CreateCurve(NEWLINE(), MSH_SEGM_CIRC, 1, NULL, NULL, -1, -1, 0., 1., ok); c->Control_Points = List_Create(3, 1, sizeof(Vertex *)); c->Extrude = new ExtrudeParams; c->Extrude->fill(type, T0, T1, T2, A0, A1, A2, X0, X1, X2, alpha); @@ -2591,7 +2574,8 @@ int ExtrudePoint(int type, int ip, double T0, double T1, double T2, double A0, case TRANSLATE_ROTATE: d = CTX::instance()->geom.extrudeSplinePoints; d = d ? d : 1; - c = CreateCurve(NEWLINE(), MSH_SEGM_SPLN, 1, NULL, NULL, -1, -1, 0., 1., ok); + c = + CreateCurve(NEWLINE(), MSH_SEGM_SPLN, 1, NULL, NULL, -1, -1, 0., 1., ok); c->Control_Points = List_Create( CTX::instance()->geom.extrudeSplinePoints + 1, 1, sizeof(Vertex *)); c->Extrude = new ExtrudeParams; @@ -2648,7 +2632,7 @@ int ExtrudePoint(int type, int ip, double T0, double T1, double T2, double A0, report[0][chap_num] = chap_num; report[1][body_num] = body_num; ReplaceAllDuplicates(report); - std::map<int, int>::iterator m_it = report[0].find(chap_num); + auto m_it = report[0].find(chap_num); if(m_it != report[0].end()) chap_num = report[0][chap_num]; else @@ -2672,9 +2656,7 @@ int ExtrudeCurve(int type, int ic, double T0, double T1, double T2, double A0, revpc = FindCurve(-ic); *ps = NULL; - if(!pc || !revpc) { - return 0; - } + if(!pc || !revpc) { return 0; } if(!pc->beg || !pc->end) { Msg::Error("Cannot extrude curve with no begin/end points"); @@ -2782,9 +2764,7 @@ int ExtrudeCurve(int type, int ic, double T0, double T1, double T2, double A0, ExtrudePoint(type, pc->end->Num, T0, T1, T2, A0, A1, A2, X0, X1, X2, alpha, &CurveEnd, &ReverseEnd, 0, e); - if(!CurveBeg && !CurveEnd) { - return pc->Num; - } + if(!CurveBeg && !CurveEnd) { return pc->Num; } // FIXME: if we extrude by rotation a (non-straight) curve defined by 2 end // points, with a rotation axis going through the end points, the resulting @@ -2838,7 +2818,7 @@ int ExtrudeCurve(int type, int ic, double T0, double T1, double T2, double A0, report[1][chap_num] = chap_num; report[2][body_num] = body_num; ReplaceAllDuplicates(report); - std::map<int, int>::iterator m_it = report[1].find(chap_num); + auto m_it = report[1].find(chap_num); if(m_it != report[1].end()) chap_num = report[1][chap_num]; else @@ -3031,7 +3011,7 @@ int ExtrudeSurface(int type, int is, double T0, double T1, double T2, double A0, std::vector<std::map<int, int> > report(3); report[2][chap_num] = chap_num; ReplaceAllDuplicates(report); - std::map<int, int>::iterator m_it = (report[2]).find(chap_num); + auto m_it = (report[2]).find(chap_num); if(m_it != report[2].end()) chap_num = report[2][chap_num]; else @@ -3544,9 +3524,7 @@ bool SetSurfaceGeneratrices(Surface *s, List_T *loops) for(std::size_t j = 0; j < fromModel.size(); j++) { ic = fromModel[j]; GEdge *ge = GModel::current()->getEdgeByTag(abs(ic)); - if(ge) { - List_Add(s->GeneratricesByTag, &ic); - } + if(ge) { List_Add(s->GeneratricesByTag, &ic); } else { Msg::Error("Unknown curve %d", ic); return false; @@ -3586,9 +3564,7 @@ bool SetVolumeSurfaces(Volume *v, List_T *loops) } else { GFace *gf = GModel::current()->getFaceByTag(abs(is)); - if(gf) { - List_Add(v->SurfacesByTag, &is); - } + if(gf) { List_Add(v->SurfacesByTag, &is); } else { Msg::Error("Unknown surface %d in GEO volume %d", is, v->Num); return false; diff --git a/Geo/Geo.h b/Geo/Geo.h index 9be2e36dcde416c34d274f6883f17ab175521d74..7eed104d814b3bf5f3e4a82f0d9368df34e8c01d 100644 --- a/Geo/Geo.h +++ b/Geo/Geo.h @@ -250,8 +250,8 @@ bool SetVolumeSurfaces(Volume *v, List_T *loops); void SetTranslationMatrix(double matrix[4][4], double T[3]); void SetSymmetryMatrix(double matrix[4][4], double A, double B, double C, double D); -void SetDilatationMatrix(double matrix[4][4], double T[3], double A, - double B, double C); +void SetDilatationMatrix(double matrix[4][4], double T[3], double A, double B, + double C); void SetRotationMatrix(double matrix[4][4], double Axe[3], double alpha); int NEWPOINT(); diff --git a/Geo/GeoInterpolation.cpp b/Geo/GeoInterpolation.cpp index d16173a2cfd873f85c2620714f342db1b9512c89..e8ae4c84e9262f4f4547c64ecda8eee1a676625e 100644 --- a/Geo/GeoInterpolation.cpp +++ b/Geo/GeoInterpolation.cpp @@ -57,15 +57,11 @@ static Vertex InterpolateCubicSpline(Vertex *v[4], double t, double mat[4][4], T[0] = t * t * t; } - for(i = 0; i < 4; i++) { - vec[i] = 0.0; - } + for(i = 0; i < 4; i++) { vec[i] = 0.0; } // X for(i = 0; i < 4; i++) { - for(j = 0; j < 4; j++) { - vec[i] += mat[i][j] * v[j]->Pos.X; - } + for(j = 0; j < 4; j++) { vec[i] += mat[i][j] * v[j]->Pos.X; } } for(j = 0; j < 4; j++) { @@ -75,9 +71,7 @@ static Vertex InterpolateCubicSpline(Vertex *v[4], double t, double mat[4][4], // Y for(i = 0; i < 4; i++) { - for(j = 0; j < 4; j++) { - vec[i] += mat[i][j] * v[j]->Pos.Y; - } + for(j = 0; j < 4; j++) { vec[i] += mat[i][j] * v[j]->Pos.Y; } } for(j = 0; j < 4; j++) { @@ -87,9 +81,7 @@ static Vertex InterpolateCubicSpline(Vertex *v[4], double t, double mat[4][4], // Z for(i = 0; i < 4; i++) { - for(j = 0; j < 4; j++) { - vec[i] += mat[i][j] * v[j]->Pos.Z; - } + for(j = 0; j < 4; j++) { vec[i] += mat[i][j] * v[j]->Pos.Z; } } for(j = 0; j < 4; j++) { V.Pos.Z += T[j] * vec[j]; @@ -141,14 +133,10 @@ SPoint2 InterpolateCubicSpline(Vertex *v[4], double t, double mat[4][4], SPoint2 coord[4], p; for(i = 0; i < 4; i++) { - for(j = 0; j < 4; j++) { - coord[i] += v[j]->pntOnGeometry * mat[i][j]; - } + for(j = 0; j < 4; j++) { coord[i] += v[j]->pntOnGeometry * mat[i][j]; } } - for(j = 0; j < 4; j++) { - p += coord[j] * T[j]; - } + for(j = 0; j < 4; j++) { p += coord[j] * T[j]; } return p; } @@ -232,7 +220,7 @@ static Vertex InterpolateBezier(Curve *Curve, double u, int derivee) static Vertex InterpolateUBS(Curve *Curve, double u, int derivee) { #if 1 // bypass regression in Gmsh 4 for bsplines on geometry (see #685) - if(Curve->geometry){ + if(Curve->geometry) { bool periodic = (Curve->end == Curve->beg); int NbControlPoints = List_Nbr(Curve->Control_Points); int NbCurves = NbControlPoints + (periodic ? -1 : 1); @@ -328,7 +316,7 @@ static Vertex InterpolateUBS(Curve *Curve, double u, int derivee) k = std::min(iCurve + i, NbControlPoints - 1); } - if(k >= 0 && k < NbControlPoints){ + if(k >= 0 && k < NbControlPoints) { List_Read(Curve->Control_Points, k, &v[i]); } else { @@ -374,7 +362,7 @@ static Vertex InterpolateUBS(Curve *Curve, double u, int derivee) } } -#if 0 // bypass regression in Gmsh 4 for bsplines on geometry (see #685) +#if 0 // bypass regression in Gmsh 4 for bsplines on geometry (see #685) if(Curve->geometry) { SPoint2 pp = InterpolateCubicSpline(v, t, *matrix, t1, t2, Curve->geometry, derivee); @@ -532,7 +520,7 @@ Vertex InterpolateCurve(Curve *c, double u, int const derivee) Msg::Error("Line with less than 2 control points"); V.Pos.X = V.Pos.Y = V.Pos.Z = 0; } - else{ + else { int i = static_cast<int>(static_cast<double>(N - 1) * u); // clamp if(i >= N - 1) i = N - 2; @@ -626,9 +614,7 @@ Vertex InterpolateCurve(Curve *c, double u, int const derivee) List_Read(c->Control_Points, i, &v[1]); List_Read(c->Control_Points, i + 1, &v[2]); if(!i) { - if(c->beg == c->end) { - List_Read(c->Control_Points, N - 2, &v[0]); - } + if(c->beg == c->end) { List_Read(c->Control_Points, N - 2, &v[0]); } else { v[0] = &temp1; v[0]->Pos.X = 2. * v[1]->Pos.X - v[2]->Pos.X; @@ -641,9 +627,7 @@ Vertex InterpolateCurve(Curve *c, double u, int const derivee) List_Read(c->Control_Points, i - 1, &v[0]); } if(i == N - 2) { - if(c->beg == c->end) { - List_Read(c->Control_Points, 1, &v[3]); - } + if(c->beg == c->end) { List_Read(c->Control_Points, 1, &v[3]); } else { v[3] = &temp2; v[3]->Pos.X = 2. * v[2]->Pos.X - v[1]->Pos.X; @@ -679,9 +663,7 @@ Vertex InterpolateCurve(Curve *c, double u, int const derivee) Msg::Debug("Cannot interpolate discrete curve"); break; - default: - Msg::Error("Unknown curve type %d in interpolation", c->Typ); - break; + default: Msg::Error("Unknown curve type %d in interpolation", c->Typ); break; } V.u = u; return V; @@ -833,7 +815,8 @@ static Vertex InterpolateRuledSurface(Surface *s, double u, double v) for(int i = 0; i < std::min(List_Nbr(s->Generatrices), 4); i++) { List_Read(s->Generatrices, i, &C[i]); if(C[i]->Typ == MSH_SEGM_BND_LAYER || C[i]->Typ == MSH_SEGM_DISCRETE) { - Msg::Error("Cannot interpolate ruled surface with discrete bounding curves"); + Msg::Error( + "Cannot interpolate ruled surface with discrete bounding curves"); return Vertex(0., 0., 0.); } if(!C[i]->beg || !C[i]->end) { @@ -859,9 +842,7 @@ static Vertex InterpolateRuledSurface(Surface *s, double u, double v) isSphere = false; } else if(isSphere) { - if(!i) { - List_Read(C[i]->Control_Points, 1, &O); - } + if(!i) { List_Read(C[i]->Control_Points, 1, &O); } else { Vertex *tmp; List_Read(C[i]->Control_Points, 1, &tmp); @@ -928,9 +909,7 @@ static Vertex InterpolateRuledSurface(Surface *s, double u, double v) T = TransfiniteTriB(V[0], VB[0], V[1], VB[1], V[2], VB[2], *S[0], *S[1], *S[2], u, v); } - if(isSphere) { - TransfiniteSph(*S[0], *O, &T); - } + if(isSphere) { TransfiniteSph(*S[0], *O, &T); } } return T; diff --git a/Geo/GeomMeshMatcher.cpp b/Geo/GeomMeshMatcher.cpp index a8e3aa3cf8f63988b408a1f37d2cdcd8b76e3be8..9edf86d0a4393785ed9a8d8ec3f183fb43df5871 100644 --- a/Geo/GeomMeshMatcher.cpp +++ b/Geo/GeomMeshMatcher.cpp @@ -41,12 +41,10 @@ void getIntersection(std::vector<T> &res, std::vector<container> &lists) container const &first_list = lists[0]; bool allsame = true; - for(typename container::const_iterator item = first_list.begin(); - item != first_list.end(); item++) { + for(auto item = first_list.begin(); item != first_list.end(); item++) { bool found = true; - for(typename std::vector<container>::iterator list_iter = lists.begin(); - list_iter != lists.end(); list_iter++) { + for(auto list_iter = lists.begin(); list_iter != lists.end(); list_iter++) { if(*(list_iter) != first_list) { allsame = false; if(std::find((*list_iter).begin(), (*list_iter).end(), (*item)) == @@ -65,8 +63,7 @@ void getIntersection(std::vector<T> &res, std::vector<container> &lists) template <class T> T findMatching(std::vector<Pair<T, T> > &matching, T &entity) { - for(typename std::vector<Pair<T, T> >::iterator pair = matching.begin(); - pair != matching.end(); pair++) { + for(auto pair = matching.begin(); pair != matching.end(); pair++) { if((*pair).left() == entity) return ((*pair).right()); } return (0); @@ -85,7 +82,7 @@ GeomMeshMatcher::matchVertices(GModel *m1, GModel *m2, bool &ok) std::vector<GVertex *> vertices; - for(GModel::viter vit = m1->firstVertex(); vit != m1->lastVertex(); vit++) { + for(auto vit = m1->firstVertex(); vit != m1->lastVertex(); vit++) { GVertex *v1 = (GVertex *)*vit; // FIXME: need a *much* better way to fix the tolerance... @@ -94,8 +91,7 @@ GeomMeshMatcher::matchVertices(GModel *m1, GModel *m2, bool &ok) discreteVertex *choice = 0; double best_score = DBL_MAX; - for(GModel::viter vit2 = m2->firstVertex(); vit2 != m2->lastVertex(); - vit2++) { + for(auto vit2 = m2->firstVertex(); vit2 != m2->lastVertex(); vit2++) { discreteVertex *v2 = (discreteVertex *)*vit2; // We match the vertices if their coordinates are the same under the @@ -138,7 +134,7 @@ GeomMeshMatcher::matchEdges(GModel *m1, GModel *m2, std::vector<GEdge *> closed_curves; - for(GModel::eiter eit = m1->firstEdge(); eit != m1->lastEdge(); eit++) { + for(auto eit = m1->firstEdge(); eit != m1->lastEdge(); eit++) { GEdge *e1 = (GEdge *)*eit; GVertex *v1 = e1->getBeginVertex(); @@ -151,8 +147,7 @@ GeomMeshMatcher::matchEdges(GModel *m1, GModel *m2, Msg::Debug("Found a closed curve"); closed_curves.push_back(e1); - for(GModel::eiter eit2 = m2->firstEdge(); eit2 != m2->lastEdge(); - eit2++) { + for(auto eit2 = m2->firstEdge(); eit2 != m2->lastEdge(); eit2++) { GEdge *e2 = (GEdge *)*eit2; GVertex *v3 = e2->getBeginVertex(); GVertex *v4 = e2->getEndVertex(); @@ -189,7 +184,7 @@ GeomMeshMatcher::matchEdges(GModel *m1, GModel *m2, double best_score = DBL_MAX; // Next, let's iterate over the mesh entities. - for(std::vector<GEdge *>::iterator candidate = common_edges.begin(); + for(auto candidate = common_edges.begin(); candidate != common_edges.end(); candidate++) { SOrientedBoundingBox mesh_obb = (*candidate)->getOBB(); @@ -203,7 +198,7 @@ GeomMeshMatcher::matchEdges(GModel *m1, GModel *m2, coresp_e->push_back(Pair<GEdge *, GEdge *>(e1, choice)); // copy topological information - if(choice){ + if(choice) { // choice->setTag(e1->tag()); choice->physicals = e1->physicals; } @@ -229,14 +224,14 @@ GeomMeshMatcher::matchFaces(GModel *m1, GModel *m2, std::vector<Pair<GFace *, GFace *> > *coresp_f = new std::vector<Pair<GFace *, GFace *> >; - for(GModel::fiter fit = m1->firstFace(); fit != m1->lastFace(); fit++) { + for(auto fit = m1->firstFace(); fit != m1->lastFace(); fit++) { GFace *f1 = (GFace *)*fit; std::vector<std::vector<GFace *> > lists; std::vector<GEdge *> boundary_edges = f1->edges(); - for(std::vector<GEdge *>::iterator boundary_edge = boundary_edges.begin(); + for(auto boundary_edge = boundary_edges.begin(); boundary_edge != boundary_edges.end(); boundary_edge++) { // if (boundary_edge->getBeginVertex() == // boundary_edge->getEndVertex() && @@ -266,7 +261,7 @@ GeomMeshMatcher::matchFaces(GModel *m1, GModel *m2, double best_score = DBL_MAX; // Next, let's iterate over the mesh entities. - for(std::vector<GFace *>::iterator candidate = common_faces.begin(); + for(auto candidate = common_faces.begin(); candidate != common_faces.end(); candidate++) { SOrientedBoundingBox mesh_obb = (*candidate)->getOBB(); Msg::Info("Comparing score : %f", @@ -291,7 +286,8 @@ GeomMeshMatcher::matchFaces(GModel *m1, GModel *m2, } } - Msg::Info("Matched %i surfaces out of %i.", num_matched_faces, num_total_faces); + Msg::Info("Matched %i surfaces out of %i.", num_matched_faces, + num_total_faces); return coresp_f; } @@ -321,8 +317,8 @@ GeomMeshMatcher::matchRegions(GModel *m1, GModel *m2, return coresp_r; } - for(std::vector<GEntity *>::iterator entity1 = m1_entities.begin(); - entity1 != m1_entities.end(); entity1++) { + for(auto entity1 = m1_entities.begin(); entity1 != m1_entities.end(); + entity1++) { // if ((*entity1)->dim() != 3) continue; num_total_regions++; @@ -331,13 +327,13 @@ GeomMeshMatcher::matchRegions(GModel *m1, GModel *m2, std::vector<GFace *> coresp_bound_faces; std::vector<GRegion *> common_regions; - for(std::vector<GFace *>::iterator boundary_face = boundary_faces.begin(); + for(auto boundary_face = boundary_faces.begin(); boundary_face != boundary_faces.end(); boundary_face++) { coresp_bound_faces.push_back( findMatching<GFace *>(*coresp_f, *boundary_face)); } - for(std::vector<GEntity *>::iterator entity2 = m2_entities.begin(); - entity2 != m2_entities.end(); entity2++) { + for(auto entity2 = m2_entities.begin(); entity2 != m2_entities.end(); + entity2++) { if((*entity2)->dim() != 3) continue; std::vector<std::vector<GFace *> > lists; lists.push_back(coresp_bound_faces); @@ -370,7 +366,7 @@ GeomMeshMatcher::matchRegions(GModel *m1, GModel *m2, GRegion *choice = 0; double best_score = DBL_MAX; // Next, let's iterate over the mesh entities. - for(std::vector<GRegion *>::iterator candidate = common_regions.begin(); + for(auto candidate = common_regions.begin(); candidate != common_regions.end(); candidate++) { // Again, build an array with the vertices. SOrientedBoundingBox mesh_obb = (*candidate)->getOBB(); @@ -385,7 +381,7 @@ GeomMeshMatcher::matchRegions(GModel *m1, GModel *m2, } coresp_r->push_back( Pair<GRegion *, GRegion *>((GRegion *)*entity1, choice)); - if(choice){ + if(choice) { choice->setTag(((GRegion *)*entity1)->tag()); (*entity1)->physicals = choice->physicals; } @@ -417,7 +413,7 @@ static GVertex *getGVertex(MVertex *v1, GModel *gm, const double TOL) { GVertex *best = 0; double bestScore = TOL; - for(GModel::eiter it = gm->firstEdge(); it != gm->lastEdge(); ++it) { + for(auto it = gm->firstEdge(); it != gm->lastEdge(); ++it) { { GVertex *v2 = (*it)->getBeginVertex(); double score = sqrt((v1->x() - v2->x()) * (v1->x() - v2->x()) + @@ -447,7 +443,7 @@ static GPoint getGEdge(MVertex *v1, GModel *gm, const double TOL) GPoint gpBest; double bestScore = TOL; - for(GModel::eiter it = gm->firstEdge(); it != gm->lastEdge(); ++it) { + for(auto it = gm->firstEdge(); it != gm->lastEdge(); ++it) { GEdge *e = *it; double pp; GPoint gp = e->closestPoint(SPoint3(v1->x(), v1->y(), v1->z()), pp); @@ -467,7 +463,7 @@ static GPoint getGFace(MVertex *v1, GModel *gm, const double TOL) { GPoint gpBest; double bestScore = TOL; - for(GModel::fiter it = gm->firstFace(); it != gm->lastFace(); ++it) { + for(auto it = gm->firstFace(); it != gm->lastFace(); ++it) { GFace *gf = *it; SPoint2 pp; double guess[2] = {0, 0}; @@ -505,8 +501,8 @@ int GeomMeshMatcher::forceTomatch(GModel *geom, GModel *mesh, const double TOL) if(gp.g()) { GEntity *gg = (GEntity *)gp.g(); found = 1; - gg->mesh_vertices.push_back(new MEdgeVertex( - gp.x(), gp.y(), gp.z(), gg, gp.u(), v->getNum())); + gg->mesh_vertices.push_back( + new MEdgeVertex(gp.x(), gp.y(), gp.z(), gg, gp.u(), v->getNum())); } } if(!found && v->onWhat()->dim() <= 2) { @@ -523,7 +519,7 @@ int GeomMeshMatcher::forceTomatch(GModel *geom, GModel *mesh, const double TOL) v->onWhat()->dim(), v->onWhat()->tag()); } } - for(GModel::eiter it = mesh->firstEdge(); it != mesh->lastEdge(); ++it) { + for(auto it = mesh->firstEdge(); it != mesh->lastEdge(); ++it) { for(std::size_t i = 0; i < (*it)->lines.size(); i++) { MVertex *v1 = geom->getMeshVertexByTag((*it)->lines[i]->getVertex(0)->getNum()); @@ -555,7 +551,7 @@ int GeomMeshMatcher::forceTomatch(GModel *geom, GModel *mesh, const double TOL) } } } - for(GModel::fiter it = mesh->firstFace(); it != mesh->lastFace(); ++it) { + for(auto it = mesh->firstFace(); it != mesh->lastFace(); ++it) { for(std::size_t i = 0; i < (*it)->triangles.size(); i++) { MVertex *v1 = geom->getMeshVertexByTag((*it)->triangles[i]->getVertex(0)->getNum()); @@ -603,13 +599,12 @@ static void copy_periodicity(std::vector<Pair<GEType *, GEType *> > &eCor, std::map<MVertex *, MVertex *> &mesh_to_geom) { typename std::multimap<GEType *, GEType *> eMap; // (eCor.begin(),eCor.end()); - typename std::vector<Pair<GEType *, GEType *> >::iterator eIter = - eCor.begin(); + auto eIter = eCor.begin(); for(; eIter != eCor.end(); ++eIter) { eMap.insert(std::make_pair(eIter->second(), eIter->first())); } - typename std::multimap<GEType *, GEType *>::iterator srcIter = eMap.begin(); + auto srcIter = eMap.begin(); for(; srcIter != eMap.end(); ++srcIter) { GEType *oldTgt = srcIter->first; @@ -617,8 +612,7 @@ static void copy_periodicity(std::vector<Pair<GEType *, GEType *> > &eCor, if(oldSrc != NULL && oldSrc != oldTgt) { GEType *newTgt = srcIter->second; - typename std::multimap<GEType *, GEType *>::iterator tgtIter = - eMap.find(oldSrc); + auto tgtIter = eMap.find(oldSrc); if(tgtIter == eMap.end()) { Msg::Error("Could not find matched entity for %d", "which has a matched periodic counterpart %d", oldSrc->tag(), @@ -630,15 +624,13 @@ static void copy_periodicity(std::vector<Pair<GEType *, GEType *> > &eCor, std::map<MVertex *, MVertex *> &oldV2v = oldTgt->correspondingVertices; std::map<MVertex *, MVertex *> &newV2v = newTgt->correspondingVertices; - std::map<MVertex *, MVertex *>::iterator vIter = oldV2v.begin(); + auto vIter = oldV2v.begin(); for(; vIter != oldV2v.end(); ++vIter) { MVertex *oldTgtV = vIter->first; MVertex *oldSrcV = vIter->second; - std::map<MVertex *, MVertex *>::iterator newTvIter = - mesh_to_geom.find(oldTgtV); - std::map<MVertex *, MVertex *>::iterator newSvIter = - mesh_to_geom.find(oldSrcV); + auto newTvIter = mesh_to_geom.find(oldTgtV); + auto newSvIter = mesh_to_geom.find(oldSrcV); if(newTvIter == mesh_to_geom.end()) { Msg::Error( @@ -661,13 +653,12 @@ template <class GEType> static bool apply_periodicity(std::vector<Pair<GEType *, GEType *> > &eCor) { typename std::multimap<GEType *, GEType *> eMap; // (eCor.begin(),eCor.end()); - typename std::vector<Pair<GEType *, GEType *> >::iterator eIter = - eCor.begin(); + auto eIter = eCor.begin(); for(; eIter != eCor.end(); ++eIter) { eMap.insert(std::make_pair(eIter->second(), eIter->first())); } - typename std::multimap<GEType *, GEType *>::iterator srcIter = eMap.begin(); + auto srcIter = eMap.begin(); int dim = -1; @@ -784,8 +775,7 @@ static void copy_elements(std::vector<ELEMENT *> &to, ELEMENT *e = from[i]; std::vector<MVertex *> nodes; for(std::size_t j = 0; j < e->getNumVertices(); j++) { - std::map<MVertex *, MVertex *>::iterator vIter = - _mesh_to_geom.find(e->getVertex(j)); + auto vIter = _mesh_to_geom.find(e->getVertex(j)); if(vIter == _mesh_to_geom.end()) { Msg::Error("Could not find match for node %i during element copy " diff --git a/Geo/Homology.cpp b/Geo/Homology.cpp index a02160e102bfa229120192a19e20ec9bb00fd924..ea6267dc46e1acb2ff78d55f22e9b4522c7f8ee5 100644 --- a/Geo/Homology.cpp +++ b/Geo/Homology.cpp @@ -25,8 +25,7 @@ Homology::Homology(GModel *model, const std::vector<int> &physicalDomain, int dim = _model->getDim(); std::vector<GEntity *> entities; _model->getEntities(entities); - for(std::vector<GEntity *>::iterator it = entities.begin(); - it != entities.end(); it++) { + for(auto it = entities.begin(); it != entities.end(); it++) { if((*it)->dim() == dim) _domainEntities.push_back(*it); } } @@ -195,11 +194,14 @@ void Homology::findHomologyBasis(std::vector<int> dim) _cellComplex->getSize(1), _cellComplex->getSize(0)); Msg::StatusBar(true, "Computing homology space bases..."); - t1 = Cpu(); w1 = TimeOfDay(); + t1 = Cpu(); + w1 = TimeOfDay(); ChainComplex chainComplex = ChainComplex(_cellComplex); chainComplex.computeHomology(); - t2 = Cpu(); w2 = TimeOfDay(); - Msg::StatusBar(true, "Done computing homology space bases (Wall %gs, CPU %gs)", + t2 = Cpu(); + w2 = TimeOfDay(); + Msg::StatusBar(true, + "Done computing homology space bases (Wall %gs, CPU %gs)", w2 - w1, t2 - t1); _deleteChains(dim); @@ -284,11 +286,14 @@ void Homology::findCohomologyBasis(std::vector<int> dim) _cellComplex->getSize(1), _cellComplex->getSize(0)); Msg::StatusBar(true, "Computing cohomology space bases ..."); - t1 = Cpu(); w1 = TimeOfDay(); + t1 = Cpu(); + w1 = TimeOfDay(); ChainComplex chainComplex = ChainComplex(_cellComplex); chainComplex.computeHomology(true); - t2 = Cpu(); w2 = TimeOfDay(); - Msg::StatusBar(true, "Done computing cohomology space bases (Wall %gs, CPU %gs)", + t2 = Cpu(); + w2 = TimeOfDay(); + Msg::StatusBar(true, + "Done computing cohomology space bases (Wall %gs, CPU %gs)", w2 - w1, t2 - t1); _deleteCochains(dim); @@ -538,22 +543,25 @@ void Homology::findBettiNumbers() double t2 = Cpu(), w2 = TimeOfDay(); double size2 = _cellComplex->getSize(-1); - Msg::StatusBar(true, "Done reducing cell complex (Wall %gs, CPU %gs, %g %%)", + Msg::StatusBar(true, + "Done reducing cell complex (Wall %gs, CPU %gs, %g %%)", w2 - w1, t2 - t1, (1. - size2 / size1) * 100.); Msg::Info("%d volumes, %d faces, %d edges, and %d vertices", _cellComplex->getSize(3), _cellComplex->getSize(2), _cellComplex->getSize(1), _cellComplex->getSize(0)); Msg::StatusBar(true, "Computing betti numbers..."); - t1 = Cpu(); w1 = TimeOfDay(); + t1 = Cpu(); + w1 = TimeOfDay(); ChainComplex chainComplex = ChainComplex(_cellComplex); chainComplex.computeHomology(); for(int i = 0; i < 4; i++) _betti[i] = chainComplex.getBasisSize(i, 3); - t2 = Cpu(); w2 = TimeOfDay(); - Msg::StatusBar(true, "Betti numbers computed (Wall %gs, CPU %gs)", - w2 - w1, t2 - t1); + t2 = Cpu(); + w2 = TimeOfDay(); + Msg::StatusBar(true, "Betti numbers computed (Wall %gs, CPU %gs)", w2 - w1, + t2 - t1); } std::string domain = _getDomainString(_domain, _subdomain); @@ -588,7 +596,7 @@ void Homology::_createChain(std::map<Cell *, int, CellPtrLessThan> &preChain, Chain<int> *chain = new Chain<int>(); chain->setName(name); - for(citer cit = preChain.begin(); cit != preChain.end(); cit++) { + for(auto cit = preChain.begin(); cit != preChain.end(); cit++) { Cell *cell = cit->first; int coeff = cit->second; if(coeff == 0) continue; @@ -613,9 +621,7 @@ std::string Homology::_getDomainString(const std::vector<int> &domain, for(std::size_t i = 0; i < domain.size(); i++) { std::string temp = convertInt(domain.at(i)); domainString += temp; - if(domain.size() - 1 > i) { - domainString += ","; - } + if(domain.size() - 1 > i) { domainString += ","; } } } domainString += "}"; @@ -625,9 +631,7 @@ std::string Homology::_getDomainString(const std::vector<int> &domain, for(std::size_t i = 0; i < subdomain.size(); i++) { std::string temp = convertInt(subdomain.at(i)); domainString += temp; - if(subdomain.size() - 1 > i) { - domainString += ","; - } + if(subdomain.size() - 1 > i) { domainString += ","; } } domainString += "}"; } @@ -648,12 +652,12 @@ void Homology::storeCells(CellComplex *cellComplex, int dim) std::vector<MElement *> elements; MElementFactory factory; - for(CellComplex::citer cit = cellComplex->firstCell(dim); - cit != cellComplex->lastCell(dim); cit++) { + for(auto cit = cellComplex->firstCell(dim); cit != cellComplex->lastCell(dim); + cit++) { Cell *cell = *cit; std::map<Cell *, int, CellPtrLessThan> cells; cell->getCells(cells); - for(Cell::citer it = cells.begin(); it != cells.end(); it++) { + for(auto it = cells.begin(); it != cells.end(); it++) { Cell *subCell = it->first; std::vector<MVertex *> v; subCell->getMeshVertices(v); diff --git a/Geo/MEdge.cpp b/Geo/MEdge.cpp index 95ad46bf47f3872a6b4f0c06efa727d4cf55e1e1..5b01876814c45387603212b96e39d9b98cd942dd 100644 --- a/Geo/MEdge.cpp +++ b/Geo/MEdge.cpp @@ -76,8 +76,7 @@ bool SortEdgeConsecutive(const std::vector<MEdge> &e, MVertex *v0 = e[i].getVertex(0); MVertex *v1 = e[i].getVertex(1); - std::map<MVertex *, std::pair<MVertex *, MVertex *>, MVertexPtrLessThan> - ::iterator it0 = c.find(v0), it1 = c.find(v1); + auto it0 = c.find(v0), it1 = c.find(v1); if(it0 == c.end()) c[v0] = std::make_pair(v1, (MVertex *)NULL); else { @@ -105,8 +104,7 @@ bool SortEdgeConsecutive(const std::vector<MEdge> &e, std::vector<MVertex *> v; MVertex *start = NULL; { - std::map<MVertex *, std::pair<MVertex *, MVertex *>, MVertexPtrLessThan> - ::iterator it = c.begin(); + auto it = c.begin(); start = it->first; for(; it != c.end(); ++it) { if(it->second.second == NULL) { @@ -116,8 +114,7 @@ bool SortEdgeConsecutive(const std::vector<MEdge> &e, } } - std::map<MVertex *, std::pair<MVertex *, MVertex *>, MVertexPtrLessThan > - ::iterator its = c.find(start); + auto its = c.find(start); MVertex *prev = (its->second.second == start) ? its->second.first : its->second.second; @@ -129,8 +126,7 @@ bool SortEdgeConsecutive(const std::vector<MEdge> &e, return false; } v.push_back(current); - std::map<MVertex *, std::pair<MVertex *, MVertex *>, MVertexPtrLessThan> - ::iterator it = c.find(current); + auto it = c.find(current); if(it == c.end() || it->first == NULL) { Msg::Error("Impossible to find %d", current->getNum()); return false; diff --git a/Geo/MEdge.h b/Geo/MEdge.h index dcf18e2c7a9d7bfa3a1672aedd09e22f0c67df81..d8a3f39b7e64387f26822808d98d03bc8b39f85c 100644 --- a/Geo/MEdge.h +++ b/Geo/MEdge.h @@ -116,10 +116,7 @@ inline bool operator!=(const MEdge &e1, const MEdge &e2) } struct MEdgeEqual { - bool operator()(const MEdge &e1, const MEdge &e2) const - { - return (e1 == e2); - } + bool operator()(const MEdge &e1, const MEdge &e2) const { return (e1 == e2); } }; struct MEdgeLessThan { diff --git a/Geo/MElement.cpp b/Geo/MElement.cpp index 58ff39c6b73808bd43ff0844638bbf114d97b1b9..42f16a11bcfe199c234fbc4aa15d3c383d921993 100644 --- a/Geo/MElement.cpp +++ b/Geo/MElement.cpp @@ -353,11 +353,10 @@ void MElement::idealJacRange(double &jmin, double &jmax, GEntity *ge) jmax = 0.; return; } - double scale = (dim == 1.) ? - invMeanEdLength : - (dim == 2.) ? - invMeanEdLength * invMeanEdLength : - invMeanEdLength * invMeanEdLength * invMeanEdLength; + double scale = + (dim == 1.) ? invMeanEdLength : + (dim == 2.) ? invMeanEdLength * invMeanEdLength : + invMeanEdLength * invMeanEdLength * invMeanEdLength; if(ge && (ge->dim() == 2) && ge->haveParametrization()) { // If parametrized surface entity provided... SVector3 geoNorm(0., 0., 0.); @@ -1739,9 +1738,9 @@ void MElement::writeMESH(FILE *fp, int elementTagType, int elementary, else fprintf(fp, " %ld", getVertex(i)->getIndex()); fprintf(fp, " %d\n", - (elementTagType == 3) ? - _partition : - (elementTagType == 2) ? abs(physical) : elementary); + (elementTagType == 3) ? _partition : + (elementTagType == 2) ? abs(physical) : + elementary); if(physical < 0) reverse(); } @@ -1766,9 +1765,9 @@ void MElement::writeIR3(FILE *fp, int elementTagType, int num, int elementary, int numVert = getNumVertices(); fprintf(fp, "%d %d %d", num, - (elementTagType == 3) ? - _partition : - (elementTagType == 2) ? abs(physical) : elementary, + (elementTagType == 3) ? _partition : + (elementTagType == 2) ? abs(physical) : + elementary, numVert); for(int i = 0; i < numVert; i++) fprintf(fp, " %ld", getVertex(i)->getIndex()); @@ -1789,9 +1788,9 @@ void MElement::writeBDF(FILE *fp, int format, int elementTagType, if(physical < 0) reverse(); - int tag = (elementTagType == 3) ? - _partition : - (elementTagType == 2) ? abs(physical) : elementary; + int tag = (elementTagType == 3) ? _partition : + (elementTagType == 2) ? abs(physical) : + elementary; if(format == 0) { // free field format fprintf(fp, "%s,%lu,%d", str, _num, tag); @@ -2397,7 +2396,7 @@ MElement *MElement::copy(std::map<int, MVertex *> &vertexMap, MElement *parent = 0; if(eParent && !getDomain(0) && !getDomain(1)) { - std::map<MElement *, MElement *>::iterator it = newParents.find(eParent); + auto it = newParents.find(eParent); MElement *newParent; if(it == newParents.end()) { newParent = eParent->copy(vertexMap, newParents, newDomains); @@ -2415,7 +2414,7 @@ MElement *MElement::copy(std::map<int, MVertex *> &vertexMap, for(int i = 0; i < 2; i++) { MElement *dom = getDomain(i); if(!dom) continue; - std::map<MElement *, MElement *>::iterator it = newDomains.find(dom); + auto it = newDomains.find(dom); MElement *newDom; if(it == newDomains.end()) { newDom = dom->copy(vertexMap, newParents, newDomains); diff --git a/Geo/MElementCut.cpp b/Geo/MElementCut.cpp index 7c89d433927c9e1c7000fc9f95db022ec368395c..cc62fc6eff73fc0bf7000b6b60911567b3cd7a9d 100644 --- a/Geo/MElementCut.cpp +++ b/Geo/MElementCut.cpp @@ -484,8 +484,8 @@ void MLineBorder::getIntegrationPoints(int pOrder, int *npts, IntPt **pts) *pts = _intpt; } - //---------------------------------------- CutMesh - //---------------------------- +//---------------------------------------- CutMesh +//---------------------------- #if defined(HAVE_DINTEGRATION) @@ -503,10 +503,9 @@ assignPhysicals(GModel *GM, std::vector<int> &gePhysicals, int reg, int dim, (!physicals[dim].count(reg) || !physicals[dim][reg].count(phys2))) { std::string name = GM->getPhysicalName(dim, phys); if(name != "" && newPhysTags.count(-phys)) { - std::map<int, std::map<int, std::string> >::iterator it = - physicals[dim].begin(); + auto it = physicals[dim].begin(); for(; it != physicals[dim].end(); it++) { - std::map<int, std::string>::iterator it2 = it->second.begin(); + auto it2 = it->second.begin(); for(; it2 != it->second.end(); it2++) if(it2->second == name) physicals[dim][it->first][it2->first] = name + "_out"; @@ -522,10 +521,9 @@ assignPhysicals(GModel *GM, std::vector<int> &gePhysicals, int reg, int dim, (!physicals[dim].count(reg) || !physicals[dim][reg].count(phys2))) { std::string name = GM->getPhysicalName(dim, phys); if(name != "" && newPhysTags.count(phys)) { - std::map<int, std::map<int, std::string> >::iterator it = - physicals[dim].begin(); + auto it = physicals[dim].begin(); for(; it != physicals[dim].end(); it++) { - std::map<int, std::string>::iterator it2 = it->second.begin(); + auto it2 = it->second.begin(); for(; it2 != it->second.end(); it2++) if(it2->second == name) physicals[dim][it->first][it2->first] = name + "_in"; @@ -597,7 +595,8 @@ static int getBorderTag(int lsTag, int count, int &maxTag, static void elementSplitMesh( MElement *e, std::vector<gLevelset *> &RPN, fullMatrix<double> &verticesLs, - GEntity *ge, GModel *GM, std::size_t &numEle, std::map<int, MVertex *> &vertexMap, + GEntity *ge, GModel *GM, std::size_t &numEle, + std::map<int, MVertex *> &vertexMap, std::map<MElement *, MElement *> &newParents, std::map<MElement *, MElement *> &newDomains, std::map<int, std::vector<MElement *> > elements[10], @@ -828,12 +827,13 @@ static int getElementVertexNum(DI_Point *p, MElement *e) return -1; } -typedef std::set<MVertex *, MVertexPtrLessThanLexicographic> newVerticesContainer; +typedef std::set<MVertex *, MVertexPtrLessThanLexicographic> + newVerticesContainer; static void elementCutMesh( MElement *e, std::vector<gLevelset *> &RPN, fullMatrix<double> &verticesLs, - GEntity *ge, GModel *GM, std::size_t &numEle, std::map<int, MVertex *> &vertexMap, - newVerticesContainer &newVertices, + GEntity *ge, GModel *GM, std::size_t &numEle, + std::map<int, MVertex *> &vertexMap, newVerticesContainer &newVertices, std::map<MElement *, MElement *> &newParents, std::map<MElement *, MElement *> &newDomains, std::multimap<MElement *, MElement *> borders[2], @@ -996,7 +996,7 @@ static void elementCutMesh( if(!it.second) newv->deleteLast(); } else { - std::map<int, MVertex *>::iterator it = vertexMap.find(numV); + auto it = vertexMap.find(numV); if(it == vertexMap.end()) { mv[j] = new MVertex(tetras[i]->x(j), tetras[i]->y(j), tetras[i]->z(j), 0, numV); @@ -1036,8 +1036,7 @@ static void elementCutMesh( std::multimap<MElement *, MElement *>::iterator> itr = borders[1].equal_range(copy); std::vector<std::pair<MElement *, MElement *> > bords; - for(std::multimap<MElement *, MElement *>::iterator it = itr.first; - it != itr.second; it++) { + for(auto it = itr.first; it != itr.second; it++) { MElement *tb = it->second; int match = 0; for(std::size_t i = 0; i < p1->getNumPrimaryVertices(); i++) { @@ -1052,8 +1051,7 @@ static void elementCutMesh( bords.push_back(std::pair<MElement *, MElement *>(dom, tb)); } borders[1].erase(itr.first, itr.second); - for(std::size_t i = 0; i < bords.size(); i++) - borders[1].insert(bords[i]); + for(std::size_t i = 0; i < bords.size(); i++) borders[1].insert(bords[i]); if(eParent) { copy->setParent(NULL, false); delete copy; @@ -1094,7 +1092,7 @@ static void elementCutMesh( if(!it.second) newv->deleteLast(); } else { - std::map<int, MVertex *>::iterator it = vertexMap.find(numV); + auto it = vertexMap.find(numV); if(it == vertexMap.end()) { mv[j] = new MVertex(triangles[i]->x(j), triangles[i]->y(j), triangles[i]->z(j), 0, numV); @@ -1119,11 +1117,8 @@ static void elementCutMesh( int cR = elements[2].count(lsTag) + elements[3].count(lsTag) + elements[8].count(lsTag); int cP = 0; - for(std::map<int, std::map<int, std::string> >::iterator it = - physicals[2].begin(); - it != physicals[2].end(); it++) - for(std::map<int, std::string>::iterator it2 = it->second.begin(); - it2 != it->second.end(); it2++) + for(auto it = physicals[2].begin(); it != physicals[2].end(); it++) + for(auto it2 = it->second.begin(); it2 != it->second.end(); it2++) if(it2->first == lsTag) { cP = 1; break; @@ -1201,7 +1196,7 @@ static void elementCutMesh( if(!it.second) newv->deleteLast(); } else { - std::map<int, MVertex *>::iterator it = vertexMap.find(numV); + auto it = vertexMap.find(numV); if(it == vertexMap.end()) { mv[j] = new MVertex(triangles[i]->x(j), triangles[i]->y(j), triangles[i]->z(j), 0, numV); @@ -1231,7 +1226,7 @@ static void elementCutMesh( if(!it.second) newv->deleteLast(); } else { - std::map<int, MVertex *>::iterator it = vertexMap.find(numV); + auto it = vertexMap.find(numV); if(it == vertexMap.end()) { mv[j] = new MVertex(quads[i]->x(j), quads[i]->y(j), quads[i]->z(j), 0, numV); @@ -1293,8 +1288,7 @@ static void elementCutMesh( std::multimap<MElement *, MElement *>::iterator> itr = borders[0].equal_range(copy); std::vector<std::pair<MElement *, MElement *> > bords; - for(std::multimap<MElement *, MElement *>::iterator it = itr.first; - it != itr.second; ++it) { + for(auto it = itr.first; it != itr.second; ++it) { MElement *lb = it->second; int match = 0; for(std::size_t i = 0; i < p1->getNumPrimaryVertices(); i++) { @@ -1308,8 +1302,7 @@ static void elementCutMesh( bords.push_back(std::pair<MElement *, MElement *>(dom, lb)); } borders[0].erase(itr.first, itr.second); - for(std::size_t i = 0; i < bords.size(); i++) - borders[0].insert(bords[i]); + for(std::size_t i = 0; i < bords.size(); i++) borders[0].insert(bords[i]); if(eParent) { copy->setParent(NULL, false); delete copy; @@ -1350,7 +1343,7 @@ static void elementCutMesh( if(!it.second) newv->deleteLast(); } else { - std::map<int, MVertex *>::iterator it = vertexMap.find(numV); + auto it = vertexMap.find(numV); if(it == vertexMap.end()) { mv[j] = new MVertex(lines[i]->x(j), lines[i]->y(j), lines[i]->z(j), 0, numV); @@ -1372,11 +1365,8 @@ static void elementCutMesh( int lsTag = lines[i]->lsTag(); int cR = elements[1].count(lsTag); int cP = 0; - for(std::map<int, std::map<int, std::string> >::iterator it = - physicals[1].begin(); - it != physicals[1].end(); it++) - for(std::map<int, std::string>::iterator it2 = it->second.begin(); - it2 != it->second.end(); it2++) + for(auto it = physicals[1].begin(); it != physicals[1].end(); it++) + for(auto it2 = it->second.begin(); it2 != it->second.end(); it2++) if(it2->first == lsTag) { cP = 1; break; @@ -1418,7 +1408,7 @@ static void elementCutMesh( if(!it.second) newv->deleteLast(); } else { - std::map<int, MVertex *>::iterator it = vertexMap.find(numV); + auto it = vertexMap.find(numV); if(it == vertexMap.end()) { mv[j] = new MVertex(lines[i]->x(j), lines[i]->y(j), lines[i]->z(j), 0, numV); @@ -1548,7 +1538,8 @@ GModel *buildCutMesh(GModel *gm, gLevelset *ls, } // element number increment - std::size_t numEle = gm->getNumMeshElements() + gm->getNumMeshParentElements(); + std::size_t numEle = + gm->getNumMeshElements() + gm->getNumMeshParentElements(); for(std::size_t i = 0; i < gmEntities.size(); i++) { for(std::size_t j = 0; j < gmEntities[i]->getNumMeshElements(); j++) { MElement *e = gmEntities[i]->getMeshElement(j); @@ -1602,9 +1593,7 @@ GModel *buildCutMesh(GModel *gm, gLevelset *ls, std::vector<int> lsLineRegs; for(std::size_t i = 0; i < gmEntities.size(); i++) { std::vector<int> oldLineRegs; - for(std::map<int, std::vector<MElement *> >::iterator it = - elements[1].begin(); - it != elements[1].end(); it++) + for(auto it = elements[1].begin(); it != elements[1].end(); it++) oldLineRegs.push_back(it->first); int nbBorders = borders[0].size(); for(std::size_t j = 0; j < gmEntities[i]->getNumMeshElements(); j++) { @@ -1624,9 +1613,7 @@ GModel *buildCutMesh(GModel *gm, gLevelset *ls, if((int)borders[0].size() > nbBorders && gmEntities[i]->dim() == 2 && i == gm->getNumVertices() + gm->getNumEdges() + gm->getNumFaces() - 1) { int k = 0; - for(std::map<int, std::vector<MElement *> >::iterator it = - elements[1].begin(); - it != elements[1].end(); it++) { + for(auto it = elements[1].begin(); it != elements[1].end(); it++) { if(oldLineRegs.size() && it->first == oldLineRegs[k]) k++; else @@ -1678,8 +1665,7 @@ GModel *buildCutMesh(GModel *gm, gLevelset *ls, } } - for(DI_Point::Container::iterator it = cp.begin(); it != cp.end(); it++) - delete *it; + for(auto it = cp.begin(); it != cp.end(); it++) delete *it; for(std::size_t k = 0; k < lines.size(); k++) delete lines[k]; for(std::size_t k = 0; k < triangles.size(); k++) delete triangles[k]; for(std::size_t k = 0; k < quads.size(); k++) delete quads[k]; @@ -1718,8 +1704,7 @@ GModel *buildCutMesh(GModel *gm, gLevelset *ls, printf("new Model : %d elements %d nodes\n\n",numElements,vertexMap.size()); #endif - for(newVerticesContainer::iterator it = newVertices.begin(); - it != newVertices.end(); ++it) { + for(auto it = newVertices.begin(); it != newVertices.end(); ++it) { vertexMap[(*it)->getNum()] = *it; } diff --git a/Geo/MElementCut.h b/Geo/MElementCut.h index 10918f65a0825e0156f29cc4f8893fe02c73f99f..757b2a5fa54810b242299e5af199025ed7d947ac 100644 --- a/Geo/MElementCut.h +++ b/Geo/MElementCut.h @@ -193,8 +193,8 @@ public: { return 1; } - virtual int getVertexSolin(int numEdge, int numVertex){return 0;} - virtual MFace getFaceSolin(int numFace){return getFace(numFace);} + virtual int getVertexSolin(int numEdge, int numVertex) { return 0; } + virtual MFace getFaceSolin(int numFace) { return getFace(numFace); } }; class MPolygon : public MElement { @@ -359,8 +359,8 @@ public: { return 1; } - virtual int getVertexSolin(int numEdge, int numVertex){return 0;} - virtual MFace getFaceSolin(int numFace){return getFace(numFace);} + virtual int getVertexSolin(int numEdge, int numVertex) { return 0; } + virtual MFace getFaceSolin(int numFace) { return getFace(numFace); } }; class MLineChild : public MLine { diff --git a/Geo/MElementOctree.cpp b/Geo/MElementOctree.cpp index becc04bfb6ea80fb6bac10794851345dc6d83d99..339ae31f6267917e2926b863500eac33bb34db86 100644 --- a/Geo/MElementOctree.cpp +++ b/Geo/MElementOctree.cpp @@ -152,7 +152,7 @@ std::vector<MElement *> MElementOctree::findAll(double x, double y, double z, std::vector<void *> v; std::vector<MElement *> e; Octree_SearchAll(P, _octree, &v); - for(std::vector<void *>::iterator it = v.begin(); it != v.end(); ++it) { + for(auto it = v.begin(); it != v.end(); ++it) { MElement *el = (MElement *)*it; if(dim == -1 || el->getDim() == dim) e.push_back(el); } @@ -168,9 +168,7 @@ std::vector<MElement *> MElementOctree::findAll(double x, double y, double z, for(std::size_t j = 0; j < entities[i]->getNumMeshElements(); j++) { MElement *el = entities[i]->getMeshElement(j); if(dim == -1 || el->getDim() == dim) { - if(MElementInEle(el, P)) { - e.push_back(el); - } + if(MElementInEle(el, P)) { e.push_back(el); } } } } @@ -190,9 +188,7 @@ std::vector<MElement *> MElementOctree::findAll(double x, double y, double z, for(std::size_t i = 0; i < _elems.size(); i++) { MElement *el = _elems[i]; if(dim == -1 || el->getDim() == dim) { - if(MElementInEle(el, P)) { - e.push_back(el); - } + if(MElementInEle(el, P)) { e.push_back(el); } } } if(!e.empty()) { @@ -215,11 +211,9 @@ MElement *MElementOctree::find(double x, double y, double z, int dim, std::vector<void *> l; if(e && e->getDim() != dim) { Octree_SearchAll(P, _octree, &l); - for(std::vector<void *>::iterator it = l.begin(); it != l.end(); it++) { + for(auto it = l.begin(); it != l.end(); it++) { MElement *el = (MElement *)*it; - if(el->getDim() == dim) { - return el; - } + if(el->getDim() == dim) { return el; } } } if(!strict && _gm) { diff --git a/Geo/MFace.cpp b/Geo/MFace.cpp index ccdf8da51af77b2687f4b7a56840684fed9d3529..d789e6563fb2200063d76a36634287ecb166c2d9 100644 --- a/Geo/MFace.cpp +++ b/Geo/MFace.cpp @@ -109,9 +109,7 @@ void MFace::getOrientationFlagForFace(std::vector<int> &faceOrientationFlag) else { // quadrilateral face int c = 0; for(int i = 0; i < 4; i++) { - if(_v[int(_si[0])]->getNum() == unsigned(_v[i]->getNum())) { - c = i; - } + if(_v[int(_si[0])]->getNum() == unsigned(_v[i]->getNum())) { c = i; } } int indexopposedVertex = 0; switch(c) { diff --git a/Geo/MFace.h b/Geo/MFace.h index bbe0097aefc1e1ea2ae9ed1099fd11f5157ffec7..625385d33539d96ab733f1ddf265ad5b984477a7 100644 --- a/Geo/MFace.h +++ b/Geo/MFace.h @@ -29,7 +29,8 @@ public: std::size_t getNumVertices() const { return _v.size(); } MVertex *getVertex(std::size_t i) const { return _v[i]; } MVertex *getSortedVertex(std::size_t i) const - { return _v[std::size_t(_si[i])]; + { + return _v[std::size_t(_si[i])]; } MEdge getEdge(std::size_t i) const { diff --git a/Geo/MHexahedron.cpp b/Geo/MHexahedron.cpp index 454505e56ebdaeb718bf222e3b511ef645246c15..7ef00df6bdb19e2822355cc48efe823c5c2b097d 100644 --- a/Geo/MHexahedron.cpp +++ b/Geo/MHexahedron.cpp @@ -464,12 +464,8 @@ void MHexahedronN::reverse() std::copy(_vs.begin(), _vs.end(), oldv.begin() + 8); // reverse - for(int i = 0; i < 8; ++i) { - _v[i] = oldv[indices[i]]; - } - for(std::size_t i = 0; i < _vs.size(); ++i) { - _vs[i] = oldv[indices[8 + i]]; - } + for(int i = 0; i < 8; ++i) { _v[i] = oldv[indices[i]]; } + for(std::size_t i = 0; i < _vs.size(); ++i) { _vs[i] = oldv[indices[8 + i]]; } } // void _getIndicesHighOrderFace(int order, int numFace, int sign, int rot, diff --git a/Geo/MHexahedron.h b/Geo/MHexahedron.h index 43fbe85376c836bc047a7ae7b751c9333d8ae207..6a73a8e5403eb1d8cb14efda633a476ca7a7ddb4 100644 --- a/Geo/MHexahedron.h +++ b/Geo/MHexahedron.h @@ -210,15 +210,17 @@ public: return e[face][edge]; } virtual int numCommonNodesInDualGraph(const MElement *const other) const; - virtual int getVertexSolin(int numEdge, int numVertex){ - static const int eSolin[12][2] = {{0, 1}, {0, 3}, {0, 4}, {1, 2}, - {1, 5}, {3, 2}, {2, 6}, {3, 7}, - {4, 5}, {4, 7}, {5, 6}, {7, 6}}; + virtual int getVertexSolin(int numEdge, int numVertex) + { + static const int eSolin[12][2] = {{0, 1}, {0, 3}, {0, 4}, {1, 2}, + {1, 5}, {3, 2}, {2, 6}, {3, 7}, + {4, 5}, {4, 7}, {5, 6}, {7, 6}}; return getVertex(eSolin[numEdge][numVertex])->getNum(); } - virtual MFace getFaceSolin(int numFace){ + virtual MFace getFaceSolin(int numFace) + { static const int fSolin[6][4] = {{0, 1, 3, 2}, {0, 1, 4, 5}, {0, 3, 4, 7}, - {1, 2, 5, 6}, {3, 2, 7, 6}, {4, 5, 7, 6}}; + {1, 2, 5, 6}, {3, 2, 7, 6}, {4, 5, 7, 6}}; return MFace(_v[fSolin[numFace][0]], _v[fSolin[numFace][1]], _v[fSolin[numFace][2]], _v[fSolin[numFace][3]]); } @@ -664,9 +666,7 @@ public: } virtual void getFaceVertices(const int num, std::vector<MVertex *> &v) const { - if(getIsAssimilatedSerendipity()) { - v.resize(4 * _order); - } + if(getIsAssimilatedSerendipity()) { v.resize(4 * _order); } else { v.resize((_order + 1) * (_order + 1)); } @@ -688,9 +688,7 @@ public: if((int)v.size() > count + 1) { int start = 12 * n + num * n * n; - for(int i = 0; i < n * n; i++) { - v[++count] = _vs[start + i]; - } + for(int i = 0; i < n * n; i++) { v[++count] = _vs[start + i]; } } } virtual int getTypeForMSH() const diff --git a/Geo/MLine.h b/Geo/MLine.h index be40e513a7497b1f9932fb930c558462671289db..dddfd5ae23ce6a4b2beb8beac957c46d94c9ea3a 100644 --- a/Geo/MLine.h +++ b/Geo/MLine.h @@ -112,10 +112,11 @@ public: return ((other->getType() == TYPE_LIN || other->getType() == TYPE_PNT) ? 1 : 2); } - virtual int getVertexSolin(int numEdge, int numVertex){ + virtual int getVertexSolin(int numEdge, int numVertex) + { return getVertex(numVertex)->getNum(); } - virtual MFace getFaceSolin(int numFace){return getFace(numFace);} + virtual MFace getFaceSolin(int numFace) { return getFace(numFace); } }; /* diff --git a/Geo/MPoint.h b/Geo/MPoint.h index 2d5ce2b05620433f13536051a023a64ffefc387c..a75f6550860aab6e281418840e52b1f008af7615 100644 --- a/Geo/MPoint.h +++ b/Geo/MPoint.h @@ -90,8 +90,8 @@ public: { return 1; } - virtual int getVertexSolin(int numEdge, int numVertex){return 0;} - virtual MFace getFaceSolin(int numFace){return getFace(numFace);} + virtual int getVertexSolin(int numEdge, int numVertex) { return 0; } + virtual MFace getFaceSolin(int numFace) { return getFace(numFace); } }; #endif diff --git a/Geo/MPrism.cpp b/Geo/MPrism.cpp index c88ee7e64fb71692ffc5e71687ba3cdca011cd84..ff8513564e2ee73e72ac2ce827f6e89eed403de7 100644 --- a/Geo/MPrism.cpp +++ b/Geo/MPrism.cpp @@ -593,12 +593,8 @@ void MPrismN::reverse() std::copy(_vs.begin(), _vs.end(), oldv.begin() + 6); // reverse - for(int i = 0; i < 6; ++i) { - _v[i] = oldv[indices[i]]; - } - for(std::size_t i = 0; i < _vs.size(); ++i) { - _vs[i] = oldv[indices[6 + i]]; - } + for(int i = 0; i < 6; ++i) { _v[i] = oldv[indices[i]]; } + for(std::size_t i = 0; i < _vs.size(); ++i) { _vs[i] = oldv[indices[6 + i]]; } } void MPrismN::getNode(int num, double &u, double &v, double &w) const diff --git a/Geo/MPrism.h b/Geo/MPrism.h index bcb38c2541a71245bf5c947609b04a3ae703b31a..9458611c11e6697ef6aaa7d17b8ec8f9067913b8 100644 --- a/Geo/MPrism.h +++ b/Geo/MPrism.h @@ -216,26 +216,26 @@ public: virtual int numCommonNodesInDualGraph(const MElement *const other) const; virtual int getVertexSolin(int numEdge, int numVertex) { - static const int eSolin[9][2] = {{0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 4}, - {2, 5}, {3, 4}, {3, 5}, {4, 5}}; + static const int eSolin[9][2] = {{0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 4}, + {2, 5}, {3, 4}, {3, 5}, {4, 5}}; return getVertex(eSolin[numEdge][numVertex])->getNum(); } virtual MFace getFaceSolin(int numFace) { - static const int fSolin[5][4] = {{0, 1, 3, 4}, {0, 2, 3, 5}, {1, 2, 4, 5}, - {0, 1, 2, -1}, {3, 4, 5, -1}}; - if(numFace > 2){ - return MFace(_v[fSolin[numFace][0]],_v[fSolin[numFace][1]], + static const int fSolin[5][4] = { + {0, 1, 3, 4}, {0, 2, 3, 5}, {1, 2, 4, 5}, {0, 1, 2, -1}, {3, 4, 5, -1}}; + if(numFace > 2) { + return MFace(_v[fSolin[numFace][0]], _v[fSolin[numFace][1]], _v[fSolin[numFace][2]]); } - else{ + else { return MFace(_v[fSolin[numFace][0]], _v[fSolin[numFace][1]], _v[fSolin[numFace][2]], _v[fSolin[numFace][3]]); } } virtual MVertex *getVertexVTK(int num) { - static const int map[6] = {0,2,1,3,5,4}; + static const int map[6] = {0, 2, 1, 3, 5, 4}; return getVertex(map[num]); } }; @@ -314,19 +314,19 @@ public: } virtual MVertex *getVertexBDF(int num) { - static const int map[15] = {0, 1, 2, 3, 4, 5, 6, 9, 7, - 8, 10, 11, 12, 14, 13}; + static const int map[15] = {0, 1, 2, 3, 4, 5, 6, 9, + 7, 8, 10, 11, 12, 14, 13}; return getVertex(map[num]); } virtual MVertex *getVertexINP(int num) { - static const int map[15] = {0, 1, 2, 3, 4, 5, 6, 9, 7, - 12, 14, 13, 8, 10, 11}; + static const int map[15] = {0, 1, 2, 3, 4, 5, 6, 9, + 7, 12, 14, 13, 8, 10, 11}; return getVertex(map[num]); } virtual MVertex *getVertexVTK(int num) { - static const int map[15] = {0, 1, 2, 3, 4, 5, 6, 9, + static const int map[15] = {0, 1, 2, 3, 4, 5, 6, 9, 7, 12, 14, 13, 8, 10, 11}; return getVertex(map[num]); } @@ -521,8 +521,8 @@ public: virtual int getTypeForVTK() const { return 32; } virtual MVertex *getVertexVTK(int num) { - static const int map[18] = {0, 1, 2, 3, 4, 5, 6, 9, 7, - 12, 14, 13, 8, 10, 11, 15,17,16}; + static const int map[18] = {0, 1, 2, 3, 4, 5, 6, 9, 7, + 12, 14, 13, 8, 10, 11, 15, 17, 16}; return getVertex(map[num]); } }; diff --git a/Geo/MPyramid.cpp b/Geo/MPyramid.cpp index a08799e2c64a3a18522f2d45452c241e0da44fc2..32170a141739c0d5e2fedf3e70202c4c584b28f4 100644 --- a/Geo/MPyramid.cpp +++ b/Geo/MPyramid.cpp @@ -430,12 +430,8 @@ void MPyramidN::reverse() std::copy(_vs.begin(), _vs.end(), oldv.begin() + 5); // reverse - for(int i = 0; i < 5; ++i) { - _v[i] = oldv[indices[i]]; - } - for(std::size_t i = 0; i < _vs.size(); ++i) { - _vs[i] = oldv[indices[5 + i]]; - } + for(int i = 0; i < 5; ++i) { _v[i] = oldv[indices[i]]; } + for(std::size_t i = 0; i < _vs.size(); ++i) { _vs[i] = oldv[indices[5 + i]]; } } void MPyramidN::_addHOEdgePoints(int num, std::vector<MVertex *> &v, diff --git a/Geo/MPyramid.h b/Geo/MPyramid.h index b8cc1f5c30f19a6f59184b32990829152cac0b5d..6f9a4f5e1c9c3a9fe69ede7537dc05f04edc6559 100644 --- a/Geo/MPyramid.h +++ b/Geo/MPyramid.h @@ -196,8 +196,8 @@ public: return e[face][edge]; } virtual int numCommonNodesInDualGraph(const MElement *const other) const; - virtual int getVertexSolin(int numEdge, int numVertex){return 0;} - virtual MFace getFaceSolin(int numFace){return getFace(numFace);} + virtual int getVertexSolin(int numEdge, int numVertex) { return 0; } + virtual MFace getFaceSolin(int numFace) { return getFace(numFace); } }; /* diff --git a/Geo/MQuadrangle.cpp b/Geo/MQuadrangle.cpp index c45673401ada23953b12a331edbb88dc5569488c..85487fe5032c4b5adfac063f73b3c17317d74f21 100644 --- a/Geo/MQuadrangle.cpp +++ b/Geo/MQuadrangle.cpp @@ -401,9 +401,7 @@ double MQuadrangle::getInnerRadius() double R = 1.e22; for(int j = 0; j < 4; j++) { r[j] = computeInnerRadiusForQuad(xn, yn, j); - if(r[j] < R) { - R = r[j]; - } + if(r[j] < R) { R = r[j]; } } return R; #else @@ -448,7 +446,7 @@ void MQuadrangleN::reverse() _v[3] = tmp; int npts = _order - 1, base = 0; - std::vector<MVertex *>::iterator begin = _vs.begin() + base; + auto begin = _vs.begin() + base; while(npts > 0) { std::reverse(begin, begin + 4 * npts); @@ -565,12 +563,8 @@ void MQuadrangleN::reorient(int rot, bool swap) std::copy(_vs.begin(), _vs.end(), oldv.begin() + 4); // reorient - for(int i = 0; i < 4; ++i) { - _v[i] = oldv[indices[i]]; - } - for(std::size_t i = 0; i < _vs.size(); ++i) { - _vs[i] = oldv[indices[4 + i]]; - } + for(int i = 0; i < 4; ++i) { _v[i] = oldv[indices[i]]; } + for(std::size_t i = 0; i < _vs.size(); ++i) { _vs[i] = oldv[indices[4 + i]]; } } MFaceN MQuadrangle::getHighOrderFace(int num, int sign, int rot) diff --git a/Geo/MQuadrangle.h b/Geo/MQuadrangle.h index a007538881ee6664cdc2de87a5740747e93d48b8..d25795096631360c87d27b78ca1bf20029459508 100644 --- a/Geo/MQuadrangle.h +++ b/Geo/MQuadrangle.h @@ -172,16 +172,18 @@ public: virtual double getOuterRadius(); static int edges_quad(const int edge, const int vert) { - static const int e[4][2] = {{0, 1}, {1, 2}, {2, 3}, {3, 0}}; + static const int e[4][2] = {{0, 1}, {1, 2}, {2, 3}, {3, 0}}; return e[edge][vert]; } virtual int numCommonNodesInDualGraph(const MElement *const other) const; - virtual int getVertexSolin(int numEdge, int numVertex){ - static const int eSolin[4][2] = {{0, 1}, {1, 2}, {3, 2}, {0, 3}}; + virtual int getVertexSolin(int numEdge, int numVertex) + { + static const int eSolin[4][2] = {{0, 1}, {1, 2}, {3, 2}, {0, 3}}; return getVertex(eSolin[numEdge][numVertex])->getNum(); } - virtual MFace getFaceSolin(int numFace){ - return MFace(_v[0], _v[1], _v[3], _v[2]); + virtual MFace getFaceSolin(int numFace) + { + return MFace(_v[0], _v[1], _v[3], _v[2]); } }; diff --git a/Geo/MTetrahedron.cpp b/Geo/MTetrahedron.cpp index 2cd0a3388f23051dc08663c3f61166d9fc4078be..9b137296f56264175a26fa8f8357bfa2748f9e67 100644 --- a/Geo/MTetrahedron.cpp +++ b/Geo/MTetrahedron.cpp @@ -382,10 +382,6 @@ void MTetrahedronN::reverse() std::copy(_vs.begin(), _vs.end(), oldv.begin() + 4); // reverse - for(int i = 0; i < 4; ++i) { - _v[i] = oldv[indices[i]]; - } - for(std::size_t i = 0; i < _vs.size(); ++i) { - _vs[i] = oldv[indices[4 + i]]; - } + for(int i = 0; i < 4; ++i) { _v[i] = oldv[indices[i]]; } + for(std::size_t i = 0; i < _vs.size(); ++i) { _vs[i] = oldv[indices[4 + i]]; } } diff --git a/Geo/MTetrahedron.h b/Geo/MTetrahedron.h index 40c2a4fefda4de1d02f71b01f84dcf6145b5522d..18c83f0fec0588a34f1b69a72b29338253c1844a 100644 --- a/Geo/MTetrahedron.h +++ b/Geo/MTetrahedron.h @@ -198,12 +198,16 @@ public: return e[face][edge]; } virtual int numCommonNodesInDualGraph(const MElement *const other) const; - virtual int getVertexSolin(int numEdge, int numVertex){ - static const int eSolin[6][2] = {{0, 1}, {1, 2}, {2, 0}, {0, 3}, {2, 3}, {1, 3}}; + virtual int getVertexSolin(int numEdge, int numVertex) + { + static const int eSolin[6][2] = {{0, 1}, {1, 2}, {2, 0}, + {0, 3}, {2, 3}, {1, 3}}; return getVertex(eSolin[numEdge][numVertex])->getNum(); } - virtual MFace getFaceSolin(int numFace){ - static const int fSolin[4][3] = {{0, 1, 2}, {0, 1, 3}, {0, 2, 3}, {1, 2, 3}}; + virtual MFace getFaceSolin(int numFace) + { + static const int fSolin[4][3] = { + {0, 1, 2}, {0, 1, 3}, {0, 2, 3}, {1, 2, 3}}; return MFace(_v[fSolin[numFace][0]], _v[fSolin[numFace][1]], _v[fSolin[numFace][2]]); } @@ -423,9 +427,7 @@ public: } virtual void getFaceVertices(const int num, std::vector<MVertex *> &v) const { - if(getIsAssimilatedSerendipity()) { - v.resize(3 * _order); - } + if(getIsAssimilatedSerendipity()) { v.resize(3 * _order); } else { v.resize((_order + 1) * (_order + 2) / 2); } @@ -447,9 +449,7 @@ public: if((int)v.size() > count + 1) { int start = 6 * n + num * (n - 1) * n / 2; - for(int i = 0; i < (n - 1) * n / 2; i++) { - v[++count] = _vs[start + i]; - } + for(int i = 0; i < (n - 1) * n / 2; i++) { v[++count] = _vs[start + i]; } } } virtual int getNumVolumeVertices() const diff --git a/Geo/MTriangle.cpp b/Geo/MTriangle.cpp index cf97caffae0a250d5217f6c08665ca18174ac9b5..c4b936699192afe71a4438a88066ea6884dd1024 100644 --- a/Geo/MTriangle.cpp +++ b/Geo/MTriangle.cpp @@ -123,7 +123,6 @@ double MTriangle::gammaShapeMeasure() void MTriangle::xyz2uvw(double xyz[3], double uvw[3]) const { - // double M[2][2], R[2]; // const SPoint2 p0 (getVertex(0)->x(),getVertex(0)->y()); // const SPoint2 p1 (getVertex(1)->x(),getVertex(1)->y()); @@ -365,7 +364,7 @@ void MTriangleN::reverse() _v[2] = tmp; int npts = _order - 1, base = 0; - std::vector<MVertex *>::iterator begin = _vs.begin() + base; + auto begin = _vs.begin() + base; while(npts > 0) { std::reverse(begin, begin + 3 * npts); @@ -468,12 +467,8 @@ void MTriangleN::reorient(int rot, bool swap) std::copy(_vs.begin(), _vs.end(), oldv.begin() + 3); // reorient - for(int i = 0; i < 3; ++i) { - _v[i] = oldv[indices[i]]; - } - for(std::size_t i = 0; i < _vs.size(); ++i) { - _vs[i] = oldv[indices[3 + i]]; - } + for(int i = 0; i < 3; ++i) { _v[i] = oldv[indices[i]]; } + for(std::size_t i = 0; i < _vs.size(); ++i) { _vs[i] = oldv[indices[3 + i]]; } } MFaceN MTriangle::getHighOrderFace(int num, int sign, int rot) diff --git a/Geo/MTriangle.h b/Geo/MTriangle.h index b0300ce871e544537d50579e1a829710a2a3bd54..0fa0009be0c59f76f16f2ccd2d5acf5665853f51 100644 --- a/Geo/MTriangle.h +++ b/Geo/MTriangle.h @@ -167,11 +167,12 @@ public: return e[edge][vert]; } virtual int numCommonNodesInDualGraph(const MElement *const other) const; - virtual int getVertexSolin(int numEdge, int numVertex){ + virtual int getVertexSolin(int numEdge, int numVertex) + { static const int eSolin[3][2] = {{0, 1}, {1, 2}, {2, 0}}; return getVertex(eSolin[numEdge][numVertex])->getNum(); } - virtual MFace getFaceSolin(int numFace){return getFace(numFace);} + virtual MFace getFaceSolin(int numFace) { return getFace(numFace); } }; /* diff --git a/Geo/MTrihedron.h b/Geo/MTrihedron.h index b86b7688690372340c5c0996c5e8155ffa2ac4c9..1ed297f277722b1e18cecbd3fc424b39caa1da49 100644 --- a/Geo/MTrihedron.h +++ b/Geo/MTrihedron.h @@ -180,8 +180,8 @@ public: // order to put an edge between them in the dual graph used during the // partitioning. virtual int numCommonNodesInDualGraph(const MElement *const other) const; - virtual int getVertexSolin(int numEdge, int numVertex){return 0;} - virtual MFace getFaceSolin(int numFace){return getFace(numFace);} + virtual int getVertexSolin(int numEdge, int numVertex) { return 0; } + virtual MFace getFaceSolin(int numFace) { return getFace(numFace); } }; #endif diff --git a/Geo/MVertex.cpp b/Geo/MVertex.cpp index 73a717277a29a70c188b451a6c593b7b4149a857..cbda9732acdfbbf65799d1cff02f99629c1d22c2 100644 --- a/Geo/MVertex.cpp +++ b/Geo/MVertex.cpp @@ -420,8 +420,7 @@ static void getAllParameters(MVertex *v, GFace *gf, GVertex *gv = (GVertex *)v->onWhat(); std::vector<GEdge *> const &ed = gv->edges(); bool seam = false; - for(std::vector<GEdge *>::const_iterator it = ed.begin(); it != ed.end(); - it++) { + for(auto it = ed.begin(); it != ed.end(); it++) { if((*it)->isSeam(gf)) { Range<double> range = (*it)->parBounds(0); if(gv == (*it)->getBeginVertex()) { @@ -534,8 +533,7 @@ bool reparamMeshVertexOnFace(MVertex const *v, const GFace *gf, SPoint2 ¶m, param = gv->reparamOnFace(gf, 1); // shout, we could be on a seam std::vector<GEdge *> const &ed = gv->edges(); - for(std::vector<GEdge *>::const_iterator it = ed.begin(); it != ed.end(); - it++) + for(auto it = ed.begin(); it != ed.end(); it++) if((*it)->isSeam(gf)) return false; } else if(v->onWhat()->dim() == 1) { diff --git a/Geo/MVertex.h b/Geo/MVertex.h index 0ea90d84ca3e25de548b0918894146d745947d68..2486f46848e8a4523a12ee454556ddfc12e40edd 100644 --- a/Geo/MVertex.h +++ b/Geo/MVertex.h @@ -149,7 +149,7 @@ public: } virtual bool setParameter(int i, double par) { - if (i != 0 ) return false; + if(i != 0) return false; _u = par; return true; } @@ -221,10 +221,7 @@ struct MVertexPtrEqual { }; struct MVertexPtrHash { - size_t operator()(const MVertex *v) const - { - return v->getNum(); - } + size_t operator()(const MVertex *v) const { return v->getNum(); } }; bool reparamMeshEdgeOnFace(MVertex *v1, MVertex *v2, GFace *gf, SPoint2 ¶m1, diff --git a/Geo/MVertexBoundaryLayerData.cpp b/Geo/MVertexBoundaryLayerData.cpp index 2fa129b353eda7c7ab4728f362da071bbe95e699..0592187c6c9aad9e956663aa4d811aa9f7a908ac 100644 --- a/Geo/MVertexBoundaryLayerData.cpp +++ b/Geo/MVertexBoundaryLayerData.cpp @@ -7,9 +7,7 @@ std::vector<MVertex *> *MVertexBoundaryLayerData::getChildren(int i) { - if(i < (int)this->children.size() && i >= 0) { - return &(children[i]); - } + if(i < (int)this->children.size() && i >= 0) { return &(children[i]); } else { return 0; } diff --git a/Geo/OCCAttributes.h b/Geo/OCCAttributes.h index 2f3ddc30bdd471a72291c84fc77c62d14850c990..cceaf0c1800e0794b4716c76b2299f3449fc8ffe 100644 --- a/Geo/OCCAttributes.h +++ b/Geo/OCCAttributes.h @@ -31,11 +31,9 @@ private: TopoDS_Shape _sourceShape; std::string _label; std::vector<double> _color; + public: - OCCAttributes() - : _dim(-1), _meshSize(MAX_LC), _extrude(0), _sourceDim(-1) - { - } + OCCAttributes() : _dim(-1), _meshSize(MAX_LC), _extrude(0), _sourceDim(-1) {} OCCAttributes(int dim, TopoDS_Shape shape) : _dim(dim), _shape(shape), _meshSize(MAX_LC), _extrude(0), _sourceDim(-1) { @@ -44,8 +42,8 @@ public: : _dim(dim), _shape(shape), _meshSize(size), _extrude(0), _sourceDim(-1) { } - OCCAttributes(int dim, TopoDS_Shape shape, ExtrudeParams *e, - int sourceDim, TopoDS_Shape sourceShape) + OCCAttributes(int dim, TopoDS_Shape shape, ExtrudeParams *e, int sourceDim, + TopoDS_Shape sourceShape) : _dim(dim), _shape(shape), _meshSize(MAX_LC), _extrude(e), _sourceDim(sourceDim), _sourceShape(sourceShape) { @@ -94,9 +92,9 @@ private: return true; } void _find(int dim, const TopoDS_Shape &shape, - std::vector<OCCAttributes *> &attr, - bool requireMeshSize, bool requireExtrudeParams, bool requireLabel, - bool requireColor, bool excludeSame) + std::vector<OCCAttributes *> &attr, bool requireMeshSize, + bool requireExtrudeParams, bool requireLabel, bool requireColor, + bool excludeSame) { attr.clear(); if(dim < 0 || dim > 3) return; @@ -206,7 +204,8 @@ public: try { BRepBndLib::Add(v->getShape(), box, Standard_False); if(box.IsVoid()) { - Msg::Debug("Inserting (null or degenerate) shape with void bounding box"); + Msg::Debug( + "Inserting (null or degenerate) shape with void bounding box"); // BRepTools::Dump(v->getShape(), std::cout); return; } @@ -230,7 +229,8 @@ public: try { BRepBndLib::Add(v->getShape(), box, Standard_False); if(box.IsVoid()) { - Msg::Debug("Removing (null or degenerate) shape with void bounding box"); + Msg::Debug( + "Removing (null or degenerate) shape with void bounding box"); // BRepTools::Dump(v->getShape(), std::cout); return; } @@ -279,8 +279,7 @@ public: std::vector<OCCAttributes *> attr; _find(dim, shape, attr, false, false, true, false, false); for(std::size_t i = 0; i < attr.size(); i++) { - if(!attr[i]->getLabel().empty()) - labels.push_back(attr[i]->getLabel()); + if(!attr[i]->getLabel().empty()) labels.push_back(attr[i]->getLabel()); } } bool getColor(int dim, TopoDS_Shape shape, unsigned int &color, @@ -290,7 +289,7 @@ public: _find(dim, shape, attr, false, false, false, true, false); for(std::size_t i = 0; i < attr.size(); i++) { const std::vector<double> &col = attr[i]->getColor(); - if(col.size() >= 3){ + if(col.size() >= 3) { int r = (int)(col[0] * 255); r = (r < 0) ? 0 : (r > 255) ? 255 : r; int g = (int)(col[1] * 255); @@ -298,7 +297,7 @@ public: int b = (int)(col[2] * 255); b = (b < 0) ? 0 : (b > 255) ? 255 : b; int a = 255; - if(col.size() >= 4){ + if(col.size() >= 4) { int a = (int)(col[3] * 255); a = (a < 0) ? 0 : (a > 255) ? 255 : a; } diff --git a/Geo/OCCEdge.cpp b/Geo/OCCEdge.cpp index 68957679ba8a6b3f5be3f4d89352304a703510ba..acd4e0d1110eff46d10bded920a4fcf4f3e21ddd 100644 --- a/Geo/OCCEdge.cpp +++ b/Geo/OCCEdge.cpp @@ -41,7 +41,8 @@ OCCEdge::OCCEdge(GModel *m, TopoDS_Edge c, int num, GVertex *v1, GVertex *v2) { // force orientation of internal/external edges: otherwise reverse will not // produce the expected result - if(_c.Orientation() == TopAbs_INTERNAL || _c.Orientation() == TopAbs_EXTERNAL) { + if(_c.Orientation() == TopAbs_INTERNAL || + _c.Orientation() == TopAbs_EXTERNAL) { _c = TopoDS::Edge(_c.Oriented(TopAbs_FORWARD)); } _curve = BRep_Tool::Curve(_c, _s0, _s1); @@ -69,13 +70,17 @@ SBoundingBox3d OCCEdge::bounds(bool fast) b.Get(xmin, ymin, zmin, xmax, ymax, zmax); if(CTX::instance()->geom.occBoundsUseSTL) - model()->getOCCInternals()->fixSTLBounds(xmin, ymin, zmin, xmax, ymax, zmax); + model()->getOCCInternals()->fixSTLBounds(xmin, ymin, zmin, xmax, ymax, + zmax); SBoundingBox3d bbox(xmin, ymin, zmin, xmax, ymax, zmax); return bbox; } -Range<double> OCCEdge::parBounds(int i) const { return Range<double>(_s0, _s1); } +Range<double> OCCEdge::parBounds(int i) const +{ + return Range<double>(_s0, _s1); +} Range<double> OCCEdge::parBoundsOnFace(GFace *face) const { @@ -111,9 +116,7 @@ SPoint2 OCCEdge::reparamOnFace(const GFace *face, double epar, int dir) const double t0, t1; Handle(Geom2d_Curve) c2d; - if(dir == 1) { - c2d = BRep_Tool::CurveOnSurface(_c, *s, t0, t1); - } + if(dir == 1) { c2d = BRep_Tool::CurveOnSurface(_c, *s, t0, t1); } else { c2d = BRep_Tool::CurveOnSurface(_c_rev, *s, t0, t1); } @@ -140,9 +143,10 @@ SPoint2 OCCEdge::reparamOnFace(const GFace *face, double epar, int dir) const double dy = p1.y() - p2.y(); double dz = p1.z() - p2.z(); if(sqrt(dx * dx + dy * dy + dz * dz) > CTX::instance()->geom.tolerance) { - Msg::Debug("Reparam on surface was inaccurate for curve %d on surface %d " - "at point %g", - tag(), face->tag(), epar); + Msg::Debug( + "Reparam on surface was inaccurate for curve %d on surface %d " + "at point %g", + tag(), face->tag(), epar); Msg::Debug("On the surface %d local (%g %g) global (%g %g %g)", face->tag(), u, v, p2.x(), p2.y(), p2.z()); Msg::Debug("On the curve %d local (%g) global (%g %g %g)", tag(), epar, @@ -158,12 +162,14 @@ SPoint2 OCCEdge::reparamOnFace(const GFace *face, double epar, int dir) const dz = p1.z() - p2.z(); if(sqrt(dx * dx + dy * dy + dz * dz) > CTX::instance()->geom.tolerance) { - Msg::Warning("Closest point was inaccurate for curve %d on surface %d " - "at point %g", tag(), face->tag(), epar); + Msg::Warning( + "Closest point was inaccurate for curve %d on surface %d " + "at point %g", + tag(), face->tag(), epar); Msg::Warning("On the surface %d local (%g %g) global (%g %g %g)", face->tag(), u, v, p2.x(), p2.y(), p2.z()); - Msg::Warning("On the curve %d local (%g) global (%g %g %g)", tag(), epar, - p1.x(), p1.y(), p1.z()); + Msg::Warning("On the curve %d local (%g) global (%g %g %g)", tag(), + epar, p1.x(), p1.y(), p1.z()); } } } @@ -184,16 +190,16 @@ bool OCCEdge::_project(const double p[3], double &u, double xyz[3]) const if(!periodic(0)) { const double du = umax - umin; const double utol = std::max(fabs(du) * 1e-8, 1e-12); - umin -= utol; - umax += utol; + umin -= utol; + umax += utol; } gp_Pnt pnt(p[0], p[1], p[2]); GeomAPI_ProjectPointOnCurve proj(pnt, _curve, umin, umax); if(!proj.NbPoints()) { - Msg::Warning("Projection of point (%g, %g, %g) on curve %d failed", - p[0], p[1], p[2], tag()); + Msg::Warning("Projection of point (%g, %g, %g) on curve %d failed", p[0], + p[1], p[2], tag()); return false; } @@ -255,13 +261,12 @@ GPoint OCCEdge::point(double par) const return GPoint(pnt.X(), pnt.Y(), pnt.Z(), this, par); } else if(degenerate(0)) { - return GPoint(getBeginVertex()->x(), - getBeginVertex()->y(), + return GPoint(getBeginVertex()->x(), getBeginVertex()->y(), getBeginVertex()->z()); } else { - Msg::Warning("OpenCASCADE curve %d is neither a 3D curve nor a trimmed curve", - tag()); + Msg::Warning( + "OpenCASCADE curve %d is neither a 3D curve nor a trimmed curve", tag()); return GPoint(0, 0, 0); } } @@ -334,9 +339,7 @@ int OCCEdge::minimumMeshSegments() const // if it is a seam, then return 1 if(_faces.size() == 1 && isSeam(_faces[0])) return 1; - if(geomType() == Line) { - np = GEdge::minimumMeshSegments(); - } + if(geomType() == Line) { np = GEdge::minimumMeshSegments(); } else if(geomType() == Circle || geomType() == Ellipse) { double a = fabs(_s0 - _s1); double n = CTX::instance()->mesh.minCircPoints; diff --git a/Geo/OCCFace.cpp b/Geo/OCCFace.cpp index 91d11a23f62ddbd38b397770f7b03bdba62e4584..500e8ca54adc496dca09e1dbec2c4cece1c0e5cb 100644 --- a/Geo/OCCFace.cpp +++ b/Geo/OCCFace.cpp @@ -161,8 +161,7 @@ void OCCFace::_setup() SBoundingBox3d OCCFace::bounds(bool fast) { - if(CTX::instance()->geom.occBoundsUseSTL) - buildSTLTriangulation(); + if(CTX::instance()->geom.occBoundsUseSTL) buildSTLTriangulation(); Bnd_Box b; try { @@ -175,7 +174,8 @@ SBoundingBox3d OCCFace::bounds(bool fast) b.Get(xmin, ymin, zmin, xmax, ymax, zmax); if(CTX::instance()->geom.occBoundsUseSTL) - model()->getOCCInternals()->fixSTLBounds(xmin, ymin, zmin, xmax, ymax, zmax); + model()->getOCCInternals()->fixSTLBounds(xmin, ymin, zmin, xmax, ymax, + zmax); SBoundingBox3d bbox(xmin, ymin, zmin, xmax, ymax, zmax); return bbox; @@ -240,20 +240,20 @@ bool OCCFace::_project(const double p[3], double uv[2], double xyz[3]) const if(!_periodic[0]) { const double du = _umax - _umin; const double utol = std::max(fabs(du) * 1e-8, 1e-12); - umin -= utol; - umax += utol; + umin -= utol; + umax += utol; } if(!_periodic[1]) { const double dv = _vmax - _vmin; const double vtol = std::max(fabs(dv) * 1e-8, 1e-12); - vmin -= vtol; - vmax += vtol; + vmin -= vtol; + vmax += vtol; } gp_Pnt pnt(p[0], p[1], p[2]); GeomAPI_ProjectPointOnSurf proj(pnt, _occface, umin, umax, vmin, vmax); if(!proj.NbPoints()) { - Msg::Warning("Projection of point (%g, %g, %g) on surface %d failed", - p[0], p[1], p[2], tag()); + Msg::Warning("Projection of point (%g, %g, %g) on surface %d failed", p[0], + p[1], p[2], tag()); return false; } proj.LowerDistanceParameters(uv[0], uv[1]); @@ -366,9 +366,8 @@ bool OCCFace::containsPoint(const SPoint3 &pt) const double angle = 0.; double v[3] = {pt.x(), pt.y(), pt.z()}; - std::vector<int>::const_iterator ito = l_dirs.begin(); - for(std::vector<GEdge *>::const_iterator it = l_edges.begin(); - it != l_edges.end(); it++) { + auto ito = l_dirs.begin(); + for(auto it = l_edges.begin(); it != l_edges.end(); it++) { GEdge *c = *it; int ori = 1; if(ito != l_dirs.end()) { @@ -406,7 +405,7 @@ bool OCCFace::buildSTLTriangulation(bool force) stl_vertices_xyz.clear(); stl_triangles.clear(); if(!model()->getOCCInternals()->makeFaceSTL( - _s, stl_vertices_uv, stl_vertices_xyz, stl_normals, stl_triangles)) { + _s, stl_vertices_uv, stl_vertices_xyz, stl_normals, stl_triangles)) { Msg::Info("OpenCASCADE triangulation of surface %d failed", tag()); // add a dummy triangle so that we won't try again stl_vertices_uv.push_back(SPoint2(0., 0.)); @@ -417,12 +416,14 @@ bool OCCFace::buildSTLTriangulation(bool force) return false; } - // compute the triangulation of the edges which are the boundaries of this face + // compute the triangulation of the edges which are the boundaries of this + // face std::vector<GEdge *> const &e = edges(); - for(std::vector<GEdge *>::const_iterator it = e.begin(); it != e.end(); it++) { - if ((*it)->stl_vertices_xyz.size() == 0) { + for(auto it = e.begin(); it != e.end(); it++) { + if((*it)->stl_vertices_xyz.size() == 0) { const TopoDS_Edge *c = (TopoDS_Edge *)(*it)->getNativePtr(); - model()->getOCCInternals()->makeEdgeSTLFromFace(*c, _s, &((*it)->stl_vertices_xyz)); + model()->getOCCInternals()->makeEdgeSTLFromFace( + *c, _s, &((*it)->stl_vertices_xyz)); } } diff --git a/Geo/OCCRegion.cpp b/Geo/OCCRegion.cpp index 3cbc73c47aa6cabc3943ebfeeb9cfee1c018008b..233cdd7e6d9f6a98517b75d5314393b3dc662cef 100644 --- a/Geo/OCCRegion.cpp +++ b/Geo/OCCRegion.cpp @@ -48,9 +48,7 @@ void OCCRegion::_setup() GFace *f = 0; if(model()->getOCCInternals()) f = model()->getOCCInternals()->getFaceForOCCShape(model(), face); - if(!f) { - Msg::Error("Unknown surface in volume %d", tag()); - } + if(!f) { Msg::Error("Unknown surface in volume %d", tag()); } else if(face.Orientation() == TopAbs_INTERNAL) { Msg::Debug("Adding embedded surface %d in volume %d", f->tag(), tag()); embedded_faces.push_back(f); @@ -67,9 +65,7 @@ void OCCRegion::_setup() GEdge *e = 0; if(model()->getOCCInternals()) e = model()->getOCCInternals()->getEdgeForOCCShape(model(), edge); - if(!e) { - Msg::Error("Unknown curve in volume %d", tag()); - } + if(!e) { Msg::Error("Unknown curve in volume %d", tag()); } else if(edge.Orientation() == TopAbs_INTERNAL) { Msg::Debug("Adding embedded curve %d in volume %d", e->tag(), tag()); embedded_edges.push_back(e); @@ -83,9 +79,7 @@ void OCCRegion::_setup() GVertex *v = 0; if(model()->getOCCInternals()) v = model()->getOCCInternals()->getVertexForOCCShape(model(), vertex); - if(!v) { - Msg::Error("Unknown point in volume %d", tag()); - } + if(!v) { Msg::Error("Unknown point in volume %d", tag()); } else if(vertex.Orientation() == TopAbs_INTERNAL) { Msg::Debug("Adding embedded point %d in volume %d", v->tag(), tag()); embedded_vertices.push_back(v); @@ -101,8 +95,7 @@ SBoundingBox3d OCCRegion::bounds(bool fast) // if a triangulation exist on a shape, OCC will use it to compute more // accurate bounds std::vector<GFace *> f = faces(); - for(std::size_t i = 0; i < f.size(); i++) - f[i]->buildSTLTriangulation(); + for(std::size_t i = 0; i < f.size(); i++) f[i]->buildSTLTriangulation(); } Bnd_Box b; @@ -116,7 +109,8 @@ SBoundingBox3d OCCRegion::bounds(bool fast) b.Get(xmin, ymin, zmin, xmax, ymax, zmax); if(CTX::instance()->geom.occBoundsUseSTL) - model()->getOCCInternals()->fixSTLBounds(xmin, ymin, zmin, xmax, ymax, zmax); + model()->getOCCInternals()->fixSTLBounds(xmin, ymin, zmin, xmax, ymax, + zmax); SBoundingBox3d bbox(xmin, ymin, zmin, xmax, ymax, zmax); return bbox; diff --git a/Geo/OCCVertex.cpp b/Geo/OCCVertex.cpp index 78ace3012d5e9780323b51d1c865bdee0dac7979..8a0b21bac5980ec74ab2cc323f7a7069ed18bed7 100644 --- a/Geo/OCCVertex.cpp +++ b/Geo/OCCVertex.cpp @@ -47,7 +47,7 @@ double max_surf_curvature(const GVertex *gv, double x, double y, double z, const GEdge *_myGEdge) { std::vector<GFace *> faces = _myGEdge->faces(); - std::vector<GFace *>::iterator it = faces.begin(); + auto it = faces.begin(); double curv = 1.e-22; while(it != faces.end()) { SPoint2 par = gv->reparamOnFace((*it), 1); @@ -60,7 +60,7 @@ double max_surf_curvature(const GVertex *gv, double x, double y, double z, SPoint2 OCCVertex::reparamOnFace(const GFace *gf, int dir) const { - std::vector<GEdge *>::const_iterator it = l_edges.begin(); + auto it = l_edges.begin(); while(it != l_edges.end()) { std::vector<GEdge *> const &l = gf->edges(); if(std::find(l.begin(), l.end(), *it) != l.end()) { diff --git a/Geo/SOrientedBoundingBox.cpp b/Geo/SOrientedBoundingBox.cpp index 94df4bd61f0e6be708beffa8e65bab493c13927e..5a0003d7b1489efd905a4a744ae3e192f93b9118 100644 --- a/Geo/SOrientedBoundingBox.cpp +++ b/Geo/SOrientedBoundingBox.cpp @@ -168,8 +168,7 @@ SOrientedBoundingBox::buildOBB(std::vector<SPoint3> &vertices) vmaxs.setAll(-DBL_MAX); size_t idx = 0; - for(std::set<SPoint3>::iterator uIter = unique.begin(); uIter != unique.end(); - ++uIter) { + for(auto uIter = unique.begin(); uIter != unique.end(); ++uIter) { const SPoint3 &pp = *uIter; for(int d = 0; d < 3; d++) { data(d, idx) = pp[d]; @@ -277,8 +276,7 @@ SOrientedBoundingBox::buildOBB(std::vector<SPoint3> &vertices) SPoint2 *p = new SPoint2(projected(smallest_comp == 0 ? 1 : 0, i), projected(smallest_comp == 2 ? 1 : 2, i)); bool keep = true; - for(std::vector<SPoint2 *>::iterator point = points.begin(); - point != points.end(); point++) { + for(auto point = points.begin(); point != points.end(); point++) { if(std::abs((*p)[0] - (**point)[0]) < 10e-10 && std::abs((*p)[1] - (**point)[1]) < 10e-10) { keep = false; @@ -323,8 +321,7 @@ SOrientedBoundingBox::buildOBB(std::vector<SPoint3> &vertices) for(int j = 0; j < 3; j++) { bool okay = true; - for(std::vector<Segment>::iterator seg = convex_hull.begin(); - seg != convex_hull.end(); seg++) { + for(auto seg = convex_hull.begin(); seg != convex_hull.end(); seg++) { if(((*seg).from == segs[j].from && (*seg).from == segs[j].to) // FIXME: // || ((*seg).from == segs[j].to && (*seg).from == segs[j].from) @@ -356,8 +353,7 @@ SOrientedBoundingBox::buildOBB(std::vector<SPoint3> &vertices) fullVector<double> segment(2); fullMatrix<double> rotation(2, 2); - for(std::vector<Segment>::iterator seg = convex_hull.begin(); - seg != convex_hull.end(); seg++) { + for(auto seg = convex_hull.begin(); seg != convex_hull.end(); seg++) { // segment(0) = record.points[(*seg).from].where.h - // record.points[(*seg).to].where.h; segment(1) = // record.points[(*seg).from].where.v - record.points[(*seg).to].where.v; diff --git a/Geo/STensor3.cpp b/Geo/STensor3.cpp index ab279d353ca4d8e794245e64ae1a985c83c16217..4c68d578497e6c0512ee4a14d6ab401546066ea2 100644 --- a/Geo/STensor3.cpp +++ b/Geo/STensor3.cpp @@ -51,9 +51,7 @@ SMetric3::SMetric3(const double l1, // l1 = h1^-2 void SMetric3::getMat(fullMatrix<double> &mat) const { for(int i = 0; i < 3; i++) { - for(int j = 0; j < 3; j++) { - mat(i, j) = _val[getIndex(i, j)]; - } + for(int j = 0; j < 3; j++) { mat(i, j) = _val[getIndex(i, j)]; } } } @@ -103,8 +101,7 @@ SMetric3 SMetric3::transform(fullMatrix<double> &V) return a; } -void SMetric3::eig(fullMatrix<double> &V, fullVector<double> &S, - bool s) const +void SMetric3::eig(fullMatrix<double> &V, fullVector<double> &S, bool s) const { fullMatrix<double> me(3, 3), right(3, 3); fullVector<double> im(3); @@ -309,9 +306,7 @@ SMetric3 interpolation(const SMetric3 &m1, const SMetric3 &m2, void STensor3::getMat(fullMatrix<double> &mat) const { for(int i = 0; i < 3; i++) { - for(int j = 0; j < 3; j++) { - mat(i, j) = _val[getIndex(i, j)]; - } + for(int j = 0; j < 3; j++) { mat(i, j) = _val[getIndex(i, j)]; } } } @@ -321,8 +316,7 @@ void STensor3::setMat(const fullMatrix<double> &mat) for(int j = 0; j < 3; j++) _val[getIndex(i, j)] = mat(i, j); } -void STensor3::eig(fullMatrix<double> &V, fullVector<double> &S, - bool s) const +void STensor3::eig(fullMatrix<double> &V, fullVector<double> &S, bool s) const { fullMatrix<double> me(3, 3), left(3, 3); fullVector<double> im(3); diff --git a/Geo/SVector3.h b/Geo/SVector3.h index 2907988036629a74be1711739c01e3b4eccddaa4..a76c29a8bdd9c74114d9101e8a1450db7aa179ec 100644 --- a/Geo/SVector3.h +++ b/Geo/SVector3.h @@ -130,9 +130,7 @@ public: double *data() { return P.data(); } void axpy(const double a, const SVector3 &y) { - for(int i = 0; i < 3; i++) { - P[i] += (a * y[i]); - } + for(int i = 0; i < 3; i++) { P[i] += (a * y[i]); } } }; diff --git a/Geo/affineTransformation.cpp b/Geo/affineTransformation.cpp index 3a2f4a04886afccbdcd1d229405c99698977c76d..17261ad278e1cb474e3c92d5c2ebdc456a3f85b2 100644 --- a/Geo/affineTransformation.cpp +++ b/Geo/affineTransformation.cpp @@ -10,7 +10,6 @@ #include "fullMatrix.h" - template <class FLOAT> bool computeAffineTransformation(const FLOAT *rc, const FLOAT *ra, const FLOAT *tr, std::vector<double> &tfo) @@ -72,19 +71,18 @@ template bool computeAffineTransformation(const double *rc, const double *ra, const double *tr, std::vector<double> &tfo); - -template<class FLOAT> +template <class FLOAT> bool getAffineTransformationParameters(const std::vector<double> &tfo, FLOAT *rc, FLOAT *ra, FLOAT *tr) { // rotation angles - ra[0] = std::atan2(-tfo[2*4+1], tfo[2*4+2]); - ra[1] = std::asin(tfo[2*4+0]); - ra[2] = std::atan2(-tfo[1*4+0], tfo[0*4+0]); - + ra[0] = std::atan2(-tfo[2 * 4 + 1], tfo[2 * 4 + 2]); + ra[1] = std::asin(tfo[2 * 4 + 0]); + ra[2] = std::atan2(-tfo[1 * 4 + 0], tfo[0 * 4 + 0]); + // translation for(int i = 0; i < 3; i++) rc[i] = 0.; - for(int i = 0; i < 3; i++) tr[i] = tfo[4*i+3]; + for(int i = 0; i < 3; i++) tr[i] = tfo[4 * i + 3]; return true; } @@ -97,7 +95,6 @@ template bool getAffineTransformationParameters(const std::vector<double> &tfo, double *rc, double *ra, double *tr); - bool invertAffineTransformation(const std::vector<double> &tfo, std::vector<double> &newTfo) { @@ -111,7 +108,6 @@ bool invertAffineTransformation(const std::vector<double> &tfo, return true; } - bool setUnitAffineTransformation(std::vector<double> &tfo) { tfo.resize(16, 0); diff --git a/Geo/affineTransformation.h b/Geo/affineTransformation.h index dadc3c46591baa5ca60efad48bbd39e1bbd3fe69..1adcc5552fd0aab8bda33adb280994d5593bd3d2 100644 --- a/Geo/affineTransformation.h +++ b/Geo/affineTransformation.h @@ -10,10 +10,10 @@ // compute (extended) affine transformation matrix from rotation/translation: // x' = t + (I-R)*x_c + R*x -// where t is the translation vector, I is the identity matrix, and R is the +// where t is the translation vector, I is the identity matrix, and R is the // matrix for an active intrinsic yaw-pitch-roll rotation (i.e. intrinsic // z-y'-x'' rotation or extrinsinc x-y-z rotation) with counter-clockwise angles -template<class FLOAT> +template <class FLOAT> bool computeAffineTransformation(const FLOAT *rc, // rotation center const FLOAT *ra, // rotation angle const FLOAT *tr, // translation @@ -21,13 +21,13 @@ bool computeAffineTransformation(const FLOAT *rc, // rotation center // compute rotation/translation from (extended) affine transformation matrix: // x' = t + (I-R)*x_c + R*x -// where t is the translation vector, I is the identity matrix, and R is the +// where t is the translation vector, I is the identity matrix, and R is the // matrix for an active intrinsic yaw-pitch-roll rotation (i.e. intrinsic // z-y'-x'' rotation or extrinsinc x-y-z rotation) with counter-clockwise angles -template<class FLOAT> +template <class FLOAT> bool getAffineTransformationParameters(const std::vector<double> &tfo, // trnsf. - FLOAT *rc, // rotation center - FLOAT *ra, // rotation angle + FLOAT *rc, // rotation center + FLOAT *ra, // rotation angle FLOAT *tr); // translation // invert affine transformation diff --git a/Geo/boundaryLayersData.cpp b/Geo/boundaryLayersData.cpp index 3674d4cecd636a11d970a5ac9e10f7bfae344462..f19b807325640c1e36bf8abe0dc980730068251a 100644 --- a/Geo/boundaryLayersData.cpp +++ b/Geo/boundaryLayersData.cpp @@ -159,12 +159,10 @@ static void treat2Connections(GFace *gf, MVertex *_myVert, MEdge &e1, MEdge &e2, int fanSize) { std::vector<SVector3> N1, N2; - for(std::multimap<MEdge, SVector3, MEdgeLessThan>::iterator itm = - _columns->_normals.lower_bound(e1); + for(auto itm = _columns->_normals.lower_bound(e1); itm != _columns->_normals.upper_bound(e1); ++itm) N1.push_back(itm->second); - for(std::multimap<MEdge, SVector3, MEdgeLessThan>::iterator itm = - _columns->_normals.lower_bound(e2); + for(auto itm = _columns->_normals.lower_bound(e2); itm != _columns->_normals.upper_bound(e2); ++itm) N2.push_back(itm->second); if(N1.size() == N2.size()) { @@ -233,16 +231,13 @@ static void treat3Connections(GFace *gf, MVertex *_myVert, MEdge &e1, MEdge &e2, std::vector<SVector3> &_dirs) { std::vector<SVector3> N1, N2, N3; - for(std::multimap<MEdge, SVector3, MEdgeLessThan>::iterator itm = - _columns->_normals.lower_bound(e1); + for(auto itm = _columns->_normals.lower_bound(e1); itm != _columns->_normals.upper_bound(e1); ++itm) N1.push_back(itm->second); - for(std::multimap<MEdge, SVector3, MEdgeLessThan>::iterator itm = - _columns->_normals.lower_bound(e2); + for(auto itm = _columns->_normals.lower_bound(e2); itm != _columns->_normals.upper_bound(e2); ++itm) N2.push_back(itm->second); - for(std::multimap<MEdge, SVector3, MEdgeLessThan>::iterator itm = - _columns->_normals.lower_bound(e3); + for(auto itm = _columns->_normals.lower_bound(e3); itm != _columns->_normals.upper_bound(e3); ++itm) N3.push_back(itm->second); @@ -308,7 +303,7 @@ static void getEdgesData(GFace *gf, BoundaryLayerField *blf, edges.insert(edges.begin(), embedded_edges.begin(), embedded_edges.end()); // iterate on model edges - std::vector<GEdge *>::iterator ite = edges.begin(); + auto ite = edges.begin(); while(ite != edges.end()) { // check if this edge generates a boundary layer if(isEdgeOfFaceBL(gf, *ite, blf)) { @@ -446,8 +441,7 @@ bool buildAdditionalPoints2D(GFace *gf) getNormals(gf, blf, _columns, allEdges); // for all boundry points - for(std::set<MVertex *>::iterator it = _vertices.begin(); - it != _vertices.end(); ++it) { + for(auto it = _vertices.begin(); it != _vertices.end(); ++it) { bool endOfTheBL = false; SVector3 dirEndOfBL; std::vector<MVertex *> columnEndOfBL; @@ -461,8 +455,7 @@ bool buildAdditionalPoints2D(GFace *gf) (*it)->onWhat()->dim() == 0 && blf->isFanNode((*it)->onWhat()->tag()); int fanSize = fan ? blf->fanSize((*it)->onWhat()->tag()) : 0; - for(std::multimap<MVertex *, MVertex *>::iterator itm = - _columns->_non_manifold_edges.lower_bound(*it); + for(auto itm = _columns->_non_manifold_edges.lower_bound(*it); itm != _columns->_non_manifold_edges.upper_bound(*it); ++itm) _connections.push_back(itm->second); @@ -495,8 +488,7 @@ bool buildAdditionalPoints2D(GFace *gf) if(N1.size() == 1) { std::vector<MVertex *> Ts; - for(std::multimap<MVertex *, MVertex *>::iterator itm = - tangents.lower_bound(*it); + for(auto itm = tangents.lower_bound(*it); itm != tangents.upper_bound(*it); ++itm) Ts.push_back(itm->second); // end of the BL --> let's add a column that correspond to the @@ -577,15 +569,15 @@ bool buildAdditionalPoints2D(GFace *gf) std::vector<double> t(blf->nb_divisions); double zlog = log((1 + blf->beta) / (blf->beta - 1)); - printf("T = "); + printf("T = "); for(int i = 0; i < blf->nb_divisions; i++) { const double eta = (double)(i + 1) / blf->nb_divisions; const double power = exp(zlog * (1. - eta)); const double ratio = (1. - power) / (1. + power); t[i] = 1.0 + blf->beta * ratio; - printf("%12.5E ",t[i]); + printf("%12.5E ", t[i]); } - printf("\n"); + printf("\n"); for(int i = 0; i < blf->nb_divisions; i++) { double L = hWall * t[i] / t[0]; SPoint2 pnew(par.x() + L * n.x(), par.y() + L * n.y()); @@ -615,7 +607,7 @@ bool buildAdditionalPoints2D(GFace *gf) _current->bl_data = new MVertexBoundaryLayerData; _column.push_back(_current); int ith = _column.size(); - // ADD BETA LAW HERE !!! + // ADD BETA LAW HERE !!! L += hWall * pow(blf->ratio, ith); } _columns->addColumn(n, *it, _column /*,_metrics*/); diff --git a/Geo/boundaryLayersData.h b/Geo/boundaryLayersData.h index d58020b23e162d1653f9a80958070dd2844a7796..25458dad460786b625b59a64c1b347f4fea8e85c 100644 --- a/Geo/boundaryLayersData.h +++ b/Geo/boundaryLayersData.h @@ -95,9 +95,7 @@ public: inline const BoundaryLayerFan *getFan(MVertex *v) const { std::map<MVertex *, BoundaryLayerFan>::const_iterator it = _fans.find(v); - if(it != _fans.end()) { - return &it->second; - } + if(it != _fans.end()) { return &it->second; } return 0; } inline const BoundaryLayerData &getColumn(MVertex *v, MEdge e) const diff --git a/Geo/closestVertex.cpp b/Geo/closestVertex.cpp index 2eee2c9044017f4190f55dbcd7a319f1d326226d..438257ec681c969122db4c88af43a5ddc5e29619 100644 --- a/Geo/closestVertex.cpp +++ b/Geo/closestVertex.cpp @@ -23,7 +23,7 @@ closestVertexFinder::closestVertexFinder(GEntity *ge, bool closure) : nbVtcs(0) vCoord = annAllocPts(nbVtcs, 3); int k = 0; - std::set<MVertex *>::iterator vIter = vtcs.begin(); + auto vIter = vtcs.begin(); for(; vIter != vtcs.end(); ++vIter, ++k) { MVertex *mv = *vIter; vCoord[k][0] = mv->x(); @@ -33,7 +33,8 @@ closestVertexFinder::closestVertexFinder(GEntity *ge, bool closure) : nbVtcs(0) } kdtree = new ANNkd_tree(vCoord, nbVtcs, 3); #else - Msg::Warning("Gmsh must be compiled with ANN support for finding closest nodes"); + Msg::Warning( + "Gmsh must be compiled with ANN support for finding closest nodes"); #endif } diff --git a/Geo/discreteEdge.cpp b/Geo/discreteEdge.cpp index 5e1672527b9654cdb115fa1a44390a006d5e583b..32a0548bad05cee838bc6158731b35361f703b4f 100644 --- a/Geo/discreteEdge.cpp +++ b/Geo/discreteEdge.cpp @@ -41,7 +41,7 @@ discreteEdge::discreteEdge(GModel *model) : GEdge(model, 0) } bool discreteEdge::_getLocalParameter(const double &t, int &iLine, - double &tLoc) const + double &tLoc) const { for(iLine = 0; iLine < (int)_discretization.size() - 1; iLine++) { double tmin = _pars[iLine]; @@ -156,13 +156,13 @@ int discreteEdge::createGeometry() bool sorted = true; - std::vector<MVertex*> vertices; + std::vector<MVertex *> vertices; vertices.push_back(lines[0]->getVertex(0)); for(std::size_t i = 0; i < lines.size(); i++) { - if(lines[i]->getVertex(0) == vertices.back()){ + if(lines[i]->getVertex(0) == vertices.back()) { vertices.push_back(lines[i]->getVertex(1)); } - else{ + else { sorted = false; break; } @@ -172,15 +172,12 @@ int discreteEdge::createGeometry() Msg::Debug("Sorting nodes in discrete curve %d", tag()); std::vector<MEdge> allEdges; for(std::size_t i = 0; i < lines.size(); i++) { - allEdges.push_back(MEdge(lines[i]->getVertex(0), - lines[i]->getVertex(1))); + allEdges.push_back(MEdge(lines[i]->getVertex(0), lines[i]->getVertex(1))); } std::vector<std::vector<MVertex *> > vs; SortEdgeConsecutive(allEdges, vs); - if(vs.size() == 1) { - vertices = vs[0]; - } - else{ + if(vs.size() == 1) { vertices = vs[0]; } + else { Msg::Error("Discrete curve %d has wrong topology", tag()); return 1; } @@ -189,16 +186,12 @@ int discreteEdge::createGeometry() GVertex *g0 = dynamic_cast<GVertex *>(vertices.front()->onWhat()); GVertex *g1 = dynamic_cast<GVertex *>(vertices.back()->onWhat()); - if(g0) { - setBeginVertex(g0); - } + if(g0) { setBeginVertex(g0); } else if(g1 && g1->xyz().distance(vertices.front()->point()) < 1e-14) { setBeginVertex(g1); } - if(g1) { - setEndVertex(g1); - } + if(g1) { setEndVertex(g1); } else if(g0 && g0->xyz().distance(vertices.back()->point()) < 1e-14) { setEndVertex(g0); } @@ -209,8 +202,8 @@ int discreteEdge::createGeometry() } for(std::size_t i = 0; i < vertices.size(); i++) { - _discretization.push_back - (SPoint3(vertices[i]->x(), vertices[i]->y(), vertices[i]->z())); + _discretization.push_back( + SPoint3(vertices[i]->x(), vertices[i]->y(), vertices[i]->z())); _pars.push_back((double)i); } @@ -229,14 +222,14 @@ void discreteEdge::mesh(bool verbose) bool discreteEdge::writeParametrization(FILE *fp, bool binary) { std::size_t N = _discretization.size(); - if(N != _pars.size()){ + if(N != _pars.size()) { Msg::Error("Wrong number of parameters in STL mesh of curve %d", tag()); return false; } - if(binary){ + if(binary) { fwrite(&N, sizeof(std::size_t), 1, fp); std::vector<double> d(4 * N); - for(std::size_t i = 0; i < N; i++){ + for(std::size_t i = 0; i < N; i++) { d[4 * i + 0] = _discretization[i].x(); d[4 * i + 1] = _discretization[i].y(); d[4 * i + 2] = _discretization[i].z(); @@ -244,7 +237,7 @@ bool discreteEdge::writeParametrization(FILE *fp, bool binary) } fwrite(&d[0], sizeof(double), 4 * N, fp); } - else{ + else { fprintf(fp, "%lu\n", N); for(std::size_t i = 0; i < N; i++) { fprintf(fp, "%.16g %.16g %.16g %.16g\n", _discretization[i].x(), @@ -257,23 +250,25 @@ bool discreteEdge::writeParametrization(FILE *fp, bool binary) bool discreteEdge::readParametrization(FILE *fp, bool binary) { std::size_t N; - if(binary){ + if(binary) { if(fread(&N, sizeof(std::size_t), 1, fp) != 1) { return false; } } - else{ - if(fscanf(fp, "%lu", &N) != 1){ return false; } + else { + if(fscanf(fp, "%lu", &N) != 1) { return false; } } _pars.resize(N); _discretization.resize(N); std::vector<double> d(4 * N); - if(binary){ - if(fread(&d[0], sizeof(double), 4 * N, fp) != 4 * N){ return false; } + if(binary) { + if(fread(&d[0], sizeof(double), 4 * N, fp) != 4 * N) { return false; } } - else{ + else { for(std::size_t i = 0; i < N; i++) { if(fscanf(fp, "%lf %lf %lf %lf\n", &d[4 * i + 0], &d[4 * i + 1], - &d[4 * i + 2], &d[4 * i + 3]) != 4) { return false; } + &d[4 * i + 2], &d[4 * i + 3]) != 4) { + return false; + } } } diff --git a/Geo/discreteEdge.h b/Geo/discreteEdge.h index c69bef60400b7833a4d41034fae8d0bbc6607d5e..bf1b1035ac07a4b223354958fbeee9b55d8c509d 100644 --- a/Geo/discreteEdge.h +++ b/Geo/discreteEdge.h @@ -14,6 +14,7 @@ private: std::vector<double> _pars; std::vector<SPoint3> _discretization; bool _getLocalParameter(const double &t, int &iEdge, double &tLoc) const; + public: discreteEdge(GModel *model, int num, GVertex *_v0, GVertex *_v1); discreteEdge(GModel *model, int num); diff --git a/Geo/discreteFace.cpp b/Geo/discreteFace.cpp index e47f862095a17baebdd0d3d066f169af246e14ec..3e60dacf37eda09a934524a7dced09c2300780cb 100644 --- a/Geo/discreteFace.cpp +++ b/Geo/discreteFace.cpp @@ -270,8 +270,7 @@ Range<double> discreteFace::parBounds(int i) const bool discreteFace::containsParam(const SPoint2 &pt) { if(_param.empty()) return false; - if(_param.oct->find(pt.x(), pt.y(), 0.0, -1, true)) - return true; + if(_param.oct->find(pt.x(), pt.y(), 0.0, -1, true)) return true; return false; } @@ -419,8 +418,8 @@ void discreteFace::_debugParametrization(bool uv) } fprintf(fp, "ST(%g,%g,%g, %g,%g,%g, %g,%g,%g){%g,%g,%g, %g,%g,%g};\n", xyz0.x(), xyz0.y(), xyz0.z(), xyz1.x(), xyz1.y(), xyz1.z(), - xyz2.x(), xyz2.y(), xyz2.z(), uv0.x(), uv1.x(), uv2.x(), - uv0.y(), uv1.y(), uv2.y()); + xyz2.x(), xyz2.y(), xyz2.z(), uv0.x(), uv1.x(), uv2.x(), uv0.y(), + uv1.y(), uv2.y()); } fprintf(fp, "};\n"); fclose(fp); @@ -436,21 +435,20 @@ int discreteFace::createGeometry() if(triangles.empty()) return 0; double minq = 1.; - for(auto t : triangles) - minq = std::min(minq, t->gammaShapeMeasure()); + for(auto t : triangles) minq = std::min(minq, t->gammaShapeMeasure()); if(minq < 1e-3) Msg::Warning("Poor input mesh quality (min gamma = %g) for computing " - "parametrization", minq); + "parametrization", + minq); std::vector<MVertex *> nodes; - computeParametrization(triangles, nodes, - stl_vertices_uv, stl_vertices_xyz, stl_triangles); + computeParametrization(triangles, nodes, stl_vertices_uv, stl_vertices_xyz, + stl_triangles); if(model()->getCurvatures().size()) { stl_curvatures.resize(2 * nodes.size()); for(std::size_t i = 0; i < nodes.size(); i++) { - std::map<MVertex *, std::pair<SVector3, SVector3> >::iterator it = - model()->getCurvatures().find(nodes[i]); + auto it = model()->getCurvatures().find(nodes[i]); if(it == model()->getCurvatures().end()) { Msg::Error("Curvature not found for node %d", nodes[i]->getNum()); } @@ -502,9 +500,8 @@ void discreteFace::_createGeometryFromSTL() _param.clear(); for(size_t i = 0; i < stl_vertices_uv.size(); i++) { - _param.v2d.push_back(MVertex(stl_vertices_uv[i].x(), - stl_vertices_uv[i].y(), - 0.0)); + _param.v2d.push_back( + MVertex(stl_vertices_uv[i].x(), stl_vertices_uv[i].y(), 0.0)); _param.v3d.push_back(MVertex(stl_vertices_xyz[i].x(), stl_vertices_xyz[i].y(), stl_vertices_xyz[i].z())); diff --git a/Geo/discreteFace.h b/Geo/discreteFace.h index 2e7abe7bd4071e8c86142778518354497a339220..00fd8d0b4dce0dfac2b14fadb34089607238a68a 100644 --- a/Geo/discreteFace.h +++ b/Geo/discreteFace.h @@ -36,6 +36,7 @@ private: void _createGeometryFromSTL(); void _computeSTLNormals(); void _debugParametrization(bool uv); + public: discreteFace(GModel *model, int num); discreteFace(GModel *model); diff --git a/Geo/discreteRegion.h b/Geo/discreteRegion.h index c98c85e67a07fbee3e9a3ff08c02405463ace36b..3c1626beb2748afc08d30f917c43219d19566cba 100644 --- a/Geo/discreteRegion.h +++ b/Geo/discreteRegion.h @@ -13,6 +13,7 @@ class discreteRegion : public GRegion { private: bool _geometry; + public: discreteRegion(GModel *model, int num); discreteRegion(GModel *model); diff --git a/Geo/discreteVertex.cpp b/Geo/discreteVertex.cpp index 3e41f709f281b4202945dd7510f7e9b471e699d8..1dba2365e5f589e11c1d668adaef8da3b03a57a0 100644 --- a/Geo/discreteVertex.cpp +++ b/Geo/discreteVertex.cpp @@ -24,14 +24,9 @@ discreteVertex::discreteVertex(GModel *m) : GVertex(m, 0) // of the corresponding entity in GEO internals } -discreteVertex::~discreteVertex() -{ -} +discreteVertex::~discreteVertex() {} -GPoint discreteVertex::point() const -{ - return GPoint(x(), y(), z(), this); -} +GPoint discreteVertex::point() const { return GPoint(x(), y(), z(), this); } void discreteVertex::setPosition(GPoint &p) { diff --git a/Geo/discreteVertex.h b/Geo/discreteVertex.h index 3ff868d8dab95a8c95d124dab933e57f95144a33..e7ccee6b751923deec2b6d84c08e872081ec2996 100644 --- a/Geo/discreteVertex.h +++ b/Geo/discreteVertex.h @@ -15,6 +15,7 @@ class Vertex; class discreteVertex : public GVertex { private: Vertex *_v; + public: discreteVertex(GModel *m, int num, double x = 0., double y = 0., double z = 0.); diff --git a/Geo/findLinks.cpp b/Geo/findLinks.cpp index c8fbb3336a03cf8777665dbd139f30f2f7d7f6dc..1dacc52b2cf0968b1c7ceab51aa5cf3348557801 100644 --- a/Geo/findLinks.cpp +++ b/Geo/findLinks.cpp @@ -44,9 +44,7 @@ static void recurFindLinkedEdges(int ed, List_T *edges, Tree_T *points, Msg::Error("Unknown curve %d", ed); return; } - if(!ge->getBeginVertex() || !ge->getEndVertex()){ - return; - } + if(!ge->getBeginVertex() || !ge->getEndVertex()) { return; } int ip[2]; ip[0] = ge->getBeginVertex()->tag(); @@ -78,7 +76,7 @@ static void recurFindLinkedEdges(int ed, List_T *edges, Tree_T *points, static int createEdgeLinks(Tree_T *links) { GModel *m = GModel::current(); - for(GModel::eiter it = m->firstEdge(); it != m->lastEdge(); it++) { + for(auto it = m->firstEdge(); it != m->lastEdge(); it++) { GEdge *ge = *it; if(!ge->getBeginVertex() || !ge->getEndVertex()) { Msg::Error("Cannot link curve %d with no begin or end point", ge->tag()); @@ -93,9 +91,7 @@ static int createEdgeLinks(Tree_T *links) for(int k = 0; k < 2; k++) { lnk li, *pli; li.n = ip[k]; - if((pli = (lnk *)Tree_PQuery(links, &li))) { - List_Add(pli->l, &na); - } + if((pli = (lnk *)Tree_PQuery(links, &li))) { List_Add(pli->l, &na); } else { li.l = List_Create(20, 1, sizeof(nxa)); List_Add(li.l, &na); @@ -236,8 +232,7 @@ static void recurFindLinkedFaces(int fac, List_T *faces, Tree_T *edges, } std::vector<GEdge *> const &l = gf->edges(); - for(std::vector<GEdge *>::const_iterator it = l.begin(); it != l.end(); - it++) { + for(auto it = l.begin(); it != l.end(); it++) { GEdge *ge = *it; if(ge->degenerate(0)) continue; lnk lk; @@ -265,21 +260,18 @@ static void recurFindLinkedFaces(int fac, List_T *faces, Tree_T *edges, static void createFaceLinks(Tree_T *links) { GModel *m = GModel::current(); - for(GModel::fiter it = m->firstFace(); it != m->lastFace(); it++) { + for(auto it = m->firstFace(); it != m->lastFace(); it++) { GFace *gf = *it; if(gf->tag() > 0) { nxa na; na.a = gf->tag(); std::vector<GEdge *> const &l = gf->edges(); - for(std::vector<GEdge *>::const_iterator ite = l.begin(); ite != l.end(); - ite++) { + for(auto ite = l.begin(); ite != l.end(); ite++) { GEdge *ge = *ite; if(ge->degenerate(0)) continue; lnk li, *pli; li.n = std::abs(ge->tag()); - if((pli = (lnk *)Tree_PQuery(links, &li))) { - List_Add(pli->l, &na); - } + if((pli = (lnk *)Tree_PQuery(links, &li))) { List_Add(pli->l, &na); } else { li.l = List_Create(20, 1, sizeof(nxa)); List_Add(li.l, &na); @@ -309,8 +301,7 @@ int allFacesLinked(int fac, List_T *faces) return 0; } std::vector<GEdge *> const &l = gf->edges(); - for(std::vector<GEdge *>::const_iterator it = l.begin(); it != l.end(); - it++) { + for(auto it = l.begin(); it != l.end(); it++) { GEdge *ge = *it; if(ge->degenerate(0)) continue; int ic = std::abs(ge->tag()); diff --git a/Geo/ghostEdge.h b/Geo/ghostEdge.h index 053677da49f63c78c4c2424b174c6c2dd89e4e09..031e7771c0fe4733250988aaba4eabe25f38731c 100644 --- a/Geo/ghostEdge.h +++ b/Geo/ghostEdge.h @@ -33,32 +33,24 @@ public: } } virtual GeomType geomType() const { return GhostCurve; } - virtual void setPartition(const int partition) - { - _partition = partition; - } + virtual void setPartition(const int partition) { _partition = partition; } virtual int getPartition() const { return _partition; } bool saveMesh() const { return _saveMesh; } void saveMesh(bool saveMesh) { _saveMesh = saveMesh; } bool haveMesh() const { return _haveMesh; } void haveMesh(bool haveMesh) { _haveMesh = haveMesh; } - virtual std::map<MElement *, int> &getGhostCells() - { - return _ghostCells; - } + virtual std::map<MElement *, int> &getGhostCells() { return _ghostCells; } void addLine(MLine *l, int onWhichPartition) { GEdge::addLine(l); - _ghostCells.insert( - std::pair<MElement *, int>(l, onWhichPartition)); + _ghostCells.insert(std::pair<MElement *, int>(l, onWhichPartition)); model()->addGhostCells(l, _partition); } void addElement(int type, MElement *e, int onWhichPartition) { GEdge::addElement(type, e); - _ghostCells.insert( - std::pair<MElement *, int>(e, onWhichPartition)); + _ghostCells.insert(std::pair<MElement *, int>(e, onWhichPartition)); model()->addGhostCells(e, _partition); } diff --git a/Geo/ghostFace.h b/Geo/ghostFace.h index e4192bf2939888c60f5d4fc86902a2bc28c1ddb1..0c8eadf20f3e8f07bd05f437d30620909beb4ccc 100644 --- a/Geo/ghostFace.h +++ b/Geo/ghostFace.h @@ -37,46 +37,36 @@ public: } } virtual GeomType geomType() const { return GhostSurface; } - virtual void setPartition(const int partition) - { - _partition = partition; - } + virtual void setPartition(const int partition) { _partition = partition; } virtual int getPartition() const { return _partition; } bool saveMesh() const { return _saveMesh; } void saveMesh(bool saveMesh) { _saveMesh = saveMesh; } bool haveMesh() const { return _haveMesh; } void haveMesh(bool haveMesh) { _haveMesh = haveMesh; } - virtual std::map<MElement *, int> &getGhostCells() - { - return _ghostCells; - } + virtual std::map<MElement *, int> &getGhostCells() { return _ghostCells; } virtual void addTriangle(MTriangle *t, int onWhichPartition) { GFace::addTriangle(t); - _ghostCells.insert( - std::pair<MElement *, int>(t, onWhichPartition)); + _ghostCells.insert(std::pair<MElement *, int>(t, onWhichPartition)); model()->addGhostCells(t, _partition); } virtual void addQuadrangle(MQuadrangle *q, int onWhichPartition) { GFace::addQuadrangle(q); - _ghostCells.insert( - std::pair<MElement *, int>(q, onWhichPartition)); + _ghostCells.insert(std::pair<MElement *, int>(q, onWhichPartition)); model()->addGhostCells(q, _partition); } virtual void addPolygon(MPolygon *p, int onWhichPartition) { GFace::addPolygon(p); - _ghostCells.insert( - std::pair<MElement *, int>(p, onWhichPartition)); + _ghostCells.insert(std::pair<MElement *, int>(p, onWhichPartition)); model()->addGhostCells(p, _partition); } virtual void addElement(int type, MElement *e, int onWhichPartition) { GFace::addElement(type, e); - _ghostCells.insert( - std::pair<MElement *, int>(e, onWhichPartition)); + _ghostCells.insert(std::pair<MElement *, int>(e, onWhichPartition)); model()->addGhostCells(e, _partition); } diff --git a/Geo/ghostRegion.h b/Geo/ghostRegion.h index b5ef0461e2c38c21599f7135deb545907a503d68..8e2062ca0270a04a975a8d19fe13686a6bb29174 100644 --- a/Geo/ghostRegion.h +++ b/Geo/ghostRegion.h @@ -41,67 +41,54 @@ public: } } virtual GeomType geomType() const { return GhostVolume; } - virtual void setPartition(const int partition) - { - _partition = partition; - } + virtual void setPartition(const int partition) { _partition = partition; } virtual int getPartition() const { return _partition; } bool saveMesh() const { return _saveMesh; } void saveMesh(bool saveMesh) { _saveMesh = saveMesh; } bool haveMesh() const { return _haveMesh; } void haveMesh(bool haveMesh) { _haveMesh = haveMesh; } - virtual std::map<MElement *, int> &getGhostCells() - { - return _ghostCells; - } + virtual std::map<MElement *, int> &getGhostCells() { return _ghostCells; } void addTetrahedron(MTetrahedron *t, int onWhichPartition) { GRegion::addTetrahedron(t); - _ghostCells.insert( - std::pair<MElement *, int>(t, onWhichPartition)); + _ghostCells.insert(std::pair<MElement *, int>(t, onWhichPartition)); model()->addGhostCells(t, _partition); } void addHexahedron(MHexahedron *h, int onWhichPartition) { GRegion::addHexahedron(h); - _ghostCells.insert( - std::pair<MElement *, int>(h, onWhichPartition)); + _ghostCells.insert(std::pair<MElement *, int>(h, onWhichPartition)); model()->addGhostCells(h, _partition); } void addPrism(MPrism *p, int onWhichPartition) { GRegion::addPrism(p); - _ghostCells.insert( - std::pair<MElement *, int>(p, onWhichPartition)); + _ghostCells.insert(std::pair<MElement *, int>(p, onWhichPartition)); model()->addGhostCells(p, _partition); } void addPyramid(MPyramid *p, int onWhichPartition) { GRegion::addPyramid(p); - _ghostCells.insert( - std::pair<MElement *, int>(p, onWhichPartition)); + _ghostCells.insert(std::pair<MElement *, int>(p, onWhichPartition)); model()->addGhostCells(p, _partition); } void addPolyhedron(MPolyhedron *p, int onWhichPartition) { GRegion::addPolyhedron(p); - _ghostCells.insert( - std::pair<MElement *, int>(p, onWhichPartition)); + _ghostCells.insert(std::pair<MElement *, int>(p, onWhichPartition)); model()->addGhostCells(p, _partition); } void addTrihedron(MTrihedron *t, int onWhichPartition) { GRegion::addTrihedron(t); - _ghostCells.insert( - std::pair<MElement *, int>(t, onWhichPartition)); + _ghostCells.insert(std::pair<MElement *, int>(t, onWhichPartition)); model()->addGhostCells(t, _partition); } void addElement(int type, MElement *e, int onWhichPartition) { GRegion::addElement(type, e); - _ghostCells.insert( - std::pair<MElement *, int>(e, onWhichPartition)); + _ghostCells.insert(std::pair<MElement *, int>(e, onWhichPartition)); model()->addGhostCells(e, _partition); } diff --git a/Geo/gmshEdgeDiscretize.cpp b/Geo/gmshEdgeDiscretize.cpp index 43abd93d83c1f49521294173dae16bcfbb512a7f..63f4a504e70d9e61beac12f9736761903f445cc3 100644 --- a/Geo/gmshEdgeDiscretize.cpp +++ b/Geo/gmshEdgeDiscretize.cpp @@ -50,9 +50,7 @@ static void decasteljau(double tol, discreteList &discrete, int pos, double d = std::max(dot(d130, d130), dot(d230, d230)); double l2 = dot(d30, d30); - if(d < tol * tol * l2) { - return; - } + if(d < tol * tol * l2) { return; } SPoint3 p01((p0 + p1) * 0.5); SPoint3 p12((p1 + p2) * 0.5); @@ -126,9 +124,7 @@ static void discretizeCurve(Curve *c, double tol, std::vector<SPoint3> &pts, double t1 = (iCurve) / (double)(NbCurves); double t2 = (iCurve + 1) / (double)(NbCurves); SPoint3 pt[4]; - for(int i = 0; i < 4; i++) { - pt[i] = curveGetPoint(c, iCurve * 3 + i); - } + for(int i = 0; i < 4; i++) { pt[i] = curveGetPoint(c, iCurve * 3 + i); } back = discretizeBezier(tol, discrete, back, pt, t1, t2, iCurve == 0); } break; diff --git a/Geo/gmshFace.cpp b/Geo/gmshFace.cpp index f5515d283500184dae32d5f595121831a62ac9bd..3243965e3d12850e7d143cf31557cb552a61a193 100644 --- a/Geo/gmshFace.cpp +++ b/Geo/gmshFace.cpp @@ -32,14 +32,11 @@ bool gmshFace::degenerate(int dim) const std::vector<GEdge *> const &eds = edges(); int numNonDegenerate = 0; std::set<GEdge *> t; - for(std::vector<GEdge *>::const_iterator it = eds.begin(); it != eds.end(); - ++it) { + for(auto it = eds.begin(); it != eds.end(); ++it) { GEdge *e = *it; GVertex *start = e->getBeginVertex(); GVertex *next = e->getEndVertex(); - if(start != next && t.find(e) == t.end()) { - numNonDegenerate++; - } + if(start != next && t.find(e) == t.end()) { numNonDegenerate++; } t.insert(e); } // printf("%d \n",numNonDegenerate); @@ -169,7 +166,9 @@ SVector3 gmshFace::normal(const SPoint2 ¶m) const for(int i = 0; i < List_Nbr(_s->Generatrices); i++) { Curve *c; List_Read(_s->Generatrices, i, &c); - int N = (c->Typ == MSH_SEGM_LINE && List_Nbr(c->Control_Points) == 2) ? 1 : NP; + int N = (c->Typ == MSH_SEGM_LINE && List_Nbr(c->Control_Points) == 2) ? + 1 : + NP; for(int j = 0; j < N; j++) { double u1 = (double)j / (double)N; double u2 = (double)(j + 1) / (double)N; @@ -266,16 +265,12 @@ GPoint gmshFace::closestPoint(const SPoint3 &qp, double BN[2], UV[2]; for(int i = 0; i < 2; i++) { BN[i] = 0; - for(int k = 0; k < 3; k++) { - BN[i] += B[k] * M[k][i]; - } + for(int k = 0; k < 3; k++) { BN[i] += B[k] * M[k][i]; } } for(int i = 0; i < 2; i++) { for(int j = 0; j < 2; j++) { MN[i][j] = 0; - for(int k = 0; k < 3; k++) { - MN[i][j] += M[k][i] * M[k][j]; - } + for(int k = 0; k < 3; k++) { MN[i][j] += M[k][i] * M[k][j]; } } } sys2x2(MN, BN, UV); diff --git a/Geo/gmshLevelset.cpp b/Geo/gmshLevelset.cpp index 9c49bd33bd5cd1f1cd15b0b071e96e2986e18bab..ae34337bd3213ccd46410961a3f84f5905f5ca1e 100644 --- a/Geo/gmshLevelset.cpp +++ b/Geo/gmshLevelset.cpp @@ -36,7 +36,7 @@ bool gLevelsetLessThan::operator()(const gLevelset *l1, gLevelset *gLevelset::find(int tag) { gLevelset l(tag); - std::set<gLevelset *, gLevelsetLessThan>::iterator it = all_.find(&l); + auto it = all_.find(&l); if(it == all_.end()) return 0; return *it; } @@ -145,8 +145,7 @@ void computeLevelset(GModel *gm, cartesianBox<double> &box) { std::vector<SPoint3> nodes; std::vector<int> indices; - for(cartesianBox<double>::valIter it = box.nodalValuesBegin(); - it != box.nodalValuesEnd(); ++it) { + for(auto it = box.nodalValuesBegin(); it != box.nodalValuesEnd(); ++it) { nodes.push_back(box.getNodeCoordinates(it->first)); indices.push_back(it->first); } @@ -154,7 +153,7 @@ void computeLevelset(GModel *gm, cartesianBox<double> &box) // box.getLevel()); std::vector<double> dist, localdist; std::vector<SPoint3> dummy; - for(GModel::fiter fit = gm->firstFace(); fit != gm->lastFace(); fit++) { + for(auto fit = gm->firstFace(); fit != gm->lastFace(); fit++) { if((*fit)->geomType() == GEntity::DiscreteSurface) { for(std::size_t k = 0; k < (*fit)->getNumMeshElements(); k++) { std::vector<double> iDistances; @@ -240,12 +239,9 @@ inline double evalRadialFnDer(int p, int index, double dx, double dy, double dz, case 0: // GA switch(p) { case 0: return exp(-ep * ep * r2); - case 1: - return -2 * ep * ep * dx * exp(-ep * ep * r2); // _x - case 2: - return -2 * ep * ep * dy * exp(-ep * ep * r2); // _y - case 3: - return -2 * ep * ep * dz * exp(-ep * ep * r2); // _z + case 1: return -2 * ep * ep * dx * exp(-ep * ep * r2); // _x + case 2: return -2 * ep * ep * dy * exp(-ep * ep * r2); // _y + case 3: return -2 * ep * ep * dz * exp(-ep * ep * r2); // _z } case 1: // MQ switch(p) { @@ -573,7 +569,7 @@ double gLevelsetPoints::operator()(double x, double y, double z) const Msg::Info("Levelset Points : call computeLS() before calling operator()\n"); SPoint3 sp(x, y, z); - std::map<SPoint3, double>::const_iterator it = mapP.find(sp); + auto it = mapP.find(sp); if(it != mapP.end()) return it->second; printf("Levelset Points : Point not found\n"); return 0; @@ -625,9 +621,7 @@ void gLevelsetQuadric::Ax(const double x[3], double res[3], double fact) { for(int i = 0; i < 3; i++) { res[i] = 0.; - for(int j = 0; j < 3; j++) { - res[i] += A[i][j] * x[j] * fact; - } + for(int j = 0; j < 3; j++) { res[i] += A[i][j] * x[j] * fact; } } } @@ -773,11 +767,11 @@ double gLevelsetShamrock::operator()(double x, double y, double z) const dx = x - iso_x[0]; dy = y - iso_y[0]; double distance = sqrt(dx * dx + dy * dy); - std::vector<double>::const_iterator itx = iso_x.begin(); - std::vector<double>::const_iterator itxen = iso_x.end(); - std::vector<double>::const_iterator ity = iso_y.begin(); - std::vector<double>::const_iterator itminx = iso_x.begin(); - std::vector<double>::const_iterator itminy = iso_y.begin(); + auto itx = iso_x.begin(); + auto itxen = iso_x.end(); + auto ity = iso_y.begin(); + auto itminx = iso_x.begin(); + auto itminy = iso_y.begin(); itx++; ity++; for(; itx != itxen; itx++, ity++) { @@ -954,8 +948,7 @@ gLevelsetDistMesh::gLevelsetDistMesh(GModel *gm, const std::string &physical, { std::map<int, std::vector<GEntity *> > groups[4]; gm->getPhysicalGroups(groups); - for(GModel::piter it = gm->firstPhysicalName(); it != gm->lastPhysicalName(); - ++it) { + for(auto it = gm->firstPhysicalName(); it != gm->lastPhysicalName(); ++it) { if(it->second == physical) { _entities = groups[it->first.first][it->first.second]; } @@ -980,7 +973,7 @@ gLevelsetDistMesh::gLevelsetDistMesh(GModel *gm, const std::string &physical, } ANNpointArray nodes; nodes = annAllocPts(_all.size(), 3); - std::set<MVertex *>::iterator itp = _all.begin(); + auto itp = _all.begin(); int ind = 0; while(itp != _all.end()) { MVertex *pt = *itp; @@ -1016,9 +1009,7 @@ double gLevelsetDistMesh::operator()(double x, double y, double z) const for(int i = 0; i < _nbClose; i++) { int iVertex = index[i]; MVertex *v = _vertices[iVertex]; - for(std::multimap<MVertex *, MElement *>::const_iterator itm = - _v2e.lower_bound(v); - itm != _v2e.upper_bound(v); ++itm) { + for(auto itm = _v2e.lower_bound(v); itm != _v2e.upper_bound(v); ++itm) { elements.insert(itm->second); dimE = itm->second->getDim(); } @@ -1026,8 +1017,7 @@ double gLevelsetDistMesh::operator()(double x, double y, double z) const double minDistance = 1.e22; SPoint3 closestPoint; std::vector<MElement *> closestElements; - for(std::set<MElement *>::iterator it = elements.begin(); - it != elements.end(); ++it) { + for(auto it = elements.begin(); it != elements.end(); ++it) { double distance = 0.; MVertex *v1 = (*it)->getVertex(0); MVertex *v2 = (*it)->getVertex(1); diff --git a/Geo/gmshSurface.cpp b/Geo/gmshSurface.cpp index 6ce675bbf0dea788222c3b6420726c13c59c7e81..68939c5c3b21eb0ee63f188c11c504f968b739f2 100644 --- a/Geo/gmshSurface.cpp +++ b/Geo/gmshSurface.cpp @@ -50,7 +50,7 @@ gmshSurface *gmshSphere::NewSphere(int iSphere, double x, double y, double z, gmshSurface *gmshSurface::getSurface(int iSurface) { - std::map<int, gmshSurface *>::iterator it = allGmshSurfaces.find(iSurface); + auto it = allGmshSurfaces.find(iSurface); if(it == allGmshSurfaces.end()) { Msg::Error("gmshSurface %d does not exist", iSurface); return 0; diff --git a/Geo/gmshVertex.cpp b/Geo/gmshVertex.cpp index 573cac7f69e8ea688d21d77b9086141fbc4cde8b..64f06a64fd1fbfd19aa78a8cfc41075d31695190 100644 --- a/Geo/gmshVertex.cpp +++ b/Geo/gmshVertex.cpp @@ -12,8 +12,7 @@ #include "MVertex.h" #include "MPoint.h" -gmshVertex::gmshVertex(GModel *m, Vertex *v) - : GVertex(m, v->Num, v->lc), _v(v) +gmshVertex::gmshVertex(GModel *m, Vertex *v) : GVertex(m, v->Num, v->lc), _v(v) { gmshVertex::resetMeshAttributes(); } diff --git a/Geo/partitionEdge.h b/Geo/partitionEdge.h index f2899868822cde0a2ed057c2ab5e4671120edd15..7af06b23122ed9ec99c637078bb0dd91d417792e 100644 --- a/Geo/partitionEdge.h +++ b/Geo/partitionEdge.h @@ -21,8 +21,7 @@ public: _parentEntity(NULL) { } - partitionEdge(GModel *model, int num, - const std::vector<int> &partitions) + partitionEdge(GModel *model, int num, const std::vector<int> &partitions) : discreteEdge(model, num), _partitions(partitions), _parentEntity(NULL) { } @@ -39,10 +38,7 @@ public: { _partitions = partitions; } - virtual const std::vector<int> &getPartitions() const - { - return _partitions; - } + virtual const std::vector<int> &getPartitions() const { return _partitions; } virtual int getPartition(std::size_t index) const { return _partitions[index]; diff --git a/Geo/partitionFace.h b/Geo/partitionFace.h index d41c256f5ffdd7d9d3398aa370ae7ac7dac9d811..34187221446b0fc4dd8b3e0ddb08f5b02a54ec19 100644 --- a/Geo/partitionFace.h +++ b/Geo/partitionFace.h @@ -15,8 +15,7 @@ private: GEntity *_parentEntity; public: - partitionFace(GModel *model, int num, - const std::vector<int> &partitions) + partitionFace(GModel *model, int num, const std::vector<int> &partitions) : discreteFace(model, num), _partitions(partitions), _parentEntity(NULL) { } @@ -24,8 +23,7 @@ public: : discreteFace(model, num), _partitions(), _parentEntity(NULL) { } - partitionFace(GModel *model, - const std::vector<int> &partitions) + partitionFace(GModel *model, const std::vector<int> &partitions) : discreteFace(model), _partitions(partitions), _parentEntity(NULL) { } @@ -38,10 +36,7 @@ public: { _partitions = partitions; } - virtual const std::vector<int> &getPartitions() const - { - return _partitions; - } + virtual const std::vector<int> &getPartitions() const { return _partitions; } virtual int getPartition(std::size_t index) const { return _partitions[index]; diff --git a/Geo/partitionRegion.h b/Geo/partitionRegion.h index eda5932ad456c8addd267465fa3f900e72ce784c..45b39fe41b8fb7c6964d27f1c8b2437e33fd6ef4 100644 --- a/Geo/partitionRegion.h +++ b/Geo/partitionRegion.h @@ -15,8 +15,7 @@ private: GEntity *_parentEntity; public: - partitionRegion(GModel *model, int num, - const std::vector<int> &partitions) + partitionRegion(GModel *model, int num, const std::vector<int> &partitions) : discreteRegion(model, num), _partitions(partitions), _parentEntity(NULL) { } @@ -24,8 +23,7 @@ public: : discreteRegion(model, num), _partitions(), _parentEntity(NULL) { } - partitionRegion(GModel *model, - const std::vector<int> &partitions) + partitionRegion(GModel *model, const std::vector<int> &partitions) : discreteRegion(model), _partitions(partitions), _parentEntity(NULL) { } @@ -37,10 +35,7 @@ public: { _partitions = partitions; } - virtual const std::vector<int> &getPartitions() const - { - return _partitions; - } + virtual const std::vector<int> &getPartitions() const { return _partitions; } virtual int getPartition(std::size_t index) const { return _partitions[index]; diff --git a/Geo/partitionVertex.h b/Geo/partitionVertex.h index 2da51bfb9bd98575ce86decf38d82c29204a1e70..6f697c0141245e4d6751ba59f90dff0efacf9aea 100644 --- a/Geo/partitionVertex.h +++ b/Geo/partitionVertex.h @@ -15,8 +15,7 @@ private: GEntity *_parentEntity; public: - partitionVertex(GModel *model, int num, - const std::vector<int> &partitions) + partitionVertex(GModel *model, int num, const std::vector<int> &partitions) : discreteVertex(model, num), _partitions(partitions), _parentEntity(NULL) { } @@ -24,8 +23,7 @@ public: : discreteVertex(model, num), _partitions(), _parentEntity(NULL) { } - partitionVertex(GModel *model, - const std::vector<int> &partitions) + partitionVertex(GModel *model, const std::vector<int> &partitions) : discreteVertex(model), _partitions(partitions), _parentEntity(NULL) { } @@ -37,10 +35,7 @@ public: { _partitions = partitions; } - virtual const std::vector<int> &getPartitions() const - { - return _partitions; - } + virtual const std::vector<int> &getPartitions() const { return _partitions; } virtual int getPartition(std::size_t index) const { return _partitions[index]; diff --git a/Geo/scriptStringInterface.cpp b/Geo/scriptStringInterface.cpp index e7ab6dd4037bbf1fc86ae80289726ae3f869dcf1..1a142562bca472b9588c0a61f6f681a79d514bb7 100644 --- a/Geo/scriptStringInterface.cpp +++ b/Geo/scriptStringInterface.cpp @@ -28,8 +28,7 @@ static void scriptAddCommand(const std::string &text, const std::string &lang) { if(lang != "geo") { - if(!text.empty()) - printf("%s: %s\n", lang.c_str(), text.c_str()); + if(!text.empty()) printf("%s: %s\n", lang.c_str(), text.c_str()); return; } @@ -146,19 +145,18 @@ void scriptRemoveLastCommand(const std::string &fileName) buffer << t.rdbuf(); std::string s(buffer.str()); int found = (int)s.rfind("//+"); - if(found != (int)std::string::npos){ - s.erase(found); - } - else{ - Msg::Warning("Could not find last command in script `%s'", fileName.c_str()); + if(found != (int)std::string::npos) { s.erase(found); } + else { + Msg::Warning("Could not find last command in script `%s'", + fileName.c_str()); return; } FILE *fp = Fopen(fileName.c_str(), "w"); - if(fp){ + if(fp) { fprintf(fp, "%s", s.c_str()); fclose(fp); } - else{ + else { Msg::Error("Could not open file `%s'", fileName.c_str()); } OpenProject(fileName); @@ -488,9 +486,7 @@ void scriptDeleteField(int field_id, const std::string &fileName) { for(auto &lang : CTX::instance()->scriptLang) { std::ostringstream sstream; - if(lang == "geo") { - sstream << "Delete Field [" << field_id << "];"; - } + if(lang == "geo") { sstream << "Delete Field [" << field_id << "];"; } else { // TODO } @@ -502,9 +498,7 @@ void scriptSetBackgroundField(int field_id, const std::string &fileName) { for(auto &lang : CTX::instance()->scriptLang) { std::ostringstream sstream; - if(lang == "geo") { - sstream << "Background Field = " << field_id << ";"; - } + if(lang == "geo") { sstream << "Background Field = " << field_id << ";"; } else { // TODO } diff --git a/Geo/scriptStringInterface.h b/Geo/scriptStringInterface.h index 423b9d610b04b471d0b3a5aae9051b9f9503caf3..fce1f2cd65b8401f1e41c6280a6726171091e1e1 100644 --- a/Geo/scriptStringInterface.h +++ b/Geo/scriptStringInterface.h @@ -13,8 +13,7 @@ void scriptRemoveLastCommand(const std::string &fileName); void scriptSetFactory(const std::string &factory, const std::string &fileName); -void scriptSetMeshSize(const std::string &fileName, - const std::vector<int> &l, +void scriptSetMeshSize(const std::string &fileName, const std::vector<int> &l, const std::string &lc); void scriptRecombineSurface(const std::string &fileName, const std::vector<int> &l);